低功耗蓝牙4.0BLE编程-nrf51822开发(10)-描述符
2024-08-22 14:58:53
特性中的属性有两种:属性值或描述符。
支持通知或指示的特性中默认有一个描述符:客户端特性配置描述符(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, , 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 = ; attr_md.wr_auth = ; attr_md.vlen = ; init_len = ble_srv_report_ref_encode(encoded_report_ref, p_bas_init->p_report_ref); memset(&attr_char_value, , 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 = ; 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; }
最新文章
- Keil>; 编译器特有的功能 >; 关键字和运算符 >; __weak
- Linux更改计算机名称
- PhpStorm 快捷键大全 PhpStorm 常用快捷键和配置
- Android搭建junit测环境
- 利用Spring的@Async异步处理改善web应用中耗时操作的用户体验
- Oracle 通过sql profile为sql语句加hint
- bzoj 1500: [NOI2005]维修数列 splay
- SpringMVC介绍之约定优于配置
- Keepalived+Lvs+Mysql主主复制
- hdu3516
- update和saveOrUpdate具体解释
- 【Win 10 应用开发】UI Composition 札记(三):与 XAML 集成
- ormlite介绍一
- Swift基础之UITabBarController(这是在之前UITableView中直接添加的)
- python可视化库 Matplotlib 00 画制简单图像
- Docker容器的基本了解和命令
- Java多线程系列3 synchronized 关键词
- process_begin: CreateProcess(NULL,......) make (e=87): 参数错误。
- vue给input file绑定函数获取当前上传的对象
- 【PyQt5 学习记录】006:重写窗口事件及QMessageBox
热门文章
- 玩转Android Camera开发(一):Surfaceview预览Camera,基础拍照功能完整demo
- xcode命令行编译时:codesign命令,抛出“User interaction is not allowed.”异常 的处理
- javascript优化--13模式1(DOM和浏览器模式)
- Regionals 2012 :: HangZhou
- Remainder
- Travelling
- HDU 2653 (记忆化BFS搜索+优先队列)
- silverlinght 项目
- C# - Try catch 中 使用 End()
- 清橙 A1206 小Z的袜子(莫队算法)