Skip to content

Commit

Permalink
Fix up mock ember implementation: (#32928)
Browse files Browse the repository at this point in the history
- provide data version function as described by attribute-storage.h
- fix self-referencing structure copying for mock node configurations
  • Loading branch information
andy31415 authored Apr 10, 2024
1 parent 5236e27 commit c6c8e67
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/util/mock/MockNodeConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ MockEndpointConfig::MockEndpointConfig(EndpointId aId, std::initializer_list<Moc
mEmberEndpoint.cluster = mEmberClusters.data();
}

MockEndpointConfig::MockEndpointConfig(const MockEndpointConfig & other) :
id(other.id), clusters(other.clusters), mEmberClusters(other.mEmberClusters), mEmberEndpoint(other.mEmberEndpoint)
{
// fix self-referencing pointers
mEmberEndpoint.cluster = mEmberClusters.data();
}

const MockClusterConfig * MockEndpointConfig::clusterById(ClusterId clusterId, ptrdiff_t * outIndex) const
{
return findById(clusters, clusterId, outIndex);
Expand Down
4 changes: 4 additions & 0 deletions src/app/util/mock/MockNodeConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ struct MockEndpointConfig
{
MockEndpointConfig(EndpointId aId, std::initializer_list<MockClusterConfig> aClusters = {});

// Cluster-config is self-referntial: mEmberCluster.clusters references mEmberClusters
MockEndpointConfig(const MockEndpointConfig & other);
MockEndpointConfig & operator=(const MockEndpointConfig &) = delete;

const MockClusterConfig * clusterById(ClusterId clusterId, ptrdiff_t * outIndex = nullptr) const;
const EmberAfEndpointType * emberEndpoint() const { return &mEmberEndpoint; }

Expand Down
6 changes: 6 additions & 0 deletions src/app/util/mock/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ const EmberAfCluster * emberAfFindServerCluster(EndpointId endpointId, ClusterId
return cluster->emberCluster();
}

DataVersion * emberAfDataVersionStorage(const chip::app::ConcreteClusterPath & aConcreteClusterPath)
{
// shared data version storage
return &dataVersion;
}

namespace chip {
namespace app {

Expand Down

0 comments on commit c6c8e67

Please sign in to comment.