Skip to content

Commit

Permalink
fix crash issue which caused by data model init after thread stack in…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerry-ESP authored Jan 14, 2025
1 parent 5bd63d5 commit a5bf60d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
3 changes: 2 additions & 1 deletion examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ extern "C" void app_main()
{
ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format());
}
ESPOpenThreadInit();

chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

ESPOpenThreadInit();
}

bool lowPowerClusterSleep()
Expand Down
3 changes: 2 additions & 1 deletion examples/all-clusters-minimal-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ extern "C" void app_main()
ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format());
}

ESPOpenThreadInit();
chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

ESPOpenThreadInit();
}

bool lowPowerClusterSleep()
Expand Down
3 changes: 2 additions & 1 deletion examples/energy-management-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ extern "C" void app_main()
#endif

SetDeviceAttestationCredentialsProvider(get_dac_provider());
ESPOpenThreadInit();

chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

ESPOpenThreadInit();
}
16 changes: 3 additions & 13 deletions examples/light-switch-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "DeviceCallbacks.h"
#include <common/CHIPDeviceManager.h>
#include <common/Esp32AppServer.h>
#include <common/Esp32ThreadInit.h>

#include "AppTask.h"
#include "BindingHandler.h"
Expand Down Expand Up @@ -135,21 +136,10 @@ extern "C" void app_main()
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER

#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
if (DeviceLayer::ThreadStackMgr().InitThreadStack() != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to initialize Thread stack");
return;
}
if (DeviceLayer::ThreadStackMgr().StartThreadTask() != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to launch Thread task");
return;
}
#endif

chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

ESPOpenThreadInit();

error = GetAppTask().StartAppTask();
if (error != CHIP_NO_ERROR)
{
Expand Down
3 changes: 2 additions & 1 deletion examples/lighting-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,11 @@ extern "C" void app_main()
#endif

SetDeviceAttestationCredentialsProvider(get_dac_provider());
ESPOpenThreadInit();

chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

ESPOpenThreadInit();

error = GetAppTask().StartAppTask();
if (error != CHIP_NO_ERROR)
{
Expand Down
3 changes: 2 additions & 1 deletion examples/lit-icd-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ extern "C" void app_main()
#else
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
ESPOpenThreadInit();
static UatButton sButton;
sButton.Init(UAT_GPIO, ESP_EXT1_WAKEUP_ANY_LOW);
sButton.SetUatButtonPressCallback(UatButtonHandler);

chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

ESPOpenThreadInit();
}
3 changes: 2 additions & 1 deletion examples/thread-br-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,10 @@ extern "C" void app_main()
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
esp_openthread_set_backbone_netif(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"));
ESPOpenThreadInit();

chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast<intptr_t>(nullptr));

ESPOpenThreadInit();
}

extern "C" void otSysProcessDrivers(otInstance * aInstance)
Expand Down

0 comments on commit a5bf60d

Please sign in to comment.