C030 SARA-R412M: URC already added with prefix. Cellular state machine failure

Description of defect

Normally the cellular connection works without problems. We noticed that a reboot with external power supply of the device after the battery (without external power) went dead, the Ublox SIM chip is in a bad state and it shows this warnings:

[00226631ms][WARN][CELL]: URC already added with prefix: +CGEV: NW DEACT
[00226648ms][WARN][CELL]: URC already added with prefix: +CGEV: ME DEACT
[00226665ms][WARN][CELL]: URC already added with prefix: +CGEV: NW PDN D
[00226693ms][WARN][CELL]: URC already added with prefix: +CGEV: ME PDN D

After many retries of AT TX ( 9): AT+CFUN=4 we get the errors:

[00367436ms][ERR ][CELL]: CellularStateMachine failure: Device ready
[00367453ms][ERR ][CELL]: CellularStateMachine target state Attaching network, current state Device ready
[00367494ms][INFO][CELL]: CellularContext connect
[00367509ms][INFO][CELL]: CellularContext connect

and the connection procedure don’t continue. Our code is simple:

...
iface = CellularContext::get_default_instance();
iface->attach(callback(this, &Cellular::cbCellular));
iface->set_default_parameters();

nsapi_error_t retcode = NSAPI_ERROR_OK;
retcode = iface->connect();
...
Questions
  1. How can we capture the CellularStateMachine error?
  2. What should we set/call/config to avoid this problem?
  3. How can we send AT commands from iface (CellularContext) to try some commands?

Target(s) affected by this defect ?

C030-R412M

Toolchain(s) (name and version) displaying this defect ?

Mbed Studio 1.4.3

What version of Mbed-os are you using (tag or sha) ?

mbed-os-5.15.7

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

Mbed Studio 1.4.3

How is this defect reproduced ?

