Expand description
Wireless M-Bus receiver sticks, sans-I/O: their serial protocols in, radio telegrams out.
| Stick | Serial | Framing | Telegram | RSSI |
|---|---|---|---|---|
| IMST iM871A, iM170A | 57600 8N1 | A5, control/endpoint, message, length, payload, (timestamp), (RSSI), CRC-16/X-25 | L field = HCI length, then C … | raw, approximate dBm |
| IMST iU891A, iM891A | 115200 8N1 | SLIP; SAP, message, payload, CRC-16/X-25 | L field first | dBm (signed) |
| Amber/Würth AMB8465, AMB8665 (command mode) | 9600 8N1 | FF, command, length, payload, (RSSI), XOR | L field = length − 1 (with RSSI), then C … | dBm |
Every stick checks and removes the link-layer CRCs: a Received frame starts at the
L field and goes to wireless::decode or
wireless::open with
Format::Stripped.
use mbus_kit::stick::{LinkMode, Message, Receiver, Stick};
let stick = Stick::Im871a;
let listen = stick.listen(LinkMode::T1).unwrap(); // write listen.bytes() to the port once
let mut rx = Receiver::new(stick);
rx.extend(&from_port); // whatever the port delivered, in any chunks
while let Some(message) = rx.next_message() {
match message {
Ok(Message::Telegram(t)) => println!("{:02X?} at {:?} dBm", t.frame, t.rssi_dbm),
Ok(Message::Response { .. }) => { /* a confirmation of a command */ }
Err(e) => eprintln!("skipped: {e}"), // noise or a corrupted stick frame
}
}The Amber sticks deliver telegrams framed only in command mode with RSSI: run
Stick::setup once (it writes the stick’s non-volatile settings), then
Stick::listen after every power-up.
Structs§
- Command
- Bytes to write to a stick.
- Received
- A radio telegram the stick received.
- Receiver
- Turns a stick’s byte stream into
Messages, without allocating.