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

Add ICD support (featuremap and commands) to FabricAdmin/FabricBridge samples #34855

Merged
merged 53 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
48a0363
Add extra attributes to the bridged device basic info structures, rem…
andy31415 Aug 6, 2024
c37cd56
Make use of AAI for BridgedDeviceBasicInformation cluster
andy31415 Aug 7, 2024
530691d
Restyled by gn
restyled-commits Aug 7, 2024
a7240c8
Fix sizes for software version
andy31415 Aug 7, 2024
eb95854
Update the synchronized device proto to have more data in it
andy31415 Aug 7, 2024
1356b1f
Switch to unique ptr in the registry, making sure memory management w…
andy31415 Aug 7, 2024
3d06305
Use more std::optional
andy31415 Aug 7, 2024
ece219b
Bump revision to 4
andy31415 Aug 7, 2024
651f092
Merge branch 'fabric_admin_info' into fabric_admin_add_rpc
andy31415 Aug 7, 2024
9f20d0f
Forward attributes from the create call into the bridged device
andy31415 Aug 7, 2024
5a1cb33
Make attribute mapping actually work
andy31415 Aug 7, 2024
4475143
Restyle
andy31415 Aug 7, 2024
152d225
Ensure unique IDs are generated
andy31415 Aug 7, 2024
c6877c8
Restyle
andy31415 Aug 7, 2024
28c8bb3
Increase size to 33 to allow for a null terminator
andy31415 Aug 7, 2024
23d61eb
make sure that the rpc structures are initialized
andy31415 Aug 7, 2024
6628f5c
Restyle
andy31415 Aug 7, 2024
33f2517
Add some fake data to test moving the data around
andy31415 Aug 7, 2024
68b58ef
Merge branch 'master' into fabric_admin_info
andy31415 Aug 7, 2024
d72e4cf
Merge branch 'fabric_admin_info' into fabric_admin_add_rpc
andy31415 Aug 7, 2024
fbb42ac
Remove unused members that were likely just copied over
andy31415 Aug 7, 2024
4abba22
make the attributes optional
andy31415 Aug 7, 2024
fab3b06
Prepare some device sync data - reading the basic info cluster
andy31415 Aug 7, 2024
f2d353e
Prepare some device sync data - reading the basic info cluster
andy31415 Aug 7, 2024
0d0ddae
Full implementation of forwarding data
andy31415 Aug 7, 2024
a4bc1b8
Restyle
andy31415 Aug 7, 2024
ff84027
Add missing file
andy31415 Aug 7, 2024
c60afe6
Restyle
andy31415 Aug 7, 2024
348030a
reset readclient, since this may reset the exchange manager ... seems…
andy31415 Aug 7, 2024
471941c
Add the verifyOrDie
andy31415 Aug 7, 2024
bcb6a11
Merge branch 'master' into fabric_admin_info
andy31415 Aug 7, 2024
b1d878d
Merge branch 'fabric_admin_info' into fabric_admin_add_rpc
andy31415 Aug 7, 2024
f9465eb
Restyled by clang-format
restyled-commits Aug 7, 2024
b0c3ffd
Merge branch 'fabric_admin_add_rpc' into fabric_admin_populate
andy31415 Aug 7, 2024
c256b3b
Fix string size for HW and software versions
andy31415 Aug 7, 2024
e0156e4
Move ICD support: set separate commands, handle feature mask
andy31415 Aug 7, 2024
3d78200
Restyle
andy31415 Aug 7, 2024
e965259
Merge branch 'master' into fabric_admin_add_rpc
andy31415 Aug 7, 2024
61d43f1
Merge branch 'fabric_admin_add_rpc' into fabric_admin_populate
andy31415 Aug 7, 2024
f2841eb
Remove some of the spammier logs
andy31415 Aug 7, 2024
dc75ac5
Enfore RPC enabling for synchronized device addition
andy31415 Aug 7, 2024
1a875b4
Merge branch 'fabric_admin_populate' into handle_icd_devices
andy31415 Aug 7, 2024
2501d42
Add device sync in progress tracking
andreilitvin Aug 8, 2024
9ff1c0d
Undo submodule update
andreilitvin Aug 8, 2024
46b75f2
Fix up device sync progress tracking to better handle errors
andreilitvin Aug 8, 2024
4ae53d0
Restyled by clang-format
restyled-commits Aug 8, 2024
860a682
Merge branch 'master' into fabric_admin_populate
andreilitvin Aug 8, 2024
61164a7
Merge branch 'fabric_admin_populate' into handle_icd_devices
andreilitvin Aug 8, 2024
a59fef7
Fix typo
andreilitvin Aug 8, 2024
29e2dcd
Undo submodule update
andreilitvin Aug 8, 2024
443b0c7
Merge branch 'master' into handle_icd_devices
andreilitvin Aug 8, 2024
c4064f0
Fix merge
andreilitvin Aug 8, 2024
efcb58a
Restyled by clang-format
restyled-commits Aug 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "fabric_bridge_service/fabric_bridge_service.pb.h"
#include "fabric_bridge_service/fabric_bridge_service.rpc.pb.h"

