2026-09-28 15:36:37 +02:00
|
|
|
#pragma once
|
|
|
|
|
#include <Arduino.h>
|
2026-09-28 18:14:00 +02:00
|
|
|
#include <HexapodProtocol.h> // CmdPacket + FLAG_* + radio settings, shared with the remote (shared/)
|
2026-09-28 15:36:37 +02:00
|
|
|
|
|
|
|
|
class Comms {
|
|
|
|
|
public:
|
|
|
|
|
bool begin();
|
|
|
|
|
void update(); // call every loop; polls the radio if present
|
|
|
|
|
bool linkOk() const { return link_ok_; }
|
|
|
|
|
const CmdPacket& latest() const { return packet_; }
|
|
|
|
|
|
|
|
|
|
// Lets the serial test harness (or, later, real radio) inject a packet directly.
|
|
|
|
|
void injectPacket(const CmdPacket& p) { packet_ = p; last_rx_ms_ = millis(); }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CmdPacket packet_;
|
|
|
|
|
uint32_t last_rx_ms_ = 0;
|
|
|
|
|
bool link_ok_ = false;
|
|
|
|
|
bool radio_present_ = false;
|
|
|
|
|
};
|