Skip to content

Commit bda703a

Browse files
committed
Merge branch 'master' into refactor-command-handler-upload
2 parents ef098ae + bdb88bd commit bda703a

File tree

99 files changed

+3987
-393
lines changed

Some content is hidden

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

99 files changed

+3987
-393
lines changed

.github/.wordlist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ ttymxc
14401440
ttyUSB
14411441
TurbidityConcentrationMeasurement
14421442
TvCasting
1443+
TVOC
14431444
tvOS
14441445
TXD
14451446
txt

.github/workflows/darwin.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ jobs:
5454
# Disable availability annotations, since we are not building a system
5555
# Matter.framework.
5656
run: xcodebuild -target "Matter" -sdk watchos -configuration Debug GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
57+
- name: Run tvOS Build Debug
58+
working-directory: src/darwin/Framework
59+
# Disable availability annotations, since we are not building a system
60+
# Matter.framework.
61+
run: xcodebuild -target "Matter" -sdk appletvos -configuration Debug GCC_PREPROCESSOR_DEFINITIONS='${inherited} MTR_NO_AVAILABILITY=1'
5762
- name: Run iOS Build Debug
5863
working-directory: src/darwin/Framework
5964
# Disable availability annotations, since we are not building a system

config/nrfconnect/chip-gn/.gn

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import("//build_overrides/build.gni")
1616
import("//build_overrides/chip.gni")
17+
import("//build_overrides/pigweed.gni")
1718

1819
# The location of the build configuration file.
1920
buildconfig = "${build_root}/config/BUILDCONFIG.gn"
@@ -25,5 +26,14 @@ default_args = {
2526
target_cpu = "arm"
2627
target_os = "zephyr"
2728

29+
pw_sys_io_BACKEND = dir_pw_sys_io_stdio
30+
pw_assert_BACKEND = dir_pw_assert_log
31+
pw_log_BACKEND = dir_pw_log_basic
32+
33+
pw_build_LINK_DEPS = [
34+
"$dir_pw_assert:impl",
35+
"$dir_pw_log:impl",
36+
]
37+
2838
import("${chip_root}/config/nrfconnect/chip-gn/args.gni")
2939
}
Loading

