Using Lwm2m (DTLS PSK) and a custom service (COAPS [DTLS PSK]) at the same time

Hi,

OS: nrf-sdk v2.6.1

Hardware: NRF52840 custom board

Network: OpenThread

Setup

Our device uses LwM2M [queue mode] (DTLS - PSK) for device control and monitoring remotely, using port 5684.

We are also developing a local interface using COAPS (DTLS - PSK) for controlling devices on the local network, using port 5688.

Both interfaces use the same network interface which is implemented using OpenThread.

Both interfaces work well when not used together; however we want both interfaces to be accessible at the same time.

Implementation

The LwM2M stack is provided by nrf-sdk / zephyr.

The "local interface" uses OpenThread's COAPS functions, which is effectively a copy paste of the CLI functions: (https://openthread.io/reference/cli/concepts/coaps).

Problem

When the device performs an LwM2M registration or update, it keeps the socket open for "CONFIG_LWM2M_QUEUE_MODE_UPTIME" seconds. During this time it is not possible to communicate with the device via the "local interface".

Once LwM2M closes its socket, the device can then be accessed via the local interface.

Question

Taking that both the LwM2M stack and our "local interface" stack use different ports. Why is it not possible to connect to the device when one already has an open connection?

Is it because the LwM2M stack and Openthread use the same MBEDTLS functions? If so, is there a way around this?

Cheers,

Sam

Parents Reply
  • Hi Amanda,

    I've tried CONFIG_LWM2M_TICKLESS=n and it didn't seem to have an effect.

    Sample code wise the Zephyr LwM2M example with the "overlay-ot" will show the same issue https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/net/lwm2m_client. 

    Once Zephyr OpenThread is connected to the border router, you can run the following on the device:

    coaps psk 1234 key1
    ot coaps start
    ot coaps resource test

    Then on the border router run

    coaps psk 1234 key1
    coaps start
    coaps connect {zephyr device ip}
    coaps get test

    You should notice when the LwM2M port is open "coaps connect" and "coaps get" will always timeout. However once the LwM2M socket closes they will succeed. 

    I've been testing everything with Wireshark + nRF sniffer. I'll get some logs of whats happening for you.

    Apologies, i know the setup isn't exactly quick todo.

    Additionally, if you open the "coaps connect" and leave it open, LwM2M can not longer perform socket operations.

Children
No Data
Related