diff --git a/features/cellular/framework/AT/AT_CellularNetwork.cpp b/features/cellular/framework/AT/AT_CellularNetwork.cpp index 5c05d35e1f..db9e02e44f 100644 --- a/features/cellular/framework/AT/AT_CellularNetwork.cpp +++ b/features/cellular/framework/AT/AT_CellularNetwork.cpp @@ -546,10 +546,20 @@ nsapi_error_t AT_CellularNetwork::set_registration(const char *plmn) if (!plmn) { tr_debug("Automatic network registration"); - _at.cmd_start("AT+COPS=0"); + uint8_t len=8; + uint8_t buf[8]; + _at.cmd_start("AT+COPS?"); _at.cmd_stop(); _at.resp_start(); + _at.read_bytes(buf,len); _at.resp_stop(); + if (strncmp((char*)buf,"+COPS: 0",len) != 0) { + _at.clear_error(); + _at.cmd_start("AT+COPS=0"); + _at.cmd_stop(); + _at.resp_start(); + _at.resp_stop(); + } } else { tr_debug("Manual network registration to %s", plmn); _at.cmd_start("AT+COPS=4,2,");