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

Commit

Permalink
Always use RX1 in US915 and AU915
Browse files Browse the repository at this point in the history
  • Loading branch information
htdvisser committed May 2, 2016
1 parent becd34e commit e2bddbf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 42 deletions.
28 changes: 14 additions & 14 deletions core/components/handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ func TestHandleJoin(t *testing.T) {
// --------------------

{
Desc(t, "Handle valid join-request [US, RX1] | get join-accept")
Desc(t, "Handle valid join-request [US, SF7] | get join-accept")

// Build
tmst := time.Now()
Expand Down Expand Up @@ -1691,7 +1691,7 @@ func TestHandleJoin(t *testing.T) {
// --------------------

{
Desc(t, "Handle valid join-request [US, RX2] | get join-accept")
Desc(t, "Handle valid join-request [US, SF9] | get join-accept")

// Build
tmst := time.Now()
Expand All @@ -1701,7 +1701,7 @@ func TestHandleJoin(t *testing.T) {
DevEUI: []byte{2, 2, 2, 2, 2, 2, 2, 2},
DevNonce: []byte{14, 42},
Metadata: &core.Metadata{
DataRate: "SF10BW125",
DataRate: "SF9BW125",
Region: "us",
Frequency: 902.3,
Timestamp: uint32(tmst.Unix() * 1000000),
Expand Down Expand Up @@ -1740,12 +1740,12 @@ func TestHandleJoin(t *testing.T) {
Payload: &core.LoRaWANJoinAccept{}, // We'll check it by decoding
NwkSKey: nil, // We'll assume it's correct if payload is okay
Metadata: &core.Metadata{
DataRate: "SF12BW500",
DataRate: "SF9BW500",
Frequency: 923.3,
CodingRate: "4/5",
Timestamp: uint32(tmst.Add(6*time.Second).Unix() * 1000000),
Timestamp: uint32(tmst.Add(5*time.Second).Unix() * 1000000),
PayloadSize: 17,
Power: 26,
Power: 21,
InvPolarity: true,
},
}
Expand Down Expand Up @@ -1782,7 +1782,7 @@ func TestHandleJoin(t *testing.T) {
// --------------------

{
Desc(t, "Handle valid join-request [AU, RX1] | get join-accept")
Desc(t, "Handle valid join-request [AU, SF7] | get join-accept")

// Build
tmst := time.Now()
Expand Down Expand Up @@ -1873,7 +1873,7 @@ func TestHandleJoin(t *testing.T) {
// --------------------

{
Desc(t, "Handle valid join-request [AU, RX2] | get join-accept")
Desc(t, "Handle valid join-request [AU, SF9] | get join-accept")

// Build
tmst := time.Now()
Expand All @@ -1883,9 +1883,9 @@ func TestHandleJoin(t *testing.T) {
DevEUI: []byte{2, 2, 2, 2, 2, 2, 2, 2},
DevNonce: []byte{14, 42},
Metadata: &core.Metadata{
DataRate: "SF10BW125",
DataRate: "SF9BW125",
Region: "au",
Frequency: 902.3,
Frequency: 916.0,
Timestamp: uint32(tmst.Unix() * 1000000),
CodingRate: "4/5",
DutyRX1: uint32(dutycycle.StateAvailable),
Expand Down Expand Up @@ -1922,12 +1922,12 @@ func TestHandleJoin(t *testing.T) {
Payload: &core.LoRaWANJoinAccept{}, // We'll check it by decoding
NwkSKey: nil, // We'll assume it's correct if payload is okay
Metadata: &core.Metadata{
DataRate: "SF12BW500",
Frequency: 923.3,
DataRate: "SF9BW500",
Frequency: 925.7,
CodingRate: "4/5",
Timestamp: uint32(tmst.Add(6*time.Second).Unix() * 1000000),
Timestamp: uint32(tmst.Add(5*time.Second).Unix() * 1000000),
PayloadSize: 17,
Power: 26,
Power: 21,
InvPolarity: true,
},
}
Expand Down
32 changes: 4 additions & 28 deletions core/dutycycle/scoreComputer.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ func (c *ScoreComputer) Get(s scores) *Configuration {
}
}
case US:
var err error
if s.rx1.Score > 0 && (c.sf == 7 || c.sf == 8) { // Favor RX1 on SF7 & SF8
var dr int
dr, err = us902_928.GetDataRate(dataRate)
if s.rx1.Score > 0 {
dr, err := us902_928.GetDataRate(dataRate)
if err != nil {
fmt.Println(err.Error())
return nil
Expand All @@ -147,21 +145,9 @@ func (c *ScoreComputer) Get(s scores) *Configuration {
JoinDelay: 5000000,
}
}
if err != nil || s.rx2.Score > 0 {
return &Configuration{
ID: s.rx2.ID,
Frequency: 923.3,
DataRate: "SF12BW500",
Power: 26,
RXDelay: 2000000,
JoinDelay: 6000000,
}
}
case Australia:
var err error
if s.rx1.Score > 0 && (c.sf == 7 || c.sf == 8) { // Favor RX1 on SF7 & SF8
var dr int
dr, err = au915_928.GetDataRate(dataRate)
if s.rx1.Score > 0 {
dr, err := au915_928.GetDataRate(dataRate)
if err != nil {
fmt.Println(err.Error())
return nil
Expand All @@ -188,16 +174,6 @@ func (c *ScoreComputer) Get(s scores) *Configuration {
JoinDelay: 5000000,
}
}
if err != nil || s.rx2.Score > 0 {
return &Configuration{
ID: s.rx2.ID,
Frequency: 923.3,
DataRate: "SF12BW500",
Power: 26,
RXDelay: 2000000,
JoinDelay: 6000000,
}
}
default:
}
return nil
Expand Down

0 comments on commit e2bddbf

Please sign in to comment.