Part Number: CC2640
Other Parts Discussed in Thread: CC2541,
I'm using the 2.2.1 SDK on the eval board. My application reads in about 250 bytes per second via the UART and sends it via notification messages to my phone app by calling SerialPortService_SetParameter() as shown below.
The UART driver simply copies the data into a 270 byte circular buffer and a 5 mS event pulls up to 80 bytes, 4 20-byte chunks, at a time and sends it to the phone. Our previous design used the CC2541 which was stable across all phone platforms including the Android 5.0 phone. We are currently upgrading to the CC2640 so I am getting the design running on the eval board first. The design is stable on Android 6 and IOS 10. When using Android 5 I can run for 10 to 15 seconds and then get a bleTimeout, return code 0x16, and the system is dead until I reconnect. If I modify the design to write only 2 20-byte buffers every 80 mS then it runs for longer but will occasionally stall for 30 seconds and then come back to life.
Questions:
- What causes the bleTimeout since I am sending notification messages to the phone?
- When I get the bleTimeout is there any way to recover?
- Why when I throttle back does the system stall for 30 seconds and then recovers?
Thanks,
John
Code snippet:
static bool PumpDataToPhone(void)
{
uint16 i;
uint16 uLen;
bStatus_t retVal;
bool bRtn;
bRtn = false;
if( s_uPhoneTxBuffHead != s_uPhoneTxBuffTail )
{
// We are active...
bRtn = true;
// Try to output 4 20 byte buffers...
for( i = 0; i < 4; i++)
{
if( s_uPhoneTxBuffHead > s_uPhoneTxBuffTail)
{
uLen = s_uPhoneTxBuffHead - s_uPhoneTxBuffTail;
}
else
{
uLen = sizeof(s_phoneTxBuff) - s_uPhoneTxBuffTail;
}
if(uLen > TX_PACKET_SIZE)
{
uLen = TX_PACKET_SIZE;
}
retVal = SerialPortService_SetParameter(SERIALPORTSERVICE_CHAR_DATA, uLen, &s_phoneTxBuff[s_uPhoneTxBuffTail]);
if(retVal == SUCCESS)
{
s_uPhoneTxBuffTail += uLen;
if(s_uPhoneTxBuffTail >= sizeof(s_phoneTxBuff))
{
s_uPhoneTxBuffTail = 0;
}
if(s_uPhoneTxBuffTail == s_uPhoneTxBuffHead)
{
// No more to send...
break;
}
}
else
{
Display_print1(dispHandle, 4, 0, "JDO Noti Err: %d", retVal);
break;
}
}
}
return(bRtn);
}