Add enabled class to DeviceInfo in events.

This commit is contained in:
Orne Brocaar 2023-06-14 12:51:08 +01:00
parent d6d735cb03
commit 6480b3bbd5
14 changed files with 290 additions and 265 deletions

View File

@ -167,17 +167,6 @@ service DeviceService {
}
}
enum DeviceClass {
// Class-A.
A = 0;
// Class-B.
B = 1;
// Class-C.
C = 2;
}
message Device {
// DevEUI (EUI64).
string dev_eui = 1;
@ -302,7 +291,7 @@ message GetDeviceResponse {
DeviceStatus device_status = 5;
// Enabled class.
DeviceClass enabled_class = 6;
common.DeviceClass enabled_class = 6;
}
message UpdateDeviceRequest {

View File

@ -11,193 +11,205 @@ option csharp_namespace = "Chirpstack.Common";
import "google/protobuf/timestamp.proto";
enum Modulation {
// LoRa
LORA = 0;
// LoRa
LORA = 0;
// FSK
FSK = 1;
// FSK
FSK = 1;
// LR-FHSS
LR_FHSS = 2;
// LR-FHSS
LR_FHSS = 2;
}
enum Region {
// EU868
EU868 = 0;
// EU868
EU868 = 0;
// US915
US915 = 2;
// US915
US915 = 2;
// CN779
CN779 = 3;
// CN779
CN779 = 3;
// EU433
EU433 = 4;
// EU433
EU433 = 4;
// AU915
AU915 = 5;
// AU915
AU915 = 5;
// CN470
CN470 = 6;
// CN470
CN470 = 6;
// AS923
AS923 = 7;
// AS923
AS923 = 7;
// AS923 with -1.80 MHz frequency offset
AS923_2 = 12;
// AS923 with -1.80 MHz frequency offset
AS923_2 = 12;
// AS923 with -6.60 MHz frequency offset
AS923_3 = 13;
// AS923 with -6.60 MHz frequency offset
AS923_3 = 13;
// (AS923 with -5.90 MHz frequency offset).
AS923_4 = 14;
// (AS923 with -5.90 MHz frequency offset).
AS923_4 = 14;
// KR920
KR920 = 8;
// KR920
KR920 = 8;
// IN865
IN865 = 9;
// IN865
IN865 = 9;
// RU864
RU864 = 10;
// RU864
RU864 = 10;
// ISM2400 (LoRaWAN 2.4 GHz)
ISM2400 = 11;
// ISM2400 (LoRaWAN 2.4 GHz)
ISM2400 = 11;
}
enum MType {
// JoinRequest.
JOIN_REQUEST = 0;
// JoinRequest.
JOIN_REQUEST = 0;
// JoinAccept.
JOIN_ACCEPT = 1;
// UnconfirmedDataUp.
UNCONFIRMED_DATA_UP = 2;
// JoinAccept.
JOIN_ACCEPT = 1;
// UnconfirmedDataDown.
UNCONFIRMED_DATA_DOWN = 3;
// UnconfirmedDataUp.
UNCONFIRMED_DATA_UP = 2;
// ConfirmedDataUp.
CONFIRMED_DATA_UP = 4;
// ConfirmedDataDown.
CONFIRMED_DATA_DOWN = 5;
// UnconfirmedDataDown.
UNCONFIRMED_DATA_DOWN = 3;
// RejoinRequest.
REJOIN_REQUEST = 6;
// ConfirmedDataUp.
CONFIRMED_DATA_UP = 4;
// Proprietary.
PROPRIETARY = 7;
// ConfirmedDataDown.
CONFIRMED_DATA_DOWN = 5;
// RejoinRequest.
REJOIN_REQUEST = 6;
// Proprietary.
PROPRIETARY = 7;
}
enum MacVersion {
LORAWAN_1_0_0 = 0;
LORAWAN_1_0_1 = 1;
LORAWAN_1_0_2 = 2;
LORAWAN_1_0_3 = 3;
LORAWAN_1_0_4 = 4;
LORAWAN_1_1_0 = 5;
LORAWAN_1_0_0 = 0;
LORAWAN_1_0_1 = 1;
LORAWAN_1_0_2 = 2;
LORAWAN_1_0_3 = 3;
LORAWAN_1_0_4 = 4;
LORAWAN_1_1_0 = 5;
}
enum RegParamsRevision {
A = 0;
B = 1;
RP002_1_0_0 = 2;
RP002_1_0_1 = 3;
RP002_1_0_2 = 4;
RP002_1_0_3 = 5;
A = 0;
B = 1;
RP002_1_0_0 = 2;
RP002_1_0_1 = 3;
RP002_1_0_2 = 4;
RP002_1_0_3 = 5;
}
enum LocationSource {
// Unknown.
UNKNOWN = 0;
// Unknown.
UNKNOWN = 0;
// GPS.
GPS = 1;
// GPS.
GPS = 1;
// Manually configured.
CONFIG = 2;
// Manually configured.
CONFIG = 2;
// Geo resolver (TDOA).
GEO_RESOLVER_TDOA = 3;
// Geo resolver (TDOA).
GEO_RESOLVER_TDOA = 3;
// Geo resolver (RSSI).
GEO_RESOLVER_RSSI = 4;
// Geo resolver (RSSI).
GEO_RESOLVER_RSSI = 4;
// Geo resolver (GNSS).
GEO_RESOLVER_GNSS = 5;
// Geo resolver (GNSS).
GEO_RESOLVER_GNSS = 5;
// Geo resolver (WIFI).
GEO_RESOLVER_WIFI = 6;
// Geo resolver (WIFI).
GEO_RESOLVER_WIFI = 6;
}
enum Aggregation {
// Hour.
HOUR = 0;
// Hour.
HOUR = 0;
// Day.
DAY = 1;
// Day.
DAY = 1;
// Month.
MONTH = 2;
// Month.
MONTH = 2;
}
enum MetricKind {
// Incrementing counters that never decrease (these are not reset on each reading).
COUNTER = 0;
// Incrementing counters that never decrease (these are not reset on each
// reading).
COUNTER = 0;
// Counters that do get reset upon reading.
ABSOLUTE = 1;
// Counters that do get reset upon reading.
ABSOLUTE = 1;
// E.g. a temperature value.
GAUGE = 2;
// E.g. a temperature value.
GAUGE = 2;
}
message Location {
// Latitude.
double latitude = 1;
// Latitude.
double latitude = 1;
// Longitude.
double longitude = 2;
// Longitude.
double longitude = 2;
// Altitude.
double altitude = 3;
// Altitude.
double altitude = 3;
// Location source.
LocationSource source = 4;
// Location source.
LocationSource source = 4;
// Accuracy.
float accuracy = 5;
// Accuracy.
float accuracy = 5;
}
message KeyEnvelope {
// KEK label.
string kek_label = 1;
// KEK label.
string kek_label = 1;
// AES key (when the kek_label is set, this value must first be decrypted).
bytes aes_key = 2;
// AES key (when the kek_label is set, this value must first be decrypted).
bytes aes_key = 2;
}
message Metric {
// Name.
string name = 1;
// Name.
string name = 1;
// Timestamps.
repeated google.protobuf.Timestamp timestamps = 2;
// Timestamps.
repeated google.protobuf.Timestamp timestamps = 2;
// Datasets.
repeated MetricDataset datasets = 3;
// Datasets.
repeated MetricDataset datasets = 3;
// Kind.
MetricKind kind = 4;
// Kind.
MetricKind kind = 4;
}
message MetricDataset {
// Label.
string label = 1;
// Label.
string label = 1;
// Data.
// Each value index corresponds with the same timestamp index of the Metric.
repeated float data = 2;
// Data.
// Each value index corresponds with the same timestamp index of the Metric.
repeated float data = 2;
}
enum DeviceClass {
// Class-A.
CLASS_A = 0;
// Class-B.
CLASS_B = 1;
// Class-C.
CLASS_C = 2;
}

View File

@ -83,6 +83,9 @@ message DeviceInfo {
// Device EUI.
string dev_eui = 8;
// Device class.
common.DeviceClass device_enabled_class = 10;
// Device-profile and device tags.
map<string, string> tags = 9;
}

View File

@ -167,17 +167,6 @@ service DeviceService {
}
}
enum DeviceClass {
// Class-A.
A = 0;
// Class-B.
B = 1;
// Class-C.
C = 2;
}
message Device {
// DevEUI (EUI64).
string dev_eui = 1;
@ -302,7 +291,7 @@ message GetDeviceResponse {
DeviceStatus device_status = 5;
// Enabled class.
DeviceClass enabled_class = 6;
common.DeviceClass enabled_class = 6;
}
message UpdateDeviceRequest {

View File

@ -11,193 +11,205 @@ option csharp_namespace = "Chirpstack.Common";
import "google/protobuf/timestamp.proto";
enum Modulation {
// LoRa
LORA = 0;
// LoRa
LORA = 0;
// FSK
FSK = 1;
// FSK
FSK = 1;
// LR-FHSS
LR_FHSS = 2;
// LR-FHSS
LR_FHSS = 2;
}
enum Region {
// EU868
EU868 = 0;
// EU868
EU868 = 0;
// US915
US915 = 2;
// US915
US915 = 2;
// CN779
CN779 = 3;
// CN779
CN779 = 3;
// EU433
EU433 = 4;
// EU433
EU433 = 4;
// AU915
AU915 = 5;
// AU915
AU915 = 5;
// CN470
CN470 = 6;
// CN470
CN470 = 6;
// AS923
AS923 = 7;
// AS923
AS923 = 7;
// AS923 with -1.80 MHz frequency offset
AS923_2 = 12;
// AS923 with -1.80 MHz frequency offset
AS923_2 = 12;
// AS923 with -6.60 MHz frequency offset
AS923_3 = 13;
// AS923 with -6.60 MHz frequency offset
AS923_3 = 13;
// (AS923 with -5.90 MHz frequency offset).
AS923_4 = 14;
// (AS923 with -5.90 MHz frequency offset).
AS923_4 = 14;
// KR920
KR920 = 8;
// KR920
KR920 = 8;
// IN865
IN865 = 9;
// IN865
IN865 = 9;
// RU864
RU864 = 10;
// RU864
RU864 = 10;
// ISM2400 (LoRaWAN 2.4 GHz)
ISM2400 = 11;
// ISM2400 (LoRaWAN 2.4 GHz)
ISM2400 = 11;
}
enum MType {
// JoinRequest.
JOIN_REQUEST = 0;
// JoinRequest.
JOIN_REQUEST = 0;
// JoinAccept.
JOIN_ACCEPT = 1;
// UnconfirmedDataUp.
UNCONFIRMED_DATA_UP = 2;
// JoinAccept.
JOIN_ACCEPT = 1;
// UnconfirmedDataDown.
UNCONFIRMED_DATA_DOWN = 3;
// UnconfirmedDataUp.
UNCONFIRMED_DATA_UP = 2;
// ConfirmedDataUp.
CONFIRMED_DATA_UP = 4;
// ConfirmedDataDown.
CONFIRMED_DATA_DOWN = 5;
// UnconfirmedDataDown.
UNCONFIRMED_DATA_DOWN = 3;
// RejoinRequest.
REJOIN_REQUEST = 6;
// ConfirmedDataUp.
CONFIRMED_DATA_UP = 4;
// Proprietary.
PROPRIETARY = 7;
// ConfirmedDataDown.
CONFIRMED_DATA_DOWN = 5;
// RejoinRequest.
REJOIN_REQUEST = 6;
// Proprietary.
PROPRIETARY = 7;
}
enum MacVersion {
LORAWAN_1_0_0 = 0;
LORAWAN_1_0_1 = 1;
LORAWAN_1_0_2 = 2;
LORAWAN_1_0_3 = 3;
LORAWAN_1_0_4 = 4;
LORAWAN_1_1_0 = 5;
LORAWAN_1_0_0 = 0;
LORAWAN_1_0_1 = 1;
LORAWAN_1_0_2 = 2;
LORAWAN_1_0_3 = 3;
LORAWAN_1_0_4 = 4;
LORAWAN_1_1_0 = 5;
}
enum RegParamsRevision {
A = 0;
B = 1;
RP002_1_0_0 = 2;
RP002_1_0_1 = 3;
RP002_1_0_2 = 4;
RP002_1_0_3 = 5;
A = 0;
B = 1;
RP002_1_0_0 = 2;
RP002_1_0_1 = 3;
RP002_1_0_2 = 4;
RP002_1_0_3 = 5;
}
enum LocationSource {
// Unknown.
UNKNOWN = 0;
// Unknown.
UNKNOWN = 0;
// GPS.
GPS = 1;
// GPS.
GPS = 1;
// Manually configured.
CONFIG = 2;
// Manually configured.
CONFIG = 2;
// Geo resolver (TDOA).
GEO_RESOLVER_TDOA = 3;
// Geo resolver (TDOA).
GEO_RESOLVER_TDOA = 3;
// Geo resolver (RSSI).
GEO_RESOLVER_RSSI = 4;
// Geo resolver (RSSI).
GEO_RESOLVER_RSSI = 4;
// Geo resolver (GNSS).
GEO_RESOLVER_GNSS = 5;
// Geo resolver (GNSS).
GEO_RESOLVER_GNSS = 5;
// Geo resolver (WIFI).
GEO_RESOLVER_WIFI = 6;
// Geo resolver (WIFI).
GEO_RESOLVER_WIFI = 6;
}
enum Aggregation {
// Hour.
HOUR = 0;
// Hour.
HOUR = 0;
// Day.
DAY = 1;
// Day.
DAY = 1;
// Month.
MONTH = 2;
// Month.
MONTH = 2;
}
enum MetricKind {
// Incrementing counters that never decrease (these are not reset on each reading).
COUNTER = 0;
// Incrementing counters that never decrease (these are not reset on each
// reading).
COUNTER = 0;
// Counters that do get reset upon reading.
ABSOLUTE = 1;
// Counters that do get reset upon reading.
ABSOLUTE = 1;
// E.g. a temperature value.
GAUGE = 2;
// E.g. a temperature value.
GAUGE = 2;
}
message Location {
// Latitude.
double latitude = 1;
// Latitude.
double latitude = 1;
// Longitude.
double longitude = 2;
// Longitude.
double longitude = 2;
// Altitude.
double altitude = 3;
// Altitude.
double altitude = 3;
// Location source.
LocationSource source = 4;
// Location source.
LocationSource source = 4;
// Accuracy.
float accuracy = 5;
// Accuracy.
float accuracy = 5;
}
message KeyEnvelope {
// KEK label.
string kek_label = 1;
// KEK label.
string kek_label = 1;
// AES key (when the kek_label is set, this value must first be decrypted).
bytes aes_key = 2;
// AES key (when the kek_label is set, this value must first be decrypted).
bytes aes_key = 2;
}
message Metric {
// Name.
string name = 1;
// Name.
string name = 1;
// Timestamps.
repeated google.protobuf.Timestamp timestamps = 2;
// Timestamps.
repeated google.protobuf.Timestamp timestamps = 2;
// Datasets.
repeated MetricDataset datasets = 3;
// Datasets.
repeated MetricDataset datasets = 3;
// Kind.
MetricKind kind = 4;
// Kind.
MetricKind kind = 4;
}
message MetricDataset {
// Label.
string label = 1;
// Label.
string label = 1;
// Data.
// Each value index corresponds with the same timestamp index of the Metric.
repeated float data = 2;
// Data.
// Each value index corresponds with the same timestamp index of the Metric.
repeated float data = 2;
}
enum DeviceClass {
// Class-A.
CLASS_A = 0;
// Class-B.
CLASS_B = 1;
// Class-C.
CLASS_C = 2;
}

View File

@ -83,6 +83,9 @@ message DeviceInfo {
// Device EUI.
string dev_eui = 8;
// Device class.
common.DeviceClass device_enabled_class = 10;
// Device-profile and device tags.
map<string, string> tags = 9;
}

View File

@ -249,12 +249,12 @@ impl FromProto<lrwn::RelayModeActivation> for api::RelayModeActivation {
}
}
impl ToProto<api::DeviceClass> for DeviceClass {
fn to_proto(self) -> api::DeviceClass {
impl ToProto<common::DeviceClass> for DeviceClass {
fn to_proto(self) -> common::DeviceClass {
match self {
DeviceClass::A => api::DeviceClass::A,
DeviceClass::B => api::DeviceClass::B,
DeviceClass::C => api::DeviceClass::C,
DeviceClass::A => common::DeviceClass::ClassA,
DeviceClass::B => common::DeviceClass::ClassB,
DeviceClass::C => common::DeviceClass::ClassC,
}
}
}

View File

@ -8,7 +8,7 @@ use rand::Rng;
use tracing::{error, span, trace, warn, Instrument, Level};
use crate::api::backend::get_async_receiver;
use crate::api::helpers::FromProto;
use crate::api::helpers::{FromProto, ToProto};
use crate::backend::roaming;
use crate::downlink::{classb, helpers, tx_ack};
use crate::gpstime::{ToDateTime, ToGpsTime};
@ -431,6 +431,7 @@ impl Data {
device_profile_id: self.device_profile.id.to_string(),
device_profile_name: self.device_profile.name.clone(),
device_name: self.device.name.clone(),
device_enabled_class: self.device.enabled_class.to_proto().into(),
dev_eui: self.device.dev_eui.to_string(),
tags: {
let mut tags = (*self.device_profile.tags).clone();

View File

@ -454,6 +454,7 @@ impl TxAck {
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags,
}),
@ -502,6 +503,7 @@ impl TxAck {
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags,
}),
@ -550,6 +552,7 @@ impl TxAck {
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags,
}),

View File

@ -3,6 +3,7 @@ use bigdecimal::BigDecimal;
use chrono::{DateTime, Utc};
use tracing::info;
use crate::api::helpers::ToProto;
use crate::integration;
use crate::storage::{application, device, device_profile, tenant};
use crate::uplink::{helpers, UplinkFrameSet};
@ -62,6 +63,7 @@ pub async fn handle(
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags,
}),

View File

@ -2,6 +2,7 @@ use anyhow::Result;
use chrono::Utc;
use tracing::info;
use crate::api::helpers::ToProto;
use crate::integration;
use crate::storage::{application, device, device_profile, tenant};
use chirpstack_api::integration as integration_pb;
@ -32,6 +33,7 @@ pub async fn handle(
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags: {
let mut tags = (*dp.tags).clone();
@ -74,6 +76,8 @@ mod test {
use tokio::time::sleep;
use uuid::Uuid;
use chirpstack_api::common;
use crate::storage::fields;
use crate::test;
@ -148,6 +152,7 @@ mod test {
device_profile_id: dp.id.to_string(),
device_profile_name: "dp".to_string(),
device_name: "dev".to_string(),
device_enabled_class: common::DeviceClass::ClassA.into(),
dev_eui: dev.dev_eui.to_string(),
tags: [
("dp_tag".to_string(), "dp_value".to_string()),

View File

@ -400,6 +400,7 @@ impl Data {
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags,
});
@ -1152,6 +1153,7 @@ impl Data {
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags,
}),

View File

@ -16,7 +16,8 @@ use super::{
filter_rx_info_by_region_config_id, filter_rx_info_by_tenant_id, helpers, RelayContext,
UplinkFrameSet,
};
use crate::api::backend::get_async_receiver;
use crate::api::{backend::get_async_receiver, helpers::ToProto};
use crate::backend::{joinserver, keywrap, roaming};
use crate::storage::device_session;
use crate::storage::{
@ -316,6 +317,7 @@ impl JoinRequest {
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags,
});

View File

@ -5,6 +5,7 @@ use chrono::{DateTime, Local, Utc};
use tracing::{span, trace, Instrument, Level};
use super::{helpers, UplinkFrameSet};
use crate::api::helpers::ToProto;
use crate::backend::{joinserver, keywrap, roaming};
use crate::storage::{
application,
@ -184,6 +185,7 @@ impl JoinRequest {
device_profile_id: dp.id.to_string(),
device_profile_name: dp.name.clone(),
device_name: dev.name.clone(),
device_enabled_class: dev.enabled_class.to_proto().into(),
dev_eui: dev.dev_eui.to_string(),
tags,
});