CongducPham / LowCostLoRaGw

Low-cost LoRa IoT & gateway with SX12XX (SX1261/62/68; SX1272/76/77/78/79; SX1280/81), RaspberryPI and Arduino boards
703 stars 355 forks source link

Change ChirpStack Server not possible #274

Closed sheggy012 closed 4 years ago

sheggy012 commented 4 years ago

Hello together I have dedicated Chirpstack server running in a VM, can I have my gateway sent to this address? In the admin interface there is an option to set a Chirpstack IP, but the submit button does not work. If I change the address in the CloudChirpStack.py and key_ChirpStack.py it seems to be not working either. Gateway is still shown as offline.

sheggy012 commented 4 years ago

Okay, found the problem. It seems that the scripts/lorawan_stats/ttn_stats.py and the cs_stats.py cannot read the key_TTN.py and key_Chirpstack.py The value under

except ImportError:
        lorawan_server="127.0.0.1"

is always taken. So only the status updates go to the wrong address. For the client traffic the import works.

CongducPham commented 4 years ago

Hi, first, verify that your configuration file (gateway_conf.json and the key files) follows the lastest version because to preserve existing configuration these file are not updated. So maybe your key_Chirpstack.py file is not up to date with the correct fields. Check the latest version on github and modify your file accordingly. I believe the issue comes from this problem. Then, when you change the ChirpStack server address, use the Configure for LoRaWAN quick button to also set the downlink server in gateway_conf.json to the correct lorawan server address.

sheggy012 commented 4 years ago

It's a fresh installation, all files are up to date. The problem is that the script scripts/lorawan_stats/cs_stats.py looks only in the same directory for key_Chirpstack.py but its 2 folder higher. You can easy test it. Just change the IP Adress in cs_stats.py in the section "except ImportError:" and it will get instantly used in the next status update. If I copy the file key_Chirpstack.py to scripts/lorawan_stats/ it starts working like expected.

CongducPham commented 4 years ago

Yes, you are right, even though the current directory is still /home/pi/lora_gateway, the import statement seems to fail. So you can just add

sys.path.insert(1, '/home/pi/lora_gateway')

right after import sys in cs_stats.py

thanks for raising this issue. regards,

sheggy012 commented 4 years ago

With the change it works now. Thanks for your support and your hard work. Best Regards