From 39fe904249df9168c874e4cb1012cc117870c1e8 Mon Sep 17 00:00:00 2001 From: Daniel Bahrdt Date: Mon, 19 Jun 2023 13:16:29 +0200 Subject: [PATCH] Hack: Use serial number to generate wifi api This commit changes the SSID of the Wifi AP to PREFIX- in accordance with Eltako wifi ap. This change is likely not compatible with Matter. However we do not support commissioning using Wifi anyway. Yet we need wifi to be available to configure the device by other means. In the future we need to find a way to either enable the ap without using Matter functions or provide proper commissioning over wifi. The latter is likely the better way. --- src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index 2eb2e1b3ad11e0..e0b60b15cfaf3c 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -933,11 +933,13 @@ CHIP_ERROR ConnectivityManagerImpl::ConfigureWiFiAP() uint16_t vendorId; uint16_t productId; + char serial[sizeof(wifiConfig.ap.ssid)-sizeof(CHIP_DEVICE_CONFIG_WIFI_AP_SSID_PREFIX)]; + memset(serial, 0, sizeof(serial)); ReturnErrorOnFailure(GetDeviceInstanceInfoProvider()->GetVendorId(vendorId)); ReturnErrorOnFailure(GetDeviceInstanceInfoProvider()->GetProductId(productId)); + ReturnErrorOnFailure(GetDeviceInstanceInfoProvider()->GetSerialNumber(serial, sizeof(serial))); - snprintf((char *) wifiConfig.ap.ssid, sizeof(wifiConfig.ap.ssid), "%s%03X-%04X-%04X", CHIP_DEVICE_CONFIG_WIFI_AP_SSID_PREFIX, - discriminator, vendorId, productId); + snprintf((char *) wifiConfig.ap.ssid, sizeof(wifiConfig.ap.ssid), "%s-%s", CHIP_DEVICE_CONFIG_WIFI_AP_SSID_PREFIX, serial); wifiConfig.ap.channel = CHIP_DEVICE_CONFIG_WIFI_AP_CHANNEL; wifiConfig.ap.authmode = WIFI_AUTH_OPEN; wifiConfig.ap.max_connection = CHIP_DEVICE_CONFIG_WIFI_AP_MAX_STATIONS;