Skip to content
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

Valve cluster: refactor to make unit-testable #35631

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Changes from 10 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6f3357b
Valve: disco ball - Attribute getters
cecille Sep 6, 2024
1ab57bb
Valve: Disco ball - Attribute Setters for client
cecille Sep 8, 2024
6d4c366
Valve: Disco ball - Open command
cecille Sep 8, 2024
30e6fd1
Valve: Disco ball - start of Remaining duration with Q
cecille Sep 11, 2024
02906e1
Valve: Disco ball - Handle automatic close
cecille Sep 15, 2024
8bf5e5a
Valve: disco ball - Handle close command
cecille Sep 16, 2024
2e4f0ff
Valve: Disco ball - Access and command interfaces
cecille Sep 16, 2024
83d5b79
Valve: Disco ball - add example app
cecille Sep 17, 2024
100a967
Add endpoint marker to print
cecille Sep 19, 2024
52449a3
add feature map and cluster revision
cecille Sep 26, 2024
9e6b521
Merge remote-tracking branch 'upstream/master' into valve
cecille Sep 27, 2024
58cfb19
Fix conformance
cecille Sep 27, 2024
6be91cd
Add taglists to distinguish endpoints
cecille Sep 27, 2024
bc8f3d4
Use Node label instead of tags
cecille Sep 29, 2024
ab2b7bd
Valve: fix write to use KVS manager properly
cecille Sep 28, 2024
0712293
TC-DESC-2.2: Fix comparison when mfg label is in the list
cecille Sep 28, 2024
2710453
TC-VALCC-3.1: Allow immediate open of valve
cecille Sep 28, 2024
e0195d7
TC-VALCC-4.2: unconditionally write open duration
cecille Sep 28, 2024
eb2dcbf
VALCC: Remove top-level PICS
cecille Sep 28, 2024
3e30568
controller start: not done or tested
cecille Sep 30, 2024
b994417
controller now tested
cecille Sep 30, 2024
f01c8f5
Add readme and additional functions for controller
cecille Oct 1, 2024
84a0899
valve: Set target state to transitioning first
cecille Oct 4, 2024
bdadfb0
fixup for 3.1 test
cecille Oct 4, 2024
847a8d7
another fixup for 3.1
cecille Oct 7, 2024
8d1491e
Add close at start of test
cecille Oct 7, 2024
31ed684
Fix tests to account for unconditional change to target and current a…
cecille Oct 9, 2024
1a1d5c6
Add a mystery option to the controller
cecille Oct 15, 2024
03c8e98
Merge remote-tracking branch 'upstream/master' into valve
cecille Jan 7, 2025
6e354ba
Fix build file from bad merge
cecille Jan 7, 2025
b95be0a
python framework: Fix warning on asyncio not awaited
cecille Dec 19, 2024
82e67de
Uncomment the attribute access interface registration - whoops
cecille Jan 7, 2025
e3a9b43
fix up some tests
cecille Jan 8, 2025
90e41f5
Merge remote-tracking branch 'upstream/master' into valve
cecille Jan 9, 2025
a0c0737
Merge remote-tracking branch 'origin/valve' into valve_rebased
cecille Jan 9, 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
25 changes: 25 additions & 0 deletions examples/valve-app/linux/.gn
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")
}
55 changes: 55 additions & 0 deletions examples/valve-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# 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.

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

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

assert(chip_build_tools)

import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni")

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

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

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

cflags = [ "-Wconversion" ]

include_dirs = [ "include" ]
output_dir = root_out_dir
}

group("linux") {
deps = [ ":valve-app" ]
}

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

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/air-purifier-app/linux/include" ]
chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ]
1 change: 1 addition & 0 deletions examples/valve-app/linux/build_overrides
38 changes: 38 additions & 0 deletions examples/valve-app/linux/include/CHIPProjectAppConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
*
* Copyright (c) 2023 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

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY_CLIENT 0

#define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1

#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 0x0042 // Water valve

#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_NAME 1

#define CHIP_DEVICE_ENABLE_PORT_PARAMS 1

#define CHIP_DEVICE_CONFIG_DEVICE_NAME "DISCO Drinks"
119 changes: 119 additions & 0 deletions examples/valve-app/linux/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
*
* 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 <app-common/zap-generated/ids/Clusters.h>
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-cluster-logic.h>
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-delegate.h>
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server-disco.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/KvsPersistentStorageDelegate.h>

using namespace chip;
using namespace chip::app;
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::ValveConfigurationAndControl;
namespace {
class PrintOnlyDelegate : public NonLevelControlDelegate
{
public:
PrintOnlyDelegate(EndpointId endpoint) : mEndpoint(endpoint) {}
CHIP_ERROR HandleOpenValve(ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) override
{
ChipLogProgress(NotSpecified, "VALVE IS OPENING on endpoint %u!!!!!", mEndpoint);
state = ValveStateEnum::kOpen;
currentState = state;
return CHIP_NO_ERROR;
}
ValveStateEnum GetCurrentValveState() override { return state; }
CHIP_ERROR HandleCloseValve(ValveStateEnum & currentState, BitMask<ValveFaultBitmap> & valveFault) override
{
ChipLogProgress(NotSpecified, "VALVE IS CLOSING on endpoint %u!!!!!", mEndpoint);
state = ValveStateEnum::kClosed;
currentState = state;
return CHIP_NO_ERROR;
}

private:
ValveStateEnum state = ValveStateEnum::kClosed;
EndpointId mEndpoint;
};

class NonLevelValveEndpoint
{
public:
NonLevelValveEndpoint(EndpointId endpoint) :
mEndpoint(endpoint), mContext(mEndpoint, storage), mDelegate(mEndpoint), mLogic(mDelegate, mContext),
mInterface(mEndpoint, mLogic)
{}
CHIP_ERROR Init()
{
ReturnErrorOnFailure(mLogic.Init(kConformance, kInitParams));
ReturnErrorOnFailure(mInterface.Init());
return CHIP_NO_ERROR;
}

private:
const ClusterConformance kConformance = {
.featureMap = 0, .supportsDefaultOpenLevel = false, .supportsValveFault = false, .supportsLevelStep = false
};
const ClusterInitParameters kInitParams = { .currentState = DataModel::MakeNullable(ValveStateEnum::kClosed),
.currentLevel = DataModel::NullNullable,
.valveFault = 0,
.levelStep = 1 };
EndpointId mEndpoint;
KvsPersistentStorageDelegate storage;
MatterContext mContext;
PrintOnlyDelegate mDelegate;
ClusterLogic mLogic;
Interface mInterface;
};

NonLevelValveEndpoint ep1(1);
NonLevelValveEndpoint ep2(2);
NonLevelValveEndpoint ep3(3);
NonLevelValveEndpoint ep4(4);
NonLevelValveEndpoint ep5(5);
NonLevelValveEndpoint ep6(6);
} // namespace

void ApplicationInit()
{
ChipLogError(NotSpecified, "App init!!!");
ep1.Init();
ep2.Init();
ep3.Init();
ep4.Init();
ep5.Init();
ep6.Init();
}

void ApplicationShutdown()
{
ChipLogDetail(NotSpecified, "ApplicationShutdown()");
}

int main(int argc, char * argv[])
{
if (ChipLinuxAppInit(argc, argv) != 0)
{
return -1;
}

ChipLinuxAppMainLoop();
return 0;
}
1 change: 1 addition & 0 deletions examples/valve-app/linux/third_party/connectedhomeip
21 changes: 21 additions & 0 deletions examples/valve-app/valve-common/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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}/src/app/chip_data_model.gni")

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