use uuid::{Uuid, uuid};
pub const SAF_TEHNIKA_SERVICE_NEW: Uuid = uuid!("0000fce0-0000-1000-8000-00805f9b34fb");
pub const SAF_TEHNIKA_SERVICE_OLD: Uuid = uuid!("f0cd1400-95da-4f4b-9ac8-aa55d312af0c");
pub const MANUFACTURER_ID: u16 = 0x0702;
pub const CURRENT_READINGS: Uuid = uuid!("f0cd1503-95da-4f4b-9ac8-aa55d312af0c");
pub const CURRENT_READINGS_DETAIL: Uuid = uuid!("f0cd3001-95da-4f4b-9ac8-aa55d312af0c");
pub const CURRENT_READINGS_DETAIL_ALT: Uuid = uuid!("f0cd3003-95da-4f4b-9ac8-aa55d312af0c");
pub const TOTAL_READINGS: Uuid = uuid!("f0cd2001-95da-4f4b-9ac8-aa55d312af0c");
pub const READ_INTERVAL: Uuid = uuid!("f0cd2002-95da-4f4b-9ac8-aa55d312af0c");
pub const HISTORY_V1: Uuid = uuid!("f0cd2003-95da-4f4b-9ac8-aa55d312af0c");
pub const HISTORY_V2: Uuid = uuid!("f0cd2005-95da-4f4b-9ac8-aa55d312af0c");
pub const SENSOR_STATE: Uuid = uuid!("f0cd1401-95da-4f4b-9ac8-aa55d312af0c");
pub const COMMAND: Uuid = uuid!("f0cd1402-95da-4f4b-9ac8-aa55d312af0c");
pub const SECONDS_SINCE_UPDATE: Uuid = uuid!("f0cd2004-95da-4f4b-9ac8-aa55d312af0c");
pub const CALIBRATION: Uuid = uuid!("f0cd1502-95da-4f4b-9ac8-aa55d312af0c");
pub const GAP_SERVICE: Uuid = uuid!("00001800-0000-1000-8000-00805f9b34fb");
pub const DEVICE_INFO_SERVICE: Uuid = uuid!("0000180a-0000-1000-8000-00805f9b34fb");
pub const BATTERY_SERVICE: Uuid = uuid!("0000180f-0000-1000-8000-00805f9b34fb");
pub const DEVICE_NAME: Uuid = uuid!("00002a00-0000-1000-8000-00805f9b34fb");
pub const MODEL_NUMBER: Uuid = uuid!("00002a24-0000-1000-8000-00805f9b34fb");
pub const SERIAL_NUMBER: Uuid = uuid!("00002a25-0000-1000-8000-00805f9b34fb");
pub const FIRMWARE_REVISION: Uuid = uuid!("00002a26-0000-1000-8000-00805f9b34fb");
pub const HARDWARE_REVISION: Uuid = uuid!("00002a27-0000-1000-8000-00805f9b34fb");
pub const SOFTWARE_REVISION: Uuid = uuid!("00002a28-0000-1000-8000-00805f9b34fb");
pub const MANUFACTURER_NAME: Uuid = uuid!("00002a29-0000-1000-8000-00805f9b34fb");
pub const BATTERY_LEVEL: Uuid = uuid!("00002a19-0000-1000-8000-00805f9b34fb");
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_saf_tehnika_service_new_uuid() {
let expected = "0000fce0-0000-1000-8000-00805f9b34fb";
assert_eq!(SAF_TEHNIKA_SERVICE_NEW.to_string(), expected);
}
#[test]
fn test_saf_tehnika_service_old_uuid() {
let expected = "f0cd1400-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(SAF_TEHNIKA_SERVICE_OLD.to_string(), expected);
}
#[test]
fn test_manufacturer_id() {
assert_eq!(MANUFACTURER_ID, 0x0702);
assert_eq!(MANUFACTURER_ID, 1794);
}
#[test]
fn test_current_readings_uuid() {
let expected = "f0cd1503-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(CURRENT_READINGS.to_string(), expected);
}
#[test]
fn test_current_readings_detail_uuid() {
let expected = "f0cd3001-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(CURRENT_READINGS_DETAIL.to_string(), expected);
}
#[test]
fn test_current_readings_detail_alt_uuid() {
let expected = "f0cd3003-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(CURRENT_READINGS_DETAIL_ALT.to_string(), expected);
}
#[test]
fn test_total_readings_uuid() {
let expected = "f0cd2001-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(TOTAL_READINGS.to_string(), expected);
}
#[test]
fn test_read_interval_uuid() {
let expected = "f0cd2002-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(READ_INTERVAL.to_string(), expected);
}
#[test]
fn test_history_v1_uuid() {
let expected = "f0cd2003-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(HISTORY_V1.to_string(), expected);
}
#[test]
fn test_history_v2_uuid() {
let expected = "f0cd2005-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(HISTORY_V2.to_string(), expected);
}
#[test]
fn test_sensor_state_uuid() {
let expected = "f0cd1401-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(SENSOR_STATE.to_string(), expected);
}
#[test]
fn test_command_uuid() {
let expected = "f0cd1402-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(COMMAND.to_string(), expected);
}
#[test]
fn test_seconds_since_update_uuid() {
let expected = "f0cd2004-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(SECONDS_SINCE_UPDATE.to_string(), expected);
}
#[test]
fn test_calibration_uuid() {
let expected = "f0cd1502-95da-4f4b-9ac8-aa55d312af0c";
assert_eq!(CALIBRATION.to_string(), expected);
}
#[test]
fn test_gap_service_uuid() {
let expected = "00001800-0000-1000-8000-00805f9b34fb";
assert_eq!(GAP_SERVICE.to_string(), expected);
}
#[test]
fn test_device_info_service_uuid() {
let expected = "0000180a-0000-1000-8000-00805f9b34fb";
assert_eq!(DEVICE_INFO_SERVICE.to_string(), expected);
}
#[test]
fn test_battery_service_uuid() {
let expected = "0000180f-0000-1000-8000-00805f9b34fb";
assert_eq!(BATTERY_SERVICE.to_string(), expected);
}
#[test]
fn test_device_name_uuid() {
let expected = "00002a00-0000-1000-8000-00805f9b34fb";
assert_eq!(DEVICE_NAME.to_string(), expected);
}
#[test]
fn test_model_number_uuid() {
let expected = "00002a24-0000-1000-8000-00805f9b34fb";
assert_eq!(MODEL_NUMBER.to_string(), expected);
}
#[test]
fn test_serial_number_uuid() {
let expected = "00002a25-0000-1000-8000-00805f9b34fb";
assert_eq!(SERIAL_NUMBER.to_string(), expected);
}
#[test]
fn test_firmware_revision_uuid() {
let expected = "00002a26-0000-1000-8000-00805f9b34fb";
assert_eq!(FIRMWARE_REVISION.to_string(), expected);
}
#[test]
fn test_hardware_revision_uuid() {
let expected = "00002a27-0000-1000-8000-00805f9b34fb";
assert_eq!(HARDWARE_REVISION.to_string(), expected);
}
#[test]
fn test_software_revision_uuid() {
let expected = "00002a28-0000-1000-8000-00805f9b34fb";
assert_eq!(SOFTWARE_REVISION.to_string(), expected);
}
#[test]
fn test_manufacturer_name_uuid() {
let expected = "00002a29-0000-1000-8000-00805f9b34fb";
assert_eq!(MANUFACTURER_NAME.to_string(), expected);
}
#[test]
fn test_battery_level_uuid() {
let expected = "00002a19-0000-1000-8000-00805f9b34fb";
assert_eq!(BATTERY_LEVEL.to_string(), expected);
}
#[test]
fn test_aranet_service_uuids_are_distinct() {
assert_ne!(SAF_TEHNIKA_SERVICE_NEW, SAF_TEHNIKA_SERVICE_OLD);
}
#[test]
fn test_current_readings_uuids_are_distinct() {
assert_ne!(CURRENT_READINGS, CURRENT_READINGS_DETAIL);
assert_ne!(CURRENT_READINGS_DETAIL, CURRENT_READINGS_DETAIL_ALT);
assert_ne!(CURRENT_READINGS, CURRENT_READINGS_DETAIL_ALT);
}
#[test]
fn test_history_uuids_are_distinct() {
assert_ne!(HISTORY_V1, HISTORY_V2);
}
#[test]
fn test_standard_service_uuids_are_distinct() {
assert_ne!(GAP_SERVICE, DEVICE_INFO_SERVICE);
assert_ne!(DEVICE_INFO_SERVICE, BATTERY_SERVICE);
assert_ne!(GAP_SERVICE, BATTERY_SERVICE);
}
#[test]
fn test_aranet_characteristic_prefix() {
let aranet_uuids = [
CURRENT_READINGS,
CURRENT_READINGS_DETAIL,
CURRENT_READINGS_DETAIL_ALT,
TOTAL_READINGS,
READ_INTERVAL,
HISTORY_V1,
HISTORY_V2,
SENSOR_STATE,
COMMAND,
SECONDS_SINCE_UPDATE,
CALIBRATION,
];
for uuid in aranet_uuids {
assert!(
uuid.to_string().starts_with("f0cd"),
"UUID {} should start with f0cd",
uuid
);
}
}
#[test]
fn test_standard_ble_characteristic_prefix() {
let standard_uuids = [
DEVICE_NAME,
MODEL_NUMBER,
SERIAL_NUMBER,
FIRMWARE_REVISION,
HARDWARE_REVISION,
SOFTWARE_REVISION,
MANUFACTURER_NAME,
BATTERY_LEVEL,
];
for uuid in standard_uuids {
assert!(
uuid.to_string().starts_with("00002a"),
"UUID {} should start with 00002a",
uuid
);
}
}
}