Skip to content

Commit 8f8b664

Browse files
committed
Implement optional iPol field for tx.
1 parent eb4c5a7 commit 8f8b664

File tree

7 files changed

+68
-6
lines changed

7 files changed

+68
-6
lines changed

docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 2.1.2
4+
5+
* Add optional `iPol` field to `txInfo` struct in JSON to override the default
6+
behaviour (which is `iPol=true` when using LoRa modulation)
7+
38
## 2.1.1
49

510
* Do not unmarshal and marshal PHYPayload on receiving / sending

docs/topics.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ Example payload:
7979
}
8080
}
8181
```
82+
83+
Optionally, the field `iPol` (type `bool`) can be used to control the
84+
LoRa modulation polarization inversion. When left blank (`null`), the default
85+
will be used (which is `true` for downlink LoRa modulation.

gateway/backend.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,11 @@ func newTXPKFromTXPacket(txPacket gw.TXPacketBytes) (TXPK, error) {
447447
txpk.FDev = uint16(txPacket.TXInfo.DataRate.BitRate / 2)
448448
}
449449

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

gateway/backend_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,55 @@ func TestNewGatewayStatPacket(t *testing.T) {
256256
})
257257
}
258258

259+
func TestNewTXPKFromTXPacket(t *testing.T) {
260+
Convey("Given a TXPacket", t, func() {
261+
txPacket := gw.TXPacketBytes{
262+
TXInfo: gw.TXInfo{
263+
Timestamp: 12345,
264+
Frequency: 868100000,
265+
Power: 14,
266+
CodeRate: "4/5",
267+
DataRate: band.DataRate{
268+
Modulation: band.LoRaModulation,
269+
SpreadFactor: 9,
270+
Bandwidth: 250,
271+
},
272+
},
273+
PHYPayload: []byte{1, 2, 3, 4},
274+
}
275+
276+
Convey("Then te expected TXPK is returned (with default IPol", func() {
277+
txpk, err := newTXPKFromTXPacket(txPacket)
278+
So(err, ShouldBeNil)
279+
So(txpk, ShouldResemble, TXPK{
280+
Imme: false,
281+
Tmst: 12345,
282+
Freq: 868.1,
283+
Powe: 14,
284+
Modu: "LORA",
285+
DatR: DatR{
286+
LoRa: "SF9BW250",
287+
},
288+
CodR: "4/5",
289+
Size: 4,
290+
Data: "AQIDBA==",
291+
IPol: true,
292+
})
293+
})
294+
295+
Convey("Given IPol is requested to false", func() {
296+
f := false
297+
txPacket.TXInfo.IPol = &f
298+
299+
Convey("Then the TXPK IPol is set to false", func() {
300+
txpk, err := newTXPKFromTXPacket(txPacket)
301+
So(err, ShouldBeNil)
302+
So(txpk.IPol, ShouldBeFalse)
303+
})
304+
})
305+
})
306+
}
307+
259308
func TestNewRXPacketFromRXPK(t *testing.T) {
260309
Convey("Given a (Semtech) RXPK and gateway MAC", t, func() {
261310
now := time.Now().UTC()

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pages:
1616
- Kerlink IoT Station: gateways/kerlink-iot-station.md
1717

1818
extra:
19-
version: '2.1.1'
19+
version: '2.1.2'
2020
github:
2121
download_release: true
2222

vendor/github.com/brocaar/loraserver/api/gw/gw.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/vendor.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"revisionTime": "2016-06-01T11:32:10Z"
1010
},
1111
{
12-
"checksumSHA1": "aFJowcDa1NphX/ZeDpjuTdd6Ek0=",
12+
"checksumSHA1": "rHBPrqOaYAGyF0JupgYmj4643+k=",
1313
"path": "github.com/brocaar/loraserver/api/gw",
14-
"revision": "223fc82d79ba63547cd1249379a2b1dce69a3555",
15-
"revisionTime": "2016-09-25T18:21:44Z"
14+
"revision": "b7ac42216a89370da930250f3cce4221937fae61",
15+
"revisionTime": "2016-09-27T17:54:38Z"
1616
},
1717
{
1818
"checksumSHA1": "ya7tMk+wexXh1cmbdp0Sw0lbM1k=",

0 commit comments

Comments
 (0)