Skip to main content

Module stick

Module stick 

Source
Expand description

Wireless M-Bus receiver sticks, sans-I/O: their serial protocols in, radio telegrams out.

StickSerialFramingTelegramRSSI
IMST iM871A, iM170A57600 8N1A5, control/endpoint, message, length, payload, (timestamp), (RSSI), CRC-16/X-25L field = HCI length, then C …raw, approximate dBm
IMST iU891A, iM891A115200 8N1SLIP; SAP, message, payload, CRC-16/X-25L field firstdBm (signed)
Amber/Würth AMB8465, AMB8665 (command mode)9600 8N1FF, command, length, payload, (RSSI), XORL 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.

Enums§

LinkMode
A link mode to receive.
Message
What a stick sent.
Stick
A supported receiver stick.