Default LWM2M lifetime setting does not work

I have the following:
- NRF52840
- BG96 modem
- NCS 1.5.1
- Zephyr v2.4.99-ncs2

When I start the firmware, it will first bootstrap followed by leshan server registration.

In my prj.conf I have:

CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=900

But when I look at the tcpdump I see lt=20.

I also checked with grep:

grep -R CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME *
build_nrf52840_orbitz/zephyr/include/generated/autoconf.h:#define CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME 900
Binary file build_nrf52840/zephyr/zephyr_prebuilt.elf matches
build_nrf52840/zephyr/zephyr.lst:	lifetime[index] = CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME;
build_nrf52840/zephyr/zephyr.lst:		new_lifetime = CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME;
build_nrf52840/zephyr/zephyr.lst:		new_lifetime = CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME;
build_nrf52840/zephyr/.config.old:CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=900
build_nrf52840/zephyr/.config:CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=900
build_nrf52840/zephyr/misc/generated/configs.c:GEN_ABSOLUTE_SYM(CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME, 900);
Binary file build_nrf52840/zephyr/zephyr.elf matches
Binary file build_nrf52840/zephyr/libzephyr.a matches
Binary file build_nrf52840/zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj matches
prj.conf:CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME=900

Somehow this setting is being overruled.
There's no mention of overrule in the documentation:
https://docs.zephyrproject.org/1.14.0/reference/kconfig/CONFIG_LWM2M_ENGINE_DEFAULT_LIFETIME.html

Also according to the documentation, the default is 30.

Where does 20 come from? and how do I change my project to use lifetime 900?

Parents
  • Hi Philip,

    nRF52840 does not support that sample. I guess you are looking for a sample like  nRF9160: LwM2M Client — nRF Connect SDK 1.8.0 documentation (nordicsemi.com)

    Can you provide more information about your application?

    Best regards,

    Charlie

  • I'm starting my LWM2M client with lwm2m_rd_client_start() which is located in ncs/zephyr/subsys/net/lib/lwm2m/lwm2m_rd_client.c

    The application is basically polling the BG96 modem for GPS coordinates and send it via LWM2M object 3336/0/5514 and 3336/0/5515

    Stack trace I have up until now:

    Modem_AddEventCallback(ModemObserverCallback)
        ModemObserverCallback()
            StartLwM2MClient()
                LwM2M_ClientStart()
                    lwm2m_rd_client_start()
                        set_sm_state(ENGINE_INIT);
    		                case ENGINE_INIT:
                                 sm_do_init();
                                       client.lifetime = 0U;

    In the beginning the lifetime is set to 0. Later on it's set to the correct value.

    I've narrowed it down to the function:

    static int lwm2m_engine_get(char *pathstr, void *buf, uint16_t buflen)

    There it uses this function:

    path_to_objs()

    To convert the path into an object with the lifetime in it, but I do not understand the code or where the lifetime comes from?

    If I look at the function:

    static int path_to_objs(const struct lwm2m_obj_path *path,
    			struct lwm2m_engine_obj_inst **obj_inst,
    			struct lwm2m_engine_obj_field **obj_field,
    			struct lwm2m_engine_res **res,
    			struct lwm2m_engine_res_inst **res_inst)
    {

    It somehow gets this information from the objects.

    I also thought maybe the lifetime is set using the function:

    lwm2m_engine_set()

    But when I look at the logging I get:

    [00:00:06.484,893] <dbg> net_lwm2m_engine.lwm2m_engine_set: path:0/0/2, value:0x2001a837, len:1
    [00:00:06.484,954] <dbg> net_lwm2m_engine.lwm2m_engine_set: path:0/0/3, value:0x20012662, len:2
    [00:00:06.484,985] <dbg> net_lwm2m_engine.lwm2m_engine_set: path:0/0/5, value:0x200126a2, len:5
    [00:00:06.485,046] <dbg> net_lwm2m_engine.lwm2m_engine_set: path:0/0/1, value:0x2001a837, len:1
    [00:00:19.959,045] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/0/1, buf:0x20018c57, buflen:1
    [00:03:35.387,329] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/0/1, buf:0x20018c57, buflen:1
    [00:03:43.638,336] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/0/1, buf:0x20018c57, buflen:1
    [00:03:43.638,397] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/1/1, buf:0x20018c57, buflen:1
    [00:03:43.638,458] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/1/10, buf:0x20018caa, buflen:2

    I do not see object 1/0/1, which is lifetime.

    I am able to set lifetime from lwm2m server web GUI. So when lifetime is only 20 seconds, I quickly set it higher via the lwm2m server web GUI.

Reply
  • I'm starting my LWM2M client with lwm2m_rd_client_start() which is located in ncs/zephyr/subsys/net/lib/lwm2m/lwm2m_rd_client.c

    The application is basically polling the BG96 modem for GPS coordinates and send it via LWM2M object 3336/0/5514 and 3336/0/5515

    Stack trace I have up until now:

    Modem_AddEventCallback(ModemObserverCallback)
        ModemObserverCallback()
            StartLwM2MClient()
                LwM2M_ClientStart()
                    lwm2m_rd_client_start()
                        set_sm_state(ENGINE_INIT);
    		                case ENGINE_INIT:
                                 sm_do_init();
                                       client.lifetime = 0U;

    In the beginning the lifetime is set to 0. Later on it's set to the correct value.

    I've narrowed it down to the function:

    static int lwm2m_engine_get(char *pathstr, void *buf, uint16_t buflen)

    There it uses this function:

    path_to_objs()

    To convert the path into an object with the lifetime in it, but I do not understand the code or where the lifetime comes from?

    If I look at the function:

    static int path_to_objs(const struct lwm2m_obj_path *path,
    			struct lwm2m_engine_obj_inst **obj_inst,
    			struct lwm2m_engine_obj_field **obj_field,
    			struct lwm2m_engine_res **res,
    			struct lwm2m_engine_res_inst **res_inst)
    {

    It somehow gets this information from the objects.

    I also thought maybe the lifetime is set using the function:

    lwm2m_engine_set()

    But when I look at the logging I get:

    [00:00:06.484,893] <dbg> net_lwm2m_engine.lwm2m_engine_set: path:0/0/2, value:0x2001a837, len:1
    [00:00:06.484,954] <dbg> net_lwm2m_engine.lwm2m_engine_set: path:0/0/3, value:0x20012662, len:2
    [00:00:06.484,985] <dbg> net_lwm2m_engine.lwm2m_engine_set: path:0/0/5, value:0x200126a2, len:5
    [00:00:06.485,046] <dbg> net_lwm2m_engine.lwm2m_engine_set: path:0/0/1, value:0x2001a837, len:1
    [00:00:19.959,045] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/0/1, buf:0x20018c57, buflen:1
    [00:03:35.387,329] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/0/1, buf:0x20018c57, buflen:1
    [00:03:43.638,336] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/0/1, buf:0x20018c57, buflen:1
    [00:03:43.638,397] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/1/1, buf:0x20018c57, buflen:1
    [00:03:43.638,458] <dbg> net_lwm2m_engine.lwm2m_engine_get: path:0/1/10, buf:0x20018caa, buflen:2

    I do not see object 1/0/1, which is lifetime.

    I am able to set lifetime from lwm2m server web GUI. So when lifetime is only 20 seconds, I quickly set it higher via the lwm2m server web GUI.

Children
Related