UART communication
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user