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

pkg/libcoap: Add in libcoap CoAP library support #19889

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrdeep1
Copy link
Contributor

@mrdeep1 mrdeep1 commented Aug 15, 2023

Contribution description

Adds in support for using the libcoap CoAP library with version 4.3.4, as per https://github.com/obgm/libcoap with documentation at https://libcoap.net/doc/reference/develop/ .

pkg/libcoap contains the information for the libcoap library to be included and built as appropriate.
examples/libcoap-client provides an example CoAP client.
examples/libcoap-server provides an example CoAP server.
pkg/Kconfig updated to include libcoap.

Testing procedure

test/pkg/libcoap provided which does a loop-back test with libcoap client logic sending request to libcoap server logic and sanity checks the response.

Issues/PRs references

None, other than adding in new functionality.

@github-actions github-actions bot added Area: doc Area: Documentation Area: pkg Area: External package ports Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration labels Aug 15, 2023
@mrdeep1 mrdeep1 force-pushed the libcoap_add branch 2 times, most recently from 3dc435e to a04974a Compare August 18, 2023 13:49
Copy link
Member

@JKRhb JKRhb left a comment

Choose a reason for hiding this comment

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

Just a couple of minor suggestions below to get rid of the warnings.

examples/libcoap-client/client-coap.c Outdated Show resolved Hide resolved
examples/libcoap-client/client-coap.c Outdated Show resolved Hide resolved
examples/libcoap-server/server-coap.c Outdated Show resolved Hide resolved
examples/libcoap-server/server-coap.c Outdated Show resolved Hide resolved
examples/libcoap-server/server-coap.c Outdated Show resolved Hide resolved
examples/libcoap-server/server-coap.c Outdated Show resolved Hide resolved
examples/libcoap-server/server-coap.c Outdated Show resolved Hide resolved
examples/libcoap-server/server-coap.c Outdated Show resolved Hide resolved
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 7, 2023
@riot-ci
Copy link

riot-ci commented Sep 7, 2023

Murdock results

✔️ PASSED

84938e4 pkg/libcoap: Add in libcoap CoAP library support

Success Failures Total Runtime
10255 0 10255 16m:54s

Artifacts

@mrdeep1 mrdeep1 force-pushed the libcoap_add branch 11 times, most recently from fd8dd7f to 0e71780 Compare September 9, 2023 16:38
@github-actions github-actions bot added the Area: sys Area: System label Sep 10, 2023
@mrdeep1 mrdeep1 force-pushed the libcoap_add branch 6 times, most recently from a83ac87 to 53a12f4 Compare September 11, 2023 10:15
@mrdeep1
Copy link
Contributor Author

mrdeep1 commented Nov 18, 2023

Is there anything I need to do here to progress this?

@mrdeep1 mrdeep1 force-pushed the libcoap_add branch 5 times, most recently from 2cebb3c to d1b223e Compare March 5, 2024 10:38
@miri64 miri64 requested a review from chrysn March 7, 2024 09:19
@miri64
Copy link
Member

miri64 commented Mar 7, 2024

@chrysn could you maybe have a look?

@mrdeep1 mrdeep1 force-pushed the libcoap_add branch 2 times, most recently from 239cd10 to f6e909c Compare May 9, 2024 12:54
@mrdeep1
Copy link
Contributor Author

mrdeep1 commented May 9, 2024

I guess I do not understand why the Murdock test build failed for libcoap - msb-430 is definitely defined in tests/pkg/libcoap/Makefile.ci as a BOARD_INSUFFICIENT_MEMORY entry. It appears that size_t in this case is only 2 bytes wide.

@maribu
Copy link
Member

maribu commented May 9, 2024

This is correct behavior. The BOARD_INSUFFICIENT_MEMORY is used to flag boards that have too little RAM and/or flash for the linking step to succeed. Hence, the CI will do all compilation steps (to still confirm that the code is otherwise valid and portable C code), but skip the final linking step.

We do have two platforms where size_t is 16 bits wide: AVR and MSP430.

Note that size_t is defined to be able to hold any array index for an in-memory C array. So it may even not be possible to cast any pointer to size_t and back without loosing information, as the address space may be larger than anything that can be stored in RAM in a contiguous fashion.

Hence, size_t is not a suitable type for lengths of files written to e.g. SD cards and transferred over network e.g. using CoAP blockwise transfers.

But given that this bug is likely upstream, you could just add FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit to the Makefile.dep of the package and prevent it from being compiled on our 8 bit and 16 bit boards.

@mrdeep1
Copy link
Contributor Author

mrdeep1 commented May 9, 2024

Thanks for the information, It looks like only a compile issue in one place, which I will get fixed shortly.

@maribu
Copy link
Member

maribu commented May 9, 2024

I only took a quick peek, but this looks good to me. @chrysn might be interested in this, as this would also provide an alternative implementation of OSCORE.

One thing: Most (if not all) of the KConfig parts can be dropped now, (see https://forum.riot-os.org/t/last-chance-for-kconfig-dependency-modelling/4068 for details). Selection of modules and packages and the dependency resolution via KConfig has been removed from upstream; but you can still use KConfig to expose configuration knobs (such as buffer sizes, ports to listen on, etc.).

I can take an in-depth look tomorrow, if you think this is ready for review? Would be cool to get this back in :)

@mrdeep1
Copy link
Contributor Author

mrdeep1 commented May 9, 2024

I can take an in-depth look tomorrow, if you think this is ready for review?

I have just found an OSCORE issue that needs to get fixed. I will fix this and have everything pushed for Monday.

Most (if not all) of the KConfig parts can be dropped now

I will look at doing this, probably not by Monday though.

@mrdeep1
Copy link
Contributor Author

mrdeep1 commented May 9, 2024

I have just found an OSCORE issue that needs to get fixed. I will fix this and have everything pushed for Monday.

Just pushed the fix. Do you want all these commits squashed?

@maribu
Copy link
Member

maribu commented May 9, 2024

Just pushed the fix. Do you want all these commits squashed?

Do as you prefer. Some other maintainers are a bit picky about when to squash, but I only look at the diff to upstream (or to when I last checked). So as long as only I am reviewing, you can squash (or not squash) during the review as works best for you.

@mrdeep1
Copy link
Contributor Author

mrdeep1 commented Jun 6, 2024

@maribu I have just pushed libcoap v4.3.5rc1 for review.

I have left in the Kconfig stuff for now - certainly users can just modify app.config to get the same results for configuring things.

libcoap version 4.3.5rc3.

Using Sock interface.

Includes a CoAP client and CoAP server example.

tests/pkg/libcoap: Simple CoAP over DTLS loopback test.
@mguetschow mguetschow requested review from mguetschow and removed request for smlng October 29, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: doc Area: Documentation Area: examples Area: Example Applications Area: Kconfig Area: Kconfig integration Area: pkg Area: External package ports Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants