ESP-NOW utility library for automatic pairing with ESP32 SOCs.
The pairing process is simple and fast, and does not require prior knowledge or hardcoding of peer details.
Note: this library assumes a peapod contains only two peas.
- Simple pairing between two ESP32s
- Callbacks for pairing and transmission operations
- Persistent storage of pairing data
- No need to know peer MAC addresses beforehand
- No required designation of server/client roles
Two ESP32s can be flashed with the following program. Once they are paired, the
repeated message "Hello there!" can be observed with a UART/serial monitor.
#include "peapod/PeaPod.h"
#include <freertos/FreeRTOS.h>
#include <string>
const char *message = "Hello there!";
class Callbacks: pp::PeaPodCallbacks {
virtual void on_receive(const uint8_t* rx_data, std::size_t data_len) override {
std::string rx_str((const char*)rx_data, data_len);
Serial.println(rx_str.c_str());
}
};
void setup() {
Serial.begin();
PeaPod.begin();
PeaPod.set_callbacks(new Callbacks());
if (!PeaPod.is_paired()) {
Serial.println("Pairing now");
PeaPod.pairing()->start();
}
}
void loop() {
vTaskDelay(pdMS_TO_TICKS(1000));
if (!PeaPod.is_paired())
continue;
PeaPod.pea().send(message);
}