Skip to content

Commit d5916d7

Browse files
brosahayrosahay-silabs
authored andcommitted
Clean up of logs and added checks
1 parent daa2a57 commit d5916d7

File tree

12 files changed

+304
-446
lines changed

12 files changed

+304
-446
lines changed

examples/platform/silabs/BaseApplication.cpp

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

236236
// Start App task.
237237
sAppTaskHandle = osThreadNew(taskFunction, &sAppEventQueue, &appTaskAttr);
238238
if (sAppTaskHandle == nullptr)
239239
{
240-
SILABS_LOG("Failed to create app task");
240+
ChipLogDetail(AppServer, "Failed to create app task");
241241
appError(APP_ERROR_CREATE_TASK_FAILED);
242242
}
243243
return CHIP_NO_ERROR;
@@ -251,12 +251,12 @@ CHIP_ERROR BaseApplication::Init()
251251
/*
252252
* Wait for the WiFi to be initialized
253253
*/
254-
SILABS_LOG("APP: Wait WiFi Init");
254+
ChipLogDetail(AppServer, "APP: Wait WiFi Init");
255255
while (!wfx_hw_ready())
256256
{
257257
vTaskDelay(pdMS_TO_TICKS(10));
258258
}
259-
SILABS_LOG("APP: Done WiFi Init");
259+
ChipLogDetail(AppServer, "APP: Done WiFi Init");
260260
/* We will init server when we get IP */
261261

262262
chip::DeviceLayer::PlatformMgr().LockChipStack();
@@ -273,7 +273,7 @@ CHIP_ERROR BaseApplication::Init()
273273
);
274274
if (sFunctionTimer == NULL)
275275
{
276-
SILABS_LOG("funct timer create failed");
276+
ChipLogDetail(AppServer, "funct timer create failed");
277277
appError(APP_ERROR_CREATE_TIMER_FAILED);
278278
}
279279

@@ -285,12 +285,12 @@ CHIP_ERROR BaseApplication::Init()
285285
);
286286
if (sLightTimer == NULL)
287287
{
288-
SILABS_LOG("Light Timer create failed");
288+
ChipLogDetail(AppServer, "Light Timer create failed");
289289
appError(APP_ERROR_CREATE_TIMER_FAILED);
290290
}
291291

292-
SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
293-
SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
292+
ChipLogDetail(AppServer, "Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
293+
ChipLogDetail(AppServer, "Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
294294

295295
ConfigurationMgr().LogDeviceConfig();
296296

@@ -540,12 +540,12 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
540540
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
541541
if (err != CHIP_NO_ERROR)
542542
{
543-
SILABS_LOG("Failed to open the Basic Commissioning Window");
543+
ChipLogDetail(AppServer, "Failed to open the Basic Commissioning Window");
544544
}
545545
}
546546
else
547547
{
548-
SILABS_LOG("Network is already provisioned, Ble advertisement not enabled");
548+
ChipLogDetail(AppServer, "Network is already provisioned, Ble advertisement not enabled");
549549
#if CHIP_CONFIG_ENABLE_ICD_SERVER
550550
// Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups.
551551
PlatformMgr().ScheduleWork([](intptr_t) { ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); });
@@ -568,7 +568,7 @@ void BaseApplication::CancelFunctionTimer()
568568
{
569569
if (osTimerStop(sFunctionTimer) == osError)
570570
{
571-
SILABS_LOG("app timer stop() failed");
571+
ChipLogDetail(AppServer, "app timer stop() failed");
572572
appError(APP_ERROR_STOP_TIMER_FAILED);
573573
}
574574
}
@@ -578,15 +578,15 @@ void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs)
578578
// Starts or restarts the function timer
579579
if (osTimerStart(sFunctionTimer, pdMS_TO_TICKS(aTimeoutInMs)) != osOK)
580580
{
581-
SILABS_LOG("app timer start() failed");
581+
ChipLogDetail(AppServer, "app timer start() failed");
582582
appError(APP_ERROR_START_TIMER_FAILED);
583583
}
584584
}
585585

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

591591
// Start timer for FACTORY_RESET_CANCEL_WINDOW_TIMEOUT to allow user to
592592
// cancel, if required.
@@ -615,15 +615,15 @@ void BaseApplication::CancelFactoryResetSequence()
615615
if (sIsFactoryResetTriggered)
616616
{
617617
sIsFactoryResetTriggered = false;
618-
SILABS_LOG("Factory Reset has been Canceled");
618+
ChipLogDetail(AppServer, "Factory Reset has been Canceled");
619619
}
620620
}
621621

622622
void BaseApplication::StartStatusLEDTimer()
623623
{
624624
if (osTimerStart(sLightTimer, kLightTimerPeriod) != osOK)
625625
{
626-
SILABS_LOG("Light Time start failed");
626+
ChipLogDetail(AppServer, "Light Time start failed");
627627
appError(APP_ERROR_START_TIMER_FAILED);
628628
}
629629
}
@@ -636,7 +636,7 @@ void BaseApplication::StopStatusLEDTimer()
636636

