Skip to content

Commit

Permalink
Added a default ReportScheduler to the server init
Browse files Browse the repository at this point in the history
  • Loading branch information
lpbeliveau-silabs committed Aug 3, 2023
1 parent 53ba76b commit 2dc03f7
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 23 deletions.
6 changes: 4 additions & 2 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
VerifyOrExit(initParams.sessionKeystore != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(initParams.operationalKeystore != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(initParams.opCertStore != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrExit(initParams.reportScheduler != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);

// TODO(16969): Remove chip::Platform::MemoryInit() call from Server class, it belongs to outer code
chip::Platform::MemoryInit();
Expand Down Expand Up @@ -253,7 +252,7 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
#endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT

#if CHIP_CONFIG_ENABLE_ICD_SERVER
mICDManager.Init(mDeviceStorage, &GetFabricTable(), &mReportScheduler);
mICDManager.Init(mDeviceStorage, &GetFabricTable(), mReportScheduler);
mICDEventManager.Init(&mICDManager);
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER

Expand Down Expand Up @@ -558,6 +557,9 @@ KvsPersistentStorageDelegate CommonCaseDeviceServerInitParams::sKvsPersistenStor
PersistentStorageOperationalKeystore CommonCaseDeviceServerInitParams::sPersistentStorageOperationalKeystore;
Credentials::PersistentStorageOpCertStore CommonCaseDeviceServerInitParams::sPersistentStorageOpCertStore;
Credentials::GroupDataProviderImpl CommonCaseDeviceServerInitParams::sGroupDataProvider;
app::DefaultTimerDelegate CommonCaseDeviceServerInitParams::sTimerDelegate;
app::reporting::ReportSchedulerImpl
CommonCaseDeviceServerInitParams::sReportScheduler(&CommonCaseDeviceServerInitParams::sTimerDelegate);

#if CHIP_CONFIG_ENABLE_SESSION_RESUMPTION
SimpleSessionResumptionStorage CommonCaseDeviceServerInitParams::sSessionResumptionStorage;
Expand Down
111 changes: 90 additions & 21 deletions src/app/server/Server.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct ServerInitParams
ServerInitParams() = default;

// Not copyable
ServerInitParams(const ServerInitParams &) = delete;
ServerInitParams(const ServerInitParams &) = delete;
ServerInitParams & operator=(const ServerInitParams &) = delete;

// Application delegate to handle some commissioning lifecycle events
Expand Down Expand Up @@ -182,7 +182,7 @@ struct CommonCaseDeviceServerInitParams : public ServerInitParams
CommonCaseDeviceServerInitParams() = default;

// Not copyable
CommonCaseDeviceServerInitParams(const CommonCaseDeviceServerInitParams &) = delete;
CommonCaseDeviceServerInitParams(const CommonCaseDeviceServerInitParams &) = delete;
CommonCaseDeviceServerInitParams & operator=(const CommonCaseDeviceServerInitParams &) = delete;

/**
Expand Down Expand Up @@ -224,6 +224,11 @@ struct CommonCaseDeviceServerInitParams : public ServerInitParams
this->opCertStore = &sPersistentStorageOpCertStore;
}

if (this->reportScheduler == nullptr)
{
reportScheduler = &sReportScheduler;
}

// Session Keystore injection
this->sessionKeystore = &sSessionKeystore;

Expand Down Expand Up @@ -263,6 +268,13 @@ struct CommonCaseDeviceServerInitParams : public ServerInitParams
static Credentials::PersistentStorageOpCertStore sPersistentStorageOpCertStore;
static Credentials::GroupDataProviderImpl sGroupDataProvider;

#if CHIP_CONFIG_SYNCHRONOUS_REPORTS_ENABLED
static chip::SynchronizedTimerDelegate sTimerDelegate;
static app::reporting::SynchronizedReportSchedulerImpl sReportScheduler;
#else
static chip::app::DefaultTimerDelegate sTimerDelegate;
static app::reporting::ReportSchedulerImpl sReportScheduler;
#endif
#if CHIP_CONFIG_ENABLE_SESSION_RESUMPTION
static SimpleSessionResumptionStorage sSessionResumptionStorage;
#endif
Expand Down Expand Up @@ -306,43 +318,97 @@ class Server
*/
void RejoinExistingMulticastGroups();

FabricTable & GetFabricTable() { return mFabrics; }
FabricTable & GetFabricTable()
{
return mFabrics;
}

CASESessionManager * GetCASESessionManager() { return &mCASESessionManager; }
CASESessionManager * GetCASESessionManager()
{
return &mCASESessionManager;
}

Messaging::ExchangeManager & GetExchangeManager() { return mExchangeMgr; }
Messaging::ExchangeManager & GetExchangeManager()
{
return mExchangeMgr;
}

SessionManager & GetSecureSessionManager() { return mSessions; }
SessionManager & GetSecureSessionManager()
{
return mSessions;
}

SessionResumptionStorage * GetSessionResumptionStorage() { return mSessionResumptionStorage; }
SessionResumptionStorage * GetSessionResumptionStorage()
{
return mSessionResumptionStorage;
}

app::SubscriptionResumptionStorage * GetSubscriptionResumptionStorage() { return mSubscriptionResumptionStorage; }
app::SubscriptionResumptionStorage * GetSubscriptionResumptionStorage()
{
return mSubscriptionResumptionStorage;
}

TransportMgrBase & GetTransportManager() { return mTransports; }
TransportMgrBase & GetTransportManager()
{
return mTransports;
}

Credentials::GroupDataProvider * GetGroupDataProvider() { return mGroupsProvider; }
Credentials::GroupDataProvider * GetGroupDataProvider()
{
return mGroupsProvider;
}

Crypto::SessionKeystore * GetSessionKeystore() const { return mSessionKeystore; }
Crypto::SessionKeystore * GetSessionKeystore() const
{
return mSessionKeystore;
}

#if CONFIG_NETWORK_LAYER_BLE
Ble::BleLayer * GetBleLayerObject() { return mBleLayer; }
Ble::BleLayer * GetBleLayerObject()
{
return mBleLayer;
}
#endif

CommissioningWindowManager & GetCommissioningWindowManager() { return mCommissioningWindowManager; }
CommissioningWindowManager & GetCommissioningWindowManager()
{
return mCommissioningWindowManager;
}

PersistentStorageDelegate & GetPersistentStorage() { return *mDeviceStorage; }
PersistentStorageDelegate & GetPersistentStorage()
{
return *mDeviceStorage;
}

app::FailSafeContext & GetFailSafeContext() { return mFailSafeContext; }
app::FailSafeContext & GetFailSafeContext()
{
return mFailSafeContext;
}

TestEventTriggerDelegate * GetTestEventTriggerDelegate() { return mTestEventTriggerDelegate; }
TestEventTriggerDelegate * GetTestEventTriggerDelegate()
{
return mTestEventTriggerDelegate;
}

Crypto::OperationalKeystore * GetOperationalKeystore() { return mOperationalKeystore; }
Crypto::OperationalKeystore * GetOperationalKeystore()
{
return mOperationalKeystore;
}

Credentials::OperationalCertificateStore * GetOpCertStore() { return mOpCertStore; }
Credentials::OperationalCertificateStore * GetOpCertStore()
{
return mOpCertStore;
}

app::DefaultAttributePersistenceProvider & GetDefaultAttributePersister() { return mAttributePersister; }
app::DefaultAttributePersistenceProvider & GetDefaultAttributePersister()
{
return mAttributePersister;
}

app::reporting::ReportScheduler * GetReportScheduler() { return mReportScheduler; }
app::reporting::ReportScheduler * GetReportScheduler()
{
return mReportScheduler;
}

/**
* This function causes the ShutDown event to be generated async on the
Expand All @@ -359,7 +425,10 @@ class Server
return System::SystemClock().GetMonotonicMicroseconds64() - mInitTimestamp;
}

static Server & GetInstance() { return sServer; }
static Server & GetInstance()
{
return sServer;
}

private:
Server() {}
Expand Down

0 comments on commit 2dc03f7

Please sign in to comment.