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
10.51k stars 6.44k forks source link

lwm2m: firmware pull not working with queue mode #71450

Closed laurin closed 4 months ago

laurin commented 5 months ago

When using LwM2M with queue mode enabled, the pull firmware update does not work. The lwm2m subsystem prints the following error to the console

[00:00:34.201,000] <inf> net_lwm2m_engine: Connected, sock id 1
[00:00:34.201,000] <inf> net_lwm2m_pull_context: Connecting to server coap://some.coap.server:5883/f/fw.bin
[00:00:34.201,000] <err> net_lwm2m_pull_context: Error sending LWM2M packet (err:-1).

To Reproduce

Expected behavior The zephyr lwm2m subsystem pulls the update blockwise.

Impact LwM2M firmware update in pull-mode cannot be used with queue mode enabled.

Environment:

Additional context In subsys\net\lib\lwm2m\lwm2m_pull_context.c, transfer_request calls lwm2m_send_message_async, which returns the -1 error. In lwm2m_send_message_async in subsys\net\lib\lwm2m\lwm2m_message_handling.c, a call to lwm2m_rd_client_connection_resume will be made, if queue mode is enabled. That function returns -EPERM, because the pointers client.ctx and client_ctx are not the same.

I currently do not have a good enough overview to know what is happening. My wild guess would be that this is caused by the fact that the pull operation is using another server then the connected lwm2m server.

My hack to get it working for now was to comment out the call to lwm2m_rd_client_connection_resume in subsys\net\lib\lwm2m\lwm2m_message_handling.c.

laurin commented 5 months ago

This issue has also been mentioned here: https://discord.com/channels/720317445772017664/886300320643317760/1225422570896228362