Skip to content

Commit fb56787

Browse files
committed
Replace SILABS_LOG with ChipLogging
1 parent b2687c8 commit fb56787

File tree

1 file changed

+30
-40
lines changed

1 file changed

+30
-40
lines changed

examples/platform/silabs/BaseApplication.cpp

+30-40
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,6 @@ LEDWidget * BaseApplication::sAppActionLed = nullptr;
165165
BaseApplicationDelegate BaseApplication::sAppDelegate = BaseApplicationDelegate();
166166
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
167167

168-
#ifdef DIC_ENABLE
169-
namespace {
170-
void AppSpecificConnectivityEventCallback(const ChipDeviceEvent * event, intptr_t arg)
171-
{
172-
SILABS_LOG("AppSpecificConnectivityEventCallback: call back for IPV4");
173-
if ((event->Type == DeviceEventType::kInternetConnectivityChange) &&
174-
(event->InternetConnectivityChange.IPv4 == kConnectivity_Established))
175-
{
176-
SILABS_LOG("Got IPv4 Address! Starting DIC module\n");
177-
if (DIC_OK != dic_init(dic::control::subscribeCB))
178-
SILABS_LOG("Failed to initialize DIC module\n");
179-
}
180-
}
181-
} // namespace
182-
#endif // DIC_ENABLE
183-
184168
#if CHIP_CONFIG_ENABLE_ICD_SERVER && SLI_SI917
185169
void BaseApplicationDelegate::OnCommissioningSessionStarted()
186170
{
@@ -212,15 +196,15 @@ CHIP_ERROR BaseApplication::StartAppTask(osThreadFunc_t taskFunction)
212196
sAppEventQueue = osMessageQueueNew(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), &appEventQueueAttr);
213197
if (sAppEventQueue == NULL)
214198
{
215-
SILABS_LOG("Failed to allocate app event queue");
199+
ChipLogDetail(AppServer, "Failed to allocate app event queue");
216200
appError(APP_ERROR_EVENT_QUEUE_FAILED);
217201
}
218202

219203
// Start App task.
220204
sAppTaskHandle = osThreadNew(taskFunction, &sAppEventQueue, &appTaskAttr);
221205
if (sAppTaskHandle == nullptr)
222206
{
223-
SILABS_LOG("Failed to create app task");
207+
ChipLogDetail(AppServer, "Failed to create app task");
224208
appError(APP_ERROR_CREATE_TASK_FAILED);
225209
}
226210
return CHIP_NO_ERROR;
@@ -234,12 +218,12 @@ CHIP_ERROR BaseApplication::Init()
234218
/*
235219
* Wait for the WiFi to be initialized
236220
*/
237-
SILABS_LOG("APP: Wait WiFi Init");
221+
ChipLogDetail(AppServer, "APP: Wait WiFi Init");
238222
while (!wfx_hw_ready())
239223
{
240224
vTaskDelay(pdMS_TO_TICKS(10));
241225
}
242-
SILABS_LOG("APP: Done WiFi Init");
226+
ChipLogDetail(AppServer, "APP: Done WiFi Init");
243227
/* We will init server when we get IP */
244228

245229
chip::DeviceLayer::PlatformMgr().LockChipStack();
@@ -256,7 +240,7 @@ CHIP_ERROR BaseApplication::Init()
256240
);
257241
if (sFunctionTimer == NULL)
258242
{
259-
SILABS_LOG("funct timer create failed");
243+
ChipLogDetail(AppServer, "funct timer create failed");
260244
appError(APP_ERROR_CREATE_TIMER_FAILED);
261245
}
262246

@@ -268,16 +252,12 @@ CHIP_ERROR BaseApplication::Init()
268252
);
269253
if (sLightTimer == NULL)
270254
{
271-
SILABS_LOG("Light Timer create failed");
255+
ChipLogDetail(AppServer, "Light Timer create failed");
272256
appError(APP_ERROR_CREATE_TIMER_FAILED);
273257
}
274258

