Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and pankore committed May 23, 2022
1 parent f5ffdd8 commit 6ee1798
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 46 deletions.
1 change: 0 additions & 1 deletion examples/lighting-app/ameba/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ void InitOTARequestorHandler(System::Layer * systemLayer, void * appState)
}
#endif


void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg)
{
switch (event->Type)
Expand Down
1 change: 0 additions & 1 deletion examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void InitOTARequestorHandler(System::Layer * systemLayer, void * appState)
}
#endif


void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg)
{
switch (event->Type)
Expand Down
2 changes: 1 addition & 1 deletion examples/platform/ameba/ota/OTAHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
38 changes: 19 additions & 19 deletions src/platform/Ameba/AmebaConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" };
Expand Down
31 changes: 16 additions & 15 deletions src/platform/Ameba/AmebaUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
/* this file behaves like a config.h, comes first */
#include <platform/internal/CHIPDeviceLayerInternal.h>

#include <chip_porting.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/ErrorStr.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/Ameba/AmebaUtils.h>
#include <platform/Ameba/AmebaConfig.h>
#include <platform/Ameba/AmebaUtils.h>
#include <platform/Ameba/ConfigurationManagerImpl.h>
#include <chip_porting.h>

using namespace ::chip::DeviceLayer::Internal;
using chip::DeviceLayer::Internal::DeviceNetworkInfo;
Expand All @@ -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;
}

Expand All @@ -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 */
Expand All @@ -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:
Expand All @@ -119,21 +120,21 @@ 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;
}

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;
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Ameba/AmebaUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Ameba/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <platform/internal/GenericConnectivityManagerImpl_WiFi.ipp>
#endif

#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/Ameba/AmebaUtils.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/internal/BLEManager.h>
#include <support/CodeUtils.h>
#include <support/logging/CHIPLogging.h>
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#include <lib/support/CodeUtils.h>
#include <lib/support/SafeInt.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/Ameba/AmebaUtils.h>
#include <platform/Ameba/NetworkCommissioningDriver.h>
#include <platform/CHIPDeviceLayer.h>

#include <limits>
Expand All @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6ee1798

Please sign in to comment.