Dragino PG1302 + Lora Basics - Illegal value "type"

Hey,

I recently bought a Dragino PG1302 concetrator with the accompnying hat for the Raspberry Pi 4. I’ve been trying to to run it as a lora gateway and connect it to TTN via the Lora Basics protocol. I have used the following method as described in the docs to get to compile the Lora Basics binary and get it running:

git clone https://github.com/lorabasics/basicstation.git
cd basicstation/
make platform=rpi variant=std

And then in my ~/TTN dir, I have the various configuration files, the API key, and letsencrypt cert:

tc.key
tc.trust # obtained with curl https://letsencrypt.org/certs/isrgrootx1.pem.txt -o tc.trust
tc.uri # wss://au1.cloud.thethings.network:8887
station.conf

The contents of my station.conf is as follows:

{
    "radio_conf": {                       /* Actual channel plan is controlled by the server */
        "lorawan_public": true,           /* is default */
        "clksrc": 0,
        "device": "/dev/spidev0.0",
        "pps": true,                      /* default SPI device is platform specific */
        "antenna_gain": 10,                /* antenna gain, in dBi */
        "full_duplex": false,
        "radio_0": {
            /* freq/enable provided by LNS - only hardware-specific settings are listed here */
            "type": "SX1250",
            "rssi_offset": -215.4,
            "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0},
            "tx_enable": true
        },
        "radio_1": {
            "type": "SX1250",
            "rssi_offset": -215.4,
            "rssi_tcomp": {"coeff_a": 0, "coeff_b": 0, "coeff_c": 20.41, "coeff_d": 2162.56, "coeff_e": 0},
            "tx_enable": false
        }
        /* chan_multiSF_X, chan_Lora_std, chan_FSK provided by LNS */
    },
    "station_conf": {
      "log_file":    "stderr",
      "log_level":   "INFO",
      "log_size":    10e6,
      "log_rotate":  3
    }
}

and start the binary in the TTN dir like so:

~/basicstation/build-rpi-std/bin/station

However there the gateway does not start . It looks like the entire station.conf just gets ignored due to a json parsing issue ast atated in the logs. It seems wierd that SX1250 is not a valid value for the type field.

2024-02-18 05:10:24.789 [SYS:INFO] Logging     : stderr (maxsize=10000000, rotate=3)
2024-02-18 05:10:24.789 [SYS:INFO] Station Ver : 2.0.6(rpi/std) 2024-02-17 04:26:48
2024-02-18 05:10:24.789 [SYS:INFO] Package Ver : (null)
2024-02-18 05:10:24.789 [SYS:INFO] mbedTLS Ver : 2.28.0
2024-02-18 05:10:24.789 [SYS:INFO] proto EUI   : 0:d83a:dd21:46a2	(/sys/class/net/eth0/address)
2024-02-18 05:10:24.789 [SYS:INFO] prefix EUI  : ::1	(builtin)
2024-02-18 05:10:24.789 [SYS:INFO] Station EUI : d83a:ddff:fe21:46a2
2024-02-18 05:10:24.789 [SYS:INFO] Station home: ./	(builtin)
2024-02-18 05:10:24.789 [SYS:INFO] Station temp: /var/tmp/	(builtin)
2024-02-18 05:10:24.789 [SYS:WARN] Station in NO-CUPS mode
2024-02-18 05:10:24.991 [TCE:INFO] Starting TC engine
2024-02-18 05:10:24.993 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2024-02-18 05:10:24.993 [TCE:INFO] Connecting to INFOS: wss://au1.cloud.thethings.network:8887
2024-02-18 05:10:26.092 [TCE:INFO] Infos: d83a:ddff:fe21:46a2 muxs-::0 wss://au1.cloud.thethings.network:8887/traffic/eui-D83ADDFFFE2146A2
2024-02-18 05:10:26.092 [AIO:DEBU] [3] ws_close reason=1000
2024-02-18 05:10:26.092 [AIO:ERRO] Recv failed: SSL - The peer notified us that the connection is going to be closed
2024-02-18 05:10:26.092 [AIO:DEBU] [3] WS connection shutdown...
2024-02-18 05:10:26.094 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2024-02-18 05:10:26.094 [TCE:VERB] Connecting to MUXS...
2024-02-18 05:10:27.324 [TCE:VERB] Connected to MUXS.
2024-02-18 05:10:27.399 [RAL:WARN] Ignoring unsupported/unknown field: full_duplex
2024-02-18 05:10:27.399 [JSN:ERRO] @.SX1302_conf.radio_0.type: Illegal value for field "type": SX1250
2024-02-18 05:10:27.399 [RAL:ERRO] Parsing of JSON failed - 'station.conf' ignored
2024-02-18 05:10:27.399 [RAL:ERRO] ral_config failed with status 0x01
2024-02-18 05:10:27.399 [any:ERRO] Closing connection to muxs - error in s2e_onMsg
2024-02-18 05:10:27.399 [AIO:DEBU] [3] ws_close reason=1000
2024-02-18 05:10:27.399 [AIO:DEBU] Echoing close - reason=1000
2024-02-18 05:10:27.445 [AIO:DEBU] [3|WS] Server sent close: reason=1000
2024-02-18 05:10:27.445 [AIO:DEBU] [3] WS connection shutdown...
2024-02-18 05:10:27.446 [TCE:VERB] Connection to MUXS closed in state -1
2024-02-18 05:10:27.446 [TCE:INFO] INFOS reconnect backoff 10s (retry 1)

