Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ source_set("device-factory") {
"${chip_root}/examples/all-devices-app/all-devices-common/devices/aggregator",
"${chip_root}/examples/all-devices-app/all-devices-common/devices/air-purifier/impl:logging",
"${chip_root}/examples/all-devices-app/all-devices-common/devices/air-quality-sensor",
"${chip_root}/examples/all-devices-app/all-devices-common/devices/ambient-context-sensor/impl:logging",
"${chip_root}/examples/all-devices-app/all-devices-common/devices/boolean-state-sensor",
"${chip_root}/examples/all-devices-app/all-devices-common/devices/bridged-node",
"${chip_root}/examples/all-devices-app/all-devices-common/devices/chime",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <devices/aggregator/AggregatorDevice.h>
#include <devices/air-purifier/impl/LoggingAirPurifierDevice.h>
#include <devices/air-quality-sensor/AirQualitySensorDevice.h>
#include <devices/ambient-context-sensor/impl/LoggingAmbientContextSensorDevice.h>
#include <devices/boolean-state-sensor/BooleanStateSensorDevice.h>
#include <devices/bridged-node/BridgedNodeDevice.h>
#include <devices/chime/ChimeDevice.h>
Expand Down Expand Up @@ -205,6 +206,14 @@ class DeviceFactory
});
});
}
if constexpr (ALL_DEVICES_ENABLE_AMBIENT_CONTEXT_SENSOR)
{
RegisterCreator("ambient-context-sensor", [this]() {
VerifyOrDie(mContext.has_value());
return std::make_unique<Clusters::AmbientContextSensing::LoggingAmbientContextSensorDevice>(
mContext->timerDelegate);
});
}
if constexpr (ALL_DEVICES_ENABLE_BRIDGED_NODE)
{
RegisterCreator("bridged-node", [this](const std::string & nodeLabel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ set(ALL_DEVICES_DEVICE_SOURCES
"${ALL_DEVICES_COMMON_DIR}/devices/air-purifier/AirPurifierDevice.cpp"
"${ALL_DEVICES_COMMON_DIR}/devices/air-purifier/impl/LoggingAirPurifierDevice.cpp"
"${ALL_DEVICES_COMMON_DIR}/devices/air-quality-sensor/AirQualitySensorDevice.cpp"
"${ALL_DEVICES_COMMON_DIR}/devices/ambient-context-sensor/AmbientContextSensorDevice.cpp"
"${ALL_DEVICES_COMMON_DIR}/devices/ambient-context-sensor/impl/LoggingAmbientContextSensorDevice.cpp"
"${ALL_DEVICES_COMMON_DIR}/devices/boolean-state-sensor/BooleanStateSensorDevice.cpp"
"${ALL_DEVICES_COMMON_DIR}/devices/bridged-node/BridgedNodeDevice.cpp"
"${ALL_DEVICES_COMMON_DIR}/devices/chime/ChimeDevice.cpp"
Expand Down Expand Up @@ -147,6 +149,7 @@ foreach(_key
aggregator
air-purifier
air-quality-sensor
ambient-context-sensor
bridged-node
chime
contact-sensor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ _available_devices = [
"air-quality-sensor",
"AIR_QUALITY_SENSOR",
],
[
"ambient-context-sensor",
"AMBIENT_CONTEXT_SENSOR",
],
[
"bridged-node",
"BRIDGED_NODE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#cmakedefine01 ALL_DEVICES_ENABLE_AGGREGATOR
#cmakedefine01 ALL_DEVICES_ENABLE_AIR_PURIFIER
#cmakedefine01 ALL_DEVICES_ENABLE_AIR_QUALITY_SENSOR
#cmakedefine01 ALL_DEVICES_ENABLE_AMBIENT_CONTEXT_SENSOR
#cmakedefine01 ALL_DEVICES_ENABLE_BRIDGED_NODE
#cmakedefine01 ALL_DEVICES_ENABLE_CHIME
#cmakedefine01 ALL_DEVICES_ENABLE_CONTACT_SENSOR
Expand Down
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
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/ambient-context-sensing-server/AmbientContextSensingCluster.h>
#include <app/clusters/identify-server/IdentifyCluster.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
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/ambient-context-sensing-server",
"${chip_root}/src/app/clusters/identify-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/",
]
}
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",
]
}
Loading
Loading