mirror of
https://github.com/chirpstack/chirpstack.git
synced 2025-05-21 10:07:56 +00:00
Add app-layer params field to device-profile API.
This commit is contained in:
parent
12c0334391
commit
477f7c74d2
38
api/proto/api/device_profile.proto
vendored
38
api/proto/api/device_profile.proto
vendored
@ -98,6 +98,30 @@ enum RelayModeActivation {
|
|||||||
END_DEVICE_CONTROLLED = 3;
|
END_DEVICE_CONTROLLED = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Ts003Version {
|
||||||
|
// Not implemented.
|
||||||
|
TS003_NOT_IMPLEMENTED = 0;
|
||||||
|
|
||||||
|
// v1.0.0.
|
||||||
|
TS003_V100 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Ts004Version {
|
||||||
|
// Not implemented.
|
||||||
|
TS004_NOT_IMPLEMENTED = 0;
|
||||||
|
|
||||||
|
// v1.0.0.
|
||||||
|
TS004_V100 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Ts005Version {
|
||||||
|
// Not implemented.
|
||||||
|
TS005_NOT_IMPLEMENTED = 0;
|
||||||
|
|
||||||
|
// v1.0.0.
|
||||||
|
TS005_V100 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// DeviceProfileService is the service providing API methods for managing
|
// DeviceProfileService is the service providing API methods for managing
|
||||||
// device-profiles.
|
// device-profiles.
|
||||||
service DeviceProfileService {
|
service DeviceProfileService {
|
||||||
@ -421,6 +445,9 @@ message DeviceProfile {
|
|||||||
// it.
|
// it.
|
||||||
// Valid options are 1 - 15 (0 = always use system RX1 Delay).
|
// Valid options are 1 - 15 (0 = always use system RX1 Delay).
|
||||||
uint32 rx1_delay = 53;
|
uint32 rx1_delay = 53;
|
||||||
|
|
||||||
|
// Application Layer parameters.
|
||||||
|
AppLayerParams app_layer_params = 54;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Measurement {
|
message Measurement {
|
||||||
@ -431,6 +458,17 @@ message Measurement {
|
|||||||
MeasurementKind kind = 3;
|
MeasurementKind kind = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message AppLayerParams {
|
||||||
|
// TS003 version (Application Layer Clock Sync).
|
||||||
|
Ts003Version ts003_version = 1;
|
||||||
|
|
||||||
|
// TS004 version (Fragmented Data Block Transport).
|
||||||
|
Ts004Version ts004_version = 2;
|
||||||
|
|
||||||
|
// TS005 version (Remote Multicast Setup).
|
||||||
|
Ts005Version ts005_version = 3;
|
||||||
|
}
|
||||||
|
|
||||||
message DeviceProfileListItem {
|
message DeviceProfileListItem {
|
||||||
// Device-profile ID (UUID).
|
// Device-profile ID (UUID).
|
||||||
string id = 1;
|
string id = 1;
|
||||||
|
@ -98,6 +98,30 @@ enum RelayModeActivation {
|
|||||||
END_DEVICE_CONTROLLED = 3;
|
END_DEVICE_CONTROLLED = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Ts003Version {
|
||||||
|
// Not implemented.
|
||||||
|
TS003_NOT_IMPLEMENTED = 0;
|
||||||
|
|
||||||
|
// v1.0.0.
|
||||||
|
TS003_V100 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Ts004Version {
|
||||||
|
// Not implemented.
|
||||||
|
TS004_NOT_IMPLEMENTED = 0;
|
||||||
|
|
||||||
|
// v1.0.0.
|
||||||
|
TS004_V100 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Ts005Version {
|
||||||
|
// Not implemented.
|
||||||
|
TS005_NOT_IMPLEMENTED = 0;
|
||||||
|
|
||||||
|
// v1.0.0.
|
||||||
|
TS005_V100 = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// DeviceProfileService is the service providing API methods for managing
|
// DeviceProfileService is the service providing API methods for managing
|
||||||
// device-profiles.
|
// device-profiles.
|
||||||
service DeviceProfileService {
|
service DeviceProfileService {
|
||||||
@ -421,6 +445,9 @@ message DeviceProfile {
|
|||||||
// it.
|
// it.
|
||||||
// Valid options are 1 - 15 (0 = always use system RX1 Delay).
|
// Valid options are 1 - 15 (0 = always use system RX1 Delay).
|
||||||
uint32 rx1_delay = 53;
|
uint32 rx1_delay = 53;
|
||||||
|
|
||||||
|
// Application Layer parameters.
|
||||||
|
AppLayerParams app_layer_params = 54;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Measurement {
|
message Measurement {
|
||||||
@ -431,6 +458,17 @@ message Measurement {
|
|||||||
MeasurementKind kind = 3;
|
MeasurementKind kind = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message AppLayerParams {
|
||||||
|
// TS003 version (Application Layer Clock Sync).
|
||||||
|
Ts003Version ts003_version = 1;
|
||||||
|
|
||||||
|
// TS004 version (Fragmented Data Block Transport).
|
||||||
|
Ts004Version ts004_version = 2;
|
||||||
|
|
||||||
|
// TS005 version (Remote Multicast Setup).
|
||||||
|
Ts005Version ts005_version = 3;
|
||||||
|
}
|
||||||
|
|
||||||
message DeviceProfileListItem {
|
message DeviceProfileListItem {
|
||||||
// Device-profile ID (UUID).
|
// Device-profile ID (UUID).
|
||||||
string id = 1;
|
string id = 1;
|
||||||
|
@ -140,6 +140,15 @@ impl DeviceProfileService for DeviceProfile {
|
|||||||
} else {
|
} else {
|
||||||
None
|
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()
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -252,6 +261,11 @@ impl DeviceProfileService for DeviceProfile {
|
|||||||
as u32,
|
as u32,
|
||||||
allow_roaming: dp.allow_roaming,
|
allow_roaming: dp.allow_roaming,
|
||||||
rx1_delay: dp.rx1_delay as u32,
|
rx1_delay: dp.rx1_delay as u32,
|
||||||
|
app_layer_params: Some(api::AppLayerParams {
|
||||||
|
ts003_version: dp.app_layer_params.ts003_version.to_proto().into(),
|
||||||
|
ts004_version: dp.app_layer_params.ts004_version.to_proto().into(),
|
||||||
|
ts005_version: dp.app_layer_params.ts005_version.to_proto().into(),
|
||||||
|
}),
|
||||||
}),
|
}),
|
||||||
created_at: Some(helpers::datetime_to_prost_timestamp(&dp.created_at)),
|
created_at: Some(helpers::datetime_to_prost_timestamp(&dp.created_at)),
|
||||||
updated_at: Some(helpers::datetime_to_prost_timestamp(&dp.updated_at)),
|
updated_at: Some(helpers::datetime_to_prost_timestamp(&dp.updated_at)),
|
||||||
@ -568,6 +582,7 @@ pub mod test {
|
|||||||
mac_version: common::MacVersion::Lorawan103.into(),
|
mac_version: common::MacVersion::Lorawan103.into(),
|
||||||
reg_params_revision: common::RegParamsRevision::A.into(),
|
reg_params_revision: common::RegParamsRevision::A.into(),
|
||||||
adr_algorithm_id: "default".into(),
|
adr_algorithm_id: "default".into(),
|
||||||
|
app_layer_params: Some(api::AppLayerParams::default()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
get_resp.get_ref().device_profile
|
get_resp.get_ref().device_profile
|
||||||
@ -608,6 +623,7 @@ pub mod test {
|
|||||||
mac_version: common::MacVersion::Lorawan103.into(),
|
mac_version: common::MacVersion::Lorawan103.into(),
|
||||||
reg_params_revision: common::RegParamsRevision::A.into(),
|
reg_params_revision: common::RegParamsRevision::A.into(),
|
||||||
adr_algorithm_id: "default".into(),
|
adr_algorithm_id: "default".into(),
|
||||||
|
app_layer_params: Some(api::AppLayerParams::default()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
get_resp.get_ref().device_profile
|
get_resp.get_ref().device_profile
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
use crate::codec::Codec;
|
|
||||||
use crate::storage::fields::{MeasurementKind, MulticastGroupSchedulingType};
|
|
||||||
use crate::storage::{device, device::DeviceClass, gateway, metrics::Aggregation};
|
|
||||||
use chirpstack_api::{api, common};
|
use chirpstack_api::{api, common};
|
||||||
use lrwn::region::{CommonName, MacVersion, Revision};
|
use lrwn::region::{CommonName, MacVersion, Revision};
|
||||||
|
|
||||||
|
use crate::codec::Codec;
|
||||||
|
use crate::storage::fields::{self, MeasurementKind, MulticastGroupSchedulingType};
|
||||||
|
use crate::storage::{device, device::DeviceClass, gateway, metrics::Aggregation};
|
||||||
|
|
||||||
pub trait FromProto<T> {
|
pub trait FromProto<T> {
|
||||||
#[allow(clippy::wrong_self_convention)]
|
#[allow(clippy::wrong_self_convention)]
|
||||||
fn from_proto(self) -> T;
|
fn from_proto(self) -> T;
|
||||||
@ -284,6 +285,60 @@ impl FromProto<gateway::OrderBy> for api::list_gateways_request::OrderBy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToProto<api::Ts003Version> for Option<fields::device_profile::Ts003Version> {
|
||||||
|
fn to_proto(self) -> api::Ts003Version {
|
||||||
|
match self {
|
||||||
|
None => api::Ts003Version::Ts003NotImplemented,
|
||||||
|
Some(fields::device_profile::Ts003Version::V100) => api::Ts003Version::Ts003V100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromProto<Option<fields::device_profile::Ts003Version>> for api::Ts003Version {
|
||||||
|
fn from_proto(self) -> Option<fields::device_profile::Ts003Version> {
|
||||||
|
match self {
|
||||||
|
api::Ts003Version::Ts003NotImplemented => None,
|
||||||
|
api::Ts003Version::Ts003V100 => Some(fields::device_profile::Ts003Version::V100),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToProto<api::Ts004Version> for Option<fields::device_profile::Ts004Version> {
|
||||||
|
fn to_proto(self) -> api::Ts004Version {
|
||||||
|
match self {
|
||||||
|
None => api::Ts004Version::Ts004NotImplemented,
|
||||||
|
Some(fields::device_profile::Ts004Version::V100) => api::Ts004Version::Ts004V100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromProto<Option<fields::device_profile::Ts004Version>> for api::Ts004Version {
|
||||||
|
fn from_proto(self) -> Option<fields::device_profile::Ts004Version> {
|
||||||
|
match self {
|
||||||
|
api::Ts004Version::Ts004NotImplemented => None,
|
||||||
|
api::Ts004Version::Ts004V100 => Some(fields::device_profile::Ts004Version::V100),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToProto<api::Ts005Version> for Option<fields::device_profile::Ts005Version> {
|
||||||
|
fn to_proto(self) -> api::Ts005Version {
|
||||||
|
match self {
|
||||||
|
None => api::Ts005Version::Ts005NotImplemented,
|
||||||
|
Some(fields::device_profile::Ts005Version::V100) => api::Ts005Version::Ts005V100,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FromProto<Option<fields::device_profile::Ts005Version>> for api::Ts005Version {
|
||||||
|
fn from_proto(self) -> Option<fields::device_profile::Ts005Version> {
|
||||||
|
match self {
|
||||||
|
api::Ts005Version::Ts005NotImplemented => None,
|
||||||
|
api::Ts005Version::Ts005V100 => Some(fields::device_profile::Ts005Version::V100),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn datetime_to_prost_timestamp(dt: &DateTime<Utc>) -> prost_types::Timestamp {
|
pub fn datetime_to_prost_timestamp(dt: &DateTime<Utc>) -> prost_types::Timestamp {
|
||||||
let ts = dt.timestamp_nanos_opt().unwrap_or_default();
|
let ts = dt.timestamp_nanos_opt().unwrap_or_default();
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
mod big_decimal;
|
mod big_decimal;
|
||||||
mod dev_nonces;
|
mod dev_nonces;
|
||||||
mod device_profile;
|
pub mod device_profile;
|
||||||
mod device_session;
|
mod device_session;
|
||||||
mod key_value;
|
mod key_value;
|
||||||
mod measurements;
|
mod measurements;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user