Suffix provisioning AP SSID with device MAC to avoid collisions

Two frames on the same network would otherwise both advertise the same
ESPRESSO SSID during provisioning. Appends the last 3 bytes of the WiFi MAC
(read via esp_read_mac(), available before the WiFi driver starts) so each
device's softAP is uniquely named.
This commit is contained in:
2026-07-18 10:52:56 -04:00
parent de449d5973
commit 87c2eccfdf
2 changed files with 10 additions and 3 deletions
+4 -2
View File
@@ -1,10 +1,12 @@
menu "ESPresso Frame Configuration" menu "ESPresso Frame Configuration"
config ESP_AP_SSID config ESP_AP_SSID
string "Provisioning softAP SSID" string "Provisioning softAP SSID prefix"
default "ESPRESSO" default "ESPRESSO"
help help
SSID of the softAP the device brings up when it needs provisioning. SSID prefix of the softAP the device brings up when it needs
provisioning; the device appends "_XXXXXX" (last 3 bytes of its
WiFi MAC) so multiple frames never collide on the same SSID.
The password is generated randomly per device on first boot and The password is generated randomly per device on first boot and
shown on the e-ink panel both as a WiFi-join QR code and as shown on the e-ink panel both as a WiFi-join QR code and as
plaintext underneath it, so it can be typed in by hand on a plaintext underneath it, so it can be typed in by hand on a
+6 -1
View File
@@ -112,7 +112,12 @@ static void generate_ap_password(char *out, size_t out_size)
void ap_identity_get(char *ssid_out, size_t ssid_len, char *pass_out, size_t pass_len) void ap_identity_get(char *ssid_out, size_t ssid_len, char *pass_out, size_t pass_len)
{ {
snprintf(ssid_out, ssid_len, "%s", CONFIG_ESP_AP_SSID); /* Suffix with the last 3 bytes of the station MAC so two frames on the
* same network never advertise the same SSID. esp_read_mac() works
* before the WiFi driver is started. */
uint8_t mac[6];
ESP_ERROR_CHECK(esp_read_mac(mac, ESP_MAC_WIFI_STA));
snprintf(ssid_out, ssid_len, "%s_%02X%02X%02X", CONFIG_ESP_AP_SSID, mac[3], mac[4], mac[5]);
nvs_handle_t handle; nvs_handle_t handle;
ESP_ERROR_CHECK(nvs_open(NVS_NAMESPACE, NVS_READWRITE, &handle)); ESP_ERROR_CHECK(nvs_open(NVS_NAMESPACE, NVS_READWRITE, &handle));