#include <WifiEspNow.h>
|
| using | RxCallback = void(*)(const uint8_t mac[WIFIESPNOW_ALEN], const uint8_t *buf, size_t count, void *arg) |
| |
|
| bool | begin () |
| | Initialize ESP-NOW.
|
| |
| void | end () |
| | Stop ESP-NOW.
|
| |
| bool | setPrimaryKey (const uint8_t key[WIFIESPNOW_KEYLEN]) |
| | Set primary key, also known as KOK or PMK.
|
| |
| int | listPeers (WifiEspNowPeerInfo *peers, int maxPeers) const |
| | List current peers.
|
| |
| bool | hasPeer (const uint8_t mac[WIFIESPNOW_ALEN]) const |
| | Test whether peer exists.
|
| |
| 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.
|
| |
| bool | removePeer (const uint8_t mac[WIFIESPNOW_ALEN]) |
| | Remove a peer.
|
| |
| void | onReceive (RxCallback cb, void *arg) |
| | Set receive callback.
|
| |
| bool | send (const uint8_t mac[WIFIESPNOW_ALEN], const uint8_t *buf, size_t count) |
| | Send a message.
|
| |
| WifiEspNowSendStatus | getSendStatus () const |
| | Retrieve status of last sent message.
|
| |
◆ RxCallback
◆ addPeer()
| bool WifiEspNowClass::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.
- Parameters
-
| mac | peer MAC address. |
| channel | peer channel, 0 for current channel. |
| key | encryption key, nullptr to disable encryption. |
| netif | (ESP32 only) WiFi interface. |
- Returns
- whether success.
◆ begin()
| bool WifiEspNowClass::begin |
( |
| ) |
|
Initialize ESP-NOW.
- Returns
- whether success.
◆ end()
| void WifiEspNowClass::end |
( |
| ) |
|
◆ getSendStatus()
Retrieve status of last sent message.
◆ hasPeer()
| bool WifiEspNowClass::hasPeer |
( |
const uint8_t |
mac[WIFIESPNOW_ALEN] | ) |
const |
Test whether peer exists.
- Parameters
-
- Returns
- whether peer exists.
◆ listPeers()
List current peers.
- Parameters
-
| [out] | peers | buffer for peer information. |
| maxPeers | buffer size. |
- Returns
- total number of peers,
std::min(retval,maxPeers) is written to peers .
◆ onReceive()
| void WifiEspNowClass::onReceive |
( |
RxCallback |
cb, |
|
|
void * |
arg |
|
) |
| |
Set receive callback.
- Parameters
-
| cb | the callback. |
| arg | an arbitrary argument passed to the callback. |
- Note
- Only one callback is allowed; this replaces any previous callback.
◆ removePeer()
| bool WifiEspNowClass::removePeer |
( |
const uint8_t |
mac[WIFIESPNOW_ALEN] | ) |
|
Remove a peer.
- Parameters
-
- Returns
- whether success.
◆ send()
| bool WifiEspNowClass::send |
( |
const uint8_t |
mac[WIFIESPNOW_ALEN], |
|
|
const uint8_t * |
buf, |
|
|
size_t |
count |
|
) |
| |
Send a message.
- Parameters
-
| mac | destination MAC address, nullptr for all peers. |
| buf | payload. |
| count | payload size, must not exceed WIFIESPNOW_MAXMSGLEN . |
- Returns
- whether success (message queued for transmission).
◆ setPrimaryKey()
| bool WifiEspNowClass::setPrimaryKey |
( |
const uint8_t |
key[WIFIESPNOW_KEYLEN] | ) |
|
Set primary key, also known as KOK or PMK.
- Parameters
-
| key | primary encryption key. |
- Returns
- whether success.
The documentation for this class was generated from the following files: