This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9160 LWM2M sample with Leshan prj.conf setup

I've been trying to run the LWM2M sample from here but I've been running into some issues. Leshan provides two URLs for publicly accessible test LWM2M servers, coap://leshan.eclipseprojects.io:5683 and coaps://leshan.eclipseprojects.io:5684, as described here. I've followed the instructions on the "nRF9160: LwM2M Client" page but I've been unable to connect to the LWM2M server and my client prints this error:

[00:17:17.579,650] <inf> net_lwm2m_rd_client: RD Client started with endpoint 'nrf-{IMEI REDACTED}' with client lifetime 30
[00:17:17.579,772] <err> net_lwm2m_rd_client: Cannot init LWM2M engine (-22)

My best guess is that I'm entering the server URL in the prj.conf incorrectly. I've tried a few different possible combinations but to no avail

CONFIG_APP_LWM2M_SERVER="coaps://leshan.eclipseprojects.io:5684"
CONFIG_APP_LWM2M_SERVER="coaps://leshan.eclipseprojects.io"
CONFIG_APP_LWM2M_SERVER="leshan.eclipseprojects.io:5684"
CONFIG_APP_LWM2M_SERVER="coap://leshan.eclipseprojects.io:5683"
CONFIG_APP_LWM2M_SERVER="coap://leshan.eclipseprojects.io"
CONFIG_APP_LWM2M_SERVER="leshan.eclipseprojects.io:5683"
CONFIG_APP_LWM2M_SERVER="leshan.eclipseprojects.io"

I also have my LWM2M_PEER_PORT set to 5684 if that matters. It could also be possible that my PSK settings are wrong. My config in the Leshan server is as described in the guide (id=Client_identity, PSK=000102030405060708090a0b0c0d0e0f, endpoint=nrf-{IMEI})

Any help to get this sample up and running would be appreciated.

EDIT:

I've checked the modem firmware and it's up to date (1.0.1). I also verified the Leshan demo LWM2M server using a separate LWM2M client running locally and it appears to be working fine as well.

Parents
  • Hello, 

    I've followed the instructions on the "nRF9160: LwM2M Client" page but I've been unable to connect to the LWM2M server

    The only thing that comes to mind, is that in the documentation it to configure prj.config with: 

    CONFIG_APP_LWM2M_SERVER="{IP address of LwM2M server}"
    CONFIG_LWM2M_PEER_PORT=5684

    However, the error message:

    [00:17:17.579,772] <err> net_lwm2m_rd_client: Cannot init LWM2M engine (-22)

     "Cannot init LWM2M engine (-22) indicates, according to errno.h, an invalid argument when calling lwm2m_engine_start()

    Will investigate here.

    Kind regards,
    Øyvind

Reply
  • Hello, 

    I've followed the instructions on the "nRF9160: LwM2M Client" page but I've been unable to connect to the LWM2M server

    The only thing that comes to mind, is that in the documentation it to configure prj.config with: 

    CONFIG_APP_LWM2M_SERVER="{IP address of LwM2M server}"
    CONFIG_LWM2M_PEER_PORT=5684

    However, the error message:

    [00:17:17.579,772] <err> net_lwm2m_rd_client: Cannot init LWM2M engine (-22)

     "Cannot init LWM2M engine (-22) indicates, according to errno.h, an invalid argument when calling lwm2m_engine_start()

    Will investigate here.

    Kind regards,
    Øyvind

Children
  • Hello again, 

    I am seeing the same here, and unfortunately, nothing to do at the moment.  Will report as a bug to our SDK team.

    Kind regards,
    Øyvind

  • Hi Øyvind,

    Thanks for your feedback and flagging to the SDK team. Could you please provide a target date for the resolution of the issue?

    Best regards,
    Ben

  • Hi Ben, 

    I'm sorry, but no target date available yet. Will keep you posted.

    Kind regards,
    Øyvind

  • Hi Ben, 

    Can you please try to use an IP address instead of server name:

    CONFIG_APP_LWM2M_SERVER="23.97.187.154"

    According to the responsible engineer, this is a known bug and will be handled in a future release. 

    Kind regards,
    Øyvind

  • Hi Øyvind,

    I tried using the IP address and it looks like it worked a bit better. Now I get an error getting the modem parameters and I'm unabled to connect to the LWM2M server. I did some debugging and it looks like the error occurs inside modem_info_params_get when trying to get cellid_hex. After sending the AT command and reading, modem_info_parse returns E2BIG.

    Here's the console output:

    uart:~$ ***** Booting Zephyr OS build v1.14.99-ncs3-snapshot2-1281-g40b430ba977c *****
    [00:00:00.340,911] <inf> app_lwm2m_client: Run LWM2M client
    [00:00:00.341,308] <err> buzzer: Could not bind to device
    [00:00:00.341,308] <err> ui: Could not enable buzzer, err code: -19
    [00:00:00.341,827] <inf> app_lwm2m_client: Initializing modem.
    [00:00:00.342,651] <inf> app_lwm2m_client: endpoint: nrf-xxxxxxxxxxxxxxx
    [00:00:00.343,170] <dbg> app_lwm2m_loc.lwm2m_init_location: GPS device found: GPS_SIM
    [00:00:00.343,811] <dbg> app_lwm2m_loc.update_location_data: nmea_data
    [00:00:00.343,963] <err> app_lwm2m_temp: No temperature device found.
    [00:00:00.344,573] <inf> app_lwm2m_accel: accelerometer normal
    [00:00:00.344,696] <inf> app_lwm2m_firmware: Update Counter: current 0, update 0
    [00:00:00.344,726] <inf> app_lwm2m_firmware: Image is confirmed OK
    [00:00:00.344,726] <inf> app_lwm2m_firmware: Firmware updated successfully
    [00:00:02.734,252] <inf> app_lwm2m_client: Connecting to LTE network.
    [00:00:02.734,252] <inf> app_lwm2m_client: This may take several minutes.
    [00:00:07.415,252] <inf> app_lwm2m_client: Connected to LTE network
    [00:00:07.417,114] <inf> net_lwm2m_rd_client: LWM2M Client: nrf-xxxxxxxxxxxxxxx
    [00:00:07.423,522] <err> app_lwm2m_connmon: Unable to obtain modem parameters: -11
    [00:00:08.342,346] <inf> net_lwm2m_rd_client: RD Client started with endpoint 'nrf-xxxxxxxxxxxxxxx' with client lifetime 30
    [00:00:19.038,024] <inf> net_lwm2m_engine: Resending message: 0x200226a4
    [00:00:39.038,909] <inf> net_lwm2m_engine: Resending message: 0x200226a4
    [00:01:00.342,437] <dbg> app_lwm2m_loc.update_location_data: nmea_data
    [00:01:19.048,065] <inf> net_lwm2m_engine: Resending message: 0x200226a4
    [00:02:00.350,982] <dbg> app_lwm2m_loc.update_location_data: nmea_data
    [00:02:39.057,189] <wrn> net_lwm2m_rd_client: Registration Timeout
    [00:02:39.057,189] <dbg> app_lwm2m_client.rd_client_event: Disconnected
    [00:02:39.057,220] <dbg> app_lwm2m_client.rd_client_event: Registration failure!
    [00:02:39.577,178] <inf> net_lwm2m_rd_client: RD Client started with endpoint 'nrf-xxxxxxxxxxxxxxx' with client lifetime 30

Related