Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LTE] adds 1 retry for UDP/TCP socket send in case of error [ch18789] #1576

Merged
merged 1 commit into from Sep 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 23 additions & 14 deletions hal/src/electron/modem/mdm_hal.cpp
Expand Up @@ -52,6 +52,7 @@ std::recursive_mutex mdm_mutex;
#define PROFILE "0" //!< this is the psd profile used
#define MAX_SIZE 1024 //!< max expected messages (used with RX)
#define USO_MAX_WRITE 1024 //!< maximum number of bytes to write to socket (used with TX)
#define MDM_SOCKET_SEND_RETRIES (1) //!< maximum number of times to retry a socket send in case of error

// ID of the PDP context used to configure the default EPS bearer when registering in an LTE network
// Note: There are no PDP contexts in LTE, SARA-R4 uses this naming for the sake of simplicity
Expand Down Expand Up @@ -1987,13 +1988,17 @@ int MDMParser::socketSend(int socket, const char * buf, int len)
{
LOCK();
if (ISSOCKET(socket)) {
sendFormated("AT+USOWR=%d,%d\r\n",_sockets[socket].handle,blk);
if (RESP_PROMPT == waitFinalResp()) {
HAL_Delay_Milliseconds(50);
send(buf, blk);
if (RESP_OK == waitFinalResp())
ok = true;
}
uint8_t retry_num = 0;
do {
sendFormated("AT+USOWR=%d,%d\r\n",_sockets[socket].handle,blk);
if (RESP_PROMPT == waitFinalResp()) {
HAL_Delay_Milliseconds(50);
send(buf, blk);
if (RESP_OK == waitFinalResp()) {
ok = true;
}
}
} while(!ok && retry_num++ < MDM_SOCKET_SEND_RETRIES);
}
UNLOCK();
}
Expand Down Expand Up @@ -2075,13 +2080,17 @@ int MDMParser::socketSendTo(int socket, MDM_IP ip, int port, const char * buf, i
{
LOCK();
if (ISSOCKET(socket)) {
sendFormated("AT+USOST=%d,\"" IPSTR "\",%d,%d\r\n",_sockets[socket].handle,IPNUM(ip),port,blk);
if (RESP_PROMPT == waitFinalResp()) {
HAL_Delay_Milliseconds(50);
send(buf, blk);
if (RESP_OK == waitFinalResp())
ok = true;
}
uint8_t retry_num = 0;
do {
sendFormated("AT+USOST=%d,\"" IPSTR "\",%d,%d\r\n",_sockets[socket].handle,IPNUM(ip),port,blk);
if (RESP_PROMPT == waitFinalResp()) {
HAL_Delay_Milliseconds(50);
send(buf, blk);
if (RESP_OK == waitFinalResp()) {
ok = true;
}
}
} while(!ok && retry_num++ < MDM_SOCKET_SEND_RETRIES);
}
UNLOCK();
}
Expand Down