Skip to content

Commit 3bee060

Browse files
author
Mudassar Hussain
committed
Cellular: update attach test
1 parent fe2e4a3 commit 3bee060

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
@@ -546,10 +546,20 @@ nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn)
546546

547547
if (!plmn) {
548548
tr_debug("Automatic network registration");
549-
_at.cmd_start("AT+COPS=0");
549+
uint8_t len=8;
550+
uint8_t buf[8];
551+
_at.cmd_start("AT+COPS?");
550552
_at.cmd_stop();
551553
_at.resp_start();
554+
_at.read_bytes(buf,len);
552555
_at.resp_stop();
556+
if (strncmp((char*)buf,"+COPS: 0",len) != 0) {
557+
_at.clear_error();
558+
_at.cmd_start("AT+COPS=0");
559+
_at.cmd_stop();
560+
_at.resp_start();
561+
_at.resp_stop();
562+
}
553563
} else {
554564
tr_debug("Manual network registration to %s", plmn);
555565
_at.cmd_start("AT+COPS=4,2,");

0 commit comments

Comments
 (0)