Skip to content

Commit

Permalink
Merge pull request #693 from spark/feature/electron-connection-behavior
Browse files Browse the repository at this point in the history
reduce socketSetBlocking timout and let URCs recv
  • Loading branch information
technobly committed Oct 14, 2015
2 parents 159dbc4 + 5f5035d commit 42c3f7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions hal/src/electron/modem/mdm_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ bool MDMParser::socketSetBlocking(int socket, system_tick_t timeout_ms)
{
bool ok = false;
LOCK();
DEBUG_D("socketSetBlocking(%d,%d)\r\n", socket,timeout_ms);
// DEBUG_D("socketSetBlocking(%d,%d)\r\n", socket,timeout_ms);
if (ISSOCKET(socket)) {
_sockets[socket].timeout_ms = timeout_ms;
ok = true;
Expand Down Expand Up @@ -1259,10 +1259,10 @@ int MDMParser::socketRecv(int socket, char* buf, int len)
ok = true;
}
} else if (!TIMEOUT(start, _sockets[socket].timeout_ms)) {
//DEBUG_D("socketRecv: WAIT FOR URCs\r\n");
// DEBUG_D("socketRecv: WAIT FOR URCs\r\n");
ok = (WAIT == waitFinalResp(NULL,NULL,0)); // wait for URCs
} else {
DEBUG_D("socketRecv: TIMEOUT\r\n");
// DEBUG_D("socketRecv: TIMEOUT\r\n");
len = 0;
ok = true;
}
Expand Down
4 changes: 2 additions & 2 deletions hal/src/electron/socket_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int32_t socket_connect(sock_handle_t sd, const sockaddr_t *addr, long addrlen)
ElectronMDM::IP ip = IPADR(addr_data[2], addr_data[3], addr_data[4], addr_data[5]);
electronMDM.socketSetBlocking(sd, 5000);
bool result = electronMDM.socketConnect(sd, ip, port);
electronMDM.socketSetBlocking(sd, 0);
return (result ? 0 : 1);
}

Expand All @@ -29,8 +30,7 @@ sock_result_t socket_reset_blocking_call()

sock_result_t socket_receive(sock_handle_t sd, void* buffer, socklen_t len, system_tick_t _timeout)
{
//electronMDM.socketSetBlocking(sd, _timeout);
electronMDM.socketSetBlocking(sd, 5000); // force a minimum 5 second timeout
electronMDM.socketSetBlocking(sd, _timeout);
return electronMDM.socketRecv(sd, (char*)buffer, len);
}

Expand Down

0 comments on commit 42c3f7d

Please sign in to comment.