hi dialog
According to the Bluetooth 4.0 specification Vol 3 Part F 3.4.7.1"If the attribute value is longer than (ATT_MTU–3) octets, then only the first (ATT_MTU–3) octets of this attributes value can be sent in a notification."
when attribute value is longer than (ATT_MTU–3) ,I can get max (ATT_MTU–3) octets .
1step
I found "ble_app_peripheral "project
#define DEF_CUST1_LONG_VALUE_CHAR_LEN 50
2step
[add]@file user_custs_config.h
#define DEF_CUST1_BETA_VAL_1_UUID_128 {0x27, 0x68, 0xEC, 0x52, 0x1E, 0x62, 0x44, 0x74, 0x9A, 0x1B, 0xD1, 0x8B, 0xAB, 0x75, 0xB6, 0x6E}
#define DEF_CUST1_BETA_VAL_2_UUID_128 {0x28, 0x68, 0xEC, 0x52, 0x1E, 0x62, 0x44, 0x74, 0x9A, 0x1B, 0xD1, 0x8B, 0xAB, 0x75, 0xB6, 0x6E}
#define DEF_CUST1_WORD_VAL_1_CHAR_LEN 30
#define DEF_CUST1_WORD_VAL_2_CHAR_LEN 30
#define CUST1_WORD_VAL_1_USER_DESC "word Value1"
#define CUST1_WORD_VAL_2_USER_DESC "word Value2"
enum
{
CUST1_IDX_SVC = 0,
....
CUST1_IDX_WORD_VAL_1_CHAR,
CUST1_IDX_WORD_VAL_1_VAL,
CUST1_IDX_WORD_VAL_1_USER_DESC,
CUST1_IDX_WORD_VAL_2_CHAR,
CUST1_IDX_WORD_VAL_2_VAL,
CUST1_IDX_WORD_VAL_2_USER_DESC,
CUST1_IDX_NB
}
static uint8_t CUST1_WORD_VAL_1_UUID_128[ATT_UUID_128_LEN] = DEF_CUST1_WORD_VAL_1_UUID_128;
static uint8_t CUST1_WORD_VAL_2_UUID_128[ATT_UUID_128_LEN] = DEF_CUST1_WORD_VAL_2_UUID_128;
static const struct att_char128_desc custs1_word_val_1_char = {ATT_CHAR_PROP_WR_NO_RESP,
{0, 0},
DEF_CUST1_WORD_VAL_1_UUID_128};
static const struct att_char128_desc custs1_word_val_2_char = {ATT_CHAR_PROP_RD,
{0, 0},
DEF_CUST1_WORD_VAL_2_UUID_128};
static const struct attm_desc_128 custs1_att_db[CUST1_IDX_NB] =
{
// WORD Value 1 Characteristic Declaration
[CUST1_IDX_WORD_VAL_1_CHAR] ={(uint8_t*)&att_dec1_char, ATT_UUID_16_LEN, PERM(RD, ENABLE),
sizeof(custs1_word_val_1_char), sizeof(custs1_word_val_1_char), (uint8_t*)&custs1_word_val_1_char},
// WORD Value 1 Characteristic Value
[CUST1_IDX_WORD_VAL_1_VAL] = {CUST1_WORD_VAL_1_UUID_128, ATT_UUID_128_LEN, PERM(WR, ENABLE) ,
DEF_CUST1_WORD_VAL_1_CHAR_LEN, 0, NULL},
// WORD Value 1 Characteristic User Description
[CUST1_IDX_WORD_VAL_1_USER_DESC] = {(uint8_t*)&att_dec1_user_desc, ATT_UUID_16_LEN, PERM(RD, ENABLE),
sizeof(CUST1_WORD_VAL_1_USER_DESC) - 1, sizeof(CUST1_WORD_VAL_1_USER_DESC) - 1, CUST1_WORD_VAL_1_USER_DESC},
// WORD Value 2 Characteristic Declaration
[CUST1_IDX_WORD_VAL_2_CHAR] = {(uint8_t*)&att_dec1_char, ATT_UUID_16_LEN, PERM(RD, ENABLE),
sizeof(custs1_word_val_2_char), sizeof(custs1_word_val_2_char), (uint8_t*)&custs1_word_val_2_char},
// WORD Value 2 Characteristic Value
[CUST1_IDX_WORD_VAL_2_VAL] = {CUST1_WORD_VAL_1_UUID_128, ATT_UUID_128_LEN, PERM(RD, ENABLE) ,
DEF_CUST1_WORD_VAL_2_CHAR_LEN, 0, NULL},
// WORD Value 2 Characteristic User Description
[CUST1_IDX_WORD_VAL_2_USER_DESC] = {(uint8_t*)&att_dec1_user_desc, ATT_UUID_16_LEN, PERM(RD, ENABLE),
sizeof(CUST1_WORD_VAL_2_USER_DESC) - 1, sizeof(CUST1_WORD_VAL_2_USER_DESC) - 1, CUST1_WORD_VAL_2_USER_DESC},
};
3step
[添加] @file user_custs1_impl.c
void user_custs1_word_1_wr_ind_handler(ke_msg_id_t const msgid,
struct custs1_val_write_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
uint8_t val = 0;
struct custs1_val_set_req* req = KE_MSG_ALLOC_DYN(CUSTS1_VAL_SET_REQ,
TASK_CUSTS1,
TASK_APP,
custs1_val_set_req,
DEF_CUST1_WORD_VAL_2_CHAR_LEN);
req->conhdl = app_env->conhdl;
req->handle = CUST1_IDX_WORD_VAL_2_VAL;
req->length = DEF_CUST1_WORD_VAL_2_CHAR_LEN;
memcpy(req->value, ¶m->value[0], param->length);
ke_msg_send(req);
}
4step@fileuser_peripheral.c
void user_catch_rest_hndl(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
switch(msgid)
{
case CUSTS1_VAL_WRITE_IND:
{
struct custs1_val_write_ind const *msg_param = (struct custs1_val_write_ind const *)(param);
交换机(msg_param->句柄)
{
....
case CUST1_IDX_WORD_VAL_1_VAL:
{
user_custs1_word_1_wr_ind_handler(msgid, msg_param, dest_id, src_id);
}
break;
default:
break;
}
}
Hi libra_13179,
I am not sure i undestand the question. Yes thats true, if the characteristic is larger that the default MTU through notifications you are going to be able to send only ATT_MTU-3. If you want to send larger notifications you have to issue an mtu request.
Check this post for more informationhttp://support.dialog-semiconductor.com/when-i-enable-notification-chara...
Thanks MT_dialog