如何处理属性值比(ATT_MTU-3) (SDK5)长

2个职位/ 0个新职位
最后发表
libra_13179
离线
最后看到:5年3个星期前
加入:2015-06-16有机会
如何处理属性值比(ATT_MTU-3) (SDK5)长

嗨对话框
根据蓝牙4.0规范第3卷第F部分3.4.7.1“如果属性值大于(ATT_MTU-3)字节,那么只有该属性值的第一个(ATT_MTU-3)字节才能发送通知。”
当属性值大于(ATT_MTU-3)时,我可以得到max (ATT_MTU-3)字节。
1步
我找到了“ble_app_peripheral”项目
#定义DEF_CUST1_LONG_VALUE_CHAR_LEN 50
2步
【添加】@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}

#定义DEF_CUST1_WORD_VAL_1_CHAR_LEN 30
#定义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"

枚举

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},
DEF_CUST1_WORD_VAL_1_UUID_128};

static const struct att_char128_desc custs1_word_val_2_char = {ATT_CHAR_PROP_RD,
{0},
DEF_CUST1_WORD_VAL_2_UUID_128};
static const struct attm_desc_128 custs1_att_db[CUST1_IDX_NB] =

// WORD值1特征声明
[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特征值
[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零},

// WORD值1特征用户描述
[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值2特征声明
[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值2特征值
[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零},

// WORD值2特征用户描述
[CUST1_IDX_WORD_VAL_2_USER_DESC] = {(uint8_t*)&att_dec1_user_desc, ATT_UUID_16_LEN, PERM(RD, ENABLE),
sizeof(cust1_word_val_user_desc) - 1, sizeof(cust1_word_val_user_desc) - 1, cust1_word_val_user_desc},

};

3步
【添加】@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;
结构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);
申请- > conhdl = app_env - > conhdl;
申请- >处理= CUST1_IDX_WORD_VAL_2_VAL;
申请- >长度= DEF_CUST1_WORD_VAL_2_CHAR_LEN;
memcpy(请求- >值,参数[0]- >值,参数- >长度);
ke_msg_send(要求的);


4 step@fileuser_peripheral.c
Void user_catch_rest_hndl(ke_msg_id_t const msgid,
空白const *参数,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)

开关(是否)

案例CUSTS1_VAL_WRITE_IND:

Struct custs1_val_write_ind const *msg_param = (Struct custs1_val_write_ind const *)(param);

开关(msg_param - >处理)

....
案例CUST1_IDX_WORD_VAL_1_VAL:

User_custs1_word_1_wr_ind_handler (msgid, msg_param, dest_id, src_id);

打破;
默认值:
打破;

关键词:
设备:
MT_dialog
离线
最后看到:7个月1天前
工作人员
加入:2015-06-08 34
嗨libra_13179,

嗨libra_13179,

我不能肯定我理解了这个问题。是的,这是真的,如果特征是更大的默认MTU通过通知,你将只能发送ATT_MTU-3。如果想发送较大的通知,就必须发出mtu请求。

查看这篇文章获取更多信息http://support.dialog-semiconductor.com/when-i-enable-notification-chara..。

由于MT_dialog