[riot-notifications] [RIOT-OS/RIOT] net/coap: Add Link Format attributes to resources (#11328)

Kaspar Schleiser notifications at github.com
Tue Apr 2 13:59:21 CEST 2019

can we extend the handler's functionality? We could have "virtual" methods.
Currently, every handler (that cares) gets the request method out of the pkt structure.

Maybe it makes sense to declare the handlers not "request handlers", but "resource handlers".
We can then make them handle e.g., ".well-known/core" themselves, which comes in handy with the new subtrees. And, we could make them generate their own link format, dynamically if necessary.

This is just an idea, but the outline is this:

Change the handler signature:
 * @brief   Resource handler type     
-typedef ssize_t (*coap_handler_t)(coap_pkt_t *pkt, uint8_t *buf, size_t len, void *context);
+typedef ssize_t (*coap_handler_t)(coap_pkt_t *pkt, uint32_t method, uint8_t *buf, size_t len, void *context);

Then a handler could be defined with:

{ "/node/info",  COAP_GET | COAP_LINK_FORMAT, _handler_info, NULL },

int _handler_info(pkt, method, buf, len, context) {
if (method==COAP_LINK_FORMAT) {
  // write link format to buf

I'd rather avoid adding (more) optional fields to the coap struct.

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...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190402/92db3463/attachment-0001.html>

More information about the notifications mailing list