example: Add ESP32-C3 support for light_wifi_prov example

This commit is contained in:
WanqQixiang
2024-07-30 12:05:18 +08:00
parent e900022519
commit d9a3dc3021
5 changed files with 185 additions and 3 deletions
@@ -60,6 +60,17 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s
return 0;
}
CHIP_ERROR PlatformManagerImpl::DisableESPEventDispatch()
{
esp_err_t err = esp_event_handler_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent);
if (err != ESP_OK)
{
return Internal::ESP32Utils::MapError(err);
}
err = esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent);
return Internal::ESP32Utils::MapError(err);
}
CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
{
// Arrange for CHIP-encapsulated ESP32 errors to be translated to text
@@ -1 +0,0 @@
../../../../../connectedhomeip/connectedhomeip/src/platform/ESP32/PlatformManagerImpl.h
@@ -0,0 +1,97 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2018 Nest Labs, Inc.
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* Provides an implementation of the PlatformManager object
* for the ESP32 platform.
*/
#pragma once
#include <platform/internal/GenericPlatformManagerImpl_FreeRTOS.h>
#include <system/SystemClock.h>
namespace chip {
namespace DeviceLayer {
/**
* Concrete implementation of the PlatformManager singleton object for the ESP32 platform.
*/
class PlatformManagerImpl final : public PlatformManager, public Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>
{
// Allow the PlatformManager interface class to delegate method calls to
// the implementation methods provided by this class.
friend PlatformManager;
// Allow the generic implementation base class to call helper methods on
// this class.
#ifndef DOXYGEN_SHOULD_SKIP_THIS
friend Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>;
#endif
public:
// ===== Platform-specific members that may be accessed directly by the application.
CHIP_ERROR InitLwIPCoreLock(void);
static void HandleESPSystemEvent(void * arg, esp_event_base_t eventBase, int32_t eventId, void * eventData);
System::Clock::Timestamp GetStartTime() { return mStartTime; }
static CHIP_ERROR DisableESPEventDispatch();
private:
// ===== Methods that implement the PlatformManager abstract interface.
CHIP_ERROR _InitChipStack(void);
void _Shutdown();
// ===== Members for internal use by the following friends.
friend PlatformManager & PlatformMgr(void);
friend PlatformManagerImpl & PlatformMgrImpl(void);
System::Clock::Timestamp mStartTime = System::Clock::kZero;
static PlatformManagerImpl sInstance;
};
/**
* Returns the public interface of the PlatformManager singleton object.
*
* Chip applications should use this to access features of the PlatformManager object
* that are common to all platforms.
*/
inline PlatformManager & PlatformMgr(void)
{
return PlatformManagerImpl::sInstance;
}
/**
* Returns the platform-specific implementation of the PlatformManager singleton object.
*
* Chip applications can use this to gain access to features of the PlatformManager
* that are specific to the ESP32 platform.
*/
inline PlatformManagerImpl & PlatformMgrImpl(void)
{
return PlatformManagerImpl::sInstance;
}
} // namespace DeviceLayer
} // namespace chip
@@ -26,6 +26,8 @@
#include <nvs_flash.h>
#include <esp_timer.h>
#include "app_wifi.h"
#include <platform/PlatformManager.h>
#include <platform/ESP32_custom/PlatformManagerImpl.h>
ESP_EVENT_DEFINE_BASE(APP_WIFI_EVENT);
@@ -159,6 +161,7 @@ static void event_handler(void* arg, esp_event_base_t event_base,
switch (event_id) {
case PROTOCOMM_SECURITY_SESSION_SETUP_OK:
ESP_LOGI(TAG, "Secured session established!");
chip::DeviceLayer::PlatformManagerImpl::DisableESPEventDispatch();
break;
case PROTOCOMM_SECURITY_SESSION_INVALID_SECURITY_PARAMS:
/* fall-through */
+3 -2
View File
@@ -5,5 +5,6 @@ nvs, data, nvs, 0x10000, 0xC000,
nvs_keys, data, nvs_keys,, 0x1000, encrypted
otadata, data, ota, , 0x2000
phy_init, data, phy, , 0x1000,
ota_0, app, ota_0, 0x20000, 0x250000,
fctry, data, nvs, 0x3E0000, 0x6000
ota_0, app, ota_0, 0x20000, 1900K,
ota_1, app, ota_1, , 1900K,
fctry, data, nvs, , 0x6000
1 # Name, Type, SubType, Offset, Size, Flags
5 nvs_keys, data, nvs_keys,, 0x1000, encrypted
6 otadata, data, ota, , 0x2000
7 phy_init, data, phy, , 0x1000,
8 ota_0, app, ota_0, 0x20000, 0x250000, ota_0, app, ota_0, 0x20000, 1900K,
9 fctry, data, nvs, 0x3E0000, 0x6000 ota_1, app, ota_1, , 1900K,
10 fctry, data, nvs, , 0x6000
@@ -0,0 +1,71 @@
#enable BT
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
# Enable Extended advertisement of NIMBLE
CONFIG_BT_NIMBLE_EXT_ADV=y
CONFIG_BT_NIMBLE_MAX_EXT_ADV_INSTANCES=2
#disable BT connection reattempt
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n
#enable lwip ipv6 autoconfig
CONFIG_LWIP_IPV6_AUTOCONFIG=y
# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_OFFSET=0xC000
# Enable chip shell
CONFIG_ENABLE_CHIP_SHELL=y
#enable lwIP route hooks
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
# Button
CONFIG_BUTTON_PERIOD_TIME_MS=20
CONFIG_BUTTON_LONG_PRESS_TIME_MS=5000
# Enable HKDF in mbedtls
CONFIG_MBEDTLS_HKDF_C=y
# ESP32-S3-DevKitC-1 Settings
# Buttons
CONFIG_BSP_BUTTONS_NUM=1
CONFIG_BSP_BUTTON_1_TYPE_GPIO=y
CONFIG_BSP_BUTTON_1_GPIO=0
CONFIG_BSP_BUTTON_1_LEVEL=0
# mbedtls
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN=y
# For additional security on reset to factory
CONFIG_ESP_RMAKER_USER_ID_CHECK=y
# Fix for Timer Overflows
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3120
# External Platform
CONFIG_CHIP_ENABLE_EXTERNAL_PLATFORM=y
CONFIG_CHIP_EXTERNAL_PLATFORM_DIR="../../../../examples/common/secondary_ble_adv/platform/ESP32_custom"
CONFIG_CHIP_EXTERNAL_PLATFORM_INCLUDE_DIR="../../../../examples/common/secondary_ble_adv"
# Memory Optimization
CONFIG_ESP_WIFI_IRAM_OPT=n
CONFIG_ESP_WIFI_RX_IRAM_OPT=n
CONFIG_ESP_MATTER_MAX_DEVICE_TYPE_COUNT=2
CONFIG_ESP_MATTER_BINDING_TABLE_SIZE=1
CONFIG_EVENT_LOGGING_CRIT_BUFFER_SIZE=512
CONFIG_EVENT_LOGGING_INFO_BUFFER_SIZE=256
CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE=256
CONFIG_MAX_EXCHANGE_CONTEXTS=5
CONFIG_MAX_BINDINGS=2
CONFIG_MAX_PEER_NODES=8
CONFIG_DISABLE_IPV4=y
CONFIG_NUM_TCP_ENDPOINTS=1
CONFIG_NUM_UDP_ENDPOINTS=6