@@ -57,7 +57,9 @@ class TestICDManager;
57
57
class ICDManager : public ICDListener , public TestEventTriggerHandler
58
58
{
59
59
public:
60
- // This structure is used for the creation an ObjectPool of ICDStateObserver pointers
60
+ /* *
61
+ * @brief This structure is used for the creation an ObjectPool of ICDStateObserver pointers
62
+ */
61
63
struct ObserverPointer
62
64
{
63
65
ObserverPointer (ICDStateObserver * obs) : mObserver (obs) {}
@@ -71,11 +73,14 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler
71
73
ActiveMode,
72
74
};
73
75
74
- // This enum class represents to all ICDStateObserver callbacks available from the
75
- // mStateObserverPool for the ICDManager.
76
+ /* *
77
+ * @brief This enum class represents to all ICDStateObserver callbacks available from the
78
+ * mStateObserverPool for the ICDManager.
79
+ */
76
80
enum class ObserverEventType : uint8_t
77
81
{
78
82
EnterActiveMode,
83
+ EnterIdleMode,
79
84
TransitionToIdle,
80
85
ICDModeChange,
81
86
};
@@ -85,22 +90,31 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler
85
90
* This type can be used to implement specific verifiers that can be used in the CheckInMessagesWouldBeSent function.
86
91
* The goal is to avoid having multiple functions that implement the iterator loop with only the check changing.
87
92
*
88
- * @return true if at least one Check-In message would be sent
89
- * false No Check-In messages would be sent
93
+ * @return true: if at least one Check-In message would be sent
94
+ * false: No Check-In messages would be sent
90
95
*/
91
-
92
96
using ShouldCheckInMsgsBeSentFunction = bool (FabricIndex aFabricIndex, NodeId subjectID);
93
97
94
- ICDManager () {}
98
+ ICDManager () = default ;
99
+ ~ICDManager () = default ;
100
+
95
101
void Init (PersistentStorageDelegate * storage, FabricTable * fabricTable, Crypto::SymmetricKeystore * symmetricKeyStore,
96
- Messaging::ExchangeManager * exchangeManager, SubscriptionsInfoProvider * manager );
102
+ Messaging::ExchangeManager * exchangeManager, SubscriptionsInfoProvider * subInfoProvider );
97
103
void Shutdown ();
98
- void UpdateICDMode ();
99
- void UpdateOperationState (OperationalState state);
100
- void SetKeepActiveModeRequirements (KeepActiveFlags flag, bool state);
101
- bool IsKeepActive () { return mKeepActiveFlags .HasAny (); }
104
+
105
+ /* *
106
+ * @brief SupportsFeature verifies if a given FeatureMap bit is enabled
107
+ *
108
+ * @param[in] feature FeatureMap bit to verify
109
+ *
110
+ * @return true: if the FeatureMap bit is enabled in the ICDM cluster attribute.
111
+ * false: ff the FeatureMap bit is not enabled in the ICDM cluster attribute.
112
+ * if we failed to read the FeatureMap attribute.
113
+ */
102
114
bool SupportsFeature (Clusters::IcdManagement::Feature feature);
115
+
103
116
ICDConfigurationData::ICDMode GetICDMode () { return ICDConfigurationData::GetInstance ().GetICDMode (); };
117
+
104
118
/* *
105
119
* @brief Adds the referenced observer in parameters to the mStateObserverPool
106
120
* A maximum of CHIP_CONFIG_ICD_OBSERVERS_POOL_SIZE observers can be concurrently registered
@@ -111,36 +125,29 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler
111
125
112
126
/* *
113
127
* @brief Remove the referenced observer in parameters from the mStateObserverPool
128
+ * If the observer is not present in the object pool, we do nothing
114
129
*/
115
130
void ReleaseObserver (ICDStateObserver * observer);
116
131
117
- /* *
118
- * @brief Associates the ObserverEventType parameters to the correct
119
- * ICDStateObservers function and calls it for all observers in the mStateObserverPool
120
- */
121
- void postObserverEvent (ObserverEventType event);
122
- OperationalState GetOperationalState () { return mOperationalState ; }
123
-
124
132
/* *
125
133
* @brief Ensures that the remaining Active Mode duration is at least the smaller of 30000 milliseconds and stayActiveDuration.
126
134
*
127
- * @param stayActiveDuration The duration (in milliseconds) requested by the client to stay in Active Mode
135
+ * @param[in] stayActiveDuration The duration (in milliseconds) requested by the client to stay in Active Mode
128
136
* @return The duration (in milliseconds) the device will stay in Active Mode
129
137
*/
130
138
uint32_t StayActiveRequest (uint32_t stayActiveDuration);
131
139
132
140
/* *
133
141
* @brief TestEventTriggerHandler for the ICD feature set
134
142
*
135
- * @param eventTrigger Event trigger to handle.
143
+ * @param[in] eventTrigger Event trigger to handle.
144
+ *
136
145
* @return CHIP_ERROR CHIP_NO_ERROR - No erros during the processing
137
146
* CHIP_ERROR_INVALID_ARGUMENT - eventTrigger isn't a valid value
138
147
*/
139
148
CHIP_ERROR HandleEventTrigger (uint64_t eventTrigger) override ;
140
149
141
150
#if CHIP_CONFIG_ENABLE_ICD_CIP
142
- void SendCheckInMsgs ();
143
-
144
151
/* *
145
152
* @brief Trigger the ICDManager to send Check-In message if necessary
146
153
*
@@ -160,47 +167,106 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler
160
167
161
168
#if CONFIG_BUILD_FOR_HOST_UNIT_TEST
162
169
void SetTestFeatureMapValue (uint32_t featureMap) { mFeatureMap = featureMap; };
163
- #if !CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION && CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
170
+ #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS && !CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION
164
171
bool GetIsBootUpResumeSubscriptionExecuted () { return mIsBootUpResumeSubscriptionExecuted ; };
165
172
#endif // !CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION && CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
166
173
#endif
167
174
168
175
// Implementation of ICDListener functions.
169
176
// Callers must origin from the chip task context or hold the ChipStack lock.
177
+
170
178
void OnNetworkActivity () override ;
171
179
void OnKeepActiveRequest (KeepActiveFlags request) override ;
172
180
void OnActiveRequestWithdrawal (KeepActiveFlags request) override ;
173
181
void OnICDManagementServerEvent (ICDManagementEvents event) override ;
174
182
void OnSubscriptionReport () override ;
175
183
176
- protected :
184
+ private :
177
185
friend class TestICDManager ;
186
+ /* *
187
+ * @brief UpdateICDMode checks in which ICDMode (SIT or LIT) the ICD can go to and updates the mode if necessary.
188
+ * For a SIT ICD, the function does nothing.
189
+ * For a LIT ICD, the function checks if the ICD has a registration in the ICDMonitoringTable to determine in which
190
+ * ICDMode the ICD must be in.
191
+ */
192
+ void UpdateICDMode ();
193
+
194
+ /* *
195
+ * @brief UpdateOperationState updates the OperationState of the ICD to the requested one.
196
+ * IdleMode -> IdleMode : No actions are necessary, do nothing.
197
+ * IdleMode -> ActiveMode : Transition the device to ActiveMode, start the ActiveMode timer and triggers all necessary
198
+ * operations. These operations could be : Send Check-In messages
199
+ * Send subscription reports
200
+ * Process user actions
201
+ * ActiveMode -> ActiveMode : Increase remaining ActiveMode timer to one ActiveModeThreshold.
202
+ * If ActiveModeThreshold is 0, do nothing.
203
+ * ActiveMode -> IdleMode : Transition ICD to IdleMode and starts the IdleMode timer.
204
+ *
205
+ * @param state requested OperationalState for the ICD to transition to
206
+ */
207
+ void UpdateOperationState (OperationalState state);
208
+
209
+ /* *
210
+ * @brief Set or Remove a keep ActiveMode requirement for the given flag
211
+ * If state is true and the ICD is in IdleMode, transition the ICD to ActiveMode
212
+ * If state is false and the ICD is in ActiveMode, verifies if we can transition the ICD to IdleMode.
213
+ * If we can, transition the ICD to IdleMode.
214
+ *
215
+ * @param flag KeepActiveFlag to remove or add
216
+ * @param state true: adding a flag requirement
217
+ * false: removing a flag requirement
218
+ */
219
+ void SetKeepActiveModeRequirements (KeepActiveFlags flag, bool state);
220
+
221
+ /* *
222
+ * @brief Associates the ObserverEventType parameters to the correct
223
+ * ICDStateObservers function and calls it for all observers in the mStateObserverPool
224
+ */
225
+ void postObserverEvent (ObserverEventType event);
178
226
179
227
/* *
180
- * @brief Hepler function that extends the Active Mode duration as well as the Active Mode Jitter timer for the transition to
181
- * iddle mode.
228
+ * @brief Hepler function that extends the ActiveMode timer as well as the Active Mode Jitter timer for the transition to
229
+ * idle mode event .
182
230
*/
183
231
void ExtendActiveMode (System::Clock::Milliseconds16 extendDuration);
184
232
233
+ /* *
234
+ * @brief Timer callback function for when the IdleMode timer expires
235
+ *
236
+ * @param appState pointer to the ICDManager
237
+ */
185
238
static void OnIdleModeDone (System::Layer * aLayer, void * appState);
239
+
240
+ /* *
241
+ * @brief Timer callback function for when the ActiveMode timer expires
242
+ *
243
+ * @param appState pointer to the ICDManager
244
+ */
186
245
static void OnActiveModeDone (System::Layer * aLayer, void * appState);
187
246
188
247
/* *
189
- * @brief Callback function called shortly before the device enters idle mode to allow checks to be made. This is currently only
190
- * called once to prevent entering in a loop if some events re-trigger this check (for instance if a check for subscription
191
- * before entering idle mode leads to emiting a report, we will re-enter UpdateOperationState and check again for subscription,
192
- * etc.)
248
+ * @brief Timer Callback function called shortly before the device enters idle mode to allow checks to be made.
249
+ * This is currently only called once to prevent entering in a loop if some events re-trigger this check (for instance if
250
+ * a check for subscriptions before entering idle mode leads to emiting a report, we will re-enter UpdateOperationState
251
+ * and check again for subscription, etc.)
252
+ *
253
+ * @param appState pointer to the ICDManager
193
254
*/
194
255
static void OnTransitionToIdle (System::Layer * aLayer, void * appState);
195
256
196
257
#if CHIP_CONFIG_ENABLE_ICD_CIP
197
- uint8_t mCheckInRequestCount = 0 ;
198
- #endif // CHIP_CONFIG_ENABLE_ICD_CIP
199
-
200
- uint8_t mOpenExchangeContextCount = 0 ;
258
+ /* *
259
+ * @brief Function triggers all necessary Check-In messages to be sent.
260
+ *
261
+ * @note For each ICDMonitoring entry, we check if should send a Check-In message with
262
+ * ShouldCheckInMsgsBeSentAtActiveModeFunction. If we should, we allocate an ICDCheckInSender which tries to send a
263
+ * Check-In message to the registered client.
264
+ */
265
+ void SendCheckInMsgs ();
201
266
202
- private:
203
- #if CHIP_CONFIG_ENABLE_ICD_CIP
267
+ /* *
268
+ * @brief See function implementation in .cpp for details on this function.
269
+ */
204
270
bool ShouldCheckInMsgsBeSentAtActiveModeFunction (FabricIndex aFabricIndex, NodeId subjectID);
205
271
206
272
/* *
@@ -221,11 +287,15 @@ class ICDManager : public ICDListener, public TestEventTriggerHandler
221
287
OperationalState mOperationalState = OperationalState::ActiveMode;
222
288
bool mTransitionToIdleCalled = false ;
223
289
ObjectPool<ObserverPointer, CHIP_CONFIG_ICD_OBSERVERS_POOL_SIZE> mStateObserverPool ;
290
+ uint8_t mOpenExchangeContextCount = 0 ;
224
291
225
292
#if CHIP_CONFIG_ENABLE_ICD_CIP
293
+ uint8_t mCheckInRequestCount = 0 ;
294
+
226
295
#if !CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION && CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
227
296
bool mIsBootUpResumeSubscriptionExecuted = false ;
228
297
#endif // !CHIP_CONFIG_SUBSCRIPTION_TIMEOUT_RESUMPTION && CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
298
+
229
299
PersistentStorageDelegate * mStorage = nullptr ;
230
300
FabricTable * mFabricTable = nullptr ;
231
301
Messaging::ExchangeManager * mExchangeManager = nullptr ;
0 commit comments