Tool/software:
Hello Community,
I have OTA update in my custom application. The update file (.tar) is on the server.
Sometime during the update, I get SLNETERR_BSD_EAGAIN error. This happens when server does not respond before socket timeout.
I have set the socket timeout to 5 seconds and I think this is enough time for server to respond.
SLNETERR_BSD_EAGAIN error means trying again, but in ProcessOta(), when this error comes it will stop the OTA update giving error message "OTA_NOTIF_DOWNLOAD_ERROR".
To avoid this, I am retrying to get the missing packet by calling the GetChunk callback again, as you can also see in the code snippet below.
For the test, I kept the number of retry attempts to 10.
The problem is that if I don't keep the sleep time between attempts, I get the same socket timeout error consecutively, and all my retry attempts will elapse.
By keeping this sleep time, I still get this error but will not cross the retry attempts.
My question is, why this sleep time is required?
Could it be that the NWP processor is busy and not responding to the requests in time?
I am not able to understand this behaviour.
The below code snippet is from the file ota_if.c from function ProcessOta()
do
{
/* Now, fill the rest of the buffer (using GetChunk Callback) */
rc = m_sessionCBs[m_ota.type].fGetChunk(m_ota.hSession, &m_ota.buff[nUnprocessed], OTA_BUFF_SIZE-nUnprocessed);
if(rc > 0)
{
/* Update counters with the actual number of bytes read */
m_ota.nTotalRead += rc;
nUnprocessed += rc;
ui8RetryCnt = 0;
LOG_DEBUG("ProcessOta:: read=%d (%d)", rc, m_ota.nTotalRead);
}
else if(rc == 0)
{
/* mark end of input */
bEndOfInput = true;
LOG_DEBUG("ProcessOta:: read=0 (%d)", m_ota.nTotalRead);
}
else if((rc == SLNETERR_BSD_EAGAIN) && (ui8RetryCnt < OTA_PACKET_RETRY_COUNT))
{
LOG_WARNING("ProcessOta:: Socket did not respond and trying again!");
sleep(1);
}
else
{
LOG_ERROR("ProcessOta: ---- Can't get next chunk (%d)", rc);
return rc;
}
ui8RetryCnt++;
if(ui8RetryCnt > OTA_PACKET_RETRY_COUNT)
{
break;
}
}
while(rc == SLNETERR_BSD_EAGAIN);