I am developing LTE-M software on nRF9160. Previously, I checked that it runs well with nRF9160DK. Now I try it with my own board.
First, only for testing, I made following program.
int main(void) { int err; err = nrf_modem_lib_init(); return 0; }
After start debugging, static int _nrf_modem_lib_init(void) on nrf/lib/nrf_modem_lib/nrf_modem_lib.c is called and modem is successfully initialized.
Next, static void on_modem_init(int err, void *ctx) on nrf/lib/lte_link_control/lte_lc_modem_hooks.c is called and:
static void on_modem_init(int err, void *ctx) { if (err) { LOG_ERR("Modem library init error: %d, lte_lc not initialized", err); return; } /* Request configured PSM and eDRX settings to save power. */ err = lte_lc_psm_req(IS_ENABLED(CONFIG_LTE_PSM_REQ)); if (err) { LOG_ERR("Failed to configure PSM, err %d", err); return; } ...
int lte_lc_psm_req(bool enable) on nrf/lib/lte_link_control/lte_lc.c is called subsequently.
int lte_lc_psm_req(bool enable) { int err; if (enable) { if (strlen(psm_param_rptau) == 8 && strlen(psm_param_rat) == 8) { err = nrf_modem_at_printf("AT+CPSMS=1,,,\"%s\",\"%s\"", psm_param_rptau, psm_param_rat); } else if (strlen(psm_param_rptau) == 8) { err = nrf_modem_at_printf("AT+CPSMS=1,,,\"%s\"", psm_param_rptau); } else if (strlen(psm_param_rat) == 8) { err = nrf_modem_at_printf("AT+CPSMS=1,,,,\"%s\"", psm_param_rat); } else { err = nrf_modem_at_printf("AT+CPSMS=1"); } } else { err = nrf_modem_at_printf(psm_disable); } if (err) { LOG_ERR("nrf_modem_at_printf failed, reported error: %d", err); return -EFAULT; } return 0; }
In prj.conf, CONFIG_LTE_PSM_REQ=y is set. Following values are checked with debugger:
psm_param_rptau = "00000011", psm_param_rat = "00100001".
I don't know why, nrf_modem_at_printf("AT+CPSMS=1,,,\"%s\",\"%s\"", psm_param_rptau, psm_param_rat) returns 65536.
prf.conf:
CONFIG_LOG=y CONFIG_RTT_CONSOLE=y CONFIG_USE_SEGGER_RTT=y CONFIG_ASSERT=y CONFIG_REBOOT=y CONFIG_LTE_LINK_CONTROL=y CONFIG_AT_HOST_LIBRARY=y CONFIG_NRF_MODEM_LIB=y CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y CONFIG_NRF_MODEM_LIB_TRACE=n CONFIG_MODEM_INFO=y CONFIG_MODEM_INFO_ADD_NETWORK=y CONFIG_PDN=y CONFIG_PDN_ESM_STRERROR=y CONFIG_MODEM=y CONFIG_MODEM_MODULES=y CONFIG_NRFX_PDM=y CONFIG_LTE_PSM_REQ=y
Why nrf_modem_at_printf() fails? What items should I check?