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 @@ -43,6 +43,7 @@ source_set("device-factory") {
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dimmable-light:logging",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dimmable-plug-in-unit",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dishwasher:emulated",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/doorbell",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/electrical-sensor:logging",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/extractor-hood",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/fan:logging",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <device/types/dimmable-light/impl/LoggingDimmableLight.h>
#include <device/types/dimmable-plug-in-unit/DimmablePlugInUnit.h>
#include <device/types/dishwasher/impl/EmulatedDishwasher.h>
#include <device/types/doorbell/Doorbell.h>
#include <device/types/electrical-sensor/impl/SimulatedElectricalSensor.h>
#include <device/types/extractor-hood/ExtractorHood.h>
#include <device/types/fan/impl/LoggingFan.h>
Expand Down Expand Up @@ -351,6 +352,14 @@ class DeviceFactory
DimmableLoad::Config{ .levelControl = DimmableLoad::LevelControlConfig::CiPicsDefaults() });
});
}
if constexpr (ALL_DEVICES_ENABLE_DOORBELL)
{
RegisterCreator("doorbell", [this]() {
VerifyOrDie(mContext.has_value());
return std::make_unique<Doorbell>(mContext->timerDelegate, mContext->platformManager, mContext->bindingTable,
mContext->bindingManager);
});
}
if constexpr (ALL_DEVICES_ENABLE_MOUNTED_ON_OFF_CONTROL)
{
RegisterCreator("mounted-on-off-control", [this]() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ set(ALL_DEVICES_DEVICE_SOURCES
"${ALL_DEVICES_COMMON_DIR}/device/types/dimmable-plug-in-unit/DimmablePlugInUnit.cpp"
"${ALL_DEVICES_COMMON_DIR}/device/types/dishwasher/Dishwasher.cpp"
"${ALL_DEVICES_COMMON_DIR}/device/types/dishwasher/impl/EmulatedDishwasher.cpp"
"${ALL_DEVICES_COMMON_DIR}/device/types/doorbell/Doorbell.cpp"
"${ALL_DEVICES_COMMON_DIR}/device/types/electrical-sensor/ElectricalSensor.cpp"
"${ALL_DEVICES_COMMON_DIR}/device/types/electrical-sensor/impl/SimulatedElectricalSensor.cpp"
"${ALL_DEVICES_COMMON_DIR}/device/types/electrical-sensor/impl/FakeReadings.cpp"
Expand Down Expand Up @@ -178,6 +179,7 @@ foreach(_key
dimmable-light
dimmable-plug-in-unit
dishwasher
doorbell
electrical-sensor
extractor-hood
fan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ _available_devices = [
"dishwasher",
"DISHWASHER",
],
[
"doorbell",
"DOORBELL",
],
[
"electrical-sensor",
"ELECTRICAL_SENSOR",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#cmakedefine01 ALL_DEVICES_ENABLE_DIMMABLE_LIGHT
#cmakedefine01 ALL_DEVICES_ENABLE_DIMMABLE_PLUG_IN_UNIT
#cmakedefine01 ALL_DEVICES_ENABLE_DISHWASHER
#cmakedefine01 ALL_DEVICES_ENABLE_DOORBELL
#cmakedefine01 ALL_DEVICES_ENABLE_ELECTRICAL_SENSOR
#cmakedefine01 ALL_DEVICES_ENABLE_EXTRACTOR_HOOD
#cmakedefine01 ALL_DEVICES_ENABLE_FAN
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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("doorbell") {
sources = [
"Doorbell.cpp",
"Doorbell.h",
]

public_deps = [
"${chip_root}/examples/all-devices-app/all-devices-common/device/api:single-endpoint-device",
"${chip_root}/src/app/clusters/bindings",
"${chip_root}/src/app/clusters/identify-server",
"${chip_root}/src/app/clusters/switch-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,112 @@
/*
*
* 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 <clusters/Chime/Ids.h>
#include <device/types/doorbell/Doorbell.h>
#include <devices/Types.h>
#include <lib/support/logging/CHIPLogging.h>

using namespace chip::app::Clusters;

namespace chip {
namespace app {

namespace {
const ClusterId kClientClusters[] = { Chime::Id };
// Assuming a simple doorbell with two switch positions.
const uint8_t kSwitchNumberOfPositions = 2;
} // namespace

Doorbell::Doorbell(TimerDelegate & timerDelegate, DeviceLayer::PlatformManager & platformManager,
Clusters::Binding::Table & bindingTable, Clusters::Binding::Manager & bindingManager) :
SingleEndpoint(Span<const DataModel::DeviceTypeEntry>(&Device::Type::kDoorbell, 1)),
mTimerDelegate(timerDelegate), mPlatformManager(platformManager), mBindingTable(bindingTable), mBindingManager(bindingManager)
{}

CHIP_ERROR Doorbell::Register(chip::EndpointId endpoint, CodeDrivenDataModelProvider & provider, EndpointComposition composition)
{
VerifyOrReturnError(mEndpointId == kInvalidEndpointId, CHIP_ERROR_INCORRECT_STATE);
DeviceRegistrationTransaction transaction(*this, provider);

ReturnErrorOnFailure(RegisterDescriptor(endpoint, provider, composition));

mIdentifyCluster.Create(IdentifyCluster::Config(endpoint, mTimerDelegate));
ReturnErrorOnFailure(provider.AddCluster(mIdentifyCluster.Registration()));

mSwitchCluster.Create(endpoint, BitFlags<Switch::Feature>(Switch::Feature::kMomentarySwitch),
SwitchCluster::StartupConfiguration{ .numberOfPositions = kSwitchNumberOfPositions });
ReturnErrorOnFailure(provider.AddCluster(mSwitchCluster.Registration()));

mBindingCluster.Create(
BindingCluster::Context{
.bindingTable = mBindingTable,
.bindingManager = mBindingManager,
.platformManager = mPlatformManager,
},
endpoint);
ReturnErrorOnFailure(provider.AddCluster(mBindingCluster.Registration()));

ReturnErrorOnFailure(provider.AddEndpoint(mEndpointRegistration));

transaction.Commit();
return CHIP_NO_ERROR;
}

void Doorbell::Unregister(CodeDrivenDataModelProvider & provider)
{
UnregisterDescriptor(provider);
if (mBindingCluster.IsConstructed())
{
LogErrorOnFailure(provider.RemoveCluster(&mBindingCluster.Cluster()));
mBindingCluster.Destroy();
}
if (mSwitchCluster.IsConstructed())
{
LogErrorOnFailure(provider.RemoveCluster(&mSwitchCluster.Cluster()));
mSwitchCluster.Destroy();
}
if (mIdentifyCluster.IsConstructed())
{
LogErrorOnFailure(provider.RemoveCluster(&mIdentifyCluster.Cluster()));
mIdentifyCluster.Destroy();
}
}

CHIP_ERROR Doorbell::ClientClusters(ReadOnlyBufferBuilder<ClusterId> & out) const
{
return out.ReferenceExisting(Span<const ClusterId>(kClientClusters));
}

Clusters::SwitchCluster & Doorbell::SwitchCluster()
{
VerifyOrDie(mSwitchCluster.IsConstructed());
return mSwitchCluster.Cluster();
}

Clusters::IdentifyCluster & Doorbell::IdentifyCluster()
{
VerifyOrDie(mIdentifyCluster.IsConstructed());
return mIdentifyCluster.Cluster();
}

Clusters::BindingCluster & Doorbell::BindingCluster()
{
VerifyOrDie(mBindingCluster.IsConstructed());
return mBindingCluster.Cluster();
}

} // namespace app
} // namespace chip
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
*
* 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/bindings/BindingCluster.h>
#include <app/clusters/bindings/BindingManager.h>
#include <app/clusters/bindings/binding-table.h>
#include <app/clusters/identify-server/IdentifyCluster.h>
#include <app/clusters/switch-server/SwitchCluster.h>
#include <data-model-providers/codedriven/CodeDrivenDataModelProvider.h>
#include <device/api/SingleEndpoint.h>
#include <lib/support/Span.h>
#include <lib/support/TimerDelegate.h>
#include <platform/PlatformManager.h>

namespace chip {
namespace app {

class Doorbell : public SingleEndpoint
{
public:
Doorbell(TimerDelegate & timerDelegate, DeviceLayer::PlatformManager & platformManager, Clusters::Binding::Table & bindingTable,
Clusters::Binding::Manager & bindingManager);
~Doorbell() override = default;

CHIP_ERROR Register(chip::EndpointId endpoint, CodeDrivenDataModelProvider & provider,
EndpointComposition composition = {}) override;
void Unregister(CodeDrivenDataModelProvider & provider) override;

CHIP_ERROR ClientClusters(ReadOnlyBufferBuilder<ClusterId> & out) const override;

Clusters::IdentifyCluster & IdentifyCluster();
Clusters::SwitchCluster & SwitchCluster();
Clusters::BindingCluster & BindingCluster();

protected:
TimerDelegate & mTimerDelegate;
DeviceLayer::PlatformManager & mPlatformManager;
Clusters::Binding::Table & mBindingTable;
Clusters::Binding::Manager & mBindingManager;
LazyRegisteredServerCluster<Clusters::IdentifyCluster> mIdentifyCluster;
LazyRegisteredServerCluster<Clusters::SwitchCluster> mSwitchCluster;
LazyRegisteredServerCluster<Clusters::BindingCluster> mBindingCluster;
};

} // namespace app
} // namespace chip
1 change: 1 addition & 0 deletions examples/all-devices-app/posix/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ executable("all-devices-app") {
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/device-energy-management",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dimmable-plug-in-unit",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dishwasher",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/doorbell",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/electrical-sensor",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/extractor-hood",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/fan",
Expand Down
1 change: 1 addition & 0 deletions examples/all-devices-app/silabs/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ silabs_executable("all_devices_app") {
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/device-energy-management",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dimmable-light",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/dimmable-plug-in-unit",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/doorbell",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/electrical-sensor",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/extractor-hood",
"${chip_root}/examples/all-devices-app/all-devices-common/device/types/generic-switch",
Expand Down
1 change: 1 addition & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
'dimmable-light',
'dimmable-plug-in-unit',
'dishwasher',
'doorbell',
'electrical-sensor',
'extractor-hood',
'fan',
Expand Down
Loading
Loading