#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct CharacteristicProperties(pub u32);
impl CharacteristicProperties {
pub const BROADCAST: u32 = 0x001;
pub const READ: u32 = 0x002;
pub const WRITE_WITHOUT_RESPONSE: u32 = 0x004;
pub const WRITE: u32 = 0x008;
pub const NOTIFY: u32 = 0x010;
pub const INDICATE: u32 = 0x020;
pub const AUTHENTICATED_SIGNED_WRITES: u32 = 0x040;
pub const EXTENDED_PROPERTIES: u32 = 0x080;
pub const NOTIFY_ENCRYPTION_REQUIRED: u32 = 0x100;
pub const INDICATE_ENCRYPTION_REQUIRED: u32 = 0x200;
pub const RELIABLE_WRITE: u32 = 0x400;
pub const WRITABLE_AUXILIARIES: u32 = 0x800;
#[inline]
pub fn has(self, bit: u32) -> bool {
self.0 & bit != 0
}
#[inline]
pub fn broadcast(self) -> bool {
self.has(Self::BROADCAST)
}
#[inline]
pub fn read(self) -> bool {
self.has(Self::READ)
}
#[inline]
pub fn write_without_response(self) -> bool {
self.has(Self::WRITE_WITHOUT_RESPONSE)
}
#[inline]
pub fn write(self) -> bool {
self.has(Self::WRITE)
}
#[inline]
pub fn notify(self) -> bool {
self.has(Self::NOTIFY)
}
#[inline]
pub fn indicate(self) -> bool {
self.has(Self::INDICATE)
}
#[inline]
pub fn authenticated_signed_writes(self) -> bool {
self.has(Self::AUTHENTICATED_SIGNED_WRITES)
}
#[inline]
pub fn extended_properties(self) -> bool {
self.has(Self::EXTENDED_PROPERTIES)
}
#[inline]
pub fn reliable_write(self) -> bool {
self.has(Self::RELIABLE_WRITE)
}
#[inline]
pub fn writable_auxiliaries(self) -> bool {
self.has(Self::WRITABLE_AUXILIARIES)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WriteType {
WithResponse,
WithoutResponse,
}