diff --git a/chirpstack/src/api/device_profile.rs b/chirpstack/src/api/device_profile.rs index da94fe59..41942b3f 100644 --- a/chirpstack/src/api/device_profile.rs +++ b/chirpstack/src/api/device_profile.rs @@ -147,6 +147,7 @@ impl DeviceProfileService for DeviceProfile { ts003_version: app_layer_params.ts003_version().from_proto(), ts004_version: app_layer_params.ts004_version().from_proto(), ts005_version: app_layer_params.ts005_version().from_proto(), + ..Default::default() } }, ..Default::default() @@ -392,6 +393,16 @@ impl DeviceProfileService for DeviceProfile { } else { None }, + app_layer_params: { + let app_layer_params = req_dp.app_layer_params.unwrap_or_default(); + + fields::AppLayerParams { + ts003_version: app_layer_params.ts003_version().from_proto(), + ts004_version: app_layer_params.ts004_version().from_proto(), + ts005_version: app_layer_params.ts005_version().from_proto(), + ..Default::default() + } + }, ..Default::default() }) .await diff --git a/chirpstack/src/storage/fields/device_profile.rs b/chirpstack/src/storage/fields/device_profile.rs index 65dc0ca2..d91e03cf 100644 --- a/chirpstack/src/storage/fields/device_profile.rs +++ b/chirpstack/src/storage/fields/device_profile.rs @@ -235,15 +235,43 @@ mod ed_activation_mode { } } -#[derive( - Default, Debug, Clone, PartialEq, Eq, Deserialize, Serialize, AsExpression, FromSqlRow, -)] +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, AsExpression, FromSqlRow)] #[cfg_attr(feature = "postgres", diesel(sql_type = Jsonb))] #[cfg_attr(feature = "sqlite", diesel(sql_type = Text))] +#[serde(default)] pub struct AppLayerParams { pub ts003_version: Option, pub ts004_version: Option, pub ts005_version: Option, + pub ts003_f_port: u8, + pub ts004_f_port: u8, + pub ts005_f_port: u8, +} + +impl Default for AppLayerParams { + fn default() -> Self { + Self { + ts003_version: None, + ts004_version: None, + ts005_version: None, + ts003_f_port: 202, + ts004_f_port: 201, + ts005_f_port: 200, + } + } +} + +impl AppLayerParams { + pub fn is_app_layer_f_port(&self, f_port: u8) -> bool { + if (self.ts003_version.is_some() && self.ts003_f_port == f_port) + || (self.ts004_version.is_some() && self.ts004_f_port == f_port) + || (self.ts005_version.is_some() && self.ts005_f_port == f_port) + { + true + } else { + false + } + } } #[cfg(feature = "postgres")]