分享

CC2540master与Slave通信问题

 iamlijin 2019-09-16

notification刚开始都是关闭的,你需要通过主机发送如下命令enable.

To enable notifications, you must write a value of 0x0001 to the client characteristic configuration descriptor (CCCD). If you know the handle of the client characteristic descriptor, you can enable notifications by using the following code:

  attWriteReq_t writeReq;
  uint16 connHandle = connectionHandle;  // this will always be 0 if device only ever has one connection at a time

  writeReq.handle = handleOfCCCD; // if you know the value, you can put it in as a fixed value;
                                  // otherwise you will need to first discover the value
  writeReq.len = 2;
  writeReq.value[0] = LO_UINT16(GATT_CLIENT_CFG_NOTIFY);
  writeReq.value[1] = HI_UINT16(GATT_CLIENT_CFG_NOTIFY);
  writeReq.sig = 0;
  writeReq.cmd = 1;
 
  GATT_WriteNoRsp( connHandle, &writeReq, taskId );

Before doing this, you may also need to discover the handle of the CCCD. Some example of this process can be found in the TimeApp project which is included in the SDK. Specifically, look in the file 'timeapp_discovery.c

www.deyisupport.com

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多