-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[binding] Make binding table an attribute #14874
Conversation
3151416
to
0d225c7
Compare
0d225c7
to
205a6df
Compare
PR #14874: Size comparison from 2f785f4 to 205a6df Increases above 0.2%:
Increases (8 builds for cyw30739, k32w, linux, p6, qpg, telink)
Decreases (6 builds for efr32, linux, p6)
Full report (17 builds for cyw30739, efr32, k32w, linux, p6, qpg, telink)
|
PR #14874: Size comparison from 2f785f4 to 66840dd Increases above 0.2%:
Increases (28 builds for cyw30739, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
Decreases (7 builds for efr32, linux, p6)
Full report (43 builds for cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, qpg, telink)
|
@@ -37,7 +37,7 @@ class BridgedActionsAttrAccess : public AttributeAccessInterface | |||
// Register for the Bridged Actions cluster on all endpoints. | |||
BridgedActionsAttrAccess() : AttributeAccessInterface(Optional<EndpointId>::Missing(), BridgedActions::Id) {} | |||
|
|||
CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; | |||
CHIP_ERROR Read(FabricIndex fabricIndex, const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should not have been made. The fabric index was already available as aEncoder.AccessingFabricIndex()
.
{ | ||
// We already have an active connection | ||
mBoundDeviceChangedHandler(&entry, peerDevice, context); | ||
} | ||
else | ||
{ | ||
mPendingNotificationMap.AddPendingNotification(i, context); | ||
ReturnErrorOnFailure(EstablishConnection(entry.fabricIndex, entry.nodeId)); | ||
if (!peerDevice->IsConnecting()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what if peerDevice is null here? Won't this crash?
|
||
CHIP_ERROR BindingTableAccess::ReadBindingTable(FabricIndex fabricIndex, EndpointId endpoint, AttributeValueEncoder & encoder) | ||
{ | ||
DeviceLayer::AttributeList<Structs::BindingEntry::Type, EMBER_BINDING_TABLE_SIZE> bindingTable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Why can't we just encode as we go? Why does the whole list need to be built on the stack? It doesn't.
return true; | ||
} | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check for decode failure, no?
|
||
ReturnErrorOnFailure(decoder.Decode(newBindingList)); | ||
|
||
// Add entries currently not in the binding table |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong. Per spec, the order here matters, and this is not going to preserve the order of the incoming list...
emberDeleteBinding(bindingIndex); | ||
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); | ||
return true; | ||
// Remove entries not in the new binding list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring the ordering for the moment, this will completely fail if I try to overwrite the whole list with an equal length list, no? If EMBER_BINDING_TABLE_SIZE == 16 and we already have 16 bindings and I try to write 16 new ones... we will try to add before we remove and it will just fail.
<struct name="BindingEntry"> | ||
<cluster code="0x001e"/> | ||
<item name="nodeId" type="NODE_ID"/> | ||
<item name="groupId" type="GROUP_ID"/> | ||
<item name="endpointId" type="ENDPOINT_NO" /> | ||
<item name="clusterId" type="CLUSTER_ID" /> | ||
</struct> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know where this came from, but this does not match the spec. The struct has a different name, it's supposed to have a fabric index, it's supposed to have optional fields, etc, etc.
Had this matched the spec, there would have been no need to add that fabric index argument at all, because it would be right in the struct, as required by the spec.
This reverts commit 5834518. The PR made an unnecessary API mass change that should be reverted no matter what. It also introduces a null-dereference crash. Apart from that, the new code does not follow the spec in various ways: 1) Incorrect encoding of the binding target structs. 2) Does not preserve order, as the spec requires. 3) Will fail on legal writes of a list that completely replaces an existing list if the _sum_ of the lengths does not fit in our storage. 5) Does not do required error-checking on inputs.
This reverts commit 5834518. The PR made an unnecessary API mass change that should be reverted no matter what. It also introduces a null-dereference crash. Apart from that, the new code does not follow the spec in various ways: 1) Incorrect encoding of the binding target structs. 2) Does not preserve order, as the spec requires. 3) Will fail on legal writes of a list that completely replaces an existing list if the _sum_ of the lengths does not fit in our storage. 5) Does not do required error-checking on inputs.
This reverts commit 5834518. The PR made an unnecessary API mass change that should be reverted no matter what. It also introduces a null-dereference crash. Apart from that, the new code does not follow the spec in various ways: 1) Incorrect encoding of the binding target structs. 2) Does not preserve order, as the spec requires. 3) Will fail on legal writes of a list that completely replaces an existing list if the _sum_ of the lengths does not fit in our storage. 5) Does not do required error-checking on inputs.
Problem
According to the spec the binding table should be an attribute while it's now exposed as commands.
Change overview
bindings.cpp
Testing
How was this tested? (at least one bullet point required)
Run and pair two linux
all-cluster-app
.The read result is correct.
Type
switch on
in node 2 and the command are received in node 1.The read result is correct and the
switch
command cannot control node 1.