Skip to content

Commit

Permalink
add attribute change callback hook for speaker endpoint (#16944)
Browse files Browse the repository at this point in the history
* add attribute change callback hook for speaker endpoint

* Update examples/tv-app/linux/ZclCallbacks.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Update examples/tv-app/linux/ZclCallbacks.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

* Delete af-gen-event.h

Revert change pending feedback on level control cluster on endpoint 1

* add back af-gen-events

* Restyle add attribute change callback hook for speaker endpoint (#16945)

* Restyled by whitespace

* Restyled by gn

Co-authored-by: Restyled.io <commits@restyled.io>

Co-authored-by: Justin Wood <woody@apple.com>
Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
5 people authored Apr 6, 2022
1 parent 1cb44b8 commit f7b39db
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/tv-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ executable("chip-tv-app") {
"AppImpl.cpp",
"AppImpl.h",
"AppPlatformShellCommands.cpp",
"ZclCallbacks.cpp",
"include/account-login/AccountLoginManager.cpp",
"include/account-login/AccountLoginManager.h",
"include/application-basic/ApplicationBasicManager.cpp",
Expand Down
70 changes: 70 additions & 0 deletions examples/tv-app/linux/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @file
* This file implements the handler for data model messages.
*/

#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/ConcreteAttributePath.h>
#include <lib/support/logging/CHIPLogging.h>

using namespace ::chip;
using namespace ::chip::app::Clusters;

void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type,
uint16_t size, uint8_t * value)
{
ClusterId clusterId = attributePath.mClusterId;
AttributeId attributeId = attributePath.mAttributeId;
ChipLogProgress(Zcl, "Cluster callback: " ChipLogFormatMEI, ChipLogValueMEI(clusterId));

if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id)
{
ChipLogProgress(Zcl, "OnOff attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %" PRIu16,
ChipLogValueMEI(attributeId), type, *value, size);
}
else if (clusterId == LevelControl::Id)
{
ChipLogProgress(Zcl, "Level Control attribute ID: " ChipLogFormatMEI " Type: %u Value: %u, length %" PRIu16,
ChipLogValueMEI(attributeId), type, *value, size);

// WIP Apply attribute change to Light
}
}

/** @brief OnOff Cluster Init
*
* This function is called when a specific cluster is initialized. It gives the
* application an opportunity to take care of cluster initialization procedures.
* It is called exactly once for each endpoint where cluster is present.
*
* @param endpoint Ver.: always
*
* TODO Issue #3841
* emberAfOnOffClusterInitCallback happens before the stack initialize the cluster
* attributes to the default value.
* The logic here expects something similar to the deprecated Plugins callback
* emberAfPluginOnOffClusterServerPostInitCallback.
*
*/
void emberAfOnOffClusterInitCallback(EndpointId endpoint)
{
// TODO: implement any additional Cluster Server init actions
}
2 changes: 2 additions & 0 deletions zzz_generated/tv-app/zap-generated/af-gen-event.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f7b39db

Please sign in to comment.