Skip to content

Commit 5b962da

Browse files
author
Sylvain Miermont
committed
v1.4.1
- Enabling support for FSK per LoRa MAC specification - Adjusting TX and RX calibration set on 868 reference board - Added specific RX/TX calibration set for Kerlink 868 "IoT station" gateway - Changed default SPI port for native driver to Kerlink SPI device number
1 parent 3f22bb7 commit 5b962da

File tree

7 files changed

+80
-42
lines changed

7 files changed

+80
-42
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.4.0
1+
1.4.1

libloragw/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
1414
### library.cfg configuration file processing
1515

1616
ifeq ($(CFG_SPI),native)
17-
CFG_SPI_MSG := Linux native SPI driver (/dev/spidev0.0)
17+
CFG_SPI_MSG := Linux native SPI driver (/dev/spidev32766.0)
1818
CFG_SPI_OPT := CFG_SPI_NATIVE
1919
else ifeq ($(CFG_SPI),ftdi)
2020
CFG_SPI_MSG := FTDI SPI-over-USB bridge using libmpsse/libftdi/libusb
@@ -89,6 +89,9 @@ else ifeq ($(CFG_BRD),ref_1301_868)
8989
else ifeq ($(CFG_BRD),ref_1301_433)
9090
CFG_BRD_MSG := SX1301 reference board with SX1255 radios, 433 MHz filters
9191
CFG_BRD_OPT := CFG_BRD_1301REF433
92+
else ifeq ($(CFG_BRD),kerlink_868)
93+
CFG_BRD_MSG := Kerlink LoRa 868MHz gateway
94+
CFG_BRD_OPT := CFG_BRD_KERLINK868
9295
else
9396
$(info [Info] No specific board selected.)
9497
CFG_BRD_MSG := None

libloragw/inc/loragw_hal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Maintainer: Sylvain Miermont
136136
#if (CFG_BRD_NANO868 == 1)
137137
#define LGW_RF_TX_ENABLE { true, true} /* both radio A and B are usable in TX */
138138
#define LGW_RF_CLKOUT { true, true} /* both radios have clkout enabled */
139-
#elif ((CFG_BRD_1301REF868 == 1) || (CFG_BRD_1301REF433 == 1))
139+
#elif ((CFG_BRD_1301REF868 == 1) || (CFG_BRD_1301REF433 == 1) || (CFG_BRD_KERLINK868 == 1))
140140
#define LGW_RF_TX_ENABLE { true,false} /* radio B TX output is disconnected */
141141
#define LGW_RF_CLKOUT {false, true} /* radio A clkout disabled for spur optimization */
142142
/* === ADD CUSTOMIZATION FOR YOUR OWN BOARD HERE ===

libloragw/library.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### SPI interface to the concentrator ###
44
# Accepted values:
5-
# native Linux native SPI driver (/dev/spidev0.0)
5+
# native Linux native SPI driver (/dev/spidev32766.0)
66
# ftdi FTDI SPI-over-USB bridge using libmpsse/libftdi/libusb
77

88
CFG_SPI= ftdi
@@ -40,6 +40,7 @@ CFG_BAND= eu868
4040
# dev_nano_868 FPGA-based nano-concentrator, with 868 MHz SAW filter
4141
# ref_1301_868 SX1301 reference board with SX1257 radios, 868 MHz filters
4242
# ref_1301_433 SX1301 reference board with SX1255 radios, 433 MHz filters
43+
# kerlink_868 Kerlink LoRa 868MHz gateway
4344
# Keep empty for no calibration parameters (neutral values will be used).
4445

4546
CFG_BRD= ref_1301_868

libloragw/src/loragw_hal.c

Lines changed: 63 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Maintainer: Sylvain Miermont
4444

4545
#define IF_HZ_TO_REG(f) (f << 5)/15625
4646
#define SET_PPM_ON(bw,dr) (((bw == BW_125KHZ) && ((dr == DR_LORA_SF11) || (dr == DR_LORA_SF12))) || ((bw == BW_250KHZ) && (dr == DR_LORA_SF12)))
47-
#define TRACE() fprintf(stderr, "@ %s %d\n", __FUNCTION__, __LINE__);
47+
#define TRACE() fprintf(stderr, "@ %s %d\n", __FUNCTION__, __LINE__);
4848

4949
/* -------------------------------------------------------------------------- */
5050
/* --- PRIVATE CONSTANTS & TYPES -------------------------------------------- */
@@ -58,12 +58,13 @@ Maintainer: Sylvain Miermont
5858
#define TX_METADATA_NB 16
5959
#define RX_METADATA_NB 16
6060

