Skip to content

Commit 2ae320e

Browse files
[Silabs] Fix window-app sync issue with 917 soc (#33376)
* Pull request #1812: [MATTER-2228] Remove all chip lock from the Lift and Tilt actions update. Merge in WMN_TOOLS/matter from fix/Window-app-synchronization to RC_2.3.0-1.3 Squashed commit of the following: commit 05e3e7224c6108e7e08ba4d9d7ff69f2b2c6fdc1 Author: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue May 7 16:30:30 2024 -0400 address last comments commit 2d32b0eca831de91ae1105cf076f07b7fd9d424f Author: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue May 7 15:02:16 2024 -0400 address comments commit 1db94351b7be41e9ef65cabafe1abf4910446848 Author: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon May 6 11:32:49 2024 -0400 Cleanup and add briefs and comments ... and 1 more commit * Restyled by clang-format * Apply suggestions and fix default config for the window app --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 048cf12 commit 2ae320e

File tree

4 files changed

+135
-159
lines changed

4 files changed

+135
-159
lines changed

examples/window-app/silabs/build_for_wifi_args.gni

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ import("${chip_root}/src/platform/silabs/wifi_args.gni")
1919

2020
chip_enable_ota_requestor = true
2121
app_data_model = "${chip_root}/examples/window-app/common:window-common"
22+
sl_enable_test_event_trigger = true

examples/window-app/silabs/include/WindowManager.h

+41-30
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,33 @@ class WindowManager
5757

5858
struct Cover
5959
{
60-
void Init(chip::EndpointId endpoint);
61-
62-
void LiftUpdate(bool newTarget);
63-
void LiftGoToTarget() { LiftUpdate(true); }
64-
void LiftContinueToTarget() { LiftUpdate(false); }
65-
void LiftStepToward(OperationalState direction);
66-
void LiftSchedulePositionSet(chip::Percent100ths position) { SchedulePositionSet(position, false); }
67-
void LiftScheduleOperationalStateSet(OperationalState opState) { ScheduleOperationalStateSet(opState, false); }
60+
enum ControlAction : uint8_t
61+
{
62+
Lift = 0,
63+
Tilt = 1
64+
};
6865

69-
void TiltUpdate(bool newTarget);
70-
void TiltGoToTarget() { TiltUpdate(true); }
71-
void TiltContinueToTarget() { TiltUpdate(false); }
72-
void TiltStepToward(OperationalState direction);
73-
void TiltSchedulePositionSet(chip::Percent100ths position) { SchedulePositionSet(position, true); }
74-
void TiltScheduleOperationalStateSet(OperationalState opState) { ScheduleOperationalStateSet(opState, true); }
66+
void Init(chip::EndpointId endpoint);
7567

76-
void UpdateTargetPosition(OperationalState direction, bool isTilt);
68+
/**
69+
* @brief Schedule a lift or a tilt related attribute transition on the ChipEvent queue
70+
* **This function allocates a CoverWorkData which needs to be freed by the Worker callback**
71+
*
72+
* @param action : ControlAction::Lift will ScheduleWork LiftUpdateWorker, while ControlAction::Tilt will ScheduleWork
73+
* TilitUpdateWorker
74+
* @param setNewTarget : True will stop any ongoing transition and start a new one. False will continue the active
75+
* transition updates
76+
*/
77+
void ScheduleControlAction(ControlAction action, bool setNewTarget);
78+
// Helper functions that schedule Lift transitions
79+
inline void LiftGoToTarget() { ScheduleControlAction(ControlAction::Lift, true); }
80+
inline void LiftContinueToTarget() { ScheduleControlAction(ControlAction::Lift, false); }
81+
// Helper functions that schedule Tilt transitions
82+
inline void TiltGoToTarget() { ScheduleControlAction(ControlAction::Tilt, true); }
83+
inline void TiltContinueToTarget() { ScheduleControlAction(ControlAction::Tilt, false); }
84+
85+
void PositionSet(chip::EndpointId endpointId, chip::Percent100ths position, ControlAction action);
86+
void UpdateTargetPosition(OperationalState direction, ControlAction action);
7787

7888
Type CycleType();
7989

@@ -88,22 +98,23 @@ class WindowManager
8898
OperationalState mLiftOpState = OperationalState::Stall;
8999
OperationalState mTiltOpState = OperationalState::Stall;
90100

91-
struct CoverWorkData
92-
{
93-
chip::EndpointId mEndpointId;
94-
bool isTilt;
95-
96-
union
97-
{
98-
chip::Percent100ths percent100ths;
99-
OperationalState opState;
100-
};
101-
};
101+
/**
102+
* @brief Worker callbacks for the ScheduleControlAction.
103+
* Those functions compute the operational state, and transititon movement based on the current and target positions
104+
* for the cover.
105+
* @param arg Context passed to the schedule worker. In this case, a CoverWorkData pointer
106+
* The referenced CoverWorkData was allocated by ScheduleControlAction and must be freed by the worker.
107+
*/
108+
static void LiftUpdateWorker(intptr_t arg);
109+
static void TiltUpdateWorker(intptr_t arg);
110+
};
102111

103-
void SchedulePositionSet(chip::Percent100ths position, bool isTilt);
104-
static void CallbackPositionSet(intptr_t arg);
105-
void ScheduleOperationalStateSet(OperationalState opState, bool isTilt);
106-
static void CallbackOperationalStateSet(intptr_t arg);
112+
struct CoverWorkData
113+
{
114+
Cover * cover = nullptr;
115+
bool setNewTarget = false;
116+
CoverWorkData(Cover * c, bool t) : cover(c), setNewTarget(t) {}
117+
~CoverWorkData() { cover = nullptr; }
107118
};
108119

109120
static WindowManager & Instance();

examples/window-app/silabs/openthread.gni

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain")
2121
app_data_model = "${chip_root}/examples/window-app/common:window-common"
2222
chip_enable_ota_requestor = true
2323
chip_enable_openthread = true
24+
sl_enable_test_event_trigger = true
2425

2526
openthread_external_platform =
2627
"${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32"
2728

2829
# ICD Default configurations
2930
chip_enable_icd_server = true
30-
enable_synchronized_sed = true
31+
enable_synchronized_sed = false
3132
chip_subscription_timeout_resumption = false
3233
sl_use_subscription_syncing = true
3334

0 commit comments

Comments
 (0)