1mod frame;
12mod codec;
13mod crc;
14mod constants;
15
16pub use frame::{S101Frame, S101Message, MessageType, Command};
17pub use codec::{S101Codec, S101Decoder, S101Encoder};
18pub use constants::*;
19
20use crate::error::{S101Error, Result};
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24#[repr(u8)]
25pub enum Slot {
26 Default = 0x00,
28}
29
30impl TryFrom<u8> for Slot {
31 type Error = S101Error;
32
33 fn try_from(value: u8) -> std::result::Result<Self, Self::Error> {
34 match value {
35 0x00 => Ok(Slot::Default),
36 _ => Err(S101Error::InvalidSlot(value)),
37 }
38 }
39}
40
41pub const S101_VERSION: u8 = 0x01;
43
44pub const DTD_GLOW: u8 = 0x01;
46
47pub const APP_BYTES_GLOW: [u8; 2] = [0x01, 0x31]; pub fn encode_frame(payload: &[u8]) -> Vec<u8> {
52 S101Encoder::encode_ember_packet(payload)
53}
54
55pub fn decode_frame(data: &[u8]) -> Result<Vec<u8>> {
57 let frame = S101Frame::decode(data)?;
58 Ok(frame.payload)
59}