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

applications: Added support for groups in the Matter bridge #13084

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,23 @@ constexpr CommandId onOffIncomingCommands[] = {
kInvalidCommandId,
};

DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(groupsAttrs)
DECLARE_DYNAMIC_ATTRIBUTE(Clusters::Groups::Attributes::NameSupport::Id, BITMAP8, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END();

constexpr CommandId groupsIncomingCommands[] = {
app::Clusters::Groups::Commands::AddGroup::Id,
app::Clusters::Groups::Commands::ViewGroup::Id,
app::Clusters::Groups::Commands::GetGroupMembership::Id,
app::Clusters::Groups::Commands::RemoveGroup::Id,
app::Clusters::Groups::Commands::RemoveAllGroups::Id,
app::Clusters::Groups::Commands::AddGroupIfIdentifying::Id,
kInvalidCommandId,
};

DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters)
DECLARE_DYNAMIC_CLUSTER(Clusters::OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr),
DECLARE_DYNAMIC_CLUSTER(Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr),
DECLARE_DYNAMIC_CLUSTER(Clusters::Groups::Id, groupsAttrs, groupsIncomingCommands, nullptr),
DECLARE_DYNAMIC_CLUSTER(Clusters::BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr,
nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END;

Expand Down Expand Up @@ -64,6 +78,9 @@ CHIP_ERROR OnOffLightDevice::HandleRead(ClusterId clusterId, AttributeId attribu
case Clusters::OnOff::Id:
return HandleReadOnOff(attributeId, buffer, maxReadLength);
break;
case Clusters::Groups::Id:
return HandleReadGroups(attributeId, buffer, maxReadLength);
break;
default:
return CHIP_ERROR_INVALID_ARGUMENT;
}
Expand All @@ -89,6 +106,26 @@ CHIP_ERROR OnOffLightDevice::HandleReadOnOff(AttributeId attributeId, uint8_t *b
}
}

CHIP_ERROR OnOffLightDevice::HandleReadGroups(AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength)
{
switch (attributeId) {
case Clusters::Groups::Attributes::NameSupport::Id: {
uint8_t nameSupportMap = GetGroupsNameSupportMap();
return CopyAttribute(&nameSupportMap, sizeof(nameSupportMap), buffer, maxReadLength);
}
case Clusters::Groups::Attributes::ClusterRevision::Id: {
uint16_t clusterRevision = GetGroupsClusterRevision();
return CopyAttribute(&clusterRevision, sizeof(clusterRevision), buffer, maxReadLength);
}
case Clusters::Groups::Attributes::FeatureMap::Id: {
uint32_t featureMap = GetGroupsFeatureMap();
return CopyAttribute(&featureMap, sizeof(featureMap), buffer, maxReadLength);
}
default:
return CHIP_ERROR_INVALID_ARGUMENT;
}
}

CHIP_ERROR OnOffLightDevice::HandleWrite(ClusterId clusterId, AttributeId attributeId, uint8_t *buffer)
{
if (clusterId != Clusters::OnOff::Id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ class OnOffLightDevice : public MatterBridgedDevice {
public:
static constexpr uint16_t kOnOffClusterRevision = 1;
static constexpr uint32_t kOnOffFeatureMap = 0;
static constexpr uint16_t kGroupsClusterRevision = 4;
static constexpr uint32_t kGroupsFeatureMap = 0;
static constexpr uint8_t kGroupsNameSupportMap = 0;

OnOffLightDevice(const char *nodeLabel);

bool GetOnOff() { return mOnOff; }
void Toggle() { mOnOff = !mOnOff; }
uint16_t GetOnOffClusterRevision() { return kOnOffClusterRevision; }
uint32_t GetOnOffFeatureMap() { return kOnOffFeatureMap; }
uint16_t GetGroupsClusterRevision() { return kGroupsClusterRevision; }
uint32_t GetGroupsFeatureMap() { return kGroupsFeatureMap; }
uint8_t GetGroupsNameSupportMap() { return kGroupsNameSupportMap; }

MatterBridgedDevice::DeviceType GetDeviceType() const override
{
Expand All @@ -27,6 +33,7 @@ class OnOffLightDevice : public MatterBridgedDevice {
CHIP_ERROR HandleRead(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer,
uint16_t maxReadLength) override;
CHIP_ERROR HandleReadOnOff(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength);
CHIP_ERROR HandleReadGroups(chip::AttributeId attributeId, uint8_t *buffer, uint16_t maxReadLength);
CHIP_ERROR HandleWrite(chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t *buffer) override;
CHIP_ERROR HandleAttributeChange(chip::ClusterId clusterId, chip::AttributeId attributeId, void *data,
size_t dataSize) override;
Expand Down
9 changes: 9 additions & 0 deletions doc/nrf/releases_and_maturity/known_issues.rst
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ Matter

The issues in this section are related to the :ref:`ug_matter` protocol.

.. rst-class:: v2-5-0 v2-4-2 v2-4-1 v2-4-0 v2-3-0 v2-2-0 v2-1-4 v2-1-3 v2-1-2

KRKNWK-17360: Groupcast communication does not work for multiple endpoints that are part of the same group on a single Matter node
The Matter core implementation handles commands status in a wrong way for those targeted to a group.
This issue is only visible when adding multiple endpoints that exist on the same Matter node to the same group, and results in an application crash after receiving a group command.
When adding multiple Matter nodes with a single endpoint each to the same group, the communication works correctly.

**Workaround:** Manually cherry-pick and apply the commit with the fix to ``sdk-connectedhomeip`` (commit hash: ``99f80de289491ad24a13dda9178a7a24c85324a7``).

.. rst-class:: v2-5-0

KRKNWK-17864: When using Wi-Fi low power mode, the communication with the device might not work after it re-connects to the newly respawned Wi-Fi network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Thingy:53: Matter weather station
Matter Bridge
-------------

|no_changes_yet_note|
* Added support for groupcast communication to the On/Off Light device implementation.

Samples
=======
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ manifest:
- name: matter
repo-path: sdk-connectedhomeip
path: modules/lib/matter
revision: 599f334e6f865deb7ed452dbc7d63648f822094e
revision: 99f80de289491ad24a13dda9178a7a24c85324a7
submodules:
- name: nlio
path: third_party/nlio/repo
Expand Down