From 8318fff78c4ce0ef1ce3e52f6bd084f7c83d7c4b Mon Sep 17 00:00:00 2001
From: CARNEIRO--GILLET Alexandre
 <alexandre.carneiro-gillet@imt-atlantique.net>
Date: Tue, 11 Mar 2025 11:34:29 +0100
Subject: [PATCH] =?UTF-8?q?ajout=20test=5Frecept=5Floramac,=20jsp=20si=20?=
 =?UTF-8?q?=C3=A7a=20marche?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 GW-custom/test_envoi_senscom.py  |  2 ++
 GW-custom/test_recept_loramac.py | 47 ++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
 create mode 100644 GW-custom/test_recept_loramac.py

diff --git a/GW-custom/test_envoi_senscom.py b/GW-custom/test_envoi_senscom.py
index 475b7bd..72b5cd9 100644
--- a/GW-custom/test_envoi_senscom.py
+++ b/GW-custom/test_envoi_senscom.py
@@ -2,6 +2,8 @@ import json
 
 import requests
 
+## Envoi des données sur sensor community
+
 url = "https://api.sensor.community/v1/push-sensor-data/"
 headers = {
     "Content-Type": "application/json",
diff --git a/GW-custom/test_recept_loramac.py b/GW-custom/test_recept_loramac.py
new file mode 100644
index 0000000..d53b2c9
--- /dev/null
+++ b/GW-custom/test_recept_loramac.py
@@ -0,0 +1,47 @@
+import time
+
+from machine import UART, Pin
+
+# Configuration UART pour le module LoRa E5
+uart = UART(1, baudrate=9600, tx=17, rx=16)
+
+# Configuration de la broche pour le module LoRa E5
+reset_pin = Pin(18, Pin.OUT)
+reset_pin.value(1)
+
+def reset_lora():
+    reset_pin.value(0)
+    time.sleep(0.1)
+    reset_pin.value(1)
+    time.sleep(0.1)
+
+def send_command(command, delay=0.5):
+    uart.write(command + '\r\n')
+    time.sleep(delay)
+    response = uart.read()
+    if response:
+        print(response.decode('utf-8'))
+
+def setup_lora():
+    reset_lora()
+    send_command('AT+MODE=LWOTAA')
+    send_command('AT+DR=EU868')
+    send_command('AT+KEY=APPKEY,"YOUR_APP_KEY"')
+    send_command('AT+ID=DevAddr,"YOUR_DEV_ADDR"')
+    send_command('AT+ID=DevEui,"YOUR_DEV_EUI"')
+    send_command('AT+ID=AppEui,"YOUR_APP_EUI"')
+    send_command('AT+JOIN')
+
+def receive_lora():
+    while True:
+        if uart.any():
+            response = uart.read()
+            if response:
+                print("Received:", response.decode('utf-8'))
+        time.sleep(1)
+
+# Initialisation du module LoRa
+setup_lora()
+
+# Boucle de réception des messages
+receive_lora()
\ No newline at end of file
-- 
GitLab