Skip to content

Commit 24c0c73

Browse files
committed
Pull request project-chip#431: Fix window app
Merge in WMN_TOOLS/matter from fix-window-app to silabs_slc_1.0 Squashed commit of the following: commit 564ae9b57428189bb7924b77d02968f2225deabb Author: Michael Rupp <michael.rupp@silabs.com> Date: Tue Dec 13 19:26:44 2022 -0500 add window-app-no-led commit 50e0f470bc8fa152597223f8d1b55bbe49860d66 Author: Rehan Rasool <rehan.rasool@silabs.com> Date: Tue Dec 13 19:20:56 2022 -0500 Enable window-app in builds commit 8cf62c595198bcd06ecc926a4a20f2b74336f7ea Author: Rehan Rasool <rehan.rasool@silabs.com> Date: Tue Dec 13 19:20:39 2022 -0500 Add window-app thread postfix after recent change ... and 5 more commits
1 parent 856c62d commit 24c0c73

11 files changed

+1061
-95
lines changed

Jenkinsfile

+1-2
Original file line numberDiff line numberDiff line change
@@ -1105,8 +1105,7 @@ def pipeline()
11051105
openThreadBoards = ["BRD4161A", "BRD4187C", "BRD4316A"]
11061106

11071107
}
1108-
// def openThreadApps = ["window-app"] // MATTER_GSDK_TODO: enable as SLC apps are added
1109-
def openThreadApps = ["lighting-app", "lock-app", "thermostat", "light-switch-app"]
1108+
def openThreadApps = ["lighting-app", "lock-app", "thermostat", "light-switch-app", "window-app"]
11101109

11111110
def sleepyBoard = ["BRD4161A", "BRD4186C"]
11121111

matter_templates.xml

+30
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,34 @@
122122
<properties key="stockConfigCompatibility" value="com.silabs.ss.framework.project.toolchain.core.default"/>
123123
<properties key="filters" value="Type|SoC Project\ Difficulty|Beginner Wireless\ Technology|Matter"/>
124124
</descriptors>
125+
<descriptors name="MatterWindowCoverOverThread" label="Matter - Window Cover over Thread"
126+
description="This project builds a Matter Window Cover that can be developed inside Simplicity Studio">
127+
<properties key="namespace" value="template.uc"/>
128+
<properties key="keywords" value="Matter"/>
129+
<properties key="solutionReferenceId" value="slc.sample-app.window-app.window-app-thread.slcp"/>
130+
<properties key="projectFilePaths" value="slc/sample-app/window-app/window-app-thread.slcp"/>
131+
<properties key="boardCompatibility" value="brd4161a brd4162a brd4163a brd4164a brd4166a brd4170a brd4186c brd4187c brd2601b brd2703a"/>
132+
<properties key="partCompatibility" value=".*efr32mg12p.* .*efr32mg24.* .*mgm24.*"/>
133+
<properties key="ideCompatibility" value="makefile-ide simplicity-ide"/>
134+
<properties key="toolchainCompatibility" value="gcc"/>
135+
<properties key="category" value="Matter Application"/>
136+
<properties key="quality" value="EXPERIMENTAL"/>
137+
<properties key="stockConfigCompatibility" value="com.silabs.ss.framework.project.toolchain.core.default"/>
138+
<properties key="filters" value="Type|SoC Project\ Difficulty|Beginner Wireless\ Technology|Matter"/>
139+
</descriptors>
140+
<descriptors name="MatterWindowCoverOverThread" label="Matter - Window Cover over Thread"
141+
description="This project builds a Matter Window Cover that can be developed inside Simplicity Studio">
142+
<properties key="namespace" value="template.uc"/>
143+
<properties key="keywords" value="Matter"/>
144+
<properties key="solutionReferenceId" value="slc.sample-app.window-app.window-app-no-led-thread.slcp"/>
145+
<properties key="projectFilePaths" value="slc/sample-app/window-app/window-app-no-led-thread.slcp"/>
146+
<properties key="boardCompatibility" value="brd4316a brd4317a brd4319a"/>
147+
<properties key="partCompatibility" value=".*efr32mg12p.* .*efr32mg24.* .*mgm24.*"/>
148+
<properties key="ideCompatibility" value="makefile-ide simplicity-ide"/>
149+
<properties key="toolchainCompatibility" value="gcc"/>
150+
<properties key="category" value="Matter Application"/>
151+
<properties key="quality" value="EXPERIMENTAL"/>
152+
<properties key="stockConfigCompatibility" value="com.silabs.ss.framework.project.toolchain.core.default"/>
153+
<properties key="filters" value="Type|SoC Project\ Difficulty|Beginner Wireless\ Technology|Matter"/>
154+
</descriptors>
125155
</model:MDescriptors>

