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.

CC2640R2L: 通过BLE间隔10ms通过Notify发送一包数据,存在丢包情况

Part Number: CC2640R2L

使用BLE的Notify功能,通过定时器每隔10ms向手机发送一包数据,每包数据20字节,发送大约4000包后出现丢包情况,每次丢1包,再次发送大约2000包后再丢一包,这种情况是为什么呢?

当前的连接间隔:

// Minimum connection interval (units of 1.25ms, 80=100ms) for automatic
// parameter update request
#define DEFAULT_DESIRED_MIN_CONN_INTERVAL     16    //20

// Maximum connection interval (units of 1.25ms, 800=1000ms) for automatic
// parameter update request
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL     32    //40

发送代码:

        //10ms
        if (events & KFD_DATA_RECV_DELAY_EVT)
        {
            events &= ~KFD_DATA_RECV_DELAY_EVT;

            Util_startClock(&dataRecvDelayClock);

            if(tempTimes>=199)
            {
                Util_stopClock(&dataRecvDelayClock);
            }
            tempTimes++;
            Pfd_ServApp_SendNotiInd(&tempdata[0],20);
        }

发送Notify的代码:

bStatus_t Pfd_ServApp_SendNotiInd(uint8_t *nvalue, uint16_t nlen)
{
    attHandleValueNoti_t noti;
    uint16_t slen;
    bStatus_t status;
    slen  = nlen;

    gattCharCfg_t *pItem = Pfd_ProfileChar4Config;
    if(PFDexConnected)
    {
        pItem->connHandle = Pfd_CCC_Handle;
    }

    if  ( pItem->connHandle != INVALID_CONNHANDLE )
    {
        //check the notify CCCD open of not
        if (!GATTServApp_ReadCharCfg(pItem->connHandle, Pfd_ProfileChar4Config))
        {

            GATTServApp_WriteCharCfg(pItem->connHandle,Pfd_ProfileChar4Config,1);
        }
        //the above added by lining
        noti.pValue = (uint8 *)GATT_bm_alloc( pItem->connHandle, ATT_HANDLE_VALUE_NOTI,slen,&slen);
        //                                            GATT_MAX_MTU, &slen );
        if ( noti.pValue != NULL )                //申请到了地址。=NULL说明没申请到地址
        {
            noti.handle =  Pfd_ProfileAttrTbl[2].handle;
            noti.len = slen;
            memcpy(noti.pValue, nvalue, slen);
            // CCCD enabled, send notification
            status = GATT_Notification( pItem->connHandle, &noti, FALSE );

            if ( status != SUCCESS )
            {
                GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
            }
        }
        else
        {
            GATT_bm_free( (gattMsg_t *)&noti, ATT_HANDLE_VALUE_NOTI );
            status = bleNoResources;
        }
    }

    return ( status );
}