From 751f277fd117577fb5adc9bdce12e81e8e9c4152 Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Wed, 17 Nov 2021 12:10:40 +0800 Subject: [PATCH 1/4] fix WiFiDiagnostics Read bug for ESP32 platform --- .../ESP32/ConnectivityManagerImpl.cpp | 87 ---------- src/platform/ESP32/ConnectivityManagerImpl.h | 5 +- .../ESP32/ConnectivityManagerImpl_WiFi.cpp | 148 ++++++++++++++++++ 3 files changed, 152 insertions(+), 88 deletions(-) diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp index 7d0428121bcbfd..585fe53ff8bdfa 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp @@ -70,92 +70,5 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #endif } -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiSecurityType(uint8_t & securityType) -{ - securityType = 0; - wifi_ap_record_t ap_info; - esp_err_t err; - - err = esp_wifi_sta_get_ap_info(&ap_info); - if (err == ESP_OK) - { - securityType = ap_info.authmode; - } - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiChannelNumber(uint16_t & channelNumber) -{ - channelNumber = 0; - wifi_ap_record_t ap_info; - esp_err_t err; - - err = esp_wifi_sta_get_ap_info(&ap_info); - if (err == ESP_OK) - { - channelNumber = ap_info.primary; - } - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiRssi(int8_t & rssi) -{ - rssi = 0; - wifi_ap_record_t ap_info; - esp_err_t err; - - err = esp_wifi_sta_get_ap_info(&ap_info); - - if (err == ESP_OK) - { - rssi = ap_info.rssi; - } - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiBeaconLostCount(uint32_t & beaconLostCount) -{ - beaconLostCount = 0; - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) -{ - currentMaxRate = 0; - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) -{ - packetMulticastRxCount = 0; - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) -{ - packetMulticastTxCount = 0; - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) -{ - packetUnicastRxCount = 0; - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) -{ - packetUnicastTxCount = 0; - return CHIP_NO_ERROR; -} - -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiOverrunCount(uint64_t & overrunCount) -{ - overrunCount = 0; - return CHIP_NO_ERROR; -} -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI - } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index e1ffdb0529d0e4..0c5d4ac7f92215 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -113,7 +113,9 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void _OnWiFiScanDone(); void _OnWiFiStationProvisionChange(); + CHIP_ERROR _GetWiFiBssId(ByteSpan & BssId); CHIP_ERROR _GetWiFiSecurityType(uint8_t & securityType); + CHIP_ERROR _GetWiFiVersion(uint8_t & wifiVersion); CHIP_ERROR _GetWiFiChannelNumber(uint16_t & channelNumber); CHIP_ERROR _GetWiFiRssi(int8_t & rssi); CHIP_ERROR _GetWiFiBeaconLostCount(uint32_t & beaconLostCount); @@ -123,6 +125,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, CHIP_ERROR _GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount); CHIP_ERROR _GetWiFiCurrentMaxRate(uint64_t & currentMaxRate); CHIP_ERROR _GetWiFiOverrunCount(uint64_t & overrunCount); + CHIP_ERROR _ResetWiFiNetworkDiagnosticsCounts(); // ===== Private members reserved for use by this class only. @@ -134,6 +137,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, WiFiAPState mWiFiAPState; System::Clock::Timeout mWiFiStationReconnectInterval; System::Clock::Timeout mWiFiAPIdleTimeout; + uint8_t mWiFiMacAddress[kMaxHardwareAddrSize]; BitFlags mFlags; CHIP_ERROR InitWiFi(void); @@ -154,7 +158,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void OnStationIPv4AddressAvailable(const ip_event_got_ip_t & got_ip); void OnStationIPv4AddressLost(void); void OnIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip); - #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI // ===== Members for internal use by the following friends. diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index aa484a1b33ea80..6e53ef8fb3d8f3 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -994,6 +994,154 @@ void ConnectivityManagerImpl::OnIPv6AddressAvailable(const ip_event_got_ip6_t & PlatformMgr().PostEventOrDie(&event); } +uint8_t MapAuthModeToSecurityType(wifi_auth_mode_t authmode) +{ + switch (authmode) + { + case WIFI_AUTH_OPEN: + return 1; + case WIFI_AUTH_WEP: + return 2; + case WIFI_AUTH_WPA_PSK: + return 3; + case WIFI_AUTH_WPA2_PSK: + return 4; + case WIFI_AUTH_WPA3_PSK: + return 5; + default: + return 0; + } +} + +uint8_t GetWiFiVersionFromAPRecord(wifi_ap_record_t ap_info) +{ + if (ap_info.phy_11n) + return 3; + else if (ap_info.phy_11g) + return 2; + else if (ap_info.phy_11b) + return 1; + else + return 0; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiBssId(ByteSpan& BssId) +{ + wifi_ap_record_t ap_info; + esp_err_t err; + + err = esp_wifi_sta_get_ap_info(&ap_info); + if (err == ESP_OK) + { + memcpy(mWiFiMacAddress, ap_info.bssid, 6); + } + BssId = ByteSpan(mWiFiMacAddress, 6); + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiSecurityType(uint8_t & securityType) +{ + securityType = 0; + wifi_ap_record_t ap_info; + esp_err_t err; + + err = esp_wifi_sta_get_ap_info(&ap_info); + if (err == ESP_OK) + { + securityType = MapAuthModeToSecurityType(ap_info.authmode); + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiVersion(uint8_t & wifiVersion) +{ + wifiVersion = 0; + wifi_ap_record_t ap_info; + esp_err_t err; + err = esp_wifi_sta_get_ap_info(&ap_info); + if (err == ESP_OK) + { + wifiVersion = GetWiFiVersionFromAPRecord(ap_info); + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiChannelNumber(uint16_t & channelNumber) +{ + channelNumber = 0; + wifi_ap_record_t ap_info; + esp_err_t err; + + err = esp_wifi_sta_get_ap_info(&ap_info); + if (err == ESP_OK) + { + channelNumber = ap_info.primary; + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiRssi(int8_t & rssi) +{ + rssi = 0; + wifi_ap_record_t ap_info; + esp_err_t err; + + err = esp_wifi_sta_get_ap_info(&ap_info); + + if (err == ESP_OK) + { + rssi = ap_info.rssi; + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiBeaconLostCount(uint32_t & beaconLostCount) +{ + beaconLostCount = 0; + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) +{ + currentMaxRate = 0; + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) +{ + packetMulticastRxCount = 0; + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) +{ + packetMulticastTxCount = 0; + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) +{ + packetUnicastRxCount = 0; + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) +{ + packetUnicastTxCount = 0; + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiOverrunCount(uint64_t & overrunCount) +{ + overrunCount = 0; + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::_ResetWiFiNetworkDiagnosticsCounts() +{ + return CHIP_NO_ERROR; +} + } // namespace DeviceLayer } // namespace chip From 105fbbd24d515de43e11147c9e1dcb55b73d769f Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Wed, 17 Nov 2021 16:00:36 +0800 Subject: [PATCH 2/4] Add GetNetworkInterface and ReleaseNetworkInterface for ESP32 platform --- .../ESP32/ConnectivityManagerImpl.cpp | 58 +++++++++++++++++++ src/platform/ESP32/ConnectivityManagerImpl.h | 2 + 2 files changed, 60 insertions(+) diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp index 585fe53ff8bdfa..6512cefaa03e07 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp @@ -42,6 +42,7 @@ using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::System; using namespace ::chip::TLV; +using namespace ::chip::app::Clusters::GeneralDiagnostics; namespace chip { namespace DeviceLayer { @@ -70,5 +71,62 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #endif } +static InterfaceType GetInterfaceType(const char* if_desc) +{ + if (strncmp(if_desc, "ap", strnlen(if_desc, 2)) == 0 || strncmp(if_desc, "sta", strnlen(if_desc, 3)) == 0) + return InterfaceType::EMBER_ZCL_INTERFACE_TYPE_WI_FI; + if (strncmp(if_desc, "openthread", strnlen(if_desc, 10)) == 0) + return InterfaceType::EMBER_ZCL_INTERFACE_TYPE_THREAD; + if (strncmp(if_desc, "eth", strnlen(if_desc, 3)) == 0) + return InterfaceType::EMBER_ZCL_INTERFACE_TYPE_ETHERNET; + return InterfaceType::EMBER_ZCL_INTERFACE_TYPE_UNSPECIFIED; +} + +CHIP_ERROR ConnectivityManagerImpl::_GetNetworkInterfaces(NetworkInterface ** netifpp) +{ + esp_netif_t * netif = esp_netif_next(NULL); + NetworkInterface * head = NULL; + if (netif == NULL) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + } + else + { + for (esp_netif_t * ifa = netif; ifa != NULL; ifa = esp_netif_next(ifa)) + { + NetworkInterface * ifp = new NetworkInterface(); + strncpy(ifp->Name, esp_netif_get_ifkey(ifa), Inet::InterfaceId::kMaxIfNameLength); + ifp->Name[Inet::InterfaceId::kMaxIfNameLength - 1] = '\0'; + ifp->name = CharSpan(ifp->Name, strlen(ifp->Name)); + ifp->fabricConnected = true; + ifp->type = GetInterfaceType(esp_netif_get_desc(ifa)); + ifp->offPremiseServicesReachableIPv4 = false; + ifp->offPremiseServicesReachableIPv6 = false; + if (esp_netif_get_mac(ifa, ifp->MacAddress) != ESP_OK) + { + ChipLogError(DeviceLayer, "Failed to get network hardware address"); + } + else + { + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); + } + ifp->Next = head; + head = ifp; + } + } + *netifpp = head; + return CHIP_NO_ERROR; +} + +void ConnectivityManagerImpl::_ReleaseNetworkInterfaces(NetworkInterface * netifp) +{ + while (netifp) + { + NetworkInterface * del = netifp; + netifp = netifp->Next; + delete del; + } +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index 0c5d4ac7f92215..ed31629427dc67 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -86,6 +86,8 @@ class ConnectivityManagerImpl final : public ConnectivityManager, CHIP_ERROR _Init(void); void _OnPlatformEvent(const ChipDeviceEvent * event); + CHIP_ERROR _GetNetworkInterfaces(NetworkInterface ** netifpp); + void _ReleaseNetworkInterfaces(NetworkInterface * netifp); #if CHIP_DEVICE_CONFIG_ENABLE_WIFI using Flags = GenericConnectivityManagerImpl_WiFi::ConnectivityFlags; // ===== Members that implement the ConnectivityManager abstract interface. From 3a4f529fac8b408576fa2cf75d8a3040f8e15d8f Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Wed, 17 Nov 2021 20:19:06 +0800 Subject: [PATCH 3/4] fix identifytime does't decrease on ESP platform --- .../esp32/main/DeviceCallbacks.cpp | 79 ++++++++++--------- .../esp32/main/include/DeviceCallbacks.h | 2 - .../all-clusters-app/esp32/sdkconfig.defaults | 1 + 3 files changed, 44 insertions(+), 38 deletions(-) diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index 6ec297cfb51f05..f85e3acecca4d7 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -35,6 +35,7 @@ #include "route_hook/esp_route_hook.h" #include #include +#include #include #include #include @@ -49,9 +50,50 @@ using namespace ::chip::Inet; using namespace ::chip::System; using namespace ::chip::DeviceLayer; -uint32_t identifyTimerCount; constexpr uint32_t kIdentifyTimerDelayMS = 250; +void OnIdentifyTriggerEffect(Identify * identify) +{ + switch (identify->mCurrentEffectIdentifier) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + statusLED1.Blink(kIdentifyTimerDelayMS * 2); + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + break; + } + return; +} + +Identify gIdentify0 = { + chip::EndpointId{ 0 }, + [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); }, + [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); }, + EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, + OnIdentifyTriggerEffect, +}; + +Identify gIdentify1 = { + chip::EndpointId{ 1 }, + [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); }, + [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); }, + EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, + OnIdentifyTriggerEffect, +}; + + + void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) { switch (event->Type) @@ -108,10 +150,6 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster OnOnOffPostAttributeChangeCallback(endpointId, attributeId, value); break; - case ZCL_IDENTIFY_CLUSTER_ID: - OnIdentifyPostAttributeChangeCallback(endpointId, attributeId, value); - break; - case ZCL_LEVEL_CONTROL_CLUSTER_ID: OnLevelControlAttributeChangeCallback(endpointId, attributeId, value); break; @@ -218,37 +256,6 @@ void DeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpointI } #endif -void IdentifyTimerHandler(Layer * systemLayer, void * appState) -{ - statusLED1.Animate(); - - if (identifyTimerCount) - { - systemLayer->StartTimer(Clock::Milliseconds32(kIdentifyTimerDelayMS), IdentifyTimerHandler, appState); - // Decrement the timer count. - identifyTimerCount--; - } -} - -void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) -{ - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); - VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); - - statusLED1.Blink(kIdentifyTimerDelayMS * 2); - - // timerCount represents the number of callback executions before we stop the timer. - // value is expressed in seconds and the timer is fired every 250ms, so just multiply value by 4. - // Also, we want timerCount to be odd number, so the ligth state ends in the same state it starts. - identifyTimerCount = (*value) * 4; - - DeviceLayer::SystemLayer().CancelTimer(IdentifyTimerHandler, this); - DeviceLayer::SystemLayer().StartTimer(Clock::Milliseconds32(kIdentifyTimerDelayMS), IdentifyTimerHandler, this); - -exit: - return; -} - bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::Command * commandObj) { emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); diff --git a/examples/all-clusters-app/esp32/main/include/DeviceCallbacks.h b/examples/all-clusters-app/esp32/main/include/DeviceCallbacks.h index c4549e6d3a938d..91cfcba3936eea 100644 --- a/examples/all-clusters-app/esp32/main/include/DeviceCallbacks.h +++ b/examples/all-clusters-app/esp32/main/include/DeviceCallbacks.h @@ -45,7 +45,5 @@ class DeviceCallbacks : public chip::DeviceManager::CHIPDeviceManagerCallbacks #if CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM void OnColorControlAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); #endif - void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); - bool mEndpointOnOffState[2]; }; diff --git a/examples/all-clusters-app/esp32/sdkconfig.defaults b/examples/all-clusters-app/esp32/sdkconfig.defaults index 8cb1093fbfb606..3da9d42e2bc2f3 100644 --- a/examples/all-clusters-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig.defaults @@ -41,6 +41,7 @@ CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" # Vendor and product id CONFIG_DEVICE_VENDOR_ID=0x235A CONFIG_DEVICE_PRODUCT_ID=0x4541 +CONFIG_DEVICE_FIRMWARE_REVISION="prerelease" #enable debug shell CONFIG_ENABLE_CHIP_SHELL=y From 21abaf251eaa5bb2550a211b2d15debf7fa652c1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 22 Nov 2021 07:37:22 +0000 Subject: [PATCH 4/4] Restyled by clang-format --- .../esp32/main/DeviceCallbacks.cpp | 4 +--- src/platform/ESP32/ConnectivityManagerImpl.cpp | 16 ++++++++-------- .../ESP32/ConnectivityManagerImpl_WiFi.cpp | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index f85e3acecca4d7..edccd2b899e960 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -35,8 +35,8 @@ #include "route_hook/esp_route_hook.h" #include #include -#include #include +#include #include #include #include @@ -92,8 +92,6 @@ Identify gIdentify1 = { OnIdentifyTriggerEffect, }; - - void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) { switch (event->Type) diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp index 6512cefaa03e07..6c8e8ee3aeacc5 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp @@ -71,7 +71,7 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #endif } -static InterfaceType GetInterfaceType(const char* if_desc) +static InterfaceType GetInterfaceType(const char * if_desc) { if (strncmp(if_desc, "ap", strnlen(if_desc, 2)) == 0 || strncmp(if_desc, "sta", strnlen(if_desc, 3)) == 0) return InterfaceType::EMBER_ZCL_INTERFACE_TYPE_WI_FI; @@ -84,7 +84,7 @@ static InterfaceType GetInterfaceType(const char* if_desc) CHIP_ERROR ConnectivityManagerImpl::_GetNetworkInterfaces(NetworkInterface ** netifpp) { - esp_netif_t * netif = esp_netif_next(NULL); + esp_netif_t * netif = esp_netif_next(NULL); NetworkInterface * head = NULL; if (netif == NULL) { @@ -92,16 +92,16 @@ CHIP_ERROR ConnectivityManagerImpl::_GetNetworkInterfaces(NetworkInterface ** ne } else { - for (esp_netif_t * ifa = netif; ifa != NULL; ifa = esp_netif_next(ifa)) + for (esp_netif_t * ifa = netif; ifa != NULL; ifa = esp_netif_next(ifa)) { NetworkInterface * ifp = new NetworkInterface(); strncpy(ifp->Name, esp_netif_get_ifkey(ifa), Inet::InterfaceId::kMaxIfNameLength); ifp->Name[Inet::InterfaceId::kMaxIfNameLength - 1] = '\0'; - ifp->name = CharSpan(ifp->Name, strlen(ifp->Name)); - ifp->fabricConnected = true; - ifp->type = GetInterfaceType(esp_netif_get_desc(ifa)); - ifp->offPremiseServicesReachableIPv4 = false; - ifp->offPremiseServicesReachableIPv6 = false; + ifp->name = CharSpan(ifp->Name, strlen(ifp->Name)); + ifp->fabricConnected = true; + ifp->type = GetInterfaceType(esp_netif_get_desc(ifa)); + ifp->offPremiseServicesReachableIPv4 = false; + ifp->offPremiseServicesReachableIPv6 = false; if (esp_netif_get_mac(ifa, ifp->MacAddress) != ESP_OK) { ChipLogError(DeviceLayer, "Failed to get network hardware address"); diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index 6e53ef8fb3d8f3..6e976369a2289a 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -1025,7 +1025,7 @@ uint8_t GetWiFiVersionFromAPRecord(wifi_ap_record_t ap_info) return 0; } -CHIP_ERROR ConnectivityManagerImpl::_GetWiFiBssId(ByteSpan& BssId) +CHIP_ERROR ConnectivityManagerImpl::_GetWiFiBssId(ByteSpan & BssId) { wifi_ap_record_t ap_info; esp_err_t err;