/// Ensures that device data is synchronized to the remove fabric bridge.
/// Ensures that device data is synchronized to the remote fabric bridge.
///
/// Includes a state machine that:
/// - initiates a "read basic information data" command to fetch basic information
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ class BridgedDevice
BridgedDevice(chip::NodeId nodeId);
virtual ~BridgedDevice() = default;

[[nodiscard]] bool IsReachable() const { return mReachable; }
void SetReachable(bool reachable);

void LogActiveChangeEvent(uint32_t promisedActiveDurationMs);

bool IsReachable();
bool IsIcd();
void SetReachable(bool reachable);
[[nodiscard]] bool IsIcd() const { return mIsIcd; }
void SetIcd(bool icd) { mIsIcd = icd; }

inline void SetEndpointId(chip::EndpointId id) { mEndpointId = id; };
inline chip::EndpointId GetEndpointId() { return mEndpointId; };
Expand All @@ -63,11 +65,12 @@ class BridgedDevice
void SetUniqueId(const std::string & value) { mAttributes.uniqueId = value; }

protected:
bool mReachable;
bool mIsIcd = false;
chip::NodeId mNodeId;
chip::EndpointId mEndpointId;
chip::EndpointId mParentEndpointId;
bool mReachable = false;
bool mIsIcd = false;

chip::NodeId mNodeId = 0;
chip::EndpointId mEndpointId = 0;
chip::EndpointId mParentEndpointId = 0;

BridgedAttributes mAttributes;
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "BridgedDevice.h"

#include <cstdio>
#include <string>

#include <app/EventLogging.h>
#include <platform/CHIPDeviceLayer.h>
Expand All @@ -32,7 +31,7 @@ struct ActiveChangeEventWorkData
uint32_t mPromisedActiveDuration;
};

static void ActiveChangeEventWork(intptr_t arg)
void ActiveChangeEventWork(intptr_t arg)
{
ActiveChangeEventWorkData * data = reinterpret_cast<ActiveChangeEventWorkData *>(arg);

Expand Down Expand Up @@ -68,16 +67,6 @@ void BridgedDevice::LogActiveChangeEvent(uint32_t promisedActiveDurationMs)
chip::DeviceLayer::PlatformMgr().ScheduleWork(ActiveChangeEventWork, reinterpret_cast<intptr_t>(workdata));
}

bool BridgedDevice::IsReachable()
{
return mReachable;
}

bool BridgedDevice::IsIcd()
{
return mIsIcd;
}

