#pragma once #include // nRF24L01 transmitter. Uses hardware auto-ack to measure the link: the // robot's radio acks every packet it receives, so an ack = the robot heard us. class RadioLink { public: bool begin(); // false if the radio chip didn't respond bool send(const CmdPacket& p); // blocking, returns true if acked void update(uint32_t now_ms); // refreshes linkOk() bool present() const { return present_; } bool linkOk() const { return link_ok_; } uint8_t qualityPct() const; // acked share of the last 32 packets private: bool present_ = false; bool link_ok_ = false; uint32_t last_ack_ms_ = 0; bool ever_acked_ = false; uint32_t history_ = 0; // 1 bit per packet, newest in bit 0 };