lwm2m client nrf9160 - custom board

Good day

I am currently running a lwm2m based client that sends lwm2m messages after every 10 min. The process of sending is handled in another thread and the data that doesn't send is saved inside a buffer.  When the client detects that there is connection it will send the flash data.  As per my description, the client is unchanged.  However, after about 18 hours, the client will lose connection to the network and will not be able to find network and reconnect to the server again.  I have tried to trigger a network error while logging and the client manages to reestablish connection overtime.  However, after 18 or so hours, the client will just lose connection and not attempt to reconnect again.  Anybody have any ideas on how to fix this situation?  Very frustrating as I have not changed anything about the lwm2m sample in terms of the code that was already there.  please assist .  NB : I am certain that the client isn't establishing network connection because my code will always attempt to send and the flash buffer is not empty once I reboot the device.  The device will save all the data till the reboot.

I am using mfw 1.3.5 and SDK version 2.4.0.

Kind regards,

Hassan 

  • ADDITIONAL INFORMATION:

    I did some testing and found that when the lwm2m client triggers a NETWORK_ERROR, the client  enters the START client_state.  But when it enters :

    lwm2m_rd_client_start(&client, endpoint_name, bootstrap_flags,
                                                      rd_client_event, NULL);
    "Client is already running in state 9" (referring to the engine state) is logged and the client remains in state 1(START)
    However, the client is not connected to the internet and now a lwm2m_send function will fail every time due to it not being connected.  How do I stop this from happening a force reconnection.  Again , I would like to reiterate that I have not changed anything with the standard lwm2m client nrf9160 sample.
  • Hello,

    I asked the developer, and he said there is a PR with this fix. He will make a smaller one on Monday that you can apply.

  • Hi Hakon 

    Thank you for the update ! Please let me know as soon as its available.

    Kind regards,

    Hassan

  • The fix is ready. Please try this PR and see if it works for you.

  • The fix is not working for NCS 2.4 yet (it is still being worked on), but you can make these changes to fix it

    @@ -447,7 +447,7 @@ static void rd_client_event(struct lwm2m_ctx *client, enum lwm2m_rd_client_event
         case LWM2M_RD_CLIENT_EVENT_DISCONNECT:
             LOG_DBG("Disconnected");
             if (client_state != UPDATE_FIRMWARE) {
    -            state_set_and_unlock(START);
    +            state_trigger_and_unlock(START);
             } else {
                 k_mutex_unlock(&lte_mutex);
             }
    (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? y
    @@ -686,9 +686,9 @@ int main(void)
                 ret = lwm2m_rd_client_start(&client, endpoint_name, bootstrap_flags,
                                 rd_client_event, NULL);
                 if (ret) {
    -                state_set_and_unlock(NETWORK_ERROR);
    +                state_trigger_and_unlock(NETWORK_ERROR);
                 } else {
    -                state_set_and_unlock(CONNECTING);
    +                state_trigger_and_unlock(CONNECTING);

Related