From 40b1a8b138ca61fefee42b914f57da9ff36f496a Mon Sep 17 00:00:00 2001 From: Julien Cluzel <julien.cluzel@imt-atlantique.net> Date: Tue, 6 May 2025 11:34:23 +0200 Subject: [PATCH] gateway lora portable --- .DS_Store | Bin 10244 -> 10244 bytes Autre/.DS_Store | Bin 0 -> 6148 bytes Autre/pygate 2/boot.py | 1 + Autre/pygate 2/global_conf.json | 188 ++++++++++++++++++++++++++++++++ Autre/pygate 2/main.py | 57 ++++++++++ Autre/pygate 2/project.pymakr | 1 + Autre/pygate 2/pymakr.conf | 10 ++ 7 files changed, 257 insertions(+) create mode 100644 Autre/.DS_Store create mode 100644 Autre/pygate 2/boot.py create mode 100644 Autre/pygate 2/global_conf.json create mode 100644 Autre/pygate 2/main.py create mode 100644 Autre/pygate 2/project.pymakr create mode 100644 Autre/pygate 2/pymakr.conf diff --git a/.DS_Store b/.DS_Store index 8ceca99186e9dbf32b4f6169866456794034b491..1233496ee8c02aeb959da593f5005b80dca75803 100644 GIT binary patch delta 84 zcmZn(XbG6$&nU1lU^hRbz+@hQP)=3`M}|^{5{9D52Lzfp42_L-6iiGFCVL6mi^HWD hQp<vi@^bR?(is>S7&pfW?B(0cuJDUxv#1C&GXSYk71jU% delta 40 wcmZn(XbG6$&&aniU^hP_-(((v(8;}miktHUXYx&Kc(a*Z;TOy1x1!9<0319HFaQ7m diff --git a/Autre/.DS_Store b/Autre/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0f1a5df841094395828eb8202f84b49b75dbc893 GIT binary patch literal 6148 zcmZQzU|@7AO)+F(5MW?n;9!8zj35RBCIAV8Fop~hR0Kpbg3TylNM%r9FiI*fE`Z7n zb_(Qn4u%4TN``cXL<S`HC*|ZPF)%RfNGiz5EG{uHxW>rD%)-jX&cV*X%@G@%kzXEM zl2}q&?37p(4dR95=jSBB*ojGDnW^RR0wT`&c_oRNd8tJpCBc~~sY!`NG2xkcDf#72 z`K5U&#bCWq2@XyU&UgWd>S{v+6CDK;bIV#Cg=$M9104kuW3$>?P7YCJee0n3?3~=Z z{4PkqGBQGF23{x)qq@Nni{`Jg;G(>o{JeBf{KFKE(xV|T8UmvsFd70QE(D-;2M70v z^ZBTUM?+vV1PFxysC-a>wiO+qbOVG2Nii@oFo2rRAesec7Nj4*01^Xf1<@d_AR45V zff2+4n*r9!z{mj6$_Va;fb@a7Bp@2Boq>@7tet_80j!+?*5GA?XlG!AXlH<RUKk<T z85kkj85kkjVa^++M?+vV1fU_n450-;^}j0vJPScYN6FC;7!83D5dw@XF2OEN;7S?0 ze?fIEs6I`AN`q>DNOcUVs8JgMOppOZ38+#~bq~@CqQO-$BLk!+A8iQ0LTHp84FURx F0063gOOpTq literal 0 HcmV?d00001 diff --git a/Autre/pygate 2/boot.py b/Autre/pygate 2/boot.py new file mode 100644 index 0000000..edd453c --- /dev/null +++ b/Autre/pygate 2/boot.py @@ -0,0 +1 @@ +# boot.py -- run on boot-up diff --git a/Autre/pygate 2/global_conf.json b/Autre/pygate 2/global_conf.json new file mode 100644 index 0000000..023152e --- /dev/null +++ b/Autre/pygate 2/global_conf.json @@ -0,0 +1,188 @@ +{ + "SX1301_conf": { + "lorawan_public": true, + "clksrc": 1, + "antenna_gain": 0, + "radio_0": { + "enable": true, + "type": "SX1257", + "freq": 867500000, + "rssi_offset": -166, + "tx_enable": true, + "tx_freq_min": 863000000, + "tx_freq_max": 870000000 + }, + "radio_1": { + "enable": true, + "type": "SX1257", + "freq": 868500000, + "rssi_offset": -166, + "tx_enable": false + }, + "chan_multiSF_0": { + "enable": true, + "radio": 1, + "if": -400000 + }, + "chan_multiSF_1": { + "enable": true, + "radio": 1, + "if": -200000 + }, + "chan_multiSF_2": { + "enable": true, + "radio": 1, + "if": 0 + }, + "chan_multiSF_3": { + "enable": true, + "radio": 0, + "if": -400000 + }, + "chan_multiSF_4": { + "enable": true, + "radio": 0, + "if": -200000 + }, + "chan_multiSF_5": { + "enable": true, + "radio": 0, + "if": 0 + }, + "chan_multiSF_6": { + "enable": true, + "radio": 0, + "if": 200000 + }, + "chan_multiSF_7": { + "enable": true, + "radio": 0, + "if": 400000 + }, + "chan_Lora_std": { + "enable": true, + "radio": 1, + "if": -200000, + "bandwidth": 250000, + "spread_factor": 7 + }, + "chan_FSK": { + "enable": true, + "radio": 1, + "if": 300000, + "bandwidth": 125000, + "datarate": 50000 + }, + "tx_lut_0": { + "pa_gain": 0, + "mix_gain": 8, + "rf_power": -6, + "dig_gain": 0 + }, + "tx_lut_1": { + "pa_gain": 0, + "mix_gain": 10, + "rf_power": -3, + "dig_gain": 0 + }, + "tx_lut_2": { + "pa_gain": 0, + "mix_gain": 12, + "rf_power": 0, + "dig_gain": 0 + }, + "tx_lut_3": { + "pa_gain": 1, + "mix_gain": 8, + "rf_power": 3, + "dig_gain": 0 + }, + "tx_lut_4": { + "pa_gain": 1, + "mix_gain": 10, + "rf_power": 6, + "dig_gain": 0 + }, + "tx_lut_5": { + "pa_gain": 1, + "mix_gain": 12, + "rf_power": 10, + "dig_gain": 0 + }, + "tx_lut_6": { + "pa_gain": 1, + "mix_gain": 13, + "rf_power": 11, + "dig_gain": 0 + }, + "tx_lut_7": { + "pa_gain": 2, + "mix_gain": 9, + "rf_power": 12, + "dig_gain": 0 + }, + "tx_lut_8": { + "pa_gain": 1, + "mix_gain": 15, + "rf_power": 13, + "dig_gain": 0 + }, + "tx_lut_9": { + "pa_gain": 2, + "mix_gain": 10, + "rf_power": 14, + "dig_gain": 0 + }, + "tx_lut_10": { + "pa_gain": 2, + "mix_gain": 11, + "rf_power": 16, + "dig_gain": 0 + }, + "tx_lut_11": { + "pa_gain": 3, + "mix_gain": 9, + "rf_power": 20, + "dig_gain": 0 + }, + "tx_lut_12": { + "pa_gain": 3, + "mix_gain": 10, + "rf_power": 23, + "dig_gain": 0 + }, + "tx_lut_13": { + "pa_gain": 3, + "mix_gain": 11, + "rf_power": 25, + "dig_gain": 0 + }, + "tx_lut_14": { + "pa_gain": 3, + "mix_gain": 12, + "rf_power": 26, + "dig_gain": 0 + }, + "tx_lut_15": { + "pa_gain": 3, + "mix_gain": 14, + "rf_power": 27, + "dig_gain": 0 + } + }, + "gateway_conf": { + "gateway_ID": "2462ABFFFEF4C0B0", + "server_address": "eu1.cloud.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + "servers": [ + { + "gateway_ID": "2462ABFFFEF4C0B0", + "server_address": "eu1.cloud.thethings.network", + "serv_port_up": 1700, + "serv_port_down": 1700, + "serv_enabled": true + } + ] + } +} \ No newline at end of file diff --git a/Autre/pygate 2/main.py b/Autre/pygate 2/main.py new file mode 100644 index 0000000..24602c4 --- /dev/null +++ b/Autre/pygate 2/main.py @@ -0,0 +1,57 @@ +from network import WLAN +import time +import machine +from machine import RTC +import pycom + +print('\nStarting LoRaWAN concentrator') +# Disable Hearbeat +pycom.heartbeat(False) + +# Define callback function for Pygate events +def machine_cb (arg): + evt = machine.events() + if (evt & machine.PYGATE_START_EVT): + # Green + pycom.rgbled(0x103300) + elif (evt & machine.PYGATE_ERROR_EVT): + # Red + pycom.rgbled(0x331000) + elif (evt & machine.PYGATE_STOP_EVT): + # RGB off + pycom.rgbled(0x000000) + +# register callback function +machine.callback(trigger = (machine.PYGATE_START_EVT | machine.PYGATE_STOP_EVT | machine.PYGATE_ERROR_EVT), handler=machine_cb) + +print('Connecting to WiFi...', end='') +# Connect to a Wifi Network +wlan = WLAN(mode=WLAN.STA) +wlan.connect(ssid='ObjetsConnectes', auth=(WLAN.WPA2, 'Pandemie2021')) +#wlan.connect(ssid='iPhone de Charlotte', auth=(WLAN.WPA2, 'azilisenoraalan')) + +while not wlan.isconnected(): + print('.', end='') + time.sleep(1) +print(" OK") + +# Sync time via NTP server for GW timestamps on Events +print('Syncing RTC via ntp...', end='') +rtc = RTC() +rtc.ntp_sync(server="pool.ntp.org") + +while not rtc.synced(): + print('.', end='') + time.sleep(.5) +print(" OK\n") + +# Read the GW config file from Filesystem +with open('/flash/global_conf.json','r') as fp: + buf = fp.read() + +# Start the Pygate +machine.pygate_init(buf) +# disable degub messages +# machine.pygate_debug_level(1) + +# To stop the Pygate at any time press Ctrl-C on the REPL and run machine.pygate_deinit(). It will take a few seconds to stop the gateway tasks and safely power-off the concentrator. \ No newline at end of file diff --git a/Autre/pygate 2/project.pymakr b/Autre/pygate 2/project.pymakr new file mode 100644 index 0000000..a00bf29 --- /dev/null +++ b/Autre/pygate 2/project.pymakr @@ -0,0 +1 @@ +[["global_conf.json","f","0b7f1cd0e5713e9ac7c8545200e7a878ec3d5f0e63256fae78c9f85f16a4ea1e",3585],["main.py","f","43545e81570daa6f8f324427fcb4e80f42f70d882168b4a119c3c8f9bf29b460",1383]] \ No newline at end of file diff --git a/Autre/pygate 2/pymakr.conf b/Autre/pygate 2/pymakr.conf new file mode 100644 index 0000000..dd042bd --- /dev/null +++ b/Autre/pygate 2/pymakr.conf @@ -0,0 +1,10 @@ +{ + "py_ignore": [ + ".vscode", + ".gitignore", + ".git", + "env", + "venv" + ], + "name": "pygate" +} \ No newline at end of file -- GitLab