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 SENSOR_STATE: Uuid = uuid!("f0cd1401-95da-4f4b-9ac8-aa55d312af0c");
44
45pub const COMMAND: Uuid = uuid!("f0cd1402-95da-4f4b-9ac8-aa55d312af0c");
47
48pub const SECONDS_SINCE_UPDATE: Uuid = uuid!("f0cd2004-95da-4f4b-9ac8-aa55d312af0c");
50
51pub const CALIBRATION: Uuid = uuid!("f0cd1502-95da-4f4b-9ac8-aa55d312af0c");
53
54pub const GAP_SERVICE: Uuid = uuid!("00001800-0000-1000-8000-00805f9b34fb");
58
59pub const DEVICE_INFO_SERVICE: Uuid = uuid!("0000180a-0000-1000-8000-00805f9b34fb");
61
62pub const BATTERY_SERVICE: Uuid = uuid!("0000180f-0000-1000-8000-00805f9b34fb");
64
65pub const DEVICE_NAME: Uuid = uuid!("00002a00-0000-1000-8000-00805f9b34fb");
69
70pub const MODEL_NUMBER: Uuid = uuid!("00002a24-0000-1000-8000-00805f9b34fb");
72
73pub const SERIAL_NUMBER: Uuid = uuid!("00002a25-0000-1000-8000-00805f9b34fb");
75
76pub const FIRMWARE_REVISION: Uuid = uuid!("00002a26-0000-1000-8000-00805f9b34fb");
78
79pub const HARDWARE_REVISION: Uuid = uuid!("00002a27-0000-1000-8000-00805f9b34fb");
81
82pub const SOFTWARE_REVISION: Uuid = uuid!("00002a28-0000-1000-8000-00805f9b34fb");
84
85pub const MANUFACTURER_NAME: Uuid = uuid!("00002a29-0000-1000-8000-00805f9b34fb");
87
88pub const BATTERY_LEVEL: Uuid = uuid!("00002a19-0000-1000-8000-00805f9b34fb");
92
93#[cfg(test)]
94mod tests {
95 use super::*;
96
97 #[test]
100 fn test_saf_tehnika_service_new_uuid() {
101 let expected = "0000fce0-0000-1000-8000-00805f9b34fb";
103 assert_eq!(SAF_TEHNIKA_SERVICE_NEW.to_string(), expected);
104 }
105
106 #[test]
107 fn test_saf_tehnika_service_old_uuid() {
108 let expected = "f0cd1400-95da-4f4b-9ac8-aa55d312af0c";
110 assert_eq!(SAF_TEHNIKA_SERVICE_OLD.to_string(), expected);
111 }
112
113 #[test]
114 fn test_manufacturer_id() {
115 assert_eq!(MANUFACTURER_ID, 0x0702);
117 assert_eq!(MANUFACTURER_ID, 1794);
118 }
119
120 #[test]
123 fn test_current_readings_uuid() {
124 let expected = "f0cd1503-95da-4f4b-9ac8-aa55d312af0c";
125 assert_eq!(CURRENT_READINGS.to_string(), expected);
126 }
127
128 #[test]
129 fn test_current_readings_detail_uuid() {
130 let expected = "f0cd3001-95da-4f4b-9ac8-aa55d312af0c";
132 assert_eq!(CURRENT_READINGS_DETAIL.to_string(), expected);
133 }
134
135 #[test]
136 fn test_current_readings_detail_alt_uuid() {
137 let expected = "f0cd3003-95da-4f4b-9ac8-aa55d312af0c";
139 assert_eq!(CURRENT_READINGS_DETAIL_ALT.to_string(), expected);
140 }
141
142 #[test]
143 fn test_total_readings_uuid() {
144 let expected = "f0cd2001-95da-4f4b-9ac8-aa55d312af0c";
145 assert_eq!(TOTAL_READINGS.to_string(), expected);
146 }
147
148 #[test]
149 fn test_read_interval_uuid() {
150 let expected = "f0cd2002-95da-4f4b-9ac8-aa55d312af0c";
151 assert_eq!(READ_INTERVAL.to_string(), expected);
152 }
153
154 #[test]
155 fn test_history_v1_uuid() {
156 let expected = "f0cd2003-95da-4f4b-9ac8-aa55d312af0c";
157 assert_eq!(HISTORY_V1.to_string(), expected);
158 }
159
160 #[test]
161 fn test_history_v2_uuid() {
162 let expected = "f0cd2005-95da-4f4b-9ac8-aa55d312af0c";
163 assert_eq!(HISTORY_V2.to_string(), expected);
164 }
165
166 #[test]
167 fn test_sensor_state_uuid() {
168 let expected = "f0cd1401-95da-4f4b-9ac8-aa55d312af0c";
169 assert_eq!(SENSOR_STATE.to_string(), expected);
170 }
171
172 #[test]
173 fn test_command_uuid() {
174 let expected = "f0cd1402-95da-4f4b-9ac8-aa55d312af0c";
175 assert_eq!(COMMAND.to_string(), expected);
176 }
177
178 #[test]
179 fn test_seconds_since_update_uuid() {
180 let expected = "f0cd2004-95da-4f4b-9ac8-aa55d312af0c";
181 assert_eq!(SECONDS_SINCE_UPDATE.to_string(), expected);
182 }
183
184 #[test]
185 fn test_calibration_uuid() {
186 let expected = "f0cd1502-95da-4f4b-9ac8-aa55d312af0c";
187 assert_eq!(CALIBRATION.to_string(), expected);
188 }
189
190 #[test]
193 fn test_gap_service_uuid() {
194 let expected = "00001800-0000-1000-8000-00805f9b34fb";
195 assert_eq!(GAP_SERVICE.to_string(), expected);
196 }
197
198 #[test]
199 fn test_device_info_service_uuid() {
200 let expected = "0000180a-0000-1000-8000-00805f9b34fb";
201 assert_eq!(DEVICE_INFO_SERVICE.to_string(), expected);
202 }
203
204 #[test]
205 fn test_battery_service_uuid() {
206 let expected = "0000180f-0000-1000-8000-00805f9b34fb";
207 assert_eq!(BATTERY_SERVICE.to_string(), expected);
208 }
209
210 #[test]
213 fn test_device_name_uuid() {
214 let expected = "00002a00-0000-1000-8000-00805f9b34fb";
215 assert_eq!(DEVICE_NAME.to_string(), expected);
216 }
217
218 #[test]
219 fn test_model_number_uuid() {
220 let expected = "00002a24-0000-1000-8000-00805f9b34fb";
221 assert_eq!(MODEL_NUMBER.to_string(), expected);
222 }
223
224 #[test]
225 fn test_serial_number_uuid() {
226 let expected = "00002a25-0000-1000-8000-00805f9b34fb";
227 assert_eq!(SERIAL_NUMBER.to_string(), expected);
228 }
229
230 #[test]
231 fn test_firmware_revision_uuid() {
232 let expected = "00002a26-0000-1000-8000-00805f9b34fb";
233 assert_eq!(FIRMWARE_REVISION.to_string(), expected);
234 }
235
236 #[test]
237 fn test_hardware_revision_uuid() {
238 let expected = "00002a27-0000-1000-8000-00805f9b34fb";
239 assert_eq!(HARDWARE_REVISION.to_string(), expected);
240 }
241
242 #[test]
243 fn test_software_revision_uuid() {
244 let expected = "00002a28-0000-1000-8000-00805f9b34fb";
245 assert_eq!(SOFTWARE_REVISION.to_string(), expected);
246 }
247
248 #[test]
249 fn test_manufacturer_name_uuid() {
250 let expected = "00002a29-0000-1000-8000-00805f9b34fb";
251 assert_eq!(MANUFACTURER_NAME.to_string(), expected);
252 }
253
254 #[test]
255 fn test_battery_level_uuid() {
256 let expected = "00002a19-0000-1000-8000-00805f9b34fb";
257 assert_eq!(BATTERY_LEVEL.to_string(), expected);
258 }
259
260 #[test]
263 fn test_aranet_service_uuids_are_distinct() {
264 assert_ne!(SAF_TEHNIKA_SERVICE_NEW, SAF_TEHNIKA_SERVICE_OLD);
265 }
266
267 #[test]
268 fn test_current_readings_uuids_are_distinct() {
269 assert_ne!(CURRENT_READINGS, CURRENT_READINGS_DETAIL);
270 assert_ne!(CURRENT_READINGS_DETAIL, CURRENT_READINGS_DETAIL_ALT);
271 assert_ne!(CURRENT_READINGS, CURRENT_READINGS_DETAIL_ALT);
272 }
273
274 #[test]
275 fn test_history_uuids_are_distinct() {
276 assert_ne!(HISTORY_V1, HISTORY_V2);
277 }
278
279 #[test]
280 fn test_standard_service_uuids_are_distinct() {
281 assert_ne!(GAP_SERVICE, DEVICE_INFO_SERVICE);
282 assert_ne!(DEVICE_INFO_SERVICE, BATTERY_SERVICE);
283 assert_ne!(GAP_SERVICE, BATTERY_SERVICE);
284 }
285
286 #[test]
289 fn test_aranet_characteristic_prefix() {
290 let aranet_uuids = [
292 CURRENT_READINGS,
293 CURRENT_READINGS_DETAIL,
294 CURRENT_READINGS_DETAIL_ALT,
295 TOTAL_READINGS,
296 READ_INTERVAL,
297 HISTORY_V1,
298 HISTORY_V2,
299 SENSOR_STATE,
300 COMMAND,
301 SECONDS_SINCE_UPDATE,
302 CALIBRATION,
303 ];
304
305 for uuid in aranet_uuids {
306 assert!(
307 uuid.to_string().starts_with("f0cd"),
308 "UUID {} should start with f0cd",
309 uuid
310 );
311 }
312 }
313
314 #[test]
315 fn test_standard_ble_characteristic_prefix() {
316 let standard_uuids = [
318 DEVICE_NAME,
319 MODEL_NUMBER,
320 SERIAL_NUMBER,
321 FIRMWARE_REVISION,
322 HARDWARE_REVISION,
323 SOFTWARE_REVISION,
324 MANUFACTURER_NAME,
325 BATTERY_LEVEL,
326 ];
327
328 for uuid in standard_uuids {
329 assert!(
330 uuid.to_string().starts_with("00002a"),
331 "UUID {} should start with 00002a",
332 uuid
333 );
334 }
335 }
336}