Skip to content

Commit

Permalink
[esp32]: Fix random crash in M5 multi fabric test (#21759)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca authored and pull[bot] committed Feb 16, 2024
1 parent f157460 commit 0d159aa
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 42 deletions.
5 changes: 0 additions & 5 deletions examples/all-clusters-app/esp32/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "esp_log.h"
#include "esp_spi_flash.h"
#include "freertos/FreeRTOS.h"
#include <DeviceInfoProviderImpl.h>
#include <app/server/OnboardingCodesUtil.h>

#define APP_TASK_NAME "APP"
Expand All @@ -40,8 +39,6 @@ namespace {
QueueHandle_t sAppEventQueue;
TaskHandle_t sAppTaskHandle;

chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;

} // namespace

AppTask AppTask::sAppTask;
Expand Down Expand Up @@ -88,8 +85,6 @@ CHIP_ERROR AppTask::Init()
InitDeviceDisplay();
#endif

chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

return err;
}

Expand Down
14 changes: 9 additions & 5 deletions examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
#include "nvs_flash.h"
#include "platform/PlatformManager.h"
#include "shell_extension/launch.h"
#include <common/CHIPDeviceManager.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>

#include <DeviceInfoProviderImpl.h>
#include <app/server/OnboardingCodesUtil.h>
#include <app/util/af.h>
#include <binding-handler.h>
#include <common/CHIPDeviceManager.h>
#include <common/Esp32AppServer.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>

#if CONFIG_HAVE_DISPLAY
#include "DeviceWithDisplay.h"
Expand Down Expand Up @@ -91,9 +91,11 @@ AppCallbacks sCallbacks;
constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE;

#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
chip::DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider;
DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider;
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER

DeviceLayer::DeviceInfoProviderImpl sExampleDeviceInfoProvider;

} // namespace

static void InitServer(intptr_t context)
Expand Down Expand Up @@ -137,6 +139,8 @@ extern "C" void app_main()
ThreadStackMgr().InitThreadStack();
#endif

DeviceLayer::SetDeviceInfoProvider(&sExampleDeviceInfoProvider);

CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();
CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks);
DeviceCallbacksDelegate::Instance().SetAppDelegate(&sAppDeviceCallbacksDelegate);
Expand Down
4 changes: 0 additions & 4 deletions examples/light-switch-app/esp32/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "BindingHandler.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include <DeviceInfoProviderImpl.h>

#define APP_TASK_NAME "APP"
#define APP_EVENT_QUEUE_SIZE 10
Expand All @@ -38,8 +37,6 @@ namespace {

QueueHandle_t sAppEventQueue;
TaskHandle_t sAppTaskHandle;
chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;

} // namespace

AppTask AppTask::sAppTask;
Expand All @@ -65,7 +62,6 @@ CHIP_ERROR AppTask::Init()

AppButton.Init();
AppButton.SetButtonPressCallback(ButtonPressCallback);
chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

return err;
}
Expand Down
18 changes: 11 additions & 7 deletions examples/light-switch-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "nvs_flash.h"
#include "shell_extension/launch.h"

#include <DeviceInfoProviderImpl.h>
#include <app/server/OnboardingCodesUtil.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
Expand All @@ -38,15 +39,17 @@
#include <platform/ESP32/ESP32FactoryDataProvider.h>
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER

using namespace ::chip;
using namespace ::chip::Credentials;
using namespace ::chip::DeviceManager;

namespace {
#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
chip::DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider;
DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider;
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
} // namespace

using namespace ::chip;
using namespace ::chip::Credentials;
using namespace ::chip::DeviceManager;
DeviceLayer::DeviceInfoProviderImpl sExampleDeviceInfoProvider;
} // namespace

static const char * TAG = "light-switch-app";

Expand Down Expand Up @@ -80,9 +83,10 @@ extern "C" void app_main()
chip::LaunchShell();
#endif // CONFIG_ENABLE_CHIP_SHELL

CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();
DeviceLayer::SetDeviceInfoProvider(&sExampleDeviceInfoProvider);

CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks);
CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();
CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks);
if (error != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error));
Expand Down
6 changes: 0 additions & 6 deletions examples/lighting-app/esp32/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "esp_log.h"
#include "freertos/FreeRTOS.h"

#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/attributes/Accessors.h>
Expand All @@ -46,9 +45,6 @@ namespace {
constexpr EndpointId kLightEndpointId = 1;
QueueHandle_t sAppEventQueue;
TaskHandle_t sAppTaskHandle;

chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;

} // namespace

AppTask AppTask::sAppTask;
Expand Down Expand Up @@ -77,8 +73,6 @@ CHIP_ERROR AppTask::Init()

AppButton.SetButtonPressCallback(ButtonPressCallback);

chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

return err;
}

Expand Down
11 changes: 8 additions & 3 deletions examples/lighting-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "freertos/task.h"
#include "nvs_flash.h"
#include "shell_extension/launch.h"
#include <DeviceInfoProviderImpl.h>
#include <app/server/Dnssd.h>
#include <app/server/OnboardingCodesUtil.h>
#include <credentials/DeviceAttestationCredsProvider.h>
Expand All @@ -48,8 +49,10 @@ static AppDeviceCallbacks EchoCallbacks;

namespace {
#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
chip::DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider;
DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider;
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER

DeviceLayer::DeviceInfoProviderImpl sExampleDeviceInfoProvider;
} // namespace

static void InitServer(intptr_t context)
Expand Down Expand Up @@ -77,9 +80,11 @@ extern "C" void app_main()
#if CONFIG_ENABLE_CHIP_SHELL
chip::LaunchShell();
#endif
CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();

CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks);
DeviceLayer::SetDeviceInfoProvider(&sExampleDeviceInfoProvider);

CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();
CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks);
if (error != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error));
Expand Down
5 changes: 0 additions & 5 deletions examples/lock-app/esp32/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "Button.h"
#include "LEDWidget.h"
#include "esp_log.h"
#include <DeviceInfoProviderImpl.h>
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
Expand Down Expand Up @@ -57,8 +56,6 @@ QueueHandle_t sAppEventQueue;
bool sHaveBLEConnections = false;

StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)];

chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;
} // namespace

using namespace ::chip::DeviceLayer;
Expand Down Expand Up @@ -106,8 +103,6 @@ CHIP_ERROR AppTask::Init()

sLockLED.Set(!BoltLockMgr().IsUnlocked());

chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

chip::DeviceLayer::SystemLayer().ScheduleWork(UpdateClusterState, nullptr);

ConfigurationMgr().LogDeviceConfig();
Expand Down
18 changes: 11 additions & 7 deletions examples/lock-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "freertos/task.h"
#include "nvs_flash.h"
#include "shell_extension/launch.h"
#include <DeviceInfoProviderImpl.h>
#include <common/CHIPDeviceManager.h>
#include <common/Esp32AppServer.h>
#include <credentials/DeviceAttestationCredsProvider.h>
Expand All @@ -48,15 +49,17 @@
#include <platform/ESP32/ESP32FactoryDataProvider.h>
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER

using namespace ::chip;
using namespace ::chip::DeviceManager;
using namespace ::chip::Credentials;

namespace {
#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
chip::DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider;
DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider;
#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER
} // namespace

using namespace ::chip;
using namespace ::chip::DeviceManager;
using namespace ::chip::Credentials;
DeviceLayer::DeviceInfoProviderImpl sExampleDeviceInfoProvider;
} // namespace

static const char * TAG = "lock-app";

Expand Down Expand Up @@ -96,9 +99,10 @@ extern "C" void app_main()
chip::LaunchShell();
#endif

CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();
DeviceLayer::SetDeviceInfoProvider(&sExampleDeviceInfoProvider);

CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks);
CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance();
CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks);
if (error != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error));
Expand Down

0 comments on commit 0d159aa

Please sign in to comment.