Skip to content

Commit 973ba03

Browse files
authored
Merge branch 'master' into loggg
2 parents 9be119b + 8c8889b commit 973ba03

File tree

67 files changed

+6703
-560
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+6703
-560
lines changed

.github/workflows/build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ jobs:
333333
scripts/run_in_build_env.sh 'virtualenv pyenv'
334334
source pyenv/bin/activate
335335
pip3 install -r src/setup_payload/python/requirements.txt
336-
python3 src/setup_payload/tests/run_python_setup_payload_gen_test.py out/chip-tool
336+
python3 src/setup_payload/tests/run_python_setup_payload_test.py out/chip-tool
337337
338338
build_linux_python_lighting_device:
339339
name: Build on Linux (python lighting-app)

.github/workflows/darwin.yaml

+4-9
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ jobs:
9797
bootstrap-logs-framework-${{ matrix.options.flavor }}
9898
- name: Build example All Clusters Server
9999
run: |
100-
scripts/examples/gn_build_example.sh examples/all-clusters-app/linux out/debug chip_config_network_layer_ble=false
100+
scripts/examples/gn_build_example.sh examples/all-clusters-app/linux out/debug/all-clusters-app chip_config_network_layer_ble=false
101101
- name: Build example OTA Provider
102102
run: |
103-
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug chip_config_network_layer_ble=false
103+
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug/ota-provider-app chip_config_network_layer_ble=false
104104
- name: Build example OTA Requestor
105105
run: |
106106
scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/debug/ota-requestor-app chip_config_network_layer_ble=false non_spec_compliant_ota_action_delay_floor=0
@@ -113,13 +113,8 @@ jobs:
113113
run: |
114114
mkdir -p /tmp/darwin/framework-tests
115115
echo "This is a simple log" > /tmp/darwin/framework-tests/end_user_support_log.txt
116-
../../../out/debug/chip-all-clusters-app --interface-id -1 --end_user_support_log /tmp/darwin/framework-tests/end_user_support_log.txt > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) &
117-
../../../out/debug/chip-all-clusters-app --interface-id -1 --dac_provider ../../../credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json --product-id 32768 --discriminator 3839 --secured-device-port 5539 --KVS /tmp/chip-all-clusters-app-kvs2 > >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid-err.log >&2) &
118-
../../../out/debug/chip-all-clusters-app --interface-id -1 --discriminator 101 --passcode 1001 --KVS /tmp/chip-all-clusters-app-kvs101 --secured-device-port 5531 &
119-
../../../out/debug/chip-all-clusters-app --interface-id -1 --discriminator 102 --passcode 1002 --KVS /tmp/chip-all-clusters-app-kvs102 --secured-device-port 5532 &
120-
../../../out/debug/chip-all-clusters-app --interface-id -1 --discriminator 103 --passcode 1003 --KVS /tmp/chip-all-clusters-app-kvs103 --secured-device-port 5533 &
121-
../../../out/debug/chip-all-clusters-app --interface-id -1 --discriminator 104 --passcode 1004 --KVS /tmp/chip-all-clusters-app-kvs104 --secured-device-port 5534 &
122-
../../../out/debug/chip-all-clusters-app --interface-id -1 --discriminator 105 --passcode 1005 --KVS /tmp/chip-all-clusters-app-kvs105 --secured-device-port 5535 &
116+
../../../out/debug/all-clusters-app/chip-all-clusters-app --interface-id -1 --end_user_support_log /tmp/darwin/framework-tests/end_user_support_log.txt > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) &
117+
../../../out/debug/all-clusters-app/chip-all-clusters-app --interface-id -1 --dac_provider ../../../credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json --product-id 32768 --discriminator 3839 --secured-device-port 5539 --KVS /tmp/chip-all-clusters-app-kvs2 > >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid-err.log >&2) &
123118
124119
export TEST_RUNNER_ASAN_OPTIONS=__CURRENT_VALUE__:detect_stack_use_after_return=1
125120

.github/workflows/lint.yml

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ jobs:
9898
--known-failure controller/ExamplePersistentStorage.cpp \
9999
--known-failure controller/ExamplePersistentStorage.h \
100100
--known-failure app/AttributeAccessToken.h \
101-
--known-failure app/CommandHandler.h \
102101
--known-failure app/CommandHandlerInterface.h \
103102
--known-failure app/CommandResponseSender.h \
104103
--known-failure app/CommandSenderLegacyCallback.h \

docs/testing/yaml.md

