请问有没有CC2540 BLE 数据收发的详细流程说明
一直在研究SimpleBLECentral和SimpleBLEPeripheral,但是对收发数据的流程一直没搞明白,请问有没有CC2540 BLE 数据收发的详细流程说明?
谢谢。
BLE-STACK文档中TI_BLE_Software_Developer's_Guide.pdf.
说简单点,先discovery(GAPCentralRole_StartDiscovery),回调中处理simpleBLECentralStartDiscovery(),通过UUID找到对应的handle,handle就是
attribute的地址,然后就可以使用GATT_WriteCharValue()或GATT_ReadCharValue()像指定的handle发送读写操作。最后在simpleBLECentralProcessGATTMsg()处理操作结果。还有另外一种通讯方式是notification,就是server主动向Client发送数据,不同于上面这种request/response模式,附图如下。
请问在BLE-CC254x-1.3中找不到GATT_Notification(),他是不是被加到BLE Library中去了,那么留给用户调用的相应API是哪个?
GATTServApp_ProcessCharCfg()
请给出正确的确认,谢谢。
请问GATTServApp_ProcessCharCfg()是不是只支持写数据,不支持读数据?
notification类似主动上报,数据的变化可以直接从server通知给client.你得先搞清楚这两种不同的通讯方式。
1.client ->server
client 发request到server,server 回应response.读写都行。
2.server->client.
server主动发notification给Client 反映自己的属性变化。这根读写没关系吧。
server- 有数据的. client- 访问数据的。不论是mater还是slaver都可以是server或client,甚至既可以是server同时又是client.
“另外一种通讯方式是notification,就是server主动向Client发送数据”。我看代码上好像是要先判断notification是否被使能通知,没使能的话是不通知吗?如何使能通知呢?用哪个接口函数?谢谢!
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".
GATT_WriteNoRsp( connHandle, &writeReq, taskId );? or GATT_WriteNoRsp( connHandle, &writeReq,);?
这个函数只有两参数,不知道为什么技术人员要给写出3个参数。打开notity功能我也试验了好久都没弄好。
extern bStatus_t GATT_WriteNoRsp( uint16 connHandle, attWriteReq_t *pReq );