Skip to content

Commit 53adeed

Browse files
authored
Merge pull request #6350 from u-blox/cellular_test
Cellular: update attach test
2 parents a3d8c8f + 91333d2 commit 53adeed

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,18 @@ nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
556556

557557
if (!plmn) {
558558
tr_debug("Automatic network registration");
559-
_at.cmd_start("AT+COPS=0");
559+
_at.cmd_start("AT+COPS?");
560560
_at.cmd_stop();
561-
_at.resp_start();
561+
_at.resp_start("AT+COPS:");
562+
int mode = _at.read_int();
562563
_at.resp_stop();
564+
if (mode != 0) {
565+
_at.clear_error();
566+
_at.cmd_start("AT+COPS=0");
567+
_at.cmd_stop();
568+
_at.resp_start();
569+
_at.resp_stop();
570+
}
563571
} else {
564572
tr_debug("Manual network registration to %s", plmn);
565573
_at.cmd_start("AT+COPS=4,2,");

0 commit comments

Comments
 (0)