This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Add children to a Thread ressource

Hello

I am developing an application based on the "ble_thread_dyn_mtd_coap_cli" example.
To create a Thread resource, I see that the "otCoapAddResource()" function is called.
My question is: is it possible to create child resources with this function?

For example, I would like to create a resource hierarchy like this:
LED
  - LED1
  - LED2
  - LED3

So is it possible to create a tree like this so that I can send a request to the resource "/led/led2" to turn on only led2?

Thank you

  • Hello QuentinD!

    Your question seems to be related to CoAP's specification itself rather than an Thread related question.

    As you are probably aware, CoAP resources are defined by their path and the REST methods implemented. This architecture allows flexibility on path definition in such way that you can define a CoAP resource that listens on /led and three others that listen on /led/1, /led/2 and /led/3.

    The action you implement on a request to /led can call the three functions the other paths call. Does this solve your problem?

    As a final note I would advice against using the OpenThread's implementation of CoAP since it is not as complete and not as actively maintained as Zephyr's CoAP implementation.

Related