61-
#define AGC_CMD_WAIT 16
62-
#define AGC_CMD_ABORT 17
61+
#define AGC_CMD_WAIT 16
62+
#define AGC_CMD_ABORT 17
6363

6464
#define MIN_LORA_PREAMBLE 4
6565
#define STD_LORA_PREAMBLE 6
6666
#define MIN_FSK_PREAMBLE 3
67+
#define STD_FSK_PREAMBLE 5
6768
#define PLL_LOCK_MAX_ATTEMPTS 5
6869

6970
#define TX_START_DELAY 1500
@@ -100,23 +101,25 @@ F_register(24bit) = F_rf (Hz) / F_step(Hz)
100101
#define SX125x_XOSC_GM_STARTUP 13 /* (default 13) */
101102
#define SX125x_XOSC_DISABLE 2 /* Disable of Xtal Oscillator blocks bit0:regulator, bit1:core(gm), bit2:amplifier */
102103

103-
#define RSSI_MULTI_BIAS -34.5 /* difference between "multi" modem RSSI offset and "stand-alone" modem RSSI offset */
104-
#define RSSI_FSK_BIAS -37.0 /* difference between FSK modem RSSI offset and "stand-alone" modem RSSI offset */
105-
#define RSSI_FSK_REF -70.0 /* linearize FSK RSSI curve around -70 dBm */
106-
#define RSSI_FSK_SLOPE 0.8
104+
#define RSSI_MULTI_BIAS -35 /* difference between "multi" modem RSSI offset and "stand-alone" modem RSSI offset */
105+
#define RSSI_FSK_BIAS -37.0 /* difference between FSK modem RSSI offset and "stand-alone" modem RSSI offset */
106+
#define RSSI_FSK_REF -70.0 /* linearize FSK RSSI curve around -70 dBm */
107+
#define RSSI_FSK_SLOPE 0.8
107108

108109
/* Board-specific RSSI calibration constants */
109110
#if (CFG_BRD_NANO868 == 1)
110-
#define RSSI_BOARD_OFFSET 176
111+
#define RSSI_BOARD_OFFSET 176
111112
#elif (CFG_BRD_1301REF868 == 1)
112-
#define RSSI_BOARD_OFFSET 166
113+
#define RSSI_BOARD_OFFSET 169.5
114+
#elif (CFG_BRD_KERLINK868 == 1)
115+
#define RSSI_BOARD_OFFSET 167
113116
#elif (CFG_BRD_1301REF433 == 1)
114-
#define RSSI_BOARD_OFFSET 176
117+
#define RSSI_BOARD_OFFSET 176
115118
/* === ADD CUSTOMIZATION FOR YOUR OWN BOARD HERE ===
116119
#elif (CFG_BRD_MYBOARD == 1)
117120
*/
118121
#elif (CFG_BRD_NONE == 1)
119-
#define RSSI_BOARD_OFFSET 0
122+
#define RSSI_BOARD_OFFSET 0
120123
#endif
121124

