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包后再丢一包,这种情况是为什么呢?

当前的连接间隔:

Fullscreen
1
2
3
4
5
6
7
// 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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

发送代码:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//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);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

发送Notify的代码:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX