Skip to content

Commit

Permalink
ESP32: move Wi-Fi initializition out of Matter stack Initializition (#…
Browse files Browse the repository at this point in the history
…25455)

* ESP32: move Wi-Fi initializing out of Matter stack Initializing

* review changes
  • Loading branch information
wqx6 authored and pull[bot] committed Jan 4, 2024
1 parent e283862 commit 818e1f0
Show file tree
Hide file tree
Showing 23 changed files with 252 additions and 352 deletions.
4 changes: 2 additions & 2 deletions docs/guides/esp32/setup_idf_chip.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ step.
```
- For ESP32H2, please checkout tag
[v5.0-beta1](https://github.com/espressif/esp-idf/tree/v5.0-beta1),
currently only lighting-app is supported on H2
[v5.0](https://github.com/espressif/esp-idf/tree/v5.0), currently only
lighting-app is supported on H2
```
$ cd esp-idf
Expand Down
111 changes: 0 additions & 111 deletions examples/all-clusters-app/esp32/main/OpenThreadLaunch.cpp

This file was deleted.

20 changes: 0 additions & 20 deletions examples/all-clusters-app/esp32/main/include/OpenThreadLaunch.h

This file was deleted.

31 changes: 26 additions & 5 deletions examples/all-clusters-app/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "DeviceCallbacks.h"
#include "Globals.h"
#include "LEDWidget.h"
#include "OpenThreadLaunch.h"
#include "QRCodeScreen.h"
#include "ShellCommands.h"
#include "WiFiWidget.h"
Expand All @@ -41,6 +40,7 @@
#include <common/Esp32AppServer.h>
#include <credentials/DeviceAttestationCredsProvider.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <platform/ESP32/ESP32Utils.h>

#if CONFIG_HAVE_DISPLAY
#include "DeviceWithDisplay.h"
Expand Down Expand Up @@ -136,6 +136,12 @@ extern "C" void app_main()
ESP_LOGE(TAG, "nvs_flash_init() failed: %s", esp_err_to_name(err));
return;
}
err = esp_event_loop_create_default();
if (err != ESP_OK)
{
ESP_LOGE(TAG, "esp_event_loop_create_default() failed: %s", esp_err_to_name(err));
return;
}
#if CONFIG_ENABLE_PW_RPC
chip::rpc::Init();
#endif
Expand All @@ -150,10 +156,13 @@ extern "C" void app_main()
CASECommands::GetInstance().Register();
#endif // CONFIG_ENABLE_CHIP_SHELL

#if CONFIG_OPENTHREAD_ENABLED
LaunchOpenThread();
ThreadStackMgr().InitThreadStack();
#endif
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
if (DeviceLayer::Internal::ESP32Utils::InitWiFiStack() != CHIP_NO_ERROR)
{
ESP_LOGE(TAG, "Failed to initialize the Wi-Fi stack");
return;
}
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI

DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider);

Expand Down Expand Up @@ -182,6 +191,18 @@ extern "C" void app_main()
{
ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format());
}
#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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "Globals.h"
#include "LEDWidget.h"
#include "WiFiWidget.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app/CommandHandler.h>
#include <app/clusters/identify-server/identify-server.h>
Expand Down Expand Up @@ -154,7 +155,7 @@ void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpoi
#if CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM
void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
{
using namespace Clusters::ColorControl::Attributes;
using namespace chip::app::Clusters::ColorControl::Attributes;

VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id,
ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%" PRIx32 "'", attributeId));
Expand Down
111 changes: 0 additions & 111 deletions examples/all-clusters-minimal-app/esp32/main/OpenThreadLaunch.cpp

This file was deleted.

This file was deleted.

Loading

0 comments on commit 818e1f0

Please sign in to comment.