// ============================================================ // EspNowCrsf - ricezione (e invio sperimentale) 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. // - sendRaw(): invio ESP-NOW (uplink) -- vedi nota uplink in // mode_msp.cpp: NON raggiunge l'FC con ELRS stock. // // Il frame CRSF restituito inizia al sync byte (0xC8/0xEA): // [0]=sync [1]=len [2]=type [3..]=payload [..]=crc // ============================================================ #pragma once #include 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(); // Invio ESP-NOW grezzo verso il peer (broadcast). Sperimentale. // Ritorna true se esp_now_send ha accettato il pacchetto. bool sendRaw(const uint8_t* data, uint16_t len); #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