1use uuid::{Uuid, uuid};
7
8pub const SAF_TEHNIKA_SERVICE_NEW: Uuid = uuid!("0000fce0-0000-1000-8000-00805f9b34fb");
12
13pub const SAF_TEHNIKA_SERVICE_OLD: Uuid = uuid!("f0cd1400-95da-4f4b-9ac8-aa55d312af0c");
15
16pub const MANUFACTURER_ID: u16 = 0x0702;
18
19pub const CURRENT_READINGS: Uuid = uuid!("f0cd1503-95da-4f4b-9ac8-aa55d312af0c");
23
24pub const CURRENT_READINGS_DETAIL: Uuid = uuid!("f0cd3001-95da-4f4b-9ac8-aa55d312af0c");
26
27pub const CURRENT_READINGS_DETAIL_ALT: Uuid = uuid!("f0cd3003-95da-4f4b-9ac8-aa55d312af0c");
29
30pub const TOTAL_READINGS: Uuid = uuid!("f0cd2001-95da-4f4b-9ac8-aa55d312af0c");
32
33pub const READ_INTERVAL: Uuid = uuid!("f0cd2002-95da-4f4b-9ac8-aa55d312af0c");
35
36pub const HISTORY_V1: Uuid = uuid!("f0cd2003-95da-4f4b-9ac8-aa55d312af0c");
38
39pub const HISTORY_V2: Uuid = uuid!("f0cd2005-95da-4f4b-9ac8-aa55d312af0c");
41
42pub const COMMAND: Uuid = uuid!("f0cd1402-95da-4f4b-9ac8-aa55d312af0c");
44
45pub const SECONDS_SINCE_UPDATE: Uuid = uuid!("f0cd2004-95da-4f4b-9ac8-aa55d312af0c");
47
48pub const CALIBRATION: Uuid = uuid!("f0cd1502-95da-4f4b-9ac8-aa55d312af0c");
50
51pub const GAP_SERVICE: Uuid = uuid!("00001800-0000-1000-8000-00805f9b34fb");
55
56pub const DEVICE_INFO_SERVICE: Uuid = uuid!("0000180a-0000-1000-8000-00805f9b34fb");
58
59pub const BATTERY_SERVICE: Uuid = uuid!("0000180f-0000-1000-8000-00805f9b34fb");
61
62pub const DEVICE_NAME: Uuid = uuid!("00002a00-0000-1000-8000-00805f9b34fb");
66
67pub const MODEL_NUMBER: Uuid = uuid!("00002a24-0000-1000-8000-00805f9b34fb");
69
70pub const SERIAL_NUMBER: Uuid = uuid!("00002a25-0000-1000-8000-00805f9b34fb");
72
73pub const FIRMWARE_REVISION: Uuid = uuid!("00002a26-0000-1000-8000-00805f9b34fb");
75
76pub const HARDWARE_REVISION: Uuid = uuid!("00002a27-0000-1000-8000-00805f9b34fb");
78
79pub const SOFTWARE_REVISION: Uuid = uuid!("00002a28-0000-1000-8000-00805f9b34fb");
81
82pub const MANUFACTURER_NAME: Uuid = uuid!("00002a29-0000-1000-8000-00805f9b34fb");
84
85pub const BATTERY_LEVEL: Uuid = uuid!("00002a19-0000-1000-8000-00805f9b34fb");
89
90#[cfg(test)]
91mod tests {
92 use super::*;
93
94 #[test]
97 fn test_saf_tehnika_service_new_uuid() {
98 let expected = "0000fce0-0000-1000-8000-00805f9b34fb";
100 assert_eq!(SAF_TEHNIKA_SERVICE_NEW.to_string(), expected);
101 }
102
103 #[test]
104 fn test_saf_tehnika_service_old_uuid() {
105 let expected = "f0cd1400-95da-4f4b-9ac8-aa55d312af0c";
107 assert_eq!(SAF_TEHNIKA_SERVICE_OLD.to_string(), expected);
108 }
109
110 #[test]
111 fn test_manufacturer_id() {
112 assert_eq!(MANUFACTURER_ID, 0x0702);
114 assert_eq!(MANUFACTURER_ID, 1794);
115 }
116
117 #[test]
120 fn test_current_readings_uuid() {
121 let expected = "f0cd1503-95da-4f4b-9ac8-aa55d312af0c";
122 assert_eq!(CURRENT_READINGS.to_string(), expected);
123 }
124
125 #[test]
126 fn test_current_readings_detail_uuid() {
127 let expected = "f0cd3001-95da-4f4b-9ac8-aa55d312af0c";
129 assert_eq!(CURRENT_READINGS_DETAIL.to_string(), expected);
130 }
131
132 #[test]
133 fn test_current_readings_detail_alt_uuid() {
134 let expected = "f0cd3003-95da-4f4b-9ac8-aa55d312af0c";
136 assert_eq!(CURRENT_READINGS_DETAIL_ALT.to_string(), expected);
137 }
138
139 #[test]
140 fn test_total_readings_uuid() {
141 let expected = "f0cd2001-95da-4f4b-9ac8-aa55d312af0c";
142 assert_eq!(TOTAL_READINGS.to_string(), expected);
143 }
144
145 #[test]
146 fn test_read_interval_uuid() {
147 let expected = "f0cd2002-95da-4f4b-9ac8-aa55d312af0c";
148 assert_eq!(READ_INTERVAL.to_string(), expected);
149 }
150
151 #[test]
152 fn test_history_v1_uuid() {
153 let expected = "f0cd2003-95da-4f4b-9ac8-aa55d312af0c";
154 assert_eq!(HISTORY_V1.to_string(), expected);
155 }
156
157 #[test]
158 fn test_history_v2_uuid() {
159 let expected = "f0cd2005-95da-4f4b-9ac8-aa55d312af0c";
160 assert_eq!(HISTORY_V2.to_string(), expected);
161 }
162
163 #[test]
164 fn test_command_uuid() {
165 let expected = "f0cd1402-95da-4f4b-9ac8-aa55d312af0c";
166 assert_eq!(COMMAND.to_string(), expected);
167 }
168
169 #[test]
170 fn test_seconds_since_update_uuid() {
171 let expected = "f0cd2004-95da-4f4b-9ac8-aa55d312af0c";
172 assert_eq!(SECONDS_SINCE_UPDATE.to_string(), expected);
173 }
174
175 #[test]
176 fn test_calibration_uuid() {
177 let expected = "f0cd1502-95da-4f4b-9ac8-aa55d312af0c";
178 assert_eq!(CALIBRATION.to_string(), expected);
179 }
180
181 #[test]
184 fn test_gap_service_uuid() {
185 let expected = "00001800-0000-1000-8000-00805f9b34fb";
186 assert_eq!(GAP_SERVICE.to_string(), expected);
187 }
188
189 #[test]
190 fn test_device_info_service_uuid() {
191 let expected = "0000180a-0000-1000-8000-00805f9b34fb";
192 assert_eq!(DEVICE_INFO_SERVICE.to_string(), expected);
193 }
194
195 #[test]
196 fn test_battery_service_uuid() {
197 let expected = "0000180f-0000-1000-8000-00805f9b34fb";
198 assert_eq!(BATTERY_SERVICE.to_string(), expected);
199 }
200
201 #[test]
204 fn test_device_name_uuid() {
205 let expected = "00002a00-0000-1000-8000-00805f9b34fb";
206 assert_eq!(DEVICE_NAME.to_string(), expected);
207 }
208
209 #[test]
210 fn test_model_number_uuid() {
211 let expected = "00002a24-0000-1000-8000-00805f9b34fb";
212 assert_eq!(MODEL_NUMBER.to_string(), expected);
213 }
214
215 #[test]
216 fn test_serial_number_uuid() {
217 let expected = "00002a25-0000-1000-8000-00805f9b34fb";
218 assert_eq!(SERIAL_NUMBER.to_string(), expected);
219 }
220
221 #[test]
222 fn test_firmware_revision_uuid() {
223 let expected = "00002a26-0000-1000-8000-00805f9b34fb";
224 assert_eq!(FIRMWARE_REVISION.to_string(), expected);
225 }
226
227 #[test]
228 fn test_hardware_revision_uuid() {
229 let expected = "00002a27-0000-1000-8000-00805f9b34fb";
230 assert_eq!(HARDWARE_REVISION.to_string(), expected);
231 }
232
233 #[test]
234 fn test_software_revision_uuid() {
235 let expected = "00002a28-0000-1000-8000-00805f9b34fb";
236 assert_eq!(SOFTWARE_REVISION.to_string(), expected);
237 }
238
239 #[test]
240 fn test_manufacturer_name_uuid() {
241 let expected = "00002a29-0000-1000-8000-00805f9b34fb";
242 assert_eq!(MANUFACTURER_NAME.to_string(), expected);
243 }
244
245 #[test]
246 fn test_battery_level_uuid() {
247 let expected = "00002a19-0000-1000-8000-00805f9b34fb";
248 assert_eq!(BATTERY_LEVEL.to_string(), expected);
249 }
250
251 #[test]
254 fn test_aranet_service_uuids_are_distinct() {
255 assert_ne!(SAF_TEHNIKA_SERVICE_NEW, SAF_TEHNIKA_SERVICE_OLD);
256 }
257
258 #[test]
259 fn test_current_readings_uuids_are_distinct() {
260 assert_ne!(CURRENT_READINGS, CURRENT_READINGS_DETAIL);
261 assert_ne!(CURRENT_READINGS_DETAIL, CURRENT_READINGS_DETAIL_ALT);
262 assert_ne!(CURRENT_READINGS, CURRENT_READINGS_DETAIL_ALT);
263 }
264
265 #[test]
266 fn test_history_uuids_are_distinct() {
267 assert_ne!(HISTORY_V1, HISTORY_V2);
268 }
269
270 #[test]
271 fn test_standard_service_uuids_are_distinct() {
272 assert_ne!(GAP_SERVICE, DEVICE_INFO_SERVICE);
273 assert_ne!(DEVICE_INFO_SERVICE, BATTERY_SERVICE);
274 assert_ne!(GAP_SERVICE, BATTERY_SERVICE);
275 }
276
277 #[test]
280 fn test_aranet_characteristic_prefix() {
281 let aranet_uuids = [
283 CURRENT_READINGS,
284 CURRENT_READINGS_DETAIL,
285 CURRENT_READINGS_DETAIL_ALT,
286 TOTAL_READINGS,
287 READ_INTERVAL,
288 HISTORY_V1,
289 HISTORY_V2,
290 COMMAND,
291 SECONDS_SINCE_UPDATE,
292 CALIBRATION,
293 ];
294
295 for uuid in aranet_uuids {
296 assert!(
297 uuid.to_string().starts_with("f0cd"),
298 "UUID {} should start with f0cd",
299 uuid
300 );
301 }
302 }
303
304 #[test]
305 fn test_standard_ble_characteristic_prefix() {
306 let standard_uuids = [
308 DEVICE_NAME,
309 MODEL_NUMBER,
310 SERIAL_NUMBER,
311 FIRMWARE_REVISION,
312 HARDWARE_REVISION,
313 SOFTWARE_REVISION,
314 MANUFACTURER_NAME,
315 BATTERY_LEVEL,
316 ];
317
318 for uuid in standard_uuids {
319 assert!(
320 uuid.to_string().starts_with("00002a"),
321 "UUID {} should start with 00002a",
322 uuid
323 );
324 }
325 }
326}