Closed mniestroj closed 1 year ago
Visit the preview URL for this PR (updated for commit ada5fee):
https://golioth-zephyr-sdk-doxygen-dev--pr328-coap-cancel-requ-mwi5sdx8.web.app
(expires Thu, 15 Dec 2022 22:29:58 GMT)
🔥 via Firebase Hosting GitHub Action 🌎
Sign: a389eefadf4b4b68a539327b3459dd66c142cf49
First of all, do not allow to schedule CoAP requests anymore when client is disconnected from Golioth server. From now on, whenever
golioth_coap_req_cb()
API (and all APIs built on top of it, like LightDB State APIs, LightDB Stream APIs, DFU, etc.) will be called in "disconnected" state, scheduling such CoAP request will fail with-ENETDOWN
error code. This will let higher layers know that communication with server is not possible and either such request can be dropped immediately (for synchronous communication, like responding to RPC) or enqueued for sending when connection is brought back.Cancel all pending requests on disconnect event, so that those requests do not wait infinitely for new connection with Golioth server. Instead, invoke user-defined callbacks with
-ESHUTDOWN
error code, so that such "request cancelled" event can be handled accordingly.Add API tests when there is "connected" and "disconnected" state of Golioth client. Check expected error codes and payloads (when successful) in both states.
Check also behavior of callback-based API when the request was sent during "connected" state and client got disconnected immediately after. Such case should result in
-ESHUTDOWN
due to request being cancelled on "disconnected" event.