-
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
Make global attributes be part of IM instead of part of DataModel::Provider #37345
base: master
Are you sure you want to change the base?
Conversation
|
||
for (auto entry : buffer) | ||
{ | ||
if (!addedExtraGlobals && entry.attributeId > lastGlobalId) |
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 am somewhat unclear why we sort these...this was taken from the existing implementation, but it does seem to make the code more complex. Is the spec requiring sorting?
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.
Spec does not require sorting. ember attribute metadata is sorted.
When implementing attributes not in metadata we kept the "act as if they are still in metadata" behavior. But yes, we can probably nix this part and just put these things at the end, always.
PR #37345: Size comparison from 435583e to 94b4cf5 Full report (3 builds for cc32xx, stm32)
|
PR #37345: Size comparison from 435583e to 1fe7070 Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
PR #37345: Size comparison from 26341b4 to 058fcf2 Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
// if we get here, the path was NOT valid | ||
if (err == CHIP_ERROR_NOT_FOUND) | ||
{ | ||
return DataModel::ValidateClusterPath(provider, path, Status::Failure); |
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.
Worth commenting that the Status::Failure is arbitrary, because in practice we clearly failed on the endpoint-or-cluster level above?
@@ -80,6 +80,13 @@ class EndpointFinder | |||
ReadOnlyBuffer<EndpointEntry> mEndpoints; | |||
}; | |||
|
|||
/// Validates that the cluster identified by `path` exists within the given provider. | |||
/// If the endpoint exists but does not have the cluster identified by the path, will return Status::UnsupportedCluster. |
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.
/// If the endpoint exists but does not have the cluster identified by the path, will return Status::UnsupportedCluster. | |
/// If the endpoint does not exist, will return Status::UnsupportedEndpoint. | |
/// If the endpoint exists but does not have the cluster identified by the path, will return Status::UnsupportedCluster. |
/// Validates that the cluster identified by `path` exists within the given provider. | ||
/// If the endpoint exists but does not have the cluster identified by the path, will return Status::UnsupportedCluster. | ||
/// | ||
/// otherwise, it will return successStatus. |
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.
/// otherwise, it will return successStatus. | |
/// Otherwise, will return successStatus. |
@@ -37,6 +37,7 @@ | |||
#include <lib/support/CodeUtils.h> | |||
#include <optional> | |||
#include <protocols/interaction_model/StatusCode.h> | |||
#include <regex.h> |
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 is regex.h needed? That seems very odd.
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.
auto-include (probably by a typo) ... will fix
else | ||
{ | ||
|
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.
@@ -177,8 +178,15 @@ DataModel::ActionReturnStatus RetrieveClusterData(DataModel::Provider * dataMode | |||
{ | |||
status = *access_status; | |||
} | |||
else if (IsSupportedGlobalAttributeNotInMetadata(readRequest.path.mAttributeId)) | |||
{ | |||
// Global attributes are NOT directly handled by datamodel providers, instead |
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.
// Global attributes are NOT directly handled by datamodel providers, instead | |
// Global attributes are NOT directly handled by data model providers, instead |
@@ -116,27 +114,13 @@ DataModel::ActionReturnStatus CodegenDataModelProvider::ReadAttribute(const Data | |||
} | |||
|
|||
// Read via AAI | |||
std::optional<CHIP_ERROR> aai_result; | |||
if (const EmberAfCluster ** cluster = std::get_if<const EmberAfCluster *>(&metadata)) |
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.
Is the "what is the right error if we have no metadata" thing FindAttributeMetadata does still relevant here? Or is that all handled by callers now?
Also, the comments above this method no longer match the actual method behavior. Those should have been adjusted in previous PRs, but we should at least do it now.
const EmberAfAttributeMetadata * attributeMetadata = std::get<const EmberAfAttributeMetadata *>(metadata); | ||
// We can only get a status or metadata. |
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.
What guarantees that? What if someone in fact does a read for a global attribute on the provider?
@@ -102,6 +103,10 @@ DataModel::ActionReturnStatus CodegenDataModelProvider::WriteAttribute(const Dat | |||
// and tests and implementation | |||
// | |||
// Open issue that needs fixing: https://github.com/project-chip/connectedhomeip/issues/33735 | |||
|
|||
// First check things that are not even in metadata. These are read.only. | |||
VerifyOrReturnValue(!IsSupportedGlobalAttributeNotInMetadata(request.path.mAttributeId), Status::UnsupportedWrite); |
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 does not match spec, if it's actually the status that will get returned, for cases when the cluster does not exist.
So either the cluster existence check is done before we ever get here (?) or we have no test coverage for this case.
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.
Oh, one last important thing: Where are the changes to the Provider.h documentation that explain that providers do not handle global attributes not in metadata and callers have to do that themselves?
@@ -82,6 +82,27 @@ std::optional<EndpointEntry> EndpointFinder::Find(EndpointId endpointId) | |||
return std::nullopt; | |||
} | |||
|
|||
Protocols::InteractionModel::Status ValidateClusterPath(ProviderMetadataTree * provider, const ConcreteClusterPath & path, |
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 seems to duplicate ValidateClusterPath in EmberMetadata.... Is it worth commoning those up somehow?
Since this part is already in metadata, this makes code cleaner and easier to maintain (and easier to write providers).
Fixes #36486
Testing
Unit tests were updated.
Since PR #37338 merged, the changes in TestReadInteraction should be reasonable readable in what got added (generally the global list attributes).