terseCRSF vendorizzata: rimosse initialise/sbus_initialise/readCrsfFrame/ decodeRC/printPWM/prepSBUS/bytesToPWM/pwmToBytes/sendSBUS e i membri/buffer SBUS-PWM (sb_bytes, pwm_val, crsf_port, sbus_port, RC_BUILD/SBUS machinery). Usiamo solo decodeTelemetry: mantenuti i decoder + helper (bytes2*, wrap360, crc8_dvb_s2[_sbuf_accum] usata dalla patch CRC, printByte/printBytes). ~283 righe in meno, nessun riferimento pendente (verificato con grep su 01/02/03). EspNowCrsf: rimosso sendRaw() e il peer broadcast in begin() (uplink sperimentale morto, il backpack e' downlink-only). Ora RX-only pulito. main.cpp: commento "MAVLink v1" -> "v2" (la lib emette v2). DA VERIFICARE A BANCO con un build (qui non compilabile). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.3 KiB
C++
37 lines
1.3 KiB
C++
// ============================================================
|
|
// EspNowCrsf - ricezione di frame CRSF trasportati su ESP-NOW
|
|
// dal TX Backpack ExpressLRS.
|
|
//
|
|
// - begin(uid): imposta WiFi STA, MAC=UID, canale 1, ESP-NOW.
|
|
// - poll(): estrae il prossimo frame CRSF grezzo ricevuto.
|
|
//
|
|
// Il frame CRSF restituito inizia al sync byte (0xC8/0xEA):
|
|
// [0]=sync [1]=len [2]=type [3..]=payload [..]=crc
|
|
// ============================================================
|
|
#pragma once
|
|
#include <Arduino.h>
|
|
|
|
namespace EspNowCrsf {
|
|
|
|
// Inizializza radio + ESP-NOW. uid = 6 byte dalla bind phrase.
|
|
void begin(const uint8_t uid[6]);
|
|
|
|
// Estrae un frame dal ring buffer. Ritorna true e riempie out/outLen
|
|
// se c'era un frame. maxLen = dimensione del buffer out.
|
|
bool poll(uint8_t* out, uint16_t* outLen, uint16_t maxLen);
|
|
|
|
// Statistiche
|
|
uint32_t framesReceived();
|
|
uint32_t framesDropped();
|
|
|
|
#ifdef UNIT_TEST
|
|
// Hook di test (definita solo in build di test, PlatformIO imposta
|
|
// UNIT_TEST automaticamente per `pio test`: zero impatto sul firmware
|
|
// reale). Richiama l'onRecv interno senza inizializzare WiFi/ESP-NOW,
|
|
// per esercitare ring buffer + filtro keep-alive in isolamento.
|
|
void test_injectRaw(const uint8_t* data, uint16_t len);
|
|
void test_reset();
|
|
#endif
|
|
|
|
} // namespace EspNowCrsf
|