+29
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,17 @@ function can be use. See
279279
[TestEqualities](https://github.com/project-chip/connectedhomeip/blob/master/src/app/tests/suites/TestEqualities.yaml)
280280
for an example of how to use this pseudo-cluster.
281281

282+
#### Setting step timeouts
283+
284+
The timeout argument can be used for each individual test step to set the time
285+
the runner will wait for a test step to complete before reporting a failure.
286+
287+
Note that this timeout is different than the subscription report timeout and the
288+
subscription report timeout is not currently adjustable in YAML.
289+
290+
There several other options for configuring test steps as shown in the
291+
[YAML schema](./yaml_schema.md) document.
292+
282293
## Running YAML tests
283294

284295
YAML scripts are parsed and run using a python-based runner program that parses
@@ -304,6 +315,24 @@ There are several options for running tests locally. Because the YAML runner
304315
uses python, it is necessary to compile and install the chip python package
305316
before using any YAML runner script.
306317

318+
First activate the matter environment using either
319+
320+
```
321+
. ./scripts/bootstrap.sh
322+
```
323+
324+
or
325+
326+
```
327+
. ./scripts/activate.sh
328+
```
329+
330+
bootstrap.sh should be used for for the first setup, activate.sh may be used for
331+
subsequent setups as it is faster.
332+
333+
Next build the python wheels and create a venv (called `py` here, but any name
334+
may be used)
335+
307336
```
308337
./scripts/build_python.sh -i py
309338
source py/bin/activate

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+5-5
Original file line numberDiff line numberDiff line change
@@ -3876,7 +3876,7 @@ cluster ValveConfigurationAndControl = 129 {
38763876
}
38773877

38783878
/** This cluster provides a mechanism for querying data about electrical power as measured by the server. */
3879-
provisional cluster ElectricalPowerMeasurement = 144 {
3879+
cluster ElectricalPowerMeasurement = 144 {
38803880
revision 1;
38813881

38823882
enum MeasurementTypeEnum : enum16 {
@@ -3981,7 +3981,7 @@ provisional cluster ElectricalPowerMeasurement = 144 {
39813981
}
39823982

39833983
/** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */
3984-
provisional cluster ElectricalEnergyMeasurement = 145 {
3984+
cluster ElectricalEnergyMeasurement = 145 {
39853985
revision 1;
39863986

39873987
enum MeasurementTypeEnum : enum16 {
@@ -4278,7 +4278,7 @@ provisional cluster DeviceEnergyManagement = 152 {
42784278
}
42794279

42804280
/** Electric Vehicle Supply Equipment (EVSE) is equipment used to charge an Electric Vehicle (EV) or Plug-In Hybrid Electric Vehicle. This cluster provides an interface to the functionality of Electric Vehicle Supply Equipment (EVSE) management. */
4281-
provisional cluster EnergyEvse = 153 {
4281+
cluster EnergyEvse = 153 {
42824282
revision 2;
42834283

42844284
enum EnergyTransferStoppedReasonEnum : enum8 {
@@ -4490,7 +4490,7 @@ provisional cluster EnergyPreference = 155 {
44904490
}
44914491

44924492
/** The Power Topology Cluster provides a mechanism for expressing how power is flowing between endpoints. */
4493-
provisional cluster PowerTopology = 156 {
4493+
cluster PowerTopology = 156 {
44944494
revision 1;
44954495

44964496
bitmap Feature : bitmap32 {
@@ -4511,7 +4511,7 @@ provisional cluster PowerTopology = 156 {
45114511
}
45124512

45134513
/** Attributes and commands for selecting a mode from a list of supported options. */
4514-
provisional cluster EnergyEvseMode = 157 {
4514+
cluster EnergyEvseMode = 157 {
45154515
revision 1;
45164516

45174517
enum ModeTag : enum16 {

examples/bridge-app/linux/main.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,11 @@ void ApplicationInit()
899899
// Setup Mock Devices
900900
Light1.SetReachable(true);
901901
Light2.SetReachable(true);
902-
903902
Light1.SetChangeCallback(&HandleDeviceOnOffStatusChanged);
904903
Light2.SetChangeCallback(&HandleDeviceOnOffStatusChanged);
905904

906905
TempSensor1.SetReachable(true);
907-
TempSensor1.SetReachable(true);
908-
906+
TempSensor2.SetReachable(true);
909907
TempSensor1.SetChangeCallback(&HandleDeviceTempSensorStatusChanged);
910908
TempSensor2.SetChangeCallback(&HandleDeviceTempSensorStatusChanged);
911909

@@ -914,7 +912,6 @@ void ApplicationInit()
914912
ActionLight2.SetReachable(true);
915913
ActionLight3.SetReachable(true);
916914
ActionLight4.SetReachable(true);
917-
918915
ActionLight1.SetChangeCallback(&HandleDeviceOnOffStatusChanged);
919916
ActionLight2.SetChangeCallback(&HandleDeviceOnOffStatusChanged);
920917
ActionLight3.SetChangeCallback(&HandleDeviceOnOffStatusChanged);
@@ -929,7 +926,6 @@ void ApplicationInit()
929926
ComposedTempSensor2.SetReachable(true);
930927
ComposedPowerSource.SetReachable(true);
931928
ComposedPowerSource.SetBatChargeLevel(58);
932-
933929
ComposedTempSensor1.SetChangeCallback(&HandleDeviceTempSensorStatusChanged);
934930
ComposedTempSensor2.SetChangeCallback(&HandleDeviceTempSensorStatusChanged);
935931
ComposedPowerSource.SetChangeCallback(&HandleDevicePowerSourceStatusChanged);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#pragma once
19+
20+
// Please refer to https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/master/src/namespaces
21+
constexpr const uint8_t kNamespaceCommonLevel = 5;
22+
// Common Number Namespace: 5, tag 0 (Low)
23+
constexpr const uint8_t kTagCommonLow = 0;
24+
// Common Number Namespace: 5, tag 1 (Medium)
25+
constexpr const uint8_t kTagCommonMedium = 1;
26+
// Common Number Namespace: 5, tag 2 (High)
27+
constexpr const uint8_t kTagCommonHigh = 2;
28+
29+
constexpr const uint8_t kNamespaceCommonNumber = 7;
30+
// Common Number Namespace: 7, tag 0 (Zero)
31+
constexpr const uint8_t kTagCommonZero = 0;
32+
// Common Number Namespace: 7, tag 1 (One)
33+
constexpr const uint8_t kTagCommonOne = 1;
34+
// Common Number Namespace: 7, tag 2 (Two)
35+
constexpr const uint8_t kTagCommonTwo = 2;
36+
37+
constexpr const uint8_t kNamespacePosition = 8;
38+
// Common Position Namespace: 8, tag: 0 (Left)
39+
constexpr const uint8_t kTagPositionLeft = 0;
40+
// Common Position Namespace: 8, tag: 1 (Right)
41+
constexpr const uint8_t kTagPositionRight = 1;
42+
// Common Position Namespace: 8, tag: 2 (Top)
43+
constexpr const uint8_t kTagPositionTop = 2;
44+
// Common Position Namespace: 8, tag: 3 (Bottom)
45+
constexpr const uint8_t kTagPositionBottom = 3;
46+
// Common Position Namespace: 8, tag: 4 (Middle)
47+
constexpr const uint8_t kTagPositionMiddle = 4;
48+
// Common Position Namespace: 8, tag: 5 (Row)
49+
constexpr const uint8_t kTagPositionRow = 5;
50+
// Common Position Namespace: 8, tag: 6 (Column)
51+
constexpr const uint8_t kTagPositionColumn = 6;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
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+
19+
#include "chef-rpc-actions-worker.h"
20+
#include <app-common/zap-generated/attributes/Accessors.h>
21+
#include <app-common/zap-generated/callback.h>
22+
#include <app/data-model/Nullable.h>
23+
#include <app/util/config.h>
24+
#include <lib/core/DataModelTypes.h>
25+
#include <map>
26+
#include <platform/CHIPDeviceLayer.h>
27+
28+
using chip::app::DataModel::Nullable;
29+
30+
using namespace chip;
31+
using namespace chip::app;
32+
using namespace chip::app::Clusters;
33+
using namespace chip::rpc;
34+
35+
static std::map<ClusterId, ActionsDelegate *> gActionsDelegateMap{};
36+
37+
ActionsDelegate * RpcFindActionsDelegate(ClusterId clusterId)
38+
{
39+
if (gActionsDelegateMap.find(clusterId) != gActionsDelegateMap.end())
40+
{
41+
return gActionsDelegateMap[clusterId];
42+
}
43+
44+
return nullptr;
45+
}
46+
47+
static void RpcActionsTaskCallback(System::Layer * systemLayer, void * data)
48+
{
49+
ChefRpcActionsWorker * worker = (ChefRpcActionsWorker *) data;
50+
51+
worker->ProcessActionQueue();
52+
}
53+
54+
bool ChefRpcActionsCallback(EndpointId endpointId, ClusterId clusterId, uint8_t type, uint32_t delayMs, uint32_t actionId,
55+
std::vector<uint32_t> args)
56+
{
57+
ActionTask task(endpointId, clusterId, static_cast<ActionType>(type), delayMs, actionId, args);
58+
59+
return ChefRpcActionsWorker::Instance().EnqueueAction(task);
60+
}
61+
62+
bool ChefRpcActionsWorker::EnqueueAction(ActionTask task)
63+
{
64+
bool kickTimer = false;
65+
66+
if (queue.empty())
67+
{
68+
kickTimer = true; // kick timer when the first task is adding to the queue
69+
}
70+
71+
queue.push(task);
72+
73+
if (kickTimer)
74+
{
75+
(void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(task.delayMs), RpcActionsTaskCallback, this);
76+
}
77+
return true;
78+
}
79+
80+
void ChefRpcActionsWorker::ProcessActionQueue()
81+
{
82+
// Dequeue the first item
83+
ActionTask task = queue.front();
84+
queue.pop();
85+
86+
ActionsDelegate * delegate = RpcFindActionsDelegate(task.clusterId);
87+
if (nullptr == delegate)
88+
{
89+
ChipLogError(NotSpecified,
90+
"Cannot run action due to not finding delegate: endpointId=%d, clusterId=%04lx, attributeId=%04lx",
91+
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId));
92+
return;
93+
}
94+
95+
ActionType type = static_cast<ActionType>(task.type);
96+
97+
switch (type)
98+
{
99+
case ActionType::WRITE_ATTRIBUTE: {
100+
ChipLogProgress(NotSpecified, "Writing Attribute: endpointId=%d, clusterId=%04lx, attributeId=%04lx, args.size=%lu",
101+
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
102+
static_cast<unsigned long>(task.args.size()));
103+
delegate->AttributeWriteHandler(task.endpointId, static_cast<chip::AttributeId>(task.actionId), task.args);
104+
}
105+
break;
106+
case ActionType::RUN_COMMAND: {
107+
ChipLogProgress(NotSpecified, "Running Command: endpointId=%d, clusterId=%04lx, commandId=%04lx, args.size=%lu",
108+
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
109+
static_cast<unsigned long>(task.args.size()));
110+
delegate->CommandHandler(task.endpointId, static_cast<chip::CommandId>(task.actionId), task.args);
111+
}
112+
break;
113+
case ActionType::EMIT_EVENT: {
114+
ChipLogProgress(NotSpecified, "Emitting Event: endpointId=%d, clusterId=%04lx, eventIdId=%04lx, args.size=%lu",
115+
task.endpointId, static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
116+
static_cast<unsigned long>(task.args.size()));
117+
delegate->EventHandler(task.endpointId, static_cast<chip::EventId>(task.actionId), task.args);
118+
}
119+
break;
120+
default:
121+
break;
122+
}
123+
124+
if (queue.empty())
125+
{
126+
// Return due to no more actions in queue
127+
return;
128+
}
129+
130+
// Run next action
131+
task = queue.front();
132+
ChipLogProgress(NotSpecified, "StartTimer: endpointId=%d, clusterId=%04lx, eventIdId=%04lx, task.delyMs=%lu", task.endpointId,
133+
static_cast<unsigned long>(task.clusterId), static_cast<unsigned long>(task.actionId),
134+
static_cast<unsigned long>(task.delayMs));
135+
(void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(task.delayMs), RpcActionsTaskCallback, this);
136+
}
137+
138+
void ChefRpcActionsWorker::RegisterRpcActionsDelegate(ClusterId clusterId, ActionsDelegate * delegate)
139+
{
140+
// Register by cluster
141+
if (nullptr == RpcFindActionsDelegate(clusterId))
142+
{
143+
gActionsDelegateMap[clusterId] = delegate;
144+
return;
145+
}
146+
}
147+
148+
ChefRpcActionsWorker::ChefRpcActionsWorker()
149+
{
150+
chip::rpc::SubscribeActions(ChefRpcActionsCallback);
151+
}
152+
153+
static ChefRpcActionsWorker instance;
154+
155+
ChefRpcActionsWorker & ChefRpcActionsWorker::Instance()
156+
{
157+
return instance;
158+
}

0 commit comments

Comments
 (0)