examples/air-quality-sensor-app/linux/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,10 @@ Generate event `Pm10ConcentrationMeasurement`, to change the PM10 value.
183183
```
184184
echo '{"Name":"Pm10ConcentrationMeasurement","NewValue":10}' > /tmp/chip_air_quality_fifo_<PID>
185185
```
186+
187+
Generate event `TotalVolatileOrganicCompoundsConcentrationMeasurement`, to
188+
change the TVOC value.
189+
190+
```
191+
$ echo '{"Name":"TotalVolatileOrganicCompoundsConcentrationMeasurement","NewValue":100}' > /tmp/chip_air_quality_fifo_<PID>
192+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
/*
2+
* Copyright (c) 2023 Project CHIP Authors
3+
* All rights reserved.
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+
#include <chef-operational-state-delegate-impl.h>
18+
#include <platform/CHIPDeviceLayer.h>
19+
20+
using namespace chip;
21+
using namespace chip::app;
22+
using namespace chip::app::Clusters;
23+
using namespace chip::app::Clusters::OperationalState;
24+
using namespace chip::app::Clusters::RvcOperationalState;
25+
26+
static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data);
27+
28+
DataModel::Nullable<uint32_t> GenericOperationalStateDelegateImpl::GetCountdownTime()
29+
{
30+
if (mCountDownTime.IsNull())
31+
return DataModel::NullNullable;
32+
33+
return DataModel::MakeNullable((uint32_t) (mCountDownTime.Value() - mRunningTime));
34+
}
35+
36+
CHIP_ERROR GenericOperationalStateDelegateImpl::GetOperationalStateAtIndex(size_t index, GenericOperationalState & operationalState)
37+
{
38+
if (index >= mOperationalStateList.size())
39+
{
40+
return CHIP_ERROR_NOT_FOUND;
41+
}
42+
operationalState = mOperationalStateList[index];
43+
return CHIP_NO_ERROR;
44+
}
45+
46+
CHIP_ERROR GenericOperationalStateDelegateImpl::GetOperationalPhaseAtIndex(size_t index, MutableCharSpan & operationalPhase)
47+
{
48+
if (index >= mOperationalPhaseList.size())
49+
{
50+
return CHIP_ERROR_NOT_FOUND;
51+
}
52+
return CopyCharSpanToMutableCharSpan(mOperationalPhaseList[index], operationalPhase);
53+
}
54+
55+
void GenericOperationalStateDelegateImpl::HandlePauseStateCallback(GenericOperationalError & err)
56+
{
57+
OperationalState::OperationalStateEnum state =
58+
static_cast<OperationalState::OperationalStateEnum>(GetInstance()->GetCurrentOperationalState());
59+
60+
if (state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError)
61+
{
62+
err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState));
63+
return;
64+
}
65+
66+
// placeholder implementation
67+
auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused));
68+
if (error == CHIP_NO_ERROR)
69+
{
70+
err.Set(to_underlying(ErrorStateEnum::kNoError));
71+
}
72+
else
73+
{
74+
err.Set(to_underlying(ErrorStateEnum::kUnableToCompleteOperation));
75+
}
76+
}
77+
78+
void GenericOperationalStateDelegateImpl::HandleResumeStateCallback(GenericOperationalError & err)
79+
{
80+
OperationalState::OperationalStateEnum state =
81+
static_cast<OperationalState::OperationalStateEnum>(GetInstance()->GetCurrentOperationalState());
82+
83+
if (state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError)
84+
{
85+
err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState));
86+
return;
87+
}
88+
89+
// placeholder implementation
90+
auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kRunning));
91+
if (error == CHIP_NO_ERROR)
92+
{
93+
err.Set(to_underlying(ErrorStateEnum::kNoError));
94+
}
95+
else
96+
{
97+
err.Set(to_underlying(ErrorStateEnum::kUnableToCompleteOperation));
98+
}
99+
}
100+
101+
void GenericOperationalStateDelegateImpl::HandleStartStateCallback(GenericOperationalError & err)
102+
{
103+
OperationalState::GenericOperationalError current_err(to_underlying(OperationalState::ErrorStateEnum::kNoError));
104+
GetInstance()->GetCurrentOperationalError(current_err);
105+
106+
if (current_err.errorStateID != to_underlying(OperationalState::ErrorStateEnum::kNoError))
107+
{
108+
err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume));
109+
return;
110+
}
111+
112+
// placeholder implementation
113+
auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kRunning));
114+
if (error == CHIP_NO_ERROR)
115+
{
116+
(void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(1), onOperationalStateTimerTick, this);
117+
err.Set(to_underlying(ErrorStateEnum::kNoError));
118+
}
119+
else
120+
{
121+
err.Set(to_underlying(ErrorStateEnum::kUnableToCompleteOperation));
122+
}
123+
}
124+
125+
void GenericOperationalStateDelegateImpl::HandleStopStateCallback(GenericOperationalError & err)
126+
{
127+
// placeholder implementation
128+
auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kStopped));
129+
if (error == CHIP_NO_ERROR)
130+
{
131+
(void) DeviceLayer::SystemLayer().CancelTimer(onOperationalStateTimerTick, this);
132+
133+
OperationalState::GenericOperationalError current_err(to_underlying(OperationalState::ErrorStateEnum::kNoError));
134+
GetInstance()->GetCurrentOperationalError(current_err);
135+
136+
Optional<DataModel::Nullable<uint32_t>> totalTime((DataModel::Nullable<uint32_t>(mRunningTime + mPausedTime)));
137+
Optional<DataModel::Nullable<uint32_t>> pausedTime((DataModel::Nullable<uint32_t>(mPausedTime)));
138+
139+
GetInstance()->OnOperationCompletionDetected(static_cast<uint8_t>(current_err.errorStateID), totalTime, pausedTime);
140+
141+
mRunningTime = 0;
142+
mPausedTime = 0;
143+
err.Set(to_underlying(ErrorStateEnum::kNoError));
144+
}
145+
else
146+
{
147+
err.Set(to_underlying(ErrorStateEnum::kUnableToCompleteOperation));
148+
}
149+
}
150+
151+
static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data)
152+
{
153+
GenericOperationalStateDelegateImpl * delegate = reinterpret_cast<GenericOperationalStateDelegateImpl *>(data);
154+
155+
OperationalState::Instance * instance = OperationalState::GetOperationalStateInstance();
156+
OperationalState::OperationalStateEnum state =
157+
static_cast<OperationalState::OperationalStateEnum>(instance->GetCurrentOperationalState());
158+
159+
auto countdown_time = delegate->GetCountdownTime();
160+
161+
if (countdown_time.IsNull() || (!countdown_time.IsNull() && countdown_time.Value() > 0))
162+
{
163+
if (state == OperationalState::OperationalStateEnum::kRunning)
164+
{
165+
delegate->mRunningTime++;
166+
}
167+
else if (state == OperationalState::OperationalStateEnum::kPaused)
168+
{
169+
delegate->mPausedTime++;
170+
}
171+
}
172+
173+
if (state == OperationalState::OperationalStateEnum::kRunning || state == OperationalState::OperationalStateEnum::kPaused)
174+
{
175+
(void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(1), onOperationalStateTimerTick, delegate);
176+
}
177+
else
178+
{
179+
(void) DeviceLayer::SystemLayer().CancelTimer(onOperationalStateTimerTick, delegate);
180+
}
181+
}
182+
183+
// Init Operational State cluster
184+
185+
static OperationalState::Instance * gOperationalStateInstance = nullptr;
186+
static OperationalStateDelegate * gOperationalStateDelegate = nullptr;
187+
188+
OperationalState::Instance * OperationalState::GetOperationalStateInstance()
189+
{
190+
return gOperationalStateInstance;
191+
}
192+
193+
void OperationalState::Shutdown()
194+
{
195+
if (gOperationalStateInstance != nullptr)
196+
{
197+
delete gOperationalStateInstance;
198+
gOperationalStateInstance = nullptr;
199+
}
200+
if (gOperationalStateDelegate != nullptr)
201+
{
202+
delete gOperationalStateDelegate;
203+
gOperationalStateDelegate = nullptr;
204+
}
205+
}
206+
207+
void emberAfOperationalStateClusterInitCallback(chip::EndpointId endpointId)
208+
{
209+
VerifyOrDie(endpointId == 1); // this cluster is only enabled for endpoint 1.
210+
VerifyOrDie(gOperationalStateInstance == nullptr && gOperationalStateDelegate == nullptr);
211+
212+
gOperationalStateDelegate = new OperationalStateDelegate;
213+
EndpointId operationalStateEndpoint = 0x01;
214+
gOperationalStateInstance = new OperationalState::Instance(gOperationalStateDelegate, operationalStateEndpoint);
215+
216+
gOperationalStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped));
217+
218+
gOperationalStateInstance->Init();
219+
}

0 commit comments

Comments
 (0)