AVSystem / Anjay

C implementation of the client-side OMA LwM2M protocol
Other
188 stars 68 forks source link

How to get higher notification frequency than 1 per second? #57

Closed gr8rampage closed 2 years ago

gr8rampage commented 2 years ago

Dear Anjay team,

I am developing an Anjay based project which uses observes/notifications mechanism. Sometimes those notifications need to be sent in high frequency.

Apparently, Anjay by default does not allow notifications to be sent in higher frequency than 1 notification per second. Is there any way I can get around this limitation? From my tests I can see that there is no problem with active pulling of a resource value in higher frequencies (read operation), but in case of notifications there is always minimum interval of 1 second.

I tried to quickly look through the library to find the place where this 1 second interval is located, but with no luck so far. Thanks in advance.

Cheers, Tom

kFYatek commented 2 years ago

Hi Tom,

The behavior you're seeing is related to the "Minimum Period" attribute defined for LwM2M observations (see LwM2M TS 1.0.2, page 19). The default value for this attribute in Anjay is 1[^1], which means that the notifications are throttled to one per one second by default.

You can change that by issuing a Write-Attributes operation from the server side, setting pmin to 0 for the resource you want to observe more frequently, or by setting the value of the Default Minimum Period resource in the Server object (/1/x/2) to 0 to change the global default. The latter you can achieve by either issuing a Write operation from the server side, or by setting the default_min_period field in the anjay_server_instance_t structure passed to anjay_server_object_add_instance().

[^1]: This is a bug, by the way, so thanks for helping to discover it. The LwM2M TS explicitly says that the default should be 0. The value of 1 that we used seems to come from some pre-1.0 draft version of the TS and we never noticed the change in later releases. We will fix it for future Anjay releases.

gr8rampage commented 2 years ago

Thank you @kFYatek , with Default Minimum Period resource value set to 0, the notification frequency throttling is gone.