void BridgedDevice::SetReachable(bool reachable)
{
mReachable = reachable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <app/AttributeAccessInterfaceRegistry.h>

static constexpr unsigned kBridgedDeviceBasicInformationClusterRevision = 4;
static constexpr unsigned kBridgedDeviceBasicInformationFeatureMap = 0;

using namespace ::chip;
using namespace ::chip::app;
Expand All @@ -49,9 +48,12 @@ CHIP_ERROR BridgedDeviceBasicInformationImpl::Read(const ConcreteReadAttributePa
case BasicInformation::Attributes::ClusterRevision::Id:
encoder.Encode(kBridgedDeviceBasicInformationClusterRevision);
break;
case BasicInformation::Attributes::FeatureMap::Id:
encoder.Encode(kBridgedDeviceBasicInformationFeatureMap);
break;
case BasicInformation::Attributes::FeatureMap::Id: {
BitMask<Clusters::BridgedDeviceBasicInformation::Feature> features;
features.Set(Clusters::BridgedDeviceBasicInformation::Feature::kBridgedICDSupport, dev->IsIcd());
encoder.Encode(features);
}
break;
case BasicInformation::Attributes::UniqueID::Id:
encoder.Encode(CharSpan::fromCharString(dev->GetBridgedAttributes().uniqueId.c_str()));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,31 @@ constexpr CommandId administratorCommissioningCommands[] = {
kInvalidCommandId,
};

// clang-format off
// Declare Cluster List for Bridged Node endpoint
DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedNodeClusters)
DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(EcosystemInformation::Id, ecosystemInformationBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(AdministratorCommissioning::Id, AdministratorCommissioningAttrs, ZAP_CLUSTER_MASK(SERVER),
administratorCommissioningCommands, nullptr)
DECLARE_DYNAMIC_CLUSTER_LIST_END;

DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(icdBridgedNodeClusters)
DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, ZAP_CLUSTER_MASK(SERVER),
bridgedDeviceBasicInformationCommands, nullptr),
DECLARE_DYNAMIC_CLUSTER(EcosystemInformation::Id, ecosystemInformationBasicAttrs, ZAP_CLUSTER_MASK(SERVER), nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(AdministratorCommissioning::Id, AdministratorCommissioningAttrs, ZAP_CLUSTER_MASK(SERVER),
administratorCommissioningCommands, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END;
administratorCommissioningCommands, nullptr)
DECLARE_DYNAMIC_CLUSTER_LIST_END;
// clang-format on

// Declare Bridged Node endpoint
DECLARE_DYNAMIC_ENDPOINT(sBridgedNodeEndpoint, bridgedNodeClusters);
DECLARE_DYNAMIC_ENDPOINT(sIcdBridgedNodeEndpoint, icdBridgedNodeClusters);

// TODO: this is a single version array, however we may have many
// different clusters that are independent.
DataVersion sBridgedNodeDataVersions[ArraySize(bridgedNodeClusters)];

const EmberAfDeviceType sBridgedDeviceTypes[] = { { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } };
Expand All @@ -171,9 +185,12 @@ void BridgedDeviceManager::Init()
std::optional<unsigned> BridgedDeviceManager::AddDeviceEndpoint(std::unique_ptr<BridgedDevice> dev,
chip::EndpointId parentEndpointId)
{
EmberAfEndpointType * ep = &sBridgedNodeEndpoint;
EmberAfEndpointType * ep = dev->IsIcd() ? &sIcdBridgedNodeEndpoint : &sBridgedNodeEndpoint;

const chip::Span<const EmberAfDeviceType> & deviceTypeList = Span<const EmberAfDeviceType>(sBridgedDeviceTypes);
const chip::Span<chip::DataVersion> & dataVersionStorage = Span<DataVersion>(sBridgedNodeDataVersions);

// TODO: this shares data version among different clusters, which seems incorrect
const chip::Span<chip::DataVersion> & dataVersionStorage = Span<DataVersion>(sBridgedNodeDataVersions);

if (dev->GetBridgedAttributes().uniqueId.empty())
{
Expand Down
1 change: 1 addition & 0 deletions examples/fabric-bridge-app/linux/RpcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice
}

device->SetBridgedAttributes(attributes);
device->SetIcd(request.has_is_icd && request.is_icd);

auto result = BridgeDeviceMgr().AddDeviceEndpoint(std::move(device), 1 /* parentEndpointId */);
if (!result.has_value())
Expand Down
Loading