Skip to content

Commit 8cb843e

Browse files
committed
Add device id (UUID).
This has the same purpose as the id on profiles and vendors. It makes it easier to decide if the record must be imported or updated.
1 parent dfee68b commit 8cb843e

33 files changed

Lines changed: 148 additions & 216 deletions

interface/api/api.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ message DeleteProfileRequest {
221221
}
222222

223223
message Device {
224+
string id = 7;
224225
string vendor_dir = 1;
225226
string file = 2;
226227

interface/src/structs.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,28 @@ pub struct DeviceConfiguration {
120120
pub device: Device,
121121
}
122122

123-
#[derive(Default, Serialize, Deserialize)]
123+
#[derive(Serialize, Deserialize)]
124124
#[serde(default)]
125125
pub struct Device {
126+
pub id: Uuid,
126127
pub name: String,
127128
pub description: String,
128129
pub firmware: Vec<DeviceFirmware>,
129130
pub metadata: DeviceMetadata,
130131
}
131132

133+
impl Default for Device {
134+
fn default() -> Self {
135+
Device {
136+
id: Uuid::new_v4(),
137+
name: "".into(),
138+
description: "".into(),
139+
firmware: vec![],
140+
metadata: DeviceMetadata::default(),
141+
}
142+
}
143+
}
144+
132145
#[derive(Default, Serialize, Deserialize)]
133146
pub struct DeviceMetadata {
134147
pub product_url: Option<String>,
@@ -260,6 +273,7 @@ impl From<&api::Device> for DeviceConfiguration {
260273
fn from(value: &api::Device) -> Self {
261274
DeviceConfiguration {
262275
device: Device {
276+
id: Uuid::from_str(&value.id).unwrap_or_else(|_| Uuid::new_v4()),
263277
name: value.name.clone(),
264278
description: value.description.clone(),
265279
metadata: value
@@ -304,6 +318,7 @@ impl From<&DeviceConfiguration> for api::Device {
304318
vendor_dir: "".into(),
305319
file: "".into(),
306320

321+
id: value.id.to_string(),
307322
name: value.name.clone(),
308323
description: value.description.clone(),
309324
firmware: value

vendors/dragino/devices/ldds75.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[device]
2+
id = "eaaf6138-870f-48d3-b0ec-299350cb88af"
23
name = "LDDS75"
34
description = "Distance Detection Sensor"
45

vendors/dragino/devices/lds02.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[device]
2+
id = "55deef19-c13c-4b69-a10d-2e89f6398a02"
23
name = "LDS02"
34
description = "Door Sensor"
45

vendors/dragino/devices/lht65n.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[device]
2+
id = "f60ee224-4023-4574-8bcc-45e237c4c02b"
23
name = "LHT65N"
34
description = "Temperature & Humidity Sensor, optional external temperature sensor."
45

vendors/dragino/devices/lt-22222-l.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[device]
2+
id = "cb0a7bef-eaa0-4c61-a0b6-ce33e6ecbc4f"
23
name = "LT-22222-L"
34
description = "LoRa I/O Controller"
45

vendors/dragino/devices/lwl02.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[device]
2+
id = "b9a99932-c5e0-40fb-a673-85c24640cf7c"
23
name = "LWL02"
34
description = "Water Leak Sensor"
45

vendors/milesight/devices/milesight-em300-cl.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[device]
2+
id = "661ab78e-bfd3-40e5-ac75-ef9804eb5b80"
23
name = "Milesight EM300-CL"
34
description = "Capacitive Level Sensor "
45

vendors/milesight/devices/milesight-em300-di.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[device]
2+
id = "ed93f9cc-be5d-4c7f-84fb-6da71e3a1a31"
23
name = "Milesight EM300-DI"
34
description = "Pulse Counter"
45

vendors/milesight/devices/milesight-em300-mcs.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[device]
2+
id = "d3fa42cf-635e-4638-8c87-c62b45813cf3"
23
name = "Milesight EM300-MCS"
34
description = "Magnetic Contact Switch"
45

0 commit comments

Comments
 (0)