Expand description
Bundled rumqttc 0.25 connection for the eBus Homie 5 controller and device on tokio.
controller builds an ebus_homie_tokio controller with its own
rumqttc client, device a device tree, and pair both on one
connection. The host spawns the task’s run; the SDK spawns nothing. The
broker coordinates, client id, credentials and TLS come from the caller’s
MqttOptions. A host that found its broker over mDNS gives the task a
Reresolve hook (ControllerTask::reresolve), which finds the same
broker again when connecting fails, at startup or after a lost link, so a
broker whose address changed is reached at its new one.
use ebus_rumqttc::ebus_homie_tokio::ebus_homie::controller::{Config, Event};
use ebus_rumqttc::ebus_homie_tokio::{ControllerOptions, Delivered};
let mqtt = rumqttc::MqttOptions::new(ebus_rumqttc::controller_client_id(), "localhost", 1883);
let run = ebus_rumqttc::controller(mqtt, Config::wildcard(), ControllerOptions::default())?;
tokio::spawn(run.task.run());
let mut events = run.events;
while let Some(d) = events.recv().await {
match d {
Delivered::Event(Event::DeviceSynced { device, missing: 0, .. }) => {
let _values = run.handle.device(&device);
}
Delivered::Overflow { .. } => {
let _all = run.handle.devices();
}
_ => {}
}
}The transport is MQTT over TCP, or TLS with the rustls or native-tls
feature. rumqttc’s default maximum incoming packet size is 10 KiB, and a
larger $description fails the connection; raise it with
MqttOptions::set_max_packet_size
for devices that publish one.
On a clean-session reconnect rumqttc discards the requests it had not sent
and restores no subscriptions; the controller resubscribes its filters on
every CONNACK. The executor hands rumqttc nothing while the link is down
and skips every SUBSCRIBE queued before a clean-session link-up, so none is
sent after it, and the controller runs with
Config::link_up_discards_queued set.
Re-exports§
pub use ebus_homie_tokio;pub use rumqttc;
Structs§
- Controller
Task - The driver, the rumqttc event loop and the command executor, as one future.
- Device
Task - The device driver, the rumqttc event loop and the command executor, as one future.
- Pair
Task - The pair driver, the rumqttc event loop and the command executor, as one future.
- Running
Controller - A controller with its own connection.
- Running
Device - A device tree with its own connection.
- Running
Pair - A device tree and a controller sharing one connection.
Enums§
- Error
- Why
ControllerTask::runstopped early.
Functions§
- controller
- A controller for
configthat connects withmqtt, withConfig::link_up_discards_queuedset. Nothing runs until the host spawnsControllerTask::run. - controller_
client_ id ebus-controller-and 16 random hex digits, after python-sdk’shomie-controller-{uuid}(homie.py:3870).- device
- A device tree that connects with
mqtt. The broker coordinates, the client id (by convention the root’s id, homie.py:3379), credentials and TLS are the caller’s; the root’s will, a clean session, the inflight cap and the outgoing packet limit are set here, along withTreeConfig::receiptsandDeviceOptions::link_up_discards_queued. Nothing runs until the host spawnsDeviceTask::run. - pair
- A device tree and a controller for
configon one connection, configured asdeviceconfigures it. Nothing runs until the host spawnsPairTask::run.
Type Aliases§
- Reresolve
- Looks the broker up again when connects to it fail: returns its options
at the current address, or
Noneto keep the old ones. SeeControllerTask::reresolve.