-
Notifications
You must be signed in to change notification settings - Fork 2k
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
examples/gcoap-rust: Expose more functionality #20838
examples/gcoap-rust: Expose more functionality #20838
Conversation
20ac402
to
25fce0e
Compare
Tests with a particle-xenon show 5KiB free stack now; before, that would have been an overflow by 3KiB.
25fce0e
to
8aa3ede
Compare
LEDs can now be toggled with an empty POST, so the maturity concern there is done. (Still doesn't say that all resource implementations are particularly high-quality -- but after all, this is a demo example). |
Before passing this will take another tour through generate-Makefile.ci, but I'd rather do that only after an initial review, because running that takes hours. |
This updates riot-sys, riot-wrappers and the riot-example-modules in for this example, as all those are needed for full LED exposure, as well as coap-message-utils for better error responses. An update to coap-handler-implementations enables the use of the latest riot-examples-modules.
8aa3ede
to
84354ff
Compare
I've taken the liberty to add a ping example. @Teufelchen1, you may want to have fun with that from your console! Both ping and pinged are discoverable through CoAP if= properties, and while I make no promises on the textual format, the (anyway more-fun-because-it-has-more-data) CBOR that comes even with some documentation. |
26d29b0
to
8f5b48d
Compare
A new addition patches the try-lock crate to use its PR'd seanmonstar/try-lock#11 instead of its released version: as so often, armv6's lacking atomics bite and need a workaround. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on my nrf52840dk :)
This still leaves a comfortable 976 byte on the gcoap stack, and 812 on main -- and makes the application fit on way more boards.
Thanks for the review, squashed. |
8aad919
to
e94337b
Compare
Contribution description
The riot-coap-handler-demos has a few ready-made components that were not shown off in examples/rust-gcoap before. I think they are useful to have, as they point users to more example code and to things they can explore with safe Rust bindings. The added resources don't make the example's source code more complex (effectively they're all just adding a line), but obviously they increase code size.
Concretely, this exposes any board LEDs as individual resources (PUT CBOR values false or true, or POST (see maturity)), and also exposes /netif which roughly contains data from
ifconfig
(only MAC address and IP addresses so far).Two non-src/lib.rs changes are an added note in the README on security (none is there, thus we only expose harmless things), updating various riot-wrappers related dependencies (so for example LEDs are properly wrapped in the first place), and a stack size increase.
The CoAP thread's stack size gets increased from 8k to 16k. This fixes an actual bug, where on the particle-xenon the stack usage of the /ps/ handler (that was already active) was around 11k. I've done some digging into it (with terrible methodology, a mix of interactive gdb, attempts to read the stack usage from a Python script in gdb, and eventually resorting to calling ps() over and over in various places because that's faster than breakpoints), and what I can tell so far is that it's not so much related to serialization (I've tried switching CBOR libraries but the effect was present but miniomal) but that a lot of stack is used already in request parsing. Clearly something to investigate further, but for now, easy to fix.
Testing procedure
pipx run --spec 'aiocoap[prettyprint]' aiocoap-client coap://[fe80::the-address-shown%relevant-netif]/.well-known/core
(or just aiocoap-client if you have aiocoap installed) and from there interact with the other resources advertisedThe prettyprinting will make sure you see the returned CBOR in a reasonable form; very recent (I think unpublished) versions even give you readable IP addesses such as this:
(which would be a lot more readable even if tag 54's text notation had the capability of expressing zone identifiers).
Maturity
The LED resources are a bit weird so far in that toggling them requires sending a null value rather than an empty payload; I'd like to fix that before merging.