So why is “SX1250” not a valid field? It is what is in basically all the other configs I see online for gateways using the SX1302/1303 chips and is apparently what is used in the PG1302 module. If anyone can help with this, it would be greatly appreciated.

Are you building for corecell?

Thanks for the speedy response, I actually happened to be working off you blog post.

I didn’t think building for corecell would make sense on as raspberry pi, but I tried it anyway, and the build worked although I had to change ARCH.corecell in setup.gmk to aarch64-linux-gnu.

After rebuilding, it seems now that it can’t open the SPI device:

2024-02-18 07:43:55.849 [SYS:INFO] Logging     : stderr (maxsize=10000000, rotate=3)
2024-02-18 07:43:55.849 [SYS:INFO] Station Ver : 2.0.6(corecell/std) 2024-02-18 07:09:37
2024-02-18 07:43:55.849 [SYS:INFO] Package Ver : (null)
2024-02-18 07:43:55.849 [SYS:INFO] mbedTLS Ver : 2.28.0
2024-02-18 07:43:55.849 [SYS:INFO] proto EUI   : 0:d83a:dd21:46a2	(/sys/class/net/eth0/address)
2024-02-18 07:43:55.849 [SYS:INFO] prefix EUI  : ::1	(builtin)
2024-02-18 07:43:55.849 [SYS:INFO] Station EUI : d83a:ddff:fe21:46a2
2024-02-18 07:43:55.849 [SYS:INFO] Station home: ./	(builtin)
2024-02-18 07:43:55.849 [SYS:INFO] Station temp: /var/tmp/	(builtin)
2024-02-18 07:43:55.850 [SYS:WARN] Station in NO-CUPS mode
2024-02-18 07:43:56.051 [TCE:INFO] Starting TC engine
2024-02-18 07:43:56.054 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2024-02-18 07:43:56.054 [TCE:INFO] Connecting to INFOS: wss://au1.cloud.thethings.network:8887
2024-02-18 07:43:57.056 [TCE:INFO] Infos: d83a:ddff:fe21:46a2 muxs-::0 wss://au1.cloud.thethings.network:8887/traffic/eui-D83ADDFFFE2146A2
2024-02-18 07:43:57.056 [AIO:DEBU] [3] ws_close reason=1000
2024-02-18 07:43:57.056 [AIO:ERRO] Recv failed: SSL - The peer notified us that the connection is going to be closed
2024-02-18 07:43:57.056 [AIO:DEBU] [3] WS connection shutdown...
2024-02-18 07:43:57.058 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2024-02-18 07:43:57.058 [TCE:VERB] Connecting to MUXS...
2024-02-18 07:43:58.033 [TCE:VERB] Connected to MUXS.
2024-02-18 07:43:58.109 [SYS:VERB] rinit.sh: Forked, waiting...
2024-02-18 07:43:58.110 [SYS:DEBU] execvp argv[0]: </bin/sh>
2024-02-18 07:43:58.110 [SYS:DEBU]        argv[1]: <-c>
2024-02-18 07:43:58.110 [SYS:DEBU]        argv[2]: <rinit.sh>
2024-02-18 07:43:58.110 [SYS:DEBU]        argv[3]: <rinit.sh>
2024-02-18 07:43:58.110 [SYS:DEBU]        argv[4]: </dev/spidev0.0>
CoreCell reset through GPIO23...
2024-02-18 07:44:03.141 [SYS:INFO] Process rinit.sh (pid=3847) completed
2024-02-18 07:44:03.141 [RAL:INFO] Lora gateway library version: Version: 2.1.0;
2024-02-18 07:44:03.143 [RAL:INFO] [LGW sx1302] full_duplex=0 clksrc=0 lorawan_public=1
2024-02-18 07:44:03.143 [RAL:DEBU] SX130x txlut table (16 entries)
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  0:  rf_power=12 pa_gain=0 pwr_idx=15
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  1:  rf_power=13 pa_gain=0 pwr_idx=16
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  2:  rf_power=14 pa_gain=0 pwr_idx=17
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  3:  rf_power=15 pa_gain=0 pwr_idx=19
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  4:  rf_power=16 pa_gain=0 pwr_idx=20
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  5:  rf_power=17 pa_gain=0 pwr_idx=22
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  6:  rf_power=18 pa_gain=1 pwr_idx=1
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  7:  rf_power=19 pa_gain=1 pwr_idx=2
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  8:  rf_power=20 pa_gain=1 pwr_idx=3
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut  9:  rf_power=21 pa_gain=1 pwr_idx=4
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut 10:  rf_power=22 pa_gain=1 pwr_idx=5
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut 11:  rf_power=23 pa_gain=1 pwr_idx=6
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut 12:  rf_power=24 pa_gain=1 pwr_idx=7
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut 13:  rf_power=25 pa_gain=1 pwr_idx=9
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut 14:  rf_power=26 pa_gain=1 pwr_idx=11
2024-02-18 07:44:03.143 [RAL:INFO] SX1302 txlut 15:  rf_power=27 pa_gain=1 pwr_idx=14
2024-02-18 07:44:03.143 [RAL:INFO]  RX/TX RF0:    917.2MHz rssi_offset=-215.4 type=5 rssi_tcomp=0.000 0.000 20.410 2162.560 0.000
2024-02-18 07:44:03.143 [RAL:INFO]  RX    RF1:    917.9MHz rssi_offset=-215.4 type=5 rssi_tcomp=0.000 0.000 20.410 2162.560 0.000
2024-02-18 07:44:03.144 [RAL:INFO]  [mSF]   0:    916.8MHz rf=0 freq=-400.0 datarate=0
2024-02-18 07:44:03.144 [RAL:INFO]  [mSF]   1:    917.0MHz rf=0 freq=-200.0 datarate=0
2024-02-18 07:44:03.144 [RAL:INFO]  [mSF]   2:    917.2MHz rf=0 freq=  +0.0 datarate=0
2024-02-18 07:44:03.144 [RAL:INFO]  [mSF]   3:    917.4MHz rf=0 freq=+200.0 datarate=0
2024-02-18 07:44:03.144 [RAL:INFO]  [mSF]   4:    917.6MHz rf=1 freq=-300.0 datarate=0
2024-02-18 07:44:03.144 [RAL:INFO]  [mSF]   5:    917.8MHz rf=1 freq=-100.0 datarate=0
2024-02-18 07:44:03.144 [RAL:INFO]  [mSF]   6:    918.0MHz rf=1 freq=+100.0 datarate=0
2024-02-18 07:44:03.144 [RAL:INFO]  [mSF]   7:    918.2MHz rf=1 freq=+300.0 datarate=0
2024-02-18 07:44:03.144 [RAL:INFO]  [STD]   8:    917.5MHz rf=0 freq=+300.0 datarate=8 bw=6 Explicit header
2024-02-18 07:44:03.144 [RAL:INFO]  channel 9 disabled
2024-02-18 07:44:03.144 [RAL:INFO] Station device: spi:/dev/spidev0.0 (PPS capture disabled)
2024-02-18 07:44:03.144 [HAL:INFO] [lgw_com_open:84] Opening SPI communication interface
2024-02-18 07:44:03.144 [HAL:INFO] [lgw_spi_open:88] Setting SPI speed to 2000000
2024-02-18 07:44:03.144 [HAL:INFO] [lgw_connect:1192] chip version is 0x10 (v1.0)
2024-02-18 07:44:05.359 [HAL:INFO] [timestamp_counter_mode:431] using legacy timestamp
2024-02-18 07:44:05.672 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x39
2024-02-18 07:44:05.673 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x3B
2024-02-18 07:44:05.674 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x38
2024-02-18 07:44:05.674 [HAL:ERRO] [lgw_start:1120] no temperature sensor found.
2024-02-18 07:44:05.674 [RAL:ERRO] Concentrator start failed: lgw_start
2024-02-18 07:44:05.674 [RAL:ERRO] ral_config failed with status 0x08
2024-02-18 07:44:05.674 [any:ERRO] Closing connection to muxs - error in s2e_onMsg
2024-02-18 07:44:05.674 [AIO:DEBU] [3] ws_close reason=1000
2024-02-18 07:44:05.674 [AIO:DEBU] Echoing close - reason=1000
2024-02-18 07:44:05.702 [AIO:DEBU] [3|WS] Server sent close: reason=1000
2024-02-18 07:44:05.702 [AIO:DEBU] [3] WS connection shutdown...
2024-02-18 07:44:05.703 [TCE:VERB] Connection to MUXS closed in state -1
2024-02-18 07:44:05.703 [TCE:INFO] INFOS reconnect backoff 10s (retry 1)
2024-02-18 07:44:15.705 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2024-02-18 07:44:15.705 [TCE:INFO] Connecting to INFOS: wss://au1.cloud.thethings.network:8887
2024-02-18 07:44:16.700 [TCE:INFO] Infos: d83a:ddff:fe21:46a2 muxs-::0 wss://au1.cloud.thethings.network:8887/traffic/eui-D83ADDFFFE2146A2
2024-02-18 07:44:16.700 [AIO:DEBU] [3] ws_close reason=1000
2024-02-18 07:44:16.700 [AIO:ERRO] Recv failed: SSL - The peer notified us that the connection is going to be closed
2024-02-18 07:44:16.700 [AIO:DEBU] [3] WS connection shutdown...
2024-02-18 07:44:16.702 [AIO:INFO] ./tc.trust: 
cert. version     : 3
serial number     : 82:10:CF:B0:D2:40:E3:59:44:63:E0:BB:63:82:8B:00
issuer name       : C=US, O=Internet Security Research Group, CN=ISRG Root X1
subject name      : C=US, O=Internet Security Research Group, CN=ISRG Root X1
issued  on        : 2015-06-04 11:04:38
expires on        : 2035-06-04 11:04:38
signed using      : RSA with SHA-256
RSA key size      : 4096 bits
basic constraints : CA=true
key usage         : Key Cert Sign, CRL Sig2024-02-18 07:44:16.702 [TCE:VERB] Connecting to MUXS...
2024-02-18 07:44:17.665 [TCE:VERB] Connected to MUXS.
2024-02-18 07:44:17.695 [SYS:VERB] rinit.sh: Forked, waiting...
2024-02-18 07:44:17.696 [SYS:DEBU] execvp argv[0]: </bin/sh>
2024-02-18 07:44:17.696 [SYS:DEBU]        argv[1]: <-c>
2024-02-18 07:44:17.696 [SYS:DEBU]        argv[2]: <rinit.sh>
2024-02-18 07:44:17.696 [SYS:DEBU]        argv[3]: <rinit.sh>
2024-02-18 07:44:17.696 [SYS:DEBU]        argv[4]: </dev/spidev0.0>
CoreCell reset through GPIO23...
2024-02-18 07:44:22.727 [SYS:INFO] Process rinit.sh (pid=3862) completed
2024-02-18 07:44:22.727 [RAL:INFO] Lora gateway library version: Version: 2.1.0;
2024-02-18 07:44:22.729 [any:CRIT] Radio device '/dev/spidev0.0' in use by process: 3844

