Skip to content
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

Lwm2m boostrap fixes #1271

Merged
merged 3 commits into from
Aug 11, 2023
Merged

Lwm2m boostrap fixes #1271

merged 3 commits into from
Aug 11, 2023

Conversation

SeppoTakalo
Copy link
Contributor

@SeppoTakalo SeppoTakalo commented Aug 10, 2023

Original PR: zephyrproject-rtos/zephyr#61370
Related nrf PR: nrfconnect/sdk-nrf#12006

This PR fixes major bootstrap related issue and few minor issues.

Bootstrap issue

After introducing a tickless state-machine, our client now enters BOOTSTRA_TRANS_DONE immeadialy when Bootstrap-finnish packet is received. The state transition causes existing socket to be closed, and enters a next state which is DO_REGISTRATION. The problem is that ACK packet to Finnish message was still on the send-queue.
This is a problem on some bootstrap server, as the Finnish is confirmable message, and it may consider bootstrap to be failed as we just closed the connection without ACK.
wireshark

Fix the issue by introducing sm_set_state_delayed() function that causes the next state transition to be delayed. The same delay was previously a side, effect of slow socket-loop. (There is a random possibility, that it did not work previously, but Wireshark shows that it does).

This fix alone was not enough, as some callback modified the next event timestamp directly.

Do not directly modify state variables

On many places in RD client. ctx.client_state was directly written, followed by call next_event_at(0).
I removed all these, and refactored it to use set_sm_state(). Notable change was the lwm2m_rd_client_connection_resume() as it modified the timestamp unconditionally, and without this fix, the previous one does not work.

Wake up engine on pause/resume

Engine pause and Engine resume are public API, so instead of waiting for event-loop to wake up, they should cause it to immediately wake up, so there would be no delay.

This is minor fix, and nobody was complaining it yet.

Engine wake-up call was missing from pause/resume APIs
which caused delay.

Upstream PR: zephyrproject-rtos/zephyr#61370

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
(cherry picked from commit cb46ff519aa7e99f96955b1150a8d3fd54925a75)
…_state()

Some state changes were do by directly writing into
client.engine_state variable, followed by call next_event_at(0);
This causes hard-to-find side effects.

Refactor all state transitions to use set_sm_state() to have better
control for it.

Upstream PR: zephyrproject-rtos/zephyr#61370

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
(cherry picked from commit b55a3b9ca9de116e87a71b1ace05e3ded9dae055)
…tstrap

When BOOTSTRAP FINNISH message was received, it caused
engine to immediately switch to BOOTSTRAP_TRANS_DONE state
which then closed the connection.
Ack packet was still on the send-queue so it never got send before close().

Upstream PR: zephyrproject-rtos/zephyr#61370

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
(cherry picked from commit 42c0a915d0b6565159ed91dc687b72afe62ad2bb)
@rlubos rlubos merged commit 7c57aed into nrfconnect:main Aug 11, 2023
11 checks passed
@SeppoTakalo SeppoTakalo deleted the lwm2m_boostrap_nrf branch August 11, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants