Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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 @@ -33,6 +33,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 @@ -344,6 +345,14 @@ class DeviceFactory
DimmableLoad::Config{ .levelControl = DimmableLoad::LevelControlConfig::CiPicsDefaults() });
});
}
if constexpr (ALL_DEVICES_ENABLE_DOORBELL)
{
RegisterCreator("doorbell", [this]() {
Comment on lines +477 to +479
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 @@ -172,6 +172,7 @@ foreach(_key
dimmable-light
dimmable-plug-in-unit
dishwasher
doorbell
electrical-sensor
Comment thread
tersal marked this conversation as resolved.
extractor-hood
fan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,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 @@ -19,6 +19,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,35 @@
# 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/chime-server",
"${chip_root}/src/app/clusters/identify-server",
"${chip_root}/src/app/clusters/switch-server",
Comment thread
Copilot marked this conversation as resolved.
"${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/",
Comment thread
Copilot marked this conversation as resolved.
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
*
* 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 <device/types/doorbell/Doorbell.h>
#include <devices/Types.h>
#include <lib/support/logging/CHIPLogging.h>
Comment thread
Copilot marked this conversation as resolved.
Comment thread
Copilot marked this conversation as resolved.

using namespace chip::app::Clusters;

namespace chip {
namespace app {

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should go to some impl/ folder decision.

The generic types/doorbell should be generic and get this kind of stuff injected. Then a impl/SimulatedDoorbell can have an actual implementation, likely logging or actual simulation for things that involve time.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another possibility:

  • element requirement for doorbell is that Switch has MomentarySwitch so the number of positions are spec-defined to 2 (not arbitrary).

In that case, naming should reflect that and we can have a comment on requirements in ::Register

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the number of positions injected in the constructor since it seems to only configuration needed for this type of device.

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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identify delegate must generally be set on the cluster, otherwise we do not get to set it again.

We probably should get the identify injected and maybe make a impl subclass that has a logging version.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the Logging Identify delegate in the cluster constructor.

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;
}
Comment thread
Copilot marked this conversation as resolved.

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,62 @@
/*
*
* 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/chime-server/ChimeCluster.h>
#include <app/clusters/identify-server/IdentifyCluster.h>
#include <app/clusters/switch-server/SwitchCluster.h>
Comment thread
tersal marked this conversation as resolved.
#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 @@ -49,6 +49,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",
Comment thread
Copilot marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
"${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 @@ -121,6 +121,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