[riot-notifications] [RIOT-OS/RIOT] nanocoap: Move application functionality to nanocoap sock (#11488)

Ken Bannister notifications at github.com
Sat May 4 13:14:22 CEST 2019


### Contribution description
#11098 added the ability for a single (nano|g)coap resource to respond to a subtree of request URIs. Open PR #11436 additionally will provide a mechanism to lookup into a nested set of resources to handle requests within that subtree. This mechanism includes a new function and a subtree handler struct in the base nanocoap library. However, gcoap already has the ability to specify multiple sets of handlers via its listener mechanism.

The location of the additional capability for 11436 in the base nanocoap library means gcoap must evaluate whether or how to incorporate the new nanocoap subtree handlers. In this case, the new mechanism is not required. This conflict illustrates how "nanocoap" really is a combination of two tools:

* a base CoAP library, useful for any application level tool like gcoap
* an application level tool itself

nanocoap as an application already includes the [nanocoap sock](http://doc.riot-os.org/group__net__nanosock.html) module for high level functions to send and receive a message. So, this PR extends the split of these two roles by moving more application level functionality to the nanocoap sock module. Specifically, this includes these methods and structs:

* coap_build_reply()
* coap_block2_build_reply()
* coap_handle_req()
* coap_reply_simple()
* coap_well_known_core_default_handler()
* coap_resources[]
* coap_resources_numof

With this change, nanocoap sock independently can add the subtree handler functionality in 11436. This relocation allows nanocoap to innovate without causing a conflict with gcoap. At the same time, if this new mechanism develops into a generally worthwhile feature, it can be migrated to the base nanocoap library in the future.

### Testing procedure
No new functionality, so ensure nothing is broken:

* nanocoap unit tests
* nanocoap_cli test 
* nanocoap_server example

### Issues/PRs references
See description.

You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/11488

-- Commit Summary --

  * net/nanocoap: move reply funcs and app resources to nanocoap sock
  * tests/nanocoap: update for reply function move to nanocoap sock
  * examples/nanocoap: update for reply function move to nanocoap sock

-- File Changes --

    M examples/nanocoap_server/coap_handler.c (2)
    M sys/include/net/nanocoap.h (120)
    M sys/include/net/nanocoap_sock.h (131)
    M sys/net/application_layer/nanocoap/nanocoap.c (149)
    M sys/net/application_layer/nanocoap/sock.c (150)
    M tests/nanocoap_cli/request_handlers.c (2)
    M tests/unittests/tests-nanocoap/Makefile.include (3)
    M tests/unittests/tests-nanocoap/tests-nanocoap.c (2)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11488.patch
https://github.com/RIOT-OS/RIOT/pull/11488.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11488
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190504/a3cca558/attachment.html>


More information about the notifications mailing list