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(connHandle, &noti, FALSE)这个函数怎么用?



你好,首先谢谢你的回复。我想提的问题是,GATT_Notification(connHandle, &noti, FALSE)这个函数怎么用?我怎么没找到这个函数的定义。比如我定义了一个数组 unsigned int Send[260] = {......};怎么把这个数组的数据全部发送到上位机上。蓝牙4.0一帧最多能发多少个数据啊???

  • 你可以看看这个资料:http://txt.wenku.baidu.com/view/f92d9f277fd5360cba1adbe6.html

  • /*
    * Send Data
    */
    static void sendData(void )
    {

    static uint16 counter=0;
    uint8 burstData[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

    burstData[0] = (counter & 0xFF00)>>8;
    burstData[1] = (counter & 0xFF);


    attHandleValueNoti_t nData;
    nData.len = 20;
    nData.handle = 20;

    //skKeyPressed = *((uint8*)pValue);
    osal_memcpy( &nData.value, &burstData, 20 );

    // Send the Notification
    if (GATT_Notification( 0, &nData, FALSE )==SUCCESS)
    {
    counter++;
    }


    if(counter >1000) 
    {
    osal_stop_timerEx(simpleBLEPeripheral_TaskID,SBP_BURST_EVT);
    counter = 0;
    }

    }

    应用参考如上,260个字节的发送需要分包。每包20个字节。你可以在论坛搜索一下GATT_Notification .

    分包发送如下,这里 #define SBP_BURST_EVT_PERIOD                      7

    if ( events & SBP_BURST_EVT )
    {
    // Restart timer
    if ( SBP_BURST_EVT_PERIOD )
    {
    osal_start_timerEx( simpleBLEPeripheral_TaskID, SBP_BURST_EVT, SBP_BURST_EVT_PERIOD );
    }


    sendData();
    sendData();
    sendData();
    sendData();

    //burstData[0] = !burstData[0];
    return (events ^ SBP_BURST_EVT);
    }