Skip to content

Commit fd47e38

Browse files
shubhamdppull[bot]
authored andcommitted
Fix the boot loop crash on M5Stack (#24607)
* Fix the boot loop crash on M5Stack This is the regression from #24547, which is accessing the attributes even before Server is ready. Moved the lock initialization after service is initialized * Fix the typo for chip error format
1 parent 4f2fc8d commit fd47e38

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

examples/all-clusters-app/esp32/main/AppTask.cpp

+9-5
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ void AppTask::ActionCompleted(BoltLockManager::Action_t aAction)
161161
}
162162
}
163163

164+
CHIP_ERROR AppTask::LockInit()
165+
{
166+
ReturnErrorOnFailure(BoltLockMgr().InitLockState());
167+
BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
168+
return CHIP_NO_ERROR;
169+
}
170+
164171
CHIP_ERROR AppTask::Init()
165172
{
166173
/* Print chip information */
@@ -179,10 +186,7 @@ CHIP_ERROR AppTask::Init()
179186
(void *) this, // init timer id = app task obj context
180187
TimerEventHandler // timer callback handler
181188
);
182-
183-
CHIP_ERROR err = BoltLockMgr().InitLockState();
184-
185-
BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted);
189+
VerifyOrReturnError(sFunctionTimer != NULL, CHIP_ERROR_NO_MEMORY, ESP_LOGE(TAG, "Failed to create function selection timer"));
186190

187191
statusLED1.Init(STATUS_LED_GPIO_NUM);
188192
// Our second LED doesn't map to any physical LEDs so far, just to virtual
@@ -199,7 +203,7 @@ CHIP_ERROR AppTask::Init()
199203
InitDeviceDisplay();
200204
#endif
201205

202-
return err;
206+
return CHIP_NO_ERROR;
203207
}
204208

205209
void AppTask::AppTaskMain(void * pvParameter)

examples/all-clusters-app/esp32/main/include/AppTask.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class AppTask
3939
void PostEvent(const AppEvent * event);
4040
void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction);
4141
static void ButtonPressedAction(AppEvent * aEvent);
42+
CHIP_ERROR LockInit();
4243

4344
private:
4445
CHIP_ERROR Init();

examples/all-clusters-app/esp32/main/main.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ static void InitServer(intptr_t context)
115115
emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false);
116116

117117
InitBindingHandlers();
118+
119+
CHIP_ERROR err = GetAppTask().LockInit();
120+
if (err != CHIP_NO_ERROR)
121+
{
122+
ESP_LOGE(TAG, "Failed to initialize app task lock, err:%" CHIP_ERROR_FORMAT, err.Format());
123+
}
124+
118125
#if CONFIG_DEVICE_TYPE_M5STACK
119126
SetupPretendDevices();
120127
#endif

examples/platform/esp32/lock/BoltLockManager.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,6 @@ CHIP_ERROR BoltLockManager::InitLockState()
764764
// Initial lock state
765765
chip::app::DataModel::Nullable<chip::app::Clusters::DoorLock::DlLockState> state;
766766
chip::EndpointId endpointId{ 1 };
767-
chip::DeviceLayer::PlatformMgr().LockChipStack();
768767
chip::app::Clusters::DoorLock::Attributes::LockState::Get(endpointId, state);
769768

770769
uint8_t numberOfCredentialsPerUser = 0;
@@ -816,8 +815,6 @@ CHIP_ERROR BoltLockManager::InitLockState()
816815
numberOfHolidaySchedules = 10;
817816
}
818817

819-
chip::DeviceLayer::PlatformMgr().UnlockChipStack();
820-
821818
CHIP_ERROR err = BoltLockMgr().Init(state,
822819
ParamBuilder()
823820
.SetNumberOfUsers(numberOfUsers)

0 commit comments

Comments
 (0)