10 #if defined(ARDUINO_ARCH_ESP8266)
11 #include <ESP8266WiFi.h>
12 #elif defined(ARDUINO_ARCH_ESP32)
20 static const int WIFIESPNOW_ALEN = 6;
23 static const int WIFIESPNOW_KEYLEN = 16;
26 static const int WIFIESPNOW_MAXMSGLEN = 250;
29 uint8_t
mac[WIFIESPNOW_ALEN];
77 hasPeer(
const uint8_t mac[WIFIESPNOW_ALEN])
const;
87 #if defined(ARDUINO_ARCH_ESP8266)
89 addPeer(
const uint8_t mac[WIFIESPNOW_ALEN],
int channel = 0,
const uint8_t key[WIFIESPNOW_KEYLEN] =
nullptr);
90 #elif defined(ARDUINO_ARCH_ESP32)
92 addPeer(
const uint8_t mac[WIFIESPNOW_ALEN],
int channel = 0,
const uint8_t key[WIFIESPNOW_KEYLEN] =
nullptr,
int netif = ESP_IF_WIFI_AP);
101 removePeer(
const uint8_t mac[WIFIESPNOW_ALEN]);
103 using RxCallback = void (*)(
const uint8_t mac[WIFIESPNOW_ALEN],
const uint8_t* buf,
size_t count,
void* arg);
122 send(
const uint8_t mac[WIFIESPNOW_ALEN],
const uint8_t* buf,
size_t count);
133 rx(
const uint8_t* mac,
const uint8_t* data, uint8_t len);
136 tx(
const uint8_t* mac, uint8_t status);
140 void* m_rxArg =
nullptr;
142 bool m_ready =
false;
WifiEspNowSendStatus
Result of send operation.
Definition: WifiEspNow.h:34
@ NONE
result unknown, send in progress
@ OK
unicast message acknowledged by peer; multicast message transmitted
WifiEspNowClass WifiEspNow
ESP-NOW API.
Definition: WifiEspNow.cpp:14
Definition: WifiEspNow.h:41
bool removePeer(const uint8_t mac[WIFIESPNOW_ALEN])
Remove a peer.
Definition: WifiEspNow.cpp:126
void end()
Stop ESP-NOW.
Definition: WifiEspNow.cpp:30
int listPeers(WifiEspNowPeerInfo *peers, int maxPeers) const
List current peers.
Definition: WifiEspNow.cpp:49
bool addPeer(const uint8_t mac[WIFIESPNOW_ALEN], int channel=0, const uint8_t key[WIFIESPNOW_KEYLEN]=nullptr, int netif=ESP_IF_WIFI_AP)
Add a peer or change peer channel.
Definition: WifiEspNow.cpp:101
void onReceive(RxCallback cb, void *arg)
Set receive callback.
Definition: WifiEspNow.cpp:131
bool setPrimaryKey(const uint8_t key[WIFIESPNOW_KEYLEN])
Set primary key, also known as KOK or PMK.
Definition: WifiEspNow.cpp:39
void(*)(const uint8_t mac[WIFIESPNOW_ALEN], const uint8_t *buf, size_t count, void *arg) RxCallback
Definition: WifiEspNow.h:103
bool begin()
Initialize ESP-NOW.
Definition: WifiEspNow.cpp:17
bool hasPeer(const uint8_t mac[WIFIESPNOW_ALEN]) const
Test whether peer exists.
Definition: WifiEspNow.cpp:74
bool send(const uint8_t mac[WIFIESPNOW_ALEN], const uint8_t *buf, size_t count)
Send a message.
Definition: WifiEspNow.cpp:137
WifiEspNowSendStatus getSendStatus() const
Retrieve status of last sent message.
Definition: WifiEspNow.h:126
Definition: WifiEspNow.h:28
uint8_t channel
Definition: WifiEspNow.h:30
uint8_t mac[WIFIESPNOW_ALEN]
Definition: WifiEspNow.h:29