Skip to content

Commit cdb8862

Browse files
committed
Clean up of logs and added checks
1 parent 05b60aa commit cdb8862

File tree

10 files changed

+336
-477
lines changed

10 files changed

+336
-477
lines changed

examples/platform/silabs/BaseApplication.cpp

+22-22
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,15 @@ CHIP_ERROR BaseApplication::StartAppTask(osThreadFunc_t taskFunction)
232232
sAppEventQueue = osMessageQueueNew(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), &appEventQueueAttr);
233233
if (sAppEventQueue == NULL)
234234
{
235-
SILABS_LOG("Failed to allocate app event queue");
235+
ChipLogDetail(AppServer, "Failed to allocate app event queue");
236236
appError(APP_ERROR_EVENT_QUEUE_FAILED);
237237
}
238238

239239
// Start App task.
240240
sAppTaskHandle = osThreadNew(taskFunction, &sAppEventQueue, &appTaskAttr);
241241
if (sAppTaskHandle == nullptr)
242242
{
243-
SILABS_LOG("Failed to create app task");
243+
ChipLogDetail(AppServer, "Failed to create app task");
244244
appError(APP_ERROR_CREATE_TASK_FAILED);
245245
}
246246
return CHIP_NO_ERROR;
@@ -254,12 +254,12 @@ CHIP_ERROR BaseApplication::Init()
254254
/*
255255
* Wait for the WiFi to be initialized
256256
*/
257-
SILABS_LOG("APP: Wait WiFi Init");
257+
ChipLogDetail(AppServer, "APP: Wait WiFi Init");
258258
while (!wfx_hw_ready())
259259
{
260260
vTaskDelay(pdMS_TO_TICKS(10));
261261
}
262-
SILABS_LOG("APP: Done WiFi Init");
262+
ChipLogDetail(AppServer, "APP: Done WiFi Init");
263263
/* We will init server when we get IP */
264264

265265
chip::DeviceLayer::PlatformMgr().LockChipStack();
@@ -276,7 +276,7 @@ CHIP_ERROR BaseApplication::Init()
276276
);
277277
if (sFunctionTimer == NULL)
278278
{
279-
SILABS_LOG("funct timer create failed");
279+
ChipLogDetail(AppServer, "funct timer create failed");
280280
appError(APP_ERROR_CREATE_TIMER_FAILED);
281281
}
282282

@@ -288,12 +288,12 @@ CHIP_ERROR BaseApplication::Init()
288288
);
289289
if (sLightTimer == NULL)
290290
{
291-
SILABS_LOG("Light Timer create failed");
291+
ChipLogDetail(AppServer, "Light Timer create failed");
292292
appError(APP_ERROR_CREATE_TIMER_FAILED);
293293
}
294294

295-
SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
296-
SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
295+
ChipLogDetail(AppServer, "Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
296+
ChipLogDetail(AppServer, "Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
297297

298298
ConfigurationMgr().LogDeviceConfig();
299299

@@ -543,12 +543,12 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
543543
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
544544
if (err != CHIP_NO_ERROR)
545545
{
546-
SILABS_LOG("Failed to open the Basic Commissioning Window");
546+
ChipLogDetail(AppServer, "Failed to open the Basic Commissioning Window");
547547
}
548548
}
549549
else
550550
{
551-
SILABS_LOG("Network is already provisioned, Ble advertisement not enabled");
551+
ChipLogDetail(AppServer, "Network is already provisioned, Ble advertisement not enabled");
552552
#if CHIP_CONFIG_ENABLE_ICD_SERVER
553553
// Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups.
554554
PlatformMgr().ScheduleWork([](intptr_t) { ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); });
@@ -571,7 +571,7 @@ void BaseApplication::CancelFunctionTimer()
571571
{
572572
if (osTimerStop(sFunctionTimer) == osError)
573573
{
574-
SILABS_LOG("app timer stop() failed");
574+
ChipLogDetail(AppServer, "app timer stop() failed");
575575
appError(APP_ERROR_STOP_TIMER_FAILED);
576576
}
577577
}
@@ -581,15 +581,15 @@ void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs)
581581
// Starts or restarts the function timer
582582
if (osTimerStart(sFunctionTimer, pdMS_TO_TICKS(aTimeoutInMs)) != osOK)
583583
{
584-
SILABS_LOG("app timer start() failed");
584+
ChipLogDetail(AppServer, "app timer start() failed");
585585
appError(APP_ERROR_START_TIMER_FAILED);
586586
}
587587
}
588588

