// src/hardware/uart.h
#pragma once
#include "mbed.h"
#include <cstddef>

constexpr size_t UART_BUFFER_SIZE = 64;
constexpr auto MESSAGE_DISPLAY_DURATION = 1s;

enum class UartEvent {
  NoChange = 0,      // No new data
  MessageUpdate = 1, // Message changed (received or expired)
  Triggered = 2      // New message received (trigger action)
};

class UartReader {
private:
  BufferedSerial &serial_port;
  
  char rx_buffer[UART_BUFFER_SIZE];
  char message[UART_BUFFER_SIZE];
  bool message_active = false;
  
  Timer msg_timer;
  bool timer_started = false;

public:
  UartReader(BufferedSerial &serial);
  
  // Poll for UART events
  UartEvent poll();
  
  // Get current message (nullptr if no active message)
  const char* get_message() const;
  bool has_message() const { return message_active; }
};
