Modem commands

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?

Parents
  • Hi,

    What do the error codes mean?

    Unfortunately, the error code doesn't really mean anything more than that the modem returned "ERROR".

    However, in this case, the log already contains the cause of the error:

    AT+CGMR:
    mfw-pti_nrf9160_1.1.6

    You are running the Production Test Image modem FW (which is what comes on the SiP by default from the factory). This modem FW does not have all the capabilities of the full modem FW, so not all AT commands are supported.

    If you update the modem to the full modem FW, your application should work on your custom board as well.

    Best regards,

    Didrik

  • Thank you for the quick response. My custom board does not have a uart connection and therefore does not show up as a COM port. I'm using a JTAG interface to program the processor. Is there anyway to upgrade the modem firmware without using the nrfConnect programmer that requires a COM port?

  • NilsDR said:
    Is there anyway to upgrade the modem firmware without using the nrfConnect programmer that requires a COM port?

    The Programmer app shouldn't require a COM port?

    If you connect a programmer (e.g. using the Debug out header of a DK), you should be able to select the programmer in the Programmer app, and use that to write the modem FW.

Reply Children
Related