slm_shell on nrf52840

Hello,

I have moved slm_shell application t0 a separate thread, including cereg_mon() and slm_shell_data_indication() functions. I can correctly check the SLM (ncs v3.1.1 on nrf9151) responses.

I have modified cereg_mon() to schedule a delayed work, and in that work function I send +cereg=2 command, however, the control is lost:

 
static void cereg_mon(const char *notif)
{
    int status = atoi(notif + strlen("\r\n+CEREG: "));
    network_cereg_status = status;

    if (status == network_registered_home ||
            status == network_registered_roaming) {
        if((slm_network_st == slm_network_init_registration) || (slm_network_st == slm_network_not_registered)) {
            k_work_schedule(&heartbeat_wrk, K_SECONDS(NETWORK_HEARTBEAT_CHECK_SEC));
            LOG_INF("[URC] Verify registration after %d seconds", NETWORK_HEARTBEAT_CHECK_SEC);
        }
        if (slm_network_st == slm_network_first_time_registered) {
            slm_network_st = slm_network_is_registered;
        }
        k_work_cancel_delayable(&retry_wrk);
        retry_counter = 0;  
        printk("2state:%d\r\n", slm_network_st);        
    }
    else {
        LOG_WRN("[URC] LTE detached or denied (status: %d)", status);
        slm_network_st = slm_network_not_registered;
        k_work_schedule(&retry_wrk, K_SECONDS(NETWORK_RETRY_DELAY));
        printk("3state:%d\r\n", slm_network_st);
    }
}
in the work function below:
static void heartbeat_worker_fn(struct k_work *work)
{
    int rc;
    ARG_UNUSED(work);
    slm_network_st = slm_network_first_time_registered;
    rc = modem_slm_send_cmd("AT+CEREG=3\r\n", AT_CMD_TIMEOUT_MS);
    LOG_INF("heartbeat!");
    return;
}
after sending +cereg=3 the control is lost and it doesn't enter cereg_mon().
Can you please advise how to resolve it?
Parents
  • Hi,

    Sorry, I'm not sure to fully understand your issue, do you have any logs and/or diagrams that would allow me to understand better what you want to do, and what is currently happening ?

    It looks like some kind of deadlock or parallel programming issue, so I really need to understand the sequence of events happening in your program... If you had some simple sequence diagram (link) it would be super useful.

    Also, if you want to share more code, but can't do it in a public ticket, I can set this ticket to private (just ask me before uploading your code).

    Best regards,

    Simon

Reply
  • Hi,

    Sorry, I'm not sure to fully understand your issue, do you have any logs and/or diagrams that would allow me to understand better what you want to do, and what is currently happening ?

    It looks like some kind of deadlock or parallel programming issue, so I really need to understand the sequence of events happening in your program... If you had some simple sequence diagram (link) it would be super useful.

    Also, if you want to share more code, but can't do it in a public ticket, I can set this ticket to private (just ask me before uploading your code).

    Best regards,

    Simon

Children
Related