@@ -81,11 +81,12 @@ async def _send_keep_active_command(self, duration, endpoint_id) -> int:
81
81
keep_active = await self .default_controller .SendCommand (nodeid = self .dut_node_id , endpoint = endpoint_id , payload = Clusters .Objects .BridgedDeviceBasicInformation .Commands .KeepActive (stayActiveDuration = duration ))
82
82
return keep_active
83
83
84
- async def _wait_for_active_changed_event (self , timeout ) -> int :
84
+ async def _wait_for_active_changed_event (self , timeout_s ) -> int :
85
85
try :
86
- promised_active_duration = self .q .get (block = True , timeout = timeout )
87
- logging .info (f"PromisedActiveDuration: { promised_active_duration } " )
88
- return promised_active_duration
86
+ promised_active_duration_event = self .q .get (block = True , timeout = timeout_s )
87
+ logging .info (f"PromisedActiveDurationEvent: { promised_active_duration_event } " )
88
+ promised_active_duration_ms = promised_active_duration_event .Data .promisedActiveDuration
89
+ return promised_active_duration_ms
89
90
except queue .Empty :
90
91
asserts .fail ("Timeout on event ActiveChanged" )
91
92
@@ -192,21 +193,21 @@ async def test_TC_BRBINFO_4_1(self):
192
193
193
194
self .step ("1a" )
194
195
195
- idle_mode_duration = await self ._read_attribute_expect_success (
196
+ idle_mode_duration_s = await self ._read_attribute_expect_success (
196
197
_ROOT_ENDPOINT_ID ,
197
198
icdm_cluster ,
198
199
icdm_attributes .IdleModeDuration ,
199
200
self .icd_nodeid
200
201
)
201
- logging .info (f"IdleModeDuration : { idle_mode_duration } " )
202
+ logging .info (f"IdleModeDurationS : { idle_mode_duration_s } " )
202
203
203
- active_mode_duration = await self ._read_attribute_expect_success (
204
+ active_mode_duration_ms = await self ._read_attribute_expect_success (
204
205
_ROOT_ENDPOINT_ID ,
205
206
icdm_cluster ,
206
207
icdm_attributes .ActiveModeDuration ,
207
208
self .icd_nodeid
208
209
)
209
- logging .info (f"ActiveModeDuration : { active_mode_duration } " )
210
+ logging .info (f"ActiveModeDurationMs : { active_mode_duration_ms } " )
210
211
211
212
self .step ("1b" )
212
213
@@ -218,49 +219,53 @@ async def test_TC_BRBINFO_4_1(self):
218
219
subscription = await self .default_controller .ReadEvent (nodeid = self .dut_node_id , events = [(dynamic_endpoint_id , event , urgent )], reportInterval = [1 , 3 ])
219
220
subscription .SetEventUpdateCallback (callback = cb )
220
221
221
- stay_active_duration = 1000
222
- logging .info (f"Sending KeepActiveCommand({ stay_active_duration } ms)" )
223
- self ._send_keep_active_command (stay_active_duration , dynamic_endpoint_id )
222
+ stay_active_duration_ms = 1000
223
+ logging .info (f"Sending KeepActiveCommand({ stay_active_duration_ms } ms)" )
224
+ await self ._send_keep_active_command (stay_active_duration_ms , dynamic_endpoint_id )
224
225
225
226
logging .info ("Waiting for ActiveChanged from DUT..." )
226
- promised_active_duration = await self ._wait_for_active_changed_event ((idle_mode_duration + max (active_mode_duration , stay_active_duration ))/ 1000 )
227
+ timeout_s = idle_mode_duration_s + max (active_mode_duration_ms , stay_active_duration_ms )/ 1000
228
+ promised_active_duration_ms = await self ._wait_for_active_changed_event (timeout_s )
227
229
228
- asserts .assert_greater_equal (promised_active_duration , stay_active_duration , "PromisedActiveDuration < StayActiveDuration" )
230
+ asserts .assert_greater_equal (promised_active_duration_ms , stay_active_duration_ms ,
231
+ "PromisedActiveDuration < StayActiveDuration" )
229
232
230
233
self .step ("2" )
231
234
232
- stay_active_duration = 1500
233
- logging .info (f"Sending KeepActiveCommand({ stay_active_duration } ms)" )
234
- self ._send_keep_active_command (stay_active_duration )
235
+ stay_active_duration_ms = 1500
236
+ logging .info (f"Sending KeepActiveCommand({ stay_active_duration_ms } ms)" )
237
+ await self ._send_keep_active_command (stay_active_duration_ms , dynamic_endpoint_id )
235
238
236
239
logging .info ("Waiting for ActiveChanged from DUT..." )
237
- promised_active_duration = await self ._wait_for_active_changed_event ((idle_mode_duration + max (active_mode_duration , stay_active_duration ))/ 1000 )
240
+ timeout_s = idle_mode_duration_s + max (active_mode_duration_ms , stay_active_duration_ms )/ 1000
241
+ promised_active_duration_ms = await self ._wait_for_active_changed_event (timeout_s )
238
242
239
243
# wait for active time duration
240
- time .sleep (max (stay_active_duration / 1000 , promised_active_duration ))
244
+ sleep_time_s = max (stay_active_duration_ms , promised_active_duration_ms )/ 1000
245
+ time .sleep (sleep_time_s )
241
246
# ICD now should be in idle mode
242
247
243
248
# sends 3x keep active commands
244
- logging .info (f"Sending KeepActiveCommand({ stay_active_duration } )" )
245
- self ._send_keep_active_command (stay_active_duration , dynamic_endpoint_id )
246
- time .sleep (100 )
247
- logging .info (f"Sending KeepActiveCommand({ stay_active_duration } )" )
248
- self ._send_keep_active_command (stay_active_duration , dynamic_endpoint_id )
249
- time .sleep (100 )
250
- logging .info (f"Sending KeepActiveCommand({ stay_active_duration } )" )
251
- self ._send_keep_active_command (stay_active_duration , dynamic_endpoint_id )
252
- time .sleep (100 )
249
+ logging .info (f"Step3 Sending first KeepActiveCommand({ stay_active_duration_ms } )" )
250
+ await self ._send_keep_active_command (stay_active_duration_ms , dynamic_endpoint_id )
251
+ time .sleep (0.1 )
252
+ logging .info (f"Step3 Sending second KeepActiveCommand({ stay_active_duration_ms } )" )
253
+ await self ._send_keep_active_command (stay_active_duration_ms , dynamic_endpoint_id )
254
+ time .sleep (0.1 )
255
+ logging .info (f"Step3 Sending third KeepActiveCommand({ stay_active_duration_ms } )" )
256
+ await self ._send_keep_active_command (stay_active_duration_ms , dynamic_endpoint_id )
257
+ time .sleep (0.1 )
253
258
254
259
logging .info ("Waiting for ActiveChanged from DUT..." )
255
- promised_active_duration = await self ._wait_for_active_changed_event ((idle_mode_duration + max (active_mode_duration , stay_active_duration ))/ 1000 )
260
+ promised_active_duration_ms = await self ._wait_for_active_changed_event ((idle_mode_duration_s + max (active_mode_duration_ms , stay_active_duration_ms ))/ 1000 )
256
261
257
262
asserts .assert_equal (self .q .qSize (), 0 , "More than one event received from DUT" )
258
263
259
264
self .step ("3" )
260
265
261
- stay_active_duration = 10000
262
- logging .info (f"Sending KeepActiveCommand({ stay_active_duration } )" )
263
- self ._send_keep_active_command (stay_active_duration , dynamic_endpoint_id )
266
+ stay_active_duration_ms = 10000
267
+ logging .info (f"Sending KeepActiveCommand({ stay_active_duration_ms } )" )
268
+ await self ._send_keep_active_command (stay_active_duration_ms , dynamic_endpoint_id )
264
269
265
270
# stops (halts) the ICD server process by sending a SIGTOP signal
266
271
self .app_process .send_signal (signal .SIGSTOP .value )
@@ -274,9 +279,9 @@ async def test_TC_BRBINFO_4_1(self):
274
279
self .app_process .send_signal (signal .SIGCONT .value )
275
280
276
281
# wait for active changed event, expect no event will be sent
277
- event_timeout = (idle_mode_duration + max (active_mode_duration , stay_active_duration ))/ 1000
282
+ event_timeout = (idle_mode_duration_s + max (active_mode_duration_ms , stay_active_duration_ms ))/ 1000
278
283
try :
279
- promised_active_duration = self .q .get (block = True , timeout = event_timeout )
284
+ promised_active_duration_ms = self .q .get (block = True , timeout = event_timeout )
280
285
finally :
281
286
asserts .assert_true (queue .Empty (), "ActiveChanged event received when not expected" )
282
287
0 commit comments