Skip to content

Commit

Permalink
[Infineon]Update button init sequence before wifi commissioning (#30043)
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenCY authored and pull[bot] committed Aug 8, 2024
1 parent a3a3fa8 commit 3923667
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
32 changes: 16 additions & 16 deletions examples/lock-app/infineon/psoc6/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,6 @@ void AppTask::lockMgr_Init()
appError(err);
}

// Initialise WSTK buttons PB0 and PB1 (including debounce).
ButtonHandler::Init();

// Create FreeRTOS sw timer for Function Selection.
sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel
1, // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
TimerEventHandler // timer callback handler
);
if (sFunctionTimer == NULL)
{
P6_LOG("funct timer create failed");
appError(APP_ERROR_CREATE_TIMER_FAILED);
}

LockMgr().SetCallbacks(ActionInitiated, ActionCompleted);

// Initialize LEDs
Expand Down Expand Up @@ -301,6 +285,22 @@ void AppTask::Init()
appError(CHIP_ERROR_WELL_UNINITIALIZED);
}
#endif
// Initialise WSTK buttons PB0 and PB1 (including debounce).
ButtonHandler::Init();

// Create FreeRTOS sw timer for Function Selection.
sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel
1, // == default timer period (mS)
false, // no timer reload (==one-shot)
(void *) this, // init timer id = app task obj context
TimerEventHandler // timer callback handler
);
if (sFunctionTimer == NULL)
{
P6_LOG("funct timer create failed");
appError(APP_ERROR_CREATE_TIMER_FAILED);
}

// Register the callback to init the MDNS server when connectivity is available
PlatformMgr().AddEventHandler(
[](const ChipDeviceEvent * event, intptr_t arg) {
Expand Down
15 changes: 10 additions & 5 deletions src/platform/Infineon/PSOC6/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,13 @@ void ConnectivityManagerImpl::DriveAPState()
// Compute the amount of idle time before the AP should be deactivated and
// arm a timer to fire at that time.
System::Clock::Timeout apTimeout = (mLastAPDemandTime + mWiFiAPIdleTimeout) - now;
err = DeviceLayer::SystemLayer().StartTimer(apTimeout, DriveAPState, nullptr);
SuccessOrExit(err);
ChipLogProgress(DeviceLayer, "Next WiFi AP timeout in %" PRIu32 " ms",
System::Clock::Milliseconds32(apTimeout).count());
SystemLayer().ScheduleLambda([apTimeout, this] {
CHIP_ERROR ret = CHIP_NO_ERROR;
ret = DeviceLayer::SystemLayer().StartTimer(apTimeout, DriveAPState, this);
VerifyOrReturn(ret == CHIP_NO_ERROR, ChipLogError(DeviceLayer, "StartTimer failed %s: ", chip::ErrorStr(ret)));
});
}
else
{
Expand Down Expand Up @@ -605,9 +608,11 @@ void ConnectivityManagerImpl::DriveStationState()
System::Clock::Timeout timeToNextConnect = (mLastStationConnectFailTime + mWiFiStationReconnectInterval) - now;
ChipLogProgress(DeviceLayer, "Next WiFi station reconnect in %" PRIu32 " ms ",
System::Clock::Milliseconds32(timeToNextConnect).count());

err = DeviceLayer::SystemLayer().StartTimer(timeToNextConnect, DriveStationState, NULL);
SuccessOrExit(err);
SystemLayer().ScheduleLambda([timeToNextConnect, this] {
CHIP_ERROR ret = CHIP_NO_ERROR;
ret = DeviceLayer::SystemLayer().StartTimer(timeToNextConnect, DriveStationState, this);
VerifyOrReturn(ret == CHIP_NO_ERROR, ChipLogError(DeviceLayer, "StartTimer failed %s: ", chip::ErrorStr(ret)));
});
}
}
}
Expand Down

0 comments on commit 3923667

Please sign in to comment.