Skip to main content

Crate smgw_lmn

Crate smgw_lmn 

Source
Expand description

§smgw-lmn

Read meters on the Local Metrological Network into a bounded smgw_core::taf15::Profile. Every importer runs without an allocator or OS. It binds each value to the commissioned meter and register, keeps the exact decimal value, and changes nothing when it rejects an answer.

ProtocolFeatureEntry pointTypical meter
DLMS/COSEMacquisition (default)dlms::read_profile over your dlms::AttributeReaderElectricity meters with a Profile Generic buffer
SMLsmlsml::read_profile_pack, sml::capture_readingGerman electricity meters (mME, eHZ)
Wireless M-Bus / OMSmbusmbus::capture_telegramGas meters

Each module re-exports its codec as protocol: dlms-cosem-kit, sml-kit and mbus-kit with OMS security.

§Trust rules

  • DLMS/COSEM checks capture definitions, period and scaler on both sides of the buffer read.
  • SML profile rows need a calendar timestamp inside the requested range. Push readings use the gateway’s clock through Slot.
  • OMS accepts only telegrams whose MAC (mode 7) or CCM tag (mode 10) verified. Mode 5 and ELL encryption are rejected, because they hide a reading without protecting it. The host stores the returned Accepted::counter with the history and passes it back as last_counter, so a replay is rejected.

For a blocking DLMS client, wrap the commissioned transport in BudgetedTransport and pass the client and result scratch to BlockingReader::new. Set the I/O deadline on the transport. On error, check requires_reconnect() before retrying. Reader API

§Run the examples

From the workspace root:

cargo run --locked -p smgw-lmn --features simulator --example dlms_backfill
cargo run --locked -p smgw-lmn --features simulator --example sml_backfill
cargo run --locked -p smgw-lmn --features mbus --example oms_gas

The two backfill examples fill a missing quarter-hour, count duplicates and reject a conflicting reread. oms_gas accepts the published OMS Annex N mode 7 telegram and rejects a replay, a mode 5 telegram and a tampered frame. Load profile guide

§Meter and gateway roles

mme owns the register and its local observations. The simulator connects that meter to the gateway over loopback TCP with simulator::Protocol::Dlms or Protocol::Sml. Each session lasts at most four seconds, and an SML frame holds at most 1 KiB.

BuildCargo featuresResponsibility
Embedded gatewayacquisition, sml, mbusValidate meter answers and import them into the gateway’s TAF 15 profile.
smgw-simloopback-clientRead the commissioned profile. DLMS commits after the meter confirms release, SML after one complete answer frame.
mme-simdefault-features = false, loopback-meterServe a read-only snapshot of the virtual meter over either protocol.
ExamplessimulatorExercise both roles in one process.

Run cargo run --locked -p mme-sim -- --protocol sml --interactive to advance an SML meter independently of the gateway. Stateful meter walkthrough

Licensed under MIT OR Apache-2.0.

Modules§

dlms
Read a clock-selected COSEM Profile Generic buffer into a bounded TAF 15 history.
mbus
Import an authenticated wireless M-Bus (OMS) gas meter telegram into a TAF 15 history.
simulator
Loopback meter and gateway roles for the commissioned simulation channel, over DLMS/COSEM or SML.
sml
Import SML (Smart Message Language) readings into a bounded TAF 15 history.

Structs§

Counts
Counts for one fully committed import.
Slot
The slot a pushed reading fills, timed by the gateway’s trusted clock.