# receptor.py
from transceptor import transceptor
import time
from transceptor1262_const import ERROR

print("[INFO] Modo recepción activado...")

while True:
    try:
        msg, err = transceptor.recibir(timeout_ms=15000)  # 15 segundos
        if msg:
            print(f"[RX] ✅ Recibido: {msg}")
        else:
            if err == -6:
                print("[RX] ⏳ Timeout: no se recibió nada.")
            else:
                print(f"[RX] ❌ Error: {ERROR.get(err, err)}")
    except Exception as e:
        print(f"[EXCEPCIÓN] {e}")
    time.sleep(0.1)