Skip to content

Commit

Permalink
Create ICDData class with refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mkardous-silabs committed Nov 22, 2023
1 parent 1bb4be5 commit 3095155
Show file tree
Hide file tree
Showing 19 changed files with 397 additions and 245 deletions.
7 changes: 7 additions & 0 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1935,5 +1935,12 @@ bool InteractionModelEngine::HasSubscriptionsToResume()
}
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS && CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION

#if CHIP_CONFIG_ENABLE_ICD_SERVER
void InteractionModelEngine::SetICDData(ICDData & data)
{
ReadHandler::SetICDData(data);
}
#endif

} // namespace app
} // namespace chip
12 changes: 12 additions & 0 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@

#include <app/CASESessionManager.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDData.h> //nogncheck
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

namespace chip {
namespace app {

Expand Down Expand Up @@ -306,6 +310,10 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,

CHIP_ERROR ResumeSubscriptions();

#if CHIP_CONFIG_ENABLE_ICD_SERVER
void SetICDData(ICDData & data);
#endif

#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
//
// Get direct access to the underlying read handler pool
Expand Down Expand Up @@ -572,6 +580,10 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler,

CommandHandlerInterface * mCommandHandlerList = nullptr;

#if CHIP_CONFIG_ENABLE_ICD_SERVER
ICDData * mICDData = nullptr;
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

ObjectPool<CommandHandler, CHIP_IM_MAX_NUM_COMMAND_HANDLER> mCommandHandlerObjs;
ObjectPool<TimedHandler, CHIP_IM_MAX_NUM_TIMED_HANDLER> mTimedHandlers;
WriteHandler mWriteHandlers[CHIP_IM_MAX_NUM_WRITE_HANDLER];
Expand Down
11 changes: 6 additions & 5 deletions src/app/ReadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@
#include <app/ReadHandler.h>
#include <app/reporting/Engine.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDManagementServer.h> // nogncheck
#endif

namespace chip {
namespace app {
using Status = Protocols::InteractionModel::Status;

#if CHIP_CONFIG_ENABLE_ICD_SERVER
ICDData * ReadHandler::mICDData;
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

uint16_t ReadHandler::GetPublisherSelectedIntervalLimit()
{
#if CHIP_CONFIG_ENABLE_ICD_SERVER
return static_cast<uint16_t>(ICDManagementServer::GetInstance().GetIdleModeDurationSec());
VerifyOrDieWithMsg(mICDData != nullptr, DataManagement, "Requires ICDData when running as an ICD server");
return static_cast<uint16_t>(mICDData->GetIdleModeDurationSec());
#else
return kSubscriptionMaxIntervalPublisherLimit;
#endif
Expand Down
12 changes: 12 additions & 0 deletions src/app/ReadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
#include <protocols/Protocols.h>
#include <system/SystemPacketBuffer.h>

#if CHIP_CONFIG_ENABLE_ICD_SERVER
#include <app/icd/ICDData.h> //nogncheck
#endif

// https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/61a9d19e6af12fdfb0872bcff26d19de6c680a1a/src/Ch02_Architecture.adoc#1122-subscribe-interaction-limits
inline constexpr uint16_t kSubscriptionMaxIntervalPublisherLimit = 3600; // seconds (60 minutes)

Expand Down Expand Up @@ -253,6 +257,10 @@ class ReadHandler : public Messaging::ExchangeDelegate
return CHIP_NO_ERROR;
}

#if CHIP_CONFIG_ENABLE_ICD_SERVER
static void SetICDData(ICDData & icdData) { mICDData = &icdData; }
#endif

private:
PriorityLevel GetCurrentPriority() const { return mCurrentPriority; }
EventNumber & GetEventMin() { return mEventMin; }
Expand Down Expand Up @@ -577,6 +585,10 @@ class ReadHandler : public Messaging::ExchangeDelegate
chip::Callback::Callback<OnDeviceConnected> mOnConnectedCallback;
chip::Callback::Callback<OnDeviceConnectionFailure> mOnConnectionFailureCallback;
#endif

#if CHIP_CONFIG_ENABLE_ICD_SERVER
static ICDData * mICDData;
#endif
};
} // namespace app
} // namespace chip
12 changes: 9 additions & 3 deletions src/app/chip_data_model.gni
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ template("chip_data_model") {
"${_app_root}/clusters/color-control-server/color-control-server.h",
"${_app_root}/clusters/door-lock-server/door-lock-server.h",
"${_app_root}/clusters/groups-server/groups-server.h",
"${_app_root}/clusters/icd-management-server/icd-management-server.h",
"${_app_root}/clusters/identify-server/identify-server.h",
"${_app_root}/clusters/level-control/level-control.h",
"${_app_root}/clusters/on-off-server/on-off-server.h",
Expand Down Expand Up @@ -294,8 +293,15 @@ template("chip_data_model") {
"${_app_root}/clusters/${cluster}/dishwasher-alarm-delegate.h",
]
} else if (cluster == "icd-management-server") {
sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ]
deps += [ "${chip_root}/src/app/icd:cluster" ]
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
"${_app_root}/clusters/${cluster}/${cluster}.h",
]
deps += [
"${chip_root}/src/app/icd:data",
"${chip_root}/src/app/icd:notifier",
"${chip_root}/src/app/icd:table",
]
} else if (cluster == "resource-monitoring-server") {
sources += [
"${_app_root}/clusters/${cluster}/${cluster}.cpp",
Expand Down
Loading

0 comments on commit 3095155

Please sign in to comment.