Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2fef989
Initial draft of all devices example app
zaid-google Oct 23, 2025
4708c00
Restyled by whitespace
restyled-commits Oct 23, 2025
1e0aa5e
Restyled by clang-format
restyled-commits Oct 23, 2025
1f10a27
Restyled by gn
restyled-commits Oct 23, 2025
5d05758
Address some review comments
zaid-google Oct 24, 2025
d6bf556
Merge branch 'master' into new_all_devices_app
zaid-google Oct 24, 2025
050d6a7
Address more review comments
zaid-google Oct 24, 2025
675bc02
Restyled by whitespace
restyled-commits Oct 24, 2025
54f4933
Restyled by clang-format
restyled-commits Oct 24, 2025
e755f19
Restyled by gn
restyled-commits Oct 24, 2025
899949a
More review comments
zaid-google Oct 24, 2025
14230f4
Review comments for BUILD.gn configs
zaid-google Oct 24, 2025
0debc8d
Restyled by clang-format
restyled-commits Oct 24, 2025
523ed12
Restyled by gn
restyled-commits Oct 24, 2025
1f52853
Add TODOs based on review comments
zaid-google Oct 27, 2025
cdd6d6e
Restyled by whitespace
restyled-commits Oct 27, 2025
1e8876a
Restyled by clang-format
restyled-commits Oct 27, 2025
794d2aa
Merge branch 'master' into new_all_devices_app
zaid-google Oct 27, 2025
42517f3
Update wifi diagnostics optional atteribute set usage
zaid-google Oct 27, 2025
eebaef9
Remove SemanticTags function from Device
zaid-google Oct 27, 2025
c1c6f3a
Restyled by clang-format
restyled-commits Oct 27, 2025
5164883
Make device endpoint a command line argument
zaid-google Oct 29, 2025
ed2caa6
Cleanup includes and remove old args.gni
zaid-google Oct 29, 2025
cd2c5e0
Address comments, make command line args seperate from main
zaid-google Oct 30, 2025
5392dbc
Fix merge conflict
zaid-google Oct 31, 2025
ec9c9ba
Restyled by whitespace
restyled-commits Oct 31, 2025
0b4d7cb
Restyled by clang-format
restyled-commits Oct 31, 2025
1cabc92
Restyled by gn
restyled-commits Oct 31, 2025
879cffd
separation of base device with single endpoint device
zaid-google Oct 31, 2025
5ef1f49
Add comments, fix unregister calls, cleanup of member variables
zaid-google Oct 31, 2025
09a94f2
Remove unique pointer for timer
zaid-google Oct 31, 2025
5263526
Restyled by whitespace
restyled-commits Oct 31, 2025
28da318
Restyled by clang-format
restyled-commits Oct 31, 2025
1eee251
update comment
zaid-google Oct 31, 2025
ac62669
Restyled by whitespace
restyled-commits Oct 31, 2025
e1d7e9c
Restructure device interfaces
zaid-google Nov 3, 2025
b015385
Add all devices app build and basic composition test to CI
zaid-google Nov 3, 2025
9afcb3b
Restyled by clang-format
restyled-commits Nov 3, 2025
87e732f
Remove build variants for CI, not currently supported
zaid-google Nov 3, 2025
0256f69
Fix path for all devices app in CI
zaid-google Nov 4, 2025
3521dc0
Update device info provider used
zaid-google Nov 4, 2025
00f9a30
Update comments
zaid-google Nov 4, 2025
a589afb
Restyled by whitespace
restyled-commits Nov 4, 2025
c6210d5
Restyled by clang-format
restyled-commits Nov 4, 2025
f93e4e0
Add new device info provider
zaid-google Nov 4, 2025
3c9ba8f
Restyled by whitespace
restyled-commits Nov 4, 2025
8f52e9f
Restyled by clang-format
restyled-commits Nov 4, 2025
bfa4f89
Update examples/providers/AllDevicesExampleDeviceInfoProviderImpl.cpp
andy31415 Nov 6, 2025
af50f13
Update examples/all-devices-app/all-devices-common/devices/boolean-st…
andy31415 Nov 6, 2025
d1c1b5c
Update examples/all-devices-app/all-devices-common/devices/interface/…
andy31415 Nov 6, 2025
d557cba
Update examples/all-devices-app/all-devices-common/devices/interface/…
andy31415 Nov 6, 2025
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
5 changes: 4 additions & 1 deletion examples/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ if (chip_build_tests) {
deps = []
tests = []
if (chip_device_platform == "linux" && current_os == "linux") {
tests += [ "${chip_root}/examples/energy-management-app/energy-management-common/tests" ]
tests += [
"${chip_root}/examples/all-devices-app/tests",
"${chip_root}/examples/energy-management-app/energy-management-common/tests",
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

config("includes") {
# allows includes like "devices/..."
include_dirs = [ "../.." ]
}

source_set("base-device") {
sources = [
"Device.cpp",
"Device.h",
]

public_deps = [
"${chip_root}/src/app/clusters/descriptor",
"${chip_root}/src/data-model-providers/codedriven",
"${chip_root}/src/lib/core:error",
"${chip_root}/src/lib/support",
"${chip_root}/zzz_generated/app-common/clusters/Descriptor",
]

public_configs = [
":includes",
"${chip_root}/src:includes",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
*
* Copyright (c) 2025 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.h"
#include <memory>

using namespace chip::app::Clusters;

namespace chip::app {

CHIP_ERROR Device::BaseRegistration(EndpointId endpoint, CodeDrivenDataModelProvider & provider, EndpointId parentId)
{
VerifyOrReturnError(mEndpointId == kInvalidEndpointId, CHIP_ERROR_INCORRECT_STATE);
mEndpointId = endpoint;

mDescriptorCluster.Create(endpoint, DescriptorCluster::OptionalAttributesSet(0), Span<const SemanticTag>());
ReturnErrorOnFailure(provider.AddCluster(mDescriptorCluster.Registration()));

mEndpointRegistration.endpointEntry = DataModel::EndpointEntry{
.id = endpoint, //
.parentId = parentId, //
.compositionPattern = DataModel::EndpointCompositionPattern::kFullFamily,
};
return CHIP_NO_ERROR;
}

CHIP_ERROR Device::DeviceTypes(ReadOnlyBufferBuilder<DataModel::DeviceTypeEntry> & out) const
{
ReturnErrorOnFailure(out.EnsureAppendCapacity(1));

if (mDescriptorCluster.IsConstructed())
{
ReturnErrorOnFailure(out.Append(DataModel::DeviceTypeEntry{
.deviceTypeId = mDeviceType.deviceType,
.deviceTypeRevision = static_cast<uint8_t>(mDeviceType.revision),
}));
}

return CHIP_NO_ERROR;
}

CHIP_ERROR Device::SemanticTags(ReadOnlyBufferBuilder<SemanticTag> & out) const
{
// no semantic tags
return CHIP_NO_ERROR;
}

CHIP_ERROR Device::ClientClusters(ReadOnlyBufferBuilder<ClusterId> & out) const
{
// no bindings
return CHIP_NO_ERROR;
}

} // namespace chip::app
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
*
* Copyright (c) 2025 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/descriptor/descriptor-cluster.h>
#include <app/util/basic-types.h>
#include <clusters/Descriptor/Structs.h>
#include <data-model-providers/codedriven/CodeDrivenDataModelProvider.h>
#include <data-model-providers/codedriven/endpoint/EndpointInterfaceRegistry.h>

#include <string>

namespace chip::app {

/// A device is a entity that maintains some cluster functionality.
///
/// Current implementation assumes that a device is registered on a single
/// endpoint.
class Device : public EndpointInterface
{
public:
using DeviceType = Clusters::Descriptor::Structs::DeviceTypeStruct::Type;
Device(const DeviceType & deviceType) : mDeviceType(deviceType), mEndpointRegistration(*this, {}) {}
virtual ~Device() = default;

EndpointId GetEndpointId() const { return mEndpointId; }

/// Register relevant clusters on the given endpoint
virtual CHIP_ERROR Register(EndpointId endpoint, CodeDrivenDataModelProvider & provider,
EndpointId parentId = kInvalidEndpointId) = 0;

/// Remove clusters from the given provider.
///
/// Will only be called if register has succeeded before
virtual void UnRegister(CodeDrivenDataModelProvider & provider) = 0;

// Endpoint interface implementation
CHIP_ERROR SemanticTags(ReadOnlyBufferBuilder<SemanticTag> & out) const override;
CHIP_ERROR DeviceTypes(ReadOnlyBufferBuilder<DataModel::DeviceTypeEntry> & out) const override;
CHIP_ERROR ClientClusters(ReadOnlyBufferBuilder<ClusterId> & out) const override;

protected:
/// Internal registration function for common device clusters and endpoint registration.
/// Subclasses are expected to call this
CHIP_ERROR BaseRegistration(EndpointId endpoint, CodeDrivenDataModelProvider & provider, EndpointId parentId);

EndpointId mEndpointId = kInvalidEndpointId;
const DeviceType mDeviceType;
EndpointInterfaceRegistration mEndpointRegistration;

// Common clusters..
LazyRegisteredServerCluster<Clusters::DescriptorCluster> mDescriptorCluster;
};

} // namespace chip::app
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

config("includes") {
# allows includes like "devices/..."
include_dirs = [ ".." ]
}

source_set("contact-sensor") {
sources = [
"ContactSensorDevice.cpp",
"ContactSensorDevice.h",
]

public_deps = [
"${chip_root}/examples/all-devices-app/all-devices-common/devices/base-device",
"${chip_root}/src/app/clusters/boolean-state-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/clusters/Descriptor",
]

public_configs = [
":includes",
"${chip_root}/src:includes",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
*
* Copyright (c) 2025 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/contact-sensor/ContactSensorDevice.h>

using namespace chip::app::Clusters;

namespace chip::app {

CHIP_ERROR ContactSensorDevice::Register(chip::EndpointId endpoint, CodeDrivenDataModelProvider & provider, EndpointId parentId)
{
ReturnErrorOnFailure(BaseRegistration(endpoint, provider, parentId));

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

mBooleanStateCluster.Create(endpoint);
ReturnErrorOnFailure(provider.AddCluster(mBooleanStateCluster.Registration()));

return provider.AddEndpoint(mEndpointRegistration);
}

void ContactSensorDevice::UnRegister(CodeDrivenDataModelProvider & provider)
{
provider.RemoveEndpoint(mEndpointId);
if (mBooleanStateCluster.IsConstructed())
{
provider.RemoveCluster(&mBooleanStateCluster.Cluster());
mBooleanStateCluster.Destroy();
}
if (mIdentifyCluster.IsConstructed())
{
provider.RemoveCluster(&mIdentifyCluster.Cluster());
mIdentifyCluster.Destroy();
}
}

} // namespace chip::app
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
*
* Copyright (c) 2025 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/TimerDelegates.h>
#include <app/clusters/boolean-state-server/boolean-state-cluster.h>
#include <app/clusters/identify-server/IdentifyCluster.h>
#include <devices/base-device/Device.h>

namespace chip {
namespace app {

constexpr DeviceTypeId kContactSensorDeviceTypeRevision = 2;

class ContactSensorDevice : public Device
{
public:
ContactSensorDevice() :
Device(Device::DeviceType{ .deviceType = static_cast<DeviceTypeId>(0x0015), .revision = kContactSensorDeviceTypeRevision })
{}
~ContactSensorDevice() override = default;

CHIP_ERROR Register(chip::EndpointId endpoint, CodeDrivenDataModelProvider & provider,
EndpointId parentId = kInvalidEndpointId) override;
void UnRegister(CodeDrivenDataModelProvider & provider) override;

Clusters::BooleanStateCluster & Cluster() { return mBooleanStateCluster.Cluster(); }

private:
DefaultTimerDelegate mTimerDelegate;
LazyRegisteredServerCluster<Clusters::IdentifyCluster> mIdentifyCluster;
LazyRegisteredServerCluster<Clusters::BooleanStateCluster> mBooleanStateCluster;
};

} // namespace app
} // namespace chip
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")

config("includes") {
# allows includes like "devices/..."
include_dirs = [ "../.." ]
}

source_set("device-factory") {
sources = [ "DeviceFactory.h" ]

public_deps = [
"${chip_root}/examples/all-devices-app/all-devices-common/devices/contact-sensor",
"${chip_root}/examples/all-devices-app/all-devices-common/devices/water-leak-detector",
"${chip_root}/src/lib/core:error",
]

public_configs = [
":includes",
"${chip_root}/src:includes",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
*
* Copyright (c) 2025 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 <devices/contact-sensor/ContactSensorDevice.h>
#include <devices/water-leak-detector/WaterLeakDetectorDevice.h>
#include <functional>
#include <lib/core/CHIPError.h>
#include <map>

namespace chip::app {

class DeviceFactory
{
public:
using DeviceCreator = std::function<std::unique_ptr<Device>()>;

static DeviceFactory & GetInstance()
{
static DeviceFactory instance;
return instance;
}

bool IsValidDevice(const std::string & deviceTypeArg) { return mRegistry.find(deviceTypeArg) != mRegistry.end(); }

std::unique_ptr<Device> Create(const std::string & deviceTypeArg)
{
if (IsValidDevice(deviceTypeArg))
{
return mRegistry.find(deviceTypeArg)->second();
}
return nullptr;
}

private:
std::map<std::string, DeviceCreator> mRegistry;

DeviceFactory()
{
mRegistry["contact-sensor"] = []() { return std::make_unique<ContactSensorDevice>(); };
mRegistry["water-leak-detector"] = []() { return std::make_unique<WaterLeakDetectorDevice>(); };
}
};

} // namespace chip::app
Loading
Loading