eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
652 stars 407 forks source link

Observe/Notify - Notify with CON #564

Closed iot-cloud closed 6 years ago

iot-cloud commented 6 years ago

Hi Leshan Gate Keeper,

I am trying to figure out how to implement the notification with CON. Currently the notification is implemented to support NON in Leshan.

Is there a way for me to extend the BaseInstanceEnabler to set the Option header to support the Notify-CON? Given that I can only void addResourceChangedListener(ResourceChangedListener listener); void removeResourceChangedListener(ResourceChangedListener listener); ReadResponse read(int resourceId); WriteResponse write(int resourceid, LwM2mResource value); ExecuteResponse execute(int resourceid, String params); ObserveResponse observe(int resourceid); void reset(int resourceId); How do I find out the handler to ObjectReource->CoapResource from the fired Event/Enabler and hopefully is able to perform setObserveType(Type type)? I also not fully understand the relation concept implemented in CoapResource/ObjectResource.

Regards, hlkn

sbernard31 commented 6 years ago

Unfortunately, there is now way to configure the use of CON or NON by resource/object for now.

But there a way to configure this for whole system using californium NetworkConfig. There is 2 parameters about that : NOTIFICATION_CHECK_INTERVAL_COUNT (default 100) : number of NON (-1) notifications between 2 CON notifications. NOTIFICATION_CHECK_INTERVAL(default 86400000ms = 1d) : number of seconds between 2 CON notifications.

I also not fully understand the relation concept implemented in CoapResource/ObjectResource.

We have 2 module : client.core and client.cf client.core is not dependent of californium and contains only LWM2M logic (no Coap logic) and ideally most of the LWM2M logic should be implemented here. client.cf is dependent of californium and contains specific code about californium. generally this is mainly transformation from CoAP concept to LWM2M concept.

The LWM2M Object API of leshan client expose LWM2M concept without exposing any coap concept. If we want to change this is will not be straightforward because of this choice of implementation.

Is those californium global settings enough for your use case ?

sbernard31 commented 6 years ago

I add this question/answer to https://github.com/eclipse/leshan/wiki/LWM2M-Observe#i-want-leshan-client-to-send-con-notifications

@iot-cloud, Is those californium global settings enough for your use case ? Could we close this issue ?

(in a general way, could you close issues when you get enough help)