Skip to content

Commit cb5ac92

Browse files
committed
Replace SILABS_LOG with ChipLogging
1 parent 5ebdea8 commit cb5ac92

File tree

1 file changed

+32
-41
lines changed

1 file changed

+32
-41
lines changed

examples/platform/silabs/BaseApplication.cpp

+32-41
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,7 @@ bool BaseApplication::sIsFactoryResetTriggered = false;
166166
LEDWidget * BaseApplication::sAppActionLed = nullptr;
167167
BaseApplicationDelegate BaseApplication::sAppDelegate = BaseApplicationDelegate();
168168

169-
#ifdef DIC_ENABLE
170-
namespace {
171-
void AppSpecificConnectivityEventCallback(const ChipDeviceEvent * event, intptr_t arg)
172-
{
173-
SILABS_LOG("AppSpecificConnectivityEventCallback: call back for IPV4");
174-
if ((event->Type == DeviceEventType::kInternetConnectivityChange) &&
175-
(event->InternetConnectivityChange.IPv4 == kConnectivity_Established))
176-
{
177-
SILABS_LOG("Got IPv4 Address! Starting DIC module\n");
178-
if (DIC_OK != dic_init(dic::control::subscribeCB))
179-
SILABS_LOG("Failed to initialize DIC module\n");
180-
}
181-
}
182-
} // namespace
183-
#endif // DIC_ENABLE
184-
169+
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
185170
void BaseApplicationDelegate::OnCommissioningSessionStarted()
186171
{
187172
isComissioningStarted = true;
@@ -203,7 +188,7 @@ void BaseApplicationDelegate::OnCommissioningWindowClosed()
203188
ChipLogError(DeviceLayer, "Failed to enable the TA Deep Sleep");
204189
}
205190
}
206-
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917qq
191+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
207192
}
208193

209194
void BaseApplicationDelegate::OnFabricCommitted(const FabricTable & fabricTable, FabricIndex fabricIndex)
@@ -234,15 +219,15 @@ CHIP_ERROR BaseApplication::StartAppTask(osThreadFunc_t taskFunction)
234219
sAppEventQueue = osMessageQueueNew(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), &appEventQueueAttr);
235220
if (sAppEventQueue == NULL)
236221
{
237-
SILABS_LOG("Failed to allocate app event queue");
222+
ChipLogDetail(AppServer, "Failed to allocate app event queue");
238223
appError(APP_ERROR_EVENT_QUEUE_FAILED);
239224
}
240225

241226
// Start App task.
242227
sAppTaskHandle = osThreadNew(taskFunction, &sAppEventQueue, &appTaskAttr);
243228
if (sAppTaskHandle == nullptr)
244229
{
245-
SILABS_LOG("Failed to create app task");
230+
ChipLogDetail(AppServer, "Failed to create app task");
246231
appError(APP_ERROR_CREATE_TASK_FAILED);
247232
}
248233
return CHIP_NO_ERROR;
@@ -256,12 +241,12 @@ CHIP_ERROR BaseApplication::Init()
256241
/*
257242
* Wait for the WiFi to be initialized
258243
*/
259-
SILABS_LOG("APP: Wait WiFi Init");
244+
ChipLogDetail(AppServer, "APP: Wait WiFi Init");
260245
while (!wfx_hw_ready())
261246
{
262247
vTaskDelay(pdMS_TO_TICKS(10));
263248
}
264-
SILABS_LOG("APP: Done WiFi Init");
249+
ChipLogDetail(AppServer, "APP: Done WiFi Init");
265250
/* We will init server when we get IP */
266251

267252
chip::DeviceLayer::PlatformMgr().LockChipStack();
@@ -278,7 +263,7 @@ CHIP_ERROR BaseApplication::Init()
278263
);
279264
if (sFunctionTimer == NULL)
280265
{
281-
SILABS_LOG("funct timer create failed");
266+
ChipLogDetail(AppServer, "funct timer create failed");
282267
appError(APP_ERROR_CREATE_TIMER_FAILED);
283268
}
284269

@@ -290,16 +275,12 @@ CHIP_ERROR BaseApplication::Init()
290275
);
291276
if (sLightTimer == NULL)
292277
{
293-
SILABS_LOG("Light Timer create failed");
278+
ChipLogDetail(AppServer, "Light Timer create failed");
294279
appError(APP_ERROR_CREATE_TIMER_FAILED);
295280
}
296281

