Skip to content
This repository was archived by the owner on Dec 14, 2021. It is now read-only.

Commit 00a6f78

Browse files
authored
Merge pull request #768 from jpmeijers/develop
Do not fall back to SF12 when activated using OTAA
2 parents 496d447 + 401fa44 commit 00a6f78

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

core/networkserver/activation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func (n *networkServer) HandleActivate(activation *pb_handler.DeviceActivationRe
134134

135135
dev.LastSeen = time.Now()
136136
dev.UpdatedAt = time.Now()
137+
dev.ActivatedAt = time.Now()
137138
dev.DevAddr = *lorawan.DevAddr
138139
dev.NwkSKey = *lorawan.NwkSKey
139140
dev.FCntUp = 0

core/networkserver/device/device.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ type Device struct {
3636
Options Options `redis:"options"`
3737
ADR ADRSettings `redis:"adr,include"`
3838

39-
CreatedAt time.Time `redis:"created_at"`
40-
UpdatedAt time.Time `redis:"updated_at"`
39+
CreatedAt time.Time `redis:"created_at"`
40+
UpdatedAt time.Time `redis:"updated_at"`
41+
ActivatedAt time.Time `redis:"activated_at"` // Indicates whether the device was activated via OTAA method
4142
}
4243

4344
// ADRSettings contains the (desired) settings for a device that uses ADR

core/networkserver/uplink_mac.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (n *networkServer) handleUplinkMAC(message *pb_broker.DeduplicatedUplinkMes
9797
}
9898

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

0 commit comments

Comments
 (0)