From 6ee1798e1ded883a4c84a1aa17e74de08fab8801 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 23 May 2022 02:17:11 +0000 Subject: [PATCH] Restyled by clang-format --- .../ameba/main/DeviceCallbacks.cpp | 1 - .../ameba/main/DeviceCallbacks.cpp | 1 - examples/platform/ameba/ota/OTAHelper.cpp | 2 +- src/platform/Ameba/AmebaConfig.cpp | 38 +++++++++---------- src/platform/Ameba/AmebaUtils.cpp | 31 +++++++-------- src/platform/Ameba/AmebaUtils.h | 4 +- .../Ameba/ConnectivityManagerImpl.cpp | 4 +- .../Ameba/NetworkCommissioningWiFiDriver.cpp | 10 ++--- 8 files changed, 45 insertions(+), 46 deletions(-) diff --git a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp index 9214016b6ad6c9..d2d8b8da396bc3 100644 --- a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp @@ -61,7 +61,6 @@ void InitOTARequestorHandler(System::Layer * systemLayer, void * appState) } #endif - void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) { switch (event->Type) diff --git a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp index b78d05eb95b7ff..f8d602abc0dbd3 100644 --- a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp @@ -63,7 +63,6 @@ void InitOTARequestorHandler(System::Layer * systemLayer, void * appState) } #endif - void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) { switch (event->Type) diff --git a/examples/platform/ameba/ota/OTAHelper.cpp b/examples/platform/ameba/ota/OTAHelper.cpp index 1d1e804849a866..c8d5446344ea4f 100644 --- a/examples/platform/ameba/ota/OTAHelper.cpp +++ b/examples/platform/ameba/ota/OTAHelper.cpp @@ -35,7 +35,7 @@ BDXDownloader gDownloader; AmebaOTAImageProcessor gImageProcessor; chip::ota::DefaultOTARequestorUserConsent gUserConsentProvider; static chip::ota::UserConsentState gUserConsentState = chip::ota::UserConsentState::kGranted; -} +} // namespace extern "C" void amebaQueryImageCmdHandler() { diff --git a/src/platform/Ameba/AmebaConfig.cpp b/src/platform/Ameba/AmebaConfig.cpp index 8b4fc4a52f71fb..9ed767a4262e17 100644 --- a/src/platform/Ameba/AmebaConfig.cpp +++ b/src/platform/Ameba/AmebaConfig.cpp @@ -42,25 +42,25 @@ namespace Internal { // *** CAUTION ***: Changing the names or namespaces of these values will *break* existing devices. // NVS namespaces used to store device configuration information. -const char AmebaConfig::kConfigNamespace_ChipFactory[] = "chip-factory"; -const char AmebaConfig::kConfigNamespace_ChipConfig[] = "chip-config"; -const char AmebaConfig::kConfigNamespace_ChipCounters[] = "chip-counters"; -const char AmebaConfig::kConfigNamespace_ChipFabric1[] = "chip-fabric-1"; -const char AmebaConfig::kConfigNamespace_ChipFabric2[] = "chip-fabric-2"; -const char AmebaConfig::kConfigNamespace_ChipFabric3[] = "chip-fabric-3"; -const char AmebaConfig::kConfigNamespace_ChipFabric4[] = "chip-fabric-4"; -const char AmebaConfig::kConfigNamespace_ChipFabric5[] = "chip-fabric-5"; -const char AmebaConfig::kConfigNamespace_ChipACL[] = "chip-acl"; -const char AmebaConfig::kConfigNamespace_ChipGroupMessageCounters[] = "chip-groupmsgcounters"; -const char AmebaConfig::kConfigNamespace_ChipAttributes[] = "chip-attributes"; -const char AmebaConfig::kConfigNamespace_ChipBindingTable[] = "chip-bindingtable"; -const char AmebaConfig::kConfigNamespace_ChipOTA[] = "chip-ota"; -const char AmebaConfig::kConfigNamespace_ChipFailSafe[] = "chip-failsafe"; -const char AmebaConfig::kConfigNamespace_ChipSessionResumptionIndex[] = "chip-sessionresumptionindex"; -const char AmebaConfig::kConfigNamespace_ChipSessionResumption[] = "chip-sessionresumption"; -const char AmebaConfig::kConfigNamespace_ChipDeviceInfoProvider[] = "chip-deviceinfoprovider"; -const char AmebaConfig::kConfigNamespace_ChipOthers[] = "chip-others"; -const char AmebaConfig::kConfigNamespace_ChipOthers2[] = "chip-others2"; +const char AmebaConfig::kConfigNamespace_ChipFactory[] = "chip-factory"; +const char AmebaConfig::kConfigNamespace_ChipConfig[] = "chip-config"; +const char AmebaConfig::kConfigNamespace_ChipCounters[] = "chip-counters"; +const char AmebaConfig::kConfigNamespace_ChipFabric1[] = "chip-fabric-1"; +const char AmebaConfig::kConfigNamespace_ChipFabric2[] = "chip-fabric-2"; +const char AmebaConfig::kConfigNamespace_ChipFabric3[] = "chip-fabric-3"; +const char AmebaConfig::kConfigNamespace_ChipFabric4[] = "chip-fabric-4"; +const char AmebaConfig::kConfigNamespace_ChipFabric5[] = "chip-fabric-5"; +const char AmebaConfig::kConfigNamespace_ChipACL[] = "chip-acl"; +const char AmebaConfig::kConfigNamespace_ChipGroupMessageCounters[] = "chip-groupmsgcounters"; +const char AmebaConfig::kConfigNamespace_ChipAttributes[] = "chip-attributes"; +const char AmebaConfig::kConfigNamespace_ChipBindingTable[] = "chip-bindingtable"; +const char AmebaConfig::kConfigNamespace_ChipOTA[] = "chip-ota"; +const char AmebaConfig::kConfigNamespace_ChipFailSafe[] = "chip-failsafe"; +const char AmebaConfig::kConfigNamespace_ChipSessionResumptionIndex[] = "chip-sessionresumptionindex"; +const char AmebaConfig::kConfigNamespace_ChipSessionResumption[] = "chip-sessionresumption"; +const char AmebaConfig::kConfigNamespace_ChipDeviceInfoProvider[] = "chip-deviceinfoprovider"; +const char AmebaConfig::kConfigNamespace_ChipOthers[] = "chip-others"; +const char AmebaConfig::kConfigNamespace_ChipOthers2[] = "chip-others2"; // Keys stored in the chip-factory namespace const AmebaConfig::Key AmebaConfig::kConfigKey_SerialNum = { kConfigNamespace_ChipFactory, "serial-num" }; diff --git a/src/platform/Ameba/AmebaUtils.cpp b/src/platform/Ameba/AmebaUtils.cpp index 896414f3fe8e89..b5f3b95f13454b 100644 --- a/src/platform/Ameba/AmebaUtils.cpp +++ b/src/platform/Ameba/AmebaUtils.cpp @@ -22,13 +22,13 @@ /* this file behaves like a config.h, comes first */ #include +#include #include #include #include -#include #include +#include #include -#include using namespace ::chip::DeviceLayer::Internal; using chip::DeviceLayer::Internal::DeviceNetworkInfo; @@ -54,14 +54,14 @@ CHIP_ERROR AmebaUtils::IsStationEnabled(bool & staEnabled) bool AmebaUtils::IsStationProvisioned(void) { - rtw_wifi_config_t WiFiConfig = {0}; + rtw_wifi_config_t WiFiConfig = { 0 }; return ((GetWiFiConfig(&WiFiConfig) == CHIP_NO_ERROR) && (WiFiConfig.ssid[0] != 0)); } CHIP_ERROR AmebaUtils::IsStationConnected(bool & connected) { CHIP_ERROR err = CHIP_NO_ERROR; - connected = (wifi_is_connected_to_ap() == RTW_SUCCESS) ? 1 : 0; + connected = (wifi_is_connected_to_ap() == RTW_SUCCESS) ? 1 : 0; return err; } @@ -73,7 +73,7 @@ CHIP_ERROR AmebaUtils::EnableStationMode(void) return err; } -CHIP_ERROR AmebaUtils::SetWiFiConfig(rtw_wifi_config_t *config) +CHIP_ERROR AmebaUtils::SetWiFiConfig(rtw_wifi_config_t * config) { CHIP_ERROR err = CHIP_NO_ERROR; /* Store Wi-Fi Configurations in Storage */ @@ -87,20 +87,21 @@ CHIP_ERROR AmebaUtils::SetWiFiConfig(rtw_wifi_config_t *config) return err; } -CHIP_ERROR AmebaUtils::GetWiFiConfig(rtw_wifi_config_t *config) +CHIP_ERROR AmebaUtils::GetWiFiConfig(rtw_wifi_config_t * config) { - CHIP_ERROR err = CHIP_NO_ERROR; - size_t ssidLen = 0; - size_t credentialsLen = 0; + CHIP_ERROR err = CHIP_NO_ERROR; + size_t ssidLen = 0; + size_t credentialsLen = 0; /* Retrieve Wi-Fi Configurations from Storage */ err = PersistedStorage::KeyValueStoreMgr().Get(kWiFiSSIDKeyName, config->ssid, sizeof(config->ssid), &ssidLen); SuccessOrExit(err); - err = PersistedStorage::KeyValueStoreMgr().Get(kWiFiCredentialsKeyName, config->password, sizeof(config->password), &credentialsLen); + err = PersistedStorage::KeyValueStoreMgr().Get(kWiFiCredentialsKeyName, config->password, sizeof(config->password), + &credentialsLen); SuccessOrExit(err); - config->ssid_len = ssidLen; + config->ssid_len = ssidLen; config->password_len = credentialsLen; exit: @@ -119,7 +120,7 @@ CHIP_ERROR AmebaUtils::ClearWiFiConfig() CHIP_ERROR AmebaUtils::WiFiDisconnect(void) { - CHIP_ERROR err = CHIP_NO_ERROR; + CHIP_ERROR err = CHIP_NO_ERROR; ChipLogProgress(DeviceLayer, "wifi_disconnect"); err = (wifi_disconnect() == RTW_SUCCESS) ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; return err; @@ -127,13 +128,13 @@ CHIP_ERROR AmebaUtils::WiFiDisconnect(void) CHIP_ERROR AmebaUtils::WiFiConnect(void) { - CHIP_ERROR err = CHIP_NO_ERROR; - rtw_wifi_config_t *config = (rtw_wifi_config_t *)pvPortMalloc(sizeof(rtw_wifi_config_t)); + CHIP_ERROR err = CHIP_NO_ERROR; + rtw_wifi_config_t * config = (rtw_wifi_config_t *) pvPortMalloc(sizeof(rtw_wifi_config_t)); memset(config, 0, sizeof(rtw_wifi_config_t)); GetWiFiConfig(config); ChipLogProgress(DeviceLayer, "Connecting to AP : [%s]", (char *) config->ssid); int ameba_err = wifi_connect((char *) config->ssid, RTW_SECURITY_WPA_WPA2_MIXED, (char *) config->password, - strlen((const char *) config->ssid), strlen((const char *) config->password), 0, NULL); + strlen((const char *) config->ssid), strlen((const char *) config->password), 0, NULL); vPortFree(config); err = (ameba_err == RTW_SUCCESS) ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; diff --git a/src/platform/Ameba/AmebaUtils.h b/src/platform/Ameba/AmebaUtils.h index f2fc36471f60dd..b2f68f38dad1ef 100644 --- a/src/platform/Ameba/AmebaUtils.h +++ b/src/platform/Ameba/AmebaUtils.h @@ -32,8 +32,8 @@ class AmebaUtils static bool IsStationProvisioned(void); static CHIP_ERROR IsStationConnected(bool & connected); static CHIP_ERROR EnableStationMode(void); - static CHIP_ERROR SetWiFiConfig(rtw_wifi_config_t *config); - static CHIP_ERROR GetWiFiConfig(rtw_wifi_config_t *config); + static CHIP_ERROR SetWiFiConfig(rtw_wifi_config_t * config); + static CHIP_ERROR GetWiFiConfig(rtw_wifi_config_t * config); static CHIP_ERROR ClearWiFiConfig(void); static CHIP_ERROR WiFiDisconnect(void); static CHIP_ERROR WiFiConnect(void); diff --git a/src/platform/Ameba/ConnectivityManagerImpl.cpp b/src/platform/Ameba/ConnectivityManagerImpl.cpp index 63a42b0c11899d..ce2ff544c66d34 100644 --- a/src/platform/Ameba/ConnectivityManagerImpl.cpp +++ b/src/platform/Ameba/ConnectivityManagerImpl.cpp @@ -32,8 +32,8 @@ #include #endif -#include #include +#include #include #include #include @@ -60,7 +60,7 @@ ConnectivityManagerImpl ConnectivityManagerImpl::sInstance; CHIP_ERROR ConnectivityManagerImpl::_Init() { - CHIP_ERROR err = CHIP_NO_ERROR; + CHIP_ERROR err = CHIP_NO_ERROR; #if CHIP_DEVICE_CONFIG_ENABLE_WIFI mLastStationConnectFailTime = System::Clock::kZero; mLastAPDemandTime = System::Clock::kZero; diff --git a/src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp b/src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp index 6ab905ebecd619..e5754f447c7e45 100644 --- a/src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp @@ -17,8 +17,8 @@ #include #include -#include #include +#include #include #include @@ -40,8 +40,8 @@ CHIP_ERROR AmebaWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChan mpConnectCallback = nullptr; mpStatusChangeCallback = networkStatusChangeCallback; - rtw_wifi_config_t config = {0}; - err = chip::DeviceLayer::Internal::AmebaUtils::GetWiFiConfig(&config); + rtw_wifi_config_t config = { 0 }; + err = chip::DeviceLayer::Internal::AmebaUtils::GetWiFiConfig(&config); if (err == CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND) { return CHIP_NO_ERROR; @@ -64,7 +64,7 @@ CHIP_ERROR AmebaWiFiDriver::Shutdown() CHIP_ERROR AmebaWiFiDriver::CommitConfiguration() { - rtw_wifi_config_t config = {0}; + rtw_wifi_config_t config = { 0 }; memcpy(config.ssid, mStagingNetwork.ssid, mStagingNetwork.ssidLen); memcpy(config.password, mStagingNetwork.credentials, mStagingNetwork.credentialsLen); ReturnErrorOnFailure(chip::DeviceLayer::Internal::AmebaUtils::SetWiFiConfig(&config)); @@ -349,7 +349,7 @@ bool AmebaWiFiDriver::WiFiNetworkIterator::Next(Network & item) if (err == CHIP_NO_ERROR) { bool isConnected = false; - err = chip::DeviceLayer::Internal::AmebaUtils::IsStationConnected(isConnected); + err = chip::DeviceLayer::Internal::AmebaUtils::IsStationConnected(isConnected); if (isConnected && configuredNetwork.networkIDLen == item.networkIDLen && memcmp(configuredNetwork.networkID, item.networkID, item.networkIDLen) == 0)