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
+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)
{
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;
ESP_ERROR_CHECK(nvs_open(NVS_NAMESPACE, NVS_READWRITE, &handle));