特性中的属性有两种:属性值或描述符。

支持通知或指示的特性中默认有一个描述符:客户端特性配置描述符(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;
}  

最新文章

  1. Keil> 编译器特有的功能 > 关键字和运算符 > __weak
  2. Linux更改计算机名称
  3. PhpStorm 快捷键大全 PhpStorm 常用快捷键和配置
  4. Android搭建junit测环境
  5. 利用Spring的@Async异步处理改善web应用中耗时操作的用户体验
  6. Oracle 通过sql profile为sql语句加hint
  7. bzoj 1500: [NOI2005]维修数列 splay
  8. SpringMVC介绍之约定优于配置
  9. Keepalived+Lvs+Mysql主主复制
  10. hdu3516
  11. update和saveOrUpdate具体解释
  12. 【Win 10 应用开发】UI Composition 札记(三):与 XAML 集成
  13. ormlite介绍一
  14. Swift基础之UITabBarController(这是在之前UITableView中直接添加的)
  15. python可视化库 Matplotlib 00 画制简单图像
  16. Docker容器的基本了解和命令
  17. Java多线程系列3 synchronized 关键词
  18. process_begin: CreateProcess(NULL,......) make (e=87): 参数错误。
  19. vue给input file绑定函数获取当前上传的对象
  20. 【PyQt5 学习记录】006:重写窗口事件及QMessageBox

热门文章

  1. 玩转Android Camera开发(一):Surfaceview预览Camera,基础拍照功能完整demo
  2. xcode命令行编译时:codesign命令,抛出“User interaction is not allowed.”异常 的处理
  3. javascript优化--13模式1(DOM和浏览器模式)
  4. Regionals 2012 :: HangZhou
  5. Remainder
  6. Travelling
  7. HDU 2653 (记忆化BFS搜索+优先队列)
  8. silverlinght 项目
  9. C# - Try catch 中 使用 End()
  10. 清橙 A1206 小Z的袜子(莫队算法)