Skip to content

Commit df778eb

Browse files
sabollim-silabsrestyled-commitsarun-silabsmkardous-silabs
authored
Adding closure linux app (project-chip#38717)
* Adding closure linux App * Restyled by whitespace * Restyled by clang-format * Restyled by prettier-markdown * Resolve CI build error for linux app * Add closure as target * Fix CI build errors * Fixing CI build errors * Addressing PR comments * Apply suggestions from code review Co-authored-by: Mathieu Kardous <84793247+mkardous-silabs@users.noreply.github.com> * Addressing PR comments * Adding linux app to CI build and tests * Fix CI build failure * Fix CI build failure * Fix CI build failure * Adding documentation * Restyled by prettier-markdown * Addressing PR comments * Addressing PR comments * Fix CI build failures * Segregating CI enabling and Test enabling into seperate PR * Addressing PR comments * Addressing PR comments * Add closure app to issue_triage doc * Adding Maintainer for closure App --------- Co-authored-by: sabollim <satyanaag.bollimpalli@silabs.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Arun Padakanti <arunkumar.padakanti@silabs.com> Co-authored-by: Mathieu Kardous <84793247+mkardous-silabs@users.noreply.github.com>
1 parent 855bd8e commit df778eb

File tree

9 files changed

+353
-0
lines changed

9 files changed

+353
-0
lines changed

docs/issue_triage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ types or functionality) as well as individual examples.
106106
| `examples/build_overrides` | | UNMAINTAINED |
107107
| `examples/chef` | Andrei Litvin | |
108108
| `examples/chip-tool` | | UNMAINTAINED |
109+
| `examples/closure-app` | Satyanaag Bollimpalli | |
109110
| `examples/contact-sensor-app` | | UNMAINTAINED |
110111
| `examples/darwin-framework-tool` | Boris Zbarsky | |
111112
| `examples/dishwasher-app` | | UNMAINTAINED |

