Skip to content

Commit

Permalink
[Darwin] Implement DeviceInfoProviderImpl with persistent storage (#1…
Browse files Browse the repository at this point in the history
…7136)

* [Darwin] Implement DeviceInfoProviderImpl with persistent storage

* Use storage delegate instead of PersistedStorage

* Update src/platform/Darwin/DeviceInfoProviderImpl.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/platform/Darwin/DeviceInfoProviderImpl.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/platform/Darwin/DeviceInfoProviderImpl.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/platform/Darwin/DeviceInfoProviderImpl.cpp

Co-authored-by: Boris Zbarsky <[email protected]>

* Update src/include/platform/DeviceInfoProvider.h

Co-authored-by: Boris Zbarsky <[email protected]>

* Address review comments

Co-authored-by: Boris Zbarsky <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Sep 25, 2023
1 parent 7dd36de commit 1827348
Show file tree
Hide file tree
Showing 11 changed files with 657 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:
./scripts/run_in_build_env.sh \
"./scripts/tests/run_test_suite.py \
--chip-tool ./out/darwin-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT}/chip-tool \
--target-skip-glob '{TestGroupMessaging,TestUserLabelCluster}' \
--target-skip-glob '{TestGroupMessaging}' \
run \
--iterations 1 \
--all-clusters-app ./out/darwin-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \
Expand Down
8 changes: 8 additions & 0 deletions src/app/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <lib/support/logging/CHIPLogging.h>
#include <messaging/ExchangeMgr.h>
#include <platform/CHIPDeviceLayer.h>
#include <platform/DeviceInfoProvider.h>
#include <platform/KeyValueStoreManager.h>
#include <protocols/secure_channel/CASEServer.h>
#include <protocols/secure_channel/MessageCounterManager.h>
Expand Down Expand Up @@ -97,6 +98,7 @@ static ::chip::app::CircularEventBuffer sLoggingBuffer[CHIP_NUM_EVENT_LOGGING_BU
CHIP_ERROR Server::Init(const ServerInitParams & initParams)
{
CASESessionManagerConfig caseSessionManagerConfig;
DeviceLayer::DeviceInfoProvider * deviceInfoprovider = nullptr;

mOperationalServicePort = initParams.operationalServicePort;
mUserDirectedCommissioningPort = initParams.userDirectedCommissioningPort;
Expand Down Expand Up @@ -134,6 +136,12 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
mGroupsProvider = initParams.groupDataProvider;
SetGroupDataProvider(mGroupsProvider);

deviceInfoprovider = DeviceLayer::GetDeviceInfoProvider();
if (deviceInfoprovider)
{
deviceInfoprovider->SetStorageDelegate(mDeviceStorage);
}

err = mAccessControl.Init(initParams.accessDelegate, sDeviceTypeResolver);
SuccessOrExit(err);
Access::SetAccessControl(mAccessControl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ void UserPrompt(XCTestExpectation * expectation, dispatch_queue_t queue, NSStrin
[expectation fulfill];
}

// Stub for reboot target device.
void Reboot(XCTestExpectation * expectation, dispatch_queue_t queue, uint16_t discriminator)
{
[expectation fulfill];
}

void WaitForCommissionee(XCTestExpectation * expectation, dispatch_queue_t queue, uint64_t deviceId)
{
CHIPDeviceController * controller = [CHIPDeviceController sharedController];
Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/templates/tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ function getTests()
'TestLogCommands',
'TestOperationalCredentialsCluster',
'TestBinding',
'TestUserLabelCluster',
];

const SoftwareDiagnostics = [
Expand Down
150 changes: 150 additions & 0 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

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

10 changes: 10 additions & 0 deletions src/include/platform/DeviceInfoProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <app/util/basic-types.h>
#include <lib/core/CHIPError.h>
#include <lib/core/CHIPPersistentStorageDelegate.h>
#include <platform/AttributeList.h>

namespace chip {
Expand Down Expand Up @@ -81,6 +82,13 @@ class DeviceInfoProvider
DeviceInfoProvider(const DeviceInfoProvider &) = delete;
DeviceInfoProvider & operator=(const DeviceInfoProvider &) = delete;

/**
* @brief Set the storage implementation used for non-volatile storage of device information data.
*
* @param storage Pointer to storage instance to set. Cannot be nullptr, will assert.
*/
void SetStorageDelegate(PersistentStorageDelegate * storage);

CHIP_ERROR SetUserLabelList(EndpointId endpoint, const AttributeList<UserLabelType, kMaxUserLabelListLength> & labelList);
CHIP_ERROR AppendUserLabel(EndpointId endpoint, const UserLabelType & label);

Expand Down Expand Up @@ -112,6 +120,8 @@ class DeviceInfoProvider
virtual SupportedCalendarTypesIterator * IterateSupportedCalendarTypes() = 0;

protected:
PersistentStorageDelegate * mStorage = nullptr;

/**
* @brief Set the UserLabel at the specified index of the UserLabelList on a given endpoint
*
Expand Down
2 changes: 2 additions & 0 deletions src/platform/Darwin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ static_library("Darwin") {
"ConfigurationManagerImpl.h",
"ConnectivityManagerImpl.cpp",
"ConnectivityManagerImpl.h",
"DeviceInfoProviderImpl.cpp",
"DeviceInfoProviderImpl.h",
"DiagnosticDataProviderImpl.cpp",
"DiagnosticDataProviderImpl.h",
"DnssdImpl.cpp",
Expand Down
Loading

0 comments on commit 1827348

Please sign in to comment.