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

Commit

Permalink
Add NS flag to force ADR optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
htdvisser committed Mar 6, 2019
1 parent 60d50d8 commit f57e965
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ ttn gen-keypair generates a public/private keypair
**Options**

```
--force-adr-optimize Force ADR optimization
--net-id int LoRaWAN NetID (default 19)
--redis-address string Redis server and port (default "localhost:6379")
--redis-db int Redis database
Expand Down
3 changes: 3 additions & 0 deletions cmd/networkserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func init() {
"26000000/20": "otaa,abp,world,local,private,testing",
})

networkserverCmd.Flags().Bool("force-adr-optimize", false, "Force ADR optimization")
viper.BindPFlag("networkserver.force-adr-optimize", networkserverCmd.Flags().Lookup("force-adr-optimize"))

networkserverCmd.Flags().String("server-address", "0.0.0.0", "The IP address to listen for communication")
networkserverCmd.Flags().String("server-address-announce", "localhost", "The public IP address to announce")
networkserverCmd.Flags().Int("server-port", 1903, "The port for communication")
Expand Down
3 changes: 3 additions & 0 deletions core/networkserver/adr.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/TheThingsNetwork/ttn/core/networkserver/device"
"github.com/TheThingsNetwork/ttn/utils/errors"
"github.com/brocaar/lorawan"
"github.com/spf13/viper"
)

// DefaultADRMargin is the default SNR margin for ADR
Expand Down Expand Up @@ -120,6 +121,8 @@ func (n *networkServer) handleUplinkADR(message *pb_broker.DeduplicatedUplinkMes
dev.ADR.SendReq = true
if drIdx, err := fp.GetDataRateIndexFor(dev.ADR.DataRate); err == nil && drIdx == 0 {
forceADR = true
} else {
forceADR = viper.GetBool("networkserver.force-adr-optimize")
}
message.Trace = message.Trace.WithEvent(ScheduleMACEvent, macCMD, "link-adr", "reason", "optimize")
ctx.Debugf("Schedule ADR [optimize] %s->%s", dev.ADR.DataRate, desiredDataRate)
Expand Down

0 comments on commit f57e965

Please sign in to comment.