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.

CC2640R2 Notify发送结束后的事件通知



Example中通过SimpleProfile_SetParameter()来执行Notify,我想要知道的是,调用SimpleProfile_SetParameter()之后,怎样知道这一包数据已经发送出去,会否会有相应的事件或callback ?


  • case SIMPLEPROFILE_CHAR4:
    if ( len<SIMPLEPROFILE_CHAR4_LEN)
    {
    VOID memcpy( simpleProfileChar4, value, SIMPLEPROFILE_CHAR4_LEN );

    // See if Notification has been enabled
    GATTServApp_ProcessCharCfg( simpleProfileChar4Config, simpleProfileChar4, FALSE,
    simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ),
    INVALID_TASK_ID, simpleProfile_ReadAttrCB );
    }

    你可以对GATTServApp_ProcessCharCfg进行返回值判断

  • 实际上是设置了一个新的值,但是打开了notification会上报这个变化。
  • GATTServApp_ProcessCharCfg()返回的是Success or Failure,应该只是调用这个API的状态返回,即使返回Success应该也不能说明这一包数据已经发出去了,可能只是存在了队列中而已。 否则GATTServApp_ProcessCharCfg()这个API就会造成block,必须等到发送结束才会继续往下执行。
  • 你notify只能用api,对于底层没有开源。
    你仔细去看看GATTServApp_ProcessCharCfg 最后还是调用了GATT_Notification。
    返回值有如下:
    * @return @ref SUCCESS : Notification was queued successfully.
    * @return @ref INVALIDPARAMETER
    * @return @ref MSG_BUFFER_NOT_AVAIL
    * @return @ref bleNotConnected
    * @return @ref bleMemAllocError
    * @return @ref bleInvalidMtuSize : Packet length is larger than connection's MTU size.
    * @return @ref bleTimeout : Previous transaction timed out.
    通常情况下只要你不是阻塞,加一定的ms延时就可以去再次发送。

    在我们的 throughput_example_peripheral就是如下用法没有问题。

    noti.pValue = (uint8 *)GATT_bm_alloc( connectionHandle, ATT_HANDLE_VALUE_NOTI, GATT_MAX_MTU, &len );

    if ( noti.pValue != NULL ) //if allocated
    {

    // Place index
    noti.pValue[0] = (msg_counter >> 24) & 0xFF;
    noti.pValue[1] = (msg_counter >> 16) & 0xFF;
    noti.pValue[2] = (msg_counter >> 8) & 0xFF;
    noti.pValue[3] = msg_counter & 0xFF;

    // Attempt to send the notification
    status = GATT_Notification( connectionHandle, &noti, GATT_NO_AUTHENTICATION);
    if ( status != SUCCESS ) //if noti not sent
    {
    PIN_setOutputValue(hSbpPins, Board_LED1 , Board_LED_ON);
    GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
    }
    else
    {
    // Notification is successfully sent, increment counters
    PIN_setOutputValue(hSbpPins, Board_LED2 , Board_LED_ON);
    msg_counter++;
    }
    }
    else
    {
    // bleNoResources was returned
    asm(" NOP ");
    }