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.

华为手机连接 CC2540 数据丢包,有些 连接几秒钟便自动断开,麻烦工程师回复一下,谢谢!

Other Parts Discussed in Thread: CC2540

TI工程师以及大家好,我们公司在做蓝牙胎心仪,用的是CC2540,传输速率是  20ms传输 25个字节一包数据,由于传输一包数据大于20,所以分为两包传输,第一包传 20个字节,第二个传输5个字节,传输方式是Notify,具体实现如下:

if( gapProfileState == GAPROLE_CONNECTED )
{
Uart_SendFlag = 0;
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint8), &uartbuf);
Uart_SendFlag = 1;
for(i=0;i<10;i++);
SimpleProfile_SetParameter( SIMPLEPROFILE_CHAR4, sizeof(uint8), &uartbuf);
}

Uart_SendFlag 为0发送第一包数据,为1发送第二包数据

if(Uart_SendFlag == 0)
{
*pLen = 20;
pValue[0] = uartbuf[0];
pValue[1] = uartbuf[1];
pValue[2] = uartbuf[2];
pValue[3] = uartbuf[3];
pValue[4] = uartbuf[4];
pValue[5] = uartbuf[5];
pValue[6] = uartbuf[6];
pValue[7] = uartbuf[7];
pValue[8] = uartbuf[8];
pValue[9] = uartbuf[9];
pValue[10] = uartbuf[10];
pValue[11] = uartbuf[11];
pValue[12] = uartbuf[12];
/**/pValue[13] = uartbuf[13];
pValue[14] = uartbuf[14];
pValue[15] = uartbuf[15];
pValue[16] = uartbuf[16];
pValue[17] = uartbuf[17];
pValue[18] = uartbuf[18];
pValue[19] = uartbuf[19];
}
else if(Uart_SendFlag == 1)
{
*pLen = 5;
pValue[0] = uartbuf[20];
pValue[1] = uartbuf[21];
pValue[2] = uartbuf[22];
pValue[3] = uartbuf[23];
pValue[4] = uartbuf[24];
}