6 releases (3 breaking)
0.4.0 | Apr 8, 2024 |
---|---|
0.3.0 | Feb 13, 2023 |
0.2.0 | Sep 22, 2022 |
0.1.2 | Jun 10, 2022 |
0.1.0 | Aug 10, 2021 |
#441 in No standard library
806 downloads per month
Used in verdigris
32KB
347 lines
coap-message-demos
This crate contains demo applications for CoAP on Rust
All demos use the ecosystem around the coap-message crate. They come in two variations:
-
"applications" contain code that would typically be the high-level code that executes business logic.
They are a mix of standalone resource implementations, collections thereof into a whole-server handler, and possibly client code.
They reside in the
src/
directory, and are available as library modules. This allows integrating them into other demo code, eg. into examples of a coap-message implementation. -
"examples" are the stand-alone executable binaries using various backends.
They pick suitable applications, and wrap them with a CoAP implementation of choice into a program that can be run with
cargo run --example X
.Currently, the examples in this crate show the use of:
-
coap-lite, a building block for CoAP-over-UDP libraries, running directly on a socket in the example.
-
the coap crate, which provides a full implementation, and can interface with coap-message by virtue of using coap-lite as a backend.
-
embedded-nal-minimal-coapserver, which implements CoAP-over-UDP on the Embedded Network Abstraction Layer and processes messages through the [coap_handler] types. For the example, it uses a std implementation of embedded-nal.
Examples that need larger ecosystem support and can not simply be launched natively by
cargo run --example
are not included here, but show (maybe even better) what the coap-message ecosystem is capable of providing:-
verdigris is an implementation of CoAP that runs in the web browser and uses CoAP-over-WebSockets. It includes the demo applications in its color server sub-application, where they can be accessed through a proxying Resource Directory.
-
RIOT is an embedded operating system for the Internet of Things. In the examples of its Rust bindings, the
coap_through_embeddednal
application runs the no_std part of the demo applications using the same embedded-nal-minimal-coapserver crate as the local example, but using RIOT's sockets instead of POSIX sockets.
-
Usage
The examples are all configured to run a selection of the applications; which they are depends on the selected features.
For minimal operation, run the examples as
$ cargo +nightly run --example EXNAME --features example-EXNAME
where EXNAME
is substituted with any of the examples -- currently coaplite
, coap_crate
or
std_embedded_nal_minicoapserver
.
To explore all features, just run with
$ cargo +nightly run --example EXNAME --all-features
which, for example, adds access to a system ::log.
All the same can be accessed, for example, by using aiocoap-client:
$ aiocoap-client coap://localhost/.well-known/core
</>; ct="0"; title="Landing page",
</time>; ct="0"; title="Clock",
</cbor/1>; ct="60",
</cbor/2>; ct="60",
</cbor>; ct="60",
</message/warning>; title="POST warning texts here",
</message/info>; title="POST info texts here"
$ aiocoap-client coap://localhost/cbor
{'hidden': False, 'number': 32, 'label': 'Hello', 'list': [1, 2, 3]}
License: MIT OR Apache-2.0
Dependencies
~2–15MB
~212K SLoC