6621D增加0x2901特性

eddy wen · 90次点击 · 6个月前

以下两个步骤可以完成增加0x2901特性:

1.

void add_user_description(uint16_t char_handle, uint16_t max_length, uint16_t *cud_handle)

{

    ble_gatts_attr_md_t attr_md;

    ble_gatts_attr_t cud_md;

    ble_uuid_t cud_uuid;

    BLE_UUID_BLE_ASSIGN(cud_uuid, BLE_UUID_DESCRIPTOR_CHAR_USER_DESC);

    memset(&cud_md, 0, sizeof(cud_md));

    cud_md.p_uuid = &cud_uuid;

    cud_md.max_len = max_length;

    cud_md.p_attr_md = &attr_md;

    memset(&attr_md, 0, sizeof(attr_md));

    attr_md.vloc = BLE_GATTS_VLOC_STACK;

    sd_ble_gatts_descriptor_add(char_handle, &cud_md, cud_handle);

}

2.

   在sd_ble_gatts_characteristic_add函数调用之后添加这些语句:

    uint16_t cud_handle;

    add_user_description(handles.value_handle, 10, &cud_handle);//10表示长度这里固定为10个字节

    ble_gatts_value_t value = {

        5,

        0,

        (uint8_t*)"Hello"

    };

    sd_ble_gatts_value_set(0, cud_handle, &value);


被收藏 0  ∙  0 赞  
加入收藏
点赞
0 回复  
善言善语 (您需要 登录 后才能回复 没有账号 ?)

请先登录网站