-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add the application-side logic of the Ambient Context Sensing cluster server handler to all-devices-app #72731
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
Open
crlonxp
wants to merge
6
commits into
project-chip:master
Choose a base branch
from
crlonxp:acs-dev-app-pr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f864809
Add ambient context sensor device
crlonxp 142f6c6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 919b004
Fix a typo
crlonxp 69825a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] c6448ac
Restyled by gn
restyled-commits d809827
Add the missing file to .cmake
crlonxp 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
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
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
64 changes: 64 additions & 0 deletions
64
...ices-app/all-devices-common/devices/ambient-context-sensor/AmbientContextSensorDevice.cpp
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,64 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2026 Project CHIP Authors | ||
| * | ||
| * 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 <devices/Types.h> | ||
| #include <devices/ambient-context-sensor/AmbientContextSensorDevice.h> | ||
| #include <lib/support/logging/CHIPLogging.h> | ||
|
|
||
| using namespace chip::app::Clusters; | ||
|
|
||
| namespace chip::app { | ||
|
|
||
| AmbientContextSensorDevice::AmbientContextSensorDevice(AmbientContextSensingConfig config, TimerDelegate & timerDelegate) : | ||
| SingleEndpointDevice(Span<const DataModel::DeviceTypeEntry>(&Device::Type::kAmbientContextSensor, 1)), mConfig(config), | ||
| mTimerDelegate(timerDelegate) | ||
| {} | ||
|
|
||
| CHIP_ERROR AmbientContextSensorDevice::Register(chip::EndpointId endpoint, CodeDrivenDataModelProvider & provider, | ||
| EndpointComposition composition) | ||
| { | ||
| ReturnErrorOnFailure(RegisterDescriptor(endpoint, provider, composition)); | ||
|
|
||
| // Create the identify cluster. | ||
| mIdentifyCluster.Create(IdentifyCluster::Config(endpoint, mTimerDelegate)); | ||
| ReturnErrorOnFailure(provider.AddCluster(mIdentifyCluster.Registration())); | ||
|
|
||
| // Update the config with the actual endpoint ID | ||
| mConfig.mEndpointId = endpoint; | ||
|
|
||
| // Create the ambient context sensing cluster | ||
| mAmbientContextSensingCluster.Create(mConfig); | ||
| ReturnErrorOnFailure(provider.AddCluster(mAmbientContextSensingCluster.Registration())); | ||
|
|
||
| return provider.AddEndpoint(mEndpointRegistration); | ||
| } | ||
|
|
||
| void AmbientContextSensorDevice::Unregister(CodeDrivenDataModelProvider & provider) | ||
| { | ||
| UnregisterDescriptor(provider); | ||
| if (mAmbientContextSensingCluster.IsConstructed()) | ||
| { | ||
| LogErrorOnFailure(provider.RemoveCluster(&mAmbientContextSensingCluster.Cluster())); | ||
| mAmbientContextSensingCluster.Destroy(); | ||
| } | ||
| if (mIdentifyCluster.IsConstructed()) | ||
| { | ||
| LogErrorOnFailure(provider.RemoveCluster(&mIdentifyCluster.Cluster())); | ||
| mIdentifyCluster.Destroy(); | ||
| } | ||
| } | ||
|
|
||
| } // namespace chip::app |
49 changes: 49 additions & 0 deletions
49
...evices-app/all-devices-common/devices/ambient-context-sensor/AmbientContextSensorDevice.h
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,49 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2026 Project CHIP Authors | ||
| * | ||
| * 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. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <app/clusters/identify-server/IdentifyCluster.h> | ||
| #include <app/clusters/ambient-context-sensing-server/AmbientContextSensingCluster.h> | ||
| #include <devices/interface/SingleEndpointDevice.h> | ||
| #include <lib/support/TimerDelegate.h> | ||
|
|
||
| namespace chip::app { | ||
|
|
||
| class AmbientContextSensorDevice : public SingleEndpointDevice | ||
| { | ||
| public: | ||
| using AmbientContextSensingConfig = Clusters::AmbientContextSensingCluster::Config; | ||
|
|
||
| AmbientContextSensorDevice(AmbientContextSensingConfig config, TimerDelegate & timerDelegate); | ||
| ~AmbientContextSensorDevice() override = default; | ||
|
|
||
| // DeviceInterface pure virtual lifecycle hooks | ||
| CHIP_ERROR Register(chip::EndpointId endpoint, CodeDrivenDataModelProvider & provider, | ||
| EndpointComposition composition = {}) override; | ||
| void Unregister(CodeDrivenDataModelProvider & provider) override; | ||
|
|
||
| Clusters::IdentifyCluster & IdentifyCluster() { return mIdentifyCluster.Cluster(); } | ||
| Clusters::AmbientContextSensingCluster & AmbientContextSensingCluster() { return mAmbientContextSensingCluster.Cluster(); } | ||
|
|
||
| protected: | ||
| AmbientContextSensingConfig mConfig; | ||
| TimerDelegate & mTimerDelegate; | ||
| LazyRegisteredServerCluster<Clusters::IdentifyCluster> mIdentifyCluster; | ||
| LazyRegisteredServerCluster<Clusters::AmbientContextSensingCluster> mAmbientContextSensingCluster; | ||
| }; | ||
|
|
||
| } // namespace chip::app |
33 changes: 33 additions & 0 deletions
33
examples/all-devices-app/all-devices-common/devices/ambient-context-sensor/BUILD.gn
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,33 @@ | ||
| # Copyright (c) 2026 Project CHIP Authors | ||
| # | ||
| # 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. | ||
|
|
||
| import("//build_overrides/build.gni") | ||
| import("//build_overrides/chip.gni") | ||
|
|
||
| source_set("ambient-context-sensor") { | ||
| sources = [ | ||
| "AmbientContextSensorDevice.cpp", | ||
| "AmbientContextSensorDevice.h", | ||
| ] | ||
|
|
||
| public_deps = [ | ||
| "${chip_root}/examples/all-devices-app/all-devices-common/devices/interface:single-endpoint-device", | ||
| "${chip_root}/src/app/clusters/identify-server", | ||
| "${chip_root}/src/app/clusters/ambient-context-sensing-server", | ||
| "${chip_root}/src/data-model-providers/codedriven", | ||
| "${chip_root}/src/lib/core:error", | ||
| "${chip_root}/src/lib/support", | ||
| "${chip_root}/zzz_generated/app-common/devices/", | ||
| ] | ||
| } |
30 changes: 30 additions & 0 deletions
30
examples/all-devices-app/all-devices-common/devices/ambient-context-sensor/impl/BUILD.gn
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,30 @@ | ||
| # Copyright (c) 2026 Project CHIP Authors | ||
| # | ||
| # 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. | ||
|
|
||
| import("//build_overrides/build.gni") | ||
| import("//build_overrides/chip.gni") | ||
|
|
||
| #source_set("toggling") { | ||
| source_set("logging") { | ||
| sources = [ | ||
| "LoggingAmbientContextSensorDevice.cpp", | ||
| "LoggingAmbientContextSensorDevice.h", | ||
| ] | ||
|
|
||
| public_deps = [ | ||
| "${chip_root}/examples/all-devices-app/all-devices-common/devices/ambient-context-sensor", | ||
| "${chip_root}/src/lib/support", | ||
| "${chip_root}/src/platform", | ||
| ] | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.