Skip to content

Commit

Permalink
Merge pull request #4785 from TheThingsNetwork/release/v3.15.3
Browse files Browse the repository at this point in the history
Release v3.15.3
  • Loading branch information
adriansmares authored Oct 26, 2021
2 parents ed6dd0a + 8f59386 commit 6695f5c
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 156 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ For details about compatibility between different releases, see the **Commitment

### Security

## [3.15.3] - 2021-10-26

### Fixed

- Gateway disconnection when location updates from status messages are enabled.

## [3.15.2] - 2021-10-22

### Added
Expand Down Expand Up @@ -1832,7 +1838,8 @@ For details about compatibility between different releases, see the **Commitment
<!--
NOTE: These links should respect backports. See https://github.com/TheThingsNetwork/lorawan-stack/pull/1444/files#r333379706.
-->
[unreleased]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.15.2...v3.15
[unreleased]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.15.3...v3.15
[3.15.2]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.15.2...v3.15.3
[3.15.2]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.15.1...v3.15.2
[3.15.1]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.15.0...v3.15.1
[3.15.0]: https://github.com/TheThingsNetwork/lorawan-stack/compare/v3.14.2...v3.15.0
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ttn-stack",
"version": "3.15.2",
"version": "3.15.3",
"description": "The Things Stack",
"main": "index.js",
"repository": "https://github.com/TheThingsNetwork/lorawan-stack.git",
Expand All @@ -15,7 +15,7 @@
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/plugin-transform-spread": "^7.14.6",
"@babel/plugin-transform-strict-mode": "^7.12.13",
"@babel/preset-env": "^7.15.6",
"@babel/preset-env": "^7.15.8",
"@babel/preset-react": "^7.12.13",
"@babel/register": "^7.15.3",
"@babel/runtime-corejs2": "^7.12.18",
Expand All @@ -29,7 +29,7 @@
"@testing-library/cypress": "^7.0.4",
"add-asset-html-webpack-plugin": "^3.1.3",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"babel-loader": "^8.2.3",
"babel-plugin-istanbul": "^6.0.0",
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-react-intl": "^3.0.1",
Expand Down Expand Up @@ -82,7 +82,7 @@
"@formatjs/intl-numberformat": "^7.2.3",
"@formatjs/intl-pluralrules": "^4.1.2",
"@formatjs/intl-relativetimeformat": "^8.0.6",
"@sentry/browser": "^6.12.0",
"@sentry/browser": "^6.13.3",
"@sentry/integrations": "^6.13.0",
"@tippyjs/react": "^4.2.5",
"autobind-decorator": "^2.4.0",
Expand Down Expand Up @@ -114,7 +114,7 @@
"react-leaflet": "^3.1.0",
"react-paginate": "^7.1.3",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-router-dom": "^5.3.0",
"react-select": "^4.1.0",
"react-string-replace": "^0.4.4",
"react-switch": "^6.0.0",
Expand Down
58 changes: 33 additions & 25 deletions pkg/gatewayserver/gatewayserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,14 +547,7 @@ func (gs *GatewayServer) GetConnection(ctx context.Context, ids ttnpb.GatewayIde
}

