Skip to main content

open

Function open 

Source
pub fn open<'b, K: Keys + ?Sized>(
    raw: &[u8],
    format: Format,
    keys: &K,
    buf: &'b mut [u8],
) -> Result<Option<(Telegram<'b>, usize)>>
Available on crate feature oms only.
Expand description

One call from radio bytes to records: check and strip the CRCs, parse every layer, and decrypt (and authenticate) with the meter’s key from keys.

buf holds the frame without CRCs and the plaintext: it needs twice the frame’s length (512 bytes always suffice). Returns Ok(None) when raw is shorter than its L field announces. Without the meter’s key, the telegram is returned with its body still Body::Encrypted and Authenticity::None, not as an error: the unencrypted layers (address, ELL, header) are still useful.

An ELL-encrypted telegram whose TPL is encrypted as well needs a second decryption; the returned body is then Encrypted again.