589589
void BaseApplication::StartFactoryResetSequence()
590590
{
591591
// Initiate the factory reset sequence
592-
SILABS_LOG("Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
592+
ChipLogDetail(AppServer, "Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
593593

594594
// Start timer for FACTORY_RESET_CANCEL_WINDOW_TIMEOUT to allow user to
595595
// cancel, if required.
@@ -618,15 +618,15 @@ void BaseApplication::CancelFactoryResetSequence()
618618
if (sIsFactoryResetTriggered)
619619
{
620620
sIsFactoryResetTriggered = false;
621-
SILABS_LOG("Factory Reset has been Canceled");
621+
ChipLogDetail(AppServer, "Factory Reset has been Canceled");
622622
}
623623
}
624624

625625
void BaseApplication::StartStatusLEDTimer()
626626
{
627627
if (osTimerStart(sLightTimer, kLightTimerPeriod) != osOK)
628628
{
629-
SILABS_LOG("Light Time start failed");
629+
ChipLogDetail(AppServer, "Light Time start failed");
630630
appError(APP_ERROR_START_TIMER_FAILED);
631631
}
632632
}
@@ -639,7 +639,7 @@ void BaseApplication::StopStatusLEDTimer()
639639

640640
if (osTimerStop(sLightTimer) == osError)
641641
{
642-
SILABS_LOG("Light Time start failed");
642+
ChipLogDetail(AppServer, "Light Time start failed");
643643
appError(APP_ERROR_STOP_TIMER_FAILED);
644644
}
645645
}
@@ -770,12 +770,12 @@ void BaseApplication::PostEvent(const AppEvent * aEvent)
770770
{
771771
if (osMessageQueuePut(sAppEventQueue, aEvent, osPriorityNormal, 0) != osOK)
772772
{
773-
SILABS_LOG("Failed to post event to app task event queue");
773+
ChipLogDetail(AppServer, "Failed to post event to app task event queue");
774774
}
775775
}
776776
else
777777
{
778-
SILABS_LOG("App Event Queue is uninitialized");
778+
ChipLogDetail(AppServer, "App Event Queue is uninitialized");
779779
}
780780
}
781781

@@ -787,7 +787,7 @@ void BaseApplication::DispatchEvent(AppEvent * aEvent)
787787
}
788788
else
789789
{
790-
SILABS_LOG("Event received with no handler. Dropping event.");
790+
ChipLogDetail(AppServer, "Event received with no handler. Dropping event.");
791791
}
792792
}
793793

@@ -823,7 +823,7 @@ void BaseApplication::DoProvisioningReset()
823823
CHIP_ERROR err = Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow();
824824
if (err != CHIP_NO_ERROR)
825825
{
826-
SILABS_LOG("Failed to open the Basic Commissioning Window");
826+
ChipLogError(AppServer, "Failed to open the Basic Commissioning Window");
827827
}
828828
});
829829
}
@@ -841,7 +841,7 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
841841
VerifyOrReturn(event->InternetConnectivityChange.IPv4 == kConnectivity_Established);
842842
if (DIC_OK != dic_init(dic::control::subscribeCB))
843843
{
844-
SILABS_LOG("Failed to initialize DIC module\n");
844+
ChipLogError(AppServer, "dic_init failed");
845845
}
846846
#endif // DIC_ENABLE
847847
break;
@@ -884,7 +884,7 @@ void BaseApplication::OutputQrCode(bool refreshLCD)
884884
}
885885
else
886886
{
887-
SILABS_LOG("Getting QR code failed!");
887+
ChipLogDetail(AppServer, "Getting QR code failed!");
888888
}
889889
}
890890

examples/platform/silabs/SiWx917/SiWx917/sl_wifi_if.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,10 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
250250
*/
251251
ChipLogDetail(DeviceLayer, "join_callback_handler: success");
252252
memset(&temp_reset, 0, sizeof(temp_reset));
253-
254-
WfxEvent.eventType = WFX_EVT_STA_CONN;
255-
WfxPostEvent(&WfxEvent);
256253
wfx_rsi.join_retries = 0;
257254
callback_status = SL_STATUS_OK;
255+
WfxEvent.eventType = WFX_EVT_STA_CONN;
256+
WfxPostEvent(&WfxEvent);
258257
return SL_STATUS_OK;
259258
}
260259

@@ -338,7 +337,7 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_
338337
*****************************************************************************************/
339338
int32_t wfx_wifi_rsi_init(void)
340339
{
341-
ChipLogDetail(DeviceLayer, "wfx_wifi_rsi_init started");
340+
ChipLogDetail(DeviceLayer, "wfx_wifi_rsi_init: started");
342341
sl_status_t status;
343342
status = sl_wifi_init(&config, NULL, sl_wifi_default_event_handler);
344343
VerifyOrReturnError(status == SL_STATUS_OK, status);
@@ -695,11 +694,9 @@ static sl_status_t wfx_rsi_do_join(void)
695694
/// Helper function for HandleDHCPPolling.
696695
void NotifyConnectivity()
697696
{
698-
if (!hasNotifiedWifiConnectivity)
699-
{
700-
wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac);
701-
hasNotifiedWifiConnectivity = true;
702-
}
697+
VerifyOrReturn(!hasNotifiedWifiConnectivity);
698+
wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac);
699+
hasNotifiedWifiConnectivity = true;
703700
}
704701

705702
void HandleDHCPPolling()
@@ -720,6 +717,8 @@ void HandleDHCPPolling()
720717
{
721718
wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr);
722719
hasNotifiedIPV4 = true;
720+
event.eventType = WFX_EVT_STA_DHCP_DONE;
721+
WfxPostEvent(&event);
723722
NotifyConnectivity();
724723
}
725724
else if (dhcp_state == DHCP_OFF)

0 commit comments

Comments
 (0)