diff --git a/examples/rust-gcoap/Cargo.lock b/examples/rust-gcoap/Cargo.lock index 38bc8beb17d49..0a20a638dcf1e 100644 --- a/examples/rust-gcoap/Cargo.lock +++ b/examples/rust-gcoap/Cargo.lock @@ -34,32 +34,27 @@ checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" [[package]] name = "bindgen" -version = "0.64.0" +version = "0.69.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cexpr", "clang-sys", + "itertools", "lazy_static", "lazycell", "log", - "peeking_take_while", + "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex 1.3.0", - "syn 1.0.109", + "syn 2.0.75", "which", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.6.0" @@ -161,9 +156,9 @@ dependencies = [ [[package]] name = "coap-handler-implementations" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbcd2aeab8575ae5b10c04ce5649cd30113c7c2d0d085c393b79a638fd36a854" +checksum = "be078e893f1f88cab31e2af83bbbb90cd5f8e9e95384cbbb4b45c8d537dffe35" dependencies = [ "ciborium-io", "coap-handler", @@ -173,7 +168,8 @@ dependencies = [ "crc", "document-features", "embedded-io", - "minicbor", + "minicbor 0.19.1", + "minicbor 0.24.4", "serde", "serde_cbor", "windowed-infinity", @@ -182,8 +178,6 @@ dependencies = [ [[package]] name = "coap-message" version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ccab4ff10bcaab1d7f017c34ea598e9f21d187c32f6f086d7abd580b0412096" dependencies = [ "num-traits", ] @@ -206,13 +200,11 @@ dependencies = [ [[package]] name = "coap-message-utils" version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ba07600e8cd4a6bf7ee0df249fc66bb89b8c6deedcce5b4e93b192e14b3306" dependencies = [ "coap-message", "coap-numbers", "document-features", - "minicbor", + "minicbor 0.19.1", ] [[package]] @@ -333,12 +325,42 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" +[[package]] +name = "embedded-hal-async" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4c685bbef7fe13c3c6dd4da26841ed3980ef33e841cddfa15ce8a8fb3f1884" +dependencies = [ + "embedded-hal 1.0.0", +] + [[package]] name = "embedded-io" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" +[[package]] +name = "embedded-nal" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db9efecb57ab54fa918730f2874d7d37647169c50fa1357fecb81abee840b113" +dependencies = [ + "heapless 0.7.17", + "nb 1.1.0", + "no-std-net", +] + +[[package]] +name = "embedded-nal-tcpextensions" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2e746f564378f553ee88d860885d74eaa85f462bbd87db348a3e27cfc36230" +dependencies = [ + "embedded-nal", + "heapless 0.7.17", +] + [[package]] name = "errno" version = "0.3.9" @@ -438,6 +460,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -511,19 +542,25 @@ name = "minicbor" version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7005aaf257a59ff4de471a9d5538ec868a21586534fff7f85dd97d4043a6139" + +[[package]] +name = "minicbor" +version = "0.24.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29be4f60e41fde478b36998b88821946aafac540e53591e76db53921a0cc225b" dependencies = [ "minicbor-derive", ] [[package]] name = "minicbor-derive" -version = "0.13.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1154809406efdb7982841adb6311b3d095b46f78342dd646736122fe6b19e267" +checksum = "297ad6022c004a6c54f0fb28bbd2306314d5a4edc767e56b4b4cc48fc2371654" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.75", ] [[package]] @@ -553,6 +590,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" +[[package]] +name = "no-std-net" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bcece43b12349917e096cddfa66107277f123e6c96a5aea78711dc601a47152" + [[package]] name = "nom" version = "7.1.3" @@ -574,15 +617,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "peeking_take_while" -version = "0.1.2" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" [[package]] name = "pin-project" @@ -610,6 +647,22 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "portable-atomic" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn 2.0.75", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -666,7 +719,7 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "riot-coap-handler-demos" version = "0.2.0" -source = "git+https://gitlab.com/etonomy/riot-module-examples/#ab8e8e596fdbfd89c519e848cc7970b1c8410fea" +source = "git+https://gitlab.com/etonomy/riot-module-examples/#9252de4b8cd844e788dc3ebbd0f35f79c5e4edc9" dependencies = [ "ciborium-io", "ciborium-ll", @@ -678,9 +731,11 @@ dependencies = [ "document-features", "embedded-graphics", "embedded-hal 1.0.0", + "embedded-hal-async", "heapless 0.7.17", "hex", - "minicbor", + "minicbor 0.24.4", + "no-std-net", "riot-shell-commands", "riot-sys", "riot-wrappers", @@ -688,12 +743,13 @@ dependencies = [ "serde_bytes", "serde_cbor", "switch-hal", + "try-lock", ] [[package]] name = "riot-shell-commands" version = "0.1.0" -source = "git+https://gitlab.com/etonomy/riot-module-examples/#ab8e8e596fdbfd89c519e848cc7970b1c8410fea" +source = "git+https://gitlab.com/etonomy/riot-module-examples/#9252de4b8cd844e788dc3ebbd0f35f79c5e4edc9" dependencies = [ "document-features", "heapless 0.7.17", @@ -704,7 +760,6 @@ dependencies = [ [[package]] name = "riot-sys" version = "0.7.13" -source = "git+https://github.com/RIOT-OS/rust-riot-sys#0b53c15cc171ce2a95b89b1c34e3dfd0ef7e90e2" dependencies = [ "bindgen", "c2rust-asm-casts", @@ -718,8 +773,7 @@ dependencies = [ [[package]] name = "riot-wrappers" -version = "0.9.0" -source = "git+https://github.com/RIOT-OS/rust-riot-wrappers#3d280a4f453fe655e1cfdeb773dff1972025cd04" +version = "0.9.1" dependencies = [ "bare-metal", "coap-handler", @@ -729,10 +783,13 @@ dependencies = [ "embedded-graphics", "embedded-hal 0.2.7", "embedded-hal 1.0.0", + "embedded-nal", + "embedded-nal-tcpextensions", "heapless 0.8.0", "hex", "mutex-trait", "nb 0.1.3", + "no-std-net", "num-traits", "pin-project", "pin-utils", @@ -752,6 +809,7 @@ dependencies = [ "riot-coap-handler-demos", "riot-wrappers", "rust_riotmodules", + "static_cell", ] [[package]] @@ -775,11 +833,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ - "bitflags 2.6.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -882,6 +940,15 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_cell" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89b0684884a883431282db1e4343f34afc2ff6996fe1f4a1664519b66e14c1e" +dependencies = [ + "portable-atomic", +] + [[package]] name = "switch-hal" version = "0.4.0" @@ -913,6 +980,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + [[package]] name = "typenum" version = "1.17.0" @@ -951,15 +1024,16 @@ dependencies = [ [[package]] name = "windowed-infinity" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9487d1d565a9db59e1fd0b3c2d3f0c277bc375d348a6c46ff2b322917fbc035" +checksum = "ceb9fe94789e0552a8f626fddfa2c074e74ddf61db8c4ccd19eb8cfa4cdbb1bc" dependencies = [ "ciborium-io", "crc", "digest", "embedded-io", - "minicbor", + "minicbor 0.19.1", + "minicbor 0.24.4", "serde", "serde_cbor", ] diff --git a/examples/rust-gcoap/Cargo.toml b/examples/rust-gcoap/Cargo.toml index 7bb7b50be489a..c461e5e75b0d4 100644 --- a/examples/rust-gcoap/Cargo.toml +++ b/examples/rust-gcoap/Cargo.toml @@ -23,10 +23,11 @@ riot-wrappers = { version = "^0.9.0", features = [ "set_panic_handler", "panic_h coap-message-demos = { git = "https://gitlab.com/chrysn/coap-message-demos/", default-features = false } coap-handler-implementations = "0.5" -riot-coap-handler-demos = { git = "https://gitlab.com/etonomy/riot-module-examples/", features = [ "vfs", "saul" ] } +riot-coap-handler-demos = { git = "https://gitlab.com/etonomy/riot-module-examples/", features = [ "vfs", "saul", "nib", "ping" ] } # While currently this exmple does not use any RIOT modules implemented in # Rust, that may change; it is best practice for any RIOT application that has # its own top-level Rust crate to include rust_riotmodules from inside # RIOTBASE. rust_riotmodules = { path = "../../sys/rust_riotmodules/" } +static_cell = "2.1.0" diff --git a/examples/rust-gcoap/Makefile b/examples/rust-gcoap/Makefile index 2137478bcdcbb..980208bcaac88 100644 --- a/examples/rust-gcoap/Makefile +++ b/examples/rust-gcoap/Makefile @@ -19,6 +19,8 @@ USEMODULE += ztimer_usec USEMODULE += ztimer_msec USEMODULE += ztimer_sec +USEMODULE += gnrc_netapi_callbacks + # for the "vfs" feature of riot-coap-handler-demos (and vfs.c) USEMODULE += vfs USEMODULE += constfs diff --git a/examples/rust-gcoap/src/lib.rs b/examples/rust-gcoap/src/lib.rs index a23dfd2e31907..1b15ac8c0969d 100644 --- a/examples/rust-gcoap/src/lib.rs +++ b/examples/rust-gcoap/src/lib.rs @@ -6,7 +6,7 @@ #![no_std] use riot_wrappers::{riot_main, println}; -use riot_wrappers::{gcoap, thread, ztimer, gnrc}; +use riot_wrappers::{gcoap, ztimer, gnrc}; use coap_handler_implementations::{ReportingHandlerBuilder, HandlerBuilder}; @@ -21,18 +21,30 @@ fn main() { unsafe { do_vfs_init() }; + static PINGS: riot_coap_handler_demos::ping::PingPool = riot_coap_handler_demos::ping::PingPool::new(); + static PING_PASSIVE: riot_coap_handler_demos::ping_passive::PingHistoryMutex<{ riot_coap_handler_demos::ping_passive::DEFAULT_SIZE }> = riot_coap_handler_demos::ping_passive::PingHistoryMutex::new(); + let handler = coap_message_demos::full_application_tree(None) .below(&["ps"], riot_coap_handler_demos::ps::ps_tree()) .below(&["led"], riot_coap_handler_demos::led::all_leds()) .below(&["vfs"], riot_coap_handler_demos::vfs::vfs("")) .below(&["saul"], riot_coap_handler_demos::saul::SaulHandler::new(&["saul"])) .below(&["netif"], riot_coap_handler_demos::netif::netif()) + .below(&["nib", "neigh"], riot_coap_handler_demos::nib::neighbor_cache()) + .below(&["ping"], riot_coap_handler_demos::ping::ping_tree(&PINGS)) + .at(&["pinged"], riot_coap_handler_demos::ping_passive::resource(&PING_PASSIVE)) .with_wkc() ; let mut handler = riot_wrappers::coap_handler::v0_2::GcoapHandler(handler); let mut listener = gcoap::SingleHandlerListener::new_catch_all(&mut handler); + static SLOT: static_cell::StaticCell> = static_cell::StaticCell::new(); + PINGS.register(SLOT.init(Default::default())); + + static PASSIVE_SLOT: static_cell::StaticCell>> = static_cell::StaticCell::new(); + PING_PASSIVE.register(PASSIVE_SLOT.init(Default::default())); + gcoap::scope(|greg| { greg.register(&mut listener); @@ -57,6 +69,9 @@ fn main() { // Sending main thread to sleep; can't return or the Gcoap handler would need to be // deregistered (which it can't). - loop { thread::sleep(); } + loop { + PINGS.tick(); + sectimer.sleep(ztimer::Ticks(1)); + } }) }