From 863b8b0d2e30c3c98f9da15f83b8a3a2403aadf0 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 17 Aug 2022 13:55:50 +0000 Subject: [PATCH] Restyled by clang-format --- .../nxp/k32w/k32w0/main/AppTask.cpp | 139 +++++++++--------- .../nxp/k32w/k32w0/main/include/AppTask.h | 10 +- .../identify-server/identify-server.cpp | 2 +- 3 files changed, 72 insertions(+), 79 deletions(-) diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp index 9ab91ebd1a11e2..8d3f2f0bd0afac 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -85,17 +85,12 @@ using namespace chip; AppTask AppTask::sAppTask; -static Identify gIdentify = { - chip::EndpointId{1}, - AppTask::OnIdentifyStart, - AppTask::OnIdentifyStop, - EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, - AppTask::OnTriggerEffect, - //Use invalid value for identifiers to enable TriggerEffect command - //to stop Identify command for each effect - (EmberAfIdentifyEffectIdentifier)(EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT - 0x10), - EMBER_ZCL_IDENTIFY_EFFECT_VARIANT_DEFAULT -}; +static Identify gIdentify = { chip::EndpointId{ 1 }, AppTask::OnIdentifyStart, AppTask::OnIdentifyStop, + EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, AppTask::OnTriggerEffect, + // Use invalid value for identifiers to enable TriggerEffect command + // to stop Identify command for each effect + (EmberAfIdentifyEffectIdentifier)(EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT - 0x10), + EMBER_ZCL_IDENTIFY_EFFECT_VARIANT_DEFAULT }; /* OTA related variables */ #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR @@ -687,7 +682,7 @@ void AppTask::ActionCompleted(LightingManager::Action_t aAction) void AppTask::RestoreLightingState(void) { - /* restore initial state for the LED indicating Lighting state */ + /* restore initial state for the LED indicating Lighting state */ if (LightingMgr().IsTurnedOff()) { sLightLED.Set(false); @@ -698,91 +693,90 @@ void AppTask::RestoreLightingState(void) } } -void AppTask::OnIdentifyStart(Identify* identify) +void AppTask::OnIdentifyStart(Identify * identify) { - if ((kFunction_NoneSelected != sAppTask.mFunction) && (kFunction_TriggerEffect != sAppTask.mFunction)) - { - K32W_LOG("Another function is scheduled. Could not initiate Identify process!"); - return; - } + if ((kFunction_NoneSelected != sAppTask.mFunction) && (kFunction_TriggerEffect != sAppTask.mFunction)) + { + K32W_LOG("Another function is scheduled. Could not initiate Identify process!"); + return; + } - if (kFunction_TriggerEffect == sAppTask.mFunction) - { - chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerEffectComplete, identify); - OnTriggerEffectComplete(&chip::DeviceLayer::SystemLayer(), identify); - } + if (kFunction_TriggerEffect == sAppTask.mFunction) + { + chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerEffectComplete, identify); + OnTriggerEffectComplete(&chip::DeviceLayer::SystemLayer(), identify); + } - ChipLogProgress(Zcl,"Identify process has started. Status LED should blink with a period of 0.5 seconds."); - sAppTask.mFunction = kFunction_Identify; - sLightLED.Set(false); - sLightLED.Blink(250); + ChipLogProgress(Zcl, "Identify process has started. Status LED should blink with a period of 0.5 seconds."); + sAppTask.mFunction = kFunction_Identify; + sLightLED.Set(false); + sLightLED.Blink(250); } -void AppTask::OnIdentifyStop(Identify* identify) +void AppTask::OnIdentifyStop(Identify * identify) { - if (kFunction_Identify == sAppTask.mFunction) - { - ChipLogProgress(Zcl,"Identify process has stopped."); - sAppTask.mFunction = kFunction_NoneSelected; - - RestoreLightingState(); + if (kFunction_Identify == sAppTask.mFunction) + { + ChipLogProgress(Zcl, "Identify process has stopped."); + sAppTask.mFunction = kFunction_NoneSelected; - } + RestoreLightingState(); + } } void AppTask::OnTriggerEffectComplete(chip::System::Layer * systemLayer, void * appState) { - //Let Identify command take over if called during TriggerEffect already running - if (kFunction_TriggerEffect == sAppTask.mFunction) - { - ChipLogProgress(Zcl,"TriggerEffect has stopped."); - sAppTask.mFunction = kFunction_NoneSelected; + // Let Identify command take over if called during TriggerEffect already running + if (kFunction_TriggerEffect == sAppTask.mFunction) + { + ChipLogProgress(Zcl, "TriggerEffect has stopped."); + sAppTask.mFunction = kFunction_NoneSelected; - //TriggerEffect finished - reset identifiers - //Use invalid value for identifiers to enable TriggerEffect command - //to stop Identify command for each effect - gIdentify.mCurrentEffectIdentifier = (EmberAfIdentifyEffectIdentifier)(EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT - 0x10); - gIdentify.mTargetEffectIdentifier = (EmberAfIdentifyEffectIdentifier)(EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT - 0x10); - gIdentify.mEffectVariant = EMBER_ZCL_IDENTIFY_EFFECT_VARIANT_DEFAULT; + // TriggerEffect finished - reset identifiers + // Use invalid value for identifiers to enable TriggerEffect command + // to stop Identify command for each effect + gIdentify.mCurrentEffectIdentifier = + (EmberAfIdentifyEffectIdentifier)(EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT - 0x10); + gIdentify.mTargetEffectIdentifier = + (EmberAfIdentifyEffectIdentifier)(EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT - 0x10); + gIdentify.mEffectVariant = EMBER_ZCL_IDENTIFY_EFFECT_VARIANT_DEFAULT; - RestoreLightingState(); - } + RestoreLightingState(); + } } -void AppTask::OnTriggerEffect(Identify* identify) +void AppTask::OnTriggerEffect(Identify * identify) { - //Allow overlapping TriggerEffect calls - if ((kFunction_NoneSelected != sAppTask.mFunction) && (kFunction_TriggerEffect != sAppTask.mFunction)) - { - K32W_LOG("Another function is scheduled. Could not initiate Identify process!"); - return; - } - - sAppTask.mFunction = kFunction_TriggerEffect; - uint16_t timerDelay = 0; + // Allow overlapping TriggerEffect calls + if ((kFunction_NoneSelected != sAppTask.mFunction) && (kFunction_TriggerEffect != sAppTask.mFunction)) + { + K32W_LOG("Another function is scheduled. Could not initiate Identify process!"); + return; + } - ChipLogProgress(Zcl,"TriggerEffect has started."); + sAppTask.mFunction = kFunction_TriggerEffect; + uint16_t timerDelay = 0; + ChipLogProgress(Zcl, "TriggerEffect has started."); switch (identify->mCurrentEffectIdentifier) { case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: - timerDelay = 2; - break; + timerDelay = 2; + break; case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: - timerDelay = 15; - break; + timerDelay = 15; + break; case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: - timerDelay = 4; + timerDelay = 4; break; case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: - ChipLogProgress(Zcl,"Channel Change effect not supported, using effect %d", - EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK); - timerDelay = 2; - break; + ChipLogProgress(Zcl, "Channel Change effect not supported, using effect %d", EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK); + timerDelay = 2; + break; case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT: chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerEffectComplete, identify); @@ -798,13 +792,12 @@ void AppTask::OnTriggerEffect(Identify* identify) ChipLogProgress(Zcl, "Invalid effect identifier."); } - if(timerDelay) + if (timerDelay) { - sLightLED.Set(false); - sLightLED.Blink(500); + sLightLED.Set(false); + sLightLED.Blink(500); - chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(timerDelay), OnTriggerEffectComplete, - identify); + chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(timerDelay), OnTriggerEffectComplete, identify); } } diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h index a3002f5b8d06ab..fc8c164871d15e 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h +++ b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h @@ -24,8 +24,8 @@ #include "AppEvent.h" #include "LightingManager.h" -#include #include +#include #include "FreeRTOS.h" #include "timers.h" @@ -51,9 +51,9 @@ class AppTask void UpdateDeviceState(void); // Identify cluster callbacks. - static void OnIdentifyStart(Identify* identify); - static void OnIdentifyStop(Identify* identify); - static void OnTriggerEffect(Identify* identify); + static void OnIdentifyStart(Identify * identify); + static void OnIdentifyStop(Identify * identify); + static void OnTriggerEffect(Identify * identify); static void OnTriggerEffectComplete(chip::System::Layer * systemLayer, void * appState); private: @@ -103,7 +103,7 @@ class AppTask kFunction_FactoryReset, kFunctionTurnOnTurnOff, kFunction_Identify, - kFunction_TriggerEffect, + kFunction_TriggerEffect, kFunction_Invalid } Function; diff --git a/src/app/clusters/identify-server/identify-server.cpp b/src/app/clusters/identify-server/identify-server.cpp index 00b5f65858ebaf..23a3cae299ca23 100644 --- a/src/app/clusters/identify-server/identify-server.cpp +++ b/src/app/clusters/identify-server/identify-server.cpp @@ -179,7 +179,7 @@ void MatterIdentifyClusterServerAttributeChangedCallback(const app::ConcreteAttr /* finish identify process */ if (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT == identify->mCurrentEffectIdentifier && identifyTime > 0) { - Clusters::Identify::Attributes::IdentifyTime::Set(endpoint, 1); + Clusters::Identify::Attributes::IdentifyTime::Set(endpoint, 1); } /* stop identify process */ if (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT == identify->mCurrentEffectIdentifier && identifyTime > 0)