@@ -4,6 +4,7 @@ use std::path::Path;
4
4
use anyhow:: Result ;
5
5
use serde:: Deserialize ;
6
6
use tracing:: { info, span, Instrument , Level } ;
7
+ use uuid:: Uuid ;
7
8
8
9
use crate :: codec:: Codec ;
9
10
use crate :: storage:: { self , device_profile_template} ;
@@ -53,6 +54,8 @@ pub struct ProfileConfig {
53
54
#[ derive( Deserialize ) ]
54
55
#[ serde( default ) ]
55
56
pub struct Profile {
57
+ pub id : Uuid ,
58
+ pub vendor_profile_id : usize ,
56
59
pub region : region:: CommonName ,
57
60
pub mac_version : region:: MacVersion ,
58
61
pub reg_params_revision : region:: Revision ,
@@ -69,6 +72,8 @@ pub struct Profile {
69
72
impl Default for Profile {
70
73
fn default ( ) -> Self {
71
74
Self {
75
+ id : Uuid :: nil ( ) ,
76
+ vendor_profile_id : 0 ,
72
77
region : region:: CommonName :: EU868 ,
73
78
mac_version : region:: MacVersion :: LORAWAN_1_0_4 ,
74
79
reg_params_revision : region:: Revision :: RP002_1_0_4 ,
@@ -84,6 +89,7 @@ impl Default for Profile {
84
89
}
85
90
86
91
#[ derive( Default , Deserialize ) ]
92
+ #[ serde( default ) ]
87
93
pub struct ProfileAbp {
88
94
pub rx1_delay : usize ,
89
95
pub rx1_dr_offset : usize ,
@@ -92,6 +98,7 @@ pub struct ProfileAbp {
92
98
}
93
99
94
100
#[ derive( Default , Deserialize ) ]
101
+ #[ serde( default ) ]
95
102
pub struct ProfileClassB {
96
103
pub timeout_secs : usize ,
97
104
pub ping_slot_periodicity : usize ,
@@ -100,6 +107,7 @@ pub struct ProfileClassB {
100
107
}
101
108
102
109
#[ derive( Default , Deserialize ) ]
110
+ #[ serde( default ) ]
103
111
pub struct ProfileClassC {
104
112
pub timeout_secs : usize ,
105
113
}
@@ -207,15 +215,8 @@ async fn handle_profile(
207
215
208
216
let profile_conf: ProfileConfig = toml:: from_str ( & fs:: read_to_string ( profile_path) ?) ?;
209
217
210
- let id_regex = regex:: Regex :: new ( r"[^a-zA-Z0-9\-]+" ) . unwrap ( ) ;
211
- let id = format ! (
212
- "{}-{}-{}-{}" ,
213
- vendor. slug, device. slug, firmware. version, profile_conf. profile. region
214
- ) ;
215
- let id = id_regex. replace_all ( & id, "-" ) . to_string ( ) ;
216
-
217
218
let dpt = device_profile_template:: DeviceProfileTemplate {
218
- id,
219
+ id : profile_conf . profile . id . to_string ( ) ,
219
220
name : device. name . clone ( ) ,
220
221
description : device. description . clone ( ) ,
221
222
vendor : vendor. name . clone ( ) ,
0 commit comments