嗨对话框
根据蓝牙4.0规范Vol 3 Part F 3.4.7.1“如果属性值大于(ATT_MTU-3)字节,则只能在通知中发送该属性值的第一个字节(ATT_MTU-3)。”
当属性值大于(ATT_MTU-3)时,我可以获得最大(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
#定义CUST1_WORD_VAL_1_USER_DESC "word Value1"
#定义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_2uuid_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值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),
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),
(CUST1_WORD_VAL_2_USER_DESC) - 1, CUST1_WORD_VAL_2_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;
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);
申请- > 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);
}
打破;
默认值:
打破;
}
}
嗨libra_13179,
我不太明白你的问题。是的,这是真的,如果特征是更大的默认MTU通过通知,你将只能发送ATT_MTU-3。如果你想发送更大的通知,你必须发出一个mtu请求。
查看这篇文章获得更多信息http://support.dialog-semiconductor.com/when-i-enable-notification-chara..。
由于MT_dialog