[00221485ms][INFO][CELL]: New CellularContext  (2000dc10)
[00221517ms][INFO][CELL]: CellularContext connect
[00221543ms][INFO][CELL]: Start connecting (timeout 1000 ms)
[00221559ms][INFO][CELL]: AT TX ( 2): AT
[00221574ms][INFO][CELL]: AT TX ( 1): <cr>
[00222568ms][INFO][CELL]: AT TX ( 2): AT
[00222572ms][INFO][CELL]: AT TX ( 1): <cr>
[00223577ms][INFO][CELL]: Modem power ON (timeout 1000 ms)
[00223593ms][INFO][CELL]: AT TX ( 2): AT
[00223608ms][INFO][CELL]: AT TX ( 1): <cr>
[00224601ms][INFO][CELL]: AT TX ( 9): AT+CFUN=4
[00224616ms][INFO][CELL]: AT TX ( 1): <cr>
[00225610ms][INFO][CELL]: Continue after 1 seconds
[00226631ms][WARN][CELL]: URC already added with prefix: +CGEV: NW DEACT
[00226648ms][WARN][CELL]: URC already added with prefix: +CGEV: ME DEACT
[00226665ms][WARN][CELL]: URC already added with prefix: +CGEV: NW PDN D
[00226693ms][WARN][CELL]: URC already added with prefix: +CGEV: ME PDN D
[00226721ms][INFO][CELL]: AT TX ( 2): AT
[00226725ms][INFO][CELL]: AT TX ( 1): <cr>
[00227719ms][INFO][CELL]: AT TX ( 9): AT+CFUN=4
[00227734ms][INFO][CELL]: AT TX ( 1): <cr>
[00228728ms][INFO][CELL]: Continue after 2 seconds
[00230749ms][WARN][CELL]: URC already added with prefix: +CGEV: NW DEACT
[00230766ms][WARN][CELL]: URC already added with prefix: +CGEV: ME DEACT
[00230783ms][WARN][CELL]: URC already added with prefix: +CGEV: NW PDN D
[00230811ms][WARN][CELL]: URC already added with prefix: +CGEV: ME PDN D
[00230839ms][INFO][CELL]: AT TX ( 2): AT
[00230843ms][INFO][CELL]: AT TX ( 1): <cr>
[00231837ms][INFO][CELL]: AT TX ( 9): AT+CFUN=4
[00231852ms][INFO][CELL]: AT TX ( 1): <cr>
[00232846ms][INFO][CELL]: Continue after 4 seconds
[00236867ms][WARN][CELL]: URC already added with prefix: +CGEV: NW DEACT
[00236884ms][WARN][CELL]: URC already added with prefix: +CGEV: ME DEACT
[00236901ms][WARN][CELL]: URC already added with prefix: +CGEV: NW PDN D
[00236929ms][WARN][CELL]: URC already added with prefix: +CGEV: ME PDN D
[00236957ms][INFO][CELL]: AT TX ( 2): AT
[00236961ms][INFO][CELL]: AT TX ( 1): <cr>
[00237955ms][INFO][CELL]: AT TX ( 9): AT+CFUN=4
[00237970ms][INFO][CELL]: AT TX ( 1): <cr>
[00238964ms][INFO][CELL]: Continue after 8 seconds
[00246985ms][WARN][CELL]: URC already added with prefix: +CGEV: NW DEACT
[00247002ms][WARN][CELL]: URC already added with prefix: +CGEV: ME DEACT
[00247019ms][WARN][CELL]: URC already added with prefix: +CGEV: NW PDN D
[00247047ms][WARN][CELL]: URC already added with prefix: +CGEV: ME PDN D
[00247075ms][INFO][CELL]: AT TX ( 2): AT
[00247079ms][INFO][CELL]: AT TX ( 1): <cr>
[00248073ms][INFO][CELL]: AT TX ( 9): AT+CFUN=4
[00248088ms][INFO][CELL]: AT TX ( 1): <cr>
[00249082ms][INFO][CELL]: Continue after 16 seconds
[00265103ms][WARN][CELL]: URC already added with prefix: +CGEV: NW DEACT
[00265120ms][WARN][CELL]: URC already added with prefix: +CGEV: ME DEACT
[00265137ms][WARN][CELL]: URC already added with prefix: +CGEV: NW PDN D
[00265165ms][WARN][CELL]: URC already added with prefix: +CGEV: ME PDN D
[00265193ms][INFO][CELL]: AT TX ( 2): AT
[00265197ms][INFO][CELL]: AT TX ( 1): <cr>
[00266191ms][INFO][CELL]: AT TX ( 9): AT+CFUN=4
[00266206ms][INFO][CELL]: AT TX ( 1): <cr>
[00267200ms][INFO][CELL]: Continue after 32 seconds
[00299221ms][WARN][CELL]: URC already added with prefix: +CGEV: NW DEACT
[00299238ms][WARN][CELL]: URC already added with prefix: +CGEV: ME DEACT
[00299255ms][WARN][CELL]: URC already added with prefix: +CGEV: NW PDN D
[00299283ms][WARN][CELL]: URC already added with prefix: +CGEV: ME PDN D
[00299311ms][INFO][CELL]: AT TX ( 2): AT
[00299315ms][INFO][CELL]: AT TX ( 1): <cr>
[00300309ms][INFO][CELL]: AT TX ( 9): AT+CFUN=4
[00300324ms][INFO][CELL]: AT TX ( 1): <cr>
[00301318ms][INFO][CELL]: Continue after 64 seconds
[00365339ms][WARN][CELL]: URC already added with prefix: +CGEV: NW DEACT
[00365356ms][WARN][CELL]: URC already added with prefix: +CGEV: ME DEACT
[00365373ms][WARN][CELL]: URC already added with prefix: +CGEV: NW PDN D
[00365401ms][WARN][CELL]: URC already added with prefix: +CGEV: ME PDN D
[00365429ms][INFO][CELL]: AT TX ( 2): AT
[00365433ms][INFO][CELL]: AT TX ( 1): <cr>
[00366427ms][INFO][CELL]: AT TX ( 9): AT+CFUN=4
[00366442ms][INFO][CELL]: AT TX ( 1): <cr>
[00367436ms][ERR ][CELL]: CellularStateMachine failure: Device ready
[00367453ms][ERR ][CELL]: CellularStateMachine target state Attaching network, current state Device ready
[00367494ms][INFO][CELL]: CellularContext connect
[00367509ms][INFO][CELL]: CellularContext connect
[02166756ms][WARN][CELL]: No cellular connection
[02166771ms][INFO][CELL]: CellularContext connect

# No more output!