[riot-notifications] [RIOT-OS/RIOT] net/coap: Add Link Format attributes to resources (#11328)
notifications at github.com
Thu Apr 25 08:22:17 CEST 2019
I created a proof of concept branch, [coap/encode_resources](https://github.com/kb2ma/RIOT/tree/coap/encode_resources), for a function to write link format parameters for a resource.
The implementation builds on the idea of a function to write link format output, as implemented in this PR. My branch allows an application to define its own function to write the link. There is a default implementation, `gcoap_encode_resource()`, which simply writes the path in link format. I added an `_encode_link()` function to the gcoap example handler module. That module defines a const array with the link parameters for each resource, and the `_encode_link()` function appends it to the list output. With an application defined function, the application also has the option to call some specialized link format module to write the output if it wants.
So, the branch writes link parameters without an #ifdef. It also does not alter the existing coap_handler_t callback. The price is a pointer in the gcoap_listener_t, but that seem reasonable to me. (For nanocoap we could add an extern for the custom link writing function, similar to how resources are defined.)
I also like the coap_link_encoder_ctx_t parameter to the `_encode_link()` function. That gives us flexibility for the future. For example, we could add a coap_block_slicer_t to it to write block output.
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the notifications