
static void lte_handler(const struct lte_lc_evt *const evt)
{
switch (evt->type) {
case LTE_LC_EVT_NW_REG_STATUS:
if ((evt->nw_reg_status != LTE_LC_NW_REG_REGISTERED_HOME) &&
(evt->nw_reg_status != LTE_LC_NW_REG_REGISTERED_ROAMING)) {
break;
}
LOG_INF("Network registration status: %s\n",
evt->nw_reg_status == LTE_LC_NW_REG_REGISTERED_HOME ?
"Connected - home network" : "Connected - roaming\n");
k_sem_give(<e_connected);
flash_led(DK_LED2, 2000);
break;
case LTE_LC_EVT_RRC_UPDATE:
LOG_INF("RRC mode: %s\n",
evt->rrc_mode == LTE_LC_RRC_MODE_CONNECTED ?
"Connected" : "Idle\n");
break;
case LTE_LC_EVT_PSM_UPDATE:
LOG_INF("PSM parameter update: Periodic TAU: %d s, Active time: %d s",
evt->psm_cfg.tau, evt->psm_cfg.active_time);
if (evt->psm_cfg.active_time == -1) {
LOG_ERR("Network rejected PSM parameters. Failed to enable PSM");
}
break;
default:
break;
}
}
//-----------------------------------------------------------------------------------------------------------------------------------
static int modem_configure(void)
{
int err;
LOG_INF("Initializing modem library");
err = nrf_modem_lib_init();
if (err) {
LOG_ERR("Failed to initialize the modem library, error: %d", err);
return err;
}
#if NCS_VERSION_NUMBER < 0x20600
err = lte_lc_init();
if (err) {
LOG_ERR("Failed to initialize LTE link control library, error: %d", err);
return err;
}
#endif
// PSM modunu etkinleştirin
LOG_INF("Requesting PSM...");
err = lte_lc_psm_req(true);
if (err) {
LOG_ERR("Failed to request PSM, error: %d", err);
return err;
}
LOG_INF("Connecting to LTE network");
err = lte_lc_connect_async(lte_handler);
if (err) {
LOG_ERR("Error in lte_lc_connect_async, error: %d", err);
return err;
}
return 0;
}
Hİ,
I can connect to LTE. but somewhere which I think it might not be the signal, it can not connect and restart (reset). not return any error. if I change my location
with not close the device. it can connect. why ?
I need no connection after 2 min. skip and go to sleep (psm mode). maybe 1 hour later try to connect again. if not it consume current (36mA) continously.
and leads the device battery gets low fast.