637637
if (osTimerStop(sLightTimer) == osError)
638638
{
639-
SILABS_LOG("Light Time start failed");
639+
ChipLogDetail(AppServer, "Light Time start failed");
640640
appError(APP_ERROR_STOP_TIMER_FAILED);
641641
}
642642
}
@@ -767,12 +767,12 @@ void BaseApplication::PostEvent(const AppEvent * aEvent)
767767
{
768768
if (osMessageQueuePut(sAppEventQueue, aEvent, osPriorityNormal, 0) != osOK)
769769
{
770-
SILABS_LOG("Failed to post event to app task event queue");
770+
ChipLogDetail(AppServer, "Failed to post event to app task event queue");
771771
}
772772
}
773773
else
774774
{
775-
SILABS_LOG("App Event Queue is uninitialized");
775+
ChipLogDetail(AppServer, "App Event Queue is uninitialized");
776776
}
777777
}
778778

@@ -784,7 +784,7 @@ void BaseApplication::DispatchEvent(AppEvent * aEvent)
784784
}
785785
else
786786
{
787-
SILABS_LOG("Event received with no handler. Dropping event.");
787+
ChipLogDetail(AppServer, "Event received with no handler. Dropping event.");
788788
}
789789
}
790790

@@ -820,7 +820,7 @@ void BaseApplication::DoProvisioningReset()
820820
CHIP_ERROR err = Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow();
821821
if (err != CHIP_NO_ERROR)
822822
{
823-
SILABS_LOG("Failed to open the Basic Commissioning Window");
823+
ChipLogError(AppServer, "Failed to open the Basic Commissioning Window");
824824
}
825825
});
826826
}
@@ -838,7 +838,7 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
838838
VerifyOrReturn(event->InternetConnectivityChange.IPv4 == kConnectivity_Established);
839839
if (DIC_OK != dic_init(dic::control::subscribeCB))
840840
{
841-
SILABS_LOG("Failed to initialize DIC module\n");
841+
ChipLogError(AppServer, "dic_init failed");
842842
}
843843
#endif // DIC_ENABLE
844844
break;
@@ -881,7 +881,7 @@ void BaseApplication::OutputQrCode(bool refreshLCD)
881881
}
882882
else
883883
{
884-
SILABS_LOG("Getting QR code failed!");
884+
ChipLogDetail(AppServer, "Getting QR code failed!");
885885
}
886886
}
887887

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,13 @@ sl_status_t join_callback_handler(sl_wifi_event_t event, char * result, uint32_t
260260
*/
261261
ChipLogDetail(DeviceLayer, "join_callback_handler: success");
262262
memset(&temp_reset, 0, sizeof(temp_reset));
263-
264-
WfxEvent.eventType = WFX_EVT_STA_CONN;
265-
WfxPostEvent(&WfxEvent);
266263
wfx_rsi.join_retries = 0;
267264
retryInterval = WLAN_MIN_RETRY_TIMER_MS;
268265
// Once the join passes setting the disconnection event to true to differentiate between the first connection and reconnection
269266
is_wifi_disconnection_event = true;
270267
callback_status = SL_STATUS_OK;
268+
WfxEvent.eventType = WFX_EVT_STA_CONN;
269+
WfxPostEvent(&WfxEvent);
271270
return SL_STATUS_OK;
272271
}
273272

@@ -351,7 +350,7 @@ int32_t wfx_rsi_power_save(rsi_power_save_profile_mode_t sl_si91x_ble_state, sl_
351350
*****************************************************************************************/
352351
int32_t wfx_wifi_rsi_init(void)
353352
{
354-
ChipLogDetail(DeviceLayer, "wfx_wifi_rsi_init started");
353+
ChipLogDetail(DeviceLayer, "wfx_wifi_rsi_init: started");
355354
sl_status_t status;
356355
status = sl_wifi_init(&config, NULL, sl_wifi_default_event_handler);
357356
VerifyOrReturnError(status == SL_STATUS_OK, status);
@@ -709,11 +708,9 @@ static sl_status_t wfx_rsi_do_join(void)
709708
/// Helper function for HandleDHCPPolling.
710709
void NotifyConnectivity()
711710
{
712-
if (!hasNotifiedWifiConnectivity)
713-
{
714-
wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac);
715-
hasNotifiedWifiConnectivity = true;
716-
}
711+
VerifyOrReturn(!hasNotifiedWifiConnectivity);
712+
wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac);
713+
hasNotifiedWifiConnectivity = true;
717714
}
718715

719716
void HandleDHCPPolling()
@@ -734,6 +731,8 @@ void HandleDHCPPolling()
734731
{
735732
wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr);
736733
hasNotifiedIPV4 = true;
734+
event.eventType = WFX_EVT_STA_DHCP_DONE;
735+
WfxPostEvent(&event);
737736
NotifyConnectivity();
738737
}
739738
else if (dhcp_state == DHCP_OFF)

0 commit comments

Comments
 (0)