-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zephyr: coap: add cancel observations #468
Conversation
Visit the preview URL for this PR (updated for commit 724cfae): https://golioth-firmware-sdk-doxygen-dev--pr468-szczys-cancel-87so7hvd.web.app (expires Mon, 27 May 2024 19:07:21 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: a9993e61697a3983f3479e468bcb0b616f9a0578 |
93ccc11
to
5ad8222
Compare
Code Coverage
|
5ad8222
to
db9d4c4
Compare
db9d4c4
to
91ec330
Compare
f938d13
to
cb62433
Compare
cb62433
to
161664d
Compare
6ad8ec9
to
4b4040e
Compare
161664d
to
26ecaa6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work cutting through the cruft here @szczys!
The way zephyr_coap_req is interacting with coap_client_zephyr feels a little weird - can we see if there's a way to simplify that?
26ecaa6
to
5752223
Compare
5752223
to
19334fc
Compare
Check that path length will fit into the path member of a golioth_coap_request_msg_t before trying to copy the string. Signed-off-by: Mike Szczys <[email protected]>
The golioth_coap_client_observe_async() command is renamed to golioth_coap_client_observe(). This doesn't change functionality, but merely makes the function name shorted as async is assumed for all observations. Signed-off-by: Mike Szczys <[email protected]>
Introduce function that adds a coap "eager release" for telling the server we want to cancel an observation. Signed-off-by: Mike Szczys <[email protected]>
Notify the server that we are cancelling an observation. Signed-off-by: Mike Szczys <[email protected]>
Observe requests are stored in the client coap_reqs linked list. Walk the coap_reqs list, comparing the user_data pointer to each client observe slot address. Observations are cancelled by setting the client observations slot as !in_use, removing the request from the coap_reqs list, then sending an "eager release" request to the server using the original token, path, etc. Finally, the request memory is freed. Signed-off-by: Mike Szczys <[email protected]>
Handle requests of the GOLIOTH_COAP_REQUEST_OBSERVE_CANCEL type by sending an "eager release" to the server indicating an observation is being cancelled. Signed-off-by: Mike Szczys <[email protected]>
Observation updates are received from the server as unsolicited requests. The token will always match the token used when the observation was registered. The client observations list stores a copy of the original request message that contains the token to compare against, as well as the callback to notify. Observations are cancelled by settings the client observations slot as !in_use, then sending an "eager release" request to the server using the original token, path, etc. Signed-off-by: Mike Szczys <[email protected]>
Add wrapper function around the port-specific cancel functions. Signed-off-by: Mike Szczys <[email protected]>
This tests that observations can be cancelled and reestablished. This is currently an internal API which will be extended to service APIs in future work. Signed-off-by: Mike Szczys <[email protected]>
Correct the name of the board used in the build step for running tests locally. Signed-off-by: Mike Szczys <[email protected]>
19334fc
to
724cfae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on this one @szczys! Quite the beast to wrangle.
Add ability to remove observations from the client coap_reqs lists, and mark the observation slots as not in_use. The cancellation process sends an "eager release" coap packet to the server indicating the observation has been cancelled.
This searches the coap_reqs linked list by matching the request message pointer which is why the
coap_client.h
header was included. I think a future improvement to how observations are handled should be storing crucial observation values instead of the the request message. If we store the coap token as one of those values, it can be used to search in the coap_reqs.