Skip to content

Commit

Permalink
Enable AttributeAccessInterface for Basic cluster (#13852)
Browse files Browse the repository at this point in the history
* Enable AttributeAccessInterface for Basic cluster

* Run codegen
  • Loading branch information
yufengwangca authored Jan 27, 2022
1 parent a5e3b54 commit 1c6b3c8
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 37 deletions.
1 change: 1 addition & 0 deletions src/app/clusters/basic/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,5 +320,6 @@ void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint)

void MatterBasicPluginServerInitCallback()
{
registerAttributeAccessOverride(&gAttrAccess);
PlatformMgr().SetDelegate(&gPlatformMgrDelegate);
}
8 changes: 3 additions & 5 deletions src/app/tests/suites/TestBasicInformation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ tests:
- label: "Wait for the commissioned device to be retrieved"
cluster: "DelayCommands"
command: "WaitForCommissionee"
#Disabled due to issue-12983

- label: "Read location"
disabled: true
command: "readAttribute"
attribute: "location"
response:
Expand All @@ -35,9 +34,8 @@ tests:
attribute: "location"
arguments:
value: "us"
#Disabled due to issue-12983

- label: "Read back location"
disabled: true
command: "readAttribute"
attribute: "location"
response:
Expand All @@ -47,7 +45,7 @@ tests:
command: "writeAttribute"
attribute: "location"
arguments:
value: ""
value: "XX"

- label: "Read AttributeList value"
command: "readAttribute"
Expand Down
4 changes: 2 additions & 2 deletions src/app/tests/suites/TestGroupMessaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ tests:
attribute: "location"
groupId: "1"
arguments:
value: ""
value: "XX"

# Test Pair 2 : Validates previous group write attribute with a unicast to read
- label: "Read back Attribute"
command: "readAttribute"
attribute: "location"
response:
value: ""
value: "XX"

# Test Pair 3 : Sends a Group command
- label: "Turn On the light to see attribute change"
Expand Down
2 changes: 1 addition & 1 deletion src/controller/python/test/test_scripts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class AttributeWriteRequest:
requests = [
AttributeWriteRequest("Basic", "NodeLabel", "Test"),
AttributeWriteRequest("Basic", "Location",
"a pretty loooooooooooooog string", IM.Status.InvalidValue),
"a pretty loooooooooooooog string", IM.Status.Failure),
]
failed_zcl = []
for req in requests:
Expand Down
2 changes: 1 addition & 1 deletion src/controller/python/test/test_scripts/cluster_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def SendWriteRequest(cls, devCtrl):
AttributeStatus(Path=AttributePath(EndpointId=0, ClusterId=40,
AttributeId=5), Status=chip.interaction_model.Status.Success),
AttributeStatus(Path=AttributePath(EndpointId=0, ClusterId=40,
AttributeId=6), Status=chip.interaction_model.Status.InvalidValue)
AttributeId=6), Status=chip.interaction_model.Status.Failure)
]

if res != expectedRes:
Expand Down
56 changes: 52 additions & 4 deletions src/darwin/Framework/CHIPTests/CHIPClustersTests.m

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

15 changes: 15 additions & 0 deletions src/platform/Darwin/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <platform/Darwin/PosixConfig.h>
#include <platform/internal/GenericConfigurationManagerImpl.cpp>

#include <lib/support/CHIPMemString.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>

Expand Down Expand Up @@ -193,6 +194,20 @@ CHIP_ERROR ConfigurationManagerImpl::WritePersistedStorageValue(::chip::Platform
return WriteConfigValue(configKey, value);
}

CHIP_ERROR ConfigurationManagerImpl::StoreCountryCode(const char * code, size_t codeLen)
{
Platform::CopyString(mCountryCode, kCountryCodeLength + 1, code);
return CHIP_NO_ERROR;
}

CHIP_ERROR ConfigurationManagerImpl::GetCountryCode(char * buf, size_t bufSize, size_t & codeLen)
{
Platform::CopyString(buf, kCountryCodeLength + 1, mCountryCode);
codeLen = strlen(mCountryCode);

return CHIP_NO_ERROR;
}

CHIP_ERROR ConfigurationManagerImpl::ReadConfigValue(Key key, bool & val)
{
return PosixConfig::ReadConfigValue(key, val);
Expand Down
6 changes: 6 additions & 0 deletions src/platform/Darwin/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
namespace chip {
namespace DeviceLayer {

static constexpr int kCountryCodeLength = 2;

/**
* Concrete implementation of the ConfigurationManager singleton object for the Darwin platform.
*/
Expand All @@ -40,6 +42,8 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
static ConfigurationManagerImpl & GetDefaultInstance();

private:
char mCountryCode[kCountryCodeLength + 1];

// ===== Members that implement the ConfigurationManager public interface.

CHIP_ERROR Init(void) override;
Expand All @@ -48,6 +52,8 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
void InitiateFactoryReset(void) override;
CHIP_ERROR ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) override;
CHIP_ERROR WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) override;
CHIP_ERROR StoreCountryCode(const char * code, size_t codeLen) override;
CHIP_ERROR GetCountryCode(char * buf, size_t bufSize, size_t & codeLen) override;

// NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>.

Expand Down
Loading

0 comments on commit 1c6b3c8

Please sign in to comment.