Crates.io | knx-rust |
lib.rs | knx-rust |
version | 0.0.1 |
source | src |
created_at | 2024-05-02 11:26:56.390707 |
updated_at | 2024-05-02 11:26:56.390707 |
description | KNX Library |
homepage | |
repository | https://github.com/memoos/knx-rust |
max_upload_size | |
id | 1227655 |
size | 102,466 |
Knx-rust is a library written in Rust implementing the KNXNet/Ip protocol, to enable communication with KNX-Devices through KNX Ip Gateways or Routers. The library is implemented without any io calls (https://sans-io.readthedocs.io/how-to-sans-io.html) to have minimal runtime requirements so that it could be used with tokio, async-std or mio only in embedded environments.
Add knx-rust
as a dependency in Cargo.toml
:
[dependencies]
knx-rust = "0.0.1"
You need to make sure that the following functions called regularly (for exmaple in your event loop):
knx.get_outbound_data()
and send the retuned data out to UDP if there is some. There might be new data after initialisation or after a call to knx.send
, knx.handle_inbound_message
or knx.handle_time_events
.knx.handle_inbound_message(buf)
in case data is received from UDP. In case the data contains a group communication message is is returned by the function and could handled furtherknx.handle_time_events()
needs to be called next at point in time defined by knx.get_next_time_event()
. The time needs to be updated after data has been send out to UDP (after knx.get_outbound_data()
).Apart from that messages can be send to the bus at any time using knx.send(group_event)
.
An example how to interact with the library using mio or tokio can be found in the examples folder.
These examples can be executed using
cargo run --example group_tunnel_mio
or
cargo run --example group_tunnel_tokio