275-
SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
276-
SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
277-
278-
#ifdef DIC_ENABLE
279-
chip::DeviceLayer::PlatformMgr().AddEventHandler(AppSpecificConnectivityEventCallback, reinterpret_cast<intptr_t>(nullptr));
280-
#endif // DIC_ENABLE
259+
ChipLogDetail(AppServer, "Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING);
260+
ChipLogDetail(AppServer, "Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION);
281261

282262
ConfigurationMgr().LogDeviceConfig();
283263

@@ -508,12 +488,12 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent)
508488
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
509489
if (err != CHIP_NO_ERROR)
510490
{
511-
SILABS_LOG("Failed to open the Basic Commissioning Window");
491+
ChipLogDetail(AppServer, "Failed to open the Basic Commissioning Window");
512492
}
513493
}
514494
else
515495
{
516-
SILABS_LOG("Network is already provisioned, Ble advertisement not enabled");
496+
ChipLogDetail(AppServer, "Network is already provisioned, Ble advertisement not enabled");
517497
#if CHIP_CONFIG_ENABLE_ICD_SERVER
518498
// Temporarily claim network activity, until we implement a "user trigger" reason for ICD wakeups.
519499
PlatformMgr().ScheduleWork([](intptr_t) { ICDNotifier::GetInstance().NotifyNetworkActivityNotification(); });
@@ -536,7 +516,7 @@ void BaseApplication::CancelFunctionTimer()
536516
{
537517
if (osTimerStop(sFunctionTimer) == osError)
538518
{
539-
SILABS_LOG("app timer stop() failed");
519+
ChipLogDetail(AppServer, "app timer stop() failed");
540520
appError(APP_ERROR_STOP_TIMER_FAILED);
541521
}
542522
}
@@ -546,15 +526,15 @@ void BaseApplication::StartFunctionTimer(uint32_t aTimeoutInMs)
546526
// Starts or restarts the function timer
547527
if (osTimerStart(sFunctionTimer, pdMS_TO_TICKS(aTimeoutInMs)) != osOK)
548528
{
549-
SILABS_LOG("app timer start() failed");
529+
ChipLogDetail(AppServer, "app timer start() failed");
550530
appError(APP_ERROR_START_TIMER_FAILED);
551531
}
552532
}
553533

554534
void BaseApplication::StartFactoryResetSequence()
555535
{
556536
// Initiate the factory reset sequence
557-
SILABS_LOG("Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
537+
ChipLogDetail(AppServer, "Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
558538

559539
// Start timer for FACTORY_RESET_CANCEL_WINDOW_TIMEOUT to allow user to
560540
// cancel, if required.
@@ -583,15 +563,15 @@ void BaseApplication::CancelFactoryResetSequence()
583563
if (sIsFactoryResetTriggered)
584564
{
585565
sIsFactoryResetTriggered = false;
586-
SILABS_LOG("Factory Reset has been Canceled");
566+
ChipLogDetail(AppServer, "Factory Reset has been Canceled");
587567
}
588568
}
589569

590570
void BaseApplication::StartStatusLEDTimer()
591571
{
592572
if (osTimerStart(sLightTimer, kLightTimerPeriod) != osOK)
593573
{
594-
SILABS_LOG("Light Time start failed");
574+
ChipLogDetail(AppServer, "Light Time start failed");
595575
appError(APP_ERROR_START_TIMER_FAILED);
596576
}
597577
}
@@ -604,7 +584,7 @@ void BaseApplication::StopStatusLEDTimer()
604584

605585
if (osTimerStop(sLightTimer) == osError)
606586
{
607-
SILABS_LOG("Light Time start failed");
587+
ChipLogDetail(AppServer, "Light Time start failed");
608588
appError(APP_ERROR_STOP_TIMER_FAILED);
609589
}
610590
}
@@ -721,12 +701,12 @@ void BaseApplication::PostEvent(const AppEvent * aEvent)
721701
{
722702
if (osMessageQueuePut(sAppEventQueue, aEvent, osPriorityNormal, 0) != osOK)
723703
{
724-
SILABS_LOG("Failed to post event to app task event queue");
704+
ChipLogDetail(AppServer, "Failed to post event to app task event queue");
725705
}
726706
}
727707
else
728708
{
729-
SILABS_LOG("App Event Queue is uninitialized");
709+
ChipLogDetail(AppServer, "App Event Queue is uninitialized");
730710
}
731711
}
732712

@@ -738,7 +718,7 @@ void BaseApplication::DispatchEvent(AppEvent * aEvent)
738718
}
739719
else
740720
{
741-
SILABS_LOG("Event received with no handler. Dropping event.");
721+
ChipLogDetail(AppServer, "Event received with no handler. Dropping event.");
742722
}
743723
}
744724

@@ -761,6 +741,16 @@ void BaseApplication::OnPlatformEvent(const ChipDeviceEvent * event, intptr_t)
761741
{
762742
BaseApplication::sIsProvisioned = event->ServiceProvisioningChange.IsServiceProvisioned;
763743
}
744+
#ifdef DIC_ENABLE
745+
else if (event->Type == DeviceEventType::kInternetConnectivityChange)
746+
{
747+
VerifyOrReturn(event->InternetConnectivityChange.IPv4 == kConnectivity_Established);
748+
if (DIC_OK != dic_init(dic::control::subscribeCB))
749+
{
750+
ChipLogDetail(AppServer, "Failed to initialize DIC module");
751+
}
752+
}
753+
#endif // DIC_ENABLE
764754
}
765755

766756
void BaseApplication::OutputQrCode(bool refreshLCD)
@@ -787,7 +777,7 @@ void BaseApplication::OutputQrCode(bool refreshLCD)
787777
}
788778
else
789779
{
790-
SILABS_LOG("Getting QR code failed!");
780+
ChipLogDetail(AppServer, "Getting QR code failed!");
791781
}
792782
}
793783

0 commit comments

Comments
 (0)