use heapless::String;
use super::GatewayH2;
pub const DEFAULT_MATTER_PORT: u16 = 5540;
pub const SETUP_DISCRIMINATOR_DIGITS: u8 = 12;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MatterServerConfig {
pub vendor_id: u16,
pub product_id: u16,
pub discriminator: u16,
pub setup_passcode: u32,
pub device_name: String<32>,
pub port: u16,
}
impl MatterServerConfig {
pub fn new(
vendor_id: u16,
product_id: u16,
discriminator: u16,
setup_passcode: u32,
device_name: &str,
) -> Self {
let mut name = String::new();
let _ = name.push_str(device_name);
Self {
vendor_id,
product_id,
discriminator,
setup_passcode,
device_name: name,
port: DEFAULT_MATTER_PORT,
}
}
pub const fn with_port(mut self, port: u16) -> Self {
self.port = port;
self
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ThreadDatasetConfig {
pub network_name: String<16>,
pub pan_id: u16,
pub extended_pan_id: [u8; 8],
pub channel: u8,
pub network_key: [u8; 16],
}
impl ThreadDatasetConfig {
pub fn new(
network_name: &str,
pan_id: u16,
extended_pan_id: [u8; 8],
channel: u8,
network_key: [u8; 16],
) -> Self {
let mut name = String::new();
let _ = name.push_str(network_name);
Self {
network_name: name,
pan_id,
extended_pan_id,
channel,
network_key,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct MatterOverThreadConfig {
pub gateway: GatewayH2,
pub matter: MatterServerConfig,
pub thread: ThreadDatasetConfig,
}
impl MatterOverThreadConfig {
pub const fn new(
gateway: GatewayH2,
matter: MatterServerConfig,
thread: ThreadDatasetConfig,
) -> Self {
Self {
gateway,
matter,
thread,
}
}
}