21
21
*/
22
22
23
23
#include < lib/support/SafeInt.h>
24
+ #include < platform/CHIPDeviceConfig.h>
25
+ #include < platform/ConnectivityManager.h>
24
26
#include < platform/internal/CHIPDeviceLayerInternal.h>
25
27
26
28
#include " FailSafeContext.h"
@@ -48,6 +50,19 @@ void FailSafeContext::HandleDisarmFailSafe(intptr_t arg)
48
50
failSafeContext->DisarmFailSafe ();
49
51
}
50
52
53
+ void FailSafeContext::SetFailSafeArmed (bool armed)
54
+ {
55
+ #if CHIP_DEVICE_CONFIG_ENABLE_SED
56
+ if (IsFailSafeArmed () != armed)
57
+ {
58
+ // Per spec, we should be staying in active mode while a fail-safe is
59
+ // armed.
60
+ DeviceLayer::ConnectivityMgr ().RequestSEDActiveMode (armed);
61
+ }
62
+ #endif // CHIP_DEVICE_CONFIG_ENABLE_SED
63
+ mFailSafeArmed = armed;
64
+ }
65
+
51
66
void FailSafeContext::FailSafeTimerExpired ()
52
67
{
53
68
if (!IsFailSafeArmed ())
@@ -66,8 +81,9 @@ void FailSafeContext::ScheduleFailSafeCleanup(FabricIndex fabricIndex, bool addN
66
81
// Not armed, but busy so cannot rearm (via General Commissioning cluster) until the flushing
67
82
// via `HandleDisarmFailSafe` path is complete.
68
83
// TODO: This is hacky and we need to remove all this event pushing business, to keep all fail-safe logic-only.
69
- mFailSafeBusy = true ;
70
- mFailSafeArmed = false ;
84
+ mFailSafeBusy = true ;
85
+
86
+ SetFailSafeArmed (false );
71
87
72
88
ChipDeviceEvent event;
73
89
event.Type = DeviceEventType::kFailSafeTimerExpired ;
@@ -90,7 +106,7 @@ CHIP_ERROR FailSafeContext::ArmFailSafe(FabricIndex accessingFabricIndex, System
90
106
91
107
CHIP_ERROR err = CHIP_NO_ERROR;
92
108
bool cancelTimersIfError = false ;
93
- if (!mFailSafeArmed )
109
+ if (!IsFailSafeArmed () )
94
110
{
95
111
System::Clock::Timeout maxCumulativeTimeout = System::Clock::Seconds32 (CHIP_DEVICE_CONFIG_MAX_CUMULATIVE_FAILSAFE_SEC);
96
112
SuccessOrExit (err = DeviceLayer::SystemLayer ().StartTimer (maxCumulativeTimeout, HandleMaxCumulativeFailSafeTimer, this ));
@@ -100,8 +116,8 @@ CHIP_ERROR FailSafeContext::ArmFailSafe(FabricIndex accessingFabricIndex, System
100
116
SuccessOrExit (
101
117
err = DeviceLayer::SystemLayer ().StartTimer (System::Clock::Seconds16 (expiryLengthSeconds), HandleArmFailSafeTimer, this ));
102
118
103
- mFailSafeArmed = true ;
104
- mFabricIndex = accessingFabricIndex;
119
+ SetFailSafeArmed ( true ) ;
120
+ mFabricIndex = accessingFabricIndex;
105
121
106
122
exit :
107
123
0 commit comments