slc/component/matter-silabs/matter_platform_efr32.slcc

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ include:
1414
- path: examples/platform/efr32
1515
source:
1616
- path: examples/platform/efr32/BaseApplication.cpp
17+
unless: ["window_app"]
1718
- path: examples/platform/efr32/efr32_utils.cpp
1819
- path: examples/platform/efr32/heap_4_silabs.c
1920
- path: examples/platform/efr32/init_efrPlatform.cpp

slc/copy-app.sh

+9-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ fi
2525
rsync -aP --exclude=main.cpp $MATTER_ROOT/examples/$MATTER_APP/efr32/src/* sample-app/$MATTER_APP/src/
2626
rsync -aP $MATTER_ROOT/examples/$MATTER_APP/efr32/include/* sample-app/$MATTER_APP/include/
2727

28+
# Window app needs its own main, and doesn't need app.h
2829
# Window app has "common" folder instead of "window-common" like the other apps..
2930
if [ "$MATTER_APP" != "window-app" ]; then
3031
cp $MATTER_ROOT/examples/$MATTER_APP/${MATTER_APP%-*}-common/$MATTER_APP.zap sample-app/$MATTER_APP/common/$MATTER_APP.zap
3132
cp $MATTER_ROOT/examples/$MATTER_APP/${MATTER_APP%-*}-common/$MATTER_APP.matter sample-app/$MATTER_APP/common/$MATTER_APP.matter
33+
34+
cp sample-app/common/app.h sample-app/$MATTER_APP/include/app.h
35+
cp sample-app/common/main.cpp sample-app/$MATTER_APP/src/main.cpp
3236
else
3337
cp $MATTER_ROOT/examples/$MATTER_APP/common/$MATTER_APP.zap sample-app/$MATTER_APP/common/$MATTER_APP.zap
3438
cp $MATTER_ROOT/examples/$MATTER_APP/common/$MATTER_APP.matter sample-app/$MATTER_APP/common/$MATTER_APP.matter
35-
fi
3639

37-
cp sample-app/common/app.h sample-app/$MATTER_APP/include/app.h
38-
cp sample-app/common/main.cpp sample-app/$MATTER_APP/src/main.cpp
40+
rsync -aP $MATTER_ROOT/examples/$MATTER_APP/common/include/ sample-app/$MATTER_APP/include/
41+
rsync -aP $MATTER_ROOT/examples/$MATTER_APP/common/src/ sample-app/$MATTER_APP/src/
42+
43+
cp $MATTER_ROOT/examples/$MATTER_APP/efr32/src/main.cpp sample-app/$MATTER_APP/src/main.cpp
44+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 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+
#include <app/clusters/window-covering-server/window-covering-server.h>
21+
#include <lib/core/CHIPError.h>
22+
23+
using namespace chip::app::Clusters::WindowCovering;
24+
25+
class WindowApp
26+
{
27+
public:
28+
struct Timer
29+
{
30+
typedef void (*Callback)(Timer & timer);
31+
32+
Timer(const char * name, uint32_t timeoutInMs, Callback callback, void * context) :
33+
mName(name), mTimeoutInMs(timeoutInMs), mCallback(callback), mContext(context)
34+
{}
35+
virtual ~Timer() = default;
36+
virtual void Start() = 0;
37+
virtual void Stop() = 0;
38+
void Timeout();
39+
40+
const char * mName = nullptr;
41+
uint32_t mTimeoutInMs = 0;
42+
Callback mCallback = nullptr;
43+
void * mContext = nullptr;
44+
bool mIsActive = false;
45+
};
46+
47+
struct Button
48+
{
49+
enum class Id
50+
{
51+
Up = 0,
52+
Down = 1
53+
};
54+
55+
Button(Id id, const char * name) : mId(id), mName(name) {}
56+
virtual ~Button() = default;
57+
void Press();
58+
void Release();
59+
60+
Id mId;
61+
const char * mName = nullptr;
62+
};
63+
64+
enum class EventId
65+
{
66+
None = 0,
67+
Reset,
68+
ResetPressed,
69+
ResetWarning,
70+
ResetCanceled,
71+
// Button events
72+
UpPressed,
73+
UpReleased,
74+
DownPressed,
75+
DownReleased,
76+
// Cover events
77+
CoverChange,
78+
CoverTypeChange,
79+
TiltModeChange,
80+
81+
// Cover Attribute update events
82+
AttributeChange,
83+
84+
// Provisioning events
85+
ProvisionedStateChanged,
86+
ConnectivityStateChanged,
87+
BLEConnectionsChanged,
88+
WinkOff,
89+
WinkOn,
90+
};
91+
92+
struct Event
93+
{
94+
Event(EventId id) : mId(id), mEndpoint(0) {}
95+
Event(EventId id, chip::EndpointId endpoint) : mId(id), mEndpoint(endpoint) {}
96+
Event(EventId id, chip::EndpointId endpoint, chip::AttributeId attributeId) :
97+
mId(id), mEndpoint(endpoint), mAttributeId(attributeId)
98+
{}
99+
100+
EventId mId;
101+
chip::EndpointId mEndpoint;
102+
chip::AttributeId mAttributeId;
103+
};
104+
105+
struct Cover
106+
{
107+
void Init(chip::EndpointId endpoint);
108+
void Finish();
109+
110+
void LiftUpdate(bool newTarget);
111+
void LiftGoToTarget() { LiftUpdate(true); }
112+
void LiftContinueToTarget() { LiftUpdate(false); }
113+
void LiftStepToward(OperationalState direction);
114+
void LiftSchedulePositionSet(chip::Percent100ths position) { SchedulePositionSet(position, false); }
115+
void LiftScheduleOperationalStateSet(OperationalState opState) { ScheduleOperationalStateSet(opState, false); }
116+
117+
void TiltUpdate(bool newTarget);
118+
void TiltGoToTarget() { TiltUpdate(true); }
119+
void TiltContinueToTarget() { TiltUpdate(false); }
120+
void TiltStepToward(OperationalState direction);
121+
void TiltSchedulePositionSet(chip::Percent100ths position) { SchedulePositionSet(position, true); }
122+
void TiltScheduleOperationalStateSet(OperationalState opState) { ScheduleOperationalStateSet(opState, true); }
123+
124+
void StepToward(OperationalState direction, bool isTilt);
125+
126+
Type CycleType();
127+
128+
static void OnLiftTimeout(Timer & timer);
129+
static void OnTiltTimeout(Timer & timer);
130+
131+
chip::EndpointId mEndpoint = 0;
132+
133+
Timer * mLiftTimer = nullptr;
134+
Timer * mTiltTimer = nullptr;
135+
OperationalState mLiftOpState = OperationalState::Stall;
136+
OperationalState mTiltOpState = OperationalState::Stall;
137+
138+
struct CoverWorkData
139+
{
140+
chip::EndpointId mEndpointId;
141+
bool isTilt;
142+
143+
union
144+
{
145+
chip::Percent100ths percent100ths;
146+
OperationalState opState;
147+
};
148+
};
149+
150+
void SchedulePositionSet(chip::Percent100ths position, bool isTilt);
151+
static void CallbackPositionSet(intptr_t arg);
152+
void ScheduleOperationalStateSet(OperationalState opState, bool isTilt);
153+
static void CallbackOperationalStateSet(intptr_t arg);
154+
};
155+
156+
static WindowApp & Instance();
157+
158+
virtual ~WindowApp() = default;
159+
virtual CHIP_ERROR Init();
160+
virtual CHIP_ERROR Start() = 0;
161+
virtual CHIP_ERROR Run();
162+
virtual void Finish();
163+
virtual void PostEvent(const Event & event) = 0;
164+
virtual void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId) = 0;
165+
166+
protected:
167+
struct StateFlags
168+
{
169+
#if CHIP_ENABLE_OPENTHREAD
170+
bool isThreadProvisioned = false;
171+
bool isThreadEnabled = false;
172+
#else
173+
bool isWiFiProvisioned = false;
174+
bool isWiFiEnabled = false;
175+
#endif
176+
bool haveBLEConnections = false;
177+
bool isWinking = false;
178+
};
179+
180+
Cover & GetCover();
181+
Cover * GetCover(chip::EndpointId endpoint);
182+
183+
virtual Button * CreateButton(Button::Id id, const char * name) = 0;
184+
virtual void DestroyButton(Button * b);
185+
virtual Timer * CreateTimer(const char * name, uint32_t timeoutInMs, Timer::Callback callback, void * context) = 0;
186+
virtual void DestroyTimer(Timer * timer);
187+
188+
virtual void ProcessEvents() = 0;
189+
virtual void DispatchEvent(const Event & event);
190+
virtual void OnMainLoop() = 0;
191+
static void OnLongPressTimeout(Timer & timer);
192+
193+
Timer * mLongPressTimer = nullptr;
194+
Button * mButtonUp = nullptr;
195+
Button * mButtonDown = nullptr;
196+
StateFlags mState;
197+
bool mTiltMode = false;
198+
bool mUpPressed = false;
199+
bool mDownPressed = false;
200+
bool mUpSuppressed = false;
201+
bool mDownSuppressed = false;
202+
bool mResetWarning = false;
203+
204+
private:
205+
void HandleLongPress();
206+
void DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute);
207+
208+
Cover mCoverList[WINDOW_COVER_COUNT];
209+
uint8_t mCurrentCover = 0;
210+
};

slc/sample-app/window-app/include/app.h

-53
This file was deleted.

0 commit comments

Comments
 (0)