diff --git a/examples/all-clusters-app/nxp/common/main/AppAssert.cpp b/examples/all-clusters-app/nxp/common/main/AppAssert.cpp index 534f0572ab3742..07a3ea187cb5f9 100644 --- a/examples/all-clusters-app/nxp/common/main/AppAssert.cpp +++ b/examples/all-clusters-app/nxp/common/main/AppAssert.cpp @@ -21,13 +21,14 @@ #include /* -* Assert function implemented in the application layer. -* This implementation would produce a reset. -* But it could be extended with specific application contrains/requirements. -*/ -void __assert_func(const char *file, int line, const char *func, const char *failedExpr) + * Assert function implemented in the application layer. + * This implementation would produce a reset. + * But it could be extended with specific application contrains/requirements. + */ +void __assert_func(const char * file, int line, const char * func, const char * failedExpr) { PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" function name \"%s\" \n", failedExpr, file, line, func); chip::DeviceLayer::PlatformMgrImpl().Reset(); - while(1); + while (1) + ; } \ No newline at end of file diff --git a/examples/all-clusters-app/nxp/common/main/AppFactoryDataDefaultImpl.cpp b/examples/all-clusters-app/nxp/common/main/AppFactoryDataDefaultImpl.cpp index eecbdb82219f78..717321050fe14b 100644 --- a/examples/all-clusters-app/nxp/common/main/AppFactoryDataDefaultImpl.cpp +++ b/examples/all-clusters-app/nxp/common/main/AppFactoryDataDefaultImpl.cpp @@ -19,17 +19,17 @@ #include "AppFactoryData.h" +#include #include #include -#include #if CONFIG_CHIP_PLAT_LOAD_REAL_FACTORY_DATA #include "FactoryDataProvider.h" /* -* Test key used to encrypt factory data before storing it to the flash. -*/ -static const uint8_t aes128TestKey[] __attribute__((aligned)) = {0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, - 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c}; + * Test key used to encrypt factory data before storing it to the flash. + */ +static const uint8_t aes128TestKey[] + __attribute__((aligned)) = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c }; #else #include #endif diff --git a/examples/all-clusters-app/nxp/common/main/AppMatterCli.cpp b/examples/all-clusters-app/nxp/common/main/AppMatterCli.cpp index cb818e5c377d6e..663bc85920ddb4 100644 --- a/examples/all-clusters-app/nxp/common/main/AppMatterCli.cpp +++ b/examples/all-clusters-app/nxp/common/main/AppMatterCli.cpp @@ -18,17 +18,17 @@ */ #include "AppMatterCli.h" -#include -#include #include "AppTask.h" #include +#include +#include #ifdef ENABLE_CHIP_SHELL -#include -#include #include "task.h" +#include +#include -#define MATTER_CLI_TASK_SIZE ((configSTACK_DEPTH_TYPE)2048 / sizeof(portSTACK_TYPE)) +#define MATTER_CLI_TASK_SIZE ((configSTACK_DEPTH_TYPE) 2048 / sizeof(portSTACK_TYPE)) #define MATTER_CLI_LOG(message) (streamer_printf(streamer_get(), message)) using namespace chip::Shell; @@ -60,7 +60,7 @@ CHIP_ERROR commissioningManager(int argc, char * argv[]) } else { - MATTER_CLI_LOG("wrong args should be either \"mattercommissioning on\" or \"mattercommissioning off\"" ); + MATTER_CLI_LOG("wrong args should be either \"mattercommissioning on\" or \"mattercommissioning off\""); error = CHIP_ERROR_INVALID_ARGUMENT; } return error; @@ -74,7 +74,7 @@ CHIP_ERROR cliFactoryReset(int argc, char * argv[]) CHIP_ERROR cliReset(int argc, char * argv[]) { - /* + /* Shutdown device before reboot, this emits the ShutDown event, handles the server shutting down, and stores in flash the total-operational-hours value. @@ -84,7 +84,6 @@ CHIP_ERROR cliReset(int argc, char * argv[]) return CHIP_NO_ERROR; } - CHIP_ERROR AppMatterCli_RegisterCommands(void) { #ifdef ENABLE_CHIP_SHELL @@ -100,9 +99,9 @@ CHIP_ERROR AppMatterCli_RegisterCommands(void) /* Register common shell commands */ cmd_misc_init(); cmd_otcli_init(); - #if CHIP_SHELL_ENABLE_CMD_SERVER +#if CHIP_SHELL_ENABLE_CMD_SERVER cmd_app_server_init(); - #endif /* CHIP_SHELL_ENABLE_CMD_SERVER */ +#endif /* CHIP_SHELL_ENABLE_CMD_SERVER */ /* Register application commands */ static const shell_command_t kCommands[] = { @@ -128,11 +127,11 @@ CHIP_ERROR AppMatterCli_RegisterCommands(void) if (xTaskCreate(&AppMatterCliTask, "AppMatterCli_task", MATTER_CLI_TASK_SIZE, NULL, 1, &AppMatterCliTaskHandle) != pdPASS) { ChipLogError(Shell, "Failed to start Matter CLI task"); - return CHIP_ERROR_INTERNAL; + return CHIP_ERROR_INTERNAL; } isShellInitialized = true; } #endif /* ENABLE_CHIP_SHELL */ - + return CHIP_NO_ERROR; } diff --git a/examples/all-clusters-app/nxp/common/main/AppTask.cpp b/examples/all-clusters-app/nxp/common/main/AppTask.cpp index 739bd910910101..3ca3af76b96349 100644 --- a/examples/all-clusters-app/nxp/common/main/AppTask.cpp +++ b/examples/all-clusters-app/nxp/common/main/AppTask.cpp @@ -23,28 +23,28 @@ #include "DeviceCallbacks.h" #include "binding-handler.h" #include "lib/core/ErrorStr.h" -#include #include +#include #include #if CHIP_DEVICE_CONFIG_ENABLE_WPA #include #endif // CHIP_DEVICE_CONFIG_ENABLE_WPA +#include #include #include +#include #include -#include #include #include -#include -#include +#include #include -#include "AppMatterCli.h" -#include "AppMatterButton.h" #include "AppFactoryData.h" +#include "AppMatterButton.h" +#include "AppMatterCli.h" #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include "OTARequestorInitiator.h" @@ -63,7 +63,7 @@ #endif #ifndef APP_TASK_STACK_SIZE -#define APP_TASK_STACK_SIZE ((configSTACK_DEPTH_TYPE)6144 / sizeof(portSTACK_TYPE)) +#define APP_TASK_STACK_SIZE ((configSTACK_DEPTH_TYPE) 6144 / sizeof(portSTACK_TYPE)) #endif #ifndef APP_TASK_PRIORITY #define APP_TASK_PRIORITY 2 @@ -79,13 +79,13 @@ using namespace ::chip::DeviceLayer; using namespace ::chip::DeviceManager; using namespace ::chip::app::Clusters; - chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; #if CHIP_DEVICE_CONFIG_ENABLE_WPA namespace { chip::app::Clusters::NetworkCommissioning::Instance - sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(::chip::DeviceLayer::NetworkCommissioning::NXPWiFiDriver::GetInstance())); + sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, + &(::chip::DeviceLayer::NetworkCommissioning::NXPWiFiDriver::GetInstance())); } // namespace void NetWorkCommissioningInstInit() @@ -109,8 +109,7 @@ CHIP_ERROR AppTask::StartAppTask() assert(err == CHIP_NO_ERROR); } - if (xTaskCreate(&AppTask::AppTaskMain, "AppTaskMain", APP_TASK_STACK_SIZE, - &sAppTask, APP_TASK_PRIORITY, &taskHandle) != pdPASS) + if (xTaskCreate(&AppTask::AppTaskMain, "AppTaskMain", APP_TASK_STACK_SIZE, &sAppTask, APP_TASK_PRIORITY, &taskHandle) != pdPASS) { err = CHIP_ERROR_NO_MEMORY; ChipLogError(DeviceLayer, "Failed to start app task"); @@ -159,7 +158,6 @@ void AppTask::InitServer(intptr_t arg) #if ENABLE_OTA_PROVIDER InitOTAServer(); #endif - } CHIP_ERROR AppTask::Init() @@ -179,9 +177,9 @@ CHIP_ERROR AppTask::Init() } /* - * Initialize the CHIP stack. - * Would also initialize all required platform modules - */ + * Initialize the CHIP stack. + * Would also initialize all required platform modules + */ err = PlatformMgr().InitChipStack(); if (err != CHIP_NO_ERROR) { @@ -198,8 +196,8 @@ CHIP_ERROR AppTask::Init() } /* - * Register all application callbacks allowing to be informed of stack events - */ + * Register all application callbacks allowing to be informed of stack events + */ err = CHIPDeviceManager::GetInstance().Init(&deviceCallbacks); if (err != CHIP_NO_ERROR) { @@ -227,9 +225,9 @@ CHIP_ERROR AppTask::Init() #endif /* - * Schedule an event to the Matter stack to initialize - * the ZCL Data Model and start server - */ + * Schedule an event to the Matter stack to initialize + * the ZCL Data Model and start server + */ PlatformMgr().ScheduleWork(InitServer, 0); /* Init binding handlers */ @@ -244,7 +242,7 @@ CHIP_ERROR AppTask::Init() NetWorkCommissioningInstInit(); #endif // CHIP_DEVICE_CONFIG_ENABLE_WPA -#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR /* If an update is under test make it permanent */ OTARequestorInitiator::Instance().HandleSelfTest(); #endif @@ -296,7 +294,7 @@ CHIP_ERROR AppTask::Init() void AppTask::AppTaskMain(void * pvParameter) { - AppTask *task = (AppTask *)pvParameter; + AppTask * task = (AppTask *) pvParameter; CHIP_ERROR err; AppEvent event; @@ -337,7 +335,6 @@ CHIP_ERROR AppTask::DisplayDeviceInformation(void) } ChipLogProgress(DeviceLayer, "Setup discriminator: %u (0x%x)", discriminator, discriminator); - err = GetCommissionableDataProvider()->GetSetupPasscode(setupPasscode); if (err != CHIP_NO_ERROR) { @@ -354,7 +351,6 @@ CHIP_ERROR AppTask::DisplayDeviceInformation(void) } ChipLogProgress(DeviceLayer, "Vendor ID: %u (0x%x)", vendorId, vendorId); - err = GetDeviceInstanceInfoProvider()->GetProductId(productId); if (err != CHIP_NO_ERROR) { @@ -415,7 +411,7 @@ void AppTask::StartCommissioning(intptr_t arg) } else if (chip::Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen()) { - ChipLogProgress(DeviceLayer, "Commissioning window already opened"); + ChipLogProgress(DeviceLayer, "Commissioning window already opened"); } else { @@ -432,7 +428,7 @@ void AppTask::StopCommissioning(intptr_t arg) } else if (!chip::Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen()) { - ChipLogProgress(DeviceLayer, "Commissioning window not opened"); + ChipLogProgress(DeviceLayer, "Commissioning window not opened"); } else { @@ -442,7 +438,7 @@ void AppTask::StopCommissioning(intptr_t arg) void AppTask::SwitchCommissioningState(intptr_t arg) { - /* Check the status of the commissioning */ + /* Check the status of the commissioning */ if (ConfigurationMgr().IsFullyProvisioned()) { ChipLogProgress(DeviceLayer, "Device already commissioned"); diff --git a/examples/all-clusters-app/nxp/common/main/CHIPDeviceManager.cpp b/examples/all-clusters-app/nxp/common/main/CHIPDeviceManager.cpp index 301d3eb6296c38..9211601de61862 100644 --- a/examples/all-clusters-app/nxp/common/main/CHIPDeviceManager.cpp +++ b/examples/all-clusters-app/nxp/common/main/CHIPDeviceManager.cpp @@ -26,10 +26,10 @@ #include "CHIPDeviceManager.h" #include -#include +#include #include #include -#include +#include using namespace ::chip; diff --git a/examples/all-clusters-app/nxp/common/main/DeviceCallbacks.cpp b/examples/all-clusters-app/nxp/common/main/DeviceCallbacks.cpp index 65aaa120546a08..8d75ec069fbafe 100644 --- a/examples/all-clusters-app/nxp/common/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/nxp/common/main/DeviceCallbacks.cpp @@ -67,7 +67,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ case DeviceEventType::kWiFiConnectivityChange: OnWiFiConnectivityChange(event); break; - + case DeviceEventType::kInternetConnectivityChange: OnInternetConnectivityChange(event); break; @@ -91,11 +91,13 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ } } -void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, - uint8_t type, uint16_t size, uint8_t * value) +void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t type, + uint16_t size, uint8_t * value) { - ChipLogProgress(DeviceLayer, "endpointId " ChipLogFormatMEI " clusterId " ChipLogFormatMEI " attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %u", - ChipLogValueMEI(endpointId), ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId), type, *value, size); + ChipLogProgress(DeviceLayer, + "endpointId " ChipLogFormatMEI " clusterId " ChipLogFormatMEI " attribute ID: " ChipLogFormatMEI + " Type: %u Value: %u, length %u", + ChipLogValueMEI(endpointId), ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId), type, *value, size); } void DeviceCallbacks::OnWiFiConnectivityChange(const ChipDeviceEvent * event) diff --git a/examples/all-clusters-app/nxp/common/main/include/AppTask.h b/examples/all-clusters-app/nxp/common/main/include/AppTask.h index 163534f6920886..e276e287aa92a6 100644 --- a/examples/all-clusters-app/nxp/common/main/include/AppTask.h +++ b/examples/all-clusters-app/nxp/common/main/include/AppTask.h @@ -25,7 +25,6 @@ #include "AppEvent.h" #include "DeviceCallbacks.h" - class AppTask { public: diff --git a/examples/all-clusters-app/nxp/common/main/include/CHIPDeviceManager.h b/examples/all-clusters-app/nxp/common/main/include/CHIPDeviceManager.h index a9de545ef7981d..3f3d6e51eb4067 100644 --- a/examples/all-clusters-app/nxp/common/main/include/CHIPDeviceManager.h +++ b/examples/all-clusters-app/nxp/common/main/include/CHIPDeviceManager.h @@ -73,7 +73,8 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks * @param value pointer to the new value */ virtual void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, - uint8_t type, uint16_t size, uint8_t * value) {} + uint8_t type, uint16_t size, uint8_t * value) + {} virtual ~CHIPDeviceManagerCallbacks() {} }; @@ -85,8 +86,8 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks class DLL_EXPORT CHIPDeviceManager { public: - CHIPDeviceManager(const CHIPDeviceManager &) = delete; - CHIPDeviceManager(const CHIPDeviceManager &&) = delete; + CHIPDeviceManager(const CHIPDeviceManager &) = delete; + CHIPDeviceManager(const CHIPDeviceManager &&) = delete; CHIPDeviceManager & operator=(const CHIPDeviceManager &) = delete; static CHIPDeviceManager & GetInstance() diff --git a/examples/all-clusters-app/nxp/common/main/main.cpp b/examples/all-clusters-app/nxp/common/main/main.cpp index 1c995a1db5349b..c2305cf9ac4eb6 100644 --- a/examples/all-clusters-app/nxp/common/main/main.cpp +++ b/examples/all-clusters-app/nxp/common/main/main.cpp @@ -21,10 +21,10 @@ // Main Code // ================================================================================ +#include "FreeRTOS.h" +#include #include #include -#include -#include "FreeRTOS.h" #if configAPPLICATION_ALLOCATED_HEAP uint8_t __attribute__((section(".heap"))) ucHeap[configTOTAL_HEAP_SIZE]; @@ -42,7 +42,7 @@ extern "C" int main(int argc, char * argv[]) } #if (defined(configCHECK_FOR_STACK_OVERFLOW) && (configCHECK_FOR_STACK_OVERFLOW > 0)) -void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) +void vApplicationStackOverflowHook(TaskHandle_t xTask, char * pcTaskName) { assert(0); } diff --git a/examples/all-clusters-app/nxp/rt/rw61x/include/config/CHIPProjectConfig.h b/examples/all-clusters-app/nxp/rt/rw61x/include/config/CHIPProjectConfig.h index 4da03b5741f096..9fe84849fd753f 100644 --- a/examples/all-clusters-app/nxp/rt/rw61x/include/config/CHIPProjectConfig.h +++ b/examples/all-clusters-app/nxp/rt/rw61x/include/config/CHIPProjectConfig.h @@ -28,9 +28,9 @@ #pragma once -/* -* Tells to the platform Factory Data Provider whether to use the example configuration or real/provisioned data. -*/ +/* + * Tells to the platform Factory Data Provider whether to use the example configuration or real/provisioned data. + */ #ifndef CONFIG_CHIP_PLAT_LOAD_REAL_FACTORY_DATA #define CONFIG_CHIP_PLAT_LOAD_REAL_FACTORY_DATA 0 #endif @@ -44,7 +44,7 @@ /** * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID - * + * */ #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005 @@ -95,7 +95,6 @@ #define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION NXP_CONFIG_DEVICE_SOFTWARE_VERSION #endif - #ifndef CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME #define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_NAME "NXP Semiconductors" #endif @@ -162,7 +161,7 @@ * Enables synchronizing the device's real time clock with a remote CHIP Time service * using the CHIP Time Sync protocol. */ -//#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1 +// #define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1 /** * CHIP_CONFIG_MAX_BINDINGS diff --git a/src/platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h b/src/platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h index b2a91fddd25961..2b2c72cdbe5fc7 100644 --- a/src/platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h +++ b/src/platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h @@ -58,7 +58,6 @@ // These are configuration options that are unique to the NXP platform. // These can be overridden by the application as needed. - // ========== Platform-specific Configuration Overrides ========= #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 10240 diff --git a/src/platform/nxp/common/CHIPDevicePlatformEvent.h b/src/platform/nxp/common/CHIPDevicePlatformEvent.h index 227a8f3e6e6265..facc056d18b581 100644 --- a/src/platform/nxp/common/CHIPDevicePlatformEvent.h +++ b/src/platform/nxp/common/CHIPDevicePlatformEvent.h @@ -25,8 +25,8 @@ #pragma once #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE -#include #include +#include #include #endif #if CHIP_DEVICE_CONFIG_ENABLE_WPA @@ -117,7 +117,6 @@ struct ChipDevicePlatformEvent final enum wlan_event_reason WlanEventReason; struct wlan_network * pNetworkDataEvent; #endif - }; }; diff --git a/src/platform/nxp/common/ConfigurationManagerImpl.cpp b/src/platform/nxp/common/ConfigurationManagerImpl.cpp index 52e09a37721534..b14f551df63654 100644 --- a/src/platform/nxp/common/ConfigurationManagerImpl.cpp +++ b/src/platform/nxp/common/ConfigurationManagerImpl.cpp @@ -25,11 +25,12 @@ /* this file behaves like a config.h, comes first */ #include + +#include "NXPConfig.h" #include #include -#include "NXPConfig.h" -#include #include +#include #include "fsl_device_registers.h" @@ -109,7 +110,7 @@ CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) return CHIP_NO_ERROR; #else - (void)memset(&buf[0], 0, 6); // this is to avoid compilation error in GenericConfigurationManagerImpl.cpp + (void) memset(&buf[0], 0, 6); // this is to avoid compilation error in GenericConfigurationManagerImpl.cpp return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; #endif } diff --git a/src/platform/nxp/common/ConnectivityManagerImpl.cpp b/src/platform/nxp/common/ConnectivityManagerImpl.cpp index 8c3163ca91a683..36b2ae978d65c8 100644 --- a/src/platform/nxp/common/ConnectivityManagerImpl.cpp +++ b/src/platform/nxp/common/ConnectivityManagerImpl.cpp @@ -20,11 +20,11 @@ /* this file behaves like a config.h, comes first */ #include -#include -#include +#include "NetworkCommissioningDriver.h" #include #include -#include "NetworkCommissioningDriver.h" +#include +#include #include @@ -209,67 +209,70 @@ void ConnectivityManagerImpl::ProcessWlanEvent(enum wlan_event_reason wlanEvent) switch (wlanEvent) { - case WLAN_REASON_SUCCESS: - ChipLogProgress(DeviceLayer, "Connected to WLAN network = %d", is_sta_ipv6_connected()); - if (sInstance._GetWiFiStationState() == kWiFiStationState_Connecting) - { - sInstance._SetWiFiStationState(kWiFiStationState_Connecting_Succeeded); - sInstance._SetWiFiStationState(kWiFiStationState_Connected); - NetworkCommissioning::NXPWiFiDriver::GetInstance().OnConnectWiFiNetwork(NetworkCommissioning::Status::kSuccess, CharSpan(), wlanEvent); - sInstance.OnStationConnected(); - } - break; - - case WLAN_REASON_AUTH_SUCCESS: - ChipLogProgress(DeviceLayer, "Associated to WLAN network"); - break; + case WLAN_REASON_SUCCESS: + ChipLogProgress(DeviceLayer, "Connected to WLAN network = %d", is_sta_ipv6_connected()); + if (sInstance._GetWiFiStationState() == kWiFiStationState_Connecting) + { + sInstance._SetWiFiStationState(kWiFiStationState_Connecting_Succeeded); + sInstance._SetWiFiStationState(kWiFiStationState_Connected); + NetworkCommissioning::NXPWiFiDriver::GetInstance().OnConnectWiFiNetwork(NetworkCommissioning::Status::kSuccess, + CharSpan(), wlanEvent); + sInstance.OnStationConnected(); + } + break; - case WLAN_REASON_CONNECT_FAILED: - ChipLogError(DeviceLayer, "WLAN (re)connect failed"); - sInstance._SetWiFiStationState(kWiFiStationState_NotConnected); - UpdateInternetConnectivityState(); - break; - - case WLAN_REASON_NETWORK_NOT_FOUND: - ChipLogError(DeviceLayer, "WLAN network not found"); - NetworkCommissioning::NXPWiFiDriver::GetInstance().OnConnectWiFiNetwork(NetworkCommissioning::Status::kNetworkNotFound, CharSpan(), wlanEvent); - break; - - case WLAN_REASON_NETWORK_AUTH_FAILED: - ChipLogError(DeviceLayer, "Authentication to WLAN network failed"); - NetworkCommissioning::NXPWiFiDriver::GetInstance().OnConnectWiFiNetwork(NetworkCommissioning::Status::kAuthFailure, CharSpan(), wlanEvent); - ChipLogError(DeviceLayer, "Authentication to WLAN network failed end"); - break; - - case WLAN_REASON_LINK_LOST: - ChipLogError(DeviceLayer, "WLAN link lost"); - if (sInstance._GetWiFiStationState() == kWiFiStationState_Connected) - { - sInstance._SetWiFiStationState(kWiFiStationState_NotConnected); - sInstance.OnStationDisconnected(); - } - break; + case WLAN_REASON_AUTH_SUCCESS: + ChipLogProgress(DeviceLayer, "Associated to WLAN network"); + break; - case WLAN_REASON_USER_DISCONNECT: - ChipLogProgress(DeviceLayer, "Disconnected from WLAN network"); + case WLAN_REASON_CONNECT_FAILED: + ChipLogError(DeviceLayer, "WLAN (re)connect failed"); + sInstance._SetWiFiStationState(kWiFiStationState_NotConnected); + UpdateInternetConnectivityState(); + break; + + case WLAN_REASON_NETWORK_NOT_FOUND: + ChipLogError(DeviceLayer, "WLAN network not found"); + NetworkCommissioning::NXPWiFiDriver::GetInstance().OnConnectWiFiNetwork(NetworkCommissioning::Status::kNetworkNotFound, + CharSpan(), wlanEvent); + break; + + case WLAN_REASON_NETWORK_AUTH_FAILED: + ChipLogError(DeviceLayer, "Authentication to WLAN network failed"); + NetworkCommissioning::NXPWiFiDriver::GetInstance().OnConnectWiFiNetwork(NetworkCommissioning::Status::kAuthFailure, + CharSpan(), wlanEvent); + ChipLogError(DeviceLayer, "Authentication to WLAN network failed end"); + break; + + case WLAN_REASON_LINK_LOST: + ChipLogError(DeviceLayer, "WLAN link lost"); + if (sInstance._GetWiFiStationState() == kWiFiStationState_Connected) + { sInstance._SetWiFiStationState(kWiFiStationState_NotConnected); sInstance.OnStationDisconnected(); - break; + } + break; - case WLAN_REASON_INITIALIZED: - sInstance._SetWiFiStationState(kWiFiStationState_NotConnected); - sInstance._SetWiFiStationMode(kWiFiStationMode_Enabled); - break; + case WLAN_REASON_USER_DISCONNECT: + ChipLogProgress(DeviceLayer, "Disconnected from WLAN network"); + sInstance._SetWiFiStationState(kWiFiStationState_NotConnected); + sInstance.OnStationDisconnected(); + break; + + case WLAN_REASON_INITIALIZED: + sInstance._SetWiFiStationState(kWiFiStationState_NotConnected); + sInstance._SetWiFiStationMode(kWiFiStationMode_Enabled); + break; - default: - break; + default: + break; } } -int ConnectivityManagerImpl::_WlanEventCallback(enum wlan_event_reason wlanEvent, void *data) +int ConnectivityManagerImpl::_WlanEventCallback(enum wlan_event_reason wlanEvent, void * data) { ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformNxpWlanEvent; + event.Type = DeviceEventType::kPlatformNxpWlanEvent; event.Platform.WlanEventReason = wlanEvent; (void) PlatformMgr().PostEvent(&event); return 0; @@ -282,7 +285,7 @@ void ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; - (void ) PlatformMgr().PostEvent(&event); + (void) PlatformMgr().PostEvent(&event); /* Update the connectivity state in case the connected event has been received after getting an IP addr */ UpdateInternetConnectivityState(); @@ -295,7 +298,7 @@ void ConnectivityManagerImpl::OnStationDisconnected() event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Lost; - (void ) PlatformMgr().PostEvent(&event); + (void) PlatformMgr().PostEvent(&event); /* Update the connectivity state in case the connected event has been received after getting an IP addr */ UpdateInternetConnectivityState(); @@ -307,8 +310,8 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState() bool haveIPv6Conn = false; const bool hadIPv4Conn = mFlags.Has(ConnectivityFlags::kHaveIPv4InternetConnectivity); const bool hadIPv6Conn = mFlags.Has(ConnectivityFlags::kHaveIPv6InternetConnectivity); - const ip_addr_t *addr4; - const ip6_addr_t *addr6; + const ip_addr_t * addr4; + const ip6_addr_t * addr6; CHIP_ERROR err; ChipDeviceEvent event; @@ -316,7 +319,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState() if (_IsWiFiStationConnected()) { // Get the LwIP netif for the WiFi station interface. - struct netif *netif = static_cast(net_get_mlan_handle()); + struct netif * netif = static_cast(net_get_mlan_handle()); // If the WiFi station interface is up... if ((netif != nullptr) && netif_is_up(netif) && netif_is_link_up(netif)) @@ -332,7 +335,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState() if (!ip4_addr_isany_val(*netif_ip4_addr(netif)) && !ip4_addr_isany_val(*netif_ip4_gw(netif))) { haveIPv4Conn = true; - addr4 = &netif->ip_addr; + addr4 = &netif->ip_addr; } } #endif @@ -346,7 +349,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState() if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i))) { haveIPv6Conn = true; - addr6 = netif_ip6_addr(netif, i); + addr6 = netif_ip6_addr(netif, i); break; } } @@ -354,8 +357,8 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState() } // Update the current state. - mFlags.Set(ConnectivityFlags::kHaveIPv4InternetConnectivity, haveIPv4Conn).Set(ConnectivityFlags::kHaveIPv6InternetConnectivity, haveIPv6Conn); - + mFlags.Set(ConnectivityFlags::kHaveIPv4InternetConnectivity, haveIPv4Conn) + .Set(ConnectivityFlags::kHaveIPv6InternetConnectivity, haveIPv6Conn); if (haveIPv4Conn != hadIPv4Conn) { @@ -393,9 +396,10 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState() } } -void ConnectivityManagerImpl::_NetifExtCallback(struct netif* netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args) +void ConnectivityManagerImpl::_NetifExtCallback(struct netif * netif, netif_nsc_reason_t reason, + const netif_ext_callback_args_t * args) { - struct netif *station_netif; + struct netif * station_netif; ChipDeviceEvent event; ChipLogDetail(DeviceLayer, "_NetifExtCallback: netif=%p, reason=0x%04x", netif, reason); @@ -410,7 +414,7 @@ void ConnectivityManagerImpl::_NetifExtCallback(struct netif* netif, netif_nsc_r void ConnectivityManagerImpl::StartWiFiManagement() { - struct netif *netif = nullptr; + struct netif * netif = nullptr; EventBits_t bits; int32_t result; @@ -436,7 +440,7 @@ void ConnectivityManagerImpl::StartWiFiManagement() CHIP_ERROR ConnectivityManagerImpl::ProvisionWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen) { #if CHIP_DEVICE_CONFIG_ENABLE_WPA - CHIP_ERROR ret = CHIP_NO_ERROR; + CHIP_ERROR ret = CHIP_NO_ERROR; struct wlan_network * pNetworkData = (struct wlan_network *) malloc(sizeof(struct wlan_network)); int result; @@ -485,9 +489,9 @@ void ConnectivityManagerImpl::ConnectNetworkTimerHandler(::chip::System::Layer * ChipDeviceEvent event; /* - * Make sure to have the Wi-Fi station enabled before scheduling a connect event . - * Otherwise start a new timer to check again the status later. - */ + * Make sure to have the Wi-Fi station enabled before scheduling a connect event . + * Otherwise start a new timer to check again the status later. + */ if (ConnectivityMgr().IsWiFiStationEnabled()) { /* Post an event to start the connection asynchronously in the Matter task context */ @@ -498,7 +502,8 @@ void ConnectivityManagerImpl::ConnectNetworkTimerHandler(::chip::System::Layer * else { PlatformMgr().LockChipStack(); - DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_WIFI_STATION_RECONNECT_INTERVAL), ConnectNetworkTimerHandler, context); + DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_WIFI_STATION_RECONNECT_INTERVAL), + ConnectNetworkTimerHandler, context); PlatformMgr().UnlockChipStack(); } } diff --git a/src/platform/nxp/common/ConnectivityManagerImpl.h b/src/platform/nxp/common/ConnectivityManagerImpl.h index 86353e08baeb9d..427cbbe8e61cc3 100644 --- a/src/platform/nxp/common/ConnectivityManagerImpl.h +++ b/src/platform/nxp/common/ConnectivityManagerImpl.h @@ -126,16 +126,15 @@ class ConnectivityManagerImpl final : public ConnectivityManager, uint32_t mWiFiStationReconnectIntervalMS; #if CHIP_DEVICE_CONFIG_ENABLE_WPA - enum WiFiEventGroup - { + enum WiFiEventGroup{ kWiFiEventGroup_WiFiStationModeBit = (1 << 0), }; BitFlags mFlags; static netif_ext_callback_t sNetifCallback; - static int _WlanEventCallback(enum wlan_event_reason event, void *data); - static void _NetifExtCallback(struct netif* netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t* args); + static int _WlanEventCallback(enum wlan_event_reason event, void * data); + static void _NetifExtCallback(struct netif * netif, netif_nsc_reason_t reason, const netif_ext_callback_args_t * args); void OnStationConnected(void); void OnStationDisconnected(void); diff --git a/src/platform/nxp/common/DiagnosticDataProviderImpl.cpp b/src/platform/nxp/common/DiagnosticDataProviderImpl.cpp index 7d2a90f27e9b26..92ef8c0c310d29 100644 --- a/src/platform/nxp/common/DiagnosticDataProviderImpl.cpp +++ b/src/platform/nxp/common/DiagnosticDataProviderImpl.cpp @@ -25,12 +25,12 @@ #include #include +#include "DiagnosticDataProviderImpl.h" #include #include -#include "DiagnosticDataProviderImpl.h" -#include #include +#include #if CHIP_DEVICE_CONFIG_ENABLE_WPA extern "C" { @@ -115,26 +115,26 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** #if CHIP_DEVICE_CONFIG_ENABLE_THREAD const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance()); - ifp->name = CharSpan(threadNetworkName, strlen(threadNetworkName)); - ifp->isOperational = true; + ifp->name = CharSpan(threadNetworkName, strlen(threadNetworkName)); + ifp->isOperational = true; ifp->offPremiseServicesReachableIPv4.SetNull(); ifp->offPremiseServicesReachableIPv6.SetNull(); ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_THREAD; ConfigurationMgr().GetPrimary802154MACAddress(ifp->MacAddress); ifp->hardwareAddress = ByteSpan(ifp->MacAddress, kMaxHardwareAddrSize); #elif CHIP_DEVICE_CONFIG_ENABLE_WPA - struct netif *netif = nullptr; - netif = static_cast(net_get_mlan_handle()); + struct netif * netif = nullptr; + netif = static_cast(net_get_mlan_handle()); strncpy(ifp->Name, "wlan0", Inet::InterfaceId::kMaxIfNameLength); - ifp->name = CharSpan(ifp->Name, strlen(ifp->Name)); + ifp->name = CharSpan(ifp->Name, strlen(ifp->Name)); ifp->isOperational = true; ifp->offPremiseServicesReachableIPv4.SetNull(); ifp->offPremiseServicesReachableIPv6.SetNull(); - ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI; + ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI; ifp->hardwareAddress = ByteSpan(netif->hwaddr, netif->hwaddr_len); #endif - // IPv6-only support + // IPv6-only support Inet::InterfaceAddressIterator interfAddrIterator; uint8_t ipv6AddressesCount = 0; while (interfAddrIterator.HasCurrent() && ipv6AddressesCount < kMaxIPv6AddrCount) @@ -232,7 +232,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetwork CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNumber) { - channelNumber = wlan_get_current_channel(); + channelNumber = wlan_get_current_channel(); return CHIP_NO_ERROR; } @@ -286,7 +286,6 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastRxCount(uint32_t & { packetMulticastRxCount = stats.mcast_rx_frame; return CHIP_NO_ERROR; - } #endif /* CONFIG_WIFI_GET_LOG */ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; diff --git a/src/platform/nxp/common/DiagnosticDataProviderImpl.h b/src/platform/nxp/common/DiagnosticDataProviderImpl.h index 4a9cd27f7f18c0..1f6af84e267f34 100644 --- a/src/platform/nxp/common/DiagnosticDataProviderImpl.h +++ b/src/platform/nxp/common/DiagnosticDataProviderImpl.h @@ -30,11 +30,11 @@ /** * DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts() is * currently not supported due to missing reset feature from SDK's wifi driver. - * For this reason, the PKTCNT (beaconRxCount, packetMulticastRxCount, - * packetMulticastTxCount, packetUnicastRxCount, packetUnicastTxCount) + * For this reason, the PKTCNT (beaconRxCount, packetMulticastRxCount, + * packetMulticastTxCount, packetUnicastRxCount, packetUnicastTxCount) * and ERRCNT (beaconLostCount, overrunCount) features of DGWIFI cluster * are currently not supported. -*/ + */ #define DGWIFI_RESET_COUNTS_SUPPORTED 0 namespace chip { @@ -72,9 +72,9 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) override; /** * TODO : This should reset BeaconLostCount, BeaconRxCount, PacketMulticastRxCount, - * PacketMulticastTxCount, PacketUnicastRxCount, PacketUnicastTxCount + * PacketMulticastTxCount, PacketUnicastRxCount, PacketUnicastTxCount */ - //CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; + // CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; #endif /* DGWIFI_RESET_COUNTS_SUPPORTED */ #endif /* CHIP_DEVICE_CONFIG_ENABLE_WPA */ }; diff --git a/src/platform/nxp/common/KeyValueStoreManagerImpl.cpp b/src/platform/nxp/common/KeyValueStoreManagerImpl.cpp index ec6ded663abfed..8b704841374d21 100644 --- a/src/platform/nxp/common/KeyValueStoreManagerImpl.cpp +++ b/src/platform/nxp/common/KeyValueStoreManagerImpl.cpp @@ -23,8 +23,8 @@ /* this file behaves like a config.h, comes first */ #include -#include "lib/support/CHIPMem.h" #include "NXPConfig.h" +#include "lib/support/CHIPMem.h" #include #include @@ -44,8 +44,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t ChipLogProgress(DeviceLayer, "KVS, get key id:: %s", key); - err = chip::DeviceLayer::Internal::NXPConfig::ReadConfigValueBin( - key, (uint8_t *) value, value_size, read_bytes); + err = chip::DeviceLayer::Internal::NXPConfig::ReadConfigValueBin(key, (uint8_t *) value, value_size, read_bytes); *read_bytes_size = read_bytes; @@ -62,8 +61,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, ChipLogProgress(DeviceLayer, "KVS, put key id:: %s ", key); - err = chip::DeviceLayer::Internal::NXPConfig::WriteConfigValueBin( - key, (uint8_t *) value, value_size); + err = chip::DeviceLayer::Internal::NXPConfig::WriteConfigValueBin(key, (uint8_t *) value, value_size); exit: ConvertError(err); diff --git a/src/platform/nxp/common/Logging.cpp b/src/platform/nxp/common/Logging.cpp index 3b1e52fe83bb20..671a8dcbb123ef 100644 --- a/src/platform/nxp/common/Logging.cpp +++ b/src/platform/nxp/common/Logging.cpp @@ -19,9 +19,9 @@ #include #include -#include -#include #include "fsl_debug_console.h" +#include +#include #include #include @@ -41,7 +41,7 @@ namespace Platform { */ void LogV(const char * module, uint8_t category, const char * msg, va_list v) { - char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE] = {0}; + char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE] = { 0 }; size_t prefixLen; /* First add the timestamp to the log message */ diff --git a/src/platform/nxp/common/NXPConfig.cpp b/src/platform/nxp/common/NXPConfig.cpp index 39660ddfc6ee04..5324184c355248 100644 --- a/src/platform/nxp/common/NXPConfig.cpp +++ b/src/platform/nxp/common/NXPConfig.cpp @@ -26,11 +26,11 @@ #include "NXPConfig.h" +#include "FreeRTOS.h" +#include "FunctionLib.h" +#include "board.h" #include #include -#include "board.h" -#include "FunctionLib.h" -#include "FreeRTOS.h" /* FS Writes in Idle task only - LittleFS only , already enabled by default on NVM */ #ifndef CHIP_PLAT_SAVE_NVM_DATA_ON_IDLE @@ -41,26 +41,26 @@ #include "ot_platform_common.h" #endif -#define BUFFER_LOG_SIZE 256 -#define CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE 4*2048 -#define CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE 4*5000 +#define BUFFER_LOG_SIZE 256 +#define CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE 4 * 2048 +#define CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE 4 * 5000 #ifndef NVM_ID_CHIP_CONFIG_DATA_KEY_INT -#define NVM_ID_CHIP_CONFIG_DATA_KEY_INT 0xf104 +#define NVM_ID_CHIP_CONFIG_DATA_KEY_INT 0xf104 #endif #ifndef NVM_ID_CHIP_CONFIG_DATA_KEY_STRING -#define NVM_ID_CHIP_CONFIG_DATA_KEY_STRING 0xf105 +#define NVM_ID_CHIP_CONFIG_DATA_KEY_STRING 0xf105 #endif -#if defined(DEBUG_NVM) && (DEBUG_NVM==2) +#if defined(DEBUG_NVM) && (DEBUG_NVM == 2) #include "fsl_debug_console.h" -#define DBG_PRINTF PRINTF -#define INFO_PRINTF PRINTF +#define DBG_PRINTF PRINTF +#define INFO_PRINTF PRINTF -#elif defined(DEBUG_NVM) && (DEBUG_NVM==1) +#elif defined(DEBUG_NVM) && (DEBUG_NVM == 1) #include "fsl_debug_console.h" -#define DBG_PRINTF PRINTF +#define DBG_PRINTF PRINTF #define INFO_PRINTF(...) #else @@ -68,7 +68,7 @@ #define INFO_PRINTF(...) #endif -#define FREERTOS_TIMER_TICKS_2_MS(ticks) (((uint64_t)ticks) * portTICK_PERIOD_MS) +#define FREERTOS_TIMER_TICKS_2_MS(ticks) (((uint64_t) ticks) * portTICK_PERIOD_MS) typedef struct { @@ -77,7 +77,7 @@ typedef struct uint8_t chipConfigRamBuffer[CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE]; } ChipConfigRamStructKeyInt; -typedef struct +typedef struct { uint16_t chipConfigRamBufferLen; uint16_t padding; @@ -87,28 +87,30 @@ typedef struct /* File system containing only integer keys */ static ChipConfigRamStructKeyInt chipConfigRamStructKeyInt; static ramBufferDescriptor ramDescrKeyInt = { - .ramBufferLen = &chipConfigRamStructKeyInt.chipConfigRamBufferLen, + .ramBufferLen = &chipConfigRamStructKeyInt.chipConfigRamBufferLen, .ramBufferMaxLen = CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE, - .pRamBuffer = &chipConfigRamStructKeyInt.chipConfigRamBuffer[0], + .pRamBuffer = &chipConfigRamStructKeyInt.chipConfigRamBuffer[0], }; /* File system containing only string keys */ static ChipConfigRamStructKeyString chipConfigRamStructKeyString; static ramBufferDescriptor ramDescrKeyString = { - .ramBufferLen = &chipConfigRamStructKeyString.chipConfigRamBufferLen, + .ramBufferLen = &chipConfigRamStructKeyString.chipConfigRamBufferLen, .ramBufferMaxLen = CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE, - .pRamBuffer = &chipConfigRamStructKeyString.chipConfigRamBuffer[0], + .pRamBuffer = &chipConfigRamStructKeyString.chipConfigRamBuffer[0], }; static bool isInitialized = false; #if (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_NVM_FWK) -NVM_RegisterDataSet((void *)&chipConfigRamStructKeyInt, 1, sizeof(chipConfigRamStructKeyInt), NVM_ID_CHIP_CONFIG_DATA_KEY_INT, gNVM_MirroredInRam_c); -NVM_RegisterDataSet((void *)&chipConfigRamStructKeyString, 1, sizeof(chipConfigRamStructKeyString), NVM_ID_CHIP_CONFIG_DATA_KEY_STRING, gNVM_MirroredInRam_c); +NVM_RegisterDataSet((void *) &chipConfigRamStructKeyInt, 1, sizeof(chipConfigRamStructKeyInt), NVM_ID_CHIP_CONFIG_DATA_KEY_INT, + gNVM_MirroredInRam_c); +NVM_RegisterDataSet((void *) &chipConfigRamStructKeyString, 1, sizeof(chipConfigRamStructKeyString), + NVM_ID_CHIP_CONFIG_DATA_KEY_STRING, gNVM_MirroredInRam_c); #elif (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_LITTLEFS) -const char *mt_key_int_file_name = "mt_key_int"; -const char *mt_key_str_file_name = "mt_key_str"; +const char * mt_key_int_file_name = "mt_key_int"; +const char * mt_key_str_file_name = "mt_key_str"; #if CHIP_PLAT_SAVE_NVM_DATA_ON_IDLE static bool mt_key_int_save_in_flash = false; static bool mt_key_str_save_in_flash = false; @@ -123,19 +125,20 @@ namespace Internal { int NXPConfig::SaveIntKeysToFS(void) { int err_len; -#if (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_NVM_FWK) +#if (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_NVM_FWK) err_len = -1; NvSaveOnIdle(&chipConfigRamStructKeyInt, false); -#elif (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_LITTLEFS) +#elif (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_LITTLEFS) err_len = -2; #if CHIP_PLAT_SAVE_NVM_DATA_ON_IDLE mt_key_int_save_in_flash = true; #else - + /* Save it in flash now */ - err_len = ramStorageSavetoFlash(mt_key_int_file_name, &chipConfigRamStructKeyInt.chipConfigRamBuffer[0], chipConfigRamStructKeyInt.chipConfigRamBufferLen); + err_len = ramStorageSavetoFlash(mt_key_int_file_name, &chipConfigRamStructKeyInt.chipConfigRamBuffer[0], + chipConfigRamStructKeyInt.chipConfigRamBufferLen); assert(err_len <= CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE); assert(err_len >= 0); @@ -150,19 +153,20 @@ int NXPConfig::SaveIntKeysToFS(void) int NXPConfig::SaveStringKeysToFS(void) { - int err_len; -#if (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_NVM_FWK) - err_len =-1; + int err_len; +#if (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_NVM_FWK) + err_len = -1; NvSaveOnIdle(&chipConfigRamStructKeyInt, false); -#elif (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_LITTLEFS) - err_len =-2; +#elif (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_LITTLEFS) + err_len = -2; #if CHIP_PLAT_SAVE_NVM_DATA_ON_IDLE mt_key_str_save_in_flash = true; #else /* Save it in flash now */ - err_len = ramStorageSavetoFlash(mt_key_str_file_name, &chipConfigRamStructKeyString.chipConfigRamBuffer[0], chipConfigRamStructKeyString.chipConfigRamBufferLen); + err_len = ramStorageSavetoFlash(mt_key_str_file_name, &chipConfigRamStructKeyString.chipConfigRamBuffer[0], + chipConfigRamStructKeyString.chipConfigRamBufferLen); assert(err_len <= CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE); assert(err_len >= 0); @@ -181,42 +185,45 @@ CHIP_ERROR NXPConfig::Init() { ramStorageInit(); -#if (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_NVM_FWK) +#if (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_NVM_FWK) /* Init the NVM module */ NvModuleInit(); -#elif (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_LITTLEFS) - int err_len; +#elif (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_LITTLEFS) + int err_len; - /* Init the NVM module */ - err_len = FS_Init(); - assert(err_len >= 0); + /* Init the NVM module */ + err_len = FS_Init(); + assert(err_len >= 0); #endif - FLib_MemSet((void *)&chipConfigRamStructKeyInt, 0, sizeof(chipConfigRamStructKeyInt)); - FLib_MemSet((void *)&chipConfigRamStructKeyString, 0, sizeof(chipConfigRamStructKeyString)); + FLib_MemSet((void *) &chipConfigRamStructKeyInt, 0, sizeof(chipConfigRamStructKeyInt)); + FLib_MemSet((void *) &chipConfigRamStructKeyString, 0, sizeof(chipConfigRamStructKeyString)); -#if (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_NVM_FWK) +#if (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_NVM_FWK) /* Try to load the ot dataset in RAM */ - NvRestoreDataSet((void *)&chipConfigRamStructKeyInt, 0); - NvRestoreDataSet((void *)&chipConfigRamStructKeyString, 0); + NvRestoreDataSet((void *) &chipConfigRamStructKeyInt, 0); + NvRestoreDataSet((void *) &chipConfigRamStructKeyString, 0); -#elif (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_LITTLEFS) - /* Try to load the ot dataset in RAM */ - err_len = ramStorageReadFromFlash(mt_key_int_file_name, &chipConfigRamStructKeyInt.chipConfigRamBuffer[0], CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE); - assert(err_len <= CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE); - assert(err_len >= 0); - chipConfigRamStructKeyInt.chipConfigRamBufferLen = (uint16_t)err_len; - - err_len = ramStorageReadFromFlash(mt_key_str_file_name, &chipConfigRamStructKeyString.chipConfigRamBuffer[0], CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE); - assert(err_len <= CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE); - assert(err_len >= 0); - chipConfigRamStructKeyString.chipConfigRamBufferLen = (uint16_t)err_len; +#elif (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_LITTLEFS) + /* Try to load the ot dataset in RAM */ + err_len = ramStorageReadFromFlash(mt_key_int_file_name, &chipConfigRamStructKeyInt.chipConfigRamBuffer[0], + CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE); + assert(err_len <= CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE); + assert(err_len >= 0); + chipConfigRamStructKeyInt.chipConfigRamBufferLen = (uint16_t) err_len; + + err_len = ramStorageReadFromFlash(mt_key_str_file_name, &chipConfigRamStructKeyString.chipConfigRamBuffer[0], + CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE); + assert(err_len <= CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE); + assert(err_len >= 0); + chipConfigRamStructKeyString.chipConfigRamBufferLen = (uint16_t) err_len; #endif isInitialized = true; } - DBG_PRINTF("mt read %d / %d\r\n", chipConfigRamStructKeyInt.chipConfigRamBufferLen, chipConfigRamStructKeyString.chipConfigRamBufferLen); + DBG_PRINTF("mt read %d / %d\r\n", chipConfigRamStructKeyInt.chipConfigRamBufferLen, + chipConfigRamStructKeyString.chipConfigRamBufferLen); return CHIP_NO_ERROR; } @@ -229,7 +236,7 @@ CHIP_ERROR NXPConfig::ReadConfigValue(Key key, bool & val) uint16_t sizeToRead = sizeof(tempVal); VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, (uint8_t*) &tempVal, &sizeToRead); + status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, (uint8_t *) &tempVal, &sizeToRead); SuccessOrExit(err = MapRamStorageStatus(status)); val = tempVal; @@ -247,7 +254,7 @@ CHIP_ERROR NXPConfig::ReadConfigValue(Key key, uint32_t & val) uint16_t sizeToRead = sizeof(tempVal); VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, (uint8_t*) &tempVal, &sizeToRead); + status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, (uint8_t *) &tempVal, &sizeToRead); SuccessOrExit(err = MapRamStorageStatus(status)); val = tempVal; @@ -265,7 +272,7 @@ CHIP_ERROR NXPConfig::ReadConfigValue(Key key, uint64_t & val) uint16_t sizeToRead = sizeof(tempVal); VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, (uint8_t*) &tempVal, &sizeToRead); + status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, (uint8_t *) &tempVal, &sizeToRead); SuccessOrExit(err = MapRamStorageStatus(status)); val = tempVal; @@ -282,7 +289,7 @@ CHIP_ERROR NXPConfig::ReadConfigValueStr(Key key, char * buf, size_t bufSize, si uint16_t sizeToRead = bufSize; VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, (uint8_t*) buf, &sizeToRead); + status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, (uint8_t *) buf, &sizeToRead); SuccessOrExit(err = MapRamStorageStatus(status)); outLen = sizeToRead; ChipLogProgress(DeviceLayer, "ReadConfigValueStr lenRead = %u", outLen); @@ -293,17 +300,17 @@ CHIP_ERROR NXPConfig::ReadConfigValueStr(Key key, char * buf, size_t bufSize, si CHIP_ERROR NXPConfig::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen) { - return ReadConfigValueStr(key, (char*) buf, bufSize, outLen); + return ReadConfigValueStr(key, (char *) buf, bufSize, outLen); } -CHIP_ERROR NXPConfig::ReadConfigValueBin(const char* keyString, uint8_t * buf, size_t bufSize, size_t & outLen) +CHIP_ERROR NXPConfig::ReadConfigValueBin(const char * keyString, uint8_t * buf, size_t bufSize, size_t & outLen) { CHIP_ERROR err; rsError status; uint16_t sizeToRead = bufSize; VerifyOrExit(keyString != NULL, err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(&ramDescrKeyString, (const uint8_t*)keyString, strlen(keyString), 0, (uint8_t*) buf, &sizeToRead); + status = ramStorageGet(&ramDescrKeyString, (const uint8_t *) keyString, strlen(keyString), 0, (uint8_t *) buf, &sizeToRead); SuccessOrExit(err = MapRamStorageStatus(status)); outLen = sizeToRead; ChipLogProgress(DeviceLayer, "ReadConfigValueStr lenRead = %u", outLen); @@ -329,7 +336,7 @@ CHIP_ERROR NXPConfig::WriteConfigValue(Key key, bool val) SuccessOrExit(err = MapRamStorageStatus(status)); err_len = SaveIntKeysToFS(); - (void)err_len; + (void) err_len; DBG_PRINTF("WriteConfigValue: MT write %d\r\n", err_len); ChipLogProgress(DeviceLayer, "WriteConfigValue done"); @@ -345,11 +352,11 @@ CHIP_ERROR NXPConfig::WriteConfigValue(Key key, uint32_t val) int err_len; VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageSet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), (uint8_t *)&val, sizeof(uint32_t)); + status = ramStorageSet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), (uint8_t *) &val, sizeof(uint32_t)); SuccessOrExit(err = MapRamStorageStatus(status)); err_len = NXPConfig::SaveIntKeysToFS(); - (void)err_len; + (void) err_len; DBG_PRINTF("WriteConfigValue: MT write %d\r\n", err_len); ChipLogProgress(DeviceLayer, "WriteConfigValue done"); @@ -365,11 +372,11 @@ CHIP_ERROR NXPConfig::WriteConfigValue(Key key, uint64_t val) int err_len; VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageSet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), (uint8_t *)&val, sizeof(uint64_t)); + status = ramStorageSet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), (uint8_t *) &val, sizeof(uint64_t)); SuccessOrExit(err = MapRamStorageStatus(status)); err_len = NXPConfig::SaveIntKeysToFS(); - (void)err_len; + (void) err_len; DBG_PRINTF("WriteConfigValue64: MT write %d\r\n", err_len); ChipLogProgress(DeviceLayer, "WriteConfigValue done"); @@ -394,7 +401,7 @@ CHIP_ERROR NXPConfig::WriteConfigValueStr(Key key, const char * str, size_t strL SuccessOrExit(err = MapRamStorageStatus(status)); err_len = NXPConfig::SaveIntKeysToFS(); - (void)err_len; + (void) err_len; DBG_PRINTF("WriteConfigValueStr: MT write %d\r\n", err_len); ChipLogProgress(DeviceLayer, "WriteConfigValue done"); @@ -408,18 +415,18 @@ CHIP_ERROR NXPConfig::WriteConfigValueBin(Key key, const uint8_t * data, size_t return WriteConfigValueStr(key, (char *) data, dataLen); } -CHIP_ERROR NXPConfig::WriteConfigValueBin(const char* keyString, const uint8_t * data, size_t dataLen) +CHIP_ERROR NXPConfig::WriteConfigValueBin(const char * keyString, const uint8_t * data, size_t dataLen) { CHIP_ERROR err; rsError status; int err_len; - + VerifyOrExit(keyString != NULL, err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageSet(&ramDescrKeyString, (const uint8_t*)keyString, strlen(keyString), (uint8_t *) data, dataLen); + status = ramStorageSet(&ramDescrKeyString, (const uint8_t *) keyString, strlen(keyString), (uint8_t *) data, dataLen); SuccessOrExit(err = MapRamStorageStatus(status)); err_len = NXPConfig::SaveStringKeysToFS(); - (void)err_len; + (void) err_len; DBG_PRINTF("WriteConfigValueBin: MT write %d\r\n", err_len); ChipLogProgress(DeviceLayer, "WriteConfigValue done"); @@ -445,7 +452,7 @@ CHIP_ERROR NXPConfig::ClearConfigValue(Key key) SuccessOrExit(err = MapRamStorageStatus(status)); err_len = NXPConfig::SaveIntKeysToFS(); - (void)err_len; + (void) err_len; DBG_PRINTF("ClearConfigValue: MT write %d\r\n", err_len); exit: @@ -459,11 +466,11 @@ CHIP_ERROR NXPConfig::ClearConfigValue(const char * keyString) int err_len; VerifyOrExit(keyString != NULL, err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageDelete(&ramDescrKeyString, (const uint8_t*) keyString, strlen(keyString), 0); + status = ramStorageDelete(&ramDescrKeyString, (const uint8_t *) keyString, strlen(keyString), 0); SuccessOrExit(err = MapRamStorageStatus(status)); err_len = NXPConfig::SaveStringKeysToFS(); - (void)err_len; + (void) err_len; DBG_PRINTF("WriteConfigValueBin: MT write %d\r\n", err_len); exit: @@ -479,7 +486,7 @@ bool NXPConfig::ConfigValueExists(Key key) if (ValidConfigKey(key)) { status = ramStorageGet(&ramDescrKeyInt, (uint8_t *) &key, sizeof(Key), 0, NULL, &sizeToRead); - found = (status == RS_ERROR_NONE && sizeToRead != 0); + found = (status == RS_ERROR_NONE && sizeToRead != 0); } return found; } @@ -493,7 +500,7 @@ CHIP_ERROR NXPConfig::FactoryResetConfig(void) } /* Reset the key string file system as it contains on data that needs to be erased when doing a factoryreset */ - FLib_MemSet((void *)&chipConfigRamStructKeyString, 0, sizeof(chipConfigRamStructKeyString)); + FLib_MemSet((void *) &chipConfigRamStructKeyString, 0, sizeof(chipConfigRamStructKeyString)); SaveStringKeysToFS(); SaveIntKeysToFS(); @@ -538,21 +545,17 @@ CHIP_ERROR NXPConfig::MapRamStorageStatus(rsError rsStatus) return err; } - -void NXPConfig::RunConfigUnitTest(void) -{ -} - +void NXPConfig::RunConfigUnitTest(void) {} void NXPConfig::RunSystemIdleTask(void) { if (isInitialized) { -#if (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_NVM_FWK) +#if (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_NVM_FWK) NvIdle(); -#elif (CHIP_PLAT_NVM_SUPPORT==CHIP_PLAT_LITTLEFS) +#elif (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_LITTLEFS) #if CHIP_PLAT_SAVE_NVM_DATA_ON_IDLE if (mt_key_int_save_in_flash) { @@ -563,7 +566,8 @@ void NXPConfig::RunSystemIdleTask(void) mt_key_int_save_in_flash = false; /* Save it in flash now */ - err_len = ramStorageSavetoFlash(mt_key_int_file_name, &chipConfigRamStructKeyInt.chipConfigRamBuffer[0], chipConfigRamStructKeyInt.chipConfigRamBufferLen); + err_len = ramStorageSavetoFlash(mt_key_int_file_name, &chipConfigRamStructKeyInt.chipConfigRamBuffer[0], + chipConfigRamStructKeyInt.chipConfigRamBufferLen); assert(err_len <= CHIP_CONFIG_RAM_BUFFER_KEY_INT_SIZE); assert(err_len >= 0); @@ -584,7 +588,8 @@ void NXPConfig::RunSystemIdleTask(void) mt_key_str_save_in_flash = false; /* Save it in flash now */ - err_len = ramStorageSavetoFlash(mt_key_str_file_name, &chipConfigRamStructKeyString.chipConfigRamBuffer[0], chipConfigRamStructKeyString.chipConfigRamBufferLen); + err_len = ramStorageSavetoFlash(mt_key_str_file_name, &chipConfigRamStructKeyString.chipConfigRamBuffer[0], + chipConfigRamStructKeyString.chipConfigRamBufferLen); assert(err_len <= CHIP_CONFIG_RAM_BUFFER_KEY_STRING_SIZE); assert(err_len >= 0); @@ -597,7 +602,6 @@ void NXPConfig::RunSystemIdleTask(void) } #endif #endif - } #if (defined(LOG_ENABLE) && (LOG_ENABLE > 0)) && ((defined LOG_ENABLE_ASYNC_MODE) && (LOG_ENABLE_ASYNC_MODE)) diff --git a/src/platform/nxp/common/NXPConfig.h b/src/platform/nxp/common/NXPConfig.h index b8d7cb95992df9..c20dc7e5071d48 100644 --- a/src/platform/nxp/common/NXPConfig.h +++ b/src/platform/nxp/common/NXPConfig.h @@ -28,16 +28,15 @@ #include "FreeRTOS.h" #include +#define CHIP_PLAT_NO_NVM 0 +#define CHIP_PLAT_NVM_FWK 1 +#define CHIP_PLAT_LITTLEFS 2 +#define CHIP_PLAT_KEY_STORAGE 3 -#define CHIP_PLAT_NO_NVM 0 -#define CHIP_PLAT_NVM_FWK 1 -#define CHIP_PLAT_LITTLEFS 2 -#define CHIP_PLAT_KEY_STORAGE 3 - -#define DEBUG_NVM 0 +#define DEBUG_NVM 0 #ifndef CHIP_PLAT_NVM_SUPPORT -#define CHIP_PLAT_NVM_SUPPORT CHIP_PLAT_NO_NVM +#define CHIP_PLAT_NVM_SUPPORT CHIP_PLAT_NO_NVM #endif #if (CHIP_PLAT_NVM_SUPPORT == CHIP_PLAT_NVM_FWK) @@ -90,16 +89,16 @@ class NXPConfig // Key definitions for well-known configuration values. // Factory config keys - static constexpr Key kConfigKey_SerialNum = config_key(kFileId_ChipFactory, 0x00); - static constexpr Key kConfigKey_UniqueId = config_key(kFileId_ChipFactory, 0x01); - static constexpr Key kConfigKey_MfrDeviceId = config_key(kFileId_ChipFactory, 0x02); - static constexpr Key kConfigKey_MfrDeviceCert = config_key(kFileId_ChipFactory, 0x03); - static constexpr Key kConfigKey_MfrDevicePrivateKey = config_key(kFileId_ChipFactory, 0x04); - static constexpr Key kConfigKey_ManufacturingDate = config_key(kFileId_ChipFactory, 0x05); - static constexpr Key kConfigKey_SetupPinCode = config_key(kFileId_ChipFactory, 0x06); - static constexpr Key kConfigKey_MfrDeviceICACerts = config_key(kFileId_ChipFactory, 0x07); - static constexpr Key kConfigKey_HardwareVersion = config_key(kFileId_ChipFactory, 0x08); - static constexpr Key kConfigKey_SetupDiscriminator = config_key(kFileId_ChipFactory, 0x09); + static constexpr Key kConfigKey_SerialNum = config_key(kFileId_ChipFactory, 0x00); + static constexpr Key kConfigKey_UniqueId = config_key(kFileId_ChipFactory, 0x01); + static constexpr Key kConfigKey_MfrDeviceId = config_key(kFileId_ChipFactory, 0x02); + static constexpr Key kConfigKey_MfrDeviceCert = config_key(kFileId_ChipFactory, 0x03); + static constexpr Key kConfigKey_MfrDevicePrivateKey = config_key(kFileId_ChipFactory, 0x04); + static constexpr Key kConfigKey_ManufacturingDate = config_key(kFileId_ChipFactory, 0x05); + static constexpr Key kConfigKey_SetupPinCode = config_key(kFileId_ChipFactory, 0x06); + static constexpr Key kConfigKey_MfrDeviceICACerts = config_key(kFileId_ChipFactory, 0x07); + static constexpr Key kConfigKey_HardwareVersion = config_key(kFileId_ChipFactory, 0x08); + static constexpr Key kConfigKey_SetupDiscriminator = config_key(kFileId_ChipFactory, 0x09); static constexpr Key kConfigKey_Spake2pIterationCount = config_key(kFileId_ChipFactory, 0x0A); static constexpr Key kConfigKey_Spake2pSalt = config_key(kFileId_ChipFactory, 0x0B); static constexpr Key kConfigKey_Spake2pVerifier = config_key(kFileId_ChipFactory, 0x0C); @@ -168,7 +167,7 @@ class NXPConfig static CHIP_ERROR ReadConfigValue(Key key, uint64_t & val); static CHIP_ERROR ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen); static CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen); - static CHIP_ERROR ReadConfigValueBin(const char* keyString, uint8_t * buf, size_t bufSize, size_t & outLen); + static CHIP_ERROR ReadConfigValueBin(const char * keyString, uint8_t * buf, size_t bufSize, size_t & outLen); static CHIP_ERROR ReadConfigValueCounter(uint8_t counterIdx, uint32_t & val); static CHIP_ERROR WriteConfigValue(Key key, bool val); static CHIP_ERROR WriteConfigValue(Key key, uint32_t val); @@ -176,7 +175,7 @@ class NXPConfig static CHIP_ERROR WriteConfigValueStr(Key key, const char * str); static CHIP_ERROR WriteConfigValueStr(Key key, const char * str, size_t strLen); static CHIP_ERROR WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen); - static CHIP_ERROR WriteConfigValueBin(const char* keyString, const uint8_t * data, size_t dataLen); + static CHIP_ERROR WriteConfigValueBin(const char * keyString, const uint8_t * data, size_t dataLen); static CHIP_ERROR WriteConfigValueCounter(uint8_t counterIdx, uint32_t val); static CHIP_ERROR ClearConfigValue(Key key); static CHIP_ERROR ClearConfigValue(const char * keyString); diff --git a/src/platform/nxp/common/NetworkCommissioningDriver.h b/src/platform/nxp/common/NetworkCommissioningDriver.h index ed32cab697a167..4e7c9f0292e47b 100644 --- a/src/platform/nxp/common/NetworkCommissioningDriver.h +++ b/src/platform/nxp/common/NetworkCommissioningDriver.h @@ -24,9 +24,10 @@ namespace DeviceLayer { namespace NetworkCommissioning { #if CHIP_DEVICE_CONFIG_ENABLE_WPA namespace { -constexpr uint8_t kMaxWiFiNetworks = 1; -constexpr uint8_t kWiFiScanNetworksTimeOutSeconds = 10; -constexpr uint8_t kWiFiConnectNetworkTimeoutSeconds = 80; // 60 seconds is DHCP_TIMEOUT from [NXP MCUXpresso SDK]/middleware/wifi_nxp/port/lwip/net.c +constexpr uint8_t kMaxWiFiNetworks = 1; +constexpr uint8_t kWiFiScanNetworksTimeOutSeconds = 10; +constexpr uint8_t kWiFiConnectNetworkTimeoutSeconds = + 80; // 60 seconds is DHCP_TIMEOUT from [NXP MCUXpresso SDK]/middleware/wifi_nxp/port/lwip/net.c } // namespace class NXPWiFiDriver final : public WiFiDriver @@ -73,12 +74,12 @@ class NXPWiFiDriver final : public WiFiDriver /* Returns the network SSID. User needs to allocate a buffer of size >= DeviceLayer::Internal::kMaxWiFiSSIDLength. * ssid - pointer to the returned SSID - */ + */ Status GetNetworkSSID(char * ssid); /* Returns the network password. User needs to allocate a buffer of size >= DeviceLayer::Internal::kMaxWiFiKeyLength. * credentials - pointer to the returned password - */ + */ Status GetNetworkPassword(char * credentials); // WiFiDriver diff --git a/src/platform/nxp/common/NetworkCommissioningWiFiDriver.cpp b/src/platform/nxp/common/NetworkCommissioningWiFiDriver.cpp index d1ad38a5598922..7863b511b227c2 100644 --- a/src/platform/nxp/common/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/nxp/common/NetworkCommissioningWiFiDriver.cpp @@ -15,11 +15,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include +#include "NetworkCommissioningDriver.h" #include #include -#include -#include "NetworkCommissioningDriver.h" #include using namespace ::chip; @@ -37,7 +37,7 @@ constexpr char kWiFiCredentialsKeyName[] = "wifi-pass"; class NXPScanResponseIterator : public Iterator { public: - NXPScanResponseIterator(const size_t size, WiFiScanResponse *responses) : mSize(size), mResponses(responses) {} + NXPScanResponseIterator(const size_t size, WiFiScanResponse * responses) : mSize(size), mResponses(responses) {} size_t Count() override { return mSize; } bool Next(WiFiScanResponse & item) override { @@ -55,7 +55,7 @@ class NXPScanResponseIterator : public Iterator private: const size_t mSize; - WiFiScanResponse *mResponses; + WiFiScanResponse * mResponses; size_t mIternum = 0; }; @@ -76,21 +76,22 @@ CHIP_ERROR NXPWiFiDriver::Init(NetworkStatusChangeCallback * networkStatusChange sizeof(mSavedNetwork.credentials), &credentialsLen); if (err != CHIP_NO_ERROR) { - ChipLogProgress(DeviceLayer, "WiFi network credentials not retrieved from persisted storage: %" CHIP_ERROR_FORMAT, err.Format()); + ChipLogProgress(DeviceLayer, "WiFi network credentials not retrieved from persisted storage: %" CHIP_ERROR_FORMAT, + err.Format()); return CHIP_NO_ERROR; } mSavedNetwork.credentialsLen = credentialsLen; mSavedNetwork.ssidLen = ssidLen; - mStagingNetwork = mSavedNetwork; - mpScanCallback = nullptr; - mpConnectCallback = nullptr; + mStagingNetwork = mSavedNetwork; + mpScanCallback = nullptr; + mpConnectCallback = nullptr; mpStatusChangeCallback = networkStatusChangeCallback; // Connect to saved network ConnectWiFiNetwork(mSavedNetwork.ssid, ssidLen, mSavedNetwork.credentials, credentialsLen); - + return err; } @@ -212,7 +213,7 @@ void NXPWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callbac mpConnectCallback = callback; err = ConnectWiFiNetwork(reinterpret_cast(mStagingNetwork.ssid), mStagingNetwork.ssidLen, - reinterpret_cast(mStagingNetwork.credentials), mStagingNetwork.credentialsLen); + reinterpret_cast(mStagingNetwork.credentials), mStagingNetwork.credentialsLen); exit: if (err != CHIP_NO_ERROR) @@ -227,8 +228,8 @@ void NXPWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callbac } /* Always inform the cluster of the network status so that in case of success, - * we have time send the response to the controller before switching to a new network. - */ + * we have time send the response to the controller before switching to a new network. + */ if (callback != nullptr) { callback->OnResult(networkingStatus, CharSpan(), 0); @@ -241,15 +242,15 @@ CHIP_ERROR NXPWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid) ChipLogProgress(DeviceLayer, "Scan for WiFi network(s) requested"); - (void)memset(&wlan_scan_param, 0, sizeof(wlan_scan_params_v2_t)); + (void) memset(&wlan_scan_param, 0, sizeof(wlan_scan_params_v2_t)); wlan_scan_param.cb = &NXPWiFiDriver::OnScanWiFiNetworkDone; if ((ssid.size() > 0) && (ssid.size() < MLAN_MAX_SSID_LENGTH)) { #ifdef CONFIG_COMBO_SCAN - (void)memcpy(wlan_scan_param.ssid[0], ssid.data(), ssid.size()); + (void) memcpy(wlan_scan_param.ssid[0], ssid.data(), ssid.size()); #else - (void)memcpy(wlan_scan_param.ssid, ssid.data(), ssid.size()); + (void) memcpy(wlan_scan_param.ssid, ssid.data(), ssid.size()); #endif } @@ -263,7 +264,7 @@ CHIP_ERROR NXPWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid) return CHIP_NO_ERROR; } -//TODO should be modified to do it in the context of the Matter stack +// TODO should be modified to do it in the context of the Matter stack int NXPWiFiDriver::OnScanWiFiNetworkDone(unsigned int count) { ChipLogProgress(DeviceLayer, "Scan for WiFi network(s) done, found: %u", count); @@ -290,7 +291,7 @@ int NXPWiFiDriver::OnScanWiFiNetworkDone(unsigned int count) return WM_SUCCESS; } - struct WiFiScanResponse *response_list = response_list_ptr.get(); + struct WiFiScanResponse * response_list = response_list_ptr.get(); int valid = 0; @@ -311,7 +312,7 @@ int NXPWiFiDriver::OnScanWiFiNetworkDone(unsigned int count) if (res.wep != 0U) { - response.security = WiFiSecurity::kWep; + response.security = WiFiSecurity::kWep; } else if (res.wpa != 0U) { @@ -341,8 +342,9 @@ int NXPWiFiDriver::OnScanWiFiNetworkDone(unsigned int count) memcpy(response.bssid, res.bssid, DeviceLayer::Internal::kWiFiBSSIDLength); - response.channel = (uint16_t)res.channel; - response.wiFiBand = chip::DeviceLayer::NetworkCommissioning::WiFiBand::k2g4; // TODO 5 GHz also possible, but results don't show this information + response.channel = (uint16_t) res.channel; + response.wiFiBand = chip::DeviceLayer::NetworkCommissioning::WiFiBand::k2g4; // TODO 5 GHz also possible, but results don't + // show this information response.rssi = -static_cast(res.rssi); response_list[valid] = response; @@ -351,7 +353,7 @@ int NXPWiFiDriver::OnScanWiFiNetworkDone(unsigned int count) } if (CHIP_NO_ERROR == DeviceLayer::SystemLayer().ScheduleLambda([valid, response_list]() { - std::unique_ptr auto_free(response_list); + std::unique_ptr auto_free(response_list); NXPScanResponseIterator iter(valid, response_list); if (GetInstance().mpScanCallback) { diff --git a/src/platform/nxp/common/OTAImageProcessorImpl.cpp b/src/platform/nxp/common/OTAImageProcessorImpl.cpp index 3b0d34a05ced0b..9844e099b1b2e2 100644 --- a/src/platform/nxp/common/OTAImageProcessorImpl.cpp +++ b/src/platform/nxp/common/OTAImageProcessorImpl.cpp @@ -22,8 +22,6 @@ #include "OTAImageProcessorImpl.h" - - namespace chip { CHIP_ERROR OTAImageProcessorImpl::PrepareDownload() @@ -124,7 +122,7 @@ void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) ChipLogError(SoftwareUpdate, "mDownloader is null"); return; } - + /* Initialize OTA External Storage Memory */ if (OTA_SelectExternalStoragePartition() != gOtaSuccess_c) { @@ -138,7 +136,7 @@ void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) OTA_SetConfig(&OTAconfig); /* Initialize OTA service for posted operations */ - if (gOtaSuccess_c == OTA_ServiceInit(&imageProcessor->mPostedOperationsStorage[0], NB_PENDING_TRANSACTIONS*TRANSACTION_SZ)) + if (gOtaSuccess_c == OTA_ServiceInit(&imageProcessor->mPostedOperationsStorage[0], NB_PENDING_TRANSACTIONS * TRANSACTION_SZ)) { imageProcessor->mHeaderParser.Init(); imageProcessor->mDownloader->OnPreparedForDownload(CHIP_NO_ERROR); @@ -172,11 +170,11 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) /* Start the OTA Image writing session */ if (gOtaSuccess_c == OTA_StartImage(imageProcessor->mParams.totalFileBytes)) { - uint8_t *ptr = static_cast(chip::Platform::MemoryAlloc(block.size())); + uint8_t * ptr = static_cast(chip::Platform::MemoryAlloc(block.size())); if (ptr != nullptr) { MutableByteSpan mutableBlock = MutableByteSpan(ptr, block.size()); - error = CopySpanToMutableSpan(block, mutableBlock); + error = CopySpanToMutableSpan(block, mutableBlock); if (error == CHIP_NO_ERROR) { @@ -203,19 +201,20 @@ void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) return; } - if (imageProcessor->mBlock.data()!=nullptr) + if (imageProcessor->mBlock.data() != nullptr) { ChipLogProgress(SoftwareUpdate, "OTA Block received, preparing to write in flash..."); } - /* + /* * Prior to writing in flash the block received, we must erase enough space to store it. * OTA_MakeHeadRoomForNextBlock and OTA_PushImageChunk post erase / write transactions to the queue, * these operations are later processed in the context of the idle task. * After the flash erase transaction is processed, the HandleBlockEraseComplete callback * requests the next OTA block to the provider. - */ - if (gOtaSuccess_c == OTA_MakeHeadRoomForNextBlock(imageProcessor->mBlock.size(), HandleBlockEraseComplete, (uint32_t) imageProcessor)) + */ + if (gOtaSuccess_c == + OTA_MakeHeadRoomForNextBlock(imageProcessor->mBlock.size(), HandleBlockEraseComplete, (uint32_t) imageProcessor)) { /* Send block to be written in external flash */ if (gOtaSuccess_c == @@ -237,7 +236,7 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessHeader(ByteSpan & block) ReturnErrorOnFailure(error); mParams.totalFileBytes = header.mPayloadSize; - mSoftwareVersion = header.mSoftwareVersion; + mSoftwareVersion = header.mSoftwareVersion; mHeaderParser.Clear(); return CHIP_NO_ERROR; @@ -245,7 +244,7 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessHeader(ByteSpan & block) void OTAImageProcessorImpl::HandleBlockEraseComplete(uint32_t param) { - intptr_t context = (intptr_t) param; + intptr_t context = (intptr_t) param; DeviceLayer::PlatformMgr().ScheduleWork(TriggerNewRequestForData, reinterpret_cast(context)); } @@ -272,27 +271,27 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) return; } - /* - * Set the new image state as ready for test, this would allow the bootloader to perform - * the upgrade at next reboot. - */ + /* + * Set the new image state as ready for test, this would allow the bootloader to perform + * the upgrade at next reboot. + */ OTA_SetNewImageFlag(); - + ChipLogProgress(SoftwareUpdate, "Update ready for test"); - /* - * Restart the device in order to apply the update image. - * This should be done with a delay so the device has enough time to send - * the state-transition event when applying the update. - */ + /* + * Restart the device in order to apply the update image. + * This should be done with a delay so the device has enough time to send + * the state-transition event when applying the update. + */ ChipLogProgress(SoftwareUpdate, "Restarting device in 5 seconds ..."); - DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(5*1000), HandleRestart, nullptr); + DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(5 * 1000), HandleRestart, nullptr); - /* + /* * At next boot time, the bootloader will test + validate new image. * If validated, the image is marked "ok" at run time and the update state is switched to permanent. - * If the image is not valid, the bootloader will revert back to the primary application. - */ + * If the image is not valid, the bootloader will revert back to the primary application. + */ } void OTAImageProcessorImpl::HandleRestart(System::Layer * aLayer, void * context) @@ -355,4 +354,4 @@ CHIP_ERROR OTAImageProcessorImpl::ReleaseBlock() return CHIP_NO_ERROR; } -}// namespace chip +} // namespace chip diff --git a/src/platform/nxp/common/OTAImageProcessorImpl.h b/src/platform/nxp/common/OTAImageProcessorImpl.h index b35ecef6ad3fae..5531378ca7fa16 100644 --- a/src/platform/nxp/common/OTAImageProcessorImpl.h +++ b/src/platform/nxp/common/OTAImageProcessorImpl.h @@ -30,7 +30,6 @@ #define NB_PENDING_TRANSACTIONS 11 #define TRANSACTION_SZ gOtaTransactionSz_d - namespace chip { class OTAImageProcessorImpl : public OTAImageProcessorInterface @@ -79,7 +78,7 @@ class OTAImageProcessorImpl : public OTAImageProcessorInterface const char * mImageFile = nullptr; /* Buffer used for transaction storage */ - uint8_t mPostedOperationsStorage[NB_PENDING_TRANSACTIONS*TRANSACTION_SZ]; + uint8_t mPostedOperationsStorage[NB_PENDING_TRANSACTIONS * TRANSACTION_SZ]; }; } // namespace chip diff --git a/src/platform/nxp/common/PlatformManagerImpl.h b/src/platform/nxp/common/PlatformManagerImpl.h index be5296f1a9e461..86086682342ce9 100644 --- a/src/platform/nxp/common/PlatformManagerImpl.h +++ b/src/platform/nxp/common/PlatformManagerImpl.h @@ -56,7 +56,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener static void SaveSettings(void); void StopBLEConnectivity(void); CHIP_ERROR ServiceInit(void); - + System::Clock::Timestamp GetStartTime() { return mStartTime; } private: diff --git a/src/platform/nxp/common/SystemNXPPlatformDefaultConfig.h b/src/platform/nxp/common/SystemNXPPlatformDefaultConfig.h index a018ed4fdd6550..cba7b8e4742e44 100644 --- a/src/platform/nxp/common/SystemNXPPlatformDefaultConfig.h +++ b/src/platform/nxp/common/SystemNXPPlatformDefaultConfig.h @@ -36,7 +36,6 @@ struct ChipDeviceEvent; // ==================== Platform Adaptations ==================== - #ifndef CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_EVENT_FUNCTIONS #define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_EVENT_FUNCTIONS 1 #endif // CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_EVENT_FUNCTIONS diff --git a/src/platform/nxp/common/ThreadStackManagerImpl.cpp b/src/platform/nxp/common/ThreadStackManagerImpl.cpp index c146b1c7168e3e..c7f8ce7a5f0538 100644 --- a/src/platform/nxp/common/ThreadStackManagerImpl.cpp +++ b/src/platform/nxp/common/ThreadStackManagerImpl.cpp @@ -42,15 +42,13 @@ extern "C" CHIP_ERROR AppMatterCli_RegisterCommands(void); /* -* Empty content for otPlatCliUartProcess, as the openthread CLI -* is managed by the matter cli if enabled. -* An empty content is required as system.c from ot_nxp is always -* calling this function. This could be removed once system.c will -* be reworked to support more dynamically the openthread cli. -*/ -extern "C" void otPlatCliUartProcess(void) -{ -} + * Empty content for otPlatCliUartProcess, as the openthread CLI + * is managed by the matter cli if enabled. + * An empty content is required as system.c from ot_nxp is always + * calling this function. This could be removed once system.c will + * be reworked to support more dynamically the openthread cli. + */ +extern "C" void otPlatCliUartProcess(void) {} namespace chip { namespace DeviceLayer { @@ -64,14 +62,14 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack(void) CHIP_ERROR err = CHIP_NO_ERROR; /* Initialize the OpenThread Alarm module to make sure that if calling otInstance, - * it can schedule events - */ + * it can schedule events + */ otPlatAlarmInit(); /* Make sure to initialize the Matter CLI which will include the ot-cli first. - * In fact it is mandatory to enable first the ot-cli before initializing the Matter openthread layer - * which would modify some contexts of the openthread instance. - */ + * In fact it is mandatory to enable first the ot-cli before initializing the Matter openthread layer + * which would modify some contexts of the openthread instance. + */ AppMatterCli_RegisterCommands(); // Initialize the generic implementation base classes. diff --git a/src/platform/nxp/common/ble_zephyr/BLEManagerImpl.h b/src/platform/nxp/common/ble_zephyr/BLEManagerImpl.h index 4d47bad43e0a6a..411392aa3c6a8c 100644 --- a/src/platform/nxp/common/ble_zephyr/BLEManagerImpl.h +++ b/src/platform/nxp/common/ble_zephyr/BLEManagerImpl.h @@ -25,7 +25,7 @@ #pragma once -#include -#include #include #include +#include +#include diff --git a/src/platform/nxp/common/factory_data/FactoryDataProvider.cpp b/src/platform/nxp/common/factory_data/FactoryDataProvider.cpp index 818f633d2b0262..5991a81d703ac8 100644 --- a/src/platform/nxp/common/factory_data/FactoryDataProvider.cpp +++ b/src/platform/nxp/common/factory_data/FactoryDataProvider.cpp @@ -16,7 +16,6 @@ * limitations under the License. */ -#include #include #include #include @@ -46,9 +45,9 @@ #if FACTORY_DATA_PROVIDER_LOG #include "fsl_debug_console.h" -#define FACTORY_DATA_PROVIDER_PRINTF(...) \ - PRINTF("[%s] ", __FUNCTION__); \ - PRINTF(__VA_ARGS__); \ +#define FACTORY_DATA_PROVIDER_PRINTF(...) \ + PRINTF("[%s] ", __FUNCTION__); \ + PRINTF(__VA_ARGS__); \ PRINTF("\n\r"); #else #define FACTORY_DATA_PROVIDER_PRINTF(...) @@ -60,14 +59,15 @@ using namespace ::chip::Crypto; namespace chip { namespace DeviceLayer { -CHIP_ERROR FactoryDataProvider::SearchForId(uint8_t searchedType, uint8_t *pBuf, size_t bufLength, uint16_t &length, uint32_t *contentAddr) +CHIP_ERROR FactoryDataProvider::SearchForId(uint8_t searchedType, uint8_t * pBuf, size_t bufLength, uint16_t & length, + uint32_t * contentAddr) { return static_cast(this)->SearchForId(searchedType, pBuf, bufLength, length, contentAddr); } CHIP_ERROR FactoryDataProvider::Init(void) { - return static_cast(this)->Init(); + return static_cast(this)->Init(); } CHIP_ERROR FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & outBuffer) @@ -110,12 +110,13 @@ CHIP_ERROR FactoryDataProvider::GetSetupDiscriminator(uint16_t & setupDiscrimina { uint16_t discriminatorLen = 0; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kDiscriminatorId, (uint8_t *)&setupDiscriminator, sizeof(setupDiscriminator), discriminatorLen)); + ReturnErrorOnFailure(SearchForId(FactoryDataId::kDiscriminatorId, (uint8_t *) &setupDiscriminator, sizeof(setupDiscriminator), + discriminatorLen)); return CHIP_NO_ERROR; } -CHIP_ERROR FactoryDataProvider:: SetSetupDiscriminator(uint16_t setupDiscriminator) +CHIP_ERROR FactoryDataProvider::SetSetupDiscriminator(uint16_t setupDiscriminator) { return CHIP_ERROR_NOT_IMPLEMENTED; } @@ -132,11 +133,11 @@ CHIP_ERROR FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf) { static constexpr size_t kSpake2pSalt_MaxBase64Len = BASE64_ENCODED_LEN(chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length) + 1; uint8_t saltB64[kSpake2pSalt_MaxBase64Len]; - uint16_t saltB64Len = 0; + uint16_t saltB64Len = 0; ReturnErrorOnFailure(SearchForId(FactoryDataId::kSaltId, &saltB64[0], sizeof(saltB64), saltB64Len)); - size_t saltLen = chip::Base64Decode32((char *)saltB64, saltB64Len, reinterpret_cast(saltB64)); + size_t saltLen = chip::Base64Decode32((char *) saltB64, saltB64Len, reinterpret_cast(saltB64)); ReturnErrorCodeIf(saltLen > saltBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(saltBuf.data(), saltB64, saltLen); @@ -147,11 +148,11 @@ CHIP_ERROR FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf) CHIP_ERROR FactoryDataProvider::GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) { - static constexpr size_t kSpake2pSerializedVerifier_MaxBase64Len = + static constexpr size_t kSpake2pSerializedVerifier_MaxBase64Len = BASE64_ENCODED_LEN(chip::Crypto::kSpake2p_VerifierSerialized_Length) + 1; uint8_t verifierB64[kSpake2pSerializedVerifier_MaxBase64Len]; - uint16_t verifierB64Len = 0; - + uint16_t verifierB64Len = 0; + ReturnErrorOnFailure(SearchForId(FactoryDataId::kVerifierId, &verifierB64[0], sizeof(verifierB64), verifierB64Len)); verifierLen = chip::Base64Decode32((char *) verifierB64, verifierB64Len, reinterpret_cast(verifierB64)); @@ -178,7 +179,7 @@ CHIP_ERROR FactoryDataProvider::SetSetupPasscode(uint32_t setupPasscode) CHIP_ERROR FactoryDataProvider::GetVendorName(char * buf, size_t bufSize) { uint16_t length = 0; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kVendorNameId, (uint8_t *)buf, bufSize, length)); + ReturnErrorOnFailure(SearchForId(FactoryDataId::kVendorNameId, (uint8_t *) buf, bufSize, length)); buf[length] = '\0'; return CHIP_NO_ERROR; @@ -195,7 +196,7 @@ CHIP_ERROR FactoryDataProvider::GetVendorId(uint16_t & vendorId) CHIP_ERROR FactoryDataProvider::GetProductName(char * buf, size_t bufSize) { uint16_t length = 0; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kProductNameId, (uint8_t *)buf, bufSize, length)); + ReturnErrorOnFailure(SearchForId(FactoryDataId::kProductNameId, (uint8_t *) buf, bufSize, length)); buf[length] = '\0'; return CHIP_NO_ERROR; @@ -212,7 +213,7 @@ CHIP_ERROR FactoryDataProvider::GetProductId(uint16_t & productId) CHIP_ERROR FactoryDataProvider::GetPartNumber(char * buf, size_t bufSize) { uint16_t length = 0; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kPartNumber, (uint8_t *)buf, bufSize, length)); + ReturnErrorOnFailure(SearchForId(FactoryDataId::kPartNumber, (uint8_t *) buf, bufSize, length)); buf[length] = '\0'; return CHIP_NO_ERROR; @@ -221,7 +222,7 @@ CHIP_ERROR FactoryDataProvider::GetPartNumber(char * buf, size_t bufSize) CHIP_ERROR FactoryDataProvider::GetProductURL(char * buf, size_t bufSize) { uint16_t length = 0; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kProductURL, (uint8_t *)buf, bufSize, length)); + ReturnErrorOnFailure(SearchForId(FactoryDataId::kProductURL, (uint8_t *) buf, bufSize, length)); buf[length] = '\0'; return CHIP_NO_ERROR; @@ -230,7 +231,7 @@ CHIP_ERROR FactoryDataProvider::GetProductURL(char * buf, size_t bufSize) CHIP_ERROR FactoryDataProvider::GetProductLabel(char * buf, size_t bufSize) { uint16_t length = 0; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kProductLabel, (uint8_t *)buf, bufSize, length)); + ReturnErrorOnFailure(SearchForId(FactoryDataId::kProductLabel, (uint8_t *) buf, bufSize, length)); buf[length] = '\0'; return CHIP_NO_ERROR; @@ -239,7 +240,7 @@ CHIP_ERROR FactoryDataProvider::GetProductLabel(char * buf, size_t bufSize) CHIP_ERROR FactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize) { uint16_t length = 0; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kSerialNumberId, (uint8_t *)buf, bufSize, length)); + ReturnErrorOnFailure(SearchForId(FactoryDataId::kSerialNumberId, (uint8_t *) buf, bufSize, length)); buf[length] = '\0'; return CHIP_NO_ERROR; @@ -250,12 +251,12 @@ CHIP_ERROR FactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & uint16_t length = 0; uint8_t date[ConfigurationManager::kMaxManufacturingDateLength]; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kManufacturingDateId, date, ConfigurationManager::kMaxManufacturingDateLength, length)); + ReturnErrorOnFailure( + SearchForId(FactoryDataId::kManufacturingDateId, date, ConfigurationManager::kMaxManufacturingDateLength, length)); date[length] = '\0'; - if (length == 10 && isdigit(date[0]) && isdigit(date[1]) && isdigit(date[2]) && - isdigit(date[3]) && date[4] == '-' && isdigit(date[5]) && isdigit(date[6]) && - date[7] == '-' && isdigit(date[8]) && isdigit(date[9])) + if (length == 10 && isdigit(date[0]) && isdigit(date[1]) && isdigit(date[2]) && isdigit(date[3]) && date[4] == '-' && + isdigit(date[5]) && isdigit(date[6]) && date[7] == '-' && isdigit(date[8]) && isdigit(date[9])) { year = 1000 * (date[0] - '0') + 100 * (date[1] - '0') + 10 * (date[2] - '0') + date[3] - '0'; month = 10 * (date[5] - '0') + date[6] - '0'; @@ -274,8 +275,7 @@ CHIP_ERROR FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion) { uint16_t length = 0; ReturnErrorOnFailure( - SearchForId(FactoryDataId::kHardwareVersionId, (uint8_t *) &hardwareVersion, sizeof(hardwareVersion), length) - ); + SearchForId(FactoryDataId::kHardwareVersionId, (uint8_t *) &hardwareVersion, sizeof(hardwareVersion), length)); return CHIP_NO_ERROR; } @@ -283,7 +283,7 @@ CHIP_ERROR FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion) CHIP_ERROR FactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize) { uint16_t length = 0; - ReturnErrorOnFailure(SearchForId(FactoryDataId::kHardwareVersionStrId, (uint8_t *)buf, bufSize, length)); + ReturnErrorOnFailure(SearchForId(FactoryDataId::kHardwareVersionStrId, (uint8_t *) buf, bufSize, length)); buf[length] = '\0'; return CHIP_NO_ERROR; @@ -296,7 +296,7 @@ CHIP_ERROR FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & un static_assert(ConfigurationManager::kRotatingDeviceIDUniqueIDLength >= ConfigurationManager::kMinRotatingDeviceIDUniqueIDLength, "Length of unique ID for rotating device ID is smaller than minimum."); uint16_t uniqueIdLen = 0; - err = SearchForId(FactoryDataId::kUniqueId, (uint8_t *) uniqueIdSpan.data(), uniqueIdSpan.size(), uniqueIdLen); + err = SearchForId(FactoryDataId::kUniqueId, (uint8_t *) uniqueIdSpan.data(), uniqueIdSpan.size(), uniqueIdLen); #if defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) if (err != CHIP_NO_ERROR) { @@ -305,7 +305,7 @@ CHIP_ERROR FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & un ReturnErrorCodeIf(sizeof(uniqueId) > uniqueIdSpan.size(), CHIP_ERROR_BUFFER_TOO_SMALL); memcpy(uniqueIdSpan.data(), uniqueId, sizeof(uniqueId)); uniqueIdLen = sizeof(uniqueId); - err = CHIP_NO_ERROR; + err = CHIP_NO_ERROR; } #endif // CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID ReturnErrorOnFailure(err); @@ -319,9 +319,9 @@ void FactoryDataProvider::FactoryDataProviderRunTests(void) { #if FACTORY_DATA_PROVIDER_RUN_TESTS static const ByteSpan kExpectedDacPublicKey = DevelopmentCerts::kDacPublicKey; - constexpr uint8_t kExampleDigest[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, - 0x13, 0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, - 0x26, 0x27, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 }; + constexpr uint8_t kExampleDigest[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, + 0x13, 0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, + 0x26, 0x27, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 }; // Sign using the example attestation private key P256ECDSASignature da_signature; @@ -329,7 +329,7 @@ void FactoryDataProvider::FactoryDataProviderRunTests(void) CHIP_ERROR err = SignWithDeviceAttestationKey(ByteSpan{ kExampleDigest }, out_sig_span); assert(err == CHIP_NO_ERROR); - assert( out_sig_span.size() == kP256_ECDSA_Signature_Length_Raw); + assert(out_sig_span.size() == kP256_ECDSA_Signature_Length_Raw); da_signature.SetLength(out_sig_span.size()); // Get DAC from the provider @@ -338,18 +338,18 @@ void FactoryDataProvider::FactoryDataProviderRunTests(void) memset(dac_cert_span.data(), 0, dac_cert_span.size()); err = GetDeviceAttestationCert(dac_cert_span); - assert( err == CHIP_NO_ERROR); + assert(err == CHIP_NO_ERROR); // Extract public key from DAC, prior to signature verification P256PublicKey dac_public_key; err = ExtractPubkeyFromX509Cert(dac_cert_span, dac_public_key); - assert( err == CHIP_NO_ERROR); - assert( dac_public_key.Length() == kExpectedDacPublicKey.size()); - assert( 0 == memcmp(dac_public_key.ConstBytes(), kExpectedDacPublicKey.data(), kExpectedDacPublicKey.size())); + assert(err == CHIP_NO_ERROR); + assert(dac_public_key.Length() == kExpectedDacPublicKey.size()); + assert(0 == memcmp(dac_public_key.ConstBytes(), kExpectedDacPublicKey.data(), kExpectedDacPublicKey.size())); // Verify round trip signature err = dac_public_key.ECDSA_validate_msg_signature(&kExampleDigest[0], sizeof(kExampleDigest), da_signature); - assert( err == CHIP_NO_ERROR); + assert(err == CHIP_NO_ERROR); #endif } diff --git a/src/platform/nxp/common/factory_data/FactoryDataProvider.h b/src/platform/nxp/common/factory_data/FactoryDataProvider.h index 5c124431ea5293..d8153b47a82792 100644 --- a/src/platform/nxp/common/factory_data/FactoryDataProvider.h +++ b/src/platform/nxp/common/factory_data/FactoryDataProvider.h @@ -17,11 +17,11 @@ */ #pragma once +#include #include #include #include #include -#include namespace chip { namespace DeviceLayer { @@ -39,8 +39,12 @@ class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentia using ImplClass = ::chip::DeviceLayer::FactoryDataProviderImpl; public: - - enum EncryptionMode {encrypt_none = 0U, encrypt_ecb = 1U, encrypt_cbc = 2U}; + enum EncryptionMode + { + encrypt_none = 0U, + encrypt_ecb = 1U, + encrypt_cbc = 2U + }; // Default factory data IDs enum FactoryDataId @@ -106,7 +110,8 @@ class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentia protected: // Methods to be implemented by impl class delegate. - CHIP_ERROR SearchForId(uint8_t searchedType, uint8_t *pBuf, size_t bufLength, uint16_t &length, uint32_t *contentAddr=NULL); + CHIP_ERROR SearchForId(uint8_t searchedType, uint8_t * pBuf, size_t bufLength, uint16_t & length, + uint32_t * contentAddr = NULL); CHIP_ERROR SignWithDacKey(const ByteSpan & digestToSign, MutableByteSpan & outSignBuffer); }; diff --git a/src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.cpp b/src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.cpp index 112d412fa32276..7da95e29b4e027 100644 --- a/src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.cpp +++ b/src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.cpp @@ -24,12 +24,13 @@ namespace DeviceLayer { FactoryDataProviderImpl FactoryDataProviderImpl::sInstance; -CHIP_ERROR FactoryDataProviderImpl::SearchForId(uint8_t searchedType, uint8_t *pBuf, size_t bufLength, uint16_t &length, uint32_t *contentAddr) +CHIP_ERROR FactoryDataProviderImpl::SearchForId(uint8_t searchedType, uint8_t * pBuf, size_t bufLength, uint16_t & length, + uint32_t * contentAddr) { - CHIP_ERROR err = CHIP_ERROR_NOT_FOUND; + CHIP_ERROR err = CHIP_ERROR_NOT_FOUND; uint32_t readLen = 0; - uint8_t *ramBufferAddr = FDP_SearchForId(searchedType, pBuf, bufLength, &readLen); + uint8_t * ramBufferAddr = FDP_SearchForId(searchedType, pBuf, bufLength, &readLen); if (ramBufferAddr != NULL) { @@ -57,7 +58,7 @@ CHIP_ERROR FactoryDataProviderImpl::SignWithDacKey(const ByteSpan & digestToSign uint16_t certificateSize = 0; uint32_t certificateAddr; ReturnErrorOnFailure(SearchForId(FactoryDataId::kDacCertificateId, NULL, 0, certificateSize, &certificateAddr)); - MutableByteSpan dacCertSpan((uint8_t *)certificateAddr, certificateSize); + MutableByteSpan dacCertSpan((uint8_t *) certificateAddr, certificateSize); /* Extract Public Key of DAC certificate from itself */ ReturnErrorOnFailure(Crypto::ExtractPubkeyFromX509Cert(dacCertSpan, dacPublicKey)); @@ -66,9 +67,10 @@ CHIP_ERROR FactoryDataProviderImpl::SignWithDacKey(const ByteSpan & digestToSign uint16_t keySize = 0; uint32_t keyAddr; ReturnErrorOnFailure(SearchForId(FactoryDataId::kDacPrivateKeyId, NULL, 0, keySize, &keyAddr)); - MutableByteSpan dacPrivateKeySpan((uint8_t *)keyAddr, keySize); + MutableByteSpan dacPrivateKeySpan((uint8_t *) keyAddr, keySize); - ReturnErrorOnFailure(LoadKeypairFromRaw(ByteSpan(dacPrivateKeySpan.data(), dacPrivateKeySpan.size()), ByteSpan(dacPublicKey.Bytes(), dacPublicKey.Length()), keypair)); + ReturnErrorOnFailure(LoadKeypairFromRaw(ByteSpan(dacPrivateKeySpan.data(), dacPrivateKeySpan.size()), + ByteSpan(dacPublicKey.Bytes(), dacPublicKey.Length()), keypair)); ReturnErrorOnFailure(keypair.ECDSA_sign_msg(digestToSign.data(), digestToSign.size(), signature)); @@ -87,9 +89,9 @@ CHIP_ERROR FactoryDataProviderImpl::LoadKeypairFromRaw(ByteSpan privateKey, Byte CHIP_ERROR FactoryDataProviderImpl::Init(void) { /* - * Currently the fwk_factory_data_provider module supports only ecb mode. - * Therefore return an error if encrypt mode is not ecb - */ + * Currently the fwk_factory_data_provider module supports only ecb mode. + * Therefore return an error if encrypt mode is not ecb + */ if (pAesKey == NULL || encryptMode != encrypt_ecb) { return CHIP_ERROR_INVALID_ARGUMENT; @@ -103,13 +105,13 @@ CHIP_ERROR FactoryDataProviderImpl::Init(void) return CHIP_NO_ERROR; } -CHIP_ERROR FactoryDataProviderImpl::SetAes128Key(const uint8_t *keyAes128) +CHIP_ERROR FactoryDataProviderImpl::SetAes128Key(const uint8_t * keyAes128) { CHIP_ERROR error = CHIP_ERROR_INVALID_ARGUMENT; if (keyAes128 != nullptr) { pAesKey = keyAes128; - error = CHIP_NO_ERROR; + error = CHIP_NO_ERROR; } return error; } @@ -119,13 +121,13 @@ CHIP_ERROR FactoryDataProviderImpl::SetEncryptionMode(EncryptionMode mode) CHIP_ERROR error = CHIP_ERROR_INVALID_ARGUMENT; /* - * Currently the fwk_factory_data_provider module supports only ecb mode. - * Therefore return an error if encrypt mode is not ecb - */ + * Currently the fwk_factory_data_provider module supports only ecb mode. + * Therefore return an error if encrypt mode is not ecb + */ if (mode == encrypt_ecb) { encryptMode = mode; - error = CHIP_NO_ERROR; + error = CHIP_NO_ERROR; } return error; } diff --git a/src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.h b/src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.h index b41182c9c6e192..55965b9843fdc7 100644 --- a/src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.h +++ b/src/platform/nxp/common/factory_data/FactoryDataProviderFwkImpl.h @@ -34,20 +34,20 @@ namespace DeviceLayer { class FactoryDataProviderImpl : public FactoryDataProvider { public: - static FactoryDataProviderImpl sInstance; CHIP_ERROR Init(void); - CHIP_ERROR SearchForId(uint8_t searchedType, uint8_t *pBuf, size_t bufLength, uint16_t &length, uint32_t *contentAddr=NULL); + CHIP_ERROR SearchForId(uint8_t searchedType, uint8_t * pBuf, size_t bufLength, uint16_t & length, + uint32_t * contentAddr = NULL); CHIP_ERROR SignWithDacKey(const ByteSpan & digestToSign, MutableByteSpan & outSignBuffer); - CHIP_ERROR SetAes128Key(const uint8_t *keyAes128); + CHIP_ERROR SetAes128Key(const uint8_t * keyAes128); CHIP_ERROR SetEncryptionMode(EncryptionMode mode); private: CHIP_ERROR LoadKeypairFromRaw(ByteSpan privateKey, ByteSpan publicKey, Crypto::P256Keypair & keypair); - const uint8_t *pAesKey = nullptr; + const uint8_t * pAesKey = nullptr; EncryptionMode encryptMode = encrypt_ecb; }; diff --git a/src/platform/nxp/rt/rw61x/BlePlatformConfig.h b/src/platform/nxp/rt/rw61x/BlePlatformConfig.h index 4c0336fa6e416b..fdd79a53501f12 100644 --- a/src/platform/nxp/rt/rw61x/BlePlatformConfig.h +++ b/src/platform/nxp/rt/rw61x/BlePlatformConfig.h @@ -25,7 +25,6 @@ #pragma once - // ==================== Platform Adaptations ==================== /* Default NXP Platform adaptations are used */ @@ -34,6 +33,5 @@ /* Default NXP Platform configuration overrides are used */ - // Include default nxp platform configurations #include "platform/nxp/common/ble_zephyr/BleNXPPlatformDefaultConfig.h" diff --git a/src/platform/nxp/rt/rw61x/CHIPDevicePlatformConfig.h b/src/platform/nxp/rt/rw61x/CHIPDevicePlatformConfig.h index 00a026428a89c9..f2fe91b032f2af 100644 --- a/src/platform/nxp/rt/rw61x/CHIPDevicePlatformConfig.h +++ b/src/platform/nxp/rt/rw61x/CHIPDevicePlatformConfig.h @@ -26,7 +26,6 @@ #pragma once - // ==================== Platform Adaptations ==================== /* Default NXP Platform adaptations are used */ @@ -36,11 +35,9 @@ // These are configuration options that are unique to the NXP platform. // These can be overridden by the application as needed. - // ========== Platform-specific Configuration Overrides ========= /* Default NXP Platform configuration overrides are used */ - // Include default nxp platform configurations #include "platform/nxp/common/CHIPDeviceNXPPlatformDefaultConfig.h" \ No newline at end of file diff --git a/src/platform/nxp/rt/rw61x/CHIPPlatformConfig.h b/src/platform/nxp/rt/rw61x/CHIPPlatformConfig.h index b6e25a193e1c29..87889cb940f5da 100644 --- a/src/platform/nxp/rt/rw61x/CHIPPlatformConfig.h +++ b/src/platform/nxp/rt/rw61x/CHIPPlatformConfig.h @@ -38,7 +38,7 @@ // ==================== General Configuration Overrides ==================== -/* Default NXP Platform general configuration overrides are used */ +/* Default NXP Platform general configuration overrides are used */ /* For now on RW610, due to the current file system implementation only 5 fabrics are supported */ #define CHIP_CONFIG_MAX_FABRICS 5 diff --git a/src/platform/nxp/rt/rw61x/PlatformManagerImpl.cpp b/src/platform/nxp/rt/rw61x/PlatformManagerImpl.cpp index 328b22f27734e0..fb5b900f345b5d 100644 --- a/src/platform/nxp/rt/rw61x/PlatformManagerImpl.cpp +++ b/src/platform/nxp/rt/rw61x/PlatformManagerImpl.cpp @@ -26,15 +26,15 @@ /* this file behaves like a config.h, comes first */ #include -#include -#include -#include -#include -#include #include "DiagnosticDataProviderImpl.h" #include "fsl_adapter_rng.h" #include "fsl_os_abstraction.h" #include "fwk_platform_coex.h" +#include +#include +#include +#include +#include #include @@ -45,8 +45,8 @@ #endif #if CHIP_DEVICE_CONFIG_ENABLE_THREAD -#include "ot_platform_common.h" #include "fwk_platform_ot.h" +#include "ot_platform_common.h" #endif extern "C" void BOARD_InitHardware(void); @@ -81,7 +81,7 @@ extern "C" void vApplicationIdleHook(void) } #endif -extern "C" void __wrap_exit (int __status) +extern "C" void __wrap_exit(int __status) { ChipLogError(DeviceLayer, "======> error exit function !!!"); assert(0); @@ -90,7 +90,7 @@ extern "C" void __wrap_exit (int __status) /* wlan_event_callback should be defined here because it is * referenced in wlan.c but only defined in main.c of sdk examples */ #if CHIP_DEVICE_CONFIG_ENABLE_WPA -extern "C" int wlan_event_callback(enum wlan_event_reason reason, void *data) +extern "C" int wlan_event_callback(enum wlan_event_reason reason, void * data) { return 0; } @@ -112,7 +112,7 @@ CHIP_ERROR PlatformManagerImpl::ServiceInit(void) status_t status; hal_rng_status_t rngStatus; CHIP_ERROR chipRes = CHIP_NO_ERROR; - + status = CRYPTO_InitHardware(); if (status != 0) @@ -132,7 +132,7 @@ CHIP_ERROR PlatformManagerImpl::WiFiInterfaceInit(void) ChipLogProgress(DeviceLayer, "Initialize WLAN"); - wifi_status = wlan_init((uint8_t*)WIFI_FW_BIN_ADDRESS, wlan_fw_bin_len); + wifi_status = wlan_init((uint8_t *) WIFI_FW_BIN_ADDRESS, wlan_fw_bin_len); if (wifi_status != WM_SUCCESS) { ChipLogError(DeviceLayer, "WLAN initialization failed"); @@ -158,7 +158,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) // Initialize the configuration system. err = Internal::NXPConfig::Init(); SuccessOrExit(err); - + SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); @@ -170,11 +170,11 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) tcpip_init(NULL, NULL); #endif - /* + /* * Initialize controllers here before initializing BLE/OT/WIFI, - * this will load the firmware in CPU1/CPU2 depending on the + * this will load the firmware in CPU1/CPU2 depending on the * connectivity used - */ + */ #if CHIP_DEVICE_CONFIG_ENABLE_THREAD controllerMask |= conn802_15_4_c; @@ -220,7 +220,9 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) if (err != CHIP_NO_ERROR) { - ChipLogProgress(DeviceLayer, "Wi-Fi module initialization failed. Make sure the Wi-Fi/BLE module is properly configured and connected with the board and start again!"); + ChipLogProgress(DeviceLayer, + "Wi-Fi module initialization failed. Make sure the Wi-Fi/BLE module is properly configured and connected " + "with the board and start again!"); chipDie(); } ChipLogProgress(DeviceLayer, "Wi-Fi module initialization done."); @@ -258,9 +260,9 @@ void PlatformManagerImpl::IdleHook(void) if (isResetScheduled) { /* - * In case a reset in IDLE has been scheduled - * Disable IRQs so that the idle task won't be preempted until the reset - */ + * In case a reset in IDLE has been scheduled + * Disable IRQs so that the idle task won't be preempted until the reset + */ OSA_InterruptDisable(); } @@ -276,9 +278,9 @@ void PlatformManagerImpl::IdleHook(void) #endif /* - * In case a reset in idle operation has been posted, - * reset the device after having run the idle function - */ + * In case a reset in idle operation has been posted, + * reset the device after having run the idle function + */ if (isResetScheduled) { PlatformMgrImpl().Reset(); @@ -305,10 +307,7 @@ bool PlatformManagerImpl::GetResetInIdleValue(void) return resetInIdle; } -void PlatformManagerImpl::StopBLEConnectivity(void) -{ - -} +void PlatformManagerImpl::StopBLEConnectivity(void) {} void PlatformManagerImpl::_Shutdown() { diff --git a/src/platform/nxp/rt/rw61x/SystemPlatformConfig.h b/src/platform/nxp/rt/rw61x/SystemPlatformConfig.h index d4b5761fd01d05..decabf5cfbb738 100644 --- a/src/platform/nxp/rt/rw61x/SystemPlatformConfig.h +++ b/src/platform/nxp/rt/rw61x/SystemPlatformConfig.h @@ -29,7 +29,6 @@ #include - // ==================== Platform Adaptations ==================== /* Default NXP Platform adaptations are used */ diff --git a/third_party/nxp/rt_sdk/lwip/common/lwipopts_common.h b/third_party/nxp/rt_sdk/lwip/common/lwipopts_common.h index 2ac635fd88d964..0cd0675469cc49 100644 --- a/third_party/nxp/rt_sdk/lwip/common/lwipopts_common.h +++ b/third_party/nxp/rt_sdk/lwip/common/lwipopts_common.h @@ -70,7 +70,7 @@ /** * NO_SYS==1: Bare metal lwIP */ -#define NO_SYS 1 +#define NO_SYS 1 /** * LWIP_NETCONN==0: Disable Netconn API (require to use api_lib.c) */ @@ -78,7 +78,7 @@ /** * LWIP_SOCKET==0: Disable Socket API (require to use sockets.c) */ -#define LWIP_SOCKET 0 +#define LWIP_SOCKET 0 #endif @@ -91,7 +91,7 @@ /** * The maximum number of services per netif * recommended to be two times greater than number of matter fabrics supported -*/ + */ #ifndef MDNS_MAX_SERVICES #define MDNS_MAX_SERVICES 10 #endif @@ -120,11 +120,11 @@ void sys_lock_tcpip_core(void); void sys_unlock_tcpip_core(void); #define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core() -//void sys_check_core_locking(void); -//#define LWIP_ASSERT_CORE_LOCKED() sys_check_core_locking() +// void sys_check_core_locking(void); +// #define LWIP_ASSERT_CORE_LOCKED() sys_check_core_locking() -//void sys_mark_tcpip_thread(void); -//#define LWIP_MARK_TCPIP_THREAD() sys_mark_tcpip_thread() +// void sys_mark_tcpip_thread(void); +// #define LWIP_MARK_TCPIP_THREAD() sys_mark_tcpip_thread() #ifdef __cplusplus } @@ -286,7 +286,6 @@ void sys_unlock_tcpip_core(void); #define TCP_LISTEN_BACKLOG 1 #endif - /* ---------- Network Interfaces options ---------- */ /* Support netif api (in netifapi.c). */ #ifndef LWIP_NETIF_API @@ -337,7 +336,6 @@ void sys_unlock_tcpip_core(void); #define LWIP_PROVIDE_ERRNO 1 #endif - /* -------------------------------------- ---------- Checksum options ---------- @@ -349,7 +347,7 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha - To use this feature let the following define uncommented. - To disable it and process by CPU comment the the checksum. */ -//#define CHECKSUM_BY_HARDWARE +// #define CHECKSUM_BY_HARDWARE #ifdef CHECKSUM_BY_HARDWARE /* CHECKSUM_GEN_IP==0: Generate checksums by hardware for outgoing IP packets.*/ @@ -366,13 +364,13 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha #define CHECKSUM_CHECK_TCP 0 #else /* CHECKSUM_GEN_IP==1: Generate checksums in software for outgoing IP packets.*/ -#define CHECKSUM_GEN_IP 1 +#define CHECKSUM_GEN_IP 1 /* CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets.*/ -#define CHECKSUM_GEN_UDP 1 +#define CHECKSUM_GEN_UDP 1 /* CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets.*/ -#define CHECKSUM_GEN_TCP 1 +#define CHECKSUM_GEN_TCP 1 /* CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets.*/ -#define CHECKSUM_CHECK_IP 1 +#define CHECKSUM_CHECK_IP 1 /* CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets.*/ #define CHECKSUM_CHECK_UDP 1 /* CHECKSUM_CHECK_TCP==1: Check checksums in software for incoming TCP packets.*/ @@ -397,10 +395,6 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha #define DEFAULT_THREAD_PRIO 8 #endif - - - - #define LWIP_TIMEVAL_PRIVATE (0) #define LWIP_COMPAT_MUTEX (0) @@ -412,19 +406,15 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha #define SO_REUSE (0) #define LWIP_RANDOMIZE_INITIAL_LOCAL_PORTS (0) - #define TCP_QUEUE_OOSEQ 0 #define ARP_QUEUEING (0) - - // TODO: seems like this is unnecessary on Thread-only platforms #define LWIP_RAW 1 #define MEMP_NUM_RAW_PCB (1) // TODO: verify count - #define LWIP_HAVE_LOOPIF (0) // TODO: not sure why this is disabled @@ -444,7 +434,6 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha #define LWIP_DNS (1) #endif - #if LWIP_IPV6 // #define LWIP_IPV6_REASS (0) // #define LWIP_IPV6_DHCP6 0 @@ -466,21 +455,15 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha #define LWIP_PBUF_FROM_CUSTOM_POOLS (0) #define MEMP_USE_CUSTOM_POOLS (0) - #define MEM_LIBC_MALLOC 1 #define mem_clib_malloc pvPortMalloc #define mem_clib_free vPortFree #define mem_clib_calloc pvPortCalloc - - #define PBUF_CUSTOM_POOL_IDX_START (MEMP_NUM_PBUF) #define PBUF_CUSTOM_POOL_IDX_END (MEMP_NUM_PBUF) - - - #define ETH_PAD_SIZE (0) #define SUB_ETHERNET_HEADER_SPACE (0) #define PBUF_LINK_HLEN (14) @@ -495,12 +478,10 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha #define LWIP_MULTICAST_PING 0 - -#define LWIP_DNS_FOUND_CALLBACK_TYPE dns_found_callback +#define LWIP_DNS_FOUND_CALLBACK_TYPE dns_found_callback // TODO: make LWIP_DEBUG conditional on build type - #define MEMP_OVERFLOW_CHECK (0) #define MEMP_SANITY_CHECK (0) #define MDNS_DEBUG (LWIP_DBG_OFF) @@ -536,19 +517,16 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha #define LWIP_DBG_TYPES_ON \ (LWIP_DBG_ON | LWIP_DBG_TRACE) /* (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT) */ - /* ------------------------------------ ---------- Debugging options ---------- ------------------------------------ */ - - #ifdef LWIP_DEBUG -#define U8_F "c" -#define S8_F "c" -#define X8_F "02x" +#define U8_F "c" +#define S8_F "c" +#define X8_F "02x" #define U16_F "u" #define S16_F "d" #define X16_F "x" @@ -567,7 +545,7 @@ Some MCU allow computing and verifying the IP, UDP, TCP and ICMP checksums by ha #endif #define TCPIP_THREAD_STACKSIZE 1024 -#define TCPIP_THREAD_PRIO 8 +#define TCPIP_THREAD_PRIO 8 /** * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a @@ -604,7 +582,6 @@ u32_t lwip_rand(void); #define LWIP_RAND() lwip_rand() #endif - /** * DAC macro (initially defined in MIMXRT1176_cm7_features.h) must be undefined * in the use case of RT1170 platform. @@ -615,5 +592,4 @@ u32_t lwip_rand(void); #undef DAC #endif - #endif /* __LWIPOPTS_COMMON_H__ */ diff --git a/third_party/nxp/rt_sdk/sdk_hook/bt_pal/EM_platform.h b/third_party/nxp/rt_sdk/sdk_hook/bt_pal/EM_platform.h index 0f4cdfe5e6ffd2..5d85b366aeb486 100644 --- a/third_party/nxp/rt_sdk/sdk_hook/bt_pal/EM_platform.h +++ b/third_party/nxp/rt_sdk/sdk_hook/bt_pal/EM_platform.h @@ -13,7 +13,6 @@ * SPDX-License-Identifier: BSD-3-Clause */ - #ifndef _H_EM_PLATFORM_HOOK #define _H_EM_PLATFORM_HOOK diff --git a/third_party/nxp/rt_sdk/sdk_hook/mbedtls/ksdk_mbedtls_software.c b/third_party/nxp/rt_sdk/sdk_hook/mbedtls/ksdk_mbedtls_software.c index 88a95e8c4158bf..3749cf1872ddac 100644 --- a/third_party/nxp/rt_sdk/sdk_hook/mbedtls/ksdk_mbedtls_software.c +++ b/third_party/nxp/rt_sdk/sdk_hook/mbedtls/ksdk_mbedtls_software.c @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ - #if !defined(MBEDTLS_CONFIG_FILE) +#if !defined(MBEDTLS_CONFIG_FILE) #include "mbedtls/config.h" #else #include MBEDTLS_CONFIG_FILE @@ -23,23 +23,23 @@ extern void CRYPTO_ConfigureThreading(void); #endif -#include "fsl_common.h" #include "fsl_adapter_rng.h" +#include "fsl_common.h" #include "ksdk_mbedtls.h" /******************************************************************************/ /*************************** FreeRTOS ********************************************/ /******************************************************************************/ #if defined(USE_RTOS) && defined(SDK_OS_FREE_RTOS) && defined(MBEDTLS_FREESCALE_FREERTOS_CALLOC_ALT) -#include #include "FreeRTOS.h" #include "task.h" +#include /*---------HEAP_4 calloc --------------------------------------------------*/ #if defined(configFRTOS_MEMORY_SCHEME) && (configFRTOS_MEMORY_SCHEME == 4) -void *pvPortCalloc(size_t num, size_t size) +void * pvPortCalloc(size_t num, size_t size) { - void *ptr; + void * ptr; ptr = pvPortMalloc(num * size); if (!ptr) @@ -54,16 +54,16 @@ void *pvPortCalloc(size_t num, size_t size) return ptr; } #else // HEAP_3 -void *pvPortCalloc(size_t num, size_t size) +void * pvPortCalloc(size_t num, size_t size) { - void *pvReturn; + void * pvReturn; vTaskSuspendAll(); { pvReturn = calloc(num, size); traceMALLOC(pvReturn, size); } - (void)xTaskResumeAll(); + (void) xTaskResumeAll(); #if (configUSE_MALLOC_FAILED_HOOK == 1) { @@ -93,7 +93,7 @@ void *pvPortCalloc(size_t num, size_t size) * @brief Implementation of mbedtls_mutex_init for thread-safety. * */ -void mcux_mbedtls_mutex_init(mbedtls_threading_mutex_t *mutex) +void mcux_mbedtls_mutex_init(mbedtls_threading_mutex_t * mutex) { mutex->mutex = xSemaphoreCreateMutex(); @@ -111,7 +111,7 @@ void mcux_mbedtls_mutex_init(mbedtls_threading_mutex_t *mutex) * @brief Implementation of mbedtls_mutex_free for thread-safety. * */ -void mcux_mbedtls_mutex_free(mbedtls_threading_mutex_t *mutex) +void mcux_mbedtls_mutex_free(mbedtls_threading_mutex_t * mutex) { if (mutex->is_valid == 1) { @@ -126,7 +126,7 @@ void mcux_mbedtls_mutex_free(mbedtls_threading_mutex_t *mutex) * @return 0 if successful, MBEDTLS_ERR_THREADING_MUTEX_ERROR if timeout, * MBEDTLS_ERR_THREADING_BAD_INPUT_DATA if the mutex is not valid. */ -int mcux_mbedtls_mutex_lock(mbedtls_threading_mutex_t *mutex) +int mcux_mbedtls_mutex_lock(mbedtls_threading_mutex_t * mutex) { int ret = MBEDTLS_ERR_THREADING_BAD_INPUT_DATA; @@ -151,7 +151,7 @@ int mcux_mbedtls_mutex_lock(mbedtls_threading_mutex_t *mutex) * @return 0 if successful, MBEDTLS_ERR_THREADING_MUTEX_ERROR if timeout, * MBEDTLS_ERR_THREADING_BAD_INPUT_DATA if the mutex is not valid. */ -int mcux_mbedtls_mutex_unlock(mbedtls_threading_mutex_t *mutex) +int mcux_mbedtls_mutex_unlock(mbedtls_threading_mutex_t * mutex) { int ret = MBEDTLS_ERR_THREADING_BAD_INPUT_DATA; @@ -173,13 +173,10 @@ int mcux_mbedtls_mutex_unlock(mbedtls_threading_mutex_t *mutex) static void CRYPTO_ConfigureThreadingMcux(void) { /* Configure mbedtls to use FreeRTOS mutexes. */ - mbedtls_threading_set_alt(mcux_mbedtls_mutex_init, mcux_mbedtls_mutex_free, mcux_mbedtls_mutex_lock, - mcux_mbedtls_mutex_unlock); + mbedtls_threading_set_alt(mcux_mbedtls_mutex_init, mcux_mbedtls_mutex_free, mcux_mbedtls_mutex_lock, mcux_mbedtls_mutex_unlock); } #endif /* defined(MBEDTLS_MCUX_FREERTOS_THREADING_ALT) */ - - status_t CRYPTO_InitHardware(void) { #if defined(MBEDTLS_THREADING_C) && defined(MBEDTLS_THREADING_ALT) diff --git a/third_party/nxp/rt_sdk/sdk_hook/zephyr/random/rand32.cpp b/third_party/nxp/rt_sdk/sdk_hook/zephyr/random/rand32.cpp index d045ab6b554252..202d4e7ed25d04 100644 --- a/third_party/nxp/rt_sdk/sdk_hook/zephyr/random/rand32.cpp +++ b/third_party/nxp/rt_sdk/sdk_hook/zephyr/random/rand32.cpp @@ -14,7 +14,7 @@ * Returns 0 if success, -1 otherwise * */ -int sys_csrand_get(void *dst, size_t len) +int sys_csrand_get(void * dst, size_t len) { CHIP_ERROR error; error = chip::Crypto::DRBG_get_bytes(reinterpret_cast(dst), len); diff --git a/third_party/nxp/rt_sdk/sdk_hook/zephyr/random/rand32.h b/third_party/nxp/rt_sdk/sdk_hook/zephyr/random/rand32.h index d434919d7e4930..7052bc9aeb8fe1 100644 --- a/third_party/nxp/rt_sdk/sdk_hook/zephyr/random/rand32.h +++ b/third_party/nxp/rt_sdk/sdk_hook/zephyr/random/rand32.h @@ -20,7 +20,7 @@ extern "C" { * Returns 0 if success, -1 otherwise * */ -int sys_csrand_get(void *dst, size_t len); +int sys_csrand_get(void * dst, size_t len); #ifdef __cplusplus } diff --git a/third_party/nxp/rt_sdk/sdk_hook/zephyr/sys/slist.h b/third_party/nxp/rt_sdk/sdk_hook/zephyr/sys/slist.h index 04218b12b53615..308f5237b841e3 100644 --- a/third_party/nxp/rt_sdk/sdk_hook/zephyr/sys/slist.h +++ b/third_party/nxp/rt_sdk/sdk_hook/zephyr/sys/slist.h @@ -11,7 +11,6 @@ extern "C" { #include "sys/slist.h" - #if defined(__cplusplus) } #endif \ No newline at end of file diff --git a/third_party/nxp/rt_sdk/transceiver/app_transceiver_config.h b/third_party/nxp/rt_sdk/transceiver/app_transceiver_config.h index f6337b87ad473e..2422b61dbf0b1c 100644 --- a/third_party/nxp/rt_sdk/transceiver/app_transceiver_config.h +++ b/third_party/nxp/rt_sdk/transceiver/app_transceiver_config.h @@ -5,21 +5,21 @@ * SPDX-License-Identifier: BSD-3-Clause */ - #define USB_HOST_CONFIG_EHCI 2 -#define CONTROLLER_ID kUSB_ControllerEhci0 - +#define CONTROLLER_ID kUSB_ControllerEhci0 -#if defined(WIFI_IW416_BOARD_AW_AM457_USD) || defined(WIFI_IW416_BOARD_AW_AM510_USD) || defined(WIFI_88W8987_BOARD_AW_CM358_USD) || defined(WIFI_IW61x_BOARD_RD_USD) || defined(WIFI_BOARD_RW610) || defined(WIFI_88W8801_BOARD_MURATA_2DS_USD) +#if defined(WIFI_IW416_BOARD_AW_AM457_USD) || defined(WIFI_IW416_BOARD_AW_AM510_USD) || \ + defined(WIFI_88W8987_BOARD_AW_CM358_USD) || defined(WIFI_IW61x_BOARD_RD_USD) || defined(WIFI_BOARD_RW610) || \ + defined(WIFI_88W8801_BOARD_MURATA_2DS_USD) #define WIFI_TRANSCEIVER_SUPPORT 1 #else #define WIFI_TRANSCEIVER_SUPPORT 0 #endif -/* -* Check if the transceiver is supported. -* Applies only for Matter over Wi-fi or Matter over Thread -*/ +/* + * Check if the transceiver is supported. + * Applies only for Matter over Wi-fi or Matter over Thread + */ #if (CHIP_DEVICE_CONFIG_ENABLE_WPA || CHIP_DEVICE_CONFIG_ENABLE_THREAD) #if !WIFI_TRANSCEIVER_SUPPORT && !defined(K32W061_TRANSCEIVER) #error The transceiver module is unsupported