Skip to content

Commit

Permalink
all: Add relay support to band description RPCs
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansmares committed Aug 25, 2023
1 parent 655b61f commit 7434bc6
Show file tree
Hide file tree
Showing 11 changed files with 1,017 additions and 192 deletions.
17 changes: 17 additions & 0 deletions api/ttn/lorawan/v3/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@
- [Message `BandDescription.Channel`](#ttn.lorawan.v3.BandDescription.Channel)
- [Message `BandDescription.DataRatesEntry`](#ttn.lorawan.v3.BandDescription.DataRatesEntry)
- [Message `BandDescription.DwellTime`](#ttn.lorawan.v3.BandDescription.DwellTime)
- [Message `BandDescription.RelayParameters`](#ttn.lorawan.v3.BandDescription.RelayParameters)
- [Message `BandDescription.RelayParameters.RelayWORChannel`](#ttn.lorawan.v3.BandDescription.RelayParameters.RelayWORChannel)
- [Message `BandDescription.Rx2Parameters`](#ttn.lorawan.v3.BandDescription.Rx2Parameters)
- [Message `BandDescription.SubBandParameters`](#ttn.lorawan.v3.BandDescription.SubBandParameters)
- [Message `FrequencyPlanDescription`](#ttn.lorawan.v3.FrequencyPlanDescription)
Expand Down Expand Up @@ -2466,6 +2468,7 @@ PeerInfo
| `default_max_eirp` | [`float`](#float) | | |
| `default_rx2_parameters` | [`BandDescription.Rx2Parameters`](#ttn.lorawan.v3.BandDescription.Rx2Parameters) | | |
| `boot_dwell_time` | [`BandDescription.DwellTime`](#ttn.lorawan.v3.BandDescription.DwellTime) | | |
| `relay` | [`BandDescription.RelayParameters`](#ttn.lorawan.v3.BandDescription.RelayParameters) | | |

### <a name="ttn.lorawan.v3.BandDescription.BandDataRate">Message `BandDescription.BandDataRate`</a>

Expand Down Expand Up @@ -2503,6 +2506,20 @@ PeerInfo
| `uplinks` | [`google.protobuf.BoolValue`](#google.protobuf.BoolValue) | | |
| `downlinks` | [`google.protobuf.BoolValue`](#google.protobuf.BoolValue) | | |

### <a name="ttn.lorawan.v3.BandDescription.RelayParameters">Message `BandDescription.RelayParameters`</a>

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `wor_channels` | [`BandDescription.RelayParameters.RelayWORChannel`](#ttn.lorawan.v3.BandDescription.RelayParameters.RelayWORChannel) | repeated | |

### <a name="ttn.lorawan.v3.BandDescription.RelayParameters.RelayWORChannel">Message `BandDescription.RelayParameters.RelayWORChannel`</a>

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `frequency` | [`uint64`](#uint64) | | |
| `ack_frequency` | [`uint64`](#uint64) | | |
| `data_rate_index` | [`DataRateIndex`](#ttn.lorawan.v3.DataRateIndex) | | |

### <a name="ttn.lorawan.v3.BandDescription.Rx2Parameters">Message `BandDescription.Rx2Parameters`</a>

| Field | Type | Label | Description |
Expand Down
31 changes: 31 additions & 0 deletions api/ttn/lorawan/v3/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -17244,6 +17244,18 @@
}
}
},
"BandDescriptionRelayParameters": {
"type": "object",
"properties": {
"wor_channels": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/RelayParametersRelayWORChannel"
}
}
}
},
"BandDescriptionRx2Parameters": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -18419,6 +18431,22 @@
"default": "ENABLED",
"description": " - ENABLED: No restrictions are in place.\n - WARNING: Warnings are being emitted that the provider will be deprecated in the future.\n - DISABLED: New integrations cannot be set up, and old ones do not start."
},
"RelayParametersRelayWORChannel": {
"type": "object",
"properties": {
"frequency": {
"type": "string",
"format": "uint64"
},
"ack_frequency": {
"type": "string",
"format": "uint64"
},
"data_rate_index": {
"$ref": "#/definitions/v3DataRateIndex"
}
}
},
"TxAcknowledgmentResult": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -20356,6 +20384,9 @@
},
"boot_dwell_time": {
"$ref": "#/definitions/BandDescriptionDwellTime"
},
"relay": {
"$ref": "#/definitions/BandDescriptionRelayParameters"
}
}
},
Expand Down
11 changes: 11 additions & 0 deletions api/ttn/lorawan/v3/configuration_services.proto
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ message BandDescription {
}

DwellTime boot_dwell_time = 31;

message RelayParameters {
message RelayWORChannel {
uint64 frequency = 1;
uint64 ack_frequency = 2;
DataRateIndex data_rate_index = 3;
}
repeated RelayWORChannel wor_channels = 1;
}

RelayParameters relay = 33;
}

message ListBandsResponse {
Expand Down
11 changes: 11 additions & 0 deletions pkg/band/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func (b Band) BandDescription() *ttnpb.BandDescription {
Frequency: b.DefaultRx2Parameters.Frequency,
},
BootDwellTime: &ttnpb.BandDescription_DwellTime{},
Relay: &ttnpb.BandDescription_RelayParameters{},
}

for _, channel := range b.UplinkChannels {
Expand Down Expand Up @@ -194,5 +195,15 @@ func (b Band) BandDescription() *ttnpb.BandDescription {
}
}

for _, ch := range b.Relay.WORChannels {
bandDescription.Relay.WorChannels = append(
bandDescription.Relay.WorChannels, &ttnpb.BandDescription_RelayParameters_RelayWORChannel{
Frequency: ch.Frequency,
AckFrequency: ch.ACKFrequency,
DataRateIndex: ch.DataRateIndex,
},
)
}

return bandDescription
}
70 changes: 64 additions & 6 deletions pkg/band/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package band_test

import (
"context"
"sort"
"testing"
"time"
Expand All @@ -24,15 +23,15 @@ import (
. "go.thethings.network/lorawan-stack/v3/pkg/band"
"go.thethings.network/lorawan-stack/v3/pkg/errors"
"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
"go.thethings.network/lorawan-stack/v3/pkg/util/test"
"go.thethings.network/lorawan-stack/v3/pkg/util/test/assertions/should"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/wrapperspb"
)

func TestGetPhyVersions(t *testing.T) {
t.Parallel()
a := assertions.New(t)
ctx := context.Background()
a, ctx := test.New(t)

for _, tc := range []struct {
Name string
Expand Down Expand Up @@ -408,7 +407,7 @@ func TestGetPhyVersions(t *testing.T) {
}
}

func TestBand_convertToBandDescription(t *testing.T) {
func TestBandConvertToBandDescription(t *testing.T) {
t.Parallel()
a := assertions.New(t)

Expand Down Expand Up @@ -481,6 +480,21 @@ func TestBand_convertToBandDescription(t *testing.T) {
Downlinks: BoolPtr(true),
},

Relay: RelayParameters{
WORChannels: []RelayWORChannel{
{
Frequency: 1,
ACKFrequency: 2,
DataRateIndex: ttnpb.DataRateIndex_DATA_RATE_1,
},
{
Frequency: 3,
ACKFrequency: 4,
DataRateIndex: ttnpb.DataRateIndex_DATA_RATE_2,
},
},
},

SharedParameters: SharedParameters{
ReceiveDelay1: 1 * time.Second,
ReceiveDelay2: 2 * time.Second,
Expand Down Expand Up @@ -562,6 +576,21 @@ func TestBand_convertToBandDescription(t *testing.T) {
Uplinks: &wrapperspb.BoolValue{Value: true},
Downlinks: &wrapperspb.BoolValue{Value: true},
},

Relay: &ttnpb.BandDescription_RelayParameters{
WorChannels: []*ttnpb.BandDescription_RelayParameters_RelayWORChannel{
{
Frequency: 1,
AckFrequency: 2,
DataRateIndex: ttnpb.DataRateIndex_DATA_RATE_1,
},
{
Frequency: 3,
AckFrequency: 4,
DataRateIndex: ttnpb.DataRateIndex_DATA_RATE_2,
},
},
},
},
},
{
Expand Down Expand Up @@ -622,6 +651,21 @@ func TestBand_convertToBandDescription(t *testing.T) {

BootDwellTime: DwellTime{},

Relay: RelayParameters{
WORChannels: []RelayWORChannel{
{
Frequency: 1,
ACKFrequency: 2,
DataRateIndex: ttnpb.DataRateIndex_DATA_RATE_1,
},
{
Frequency: 3,
ACKFrequency: 4,
DataRateIndex: ttnpb.DataRateIndex_DATA_RATE_2,
},
},
},

SharedParameters: SharedParameters{
ReceiveDelay1: 1 * time.Second,
ReceiveDelay2: 2 * time.Second,
Expand Down Expand Up @@ -700,6 +744,21 @@ func TestBand_convertToBandDescription(t *testing.T) {
},

BootDwellTime: &ttnpb.BandDescription_DwellTime{},

Relay: &ttnpb.BandDescription_RelayParameters{
WorChannels: []*ttnpb.BandDescription_RelayParameters_RelayWORChannel{
{
Frequency: 1,
AckFrequency: 2,
DataRateIndex: ttnpb.DataRateIndex_DATA_RATE_1,
},
{
Frequency: 3,
AckFrequency: 4,
DataRateIndex: ttnpb.DataRateIndex_DATA_RATE_2,
},
},
},
},
},
} {
Expand Down Expand Up @@ -739,8 +798,7 @@ func convertBands(input map[string]map[ttnpb.PHYVersion]Band) map[string]*ttnpb.

func TestListBands(t *testing.T) {
t.Parallel()
a := assertions.New(t)
ctx := context.Background()
a, ctx := test.New(t)

for _, tc := range []struct {
Name string
Expand Down
Loading

0 comments on commit 7434bc6

Please sign in to comment.