Skip to content

Commit

Permalink
Implement optional iPol field for tx.
Browse files Browse the repository at this point in the history
  • Loading branch information
brocaar committed Sep 27, 2016
1 parent eb4c5a7 commit 8f8b664
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 6 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 2.1.2

* Add optional `iPol` field to `txInfo` struct in JSON to override the default
behaviour (which is `iPol=true` when using LoRa modulation)

## 2.1.1

* Do not unmarshal and marshal PHYPayload on receiving / sending
Expand Down
4 changes: 4 additions & 0 deletions docs/topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ Example payload:
}
}
```

Optionally, the field `iPol` (type `bool`) can be used to control the
LoRa modulation polarization inversion. When left blank (`null`), the default
will be used (which is `true` for downlink LoRa modulation.
7 changes: 5 additions & 2 deletions gateway/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,11 @@ func newTXPKFromTXPacket(txPacket gw.TXPacketBytes) (TXPK, error) {
txpk.FDev = uint16(txPacket.TXInfo.DataRate.BitRate / 2)
}

// TODO: do testing with FSK modulation
if txPacket.TXInfo.DataRate.Modulation == band.LoRaModulation {
// by default IPol=true is used for downlink LoRa modulation, however in
// some cases one might want to override this.
if txPacket.TXInfo.IPol != nil {
txpk.IPol = *txPacket.TXInfo.IPol
} else if txPacket.TXInfo.DataRate.Modulation == band.LoRaModulation {
txpk.IPol = true
}

Expand Down
49 changes: 49 additions & 0 deletions gateway/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,55 @@ func TestNewGatewayStatPacket(t *testing.T) {
})
}

func TestNewTXPKFromTXPacket(t *testing.T) {
Convey("Given a TXPacket", t, func() {
txPacket := gw.TXPacketBytes{
TXInfo: gw.TXInfo{
Timestamp: 12345,
Frequency: 868100000,
Power: 14,
CodeRate: "4/5",
DataRate: band.DataRate{
Modulation: band.LoRaModulation,
SpreadFactor: 9,
Bandwidth: 250,
},
},
PHYPayload: []byte{1, 2, 3, 4},
}

Convey("Then te expected TXPK is returned (with default IPol", func() {
txpk, err := newTXPKFromTXPacket(txPacket)
So(err, ShouldBeNil)
So(txpk, ShouldResemble, TXPK{
Imme: false,
Tmst: 12345,
Freq: 868.1,
Powe: 14,
Modu: "LORA",
DatR: DatR{
LoRa: "SF9BW250",
},
CodR: "4/5",
Size: 4,
Data: "AQIDBA==",
IPol: true,
})
})

Convey("Given IPol is requested to false", func() {
f := false
txPacket.TXInfo.IPol = &f

Convey("Then the TXPK IPol is set to false", func() {
txpk, err := newTXPKFromTXPacket(txPacket)
So(err, ShouldBeNil)
So(txpk.IPol, ShouldBeFalse)
})
})
})
}

func TestNewRXPacketFromRXPK(t *testing.T) {
Convey("Given a (Semtech) RXPK and gateway MAC", t, func() {
now := time.Now().UTC()
Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pages:
- Kerlink IoT Station: gateways/kerlink-iot-station.md

extra:
version: '2.1.1'
version: '2.1.2'
github:
download_release: true

Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/brocaar/loraserver/api/gw/gw.go

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

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"revisionTime": "2016-06-01T11:32:10Z"
},
{
"checksumSHA1": "aFJowcDa1NphX/ZeDpjuTdd6Ek0=",
"checksumSHA1": "rHBPrqOaYAGyF0JupgYmj4643+k=",
"path": "github.com/brocaar/loraserver/api/gw",
"revision": "223fc82d79ba63547cd1249379a2b1dce69a3555",
"revisionTime": "2016-09-25T18:21:44Z"
"revision": "b7ac42216a89370da930250f3cce4221937fae61",
"revisionTime": "2016-09-27T17:54:38Z"
},
{
"checksumSHA1": "ya7tMk+wexXh1cmbdp0Sw0lbM1k=",
Expand Down

0 comments on commit 8f8b664

Please sign in to comment.