use alloc::vec::Vec;
use knx_rs_core::message::ApduType;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum AppLayerError {
UnsupportedApdu(ApduType),
TruncatedPayload {
expected: usize,
got: usize,
},
MalformedData,
}
impl core::fmt::Display for AppLayerError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::UnsupportedApdu(t) => write!(f, "unsupported APDU type: {t:?}"),
Self::TruncatedPayload { expected, got } => {
write!(f, "truncated payload: expected {expected} bytes, got {got}")
}
Self::MalformedData => write!(f, "malformed APDU data"),
}
}
}
impl core::error::Error for AppLayerError {}
#[derive(Debug, Clone)]
pub enum AppIndication {
GroupValueWrite {
asap: u16,
data: Vec<u8>,
},
GroupValueResponse {
asap: u16,
data: Vec<u8>,
},
GroupValueRead {
asap: u16,
},
PropertyValueRead {
object_index: u8,
property_id: u8,
count: u8,
start_index: u16,
},
PropertyValueWrite {
object_index: u8,
property_id: u8,
count: u8,
start_index: u16,
data: Vec<u8>,
},
DeviceDescriptorRead {
descriptor_type: u8,
},
MemoryRead {
count: u8,
address: u16,
},
MemoryWrite {
count: u8,
address: u16,
data: Vec<u8>,
},
Restart,
IndividualAddressWrite {
address: u16,
},
IndividualAddressRead,
AuthorizeRequest {
key: u32,
},
RestartMasterReset {
erase_code: u8,
channel: u8,
},
PropertyDescriptionRead {
object_index: u8,
property_id: u8,
property_index: u8,
},
MemoryExtRead {
count: u8,
address: u32,
},
MemoryExtWrite {
count: u8,
address: u32,
data: Vec<u8>,
},
IndividualAddressSerialNumberRead {
serial: [u8; 6],
},
IndividualAddressSerialNumberWrite {
serial: [u8; 6],
address: u16,
},
KeyWrite {
level: u8,
key: u32,
},
FunctionPropertyCommand {
object_index: u8,
property_id: u8,
data: Vec<u8>,
},
FunctionPropertyState {
object_index: u8,
property_id: u8,
data: Vec<u8>,
},
SystemNetworkParameterRead {
object_type: u16,
property_id: u16,
test_info: Vec<u8>,
},
AdcRead {
channel: u8,
count: u8,
},
PropertyValueExtRead {
object_type: u16,
object_instance: u16,
property_id: u16,
count: u8,
start_index: u16,
},
PropertyValueExtWriteCon {
object_type: u16,
object_instance: u16,
property_id: u16,
count: u8,
start_index: u16,
data: Vec<u8>,
},
PropertyValueExtWriteUnCon {
object_type: u16,
object_instance: u16,
property_id: u16,
count: u8,
start_index: u16,
data: Vec<u8>,
},
PropertyExtDescriptionRead {
object_type: u16,
object_instance: u16,
property_id: u16,
description_type: u8,
property_index: u16,
},
}