example/nanocoap: fix block2 example [backport 2018.10] #10298
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #10293
Contribution description
The recent addition of Block2 support in nanocoap included a new resource for the nanocoap_server example, /riot/ver. This resource provides a description of the version of RIOT as well as the board and MCU. However, the construction of the payload includes the null terminator for the component strings. This PR reworks the construction to avoid addition of the \0 bytes.
Testing procedure
To reproduce, send a GET request to the /riot/ver resource. Your implementation may require you to set a block size for the request. You also can use the attached Python script task04_py.txt (renamed to satisfy GitHub), which requires a recent copy of aiocoap.
With aiocoap, the faulty response looks like:
The fixed response looks like:
Issues/PRs references
N/A