-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* A linux contact sensor app * Fix project config * Also add occupancy sensing UI * Restyle * Added TODO for boolean state - no impl yet though * Remove unnedded init override * Copy over networking logic form all clusters. This seems unusually complex unfortunately * Use bridge as an example of network commissioning * Update HAL comment with linking the boolean state issue * Restyle * Ensure port parameters are enabled in the contact sensor app --------- Co-authored-by: Andrei Litvin <[email protected]>
- Loading branch information
Showing
15 changed files
with
568 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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,65 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 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 "boolean_state.h" | ||
|
||
#include <imgui.h> | ||
|
||
#include <math.h> | ||
|
||
#include <app-common/zap-generated/attributes/Accessors.h> | ||
#include <app-common/zap-generated/cluster-enums.h> | ||
|
||
namespace example { | ||
namespace Ui { | ||
namespace Windows { | ||
|
||
void BooleanState::UpdateState() | ||
{ | ||
if (mTargetState.HasValue()) | ||
{ | ||
// TODO: if src/app/clusters/boolean-state exists, we should use its | ||
// mutation API. | ||
// | ||
// See https://github.com/project-chip/connectedhomeip/issues/25225 for | ||
// the feature request asking for a BooleanState HAL. | ||
chip::app::Clusters::BooleanState::Attributes::StateValue::Set(mEndpointId, mTargetState.Value()); | ||
mTargetState.ClearValue(); | ||
} | ||
|
||
chip::app::Clusters::BooleanState::Attributes::StateValue::Get(mEndpointId, &mState); | ||
} | ||
|
||
void BooleanState::Render() | ||
{ | ||
ImGui::Begin(mTitle.c_str()); | ||
ImGui::Text("On Endpoint %d", mEndpointId); | ||
|
||
bool uiState = mState; | ||
ImGui::Checkbox("State Value", &uiState); | ||
|
||
if (uiState != mState) | ||
{ | ||
// toggle value on the next 'UpdateState' call | ||
mTargetState.SetValue(uiState); | ||
} | ||
|
||
ImGui::End(); | ||
} | ||
|
||
} // namespace Windows | ||
} // namespace Ui | ||
} // namespace example |
This file contains 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,52 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 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 "window.h" | ||
|
||
#include <stdint.h> | ||
#include <string> | ||
|
||
#include <app/data-model/Nullable.h> | ||
#include <lib/core/DataModelTypes.h> | ||
#include <lib/core/Optional.h> | ||
|
||
#include <app-common/zap-generated/cluster-enums.h> | ||
|
||
namespace example { | ||
namespace Ui { | ||
namespace Windows { | ||
|
||
class BooleanState : public Window | ||
{ | ||
public: | ||
BooleanState(chip::EndpointId endpointId, const char * title) : mEndpointId(endpointId), mTitle(title) {} | ||
|
||
void UpdateState() override; | ||
void Render() override; | ||
|
||
private: | ||
const chip::EndpointId mEndpointId; | ||
const std::string mTitle; | ||
|
||
bool mState = false; | ||
chip::Optional<bool> mTargetState; | ||
}; | ||
|
||
} // namespace Windows | ||
} // namespace Ui | ||
} // namespace example |
This file contains 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,64 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 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 "occupancy_sensing.h" | ||
|
||
#include <imgui.h> | ||
|
||
#include <math.h> | ||
|
||
#include <app-common/zap-generated/attributes/Accessors.h> | ||
#include <app-common/zap-generated/cluster-enums.h> | ||
|
||
namespace example { | ||
namespace Ui { | ||
namespace Windows { | ||
|
||
using chip::app::Clusters::OccupancySensing::OccupancyBitmap; | ||
|
||
void OccupancySensing::UpdateState() | ||
{ | ||
if (mTargetOccupancy.HasValue()) | ||
{ | ||
chip::app::Clusters::OccupancySensing::Attributes::Occupancy::Set(mEndpointId, mTargetOccupancy.Value()); | ||
mTargetOccupancy.ClearValue(); | ||
} | ||
|
||
chip::app::Clusters::OccupancySensing::Attributes::Occupancy::Get(mEndpointId, &mOccupancy); | ||
} | ||
|
||
void OccupancySensing::Render() | ||
{ | ||
ImGui::Begin(mTitle.c_str()); | ||
ImGui::Text("On Endpoint %d", mEndpointId); | ||
|
||
bool occupied = mOccupancy.Has(OccupancyBitmap::kOccupied); | ||
bool uiState = occupied; | ||
ImGui::Checkbox("Occupancy Value", &uiState); | ||
|
||
if (uiState != occupied) | ||
{ | ||
// toggle value on the next 'UpdateState' call | ||
// Occupancy is just a single bit, update it as such | ||
mTargetOccupancy.SetValue(uiState ? BitMask(OccupancyBitmap::kOccupied) : BitMask()); | ||
} | ||
|
||
ImGui::End(); | ||
} | ||
|
||
} // namespace Windows | ||
} // namespace Ui | ||
} // namespace example |
This file contains 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,54 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 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 "window.h" | ||
|
||
#include <stdint.h> | ||
#include <string> | ||
|
||
#include <app/data-model/Nullable.h> | ||
#include <lib/core/DataModelTypes.h> | ||
#include <lib/core/Optional.h> | ||
|
||
#include <app-common/zap-generated/cluster-enums.h> | ||
|
||
namespace example { | ||
namespace Ui { | ||
namespace Windows { | ||
|
||
class OccupancySensing : public Window | ||
{ | ||
public: | ||
OccupancySensing(chip::EndpointId endpointId, const char * title) : mEndpointId(endpointId), mTitle(title) {} | ||
|
||
void UpdateState() override; | ||
void Render() override; | ||
|
||
private: | ||
const chip::EndpointId mEndpointId; | ||
const std::string mTitle; | ||
|
||
using BitMask = chip::BitMask<chip::app::Clusters::OccupancySensing::OccupancyBitmap>; | ||
|
||
BitMask mOccupancy; | ||
chip::Optional<BitMask> mTargetOccupancy; | ||
}; | ||
|
||
} // namespace Windows | ||
} // namespace Ui | ||
} // namespace example |
This file contains 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,25 @@ | ||
# Copyright (c) 2020 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") | ||
} |
This file contains 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,64 @@ | ||
# Copyright (c) 2020 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("contact-sensor-app") { | ||
sources = [ | ||
"include/CHIPProjectAppConfig.h", | ||
"main.cpp", | ||
] | ||
|
||
deps = [ | ||
"${chip_root}/examples/contact-sensor-app/contact-sensor-common", | ||
"${chip_root}/examples/platform/linux:app-main", | ||
"${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 = [ ":contact-sensor-app" ] | ||
} | ||
|
||
group("default") { | ||
deps = [ ":linux" ] | ||
} |
This file contains 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 @@ | ||
# Copyright (c) 2020 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/contact-sensor-app/linux/include" ] | ||
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] |
This file contains 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 @@ | ||
../../build_overrides |
Oops, something went wrong.