Skip to content

Commit

Permalink
[network] quectel: retry CGDCONT a few times as it might be failing t…
Browse files Browse the repository at this point in the history
…emporarily on cold boot
  • Loading branch information
avtolstoy committed Mar 12, 2021
1 parent 57c4120 commit dda488d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions hal/network/ncp_client/quectel/quectel_ncp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const int CCID_MAX_RETRY_CNT = 2;

const int DATA_MODE_BREAK_ATTEMPTS = 5;
const int PPP_ECHO_REQUEST_ATTEMPTS = 3;
const int CGDCONT_ATTEMPTS = 5;

} // anonymous

Expand Down Expand Up @@ -1235,13 +1236,19 @@ int QuectelNcpClient::configureApn(const CellularNetworkConfig& conf) {
CHECK(checkNetConfForImsi());
}
}
// FIXME: for now IPv4 context only
auto resp = parser_.sendCommand("AT+CGDCONT=%d,\"%s\",\"%s\"",
QUECTEL_DEFAULT_CID, QUECTEL_DEFAULT_PDP_TYPE,
netConf_.hasApn() ? netConf_.apn() : "");
const int r = CHECK_PARSER(resp.readResult());
CHECK_TRUE(r == AtResponse::OK, SYSTEM_ERROR_UNKNOWN);
return SYSTEM_ERROR_NONE;
// XXX: we've seen CGDCONT fail on cold boot, retrying here a few times
for (int i = 0; i < CGDCONT_ATTEMPTS; i++) {
// FIXME: for now IPv4 context only
auto resp = parser_.sendCommand("AT+CGDCONT=%d,\"%s\",\"%s\"",
QUECTEL_DEFAULT_CID, QUECTEL_DEFAULT_PDP_TYPE,
netConf_.hasApn() ? netConf_.apn() : "");
const int r = CHECK_PARSER(resp.readResult());
if (r == AtResponse::OK) {
return SYSTEM_ERROR_NONE;
}
HAL_Delay_Milliseconds(200);
}
return SYSTEM_ERROR_AT_NOT_OK;
}

int QuectelNcpClient::registerNet() {
Expand Down

0 comments on commit dda488d

Please sign in to comment.