use btleplug::platform::PeripheralId;
pub fn format_peripheral_id(id: &PeripheralId) -> String {
format!("{:?}", id)
.trim_start_matches("PeripheralId(")
.trim_end_matches(')')
.to_string()
}
pub fn create_identifier(address: &str, peripheral_id: &PeripheralId) -> String {
if address == "00:00:00:00:00:00" {
format_peripheral_id(peripheral_id)
} else {
address.to_string()
}
}
#[cfg(test)]
mod tests {
#[allow(unused_imports)]
use super::*;
#[test]
fn test_create_identifier_with_valid_address() {
let address = "AA:BB:CC:DD:EE:FF";
assert_ne!(address, "00:00:00:00:00:00");
}
#[test]
fn test_create_identifier_with_zero_address() {
let address = "00:00:00:00:00:00";
assert_eq!(address, "00:00:00:00:00:00");
}
}