-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Code Driven All Devices Example App #41607
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
zaid-google
wants to merge
51
commits into
project-chip:master
Choose a base branch
from
zaid-google:new_all_devices_app
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 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 4708c00
Restyled by whitespace
restyled-commits 1e0aa5e
Restyled by clang-format
restyled-commits 1f10a27
Restyled by gn
restyled-commits 5d05758
Address some review comments
zaid-google d6bf556
Merge branch 'master' into new_all_devices_app
zaid-google 050d6a7
Address more review comments
zaid-google 675bc02
Restyled by whitespace
restyled-commits 54f4933
Restyled by clang-format
restyled-commits e755f19
Restyled by gn
restyled-commits 899949a
More review comments
zaid-google 14230f4
Review comments for BUILD.gn configs
zaid-google 0debc8d
Restyled by clang-format
restyled-commits 523ed12
Restyled by gn
restyled-commits 1f52853
Add TODOs based on review comments
zaid-google cdd6d6e
Restyled by whitespace
restyled-commits 1e8876a
Restyled by clang-format
restyled-commits 794d2aa
Merge branch 'master' into new_all_devices_app
zaid-google 42517f3
Update wifi diagnostics optional atteribute set usage
zaid-google eebaef9
Remove SemanticTags function from Device
zaid-google c1c6f3a
Restyled by clang-format
restyled-commits 5164883
Make device endpoint a command line argument
zaid-google ed2caa6
Cleanup includes and remove old args.gni
zaid-google cd2c5e0
Address comments, make command line args seperate from main
zaid-google 5392dbc
Fix merge conflict
zaid-google ec9c9ba
Restyled by whitespace
restyled-commits 0b4d7cb
Restyled by clang-format
restyled-commits 1cabc92
Restyled by gn
restyled-commits 879cffd
separation of base device with single endpoint device
zaid-google 5ef1f49
Add comments, fix unregister calls, cleanup of member variables
zaid-google 09a94f2
Remove unique pointer for timer
zaid-google 5263526
Restyled by whitespace
restyled-commits 28da318
Restyled by clang-format
restyled-commits 1eee251
update comment
zaid-google ac62669
Restyled by whitespace
restyled-commits e1d7e9c
Restructure device interfaces
zaid-google b015385
Add all devices app build and basic composition test to CI
zaid-google 9afcb3b
Restyled by clang-format
restyled-commits 87e732f
Remove build variants for CI, not currently supported
zaid-google 0256f69
Fix path for all devices app in CI
zaid-google 3521dc0
Update device info provider used
zaid-google 00f9a30
Update comments
zaid-google a589afb
Restyled by whitespace
restyled-commits c6210d5
Restyled by clang-format
restyled-commits f93e4e0
Add new device info provider
zaid-google 3c9ba8f
Restyled by whitespace
restyled-commits 8f52e9f
Restyled by clang-format
restyled-commits bfa4f89
Update examples/providers/AllDevicesExampleDeviceInfoProviderImpl.cpp
andy31415 af50f13
Update examples/all-devices-app/all-devices-common/devices/boolean-st…
andy31415 d1c1b5c
Update examples/all-devices-app/all-devices-common/devices/interface/…
andy31415 d557cba
Update examples/all-devices-app/all-devices-common/devices/interface/…
andy31415 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
27 changes: 27 additions & 0 deletions
27
examples/all-devices-app/all-devices-common/devices/base-device/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,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", | ||
| ] | ||
| } |
68 changes: 68 additions & 0 deletions
68
examples/all-devices-app/all-devices-common/devices/base-device/Device.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,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> | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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); | ||
zaid-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| mEndpointId = endpoint; | ||
|
|
||
| mDescriptorCluster.Create(endpoint, DescriptorCluster::OptionalAttributesSet(0), Span<const SemanticTag>()); | ||
zaid-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ReturnErrorOnFailure(provider.AddCluster(mDescriptorCluster.Registration())); | ||
|
|
||
| mEndpointRegistration.endpointEntry = DataModel::EndpointEntry{ | ||
| .id = endpoint, // | ||
| .parentId = parentId, // | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .compositionPattern = DataModel::EndpointCompositionPattern::kFullFamily, | ||
| }; | ||
| return CHIP_NO_ERROR; | ||
| } | ||
|
|
||
| CHIP_ERROR Device::DeviceTypes(ReadOnlyBufferBuilder<DataModel::DeviceTypeEntry> & out) const | ||
| { | ||
| ReturnErrorOnFailure(out.EnsureAppendCapacity(1)); | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (mDescriptorCluster.IsConstructed()) | ||
| { | ||
| ReturnErrorOnFailure(out.Append(DataModel::DeviceTypeEntry{ | ||
| .deviceTypeId = mDeviceType.deviceType, | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .deviceTypeRevision = static_cast<uint8_t>(mDeviceType.revision), | ||
| })); | ||
| } | ||
|
|
||
| return CHIP_NO_ERROR; | ||
| } | ||
|
|
||
| CHIP_ERROR Device::SemanticTags(ReadOnlyBufferBuilder<SemanticTag> & out) const | ||
| { | ||
| // no semantic tags | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return CHIP_NO_ERROR; | ||
| } | ||
|
|
||
| CHIP_ERROR Device::ClientClusters(ReadOnlyBufferBuilder<ClusterId> & out) const | ||
| { | ||
| // no bindings | ||
| return CHIP_NO_ERROR; | ||
| } | ||
|
|
||
| } // namespace chip::app | ||
70 changes: 70 additions & 0 deletions
70
examples/all-devices-app/all-devices-common/devices/base-device/Device.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,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 | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /// 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 | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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 | ||
29 changes: 29 additions & 0 deletions
29
examples/all-devices-app/all-devices-common/devices/contact-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,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", | ||
| ] | ||
| } |
51 changes: 51 additions & 0 deletions
51
examples/all-devices-app/all-devices-common/devices/contact-sensor/ContactSensorDevice.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,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 |
50 changes: 50 additions & 0 deletions
50
examples/all-devices-app/all-devices-common/devices/contact-sensor/ContactSensorDevice.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,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 }) | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {} | ||
| ~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(); } | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| private: | ||
| DefaultTimerDelegate mTimerDelegate; | ||
zaid-google marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| LazyRegisteredServerCluster<Clusters::IdentifyCluster> mIdentifyCluster; | ||
| LazyRegisteredServerCluster<Clusters::BooleanStateCluster> mBooleanStateCluster; | ||
| }; | ||
|
|
||
| } // namespace app | ||
| } // namespace chip | ||
22 changes: 22 additions & 0 deletions
22
examples/all-devices-app/all-devices-common/devices/device-factory/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,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", | ||
| ] | ||
| } |
60 changes: 60 additions & 0 deletions
60
examples/all-devices-app/all-devices-common/devices/device-factory/DeviceFactory.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,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 | ||
zaid-google marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| 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 | ||
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.