最近把代码从1.3.2 升级到1.4.0 然后到1.4.1. 在从1.4.0 到1.4.1的过程中,发现centrlal 只能收到一个package, 然后就卡住了。
在simpleBLEcentralProcessGATTMsg里面读出从peripheral 发过来的数据包。其实是peripheral 不停的发20byte的包裹, 这个在BLE1.3.2 和BLE1.4.0里面测试都没有问题。
具体表现为:
1. 我从central 的 COM Port里面只能收到一个包裹然后就卡住了。
2. 我用package sniffer 去查找包裹,也是只发了一个notification, 然后就卡住不动了。然后就断开了。
具体central段的代码是这样的。我参考了simplecentral BLE1.4.1的code,在simpleCentralProcessGATTMsg 最后加了GATT_bm_free( &pMsg->msg, pMsg->method );
3. 我用lightblue去链接peripheral, 可以看到源源不断的收到包裹,所以perpheral 应该是没有问题的。
请大家给个思路吧,谢谢啦。
static void simpleBLECentralProcessGATTMsg( gattMsgEvent_t *pMsg )
{
if ( pMsg->method == ATT_HANDLE_VALUE_NOTI ||
pMsg->method == ATT_HANDLE_VALUE_IND )
{
if (pMsg->msg.handleValueNoti.handle ==0x004C) // 0x004D is the handle for the notification, 0x004C is the handle for the characteristic
{
attHandleValueNoti_t noti14;
noti14.handle = pMsg->msg.handleValueNoti.handle;
noti14.len = pMsg->msg.handleValueNoti.len;
osal_memcpy(¬i14.pValue, &pMsg->msg.handleValueNoti.pValue, noti14.len);
osal_memcpy(&char14buffer, ¬i14.pValue, noti14.len);
USBIO_WriteTransport(char14buffer,20);
USBPrintString("Receive14:");
}