net/unicoap: Unified and Modular CoAP Stack: Resource Observation (pt 4)#22277
Draft
carl-tud wants to merge 23 commits into
Draft
net/unicoap: Unified and Modular CoAP Stack: Resource Observation (pt 4)#22277carl-tud wants to merge 23 commits into
carl-tud wants to merge 23 commits into
Conversation
5 tasks
Contributor
Author
|
server.c:37 Need to read .id from properties (set by driver) and set last notification id |
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.
This PR is the 4th in a series to introduce
unicoap, a unified and modular CoAP implementation for RIOT. An overview of all PRs related tounicoapis presented in #21389, including reasons whyunicoapis needed and a performance analysis.What does this PR include?
examples/networking/coap/unicoap_clientandexamples/networking/coap/unicoap_serverHow do I use this?
To use Observation, just import
unicoap_observationin addition to theunicoap_clientand/orunicoap_serverimports.unicoapwill import just the Observation support that's necessary.Client
Pass
UNICOAP_CLIENT_FLAG_OBSERVEtounicoap_send_request_asyncand watch your callback getting invoked for every notification sent from the server. You can explicitly cancel observing the resource by callingunicoap_client_cancel_observation, which sends another request with theObserve=1option.Server
Add the new
UNICOAP_RESOURCE_FLAG_OBSERVABLEto your resource and send notifications usingunicoap_send_notification, which mirrors the API ofunicoap_send_response. Registrations from clients1 are managed automatically byunicoap.I'll organise the monolithic commit into multiple structured commits once this has passed review, and rebase this PR onto #22266 once merged.
Footnotes
gcoaponly allows a single endpoint (i.e., for IP-based transports an IP address) to register for notifications from a resource.unicoaplifts this limitation. You can independently defineCONFIG_UNICOAP_OBSERVATION_REGISTRATIONS_MAXandCONFIG_UNICOAP_OBSERVATION_CLIENTS_MAX. If nostalgia is your thing, don't worry,unicoaphas mercy and graciously offersCONFIG_UNICOAP_OBSERVATION_SINGLE_CLIENT_PER_RESOURCE. ↩