pub struct Telegram<'a> {
pub c: u8,
pub address: Address,
pub ell: Option<Ell>,
pub access_number: u8,
pub status: u8,
pub synchronous: bool,
pub security: Security,
pub records: &'a [u8],
pub tail: &'a [u8],
}oms only.Expand description
A telegram as a meter transmits it. Build it with Telegram::new and change
fields with struct update syntax.
Fields§
§c: u8The link layer’s C field: control::SND_NR for a meter’s periodic telegram.
address: AddressThe meter (link layer address; it forms the IV, the nonce and the derived keys).
ell: Option<Ell>An extended link layer: 8C (CC and access number), 8E with a receiver, 8D
/ 8F with a session number and payload CRC, encrypted with AES-128-CTR when
the session number announces it (Ell::encrypted).
access_number: u8The transport layer’s access number; a meter increments it per telegram.
status: u8The transport layer’s status byte (battery low, errors, …).
synchronous: boolThe configuration field’s S bit: the meter transmits on a fixed schedule.
security: SecurityHow the records are protected.
records: &'a [u8]The records as transmitted, without the 2F 2F marker (it is added for modes 5
and 7).
tail: &'a [u8]Records after the protected part, in plaintext.
Implementations§
Source§impl<'a> Telegram<'a>
impl<'a> Telegram<'a>
Sourcepub const fn new(
address: Address,
security: Security,
records: &'a [u8],
) -> Self
pub const fn new( address: Address, security: Security, records: &'a [u8], ) -> Self
A periodic telegram (SND_NR) from address with records: no ELL, access
number and status 0, no tail.
Sourcepub fn write(&self, key: &Key, format: Format, out: &mut [u8]) -> Result<usize>
pub fn write(&self, key: &Key, format: Format, out: &mut [u8]) -> Result<usize>
Write the telegram into out in format, protected with the meter’s key
(unused for Security::Plain without an encrypted ELL). Returns the number of
bytes written.
Error::InvalidLength when it does not fit in one frame (or mode 5/7 would need
more than 15 blocks, or 15 with a tail), Error::OutputTooSmall when out
cannot hold it. The plaintext and the derived keys are erased before returning.