I've made this following code with inspiration from the at_monitor example to test a custom board using the nrf9160 sip.
int init() { int err; // Initialize the modem printk("AT Monitor sample started\n"); err = nrf_modem_lib_init(); if (err) { printk("Modem library initialization failed, error: %d\n", err); } // Get modem firmware version err = nrf_modem_at_cmd(response, sizeof(response), "AT+CGMR"); if (err) { printk("Failed to read AT+CGMR, err %d\n", err); } printk("AT+CGMR:\n%s", response); // Subscribe to notifications printk("Subscribing to notifications\n"); err = nrf_modem_at_printf("AT+CEREG=1"); if (err) { printk("AT+CEREG failed: %d\n", nrf_modem_at_err_type(err)); } // Get signal quality err = nrf_modem_at_printf("AT%%CESQ=1"); if (err) { printk("AT+CESQ failed: %d\n", nrf_modem_at_err_type(err)); } // Set modem in normal mode printk("Connecting to network\n"); err = nrf_modem_at_printf("AT+CFUN=1"); if (err) { printk("AT+CFUN failed\n"); } // Test if modem is in normal mode err = nrf_modem_at_printf("AT+CFUN?"); if (err) { printk("AT+CFUN failed\n"); } /* Let's monitor link quality while attempting to register to network */ printk("Resuming link quality monitor for AT notifications\n"); at_monitor_resume(&link_quality); printk("Waiting for network\n"); err = k_sem_take(&cereg_sem, K_SECONDS(20)); } int main(void) { init(); return 0; }
I get the following output:
*** Booting Zephyr OS build v3.3.99-ncs1 *** AT Monitor sample started AT+CGMR: mfw-pti_nrf9160_1.1.6 OK Subscribing to notifications AT+CEREG failed: 1 AT+CESQ failed: 1 Connecting to network AT+CFUN failed AT+CFUN failed Resuming link quality monitor for AT notifications Waiting for network
When testing on the nrf9160dk board it seems to work fine:
*** Booting Zephyr OS build v3.3.99-ncs1 *** AT Monitor sample started AT+CGMR: mfw_nrf9160_1.3.5 OK Subscribing to notifications Connecting to network Resuming link quality monitor for AT notifications Waiting for network Link quality: -112 dBm Network registration status: searching Link quality: -109 dBm Link quality: -117 dBm Link quality: -116 dBm Link quality: -117 dBm Link quality: -116 dBm Link quality: -118 dBm Network registration status: roaming Link quality: -111 dBm
What do the error codes mean?