examples/closure-app/linux/.gn

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2025 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
17+
# The location of the build configuration file.
18+
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
19+
20+
# CHIP uses angle bracket includes.
21+
check_system_includes = true
22+
23+
default_args = {
24+
import("//args.gni")
25+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright (c) 2025 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import("//build_overrides/build.gni")
16+
import("//build_overrides/chip.gni")
17+
18+
import("${chip_root}/build/chip/tools.gni")
19+
20+
import("${build_root}/config/linux/pkg_config.gni")
21+
22+
assert(chip_build_tools)
23+
24+
config("config") {
25+
include_dirs = [
26+
"include",
27+
"${chip_root}/examples/closure-app/closure-common/include",
28+
]
29+
}
30+
31+
executable("closure-app") {
32+
configs += [ ":config" ]
33+
34+
sources = [
35+
"${chip_root}/examples/closure-app/closure-common/src/ClosureControlEndpoint.cpp",
36+
"${chip_root}/examples/closure-app/closure-common/src/ClosureDimensionEndpoint.cpp",
37+
"include/CHIPProjectAppConfig.h",
38+
"main.cpp",
39+
]
40+
41+
deps = [
42+
"${chip_root}/examples/closure-app/closure-common",
43+
"${chip_root}/examples/platform/linux:app-main",
44+
"${chip_root}/src/lib",
45+
]
46+
47+
output_dir = root_out_dir
48+
}
49+
50+
group("linux") {
51+
deps = [ ":closure-app" ]
52+
}
53+
54+
group("default") {
55+
deps = [ ":linux" ]
56+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# CHIP Linux Closure Example App
2+
3+
An example showing the use of Matter on the Linux. The document will describe
4+
how to build and run Matter Linux Closure Example on Raspberry Pi. This doc is
5+
tested on **Ubuntu for Raspberry Pi Server 20.04 LTS (aarch64)** and **Ubuntu
6+
for Raspberry Pi Desktop 20.10 (aarch64)**
7+
8+
<hr>
9+
10+
- [CHIP Linux Closure Example App](#chip-linux-closure-example-app)
11+
- [Building](#building)
12+
- [Commandline arguments](#commandline-arguments)
13+
- [Running the Complete Example on Raspberry Pi 4](#running-the-complete-example-on-raspberry-pi-4)
14+
15+
<hr>
16+
17+
## Building
18+
19+
- Install tool chain
20+
21+
$ sudo apt-get install git gcc g++ python pkg-config libssl-dev libdbus-1-dev libglib2.0-dev ninja-build python3-venv python3-dev unzip
22+
23+
- Build the example application:
24+
25+
$ cd ~/connectedhomeip/examples/closure-app/linux
26+
$ git submodule update --init
27+
$ source third_party/connectedhomeip/scripts/activate.sh
28+
$ gn gen out/debug
29+
$ ninja -C out/debug
30+
31+
- To delete generated executable, libraries and object files use:
32+
33+
$ cd ~/connectedhomeip/examples/closure-app/linux
34+
$ rm -rf out/
35+
36+
- Build the example with pigweed RPC
37+
38+
$ cd ~/connectedhomeip/examples/closure-app/linux
39+
$ git submodule update --init
40+
$ source third_party/connectedhomeip/scripts/activate.sh
41+
$ gn gen out/debug --args='import("//with_pw_rpc.gni")'
42+
$ ninja -C out/debug
43+
44+
## Commandline arguments
45+
46+
- `--wifi`
47+
48+
Enables WiFi management feature. Required for WiFi commissioning.
49+
50+
- `--thread`
51+
52+
Enables Thread management feature, requires ot-br-posix dbus daemon running.
53+
Required for Thread commissioning.
54+
55+
- `--ble-controller <selector>`
56+
57+
Use the specific Bluetooth controller for BLE advertisement and connections.
58+
For details on controller selection refer to
59+
[Linux BLE Settings](/platforms/linux/ble_settings.md).
60+
61+
## Running the Complete Example on Raspberry Pi 4
62+
63+
> gn gen out/debug
64+
> ninja -C out/debug
65+
66+
- Prerequisites
67+
68+
1. A Raspberry Pi 4 board
69+
2. A USB Bluetooth Dongle, Ubuntu desktop will send Bluetooth advertisement,
70+
which will block Matter from connecting via BLE. On Ubuntu server, you
71+
need to install `pi-bluetooth` via APT.
72+
3. Ubuntu 20.04 or newer image for ARM64 platform.
73+
74+
- Building
75+
76+
Follow [Building](#building) section of this document.
77+
78+
- Running
79+
80+
- [Optional] Plug USB Bluetooth dongle
81+
82+
- Plug USB Bluetooth dongle and find its bluetooth controller selector
83+
as described in
84+
[Linux BLE Settings](/platforms/linux/ble_settings.md).
85+
86+
- Run Linux Closure Example App
87+
88+
$ cd ~/connectedhomeip/examples/closure-app/linux
89+
$ sudo out/debug/closure-app --ble-controller [bluetooth controller number]
90+
# In this example, the device we want to use is hci1
91+
$ sudo out/debug/closure-app --ble-controller 1
92+
93+
- Test the device using ChipDeviceController on your laptop / workstation
94+
etc.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) 2025 Project CHIP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# CHIPProjectConfig.h
16+
17+
import("//build_overrides/chip.gni")
18+
19+
import("${chip_root}/config/standalone/args.gni")
20+
21+
chip_device_project_config_include = "<CHIPProjectAppConfig.h>"
22+
chip_project_config_include = "<CHIPProjectAppConfig.h>"
23+
chip_system_project_config_include = "<SystemProjectConfig.h>"
24+
chip_project_config_include_dirs =
25+
[ "${chip_root}/examples/closure-app/linux/include" ]
26+
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../build_overrides/
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
*
3+
* Copyright (c) 2025 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
// include the CHIPProjectConfig from config/standalone
22+
#include <CHIPProjectConfig.h>
23+
24+
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY 0
25+
26+
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT 1
27+
28+
#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1
29+
30+
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1
31+
32+
#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 0x0230 // Closure Device Type
33+
34+
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_NAME 1
35+
36+
#define CHIP_DEVICE_ENABLE_PORT_PARAMS 1
37+
38+
#define CHIP_DEVICE_CONFIG_DEVICE_NAME "Closure"
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
#include "ClosureControlEndpoint.h"
19+
#include "ClosureDimensionEndpoint.h"
20+
#include <AppMain.h>
21+
22+
#include <app-common/zap-generated/cluster-objects.h>
23+
#include <app/util/attribute-storage.h>
24+
#include <platform/CHIPDeviceLayer.h>
25+
26+
using namespace chip;
27+
using namespace chip::app;
28+
using namespace chip::app::Clusters::ClosureControl;
29+
using namespace chip::app::Clusters::ClosureDimension;
30+
31+
namespace {
32+
33+
// Define the endpoint ID for the Closure
34+
constexpr chip::EndpointId kClosureEndpoint = 1;
35+
constexpr chip::EndpointId kClosurePanel1Endpoint = 2;
36+
constexpr chip::EndpointId kClosurePanel2Endpoint = 3;
37+
38+
// Closure Endpoints
39+
ClosureControlEndpoint ep1(kClosureEndpoint);
40+
ClosureDimensionEndpoint ep2(kClosurePanel1Endpoint);
41+
ClosureDimensionEndpoint ep3(kClosurePanel2Endpoint);
42+
43+
// Define the Namespace and Tag for the endpoint
44+
// Derived from https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces/Namespace-Closure.adoc
45+
constexpr uint8_t kNamespaceClosure = 0x44;
46+
constexpr uint8_t kTagClosureCovering = 0x00;
47+
// Derived from
48+
// https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces/Namespace-Closure-Covering.adoc
49+
constexpr uint8_t kNamespaceCovering = 0x46;
50+
constexpr uint8_t kTagCoveringVenetian = 0x03;
51+
// Derived from https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces/Namespace-ClosurePanel.adoc
52+
constexpr uint8_t kNamespaceClosurePanel = 0x45;
53+
constexpr uint8_t kTagClosurePanelLift = 0x00;
54+
constexpr uint8_t kTagClosurePanelTilt = 0x01;
55+
56+
// Define the list of semantic tags for the endpoint
57+
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp1TagList[] = {
58+
{ .namespaceID = kNamespaceClosure,
59+
.tag = kTagClosureCovering,
60+
.label = chip::MakeOptional(DataModel::Nullable<chip::CharSpan>("Closure.Covering"_span)) },
61+
{ .namespaceID = kNamespaceCovering,
62+
.tag = kTagCoveringVenetian,
63+
.label = chip::MakeOptional(DataModel::Nullable<chip::CharSpan>("Covering.Venetian"_span)) },
64+
};
65+
66+
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp2TagList[] = {
67+
{ .namespaceID = kNamespaceClosurePanel,
68+
.tag = kTagClosurePanelLift,
69+
.label = chip::MakeOptional(DataModel::Nullable<chip::CharSpan>("ClosurePanel.Lift"_span)) },
70+
};
71+
72+
const Clusters::Descriptor::Structs::SemanticTagStruct::Type gEp3TagList[] = {
73+
{ .namespaceID = kNamespaceClosurePanel,
74+
.tag = kTagClosurePanelTilt,
75+
.label = chip::MakeOptional(DataModel::Nullable<chip::CharSpan>("ClosurePanel.Tilt"_span)) },
76+
};
77+
78+
} // namespace
79+
80+
void ApplicationInit()
81+
{
82+
DeviceLayer::PlatformMgr().LockChipStack();
83+
84+
// Closure endpoints initilization
85+
ep1.Init();
86+
ep2.Init();
87+
ep3.Init();
88+
89+
// Set Taglist for Closure endpoints
90+
SetTagList(/* endpoint= */ 1, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gEp1TagList));
91+
SetTagList(/* endpoint= */ 2, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gEp2TagList));
92+
SetTagList(/* endpoint= */ 3, Span<const Clusters::Descriptor::Structs::SemanticTagStruct::Type>(gEp3TagList));
93+
94+
DeviceLayer::PlatformMgr().UnlockChipStack();
95+
}
96+
97+
void ApplicationShutdown()
98+
{
99+
ChipLogDetail(NotSpecified, "ApplicationShutdown()");
100+
}
101+
102+
int main(int argc, char * argv[])
103+
{
104+
if (ChipLinuxAppInit(argc, argv) != 0)
105+
{
106+
return -1;
107+
}
108+
109+
ChipLinuxAppMainLoop();
110+
return 0;
111+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../

0 commit comments

Comments
 (0)