ch2i / LoraGW-Setup

SX1301 Lora Concentrator Raspberry PI based gateway setup
76 stars 30 forks source link

SNR and RSSI of raspberry pi LoRa Gateway #3

Closed ukritkh closed 5 years ago

ukritkh commented 6 years ago

Hi, I was trying to read out both SNR and RSSI values to display on the OLED display from oled.py script and it was unsuccessful. I did add "lora_snr" variable in both global and UDPhandler method.

So I am wondering if I want to get the SNR value, is it to do with oled.py or other files?

Thanks!

hallard commented 6 years ago

@ukritkh did you tried the latest push (26 days ago)? I should detect what packet forwarder you are using, because mp_pkt_fwd (new one) and poly_pkt_fwd (legacy) handle UDP message format not the same way. What packet forwarder are you using? Would you mind sharing your /opt/loragw/global_conf.json that should contain also the local gwtraf server on port 1688 (the one where oled.py is listening)

    "gateway_conf": {
        "gateway_ID": "yourGWID",
        "description": "CH2i TTN GW For testing  purpose",
        "servers": [
            {
                "server_fallbacks": [
                    "mqtts://bridge.asia-se.thethings.network",
                    "mqtts://bridge.us-west.thethings.network",
                    "mqtts://bridge.brazil.thethings.network"
                ],
                "server_address": "bridge.eu.thethings.network",
                "serv_gw_id": "loragw-17dd",
                "serv_type": "ttn",
                "serv_gw_key": "ttn-account-v2.yourTTNkey",
                "serv_enabled": true
            },
            {
                "serv_port_up": 1688,
                "serv_type": "gwtraf",
                "serv_enabled": true,
                "server_address": "127.0.0.1",
                "serv_port_down": 1689
            }
        ],
        "contact_email": "",
        "fake_gps": false,
        "gps": false
    }
}

If you're using the poly_pkt_fwd the field is lsnr

lora_snr = js_data["rxpk"][0]["lsnr"]

I don't know for mp_pkt_fwd (may be lora_snr = js_data["lsnr"] since I'm not using it because it does not works with downlink other than from TTN backend. Buy you can see JSON frame uncommenting this lines in oled.py and launching it by hand

loragw@loragw-17dd:/opt/loragw $ sudo service oled stop
loragw@loragw-17dd:/opt/loragw $ sudo ./oled.py
{"rxpk":[{"tmst":481511819,"time":"2018-07-02T12:58:04.352688Z","chan":0,"rfch":1,"freq":868.100000,"stat":1,"modu":"LORA","datr":"SF7BW125","codr":"4/5","lsnr":10.5,"rssi":-29,"size":27,"data":"QPh5zR4AyAYLp9tSQPOzsIW6TwtqxHVEL0HC"}]}