@@ -141,7 +141,7 @@ TimerHandle_t sOTAInitTimer = 0;
141
141
142
142
// The OTA Init Timer is only started upon the first Thread State Change
143
143
// detected if the device is already on a Thread Network, or during the AppTask
144
- // Init sequence if the device is not yet on a Thread Network. Once the timer
144
+ // Init sequence if the device is not yet on a Thread Network. Once the timer
145
145
// has been started once, it does not need to be started again so the flag will
146
146
// be set to false.
147
147
bool isAppStarting = true ;
@@ -172,7 +172,6 @@ int AppTask::StartAppTask()
172
172
return ret;
173
173
}
174
174
175
-
176
175
// Identify take action
177
176
void identify_TakeAction (void )
178
177
{
@@ -210,21 +209,24 @@ void DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg)
210
209
PLAT_LOG (" Thread State Change" );
211
210
bool isThreadAttached = ThreadStackMgrImpl ().IsThreadAttached ();
212
211
213
- if (isThreadAttached){
212
+ if (isThreadAttached)
213
+ {
214
214
PLAT_LOG (" Device is on the Thread Network" );
215
215
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
216
- if (isAppStarting){
216
+ if (isAppStarting)
217
+ {
217
218
StartTimer (OTAREQUESTOR_INIT_TIMER_DELAY_MS);
218
219
isAppStarting = false ;
219
- }
220
+ }
220
221
#endif
221
222
}
222
223
break ;
223
224
}
224
225
}
225
226
226
227
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
227
- void OTAInitTimerEventHandler (TimerHandle_t xTimer){
228
+ void OTAInitTimerEventHandler (TimerHandle_t xTimer)
229
+ {
228
230
InitializeOTARequestor ();
229
231
}
230
232
#endif
@@ -248,17 +250,17 @@ int AppTask::Init()
248
250
}
249
251
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
250
252
// Create FreeRTOS sw timer for OTA timer.
251
- sOTAInitTimer = xTimerCreate (" OTAInitTmr" , // Just a text name, not used by the RTOS kernel
252
- OTAREQUESTOR_INIT_TIMER_DELAY_MS, // timer period (mS)
253
- false , // no timer reload (==one-shot)
254
- (void *) this , // init timer id = light obj context
255
- OTAInitTimerEventHandler // timer callback handler
253
+ sOTAInitTimer = xTimerCreate (" OTAInitTmr" , // Just a text name, not used by the RTOS kernel
254
+ OTAREQUESTOR_INIT_TIMER_DELAY_MS, // timer period (mS)
255
+ false , // no timer reload (==one-shot)
256
+ (void *) this , // init timer id = light obj context
257
+ OTAInitTimerEventHandler // timer callback handler
256
258
);
257
259
258
260
if (sOTAInitTimer == NULL )
259
261
{
260
262
PLAT_LOG (" sOTAInitTimer timer create failed" );
261
- }
263
+ }
262
264
else
263
265
{
264
266
PLAT_LOG (" sOTAInitTimer timer created successfully " );
@@ -352,11 +354,12 @@ int AppTask::Init()
352
354
ConfigurationMgr ().LogDeviceConfig ();
353
355
354
356
bool isThreadEnabled = ThreadStackMgrImpl ().IsThreadEnabled ();
355
- if (!isThreadEnabled && isAppStarting){
357
+ if (!isThreadEnabled && isAppStarting)
358
+ {
356
359
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
357
- PLAT_LOG (" Thread is Disabled, enable OTA Requestor" );
358
- StartTimer (OTAREQUESTOR_INIT_TIMER_DELAY_MS);
359
- isAppStarting = false ;
360
+ PLAT_LOG (" Thread is Disabled, enable OTA Requestor" );
361
+ StartTimer (OTAREQUESTOR_INIT_TIMER_DELAY_MS);
362
+ isAppStarting = false ;
360
363
#endif
361
364
}
362
365
@@ -385,20 +388,20 @@ void AppTask::AppTaskMain(void * pvParameter)
385
388
#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
386
389
void StartTimer (uint32_t aTimeoutMs)
387
390
{
388
- PLAT_LOG (" Start OTA Init Timer" )
389
- if (xTimerIsTimerActive (sOTAInitTimer ))
390
- {
391
- PLAT_LOG (" app timer already started!" );
392
- CancelTimer ();
393
- }
391
+ PLAT_LOG (" Start OTA Init Timer" )
392
+ if (xTimerIsTimerActive (sOTAInitTimer ))
393
+ {
394
+ PLAT_LOG (" app timer already started!" );
395
+ CancelTimer ();
396
+ }
394
397
395
- // timer is not active, change its period to required value (== restart).
396
- // FreeRTOS- Block for a maximum of 100 ticks if the change period command
397
- // cannot immediately be sent to the timer command queue.
398
- if (xTimerChangePeriod (sOTAInitTimer , pdMS_TO_TICKS (aTimeoutMs), 100 ) != pdPASS)
399
- {
400
- PLAT_LOG (" sOTAInitTimer timer start() failed" );
401
- }
398
+ // timer is not active, change its period to required value (== restart).
399
+ // FreeRTOS- Block for a maximum of 100 ticks if the change period command
400
+ // cannot immediately be sent to the timer command queue.
401
+ if (xTimerChangePeriod (sOTAInitTimer , pdMS_TO_TICKS (aTimeoutMs), 100 ) != pdPASS)
402
+ {
403
+ PLAT_LOG (" sOTAInitTimer timer start() failed" );
404
+ }
402
405
}
403
406
404
407
void CancelTimer (void )
@@ -517,27 +520,27 @@ void AppTask::DispatchEvent(AppEvent * aEvent)
517
520
case AppEvent::kEventType_IdentifyStart :
518
521
switch (identify_trigger_effect)
519
522
{
520
- case IDENTIFY_TRIGGER_EFFECT_BLINK:
521
- identify_TakeAction ();
522
- break ;
523
- case IDENTIFY_TRIGGER_EFFECT_BREATHE:
524
- identify_TakeAction ();
525
- break ;
526
- case IDENTIFY_TRIGGER_EFFECT_OKAY:
527
- identify_TakeAction ();
528
- break ;
529
- default :
530
- break ;
523
+ case IDENTIFY_TRIGGER_EFFECT_BLINK:
524
+ identify_TakeAction ();
525
+ break ;
526
+ case IDENTIFY_TRIGGER_EFFECT_BREATHE:
527
+ identify_TakeAction ();
528
+ break ;
529
+ case IDENTIFY_TRIGGER_EFFECT_OKAY:
530
+ identify_TakeAction ();
531
+ break ;
532
+ default :
533
+ break ;
531
534
}
532
535
PLAT_LOG (" Identify started" );
533
536
break ;
534
-
535
- case AppEvent::kEventType_Identify :
536
- // blink LED
537
+
538
+ case AppEvent::kEventType_Identify :
539
+ // blink LED
537
540
PLAT_LOG (" Identify cmd received, will blink green led three times now" );
538
541
#if (LED_ENABLE == 1)
539
- LED_startBlinking (sAppGreenHandle , 250 , 3 );
540
- #endif
542
+ LED_startBlinking (sAppGreenHandle , 250 , 3 );
543
+ #endif
541
544
break ;
542
545
543
546
case AppEvent::kEventType_IdentifyStop :
0 commit comments