func requireDisconnect(connected, current *ttnpb.Gateway) bool {
fromPtrArray := func(in []*ttnpb.GatewayAntenna) []ttnpb.GatewayAntenna {
ret := make([]ttnpb.GatewayAntenna, len(in))
for _, a := range in {
ret = append(ret, *a)
}
return ret
}
if !sameAntennaLocations(fromPtrArray(connected.GetAntennas()), fromPtrArray(current.GetAntennas())) {
if !sameAntennaLocations(connected.GetAntennas(), current.GetAntennas()) {
// Gateway Server may update the location from status messages. If the locations aren't the same, but if the new
// location is a GPS location, do not disconnect the gateway. This is to avoid that updating the location from a
// gateway status message results in disconnecting the gateway.
Expand Down Expand Up @@ -857,28 +850,29 @@ func sameLocation(a, b ttnpb.Location) bool {
math.Abs(a.Longitude-b.Longitude) <= allowedLocationDelta
}

func sameAntennaLocations(a, b []ttnpb.GatewayAntenna) bool {
func sameAntennaLocations(a, b []*ttnpb.GatewayAntenna) bool {
if len(a) != len(b) {
return false
}
for _, a := range a {
for _, b := range b {
if a.Location != nil && b.Location != nil && !sameLocation(*a.Location, *b.Location) {
return false
}
if (a.Location == nil) != (b.Location == nil) {
return false
}
for i := range a {
a, b := a[i], b[i]
if a.Location != nil && b.Location != nil && !sameLocation(*a.Location, *b.Location) {
return false
}
if (a.Location == nil) != (b.Location == nil) {
return false
}
}
return true
}

var statusLocationFields = ttnpb.ExcludeFields(ttnpb.LocationFieldPathsNested, "source")

func (gs *GatewayServer) handleLocationUpdates(conn connectionEntry) {
var (
ctx = conn.Context()
gtw = conn.Gateway()
lastAntennas []ttnpb.GatewayAntenna
lastAntennas []*ttnpb.GatewayAntenna
)

for {
Expand All @@ -895,15 +889,29 @@ func (gs *GatewayServer) handleLocationUpdates(conn connectionEntry) {
if cs := len(status.AntennaLocations); cs > c {
c = cs
}
antennas := make([]ttnpb.GatewayAntenna, c)
for i, ant := range gtwAntennas {
antennas[i].Gain = ant.Gain
}
antennas := make([]*ttnpb.GatewayAntenna, c)
for i := range antennas {
antennas[i] = &ttnpb.GatewayAntenna{}

if i < len(gtwAntennas) {
if err := antennas[i].SetFields(
gtwAntennas[i],
ttnpb.GatewayAntennaFieldPathsNested...,
); err != nil {
log.FromContext(ctx).WithError(err).Warn("Failed to clone antenna")
}
}

if i < len(status.AntennaLocations) && status.AntennaLocations[i] != nil {
loc := *status.AntennaLocations[i]
loc.Source = ttnpb.SOURCE_GPS
antennas[i].Location = &loc
antennas[i].Location = &ttnpb.Location{
Source: ttnpb.SOURCE_GPS,
}
if err := antennas[i].Location.SetFields(
status.AntennaLocations[i],
statusLocationFields...,
); err != nil {
log.FromContext(ctx).WithError(err).Warn("Failed to clone antenna location")
}
}
}
if lastAntennas != nil && sameAntennaLocations(lastAntennas, antennas) {
Expand Down
9 changes: 2 additions & 7 deletions pkg/gatewayserver/is.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (is IS) Get(ctx context.Context, req *ttnpb.GetGatewayRequest) (*ttnpb.Gate
}

// UpdateAntennas updates the gateway antennas.
func (is IS) UpdateAntennas(ctx context.Context, ids ttnpb.GatewayIdentifiers, antennas []ttnpb.GatewayAntenna) error {
func (is IS) UpdateAntennas(ctx context.Context, ids ttnpb.GatewayIdentifiers, antennas []*ttnpb.GatewayAntenna) error {
callOpt, err := rpcmetadata.WithForwardedAuth(ctx, is.AllowInsecureForCredentials())
if err != nil {
return err
Expand All @@ -86,15 +86,10 @@ func (is IS) UpdateAntennas(ctx context.Context, ids ttnpb.GatewayIdentifiers, a
return err
}

a := make([]*ttnpb.GatewayAntenna, 0)
for _, antenna := range antennas {
a = append(a, &antenna)
}

req := &ttnpb.UpdateGatewayRequest{
Gateway: &ttnpb.Gateway{
Ids: &ids,
Antennas: a,
Antennas: antennas,
},
FieldMask: &pbtypes.FieldMask{
Paths: []string{"antennas"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/gatewayserver/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type EntityRegistry interface {
// Get the gateway with the given identifiers, selecting the fields specified.
Get(ctx context.Context, in *ttnpb.GetGatewayRequest) (*ttnpb.Gateway, error)
// UpdateAntennas updates the gateway antennas.
UpdateAntennas(ctx context.Context, ids ttnpb.GatewayIdentifiers, antennas []ttnpb.GatewayAntenna) error
UpdateAntennas(ctx context.Context, ids ttnpb.GatewayIdentifiers, antennas []*ttnpb.GatewayAntenna) error
// ValidateGatewayID validates the ID of the gateway.
ValidateGatewayID(ctx context.Context, ids ttnpb.GatewayIdentifiers) error
}
2 changes: 1 addition & 1 deletion pkg/version/ttn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion sdk/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ttn-lw",
"version": "3.15.2",
"version": "3.15.3",
"description": "The Things Stack for LoRaWAN JavaScript SDK",
"url": "https://github.com/TheThingsNetwork/lorawan-stack/tree/default/sdk/js",
"main": "dist/index.js",
Expand Down
Loading

0 comments on commit 6695f5c

Please sign in to comment.