Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Darwin] Implement DeviceInfoProviderImpl with persistent storage #17136

Merged
merged 8 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,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.

11 changes: 11 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,14 @@ class DeviceInfoProvider
DeviceInfoProvider(const DeviceInfoProvider &) = delete;
DeviceInfoProvider & operator=(const DeviceInfoProvider &) = delete;

/**
* @brief Set the storage implementation used for non-volatile storage of configuration data.
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved
* This method MUST be called before Init().
yufengwangca marked this conversation as resolved.
Show resolved Hide resolved
*
* @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 +121,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