Skip to content

Commit

Permalink
[NXP] Run clang-format on RW61x/COMMON sources
Browse files Browse the repository at this point in the history
  • Loading branch information
dinabenamar committed Oct 10, 2023
1 parent 94d11c5 commit 829307f
Show file tree
Hide file tree
Showing 45 changed files with 484 additions and 515 deletions.
13 changes: 7 additions & 6 deletions examples/all-clusters-app/nxp/common/main/AppAssert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
#include <platform/CHIPDeviceLayer.h>

/*
* 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)
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@

#include "AppFactoryData.h"

#include <credentials/DeviceAttestationCredsProvider.h>
#include <platform/CommissionableDataProvider.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <credentials/DeviceAttestationCredsProvider.h>

#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 <credentials/examples/DeviceAttestationCredsExample.h>
#endif
Expand Down
23 changes: 11 additions & 12 deletions examples/all-clusters-app/nxp/common/main/AppMatterCli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
*/

#include "AppMatterCli.h"
#include <cstring>
#include <platform/CHIPDeviceLayer.h>
#include "AppTask.h"
#include <app/server/Server.h>
#include <cstring>
#include <platform/CHIPDeviceLayer.h>

#ifdef ENABLE_CHIP_SHELL
#include <lib/shell/Engine.h>
#include <ChipShellCollection.h>
#include "task.h"
#include <ChipShellCollection.h>
#include <lib/shell/Engine.h>

#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;
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -84,7 +84,6 @@ CHIP_ERROR cliReset(int argc, char * argv[])
return CHIP_NO_ERROR;
}


CHIP_ERROR AppMatterCli_RegisterCommands(void)
{
#ifdef ENABLE_CHIP_SHELL
Expand All @@ -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[] = {
Expand All @@ -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;
}
50 changes: 23 additions & 27 deletions examples/all-clusters-app/nxp/common/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@
#include "DeviceCallbacks.h"
#include "binding-handler.h"
#include "lib/core/ErrorStr.h"
#include <app/server/Server.h>
#include <app/server/Dnssd.h>
#include <app/server/Server.h>
#include <lib/dnssd/Advertiser.h>

#if CHIP_DEVICE_CONFIG_ENABLE_WPA
#include <platform/nxp/common/NetworkCommissioningDriver.h>
#endif // CHIP_DEVICE_CONFIG_ENABLE_WPA

#include <DeviceInfoProviderImpl.h>
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <app/server/OnboardingCodesUtil.h>
#include <lib/support/ThreadOperationalDataset.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/internal/DeviceNetworkInfo.h>
#include <platform/CommissionableDataProvider.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <lib/support/ThreadOperationalDataset.h>
#include <DeviceInfoProviderImpl.h>
#include <platform/internal/DeviceNetworkInfo.h>

#include <app/util/attribute-storage.h>

#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"
Expand All @@ -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
Expand All @@ -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()
Expand All @@ -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");
Expand Down Expand Up @@ -159,7 +158,6 @@ void AppTask::InitServer(intptr_t arg)
#if ENABLE_OTA_PROVIDER
InitOTAServer();
#endif

}

CHIP_ERROR AppTask::Init()
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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 */
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

#include "CHIPDeviceManager.h"
#include <app/util/basic-types.h>
#include <setup_payload/SetupPayload.h>
#include <lib/core/ErrorStr.h>
#include <lib/support/CHIPMem.h>
#include <lib/support/CodeUtils.h>
#include <lib/core/ErrorStr.h>
#include <setup_payload/SetupPayload.h>

using namespace ::chip;

Expand Down
12 changes: 7 additions & 5 deletions examples/all-clusters-app/nxp/common/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
case DeviceEventType::kWiFiConnectivityChange:
OnWiFiConnectivityChange(event);
break;

case DeviceEventType::kInternetConnectivityChange:
OnInternetConnectivityChange(event);
break;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "AppEvent.h"
#include "DeviceCallbacks.h"


class AppTask
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
};
Expand All @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions examples/all-clusters-app/nxp/common/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
// Main Code
// ================================================================================

#include "FreeRTOS.h"
#include <AppTask.h>
#include <lib/core/CHIPError.h>
#include <lib/support/logging/CHIPLogging.h>
#include <AppTask.h>
#include "FreeRTOS.h"

#if configAPPLICATION_ALLOCATED_HEAP
uint8_t __attribute__((section(".heap"))) ucHeap[configTOTAL_HEAP_SIZE];
Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit 829307f

Please sign in to comment.