Files
hexapod-robot/2026-current/robot/Comms.cpp
T
mangavalkandClaude Opus 5.5 ad77b06c36 Initial import: robot firmware + PlatformIO two-env scaffold
Robot-side firmware (Teensy 4.0) imported unchanged as extracted.
platformio.ini defines [env:robot] (teensy40) and [env:remote]
(teensy41); scripts/select_src_dir.py points each env at its own
sketch folder so robot/ and remote/ stay Arduino-style sketches.

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

29 lines
697 B
C++

#include "Comms.h"
#include "Config.h"
#include <RF24.h>
#include <SPI.h>
static RF24 radio(RADIO_CE_PIN, RADIO_CSN_PIN);
bool Comms::begin() {
radio_present_ = radio.begin();
if (radio_present_) {
radio.openReadingPipe(1, RADIO_ADDRESS);
radio.setPALevel(RF24_PA_LOW);
radio.setDataRate(RF24_250KBPS);
radio.setChannel(96); // pick one clear of your local Wi-Fi
radio.startListening();
}
return radio_present_;
}
void Comms::update() {
if (radio_present_) {
while (radio.available()) {
radio.read(&packet_, sizeof(packet_));
last_rx_ms_ = millis();
}
}
link_ok_ = (millis() - last_rx_ms_) < (uint32_t)(LINK_TIMEOUT_SEC * 1000);
}