From 09312c50ac207fae91d63ecf3fd12bd4d7b52a24 Mon Sep 17 00:00:00 2001
From: CARNEIRO--GILLET Alexandre
 <alexandre.carneiro-gillet@imt-atlantique.net>
Date: Tue, 13 May 2025 08:32:16 +0200
Subject: [PATCH] =?UTF-8?q?modifs=20non=20commit=20de=20la=20derni=C3=A8re?=
 =?UTF-8?q?=20fois?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Autre/pygate 2/main.py          | 11 +++++++----
 GW-custom/LoRa_homemade/main.py | 23 +++--------------------
 2 files changed, 10 insertions(+), 24 deletions(-)

diff --git a/Autre/pygate 2/main.py b/Autre/pygate 2/main.py
index 24602c4..d5d204d 100644
--- a/Autre/pygate 2/main.py	
+++ b/Autre/pygate 2/main.py	
@@ -1,8 +1,9 @@
-from network import WLAN
 import time
+
 import machine
-from machine import RTC
 import pycom
+from machine import RTC
+from network import WLAN
 
 print('\nStarting LoRaWAN concentrator')
 # Disable Hearbeat
@@ -27,12 +28,14 @@ machine.callback(trigger = (machine.PYGATE_START_EVT | machine.PYGATE_STOP_EVT |
 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='Redmi Note 8 (2021)', auth=(WLAN.WPA2, 'lemotdepassecestca'))
 #wlan.connect(ssid='iPhone de Charlotte', auth=(WLAN.WPA2, 'azilisenoraalan'))
 
-while not wlan.isconnected():
+timout = 10  # seconds
+while not wlan.isconnected() and timout > 0:
     print('.', end='')
     time.sleep(1)
+    timout -= 1
 print(" OK")
 
 # Sync time via NTP server for GW timestamps on Events
diff --git a/GW-custom/LoRa_homemade/main.py b/GW-custom/LoRa_homemade/main.py
index 2981f0e..9fe0782 100644
--- a/GW-custom/LoRa_homemade/main.py
+++ b/GW-custom/LoRa_homemade/main.py
@@ -49,7 +49,7 @@ def blink_led(times, interval):
         led.value(0)  # Eteindre la LED
         time.sleep(interval)  # Attendre un certain temps
 
-def configure_lora(frequency, sf, bw, TXPR, RXPR, TX_power):
+def configure_lora():
     
     send_at_command("")
     send_at_command("+MODE=TEST")
@@ -90,7 +90,7 @@ def send_to_sensor_community_sht30(temp, humid):
     url = "https://api.sensor.community/v1/push-sensor-data/"
     headers = {
         "Content-Type": "application/json",
-        "X-Pin": "7",  # 7 = SHT30
+        "X-Pin": "7",  # 7 = SHT30 ou DHT22
         "X-Sensor": "esp32-900881266"
     }
     data = {
@@ -129,23 +129,6 @@ def try_receive():
 
 wifi_connect()  # Connexion au Wi-Fi
 
-wlan = network.WLAN(network.STA_IF)
-print(wlan.ifconfig())
-
-
-import urequests
-
-try:
-    r = urequests.post("http://httpbin.org/post", json={"test": 123})
-    print("Réponse HTTP:", r.status_code)
-    print(r.text)
-    r.close()
-except Exception as e:
-    print("Erreur:", e)
-
-
-
-
 
 uart = UART(2, baudrate=9600, tx=17, rx=16)
 
@@ -154,7 +137,7 @@ led = Pin(2, Pin.OUT)  # GPIO 2 pour la LED bleue intégrée
 # Initialisation du module LoRa
 blink_led(3, 0.5)  # Clignoter la LED 3 fois au démarrage
 print("\n\nInitialisation du module LoRa-E5...\n")
-configure_lora(868000000, 12, 125, 12, 15, 14)  # Configurer le module LoRa avec les paramètres souhaités
+configure_lora()  # Configurer le module LoRa avec les paramètres souhaités
 send_at_command("+TEST=RXLRPKT")  # Commencer la réception des paquets LoRa
 
 led.value(1)  # Rallumer la LED après l'initialisation
-- 
GitLab