codex init
This commit is contained in:
24
OpticalChannelTester/Radio.h
Normal file
24
OpticalChannelTester/Radio.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <esp_now.h>
|
||||
#include "Protocol.h"
|
||||
|
||||
struct ReceivedPacket { uint8_t mac[6]; ProtocolPacket packet; };
|
||||
|
||||
class Radio {
|
||||
public:
|
||||
bool begin();
|
||||
void end();
|
||||
bool sendBroadcast(ProtocolPacket packet);
|
||||
bool sendTo(const uint8_t mac[6], ProtocolPacket packet);
|
||||
bool receive(ReceivedPacket &received);
|
||||
void flush();
|
||||
static void macText(const uint8_t mac[6], char *out, size_t size);
|
||||
private:
|
||||
static void onReceive(const esp_now_recv_info_t *info, const uint8_t *data, int length);
|
||||
bool ensurePeer(const uint8_t mac[6]);
|
||||
static Radio *instance_;
|
||||
QueueHandle_t queue_ = nullptr;
|
||||
bool active_ = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user