Skip to content

Commit 6d4e280

Browse files
Mudassar Hussainadbridge
authored andcommitted
Cellular: update attach test
1 parent aad97a6 commit 6d4e280

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,10 +556,20 @@ 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+
uint8_t len=8;
560+
uint8_t buf[8];
561+
_at.cmd_start("AT+COPS?");
560562
_at.cmd_stop();
561563
_at.resp_start();
564+
_at.read_bytes(buf,len);
562565
_at.resp_stop();
566+
if (strncmp((char*)buf,"+COPS: 0",len) != 0) {
567+
_at.clear_error();
568+
_at.cmd_start("AT+COPS=0");
569+
_at.cmd_stop();
570+
_at.resp_start();
571+
_at.resp_stop();
572+
}
563573
} else {
564574
tr_debug("Manual network registration to %s", plmn);
565575
_at.cmd_start("AT+COPS=4,2,");

0 commit comments

Comments
 (0)