web-servicescontikiiotcoap

Observe multiple resources of a Contiki device with CoAP


This question concerns the CoAP protocol and the CoRE link format as implemented in Contiki-OS.

Suppose a Contiki device sharing several resources which are:

A client can access these resources with their respective URL like for example:

REQ: GET /sensors/humidity

Each of these resources is periodic (except Motion obviously) and observable, but the maximum number of allowed observers configured by default is limited to 3 actually.

We could increase this number to be equal to the number of observable resources and create an observer for each of these resource (I don't know what would be the consequences). We may furthermore create a global "Sensors" periodic resource and share all resource at once.

But is there a better way to do that? Is the standard providing a mechanism which allow us to combine several periodic resources in one observer?

Thanks.


Solution

  • Coap observe draft says:

    If multiple subjects are of interest to an observer, the observer must register separately for all of them.

    So, to reply to your question, no, there is no standard way, at most you could add another url that returns all the sensors if you prefer (but imho it's a very bad solution).

    Instead I would just override the default maximum observers setting. In fact the observe draft doesn't say anything about a maximum number of observers, it's just up to you to set one to be sure that your device doesn't crash because of memory allocation.