pub struct Address {
pub manufacturer: Manufacturer,
pub id: [u8; 4],
pub version: u8,
pub medium: Medium,
}Expand description
A meter’s address: manufacturer, identification number, version and device type.
The same eight bytes appear in the wireless link layer and in a long header (where they name the meter behind a repeater or a gateway). They select the key and form part of the OMS initialisation vector.
Fields§
§manufacturer: ManufacturerManufacturer (FLAG association code).
id: [u8; 4]Identification number, 8 BCD digits, as transmitted (LSB first).
version: u8Version / generation.
medium: MediumDevice type (medium).
Implementations§
Source§impl Address
impl Address
Sourcepub fn id_number(&self) -> Option<u32>
pub fn id_number(&self) -> Option<u32>
The identification number as printed on the meter, if it is valid BCD.
Examples found in repository?
examples/readout.rs (line 23)
14fn main() -> Result<(), mbus_kit::Error> {
15 let Some((Frame::Long { ci, data, .. }, _)) = Frame::parse(&TELEGRAM)? else {
16 return Err(mbus_kit::Error::UnexpectedEnd);
17 };
18 let app = Application::parse(ci, data)?;
19 if let Header::Long(h) = app.header {
20 println!(
21 "{} meter {:08} by {}, version {}",
22 h.address.medium,
23 h.address.id_number().unwrap_or(0),
24 h.address.manufacturer,
25 h.address.version
26 );
27 }
28 if let Body::Records(records) = app.body {
29 for record in records {
30 // e.g. "volume flow · maximum · storage 5 — 0.113 m³/h"
31 println!(" {}", record?);
32 }
33 }
34 Ok(())
35}Sourcepub const fn to_bytes(self) -> [u8; 8]
pub const fn to_bytes(self) -> [u8; 8]
The address in link-layer order: manufacturer (LE), ID, version, medium.
Sourcepub const fn from_link_bytes(b: [u8; 8]) -> Self
pub const fn from_link_bytes(b: [u8; 8]) -> Self
Parse link-layer order (manufacturer first).
Trait Implementations§
impl Copy for Address
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Forget for Address
impl Freeze for Address
impl Move for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnsafeUnpin for Address
impl UnwindSafe for Address
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more