Skip to content

Commit

Permalink
Merge branch 'master' into feature/message-cluster-present-message-up…
Browse files Browse the repository at this point in the history
…date
  • Loading branch information
lazarkov authored Jan 30, 2024
2 parents fd2c277 + af29ce6 commit b365864
Show file tree
Hide file tree
Showing 35 changed files with 1,406 additions and 1,209 deletions.
7 changes: 7 additions & 0 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ source_set("pre-encoded-value") {
]
}

source_set("subscription-manager") {
sources = [ "SubscriptionManager.h" ]

public_deps = [ "${chip_root}/src/lib/core" ]
}

source_set("message-def") {
sources = [
"MessageDef/ArrayBuilder.cpp",
Expand Down Expand Up @@ -247,6 +253,7 @@ static_library("interaction-model") {
":app_config",
":message-def",
":paths",
":subscription-manager",
"${chip_root}/src/app/icd:icd_config",
"${chip_root}/src/app/icd:observer",
"${chip_root}/src/lib/address_resolve",
Expand Down
8 changes: 7 additions & 1 deletion src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void InteractionModelEngine::ShutdownMatchingSubscriptions(const Optional<Fabric
}
#endif // CHIP_CONFIG_ENABLE_READ_CLIENT

bool InteractionModelEngine::SubjectHasActiveSubscription(const FabricIndex aFabricIndex, const NodeId & subjectID)
bool InteractionModelEngine::SubjectHasActiveSubscription(const FabricIndex & aFabricIndex, const NodeId & subjectID)
{
bool isActive = false;
mReadHandlers.ForEachActiveObject([aFabricIndex, subjectID, &isActive](ReadHandler * handler) {
Expand Down Expand Up @@ -367,6 +367,12 @@ bool InteractionModelEngine::SubjectHasActiveSubscription(const FabricIndex aFab
return isActive;
}

bool InteractionModelEngine::SubjectHasPersistedSubscription(const FabricIndex & aFabricIndex, const NodeId & subject)
{
// TODO(#30281) : Implement persisted sub check and verify how persistent subscriptions affects this at ICDManager::Init
return false;
}

void InteractionModelEngine::OnDone(CommandHandler & apCommandObj)
{
mCommandHandlerObjs.ReleaseObject(&apCommandObj);
Expand Down
38 changes: 20 additions & 18 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@

#include <access/AccessControl.h>
#include <app/AppConfig.h>
#include <app/MessageDef/AttributeReportIBs.h>
#include <app/MessageDef/ReportDataMessage.h>
#include <app/SubscriptionResumptionSessionEstablisher.h>
#include <lib/core/CHIPCore.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/DLLUtil.h>
#include <lib/support/Pool.h>
#include <lib/support/logging/CHIPLogging.h>
#include <messaging/ExchangeContext.h>
#include <messaging/ExchangeMgr.h>
#include <messaging/Flags.h>
#include <protocols/Protocols.h>
#include <protocols/interaction_model/Constants.h>
#include <system/SystemPacketBuffer.h>

#include <app/AttributePathParams.h>
#include <app/CommandHandler.h>
#include <app/CommandHandlerInterface.h>
Expand All @@ -51,17 +36,32 @@
#include <app/ConcreteEventPath.h>
#include <app/DataVersionFilter.h>
#include <app/EventPathParams.h>
#include <app/MessageDef/AttributeReportIBs.h>
#include <app/MessageDef/ReportDataMessage.h>
#include <app/ObjectList.h>
#include <app/ReadClient.h>
#include <app/ReadHandler.h>
#include <app/StatusResponse.h>
#include <app/SubscriptionManager.h>
#include <app/SubscriptionResumptionSessionEstablisher.h>
#include <app/TimedHandler.h>
#include <app/WriteClient.h>
#include <app/WriteHandler.h>
#include <app/reporting/Engine.h>
#include <app/reporting/ReportScheduler.h>
#include <app/util/attribute-metadata.h>
#include <app/util/basic-types.h>
#include <lib/core/CHIPCore.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/DLLUtil.h>
#include <lib/support/Pool.h>
#include <lib/support/logging/CHIPLogging.h>
#include <messaging/ExchangeContext.h>
#include <messaging/ExchangeMgr.h>
#include <messaging/Flags.h>
#include <protocols/Protocols.h>
#include <protocols/interaction_model/Constants.h>
#include <system/SystemPacketBuffer.h>

#include <app/CASESessionManager.h>

Expand All @@ -79,7 +79,8 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
public Messaging::ExchangeDelegate,
public CommandHandler::Callback,
public ReadHandler::ManagementCallback,
public FabricTable::Delegate
public FabricTable::Delegate,
public SubscriptionManager
{
public:
/**
Expand Down Expand Up @@ -323,8 +324,9 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,

CHIP_ERROR ResumeSubscriptions();

// Check if a given subject (CAT or NodeId) has at least 1 active subscription
bool SubjectHasActiveSubscription(const FabricIndex aFabricIndex, const NodeId & subject);
bool SubjectHasActiveSubscription(const FabricIndex & aFabricIndex, const NodeId & subject) override;

bool SubjectHasPersistedSubscription(const FabricIndex & aFabricIndex, const NodeId & subject) override;

#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
//
Expand Down
67 changes: 67 additions & 0 deletions src/app/SubscriptionManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* 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 defines an interface that exposes all the public subscription management APIs.
* The interface is implemented by the InteractionModelEngine to avoid creating unnecessary dependencies
* Since the IMEgine has more dependency than its consummers need.
* By leveraging the SubscriptionManager APIs, a consummer avoids depending on the global data model functions.
*/

#pragma once

#include <lib/core/DataModelTypes.h>
#include <lib/core/NodeId.h>

namespace chip {
namespace app {

class SubscriptionManager
{
public:
virtual ~SubscriptionManager(){};

/**
* @brief Check if a given subject (CAT or operational NodeId) has at least 1 active subscription.
*
* @param[in] aFabricIndex fabric index of the subject
* @param[in] subject NodeId of the subect
*
* @return true subject has at least one active subscription with the device
* false subject doesn't have any acitve subscription with the device
*/
virtual bool SubjectHasActiveSubscription(const FabricIndex & aFabricIndex, const NodeId & subject) = 0;

/**
* @brief Check if a given subject (CAT or operational NodeId) has at least 1 persisted subscription.
* If CHIP_CONFIG_PERSIST_SUBSCRIPTIONS is not enable, function alweays returns false.
* See the CHIP_CONFIG_PERSIST_SUBSCRIPTIONS for more information on persisted subscriptions.
*
* @param[in] aFabricIndex fabric index of the subject
* @param[in] subject NodeId of the subect
*
* @return true subject has at least one persisted subscription with the device
* false subject doesn't have any acitve subscription with the device
* false If CHIP_CONFIG_PERSIST_SUBSCRIPTIONS is not enabled
*/
virtual bool SubjectHasPersistedSubscription(const FabricIndex & aFabricIndex, const NodeId & subject) = 0;
};

} // namespace app
} // namespace chip
6 changes: 6 additions & 0 deletions src/app/chip_data_model.gni
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ template("chip_data_model") {
"${_app_root}/clusters/${cluster}/${cluster}.h",
"${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerHandler.h",
]
} else if (cluster == "thread-network-diagnostics-server") {
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
"${_app_root}/clusters/${cluster}/thread-network-diagnostics-provider.cpp",
"${_app_root}/clusters/${cluster}/thread-network-diagnostics-provider.h",
]
} else {
sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ]
}
Expand Down
18 changes: 18 additions & 0 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2602,6 +2602,24 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint)

isColorTempTransitionDone = computeNewColor16uValue(colorTempTransitionState);

if (!isColorTempTransitionDone)
{
// Check whether our color temperature has actually changed. If not, do
// nothing, and wait for it to change.
uint16_t currentColorTemp;
if (Attributes::ColorTemperatureMireds::Get(endpoint, &currentColorTemp) != EMBER_ZCL_STATUS_SUCCESS)
{
// Why can't we read our attribute?
return;
}

if (currentColorTemp == colorTempTransitionState->currentValue)
{
scheduleTimerCallbackMs(configureTempEventControl(endpoint), TRANSITION_UPDATE_TIME_MS.count());
return;
}
}

Attributes::RemainingTime::Set(endpoint, colorTempTransitionState->timeRemaining);

if (isColorTempTransitionDone)
Expand Down
Loading

0 comments on commit b365864

Please sign in to comment.