Files
hexapod-robot/2026-current/remote/RadioLink.h
T
mangavalkandClaude Opus 5.5 91dac16fca Draft: shared protocol, remote firmware, project docs
Not yet verified on hardware.

- shared/HexapodProtocol: CmdPacket (now 20 bytes, adds remote_roll /
  remote_pitch), FLAG_* bits and radio settings as the single protocol
  definition; static payload size = sizeof(CmdPacket) on both radios.
- robot: use the shared protocol; vx = forward (harness w/x <-> q/e);
  InputMapper adds remote tilt on top of the right stick when
  FLAG_REMOTE_GYRO is set, and robot.ino no longer zeroes stick
  roll/pitch when it's off.
- remote (Teensy 4.1): Sticks (calibration, EEPROM), RemoteIMU,
  RemoteState (interlocks, link-loss disarm, smoothing), PacketBuilder,
  RadioLink, NextionUI, SerialConsole.
- CLAUDE.md, README.md, remote/README.md, remote/NEXTION.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 18:14:00 +02:00

23 lines
805 B
C++

#pragma once
#include <HexapodProtocol.h>
// 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
};