zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
11k stars 6.7k forks source link

Handle LwM2M requests asynchronously #73224

Open koalatux opened 6 months ago

koalatux commented 6 months ago

Is your enhancement proposal related to a problem? Please describe. Handling of LwM2M requests is done in a blocking way. While handling a request no other requests can be handled at that time. To build a response we would like to query information from an external component, which can take some seconds. We would like to handle other LwM2M requests during that time.

Describe the solution you'd like In a request callback we would like to store the LwM2M request context away, send an empty CoAP ACK and tell the LwM2M engine it should not send a response upon returning of the callback. Later we want to send the response separately from a different thread using the previously stored request context.

Describe alternatives you've considered We considered calling lwm2m_acknowledge() to send an empty CoAP ACK and then block the LwM2M thread until we have the final response. While this somewhat lowers the pain it still does not allow handling of other LwM2M messages nor does it send repeated acknowledge messages for receiving duplicate requests in case the first acknowledge got lost.

Additional context None

github-actions[bot] commented 6 months ago

Hi @koalatux! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

boaks commented 3 months ago

At least in the earlier LwM2M TS (1.0) the recommendation was to use "always an empty token", which will not work with parallel pending requests from the same LwM2M server. I guess, pretty much are using none-empty tokens, so in practice that may work. I would consider to add then some notes on that.