122125
/* constant arrays defining hardware capability */
@@ -189,22 +192,22 @@ typedef struct {
189192
#elif (CFG_BRD_1301REF868 == 1)
190193
#define CUSTOM_TX_POW_TABLE 1
191194
const tx_pow_t tx_pow_table[TX_POW_LUT_SIZE] = {\
192-
{ 0, 3, 8, -9},\
193-
{ 0, 3, 10, -6},\
194-
{ 0, 3, 12, -3},\
195-
{ 1, 3, 8, 0},\
196-
{ 1, 3, 10, 4},\
197-
{ 1, 3, 12, 7},\
198-
{ 1, 3, 13, 8},\
199-
{ 1, 3, 15, 9},\
200-
{ 2, 3, 9, 10},\
201-
{ 2, 3, 10, 12},\
202-
{ 2, 3, 11, 13},\
203-
{ 3, 3, 10, 21},\
204-
{ 3, 3, 12, 23},\
205-
{ 3, 3, 12, 24},\
206-
{ 3, 3, 13, 25},\
207-
{ 3, 3, 15, 26},\
195+
{ 0, 3, 8, -6},\
196+
{ 0, 3, 10, -3},\
197+
{ 0, 3, 12, 0},\
198+
{ 1, 3, 8, 3},\
199+
{ 1, 3, 10, 6},\
200+
{ 1, 3, 12, 10},\
201+
{ 1, 3, 13, 11},\
202+
{ 2, 3, 9, 12},\
203+
{ 1, 3, 15, 13},\
204+
{ 2, 3, 10, 14},\
205+
{ 2, 3, 11, 16},\
206+
{ 3, 3, 9, 20},\
207+
{ 3, 3, 10, 23},\
208+
{ 3, 3, 11, 25},\
209+
{ 3, 3, 12, 26},\
210+
{ 3, 3, 14, 27},\
208211
}; /* calibrated */
209212
#elif (CFG_BRD_1301REF433 == 1)
210213
#define CUSTOM_TX_POW_TABLE 1
@@ -226,7 +229,27 @@ typedef struct {
226229
{ 3, 3, 12, 24},\
227230
{ 3, 3, 13, 25},\
228231
{ 3, 3, 15, 26},\
229-
}; /* TODO: calibration */
232+
}; /* TODO: approximative calibration, needs to be adjusted */
233+
#elif (CFG_BRD_KERLINK868 == 1)
234+
#define CUSTOM_TX_POW_TABLE 1
235+
const tx_pow_t tx_pow_table[TX_POW_LUT_SIZE] = {\
236+
{ 0, 3, 9,-10},\
237+
{ 0, 3, 12, -6},\
238+
{ 0, 3, 15, -3},\
239+
{ 1, 3, 9, 0},\
240+
{ 1, 3, 12, 5},\
241+
{ 1, 3, 14, 7},\
242+
{ 1, 3, 15, 8},\
243+
{ 2, 3, 10, 10},\
244+
{ 2, 3, 11, 12},\
245+
{ 2, 3, 13, 15},\
246+
{ 3, 3, 9, 17},\
247+
{ 3, 3, 10, 19},\
248+
{ 3, 3, 11, 21},\
249+
{ 3, 3, 12, 22},\
250+
{ 3, 3, 13, 23},\
251+
{ 3, 3, 15, 24},\
252+
}; /* calibrated */
230253
/* === ADD CUSTOMIZATION FOR YOUR OWN BOARD HERE ===
231254
#elif (CFG_BRD_MYBOARD == 1)
232255
*/
@@ -298,6 +321,8 @@ typedef struct {
298321
#define CFG_BRD_STR "ref_1301_868"
299322
#elif (CFG_BRD_1301REF433 == 1)
300323
#define CFG_BRD_STR "ref_1301_433"
324+
#elif (CFG_BRD_KERLINK868 == 1)
325+
#define CFG_BRD_STR "kerlink_868"
301326
/* === ADD CUSTOMIZATION FOR YOUR OWN BOARD HERE ===
302327
#elif (CFG_BRD_MYBOARD == 1)
303328
*/
@@ -648,15 +673,14 @@ void lgw_constant_adjust(void) {
648673
/* FSK demodulator setup */
649674
lgw_reg_w(LGW_FSK_RSSI_LENGTH,4); /* default 0 */
650675
lgw_reg_w(LGW_FSK_PKT_MODE,1); /* variable length, default 0 */
651-
lgw_reg_w(LGW_FSK_PSIZE,3); /* ???, default 0 */
676+
lgw_reg_w(LGW_FSK_PSIZE,2); /* pattern size-1, default 0 */
652677
lgw_reg_w(LGW_FSK_CRC_EN,1); /* default 0 */
653-
// lgw_reg_w(LGW_FSK_DCFREE_ENC,0); /* default 0 */
678+
lgw_reg_w(LGW_FSK_DCFREE_ENC,2); /* default 0 */
654679
// lgw_reg_w(LGW_FSK_CRC_IBM,0); /* default 0 */
655680
lgw_reg_w(LGW_FSK_ERROR_OSR_TOL,10); /* default 0 */
656681
lgw_reg_w(LGW_FSK_REF_PATTERN_LSB,0x01010101); /* default 0 */
657-
lgw_reg_w(LGW_FSK_REF_PATTERN_MSB,0x01010101); /* default 0 */
682+
lgw_reg_w(LGW_FSK_REF_PATTERN_MSB,0xC194C101); /* default 0 */
658683
lgw_reg_w(LGW_FSK_PKT_LENGTH,255); /* max packet length in variable length mode */
659-
660684
// lgw_reg_w(LGW_FSK_NODE_ADRS,0); /* default 0 */
661685
// lgw_reg_w(LGW_FSK_BROADCAST,0); /* default 0 */
662686
// lgw_reg_w(LGW_FSK_AUTO_AFC_ON,0); /* default 0 */
@@ -671,9 +695,9 @@ void lgw_constant_adjust(void) {
671695

672696
/* TX FSK */
673697
// lgw_reg_w(LGW_FSK_TX_GAUSSIAN_EN,1); /* default 1 */
674-
lgw_reg_w(LGW_FSK_TX_GAUSSIAN_SELECT_BT,1); /* Gaussian filter always on TX, default 0 */
675-
lgw_reg_w(LGW_FSK_TX_PSIZE,3); /* default 0 */
676-
// lgw_reg_w(LGW_FSK_TX_PATTERN_EN, 1); /* default 1 */
698+
lgw_reg_w(LGW_FSK_TX_GAUSSIAN_SELECT_BT,2); /* Gaussian filter always on TX, default 0 */
699+
lgw_reg_w(LGW_FSK_TX_PSIZE,2); /* default 0 */
700+
// lgw_reg_w(LGW_FSK_TX_PATTERN_EN,1); /* default 1 */
677701
// lgw_reg_w(LGW_FSK_TX_PREAMBLE_SEQ,0); /* default 0 */
678702

679703
return;
@@ -905,7 +929,7 @@ int lgw_start(void) {
905929
cal_cmd |= 0x20; /* Bit 5: 0: SX1257, 1: SX1255 */
906930
#endif
907931

908-
#if ((CFG_BRD_1301REF868 == 1) || (CFG_BRD_1301REF433 == 1))
932+
#if ((CFG_BRD_1301REF868 == 1) || (CFG_BRD_1301REF433 == 1) || (CFG_BRD_KERLINK868 == 1))
909933
cal_cmd |= 0x00; /* Bit 6-7: Board type 0: ref, 1: FPGA, 3: board X */
910934
cal_time = 2300; /* measured between 2.1 and 2.2 sec, because 1 TX only */
911935
#elif (CFG_BRD_NANO868 == 1)
@@ -1587,7 +1611,9 @@ int lgw_send(struct lgw_pkt_tx_s pkt_data) {
15871611
buff[11] = (pkt_data.no_crc?0:0x02); /* always in fixed length packet mode, no DC-free encoding, CCITT CRC if CRC is not disabled */
15881612

15891613
/* metadata 12 & 13, FSK preamble size */
1590-
if (pkt_data.preamble < MIN_FSK_PREAMBLE) { /* enforce minimum preamble size */
1614+
if (pkt_data.preamble == 0) { /* if not explicit, use LoRa MAC preamble size */
1615+
pkt_data.preamble = STD_FSK_PREAMBLE;
1616+
} else if (pkt_data.preamble < MIN_FSK_PREAMBLE) { /* enforce minimum preamble size */
15911617
pkt_data.preamble = MIN_FSK_PREAMBLE;
15921618
DEBUG_MSG("Note: preamble length adjusted to respect minimum FSK preamble size\n");
15931619
}

libloragw/src/loragw_spi.native.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ Maintainer: Sylvain Miermont
5353
#define READ_ACCESS 0x00
5454
#define WRITE_ACCESS 0x80
5555
#define SPI_SPEED 8000000
56-
#define SPI_DEV_PATH "/dev/spidev0.0"
56+
//#define SPI_DEV_PATH "/dev/spidev0.0"
57+
#define SPI_DEV_PATH "/dev/spidev32766.0"
5758

5859
/* -------------------------------------------------------------------------- */
5960
/* --- PUBLIC FUNCTIONS DEFINITION ------------------------------------------ */

readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ gateways as receivers.
5656
3. Changelog
5757
-------------
5858

59+
### v1.4.1 ###
60+
61+
* Enabling support for FSK per LoRa MAC specification
62+
* Adjusting TX and RX calibration set on 868 reference board
63+
* Added specific RX/TX calibration set for Kerlink 868 "IoT station" gateway
64+
* Changed default SPI port for native driver to Kerlink SPI device number
65+
5966
### v1.4.0 ###
6067

6168
* Added calibration routine to optimize RF performance

0 commit comments

Comments
 (0)