Skip to content

Commit

Permalink
[binding] Make binding table an attribute (project-chip#14952)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjc13 authored Feb 21, 2022
1 parent 498980d commit f8f54e9
Show file tree
Hide file tree
Showing 83 changed files with 2,974 additions and 1,697 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,16 @@ server cluster BinaryInputBasic = 15 {
}

server cluster Binding = 30 {
readonly global attribute int16u clusterRevision = 65533;

request struct BindRequest {
NODE_ID nodeId = 0;
GROUP_ID groupId = 1;
ENDPOINT_NO endpointId = 2;
CLUSTER_ID clusterId = 3;
struct TargetStruct {
FABRIC_IDX fabricIndex = 0;
optional NODE_ID node = 1;
optional GROUP_ID group = 2;
optional ENDPOINT_NO endpoint = 3;
optional CLUSTER_ID cluster = 4;
}

request struct UnbindRequest {
NODE_ID nodeId = 0;
GROUP_ID groupId = 1;
ENDPOINT_NO endpointId = 2;
CLUSTER_ID clusterId = 3;
}

command Bind(BindRequest): DefaultSuccess = 0;
command Unbind(UnbindRequest): DefaultSuccess = 1;
attribute TargetStruct binding[] = 0;
readonly global attribute int16u clusterRevision = 65533;
}

server cluster BooleanState = 69 {
Expand Down
70 changes: 33 additions & 37 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -877,24 +877,7 @@
"define": "BINDING_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [
{
"name": "Bind",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
},
{
"name": "Unbind",
"code": 1,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
}
],
"commands": [],
"attributes": [
{
"name": "ClusterRevision",
Expand Down Expand Up @@ -922,6 +905,21 @@
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "binding list",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand Down Expand Up @@ -8706,24 +8704,7 @@
"define": "BINDING_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [
{
"name": "Bind",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
},
{
"name": "Unbind",
"code": 1,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
}
],
"commands": [],
"attributes": [
{
"name": "ClusterRevision",
Expand Down Expand Up @@ -8751,6 +8732,21 @@
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "binding list",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand Down Expand Up @@ -21150,4 +21146,4 @@
}
],
"log": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,19 @@ static void RegisterSwitchCommands()
}
#endif // defined(ENABLE_CHIP_SHELL)

static void BoundDeviceChangedHandler(const EmberBindingTableEntry * binding, chip::DeviceProxy * peer_device, void * context)
static void BoundDeviceChangedHandler(const EmberBindingTableEntry & binding, chip::DeviceProxy * peer_device, void * context)
{
using namespace chip;
using namespace chip::app;

if (binding->type == EMBER_MULTICAST_BINDING)
if (binding.type == EMBER_MULTICAST_BINDING)
{
ChipLogError(NotSpecified, "Group binding is not supported now");
return;
}

if (binding->type == EMBER_UNICAST_BINDING && binding->local == 1 && binding->clusterId == Clusters::OnOff::Id)
if (binding.type == EMBER_UNICAST_BINDING && binding.local == 1 &&
(!binding.clusterId.HasValue() || binding.clusterId.Value() == Clusters::OnOff::Id))
{
auto onSuccess = [](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) {
ChipLogProgress(NotSpecified, "OnOff command succeeds");
Expand All @@ -90,13 +91,13 @@ static void BoundDeviceChangedHandler(const EmberBindingTableEntry * binding, ch
{
Clusters::OnOff::Commands::On::Type onCommand;
Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(),
binding->remote, onCommand, onSuccess, onFailure);
binding.remote, onCommand, onSuccess, onFailure);
}
else
{
Clusters::OnOff::Commands::Off::Type offCommand;
Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(),
binding->remote, offCommand, onSuccess, onFailure);
binding.remote, offCommand, onSuccess, onFailure);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/chip-tool/templates/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ function getTests()
'TestOperationalCredentialsCluster',
'TestModeSelectCluster',
'TestSystemCommands',
'TestBinding',
];

const SoftwareDiagnostics = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,16 @@ server cluster Basic = 40 {
}

server cluster Binding = 30 {
readonly global attribute int16u clusterRevision = 65533;

request struct BindRequest {
NODE_ID nodeId = 0;
GROUP_ID groupId = 1;
ENDPOINT_NO endpointId = 2;
CLUSTER_ID clusterId = 3;
struct TargetStruct {
FABRIC_IDX fabricIndex = 0;
optional NODE_ID node = 1;
optional GROUP_ID group = 2;
optional ENDPOINT_NO endpoint = 3;
optional CLUSTER_ID cluster = 4;
}

request struct UnbindRequest {
NODE_ID nodeId = 0;
GROUP_ID groupId = 1;
ENDPOINT_NO endpointId = 2;
CLUSTER_ID clusterId = 3;
}

command Bind(BindRequest): DefaultSuccess = 0;
command Unbind(UnbindRequest): DefaultSuccess = 1;
attribute TargetStruct binding[] = 0;
readonly global attribute int16u clusterRevision = 65533;
}

client cluster ColorControl = 768 {
Expand Down
67 changes: 32 additions & 35 deletions examples/light-switch-app/light-switch-common/light-switch-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -936,24 +936,7 @@
"define": "BINDING_CLUSTER",
"side": "client",
"enabled": 0,
"commands": [
{
"name": "Bind",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
},
{
"name": "Unbind",
"code": 1,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
}
],
"commands": [],
"attributes": []
},
{
Expand All @@ -965,6 +948,21 @@
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "binding list",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
Expand Down Expand Up @@ -5939,22 +5937,6 @@
"side": "client",
"enabled": 0,
"commands": [
{
"name": "Bind",
"code": 0,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
},
{
"name": "Unbind",
"code": 1,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
}
],
"attributes": [
{
Expand Down Expand Up @@ -5998,6 +5980,21 @@
"enabled": 1,
"commands": [],
"attributes": [
{
"name": "binding list",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
Expand Down Expand Up @@ -7067,4 +7064,4 @@
"deviceIdentifier": 259
}
]
}
}
24 changes: 8 additions & 16 deletions examples/thermostat/thermostat-common/thermostat.matter
Original file line number Diff line number Diff line change
Expand Up @@ -142,24 +142,16 @@ server cluster Basic = 40 {
}

server cluster Binding = 30 {
readonly global attribute int16u clusterRevision = 65533;

request struct BindRequest {
NODE_ID nodeId = 0;
GROUP_ID groupId = 1;
ENDPOINT_NO endpointId = 2;
CLUSTER_ID clusterId = 3;
struct TargetStruct {
FABRIC_IDX fabricIndex = 0;
optional NODE_ID node = 1;
optional GROUP_ID group = 2;
optional ENDPOINT_NO endpoint = 3;
optional CLUSTER_ID cluster = 4;
}

request struct UnbindRequest {
NODE_ID nodeId = 0;
GROUP_ID groupId = 1;
ENDPOINT_NO endpointId = 2;
CLUSTER_ID clusterId = 3;
}

command Bind(BindRequest): DefaultSuccess = 0;
command Unbind(UnbindRequest): DefaultSuccess = 1;
attribute TargetStruct binding[] = 0;
readonly global attribute int16u clusterRevision = 65533;
}

server cluster Descriptor = 29 {
Expand Down
Loading

0 comments on commit f8f54e9

Please sign in to comment.