Skip to content

Commit

Permalink
Do not fall back to SF12 when activated using OTAA. Fixes TheThingsAr…
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmeijers committed Oct 14, 2019
1 parent 9418424 commit 66d3bea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions core/networkserver/activation.go
Expand Up @@ -134,6 +134,7 @@ func (n *networkServer) HandleActivate(activation *pb_handler.DeviceActivationRe

dev.LastSeen = time.Now()
dev.UpdatedAt = time.Now()
dev.ActivatedAt = time.Now()
dev.DevAddr = *lorawan.DevAddr
dev.NwkSKey = *lorawan.NwkSKey
dev.FCntUp = 0
Expand Down
5 changes: 3 additions & 2 deletions core/networkserver/device/device.go
Expand Up @@ -36,8 +36,9 @@ type Device struct {
Options Options `redis:"options"`
ADR ADRSettings `redis:"adr,include"`

CreatedAt time.Time `redis:"created_at"`
UpdatedAt time.Time `redis:"updated_at"`
CreatedAt time.Time `redis:"created_at"`
UpdatedAt time.Time `redis:"updated_at"`
ActivatedAt time.Time `redis:"activated_at"` // Indicates whether the device was activated via OTAA method
}

// ADRSettings contains the (desired) settings for a device that uses ADR
Expand Down
2 changes: 1 addition & 1 deletion core/networkserver/uplink_mac.go
Expand Up @@ -97,7 +97,7 @@ func (n *networkServer) handleUplinkMAC(message *pb_broker.DeduplicatedUplinkMes
}

// We did not receive an ADR response, the device may have the wrong RX2 settings
if dev.ADR.ExpectRes && dev.ADR.Band == "EU_863_870" && viper.GetInt("eu-rx2-dr") != 0 {
if dev.ADR.ExpectRes && dev.ADR.Band == "EU_863_870" && viper.GetInt("eu-rx2-dr") != 0 && dev.ActivatedAt.IsZero() {
settings := message.GetResponseTemplate().GetDownlinkOption()
if settings.GetGatewayConfiguration().Frequency == 869525000 {
if loraSettings := settings.ProtocolConfiguration.GetLoRaWAN(); loraSettings != nil {
Expand Down

0 comments on commit 66d3bea

Please sign in to comment.