This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

GATT_Notification



使用2540 Ble协议栈

在SimpleBLEPeripheral工程中加入GATT_Notification,在工程HostTest中接收,能够用BTools看到数据,但是,不知道HostTest是怎么接收到的?是在那个函数里面响应了notification ?

  • 在master接收端, 如果你用的是simpleBLECentral   如果用的不是这个, 是自己写的代码的话, 也是类似.

    里面有比如simpleBLECentralProcessGATTMsg()函数, 就是在这里接收notification的.

    但是实例代码里面没有加notification的内容, 你可以自己加, 

    参考 else if ( pMsg->method == ATT_HANDLE_VALUE_IND )

    把ATT_HANDLE_VALUE_IND 换成 ATT_HANDLE_VALUE_NOTI, 然后再加相应处理.

    可以参考帖子 http://www.deyisupport.com.edgekey.net/question_answer/wireless_connectivity/bluetooth/f/103/p/20199/67878.aspx

  • 在周期函数中加入如下

    pReport.handle=0x2e;
    GAPRole_GetParameter(GAPROLE_CONNHANDLE,&noti_cHandle);
    pReport.len=1;
    pReport.pValue[0]=0x01;

    GATT_Notification(noti_cHandle,&pReport,FALSE);

    pReport.handle=0x2f;
    GAPRole_GetParameter(GAPROLE_CONNHANDLE,&noti_cHandle);
    pReport.len=1;
    pReport.pValue[0]=0x03;

    GATT_Notification(noti_cHandle,&pReport,FALSE);

    为什么Btool收不到数据呀???

  • 参考如下文档4.7节,首先要enable notication. 默认是关闭的。

    http://www.ti.com/lit/ug/swru270c/swru270c.pdf