Initial Relay support implementation (TS011).

Closes #59.
This commit is contained in:
Orne Brocaar
2023-05-22 11:04:13 +01:00
parent 513aa7804d
commit cefe61072d
138 changed files with 28259 additions and 5157 deletions

View File

@ -190,6 +190,13 @@ message Device {
// These tags are exposed in the event payloads or to integration. Tags are
// intended for aggregation and filtering.
map<string, string> tags = 9;
// JoinEUI (optional, EUI64).
// This field will be automatically set / updated on OTAA. However, in some
// cases it must be pre-configured. For example to allow OTAA using a Relay.
// In this case the Relay needs to know the JoinEUI + DevEUI combinations
// of the devices for which it needs to forward uplinks.
string join_eui = 10;
}
message DeviceStatus {

View File

@ -41,6 +41,61 @@ enum MeasurementKind {
STRING = 4;
}
enum CadPeriodicity {
// 1 second.
SEC_1 = 0;
// 500 milliseconds
MS_500 = 1;
// 250 milliseconds
MS_250 = 2;
// 100 milliseconds
MS_100 = 3;
// 50 milliseconds
MS_50 = 4;
// 20 milliseconds
MS_20 = 5;
}
enum SecondChAckOffset {
// 0 kHz.
KHZ_0 = 0;
// 200 kHz.
KHZ_200 = 1;
// 400 kHz.
KHZ_400 = 2;
// 800 kHz.
KHZ_800 = 3;
// 1600 kHz.
KHZ_1600 = 4;
// 3200 kHz.
KHZ_3200 = 5;
}
enum RelayModeActivation {
// Disable the relay mode.
DISABLE_RELAY_MODE = 0;
// Enable the relay model.
ENABLE_RELAY_MODE = 1;
// Dynamic.
DYNAMIC = 2;
// End-device controlled.
END_DEVICE_CONTROLLED = 3;
}
// DeviceProfileService is the service providing API methods for managing device-profiles.
service DeviceProfileService {
// Create the given device-profile.
@ -195,6 +250,154 @@ message DeviceProfile {
// e.g. to provide an 8 channel and 16 channel configuration for the US915
// band.
string region_config_id = 29;
// Device is a Relay device.
// Enable this in case the device is a Relay. A Relay device implements TS011
// and is able to relay data from relay capable devices.
// See for more information the TS011 specification.
bool is_relay = 30;
// Device is a Relay end-device.
// Enable this in case the device is an end-device that can operate under a
// Relay. Please refer to the TS011 specification for more information.
bool is_relay_ed = 31;
// End-device only accept data through relay.
// Only accept data for this device through a relay. This setting is useful
// for testing as in case of a test-setup, the end-device is usually within
// range of the gateway.
bool relay_ed_relay_only = 32;
// Relay must be enabled.
bool relay_enabled = 33;
// Relay CAD periodicity.
CadPeriodicity relay_cad_periodicity = 34;
// Relay default channel index.
// Valid values are 0 and 1, please refer to the RP002 specification for
// the meaning of these values.
uint32 relay_default_channel_index = 35;
// Relay second channel frequency (Hz).
uint32 relay_second_channel_freq = 36;
// Relay second channel DR.
uint32 relay_second_channel_dr = 37;
// Relay second channel ACK offset.
SecondChAckOffset relay_second_channel_ack_offset = 38;
// Relay end-device activation mode.
RelayModeActivation relay_ed_activation_mode = 39;
// Relay end-device smart-enable level.
uint32 relay_ed_smart_enable_level = 40;
// Relay end-device back-off (in case it does not receive WOR ACK frame).
// 0 = Always send a LoRaWAN uplink
// 1..63 = Send a LoRaWAN uplink after X WOR frames without a WOR ACK
uint32 relay_ed_back_off = 41;
// Relay end-device uplink limit bucket size.
//
// This field indicates the multiplier to determine the bucket size
// according to the following formula:
// BucketSize TOKEN = _reload_rate x _bucket_size
//
// Valid values (0 - 3):
// 0 = 1
// 1 = 2
// 2 = 4
// 3 = 12
uint32 relay_ed_uplink_limit_bucket_size = 42;
// Relay end-device uplink limit reload rate.
//
// Valid values:
// * 0 - 62 = X tokens every hour
// * 63 = no limitation
uint32 relay_ed_uplink_limit_reload_rate = 43;
// Relay join-request limit reload rate.
//
// Valid values:
// * 0 - 126 = X tokens every hour
// * 127 = no limitation
uint32 relay_join_req_limit_reload_rate = 44;
// Relay notify limit reload rate.
//
// Valid values:
// * 0 - 126 = X tokens every hour
// * 127 = no limitation
uint32 relay_notify_limit_reload_rate = 45;
// Relay global uplink limit reload rate.
//
// Valid values:
// * 0 - 126 = X tokens every hour
// * 127 = no limitation
uint32 relay_global_uplink_limit_reload_rate = 46;
// Relay overall limit reload rate.
//
// Valid values:
// * 0 - 126 = X tokens every hour
// * 127 = no limitation
uint32 relay_overall_limit_reload_rate = 47;
// Relay join-request limit bucket size.
//
// This field indicates the multiplier to determine the bucket size
// according to the following formula:
// BucketSize TOKEN = _reload_rate x _bucket_size
//
// Valid values (0 - 3):
// 0 = 1
// 1 = 2
// 2 = 4
// 3 = 12
uint32 relay_join_req_limit_bucket_size = 48;
// Relay notify limit bucket size.
//
// This field indicates the multiplier to determine the bucket size
// according to the following formula:
// BucketSize TOKEN = _reload_rate x _bucket_size
//
// Valid values (0 - 3):
// 0 = 1
// 1 = 2
// 2 = 4
// 3 = 12
uint32 relay_notify_limit_bucket_size = 49;
// Relay globak uplink limit bucket size.
//
// This field indicates the multiplier to determine the bucket size
// according to the following formula:
// BucketSize TOKEN = _reload_rate x _bucket_size
//
// Valid values (0 - 3):
// 0 = 1
// 1 = 2
// 2 = 4
// 3 = 12
uint32 relay_global_uplink_limit_bucket_size = 50;
// Relay overall limit bucket size.
//
// This field indicates the multiplier to determine the bucket size
// according to the following formula:
// BucketSize TOKEN = _reload_rate x _bucket_size
//
// Valid values (0 - 3):
// 0 = 1
// 1 = 2
// 2 = 4
// 3 = 12
uint32 relay_overall_limit_bucket_size = 51;
}
message Measurement {

View File

@ -34,8 +34,11 @@ message UplinkFrameLog {
// Time.
google.protobuf.Timestamp time = 7;
// Plaintext mac-commands.
bool plaintext_mac_commands = 8;
// Plaintext f_opts mac-commands.
bool plaintext_f_opts = 8;
// Plaintext frm_payload.
bool plaintext_frm_payload = 9;
}
message DownlinkFrameLog {
@ -63,6 +66,9 @@ message DownlinkFrameLog {
// Device EUI (optional).
string dev_eui = 8;
// Plaintext mac-commands.
bool plaintext_mac_commands = 9;
// Plaintext f_opts mac-commands.
bool plaintext_f_opts = 9;
// Plaintext frm_payload.
bool plaintext_frm_payload = 10;
}

119
api/proto/api/relay.proto vendored Normal file
View File

@ -0,0 +1,119 @@
syntax = "proto3";
package api;
option go_package = "github.com/chirpstack/chirpstack/api/go/v4/api";
option java_package = "io.chirpstack.api";
option java_multiple_files = true;
option java_outer_classname = "RelayProto";
option csharp_namespace = "Chirpstack.Api";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
// RelayService is the service providing API methos for managing relays.
service RelayService {
// List lists the relays for the given application id.
rpc List(ListRelaysRequest) returns (ListRelaysResponse) {
option(google.api.http) = {
get: "/api/relays"
};
}
// AddDevice adds the given device to the relay.
rpc AddDevice(AddRelayDeviceRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
post: "/api/relays/{relay_dev_eui}/devices"
body: "*"
};
}
// RemoveDevice removes the given device from the relay.
rpc RemoveDevice(RemoveRelayDeviceRequest) returns (google.protobuf.Empty) {
option(google.api.http) = {
delete: "/api/relays/{relay_dev_eui}/devices/{dev_eui}"
};
};
// ListDevices lists the devices for the given relay.
rpc ListDevices(ListRelayDevicesRequest) returns (ListRelayDevicesResponse) {
option(google.api.http) = {
get: "/api/relays/{relay_dev_eui}/devices"
};
};
}
message RelayListItem {
// DevEUI (EUI64).
string dev_eui = 1;
// Name.
string name = 2;
}
message ListRelaysRequest {
// Max number of devices to return in the result-set.
uint32 limit = 1;
// Offset in the result-set (for pagination).
uint32 offset = 2;
// Application ID (UUID).
string application_id = 3;
}
message ListRelaysResponse {
// Total number of relays.
uint32 total_count = 1;
// Result-set.
repeated RelayListItem result = 2;
}
message AddRelayDeviceRequest {
// Relay DevEUI (EUI64).
string relay_dev_eui = 1;
// Device DevEUI (EUI64).
string device_dev_eui = 2;
}
message RemoveRelayDeviceRequest {
// Relay DevEUI (EUI64).
string relay_dev_eui = 1;
// Device DevEUI (EUI64).
string device_dev_eui = 2;
}
message ListRelayDevicesRequest {
// Max number of multicast groups to return in the result-set.
uint32 limit = 1;
// Offset in the result-set (for pagination).
uint32 offset = 2;
// Relay DevEUI (EUI64).
string relay_dev_eui = 3;
}
message RelayDeviceListItem {
// DevEUI (EUI64).
string dev_eui = 1;
// Created at timestamp.
google.protobuf.Timestamp created_at = 2;
// Device name.
string name = 3;
}
message ListRelayDevicesResponse {
// Total number of devices.
uint32 total_count = 1;
// Result-set.
repeated RelayDeviceListItem result = 2;
}