Connects to Wifi from a fixed list of persisted credentials (up to 4 slots), and lets them be (re)configured at runtime through a BLE form built with GattForm. Capped at 4 rather than some rounder number: the whole slot list is one BLE GATT attribute, and ESP32's Bluedroid stack hard-caps attribute values at 600 bytes.
WifiSlot/mergeWifiSlot() (bundled in this same package) implement the
merge rules applied to each slot on a form submission. They have no
BLE/Preferences/WiFi dependency, so that part is covered by fast native unit
tests — see test/test_native.
#include <WifiManagerUnderGattForm.h>
WifiManagerUnderGattForm wifiManager;
void setup() {
wifiManager.setDeviceName("MyDevice")
.onConnected([](const String& ssid) { Serial.printf("Connected: %s\n", ssid.c_str()); })
.onConnectFailed([]() { Serial.println("Connect failed"); });
wifiManager.connect(); // tries every stored slot, blocking, up to timeoutMs
}
// Call these from wherever fits your app (a menu item, a button press, ...):
// wifiManager.startProvisioning(); // opens the BLE form to (re)configure slots
// wifiManager.stopProvisioning();
// wifiManager.clearCredentials(); // wipes every stored slotThis library ships its own platformio.ini (dev/test harness only — not used
by projects that depend on it):
# Fast unit tests (the fusion logic in mergeWifiSlot()), no hardware required
pio test -e native
# Persistence tests (Preferences/NVS) + _applySubmission, run on an actual ESP32 board
pio test -e esp32devCI runs pio test -e native on every push/PR (no hardware available in
CI, so esp32dev stays a local/manual check) — see
.github/workflows/tests.yml.
src/WifiManagerUnderGattForm.h/.cpp Public facade: provisioning, connect(), persistence, callbacks
src/WifiSlotMerge.h/.cpp WifiSlot + mergeWifiSlot(), hardware-independent
test/test_native/ Unit tests for mergeWifiSlot(), run on the host
test/test_embedded/ Integration tests (Preferences persistence), run on an ESP32 board