添加服务,属性列表不显示添加的服务?

来源:互联网 发布:scratch创意编程 pdf 编辑:程序博客网 时间:2024/06/12 20:07

在做添加服务的时候,手机端app(BLE TOOL)显示属性列表不显示添加的服务。

查找问题的顺序:

1. 查看任务初始化的时候,有没有注册服务?

/ CLH GATT Profile 添加服务
 ClhProfile_AddService(GATT_ALL_SERVICES); //读写的回调函数

如果注册了,查看第二步,

2. 进入ClhProfile_AddService()函数,查看函数GATTServApp_RegisterService()有没有执行到,并且返回值是SUCCESS?如果是SUCCESS,转第三步。

// Register GATT attribute list and CBs with GATT Server App

status = GATTServApp_RegisterService( clhProfileAttrTbl, GATT_NUM_ATTRS( clhProfileAttrTbl ),&clhProfileCBs );

3.查看attribute表,即clhProfileAttrTbl。查看clhProfileAttrTbl的第一组数据。 这是服务,将permissions 一定要设为GATT_PERMIT_READ,我就是不小心设置成GATT_PERMIT_WRITE,才导致不能显示服务。

// clh Profile Service
  { 
    { ATT_BT_UUID_SIZE, primaryServiceUUID }, /* type */
      GATT_PERMIT_READ,                      /* permissions */
    0,                                        /* handle */
    (uint8 *)&clhProfileService               /* pValue */
  },


总结,遇到问题,要回找问题。明白机制,就容易。明白约定。

原创粉丝点击