Skip to content

Commit b365864

Browse files
authored
Merge branch 'master' into feature/message-cluster-present-message-update
2 parents fd2c277 + af29ce6 commit b365864

35 files changed

+1406
-1209
lines changed

src/app/BUILD.gn

+7
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ source_set("pre-encoded-value") {
114114
]
115115
}
116116

117+
source_set("subscription-manager") {
118+
sources = [ "SubscriptionManager.h" ]
119+
120+
public_deps = [ "${chip_root}/src/lib/core" ]
121+
}
122+
117123
source_set("message-def") {
118124
sources = [
119125
"MessageDef/ArrayBuilder.cpp",
@@ -247,6 +253,7 @@ static_library("interaction-model") {
247253
":app_config",
248254
":message-def",
249255
":paths",
256+
":subscription-manager",
250257
"${chip_root}/src/app/icd:icd_config",
251258
"${chip_root}/src/app/icd:observer",
252259
"${chip_root}/src/lib/address_resolve",

src/app/InteractionModelEngine.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void InteractionModelEngine::ShutdownMatchingSubscriptions(const Optional<Fabric
330330
}
331331
#endif // CHIP_CONFIG_ENABLE_READ_CLIENT
332332

333-
bool InteractionModelEngine::SubjectHasActiveSubscription(const FabricIndex aFabricIndex, const NodeId & subjectID)
333+
bool InteractionModelEngine::SubjectHasActiveSubscription(const FabricIndex & aFabricIndex, const NodeId & subjectID)
334334
{
335335
bool isActive = false;
336336
mReadHandlers.ForEachActiveObject([aFabricIndex, subjectID, &isActive](ReadHandler * handler) {
@@ -367,6 +367,12 @@ bool InteractionModelEngine::SubjectHasActiveSubscription(const FabricIndex aFab
367367
return isActive;
368368
}
369369

370+
bool InteractionModelEngine::SubjectHasPersistedSubscription(const FabricIndex & aFabricIndex, const NodeId & subject)
371+
{
372+
// TODO(#30281) : Implement persisted sub check and verify how persistent subscriptions affects this at ICDManager::Init
373+
return false;
374+
}
375+
370376
void InteractionModelEngine::OnDone(CommandHandler & apCommandObj)
371377
{
372378
mCommandHandlerObjs.ReleaseObject(&apCommandObj);

src/app/InteractionModelEngine.h

+20-18
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,6 @@
2727

2828
#include <access/AccessControl.h>
2929
#include <app/AppConfig.h>
30-
#include <app/MessageDef/AttributeReportIBs.h>
31-
#include <app/MessageDef/ReportDataMessage.h>
32-
#include <app/SubscriptionResumptionSessionEstablisher.h>
33-
#include <lib/core/CHIPCore.h>
34-
#include <lib/support/CodeUtils.h>
35-
#include <lib/support/DLLUtil.h>
36-
#include <lib/support/Pool.h>
37-
#include <lib/support/logging/CHIPLogging.h>
38-
#include <messaging/ExchangeContext.h>
39-
#include <messaging/ExchangeMgr.h>
40-
#include <messaging/Flags.h>
41-
#include <protocols/Protocols.h>
42-
#include <protocols/interaction_model/Constants.h>
43-
#include <system/SystemPacketBuffer.h>
44-
4530
#include <app/AttributePathParams.h>
4631
#include <app/CommandHandler.h>
4732
#include <app/CommandHandlerInterface.h>
@@ -51,17 +36,32 @@
5136
#include <app/ConcreteEventPath.h>
5237
#include <app/DataVersionFilter.h>
5338
#include <app/EventPathParams.h>
39+
#include <app/MessageDef/AttributeReportIBs.h>
40+
#include <app/MessageDef/ReportDataMessage.h>
5441
#include <app/ObjectList.h>
5542
#include <app/ReadClient.h>
5643
#include <app/ReadHandler.h>
5744
#include <app/StatusResponse.h>
45+
#include <app/SubscriptionManager.h>
46+
#include <app/SubscriptionResumptionSessionEstablisher.h>
5847
#include <app/TimedHandler.h>
5948
#include <app/WriteClient.h>
6049
#include <app/WriteHandler.h>
6150
#include <app/reporting/Engine.h>
6251
#include <app/reporting/ReportScheduler.h>
6352
#include <app/util/attribute-metadata.h>
6453
#include <app/util/basic-types.h>
54+
#include <lib/core/CHIPCore.h>
55+
#include <lib/support/CodeUtils.h>
56+
#include <lib/support/DLLUtil.h>
57+
#include <lib/support/Pool.h>
58+
#include <lib/support/logging/CHIPLogging.h>
59+
#include <messaging/ExchangeContext.h>
60+
#include <messaging/ExchangeMgr.h>
61+
#include <messaging/Flags.h>
62+
#include <protocols/Protocols.h>
63+
#include <protocols/interaction_model/Constants.h>
64+
#include <system/SystemPacketBuffer.h>
6565

6666
#include <app/CASESessionManager.h>
6767

@@ -79,7 +79,8 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
7979
public Messaging::ExchangeDelegate,
8080
public CommandHandler::Callback,
8181
public ReadHandler::ManagementCallback,
82-
public FabricTable::Delegate
82+
public FabricTable::Delegate,
83+
public SubscriptionManager
8384
{
8485
public:
8586
/**
@@ -323,8 +324,9 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,
323324

324325
CHIP_ERROR ResumeSubscriptions();
325326

326-
// Check if a given subject (CAT or NodeId) has at least 1 active subscription
327-
bool SubjectHasActiveSubscription(const FabricIndex aFabricIndex, const NodeId & subject);
327+
bool SubjectHasActiveSubscription(const FabricIndex & aFabricIndex, const NodeId & subject) override;
328+
329+
bool SubjectHasPersistedSubscription(const FabricIndex & aFabricIndex, const NodeId & subject) override;
328330

329331
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
330332
//

src/app/SubscriptionManager.h

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* @file
21+
* This file defines an interface that exposes all the public subscription management APIs.
22+
* The interface is implemented by the InteractionModelEngine to avoid creating unnecessary dependencies
23+
* Since the IMEgine has more dependency than its consummers need.
24+
* By leveraging the SubscriptionManager APIs, a consummer avoids depending on the global data model functions.
25+
*/
26+
27+
#pragma once
28+
29+
#include <lib/core/DataModelTypes.h>
30+
#include <lib/core/NodeId.h>
31+
32+
namespace chip {
33+
namespace app {
34+
35+
class SubscriptionManager
36+
{
37+
public:
38+
virtual ~SubscriptionManager(){};
39+
40+
/**
41+
* @brief Check if a given subject (CAT or operational NodeId) has at least 1 active subscription.
42+
*
43+
* @param[in] aFabricIndex fabric index of the subject
44+
* @param[in] subject NodeId of the subect
45+
*
46+
* @return true subject has at least one active subscription with the device
47+
* false subject doesn't have any acitve subscription with the device
48+
*/
49+
virtual bool SubjectHasActiveSubscription(const FabricIndex & aFabricIndex, const NodeId & subject) = 0;
50+
51+
/**
52+
* @brief Check if a given subject (CAT or operational NodeId) has at least 1 persisted subscription.
53+
* If CHIP_CONFIG_PERSIST_SUBSCRIPTIONS is not enable, function alweays returns false.
54+
* See the CHIP_CONFIG_PERSIST_SUBSCRIPTIONS for more information on persisted subscriptions.
55+
*
56+
* @param[in] aFabricIndex fabric index of the subject
57+
* @param[in] subject NodeId of the subect
58+
*
59+
* @return true subject has at least one persisted subscription with the device
60+
* false subject doesn't have any acitve subscription with the device
61+
* false If CHIP_CONFIG_PERSIST_SUBSCRIPTIONS is not enabled
62+
*/
63+
virtual bool SubjectHasPersistedSubscription(const FabricIndex & aFabricIndex, const NodeId & subject) = 0;
64+
};
65+
66+
} // namespace app
67+
} // namespace chip

src/app/chip_data_model.gni

+6
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,12 @@ template("chip_data_model") {
356356
"${_app_root}/clusters/${cluster}/${cluster}.h",
357357
"${_app_root}/clusters/${cluster}/EnergyReportingTestEventTriggerHandler.h",
358358
]
359+
} else if (cluster == "thread-network-diagnostics-server") {
360+
sources += [
361+
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
362+
"${_app_root}/clusters/${cluster}/thread-network-diagnostics-provider.cpp",
363+
"${_app_root}/clusters/${cluster}/thread-network-diagnostics-provider.h",
364+
]
359365
} else {
360366
sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ]
361367
}

src/app/clusters/color-control-server/color-control-server.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -2602,6 +2602,24 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint)
26022602

26032603
isColorTempTransitionDone = computeNewColor16uValue(colorTempTransitionState);
26042604

2605+
if (!isColorTempTransitionDone)
2606+
{
2607+
// Check whether our color temperature has actually changed. If not, do
2608+
// nothing, and wait for it to change.
2609+
uint16_t currentColorTemp;
2610+
if (Attributes::ColorTemperatureMireds::Get(endpoint, &currentColorTemp) != EMBER_ZCL_STATUS_SUCCESS)
2611+
{
2612+
// Why can't we read our attribute?
2613+
return;
2614+
}
2615+
2616+
if (currentColorTemp == colorTempTransitionState->currentValue)
2617+
{
2618+
scheduleTimerCallbackMs(configureTempEventControl(endpoint), TRANSITION_UPDATE_TIME_MS.count());
2619+
return;
2620+
}
2621+
}
2622+
26052623
Attributes::RemainingTime::Set(endpoint, colorTempTransitionState->timeRemaining);
26062624

26072625
if (isColorTempTransitionDone)

0 commit comments

Comments
 (0)