net/gcoap: Replace use of gcoap_finish() with coap_opt_finish()#10892
Merged
kaspar030 merged 4 commits intoRIOT-OS:masterfrom Mar 12, 2019
Merged
net/gcoap: Replace use of gcoap_finish() with coap_opt_finish()#10892kaspar030 merged 4 commits intoRIOT-OS:masterfrom
kaspar030 merged 4 commits intoRIOT-OS:masterfrom
Conversation
6 tasks
kaspar030
approved these changes
Mar 12, 2019
Contributor
kaspar030
left a comment
There was a problem hiding this comment.
ACK.
Tested gcoap example & unittests on native. Code gets a little smaller (unless DEVELHELP is enabled...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Contribution description
#9309 and API Options introduced the struct-based Options API for nanocoap and gcoap. As part of that work, this PR transitions gcoap to use coap_opt_finish() to mark completion of writing message metadata -- header, token, and options.
As we have developed and integrated Options, it became clear that gcoap_finish(), the original mechanism for closing a message, was not flexible enough. Once the payload is written, it becomes difficult and inefficient to attempt to insert Options in front of it. This PR fixes that rookie mistake. :-/ However, to be clear, the procedure to build a message with gcoap_finish() still works.
This PR includes gcoap's internal use of coap_opt_finish(), unit tests, and the module documentation. To limit the scope for a reviewer, we plan to update the gcoap and cord examples in a follow-up PR.
Testing procedure
The items below will exercise everything that has changed.
Issues/PRs references
Part of #9309 struct-based Options API