低功耗蓝牙4.0BLE编程-nrf51822开发(10)-描述符
来源:互联网 发布:mac图片放大快捷键 编辑:程序博客网 时间:2024/06/12 19:17
特性中的属性有两种:属性值或描述符。
支持通知或指示的特性中默认有一个描述符:客户端特性配置描述符(Client Characteristic Configuration Descriptor,CCCD)。它的UUID是0x2902。
添加描述符的函数是:
- uint32_t sd_ble_gatts_descriptor_add ( uint16_t char_handle,
- ble_gatts_attr_t const *const p_attr,
- uint16_t *const p_handle
- )
Parameters
[in]
char_handle
Handle of the characteristic where the descriptor is to be placed, if BLE_GATT_HANDLE_INVALID is used, it will be placed sequentially.
[in]
p_attr
Pointer to the attribute structure.
[out]
p_handle
Pointer to a 16-bit word where the assigned handle will be stored.
示例代码:
- BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_REPORT_REF_DESCR);
- memset(&attr_md, 0, sizeof(attr_md));
- attr_md.read_perm = p_bas_init->battery_level_report_read_perm;
- BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm);
- attr_md.vloc = BLE_GATTS_VLOC_STACK;
- attr_md.rd_auth = 0;
- attr_md.wr_auth = 0;
- attr_md.vlen = 0;
- init_len = ble_srv_report_ref_encode(encoded_report_ref, p_bas_init->p_report_ref);
- memset(&attr_char_value, 0, sizeof(attr_char_value));
- attr_char_value.p_uuid = &ble_uuid;
- attr_char_value.p_attr_md = &attr_md;
- attr_char_value.init_len = init_len;
- attr_char_value.init_offs = 0;
- attr_char_value.max_len = attr_char_value.init_len;
- attr_char_value.p_value = encoded_report_ref;
- err_code = sd_ble_gatts_descriptor_add(p_bas->battery_level_handles.value_handle,
- &attr_char_value,
- &p_bas->report_ref_handle);
- if (err_code != NRF_SUCCESS)
- {
- return err_code;
- }
0 0
- 低功耗蓝牙4.0BLE编程-nrf51822开发(10)-描述符
- 低功耗蓝牙4.0BLE编程-nrf51822开发(10)-描述符
- 低功耗蓝牙4.0BLE编程-nrf51822开发(10)-描述符
- 低功耗蓝牙4.0BLE编程-nrf51822开发(1)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(2)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(3)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(4)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(5)-链路层
- 低功耗蓝牙4.0BLE编程-nrf51822开发(8)-GATT
- 低功耗蓝牙4.0BLE编程-nrf51822开发(9)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(1)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(2)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(3)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(4)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(5)-链路层
- 低功耗蓝牙4.0BLE编程-nrf51822开发(8)-GATT
- 低功耗蓝牙4.0BLE编程-nrf51822开发(9)
- 低功耗蓝牙4.0BLE编程-nrf51822开发(1)
- xmpp with openfire插件-利用Broadcast实现群
- 使用WebView显示网页
- 低功耗蓝牙4.0BLE编程-nrf51822开发(9)
- 关于hibernate session
- 设计模式-观察者设计模式
- 低功耗蓝牙4.0BLE编程-nrf51822开发(10)-描述符
- 设置附件的MIME
- java笔记
- 简单易懂地理解------怎样理解阻塞非阻塞与同步异步的区别?
- android给listview的item设定高度
- 低功耗蓝牙4.0BLE编程-nrf51822开发(11)-蓝牙串口代码分析
- 简单的红包分配算法
- 如何将SDK中的ApiDemos导入android手机中
- 读《失业的程序员》笔记----上