-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Chef: Add APIs to provide deviceType info on Endpoints. Make chef static temperature levels (temperature control cluster) endpoint agnostic. #38142
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
Merged
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
88f6797
Chef: Add APIs to provide deviceType info on Endpoints. Fix compositi…
sxb427 3441ee1
+
sxb427 bf2fde7
+
sxb427 8a441e2
Fix: two elements should not have common bits in an enum used as bitmask
sxb427 210234c
Merge branch 'master' into oven
sxb427 dc03344
Restyled by clang-format
restyled-commits b2f7220
Refactoring
sxb427 4641c8a
compilation err
sxb427 e2dd9f4
compilation err
sxb427 d8cf98a
compilation err
sxb427 7252e81
compilation err
sxb427 5e13d4b
compilation err
sxb427 e528154
compilation err
sxb427 0a04f6c
compilation err
sxb427 187407b
compilation err
sxb427 dd52e75
compilation err
sxb427 a1a8756
compilation err
sxb427 487ce16
compilation err
sxb427 0e1d905
compilation err
sxb427 f0fb2b9
compilation err
sxb427 d6a1a8c
compilation err
sxb427 e0a688a
compilation err
sxb427 a95ac81
compilation err
sxb427 49fb24f
compilation err
sxb427 81bfbf1
compilation err
sxb427 af847e1
compilation err
sxb427 137cdb0
compilation err
sxb427 50c084a
compilation err
sxb427 48cfc55
compilation err
sxb427 6aaf697
Merge branch 'master' into oven
sxb427 8426fb2
compilation err
sxb427 27faf55
compilation err
sxb427 faaee88
Merge branch 'master' into oven
sxb427 fbed38a
+
sxb427 b6fbf5e
Rename DataModelUtils to DeviceTypes
sxb427 9a688f7
Document the new methods
sxb427 a208953
Fix invalid memory.
sxb427 fa062ed
Fix compilation
sxb427 f954b82
Comments for EndpointPair struct. New chef namespace for cluster conf…
sxb427 f731b94
+
sxb427 b32ee18
Merge branch 'master' into oven
sxb427 2bb9099
Do not silently ignore CHIP_ERROR return value
sxb427 dcc6b0c
Review suggestion
sxb427 cdb5c3b
Review suggestion
sxb427 fd556ec
Use Enums for expected endpoint IDs
sxb427 c348009
Avoid enums due to casting issue
sxb427 01b50ae
Use Span for temperature levels
sxb427 3b8200d
Use Span for temperature levels
sxb427 dd544d4
Fix compilation
sxb427 69e71f0
nit: Rename constant.
sxb427 b204b5e
Merge branch 'master' into oven
sxb427 7336521
Merge branch 'master' into oven
sxb427 b0dd140
Merge branch 'master' into oven
sxb427 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* | ||
* Copyright (c) 2025 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "DeviceTypes.h" | ||
#include <app/InteractionModelEngine.h> | ||
#include <app/data-model-provider/MetadataTypes.h> | ||
#include <lib/support/CodeUtils.h> | ||
|
||
using namespace chef; | ||
using namespace chip; | ||
using namespace chip::app; | ||
|
||
bool DeviceTypes::EndpointHasDeviceType(EndpointId endpoint, DeviceTypeId deviceTypeId) | ||
{ | ||
DataModel::ListBuilder<DataModel::DeviceTypeEntry> deviceTypesList; | ||
CHIP_ERROR err = InteractionModelEngine::GetInstance()->GetDataModelProvider()->DeviceTypes(endpoint, deviceTypesList); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
ChipLogError(DeviceLayer, "GetDataModelProvider DeviceTypes returned error: %" CHIP_ERROR_FORMAT, err.Format()); | ||
return false; | ||
} | ||
auto deviceTypes = deviceTypesList.TakeBuffer(); | ||
for (const auto & type : deviceTypes) | ||
{ | ||
if (type.deviceTypeId == deviceTypeId) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
DataModel::ListBuilder<EndpointId> DeviceTypes::GetAllEndpointsHavingDeviceType(DeviceTypeId deviceTypeId) | ||
{ | ||
DataModel::ListBuilder<DataModel::EndpointEntry> endpointsList; | ||
CHIP_ERROR err = InteractionModelEngine::GetInstance()->GetDataModelProvider()->Endpoints(endpointsList); | ||
if (err != CHIP_NO_ERROR) | ||
{ | ||
ChipLogError(DeviceLayer, "GetDataModelProvider Endpoints returned error: %" CHIP_ERROR_FORMAT, err.Format()); | ||
return DataModel::ListBuilder<EndpointId>(); | ||
} | ||
auto allEndpoints = endpointsList.TakeBuffer(); | ||
|
||
DataModel::ListBuilder<EndpointId> endpoints; | ||
|
||
for (const auto & ep : allEndpoints) | ||
{ | ||
if (EndpointHasDeviceType(ep.id, deviceTypeId)) | ||
{ | ||
endpoints.Append(ep.id); | ||
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. Post-merge review because #38364 noticed this:
|
||
} | ||
} | ||
return endpoints; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* | ||
* Copyright (c) 2025 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <app/data-model-provider/MetadataList.h> | ||
#include <lib/core/CHIPError.h> | ||
#include <lib/core/DataModelTypes.h> | ||
|
||
namespace chef { | ||
namespace DeviceTypes { | ||
|
||
// Common location to store all device type IDs | ||
sxb427 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Official list is in the spec and a complete copy is in - | ||
// https://github.com/project-chip/connectedhomeip/blob/master/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml | ||
// TODO: Device type IDs must be code generated from matter-devices.xml | ||
constexpr chip::DeviceTypeId kCookSurfaceDeviceId = 0x0077; | ||
constexpr chip::DeviceTypeId kCooktopDeviceId = 0x0078; | ||
constexpr chip::DeviceTypeId kOvenDeviceId = 0x007B; | ||
constexpr chip::DeviceTypeId kRefrigeratorDeviceId = 0x0070; | ||
constexpr chip::DeviceTypeId kTemperatureControlledCabinetDeviceId = 0x0071; | ||
|
||
// Expected endpoint IDs for different device types | ||
namespace ExpectedEndpointId { | ||
// Oven | ||
constexpr chip::EndpointId kOven = 1; | ||
constexpr chip::EndpointId kTopCabinetPartOfOven = 2; | ||
constexpr chip::EndpointId kCooktopPartOfOven = 3; | ||
constexpr chip::EndpointId kCookSurfacePartOfCooktopOven = 4; | ||
|
||
// Cooktop | ||
constexpr chip::EndpointId kCooktopStandAlone = 1; | ||
constexpr chip::EndpointId kCookSurfacePartOfCooktop = 2; | ||
|
||
// Refrigerator | ||
constexpr chip::EndpointId kRefrigerator = 1; | ||
constexpr chip::EndpointId kColdCabinetPartOfRefrigerator = 2; | ||
constexpr chip::EndpointId kFreezeCabinetPartOfRefrigerator = 3; | ||
} // namespace ExpectedEndpointId | ||
|
||
// Devicetype APIs | ||
|
||
/** | ||
* Returns true if the endpoint has the specified device type in its device types list. | ||
* Device types list for the given endpoint is fetched using DataModelProvider. | ||
*/ | ||
bool EndpointHasDeviceType(chip::EndpointId endpoint, chip::DeviceTypeId deviceTypeId); | ||
|
||
/** | ||
* Returns a list of all endpoints that have the specified device type in their respective device types list. | ||
* Endpoints list is fetched using DataModelProvider. Device type match is checked using EndpointHasDeviceType. | ||
*/ | ||
chip::app::DataModel::ListBuilder<chip::EndpointId> GetAllEndpointsHavingDeviceType(chip::DeviceTypeId deviceTypeId); | ||
|
||
} // namespace DeviceTypes | ||
} // namespace chef |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
post merge review, also fixed in followup: this should return the data, not a builder.