#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Command {
ReqA = 0x26,
WupA = 0x52,
CT = 0x88,
SelCl1 = 0x93,
SelCl2 = 0x95,
SelCl3 = 0x97,
HltA = 0x50,
RAtS = 0xE0,
MfAuthKeyA = 0x60,
MfAuthKeyB = 0x61,
MfRead = 0x30,
MfWrite = 0xA0,
MfDecrement = 0xC0,
MfIncrement = 0xC1,
MfRestore = 0xC2,
MfTransfer = 0xB0,
UlWrite = 0xA2,
}
#[derive(Debug)]
pub enum Type {
Unknown,
Iso14443_4,
Iso18092,
MifareMini,
Mifare1k,
Mifare4k,
MifareUL,
MifarePlus,
MifareDesfire,
TNP3XXX,
NotComplete,
}
pub struct Sak {
byte: u8,
}
impl From<u8> for Sak {
fn from(byte: u8) -> Self {
Sak { byte }
}
}
impl Sak {
pub fn get_type(&self) -> Type {
match self.byte & 0x7F {
0x04 => Type::NotComplete, 0x09 => Type::MifareMini,
0x08 => Type::Mifare1k,
0x18 => Type::Mifare4k,
0x00 => Type::MifareUL,
0x10 | 0x11 => Type::MifarePlus,
0x01 => Type::TNP3XXX,
0x20 => Type::Iso14443_4,
0x40 => Type::Iso18092,
_ => Type::Unknown,
}
}
pub fn is_compliant(&self) -> bool {
self.byte & (1 << 5) != 0
}
pub fn is_complete(&self) -> bool {
self.byte & (1 << 2) == 0
}
}