There is a bug in the sample/nrf9160/at_monitor, namely to do with +CEREG unsolicited notification handler called "cereg_mon".
"cereg_mon" expects 0-2 +CEREG status code, evidenced by the fact that the array and the enumeration handling the status are enumerated from 0 to 2 (as shown below).
static int cereg_status;
enum cereg_status {
NO_NETWORK = 0,
HOME = 1,
SEARCHING = 2
};
static const char * const cereg_str[] = {
[NO_NETWORK] = "no network",
[SEARCHING] = "searching",
[HOME] = "home",
};
static int rsps_status;
static char response[64];
static void cereg_mon(const char *notif)
{
cereg_status = atoi(notif + strlen("+CEREG: "));
printk("Network registration status: %s\n", cereg_str[cereg_status]);
if (cereg_status == HOME) {
k_sem_give(&cereg_sem);
}
}However, from the nRF9160 V2.0 AT Command Reference Manual (see https://infocenter.nordicsemi.com/pdf/nrf91_at_commands_v2.0.pdf), and with the latest modem fw 1.3.0, the status can be 0-5 and 90. Guess what happens when +CEREG? unsolicited status update returns 5 (network is registered, roaming)?
The program hard-faults due to out-of-bound array index access.....
Please fix this issue. This is one of the first code people loads onto the device to test their board...