Skip to content

Commit

Permalink
[Linux] Matter Linux Water Leak Detector Example (project-chip#35392)
Browse files Browse the repository at this point in the history
* [Linux] Matter Linux Water Leak Detector Example

* Update README.md

Remote Echo protocol section

* Update water-leak-detector-app.zap

* Symlinks

* New sym links

* Update README.md

Fix typo

* Create water-leak-detector-app.matter

* Update water-leak-detector-app.matter

Remove last line

* Update README.md

* Update water-leak-detector-app.matter

* Update water-leak-detector-app.zap

* Update water-leak-detector-app.matter

* Update water-leak-detector-app.zap

* Update water-leak-detector-app.matter

* Delete examples/water-leak-detector-app/linux/README.md

* Update targets.py to add WATER_LEAK_DETECTOR

* Update host.py to add WATER_LEAK_DETECTOR

* Update water-leak-detector-app.matter

Fix ThreeLevelAutoEnum

* Update all_targets_linux_x64.txt

Add water-leak-detector
  • Loading branch information
lboue authored Oct 7, 2024
1 parent 386816b commit bcc1f1b
Show file tree
Hide file tree
Showing 13 changed files with 5,415 additions and 1 deletion.
25 changes: 25 additions & 0 deletions examples/water-leak-detector-app/linux/.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2024 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")

# The location of the build configuration file.
buildconfig = "${build_root}/config/BUILDCONFIG.gn"

# CHIP uses angle bracket includes.
check_system_includes = true

default_args = {
import("//args.gni")
}
64 changes: 64 additions & 0 deletions examples/water-leak-detector-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) 2024 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/chip.gni")

import("${chip_root}/build/chip/tools.gni")
import("${chip_root}/src/app/common_flags.gni")
import("${chip_root}/third_party/imgui/imgui.gni")

assert(chip_build_tools)

config("includes") {
include_dirs = [
".",
"include",
]
}

executable("water-leak-detector-app") {
sources = [
"include/CHIPProjectAppConfig.h",
"main.cpp",
]

deps = [
"${chip_root}/examples/platform/linux:app-main",
"${chip_root}/examples/water-leak-detector-app/water-leak-detector-common",
"${chip_root}/src/lib",
]

if (chip_examples_enable_imgui_ui) {
deps += [
"${chip_root}/examples/common/imgui_ui",
"${chip_root}/examples/common/imgui_ui/windows:boolean_state",
"${chip_root}/examples/common/imgui_ui/windows:occupancy_sensing",
"${chip_root}/examples/common/imgui_ui/windows:qrcode",
]
}

include_dirs = [ "include" ]

cflags = [ "-Wconversion" ]

output_dir = root_out_dir
}

group("linux") {
deps = [ ":water-leak-detector-app" ]
}

group("default") {
deps = [ ":linux" ]
}
28 changes: 28 additions & 0 deletions examples/water-leak-detector-app/linux/args.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright (c) 2024 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.

# CHIPProjectConfig.h

import("//build_overrides/chip.gni")

import("${chip_root}/config/standalone/args.gni")

chip_device_project_config_include = "<CHIPProjectAppConfig.h>"
chip_project_config_include = "<CHIPProjectAppConfig.h>"
chip_system_project_config_include = "<SystemProjectConfig.h>"

chip_project_config_include_dirs =
[ "${chip_root}/examples/water-leak-detector-app/linux/include" ]
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]
matter_enable_tracing_support = true
1 change: 1 addition & 0 deletions examples/water-leak-detector-app/linux/build_overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* 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 the CHIPProjectConfig from config/standalone
#include <CHIPProjectConfig.h>

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY 0

// Bulbs do not typically use this - enabled so we can use shell to discover commissioners
#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT 1

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1

#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 0x0043 // Water Leak Detector

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_NAME 1

#define CHIP_DEVICE_ENABLE_PORT_PARAMS 1

#define CHIP_DEVICE_CONFIG_DEVICE_NAME "Water Leak Detector"
53 changes: 53 additions & 0 deletions examples/water-leak-detector-app/linux/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* 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 <AppMain.h>
#include <platform/CHIPDeviceConfig.h>

#if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED
#include <imgui_ui/ui.h>
#include <imgui_ui/windows/boolean_state.h>
#include <imgui_ui/windows/occupancy_sensing.h>
#include <imgui_ui/windows/qrcode.h>
#endif

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;

void ApplicationInit() {}

void ApplicationShutdown() {}

int main(int argc, char * argv[])
{
VerifyOrDie(ChipLinuxAppInit(argc, argv) == 0);

#if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED
example::Ui::ImguiUi ui;

ui.AddWindow(std::make_unique<example::Ui::Windows::QRCode>());
ui.AddWindow(std::make_unique<example::Ui::Windows::BooleanState>(chip::EndpointId(1), "Water Leak Detector"));

ChipLinuxAppMainLoop(&ui);
#else
ChipLinuxAppMainLoop();
#endif

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2024 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/chip.gni")
import("${chip_root}/src/app/chip_data_model.gni")

chip_data_model("water-leak-detector-common") {
zap_file = "water-leak-detector-app.zap"
is_server = true
}
Loading

0 comments on commit bcc1f1b

Please sign in to comment.