I made sure no other porccesses were using /dev/spide0.0 by checking with ps aux | grep -i "[s]tation" and ps aux | grep -i "3844" but both commands returned no such processes.

I think SPI is working fine. It has obtained your chip version

2024-02-18 07:44:03.144 [HAL:INFO] [lgw_connect:1192] chip version is 0x10 (v1.0)

The Semtech Corecell reference design has a STTS751 Temperature Sensor which is normally omitted from the third party modules.

2024-02-18 07:44:05.672 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x39
2024-02-18 07:44:05.673 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x3B
2024-02-18 07:44:05.674 [HAL:INFO] [lgw_start:1111] no temperature sensor found on port 0x38
2024-02-18 07:44:05.674 [HAL:ERRO] [lgw_start:1120] no temperature sensor found.
2024-02-18 07:44:05.674 [RAL:ERRO] Concentrator start failed: lgw_start
2024-02-18 07:44:05.674 [RAL:ERRO] ral_config failed with status 0x08

The temperature sensor sits on the I2C bus, so potentially you have not enabled the I2C port or the I2C bus is not routed to the PG1302, but I would say it is most likely your PG1302 just doesn’t have it.

If this is the case, you can patch the code and rebuild

wget www.beyondlogic.org/patches/V2.1.0-corecell-disable-stts751.patch 
patch -p1 deps/lgw1302/platform-corecell/libloragw/src/loragw_stts751.c < V2.1.0-corecell-disable-stts751.patch 
make platform=corecell variant=std

The patch simply hardcodes the temperature to 25 degC in the absence of a real temperature sensor.

(The instructions are under troubleshooting in the blog post)

Patched the code to disable the sensor and it seems to be working nicely now. Thanks for the help!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.