Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing PR comments (#12562)
Browse files Browse the repository at this point in the history
* review comments

* Restyled by clang-format

* Added comments

Co-authored-by: Restyled.io <commits@restyled.io>
2 people authored and pull[bot] committed Dec 10, 2021
1 parent 590d235 commit 1004691
Showing 5 changed files with 222 additions and 79 deletions.
5 changes: 3 additions & 2 deletions examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
@@ -88,11 +88,12 @@ StaticTask_t appTaskStruct;
/**********************************************************
* Identify Callbacks
*********************************************************/

inline void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState)
namespace {
void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState)
{
sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
}
} // namespace

void OnTriggerIdentifyEffect(Identify * identify)
{
251 changes: 186 additions & 65 deletions src/app/clusters/color-control-server/color-control-server.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/app/clusters/color-control-server/color-control-server.h
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@ class ColorControlServer
* Functions Definitions
*********************************************************/
static ColorControlServer & Instance();
void stopAllColorTransitions(chip::EndpointId endpoint);
EmberAfStatus stopAllColorTransitions(chip::EndpointId endpoint);
bool stopMoveStepCommand(uint8_t optionsMask, uint8_t optionsOverride);

#ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_HSV
@@ -220,7 +220,7 @@ class ColorControlServer

#ifdef EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP
Color16uTransitionState * getTempTransitionState(chip::EndpointId endpoint);
void moveToColorTemp(chip::EndpointId aEndpoint, uint16_t colorTemperature, uint16_t transitionTime);
EmberAfStatus moveToColorTemp(chip::EndpointId aEndpoint, uint16_t colorTemperature, uint16_t transitionTime);
uint16_t getTemperatureCoupleToLevelMin(chip::EndpointId endpoint);
EmberEventControl * configureTempEventControl(chip::EndpointId);
#endif // EMBER_AF_PLUGIN_COLOR_CONTROL_SERVER_TEMP
35 changes: 25 additions & 10 deletions src/app/clusters/on-off-server/on-off-server.cpp
Original file line number Diff line number Diff line change
@@ -138,8 +138,12 @@ EmberAfStatus OnOffServer::setOnOffValue(chip::EndpointId endpoint, uint8_t comm
Attributes::OffWaitTime::Set(endpoint, 0);

// Stop timer on the endpoint
emberEventControlSetInactive(getEventControl(endpoint));
emberAfOnOffClusterPrintln("On/Toggle Command - Stop Timer");
EmberEventControl * event = getEventControl(endpoint);
if (event != nullptr)
{
emberEventControlSetInactive(event);
emberAfOnOffClusterPrintln("On/Toggle Command - Stop Timer");
}
}

Attributes::GlobalSceneControl::Set(endpoint, true);
@@ -352,10 +356,15 @@ bool OnOffServer::OnWithRecallGlobalSceneCommand()

bool OnOffServer::OnWithTimedOffCommand(BitFlags<OnOffControl> onOffControl, uint16_t onTime, uint16_t offWaitTime)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
chip::EndpointId endpoint = emberAfCurrentEndpoint();
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
chip::EndpointId endpoint = emberAfCurrentEndpoint();
bool isOn = false;
uint16_t currentOffWaitTime = MAX_TIME_VALUE;
uint16_t currentOnTime = 0;

EmberEventControl * event = configureEventControl(endpoint);
VerifyOrExit(event != nullptr, status = EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT);

bool isOn = false;
OnOff::Attributes::OnOff::Get(endpoint, &isOn);

// OnOff is off and the commands is only accepted if on
@@ -365,10 +374,7 @@ bool OnOffServer::OnWithTimedOffCommand(BitFlags<OnOffControl> onOffControl, uin
return true;
}

uint16_t currentOffWaitTime = MAX_TIME_VALUE;
OnOff::Attributes::OffWaitTime::Get(endpoint, &currentOffWaitTime);

uint16_t currentOnTime = 0;
OnOff::Attributes::OnTime::Get(endpoint, &currentOnTime);

if (currentOffWaitTime > 0 && !isOn)
@@ -397,6 +403,7 @@ bool OnOffServer::OnWithTimedOffCommand(BitFlags<OnOffControl> onOffControl, uin
emberEventControlSetDelayMS(configureEventControl(endpoint), UPDATE_TIME_MS);
}

exit:
emberAfSendImmediateDefaultResponse(status);
return true;
}
@@ -498,8 +505,15 @@ bool OnOffServer::areStartUpOnOffServerAttributesTokenized(EndpointId endpoint)
*/
EmberEventControl * OnOffServer::getEventControl(EndpointId endpoint)
{
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, OnOff::Id);
return &eventControls[index];
uint16_t index = emberAfFindClusterServerEndpointIndex(endpoint, OnOff::Id);
EmberEventControl * event = nullptr;

if (index < EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT)
{
event = &eventControls[index];
}

return event;
}

/**
@@ -511,6 +525,7 @@ EmberEventControl * OnOffServer::getEventControl(EndpointId endpoint)
EmberEventControl * OnOffServer::configureEventControl(EndpointId endpoint)
{
EmberEventControl * controller = getEventControl(endpoint);
VerifyOrReturnError(controller != nullptr, nullptr);

controller->endpoint = endpoint;
controller->callback = &onOffWaitTimeOffEventHandler;
6 changes: 6 additions & 0 deletions src/app/clusters/on-off-server/on-off-server.h
Original file line number Diff line number Diff line change
@@ -87,6 +87,12 @@ struct OnOffEffect
OnOffEffect(
chip::EndpointId endpoint, OffWithEffectTriggerCommand offWithEffectTrigger,
uint8_t effectIdentifier = static_cast<uint8_t>(EMBER_ZCL_ON_OFF_EFFECT_IDENTIFIER_DELAYED_ALL_OFF),

/*
* effectVariant's type depends on the effect effectIdentifier so we don't know the type at compile time.
* Casting to uint8_t for more flexibilty since the type can be OnOffDelayedAllOffEffectVariant or
* OnOffDelayedAllOffEffectVariant
*/
uint8_t effectVariant = static_cast<uint8_t>(EMBER_ZCL_ON_OFF_DELAYED_ALL_OFF_EFFECT_VARIANT_FADE_TO_OFF_IN_0P8_SECONDS));
~OnOffEffect();
};

0 comments on commit 1004691

Please sign in to comment.