[riot-notifications] [RIOT-OS/RIOT] net/coap: Block optimizations (#11057)

Ken Bannister notifications at github.com
Sun Feb 24 17:56:18 CET 2019


### Contribution description
While working on the Block implementation (#10732) we found several opportunities for optimization. However, we decided to wait until the implementation was complete before implementing them. This PR includes the improvements listed below. 

This PR also completes the Block implementation!

| Commit | Notes |
| ------ | ------ |
| c02872f | Adds coap_opt_put_uint() to write a generic uint-based option for the Buffer API. The Packet API already includes coap_opt_add_uint(). This function allows the implementation of simple options, like Content-Format, to inline this function. It also allows a user to easily add an option to a message for which there is not a specific implementation presently, like Max-Age or Size1.  |
| 1420c8e | Reimplements coap_opt_put_blockN(), coap_put_option_ct(), and coap_put_option_block1() to inline coap_opt_put_uint(). Removes implementations of those functions.  |
| d90f022 | Reworks the static _slicer_blknum() into the more useful _slicer2blkopt(). The former function only calculated the block number from a slicer struct. The latter adds a _more_ parameter to completely calculate the uint for the block option from a slicer struct. Also replaces three uses of _slicer_blknum() with _slicer2blkopt(), which also removes the duplicate calculation of the block option uint value. |
| d8ccda5 | The previous commit removed the only use of coap_opt_put_block_object(), which was added during recent development for completion of block. This commit removes coap_opt_put_block_object(). |
| 0ff2856 | The coap_get_blockN() functions were implemented separately. Only the defintiion of coap_get_block1() calculated the _offset_ attribute for the coap_block1_t struct. This commit reworks the implementation to a single definition that calculates the offset, with inlines for the specific "blockN" functions. |
| 789646e | Fixes coap_block_object_init() to also calculate the _offset_ attribute for coap_block1_t struct.  |

### Testing procedure
Verify no regression by rerunning the test procedure in #11024 and #11056.

### Issues/PRs references
Completes #10732.
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * net/nanocoap: add inline function for Content-Format
  * net/gcoap: use coap_opt_finish within gcoap
  * net/gcoap: use coap_opt_finish in unit tests
  * net/gcoap: update module doc for coap_opt_finish
  * examples/gcoap: use coap_opt_finish()
  * examples/cord_epsim: use coap_opt_finish()
  * examples/cord_ep: use coap_opt_finish()
  * net/nanocoap: Return error from coap_opt_add_xxx() if no space
  * net/nanocoap: return error from coap_opt_finish if no space
  * net/nanocoap: clarify API buffer space doc
  * tests/nanocoap: verify error when overfill buffer
  * net/gcoap: verify error when overfill on coap_opt_finish
  * net/nanocoap: create function groups in module doc
  * net/nanocoap: reference new function sections
  * net/nanocoap: rename Options APIs for clarity
  * net/nanocoap: move detailed module doc to nanocoap_sock
  * net/nanocoap: refactor block option put
  * net/nanocoap: refactor block option control use
  * examples/nanocoap: use refactored block control function
  * net/nanocoap: add block init helper function
  * net/nanocoap: use block init helper internally
  * net/nanocoap: refactor block2_finish()
  * net/nanocoap: add block slicer init function
  * net/nanocoap: add Packet API block write functions
  * examples/gcoap: handle block2 response
  * net/gcoap: add module documentation for block use
  * net/nanocoap: add generic uint block option
  * net/nanocoap: use coap_opt_add_uint() and remove unused
  * net/coap: improve slicer to block helper
  * net/nanocoap: remove unused function
  * net/coap: add generic get block function
  * net/nanocoap: initialize offset attribute

-- File Changes --

    M examples/cord_ep/main.c (8)
    M examples/cord_epsim/main.c (4)
    M examples/gcoap/Makefile (4)
    M examples/gcoap/gcoap_cli.c (74)
    M examples/nanocoap_server/coap_handler.c (4)
    M sys/include/net/gcoap.h (194)
    M sys/include/net/nanocoap.h (1410)
    M sys/include/net/nanocoap_sock.h (104)
    M sys/net/application_layer/cord/ep/cord_ep.c (4)
    M sys/net/application_layer/cord/epsim/cord_epsim.c (2)
    M sys/net/application_layer/gcoap/gcoap.c (35)
    M sys/net/application_layer/nanocoap/nanocoap.c (132)
    M tests/unittests/tests-gcoap/tests-gcoap.c (46)
    M tests/unittests/tests-nanocoap/tests-nanocoap.c (12)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/11057.patch
https://github.com/RIOT-OS/RIOT/pull/11057.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/11057
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190224/47546843/attachment-0001.html>


More information about the notifications mailing list