golioth / golioth-zephyr-sdk

Golioth SDK For Zephyr
https://www.golioth.io
Apache License 2.0
67 stars 19 forks source link

samples: dfu: call sys_reboot() from sysworkq #260

Closed mniestroj closed 2 years ago

mniestroj commented 2 years ago

So far sys_reboot() was called directly from CoAP reply callback after a bit of delay. This was fine so far, as all packets sent to cloud with golioth_fw_report_state() were sent synchronously (just once, without waiting for reply or acknowledgement). This approach prevents any communication with Golioth cloud, as connection thread (the one calling data_received() callback) is blocked. This means that no packet (for reporting firmware version) retransmission is possible (once it will be implemented).

Get rid of k_sleep() call and schedule a work item that will be run from system workqueue with proper delay. That way Golioth CoAP receive handler is not blocked and communication with Golioth cloud can still happen, leaving possibility for sending CoAP request from golioth_fw_report_state() API by system client thread (just after finishing execution of data_received() callback), instead of doing it synchronously (calling send() on transport socket) directly in golioth_fw_report_state().

github-actions[bot] commented 2 years ago

Visit the preview URL for this PR (updated for commit 88ba0f7):

https://golioth-zephyr-sdk-doxygen-dev--pr260-sample-dfu-sys-r-b1kpye9t.web.app

(expires Fri, 02 Sep 2022 06:48:38 GMT)

🔥 via Firebase Hosting GitHub Action 🌎