This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LwM2M Composite Observe

Hi,

I'm working on an LwM2M client that reads three sensors in sequence every N minutes and notifies the server about the value change.

The server supports the LwM2M 1.1 observe composite feature. It is based on leshan-server-cf 2.0.0-M5.

When the nRF9160 client sends three consecutive observe notifications they are not received as composite observe response on the server side. When each sensor value is observed on its own, the server does receive the single sensor value observe notifications.

My current client firmware is based on nrfconnect SDK version 1.6.1.


I've searched the github nrfconnect-sdk and zephyr repositories for any new notify functions but was unable to find anything aside from the following lines:

#define NOTIFY_OBSERVER(o, i, r) lwm2m_notify_observer(o, i, r)
#define NOTIFY_OBSERVER_PATH(path) lwm2m_notify_observer_path(path)
....
int lwm2m_notify_observer(uint16_t obj_id, uint16_t obj_inst_id, uint16_t res_id);
int lwm2m_notify_observer_path(struct lwm2m_obj_path *path);

My question is now: is the composite observe feature supported in any version of the nRF Connect SDK?

Thanks in advance.

Best regards

  • Hello, 

    Do you have any log outputs from the device itself? Are there any errors in this log?

    Please note that due to Christmas holiday our team is lighter staffed than normal, and response time is longer than normal. 

    Kind regards,
    Øyvind

  • Hi,

    thanks for the quick response despite the holiday season.

    I've set the device lwm2m log level to debug but there was really nothing of interest in the resulting logs.

    On the server I've also increased the log level and found out that the coap response to the composite observation request is method not allowed 4.05.

    For my situation an example where composite observe is used / implemented would help already since the device firmware I used for the latest tests is the lwm2m client (in SDK version 1.8.0) with three temperature object instances where the values are updated in a worker thread every 5 seconds.

    The temperature values and the worker handler look like this:


    static struct float32_value temp_float = { 0, 0 };
    static struct float32_value temp_float1 = { -1, 0 };
    static struct float32_value temp_float2 = { -3, 0 };

    static void mock_update_temperature_work_handler(struct k_work *work)
    {
            LOG_WRN("update temperature measurements");
            temp_float.val1 += 1;
            NOTIFY_OBSERVER(3303, 0, SENSOR_VALUE_RID);

            temp_float1.val1 += 1;
            NOTIFY_OBSERVER(3303, 1, SENSOR_VALUE_RID);

            temp_float2.val1 += 1;
            NOTIFY_OBSERVER(3303, 1, SENSOR_VALUE_RID);
    }

    Here is the server output, in case it helps:


    2021-12-22 19:05:57,171 DEBUG Client - STARTING OBSERVATIONS
    2021-12-22 19:05:57,287 DEBUG ReliabilityLayer - Exchange[L4] send request
    2021-12-22 19:05:57,288 DEBUG ReliabilityLayer - Exchange[L4] prepare retransmission for CON-FETCH  MID=   -1, Token=null, OptionSet={"Observe":0, "Content-Format":"application/senml+json", "Accept":"application/senml+json"}, "[{"n":"/3303/0/5700"},{"n":"/330".. 64 bytes
    2021-12-22 19:05:57,289 DEBUG BaseMatcher - registering observe request CON-FETCH  MID=15760, Token=null, OptionSet={"Observe":0, "Content-Format":"application/senml+json", "Accept":"application/senml+json"}, "[{"n":"/3303/0/5700"},{"n":"/330".. 64 bytes  
    2021-12-22 19:05:57,290 DEBUG InMemoryMessageExchangeStore - [LWM2M Server-coap://] Exchange[L4] added with KeyMID[172.24.213.114:49358-15760], CON-FETCH  MID=15760, Token=21A18DD012D20B91, OptionSet={"Observe":0, "Content-Format":"application/senml+json", "Accept":"application/senml+json"}, "[{"n":"/3303/0/5700"},{"n":"/330".. 64 bytes
    2021-12-22 19:05:57,291 DEBUG InMemoryMessageExchangeStore - [LWM2M Server-coap://] Exchange[L4] added with token KeyToken[21A18DD012D20B91], CON-FETCH  MID=15760, Token=21A18DD012D20B91, OptionSet={"Observe":0, "Content-Format":"application/senml+json", "Accept":"application/senml+json"}, "[{"n":"/3303/0/5700"},{"n":"/330".. 64 bytes
    2021-12-22 19:05:57,291 DEBUG UdpMatcher - tracking open request [KeyMID[172.24.213.114:49358-15760], KeyToken[21A18DD012D20B91]]
    2021-12-22 19:05:57,295 DEBUG UDPConnector - UDPConnector (Thread[UDP-Sender-/0.0.0.0:15727[0],5,Californium/Elements]) sent 82 bytes to 172.24.213.114:49358
    2021-12-22 19:05:57,826 DEBUG UDPConnector - UDPConnector (0.0.0.0:15727) received 33 bytes from 172.24.213.114:49358
    2021-12-22 19:05:57,827 DEBUG SweepDeduplicator - add exchange for KeyMID[172.24.213.114:49358-22644]
    2021-12-22 19:05:57,834 DEBUG RegistrationHandler - Updated registration org.eclipse.leshan.server.registration.UpdatedRegistration@6c268f64 by RegistrationUpdate [registrationId=Lc3H9nK4v0, identity=Identity /172.24.213.114:49358[unsecure], lifeTimeInSec=600, smsNumber=null, bindingMode=null, objectLinks=null]
    2021-12-22 19:05:57,838 DEBUG ReliabilityLayer - Exchange[R5] send response null-2.04   MID=   -1, Token=null, OptionSet={}, <empty data>
    2021-12-22 19:05:57,839 DEBUG Exchange - Exchange[R5, complete]!
    2021-12-22 19:05:57,840 DEBUG Exchange - Remote Exchange[R5, complete] completed ACK-2.04   MID=22644, Token=4C6ED8E100BF4DBE, OptionSet={}, <empty data>!
    2021-12-22 19:05:57,845 DEBUG UDPConnector - UDPConnector (Thread[UDP-Sender-/0.0.0.0:15727[0],5,Californium/Elements]) sent 12 bytes to 172.24.213.114:49358
    2021-12-22 19:05:57,846 DEBUG ClientManager - Update client
    2021-12-22 19:05:58,003 DEBUG UDPConnector - UDPConnector (0.0.0.0:15727) received 12 bytes from 172.24.213.114:49358
    2021-12-22 19:05:58,006 DEBUG BlockwiseLayer - [LWM2M Server-coap://]  received error ACK-4.05   MID=15760, Token=21A18DD012D20B91, OptionSet={}, <empty data>:
    2021-12-22 19:05:58,008 DEBUG Exchange - Exchange[L4, complete]!
    2021-12-22 19:05:58,009 DEBUG InMemoryMessageExchangeStore - [LWM2M Server-coap://] removing Exchange[L4, complete] for token KeyToken[21A18DD012D20B91]
    2021-12-22 19:05:58,010 DEBUG InMemoryMessageExchangeStore - [LWM2M Server-coap://] removing Exchange[L4, complete] for MID KeyMID[172.24.213.114:49358-15760]
    2021-12-22 19:05:58,012 DEBUG Exchange - local Exchange[L4, complete] completed CON-FETCH  MID=15760, Token=21A18DD012D20B91, OptionSet={"Observe":0, "Content-Format":"application/senml+json", "Accept":"application/senml+json"}, acked "[{"n":"/3303/0/5700"},{"n":"/330".. 64 bytes!
    2021-12-22 19:05:58,013 DEBUG CoapSyncRequestObserver - Received coap response: ACK-4.05   MID=15760, Token=21A18DD012D20B91, OptionSet={}, <empty data>
    2021-12-22 19:05:58,015 DEBUG ResourceTask - Client type is nrf9160dk_nrf9160
    2021-12-22 19:05:58,019 DEBUG BaseMatcher - observation with token Token=21A18DD012D20B91 not established, removing from observation store

    Best regards

  • Hi, 

    I'm afraid I won't be able to provide an answer until January, as our experts are out on Christmas vacation. 

    I would recommend asking in the official Zephyr OS Discord channel for more quicker support. 

    Kind regards,
    Øyvind

  • Your logs shows a "CON-FETCH". Are you sure, that the zephyr lwm2m-client (coap-server) supports FETCH as well? 4.05 / METHOD_NOT_ALLOWED seems to indicate, that it doesn't support FETCH.

  • Hi,

    thanks for the hint with the fetch.

    I did ask about composite observe in the zephyr users mailing list and found out that composite observe is not supported in the current zephyr version (2.7) but it will be in the future. (https://lists.zephyrproject.org/g/users/message/2850?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Arecentpostdate%2Fsticky%2C%2Cobserve%2C20%2C2%2C0%2C88259935)

    BR

    PS: for anyone who requires workaround which does not need to be perfectly clean - I've implemented the Report resource of the Virtual Observe Notify LwM2M object. I skipped the ObserveLinks resource since Corelnk format is not supported yet.

Related