UART communication
Build, push image, and notify Watchtower / build-image (push) Successful in 2m4s
Build, push image, and notify Watchtower / notify (push) Successful in 1m54s

This commit is contained in:
2026-07-18 17:01:25 +02:00
parent 987067aa1e
commit 4366abba69
7 changed files with 161 additions and 35 deletions
+17 -5
View File
@@ -1,8 +1,6 @@
import _thread
from machine import Pin
from shared import get_lora
from shared import deviceTypes
from shared import config
from shared import get_lora, get_uart, deviceTypes, config
import time
# --- Configuration Matérielle ---
@@ -48,10 +46,24 @@ def heartbeat_loop():
print("ESP32 : Pas de réponse de l'orchestrateur (Le RPI est-il éteint ?)")
time.sleep(config.HEARTBEAT_INTERVAL)
# UART
uart_device = get_uart(uart_id=1, tx_pin=46, rx_pin=45)
# Lancer la boucle de heartbeat dans un thread séparé
_thread.start_new_thread(heartbeat_loop, ())
# --- MAIN APPLICATION THREAD ---
print("[Main] Main execution path active.")
while True:
# Fait rien pour l'instant
time.sleep(1)
# 1. Listen for incoming UART serial packets from the WROOM board
while uart_device.any():
command = uart_device.read()
print(f"[Main] Received command from WiFi Board: {command}")
uart_device.send(f"Hello from esp-32 lora ID {DEVICE_ID}")
# 2. Send local metrics over the wire to the WiFi board every few seconds
# uart_device.send("Data Pack: LoRa Link RSSI -72dBm")
time.sleep_ms(200)