Files
MeshCore-Solo/src/helpers/esp32/ESPNOWRadio.h
T

56 lines
1.6 KiB
C++
Raw Normal View History

2025-03-24 21:16:00 +11:00
#pragma once
#include <Mesh.h>
class ESPNOWRadio : public mesh::Radio {
protected:
2026-03-30 04:25:08 +01:00
uint32_t n_recv, n_sent, n_recv_errors;
2025-03-24 21:16:00 +11:00
public:
2026-03-30 04:25:08 +01:00
ESPNOWRadio() { n_recv = n_sent = n_recv_errors = 0; }
2025-03-24 21:16:00 +11:00
uint32_t getRngSeed();
void setParams(float freq, float bw, uint8_t sf, uint8_t cr) {
// no-op
}
void powerOff() { /* no-op */ }
void init();
2025-03-24 21:16:00 +11:00
int recvRaw(uint8_t* bytes, int sz) override;
uint32_t getEstAirtimeFor(int len_bytes) override;
2025-05-12 17:26:44 +10:00
bool startSendRaw(const uint8_t* bytes, int len) override;
2025-03-24 21:16:00 +11:00
bool isSendComplete() override;
void onSendFinished() override;
bool isInRecvMode() const override;
2025-03-24 21:16:00 +11:00
uint32_t getPacketsRecv() const { return n_recv; }
uint32_t getPacketsSent() const { return n_sent; }
2026-03-30 04:25:08 +01:00
uint32_t getPacketsRecvErrors() const { return n_recv_errors; }
void resetStats() { n_recv = n_sent = n_recv_errors = 0; }
2025-05-13 18:12:58 +10:00
2025-03-24 21:16:00 +11:00
virtual float getLastRSSI() const override;
virtual float getLastSNR() const override;
float packetScore(float snr, int packet_len) override { return 0; }
2026-03-30 04:25:08 +01:00
/**
* These two functions do nothing for ESP-NOW, but are needed for the
* Radio interface.
*/
virtual void setRxBoostedGainMode(bool) { }
virtual bool getRxBoostedGainMode() const { return false; }
2025-03-25 01:26:46 +11:00
uint32_t intID();
2025-03-27 19:34:16 +11:00
void setTxPower(uint8_t dbm);
2025-03-24 21:16:00 +11:00
};
#if ESPNOW_DEBUG_LOGGING && ARDUINO
#include <Arduino.h>
#define ESPNOW_DEBUG_PRINT(F, ...) Serial.printf("ESP-Now: " F, ##__VA_ARGS__)
#define ESPNOW_DEBUG_PRINTLN(F, ...) Serial.printf("ESP-Now: " F "\n", ##__VA_ARGS__)
#else
#define ESPNOW_DEBUG_PRINT(...) {}
#define ESPNOW_DEBUG_PRINTLN(...) {}
#endif