-
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
Changing AcceptedCommands Interface #37646
base: master
Are you sure you want to change the base?
Changes from all commits
a6c102c
60c855f
97a16db
0aeb4e5
c9918d2
9685fee
1e118db
3a551c1
ff54464
6511c42
77a4f9f
7cb4b5e
dde4481
e55e237
5a0a934
62429e8
6f5ea52
319d9aa
8e92e77
777a609
5f53224
9671d96
33a0663
6e4a9e9
e4a4968
10cd5d3
731222e
98ea178
3f4a906
3037bfc
f4cdd15
7f56e9f
a20600e
afc80b1
8c10c16
2bf9949
8b8947b
316072b
9c54176
088f797
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1360,64 +1360,56 @@ void Instance::OnFailSafeTimerExpired() | |
} | ||
} | ||
|
||
CHIP_ERROR Instance::EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context) | ||
CHIP_ERROR Instance::EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, | ||
DataModel::ListBuilder<DataModel::AcceptedCommandEntry> & builder) | ||
{ | ||
using namespace Clusters::NetworkCommissioning::Commands; | ||
using Priv = Access::Privilege; | ||
|
||
if (mFeatureFlags.Has(Feature::kThreadNetworkInterface)) | ||
{ | ||
for (auto && cmd : { | ||
ScanNetworks::Id, | ||
AddOrUpdateThreadNetwork::Id, | ||
RemoveNetwork::Id, | ||
ConnectNetwork::Id, | ||
ReorderNetwork::Id, | ||
}) | ||
{ | ||
VerifyOrExit(callback(cmd, context) == Loop::Continue, /**/); | ||
} | ||
} | ||
else if (mFeatureFlags.Has(Feature::kWiFiNetworkInterface)) | ||
static constexpr size_t kNetworkCommands = 7; // Count of max possible commands assuming all features | ||
ReturnErrorOnFailure(builder.EnsureAppendCapacity(kNetworkCommands)); | ||
|
||
bool hasThread = mFeatureFlags.Has(Feature::kThreadNetworkInterface); | ||
bool hasWifi = mFeatureFlags.Has(Feature::kWiFiNetworkInterface); | ||
|
||
if (hasThread || hasWifi) | ||
{ | ||
for (auto && cmd : { | ||
ScanNetworks::Id, | ||
AddOrUpdateWiFiNetwork::Id, | ||
RemoveNetwork::Id, | ||
ConnectNetwork::Id, | ||
ReorderNetwork::Id, | ||
}) | ||
{ | ||
VerifyOrExit(callback(cmd, context) == Loop::Continue, /**/); | ||
} | ||
ReturnErrorOnFailure(builder.AppendElements({ | ||
{ ScanNetworks::Id, {}, Priv::kAdminister }, // | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fact that all this code has to duplicate parts of the spec is really fragile. What we should be doing is that cluster-objects codegen should be code-generating the relevant bits: either a getter for the I'm OK with this happening in a followup that then updates all these callsites, or in a PR that happens before this PR, either way. Just not as part of this PR. But we don't want to be shipping this in the state this PR is creating, where all sorts of spec stuff is duplicated in the cluster impls. Changes requested until we have a concrete plan for how this is going to work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of the logic issues may be pre-existing as we still controlled IDs within code. i.e. are you asking for something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, 100%. As this PR demonstrates, in several places. ;)
Yes. |
||
{ RemoveNetwork::Id, {}, Priv::kAdminister }, // | ||
{ ConnectNetwork::Id, {}, Priv::kAdminister }, // | ||
{ ReorderNetwork::Id, {}, Priv::kAdminister }, // | ||
})); | ||
ReturnErrorOnFailure( | ||
builder.Append({ hasThread ? AddOrUpdateThreadNetwork::Id : AddOrUpdateWiFiNetwork::Id, {}, Priv::kAdminister })); | ||
} | ||
|
||
if (mFeatureFlags.Has(Feature::kPerDeviceCredentials)) | ||
{ | ||
VerifyOrExit(callback(QueryIdentity::Id, context) == Loop::Continue, /**/); | ||
ReturnErrorOnFailure(builder.Append({ QueryIdentity::Id, {}, Priv::kAdminister })); | ||
} | ||
|
||
exit: | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
CHIP_ERROR Instance::EnumerateGeneratedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context) | ||
CHIP_ERROR Instance::EnumerateGeneratedCommands(const ConcreteClusterPath & cluster, DataModel::ListBuilder<CommandId> & builder) | ||
{ | ||
using namespace Clusters::NetworkCommissioning::Commands; | ||
|
||
static constexpr size_t kCommands = 4; // Count of max possible commands assuming all features | ||
ReturnErrorOnFailure(builder.EnsureAppendCapacity(kCommands)); | ||
|
||
if (mFeatureFlags.HasAny(Feature::kWiFiNetworkInterface, Feature::kThreadNetworkInterface)) | ||
{ | ||
for (auto && cmd : { ScanNetworksResponse::Id, NetworkConfigResponse::Id, ConnectNetworkResponse::Id }) | ||
{ | ||
VerifyOrExit(callback(cmd, context) == Loop::Continue, /**/); | ||
} | ||
ReturnErrorOnFailure( | ||
builder.AppendElements({ ScanNetworksResponse::Id, NetworkConfigResponse::Id, ConnectNetworkResponse::Id })); | ||
ratgr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
if (mFeatureFlags.Has(Feature::kPerDeviceCredentials)) | ||
{ | ||
VerifyOrExit(callback(QueryIdentityResponse::Id, context) == Loop::Continue, /**/); | ||
ReturnErrorOnFailure(builder.Append(QueryIdentityResponse::Id)); | ||
} | ||
|
||
exit: | ||
return CHIP_NO_ERROR; | ||
} | ||
|
||
|
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.
Does this not need EnsureAppendCapacity before AppendElements?
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.
Not really, AppendElements already ensures capacity before, only when using Append is necessary