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: Add offset to post-write callback #72590

Merged

Conversation

SeppoTakalo
Copy link
Collaborator

@SeppoTakalo SeppoTakalo commented May 10, 2024

This PR contains fix for #71351 and tests to verify that, but also new fixes for issues that I saw while implementing the tests.

lwm2m: Add offset to post-write callback

When Block-Wise transfer restarts, the post-write callback should
receive some indication that the block is actually a beginning of new,
instead of part of previous transfer.

NOTE: This is API break.

Fixes #71351
Fixes #71269

test: lwm2m: Add tests for Block-Wise transfers

Block-Wise GET, PUT and SEND

lwm2m: Allow Block-Wise write without callbacks

Allow Block-Wise writes to resources that have enough buffer for
the whole content. Calculate the offset before calling the
content specific write handlers when callback is not set.

Previously only resources with post-write callback were able to
assemble the content.

test: lwm2m: Enable DTLS Connection ID

Enable connection ID because it is on by default on the
client example as well.

@SeppoTakalo
Copy link
Collaborator Author

APi changes can be quickly refactored with following Coccinelle script

@@
identifier write_cb;
identifier oid;
identifier rid;
identifier riid;
identifier data;
identifier len;
identifier last;
identifier size;
type uint16_t;
@@

- int write_cb(uint16_t oid, uint16_t rid, uint16_t riid, uint8_t *data, uint16_t len, bool last, size_t size)
+ int write_cb(uint16_t oid, uint16_t rid, uint16_t riid, uint8_t *data, uint16_t len, bool last, size_t size, size_t offset)
{
	...
}

To use it, save as ~/refactor_post_write_cb.spatch and run

spatch --sp-file ~/refactor_post_write_cb.spatch --in-place src/*.c

@SeppoTakalo SeppoTakalo force-pushed the lwm2m_fix_blockwise_push branch 3 times, most recently from e31cade to 2899707 Compare May 10, 2024 16:52
Copy link
Contributor

@rlubos rlubos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Would be good to add an entry in the migration guide about the API change.

tests/net/lib/lwm2m/interop/src/firmware_update.c Outdated Show resolved Hide resolved
@marco85mars20
Copy link
Collaborator

Looks great! Thanks for implementing this fix @SeppoTakalo

@zephyrbot zephyrbot added the Release Notes To be mentioned in the release notes label May 13, 2024
@zephyrbot zephyrbot requested a review from aescolar May 13, 2024 14:25
@SeppoTakalo
Copy link
Collaborator Author

Added a migration guide and fixed the copyright date.

rlubos
rlubos previously approved these changes May 13, 2024
Copy link
Member

@aescolar aescolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor things

doc/releases/migration-guide-3.7.rst Outdated Show resolved Hide resolved
doc/releases/release-notes-3.7.rst Outdated Show resolved Hide resolved
doc/releases/migration-guide-3.7.rst Outdated Show resolved Hide resolved
When Block-Wise transfer restarts, the post-write callback should
receive some indication that the block is actually a beginning of new,
instead of part of previous transfer.

Fixes zephyrproject-rtos#71351

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Block-Wise GET, PUT and SEND

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Allow Block-Wise writes to resources that have enough buffer for
the whole content. Calculate the offset before calling the
content specific write handlers when callback is not set.

Previously only resources with post-write callback were able to
assemble the content.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Enable connection ID because it is on by default on the
client example as well.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Copy link
Collaborator

@marco85mars20 marco85mars20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@marco85mars20
Copy link
Collaborator

This PR also fixes #71269

@aescolar aescolar merged commit 6257576 into zephyrproject-rtos:main May 15, 2024
23 checks passed
@SeppoTakalo SeppoTakalo deleted the lwm2m_fix_blockwise_push branch May 23, 2024 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LWM2M area: Networking area: Samples Samples Release Notes To be mentioned in the release notes
Projects
None yet
6 participants