297-
SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
298-
SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
299-
300-
#ifdef DIC_ENABLE
301-
chip::DeviceLayer::PlatformMgr().AddEventHandler(AppSpecificConnectivityEventCallback, reinterpret_cast<intptr_t>(nullptr));
302-
#endif // DIC_ENABLE
282+
ChipLogDetail(AppServer, "Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
283+
ChipLogDetail(AppServer, "Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
303284

304285
ConfigurationMgr().LogDeviceConfig();
305286

@@ -549,12 +530,12 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
549530
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
550531
if (err != CHIP_NO_ERROR)
551532
{
552-
SILABS_LOG("Failed to open the Basic Commissioning Window");
533+
ChipLogDetail(AppServer, "Failed to open the Basic Commissioning Window");
553534
}
554535
}
555536
else
556537
{
557-
SILABS_LOG("Network is already provisioned, Ble advertisement not enabled");
538+
ChipLogDetail(AppServer, "Network is already provisioned, Ble advertisement not enabled");
558539
#if CHIP_CONFIG_ENABLE_ICD_SERVER
559540
// Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups.
560541
PlatformMgr().ScheduleWork([](intptr_t) { ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); });
@@ -577,7 +558,7 @@ void BaseApplication::CancelFunctionTimer()
577558
{
578559
if (osTimerStop(sFunctionTimer) == osError)
579560
{
580-
SILABS_LOG("app timer stop() failed");
561+
ChipLogDetail(AppServer, "app timer stop() failed");
581562
appError(APP_ERROR_STOP_TIMER_FAILED);
582563
}
583564
}
@@ -587,15 +568,15 @@ void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs)
587568
// Starts or restarts the function timer
588569
if (osTimerStart(sFunctionTimer, pdMS_TO_TICKS(aTimeoutInMs)) != osOK)
589570
{
590-
SILABS_LOG("app timer start() failed");
571+
ChipLogDetail(AppServer, "app timer start() failed");
591572
appError(APP_ERROR_START_TIMER_FAILED);
592573
}
593574
}
594575

595576
void BaseApplication::StartFactoryResetSequence()
596577
{
597578
// Initiate the factory reset sequence
598-
SILABS_LOG("Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
579+
ChipLogDetail(AppServer, "Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
599580

600581
// Start timer for FACTORY_RESET_CANCEL_WINDOW_TIMEOUT to allow user to
601582
// cancel, if required.
@@ -624,15 +605,15 @@ void BaseApplication::CancelFactoryResetSequence()
624605
if (sIsFactoryResetTriggered)
625606
{
626607
sIsFactoryResetTriggered = false;
627-
SILABS_LOG("Factory Reset has been Canceled");
608+
ChipLogDetail(AppServer, "Factory Reset has been Canceled");
628609
}
629610
}
630611

631612
void BaseApplication::StartStatusLEDTimer()
632613
{
633614
if (osTimerStart(sLightTimer, kLightTimerPeriod) != osOK)
634615
{
635-
SILABS_LOG("Light Time start failed");
616+
ChipLogDetail(AppServer, "Light Time start failed");
636617
appError(APP_ERROR_START_TIMER_FAILED);
637618
}
638619
}
@@ -645,7 +626,7 @@ void BaseApplication::StopStatusLEDTimer()
645626

646627
if (osTimerStop(sLightTimer) == osError)
647628
{
648-
SILABS_LOG("Light Time start failed");
629+
ChipLogDetail(AppServer, "Light Time start failed");
649630
appError(APP_ERROR_STOP_TIMER_FAILED);
650631
}
651632
}
@@ -762,12 +743,12 @@ void BaseApplication::PostEvent(const AppEvent * aEvent)
762743
{
763744
if (osMessageQueuePut(sAppEventQueue, aEvent, osPriorityNormal, 0) != osOK)
764745
{
765-
SILABS_LOG("Failed to post event to app task event queue");
746+
ChipLogDetail(AppServer, "Failed to post event to app task event queue");
766747
}
767748
}
768749
else
769750
{
770-
SILABS_LOG("App Event Queue is uninitialized");
751+
ChipLogDetail(AppServer, "App Event Queue is uninitialized");
771752
}
772753
}
773754

@@ -779,7 +760,7 @@ void BaseApplication::DispatchEvent(AppEvent * aEvent)
779760
}
780761
else
781762
{
782-
SILABS_LOG("Event received with no handler. Dropping event.");
763+
ChipLogDetail(AppServer, "Event received with no handler. Dropping event.");
783764
}
784765
}
785766

@@ -827,6 +808,16 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
827808
// Note: This is only called on Attach, we need to add a method to detect Thread Network Detach
828809
BaseApplication::sIsProvisioned = event->ServiceProvisioningChange.IsServiceProvisioned;
829810
}
811+
#ifdef DIC_ENABLE
812+
else if (event->Type == DeviceEventType::kInternetConnectivityChange)
813+
{
814+
VerifyOrReturn(event->InternetConnectivityChange.IPv4 == kConnectivity_Established);
815+
if (DIC_OK != dic_init(dic::control::subscribeCB))
816+
{
817+
ChipLogDetail(AppServer, "Failed to initialize DIC module");
818+
}
819+
}
820+
#endif // DIC_ENABLE
830821
}
831822

832823
void BaseApplication::OutputQrCode(bool refreshLCD)
@@ -853,7 +844,7 @@ void BaseApplication::OutputQrCode(bool refreshLCD)
853844
}
854845
else
855846
{
856-
SILABS_LOG("Getting QR code failed!");
847+
ChipLogDetail(AppServer, "Getting QR code failed!");
857848
}
858849
}
859850

0 commit comments

Comments
 (0)