Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESP32] Changes to support esp-idf v5.0 in lighting-app #24589

Merged
merged 6 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/esp32/components/chip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ endif()

include(${CMAKE_CURRENT_LIST_DIR}/ota-image.cmake)

set(CHIP_REQURIE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash)
set(CHIP_REQUIRE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash spi_flash)

if((NOT "${IDF_TARGET}" STREQUAL "esp32h2") AND (NOT "${IDF_TARGET}" STREQUAL "esp32c2"))
list(APPEND CHIP_REQURIE_COMPONENTS mdns)
list(APPEND CHIP_REQUIRE_COMPONENTS mdns)
endif()

if (NOT CMAKE_BUILD_EARLY_EXPANSION)
Expand All @@ -49,7 +49,7 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION)
endif()

idf_component_register(SRCS chip.c chip.cpp
PRIV_REQUIRES ${CHIP_REQURIE_COMPONENTS})
PRIV_REQUIRES ${CHIP_REQUIRE_COMPONENTS})

# Prepare initial args file (lacking compile flags)
# This will be saved as args.gn.in
Expand Down
2 changes: 1 addition & 1 deletion config/esp32/components/chip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ menu "CHIP Device Layer"

config ENABLE_ESP32_LOCATIONCAPABILITY
depends on ENABLE_ESP32_FACTORY_DATA_PROVIDER
bool "Enable ESP32 Device LocationCapability "
bool "Enable ESP32 Device LocationCapability"
default n
help
Enable ESP32 Device LocationCapability
Expand Down
6 changes: 6 additions & 0 deletions config/esp32/components/chip/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## IDF Component Manager Manifest File
dependencies:
espressif/mdns:
version: "^1.0.3"
rules:
- if: "idf_version >=5.0"
1 change: 0 additions & 1 deletion examples/lighting-app/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cm
set(EXTRA_COMPONENT_DIRS
"${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components"
"${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/QRCode"
"${IDF_PATH}/examples/common_components/led_strip"
)

project(chip-lighting-app)
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server"
)

set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash)
set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash spi_flash)

if (CONFIG_ENABLE_PW_RPC)
# Append additional directories for RPC build
Expand Down
14 changes: 8 additions & 6 deletions examples/lighting-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ using namespace chip::app::Clusters;
void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId,
uint8_t type, uint16_t size, uint8_t * value)
{
ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: '0x%02x', Attribute ID: '0x%04x'", clusterId,
endpointId, attributeId);
ESP_LOGI(TAG,
"PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'",
clusterId, endpointId, attributeId);

switch (clusterId)
{
Expand All @@ -67,7 +68,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus
#endif

default:
ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId);
ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId);
break;
}

Expand All @@ -76,7 +77,8 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus

void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
{
VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId));
VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id,
ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId));
VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId));

AppLED.Set(*value);
Expand All @@ -88,7 +90,7 @@ void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointI
void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value)
{
VerifyOrExit(attributeId == LevelControl::Attributes::CurrentLevel::Id,
ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId));
ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId));
VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId));

AppLED.SetBrightness(*value);
Expand All @@ -105,7 +107,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi

VerifyOrExit(attributeId == ColorControl::Attributes::CurrentHue::Id ||
attributeId == ColorControl::Attributes::CurrentSaturation::Id,
ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04x", attributeId));
ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId));
VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId));

if (attributeId == ColorControl::Attributes::CurrentHue::Id)
Expand Down
6 changes: 5 additions & 1 deletion examples/lighting-app/esp32/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ menu "Demo"
default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32
default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3
default DEVICE_TYPE_ESP32_S3_DEVKITM if IDF_TARGET_ESP32S3
default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2
help
Specifies the type of ESP32 device.

Expand All @@ -46,6 +47,9 @@ menu "Demo"
config DEVICE_TYPE_ESP32H2_DEVKITC
bool "ESP32H2-DevKitC"
depends on IDF_TARGET_ESP32H2
config DEVICE_TYPE_ESP32_C2_DEVKITM
bool "ESP32C2-DevKitM"
depends on IDF_TARGET_ESP32C2
endchoice

choice LED_TYPE
Expand Down Expand Up @@ -76,7 +80,7 @@ menu "Demo"
int "LED GPIO number"
range 0 48
default 26 if DEVICE_TYPE_ESP32_WROVER_KIT
default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC
default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC || DEVICE_TYPE_ESP32_C2_DEVKITM
default 48 if DEVICE_TYPE_ESP32_S3_DEVKITM
default 5
help
Expand Down
16 changes: 1 addition & 15 deletions examples/lighting-app/esp32/main/LEDWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,14 @@ void LEDWidget::Init(void)
mBrightness = UINT8_MAX;

#if CONFIG_LED_TYPE_RMT
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
led_strip_config_t strip_config = {
.strip_gpio_num = CONFIG_LED_GPIO,
.max_leds = 1,
};

led_strip_new_rmt_device(&strip_config, &mStrip);
#else
rmt_config_t config = RMT_DEFAULT_CONFIG_TX((gpio_num_t) CONFIG_LED_GPIO, (rmt_channel_t) CONFIG_LED_RMT_CHANNEL);
led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(1, (led_strip_dev_t) config.channel);

config.clk_div = 2;
rmt_config(&config);
rmt_driver_install(config.channel, 0, 0);

mStrip = led_strip_new_rmt_ws2812(&strip_config);
#endif
mStrip = led_strip_new_rmt_ws2812(&strip_config);
mHue = 0;
mSaturation = 0;
#else
Expand Down Expand Up @@ -131,13 +122,8 @@ void LEDWidget::DoSet(void)
{
HsvColor_t hsv = { mHue, mSaturation, brightness };
RgbColor_t rgb = HsvToRgb(hsv);
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
led_strip_set_pixel(mStrip, 0, rgb.r, rgb.g, rgb.b);
led_strip_refresh(mStrip);
#else
mStrip->set_pixel(mStrip, 0, rgb.r, rgb.g, rgb.b);
mStrip->refresh(mStrip, 100);
#endif
}
#else
ESP_LOGI(TAG, "DoSet to GPIO number %d", mGPIONum);
Expand Down
2 changes: 2 additions & 0 deletions examples/lighting-app/esp32/main/idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies:
espressif/led_strip: "^1.0.0-alpha"
4 changes: 0 additions & 4 deletions examples/lighting-app/esp32/main/include/LEDWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ class LEDWidget
#if CONFIG_LED_TYPE_RMT
uint8_t mHue;
uint8_t mSaturation;
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
led_strip_handle_t mStrip;
#else
led_strip_t * mStrip;
#endif
#else
gpio_num_t mGPIONum;
#endif
Expand Down
3 changes: 3 additions & 0 deletions examples/lighting-app/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB"

# Disable softap support by default
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
# This example uses the older version of RMT driver to work with both
# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option
CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y
dhrishi marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 19 additions & 0 deletions examples/lighting-app/esp32/sdkconfig.defaults.esp32c2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Disable chip shell
CONFIG_ENABLE_CHIP_SHELL=n

# CONFIG_ESP32_WIFI_IRAM_OPT is not set
# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y
CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y

CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y

CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16
CONFIG_LWIP_TCP_RECVMBOX_SIZE=8

CONFIG_BT_NIMBLE_ROLE_CENTRAL=n
CONFIG_BT_NIMBLE_ROLE_OBSERVER=n

dhrishi marked this conversation as resolved.
Show resolved Hide resolved
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16
2 changes: 1 addition & 1 deletion examples/platform/esp32/lock/BoltLockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void BoltLockManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent)

lock->mAutoLockTimerArmed = true;

ESP_LOGI(TAG, "Auto Re-lock enabled. Will be triggered in %u seconds", lock->mAutoLockDuration);
ESP_LOGI(TAG, "Auto Re-lock enabled. Will be triggered in %" PRIu32 " seconds", lock->mAutoLockDuration);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ bool emberAfFaultInjectionClusterFailAtFaultCallback(CommandHandler * commandObj

if (faultInjectionMgr != nullptr)
{
ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %d and Id: %d to be triggered deterministically",
ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %u and Id: %" PRIu32 " to be triggered deterministically",
static_cast<uint8_t>(commandData.type), commandData.id);
int32_t err = faultInjectionMgr->FailAtFault(commandData.id, commandData.numCallsToSkip, commandData.numCallsToFail,
commandData.takeMutex);
Expand Down Expand Up @@ -126,7 +126,7 @@ bool emberAfFaultInjectionClusterFailRandomlyAtFaultCallback(CommandHandler * co

if (faultInjectionMgr != nullptr)
{
ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %d and Id: %d to be triggered randomly",
ChipLogProgress(Zcl, "FaultInjection: Configure a fault of type: %u and Id: %" PRIu32 " to be triggered randomly",
static_cast<uint8_t>(commandData.type), commandData.id);
int32_t err = faultInjectionMgr->FailRandomlyAtFault(commandData.id, commandData.percentage);

Expand Down
2 changes: 1 addition & 1 deletion src/app/util/mock/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ CHIP_ERROR ReadSingleMockClusterData(FabricIndex aAccessingFabricIndex, const Co
bool dataExists =
(emberAfGetServerAttributeIndexByAttributeId(aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId) != UINT16_MAX);

ChipLogDetail(DataManagement, "Reading Mock Endpoint %" PRIx32 "Mock Cluster %" PRIx32 ", Field %" PRIx32 " is dirty",
ChipLogDetail(DataManagement, "Reading Mock Endpoint %x Mock Cluster %" PRIx32 ", Field %" PRIx32 " is dirty",
aPath.mEndpointId, aPath.mClusterId, aPath.mAttributeId);

if (!dataExists)
Expand Down
8 changes: 4 additions & 4 deletions src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext)
ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return loopback.mSentMessageCount >= 2; });
now = System::SystemClock().GetMonotonicTimestamp();
timeoutTime = now - startTime;
ChipLogProgress(Test, "Attempt #1 Timeout : %d ms", timeoutTime.count());
ChipLogProgress(Test, "Attempt #1 Timeout : %" PRIu32 "ms", timeoutTime.count());
expectedBackoff = &theBackoffComplianceTestVector[0];
NL_TEST_ASSERT(inSuite, timeoutTime >= expectedBackoff->backoffMin - margin);

Expand All @@ -383,7 +383,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext)
ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return loopback.mSentMessageCount >= 3; });
now = System::SystemClock().GetMonotonicTimestamp();
timeoutTime = now - startTime;
ChipLogProgress(Test, "Attempt #2 Timeout : %d ms", timeoutTime.count());
ChipLogProgress(Test, "Attempt #2 Timeout : %" PRIu32 "ms", timeoutTime.count());
expectedBackoff = &theBackoffComplianceTestVector[1];
NL_TEST_ASSERT(inSuite, timeoutTime >= expectedBackoff->backoffMin - margin);

Expand All @@ -400,7 +400,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext)
ctx.GetIOContext().DriveIOUntil(1000_ms32, [&] { return loopback.mSentMessageCount >= 4; });
now = System::SystemClock().GetMonotonicTimestamp();
timeoutTime = now - startTime;
ChipLogProgress(Test, "Attempt #3 Timeout : %d ms", timeoutTime.count());
ChipLogProgress(Test, "Attempt #3 Timeout : %" PRIu32 "ms", timeoutTime.count());
expectedBackoff = &theBackoffComplianceTestVector[2];
NL_TEST_ASSERT(inSuite, timeoutTime >= expectedBackoff->backoffMin - margin);

Expand All @@ -417,7 +417,7 @@ void CheckResendApplicationMessage(nlTestSuite * inSuite, void * inContext)
ctx.GetIOContext().DriveIOUntil(1500_ms32, [&] { return loopback.mSentMessageCount >= 5; });
now = System::SystemClock().GetMonotonicTimestamp();
timeoutTime = now - startTime;
ChipLogProgress(Test, "Attempt #4 Timeout : %d ms", timeoutTime.count());
ChipLogProgress(Test, "Attempt #4 Timeout : %" PRIu32 "ms", timeoutTime.count());
expectedBackoff = &theBackoffComplianceTestVector[3];
NL_TEST_ASSERT(inSuite, timeoutTime >= expectedBackoff->backoffMin - margin);

Expand Down
48 changes: 32 additions & 16 deletions src/platform/ESP32/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,22 @@ CHIP_ERROR ConfigurationManagerImpl::Init()
{
ChipLogError(DeviceLayer,
"CONFIG_NVS_ENCRYPTION is enabled, but no partition with subtype nvs_keys found in the partition table.");
SuccessOrExit(MapConfigError(esp_err));
err = MapConfigError(esp_err);
SuccessOrExit(err);
}

esp_err = nvs_flash_read_security_cfg(key_part, &cfg);
if (esp_err == ESP_ERR_NVS_KEYS_NOT_INITIALIZED)
{
ChipLogError(DeviceLayer, "NVS key partition empty");
SuccessOrExit(MapConfigError(esp_err));
err = MapConfigError(esp_err);
SuccessOrExit(err);
}
else if (esp_err != ESP_OK)
{
ChipLogError(DeviceLayer, "Failed to read NVS security cfg, err:0x%02x", esp_err);
SuccessOrExit(MapConfigError(esp_err));
err = MapConfigError(esp_err);
SuccessOrExit(err);
}

// Securely initialize the nvs partitions,
Expand All @@ -93,35 +96,41 @@ CHIP_ERROR ConfigurationManagerImpl::Init()
{
ChipLogError(DeviceLayer, "Failed to initialize NVS partition %s err:0x%02x",
CHIP_DEVICE_CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION, esp_err);
SuccessOrExit(MapConfigError(esp_err));
err = MapConfigError(esp_err);
SuccessOrExit(err);
}

esp_err = nvs_flash_secure_init_partition(CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION, &cfg);
if (esp_err == ESP_ERR_NVS_NO_FREE_PAGES || esp_err == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
ChipLogError(DeviceLayer, "Failed to initialize NVS partition %s err:0x%02x",
CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION, esp_err);
SuccessOrExit(MapConfigError(esp_err));
err = MapConfigError(esp_err);
SuccessOrExit(err);
}

esp_err = nvs_flash_secure_init_partition(CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION, &cfg);
if (esp_err == ESP_ERR_NVS_NO_FREE_PAGES || esp_err == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
ChipLogError(DeviceLayer, "Failed to initialize NVS partition %s err:0x%02x",
CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION, esp_err);
SuccessOrExit(MapConfigError(esp_err));
err = MapConfigError(esp_err);
SuccessOrExit(err);
}
#else
// Initialize the nvs partitions,
// nvs_flash_init_partition() will initialize the partition only if it is not already initialized.
esp_err_t esp_err = nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION);
SuccessOrExit(MapConfigError(esp_err));
esp_err = nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION);
SuccessOrExit(MapConfigError(esp_err));
esp_err = nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION);
SuccessOrExit(MapConfigError(esp_err));
esp_err = nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_KVS_NAMESPACE_PARTITION);
SuccessOrExit(MapConfigError(esp_err));
err = MapConfigError(nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION));
SuccessOrExit(err);

err = MapConfigError(nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_CONFIG_NAMESPACE_PARTITION));
SuccessOrExit(err);

err = MapConfigError(nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_COUNTERS_NAMESPACE_PARTITION));
SuccessOrExit(err);

err = MapConfigError(nvs_flash_init_partition(CHIP_DEVICE_CONFIG_CHIP_KVS_NAMESPACE_PARTITION));
SuccessOrExit(err);
#endif

// Force initialization of NVS namespaces if they doesn't already exist.
Expand Down Expand Up @@ -188,7 +197,14 @@ CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOp
CHIP_ERROR ConfigurationManagerImpl::GetSoftwareVersionString(char * buf, size_t bufSize)
{
memset(buf, 0, bufSize);
const esp_app_desc_t * appDescription = esp_ota_get_app_description();
const esp_app_desc_t * appDescription = NULL;

#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
appDescription = esp_app_get_description();
#else
appDescription = esp_ota_get_app_description();
#endif

ReturnErrorCodeIf(bufSize < sizeof(appDescription->version), CHIP_ERROR_BUFFER_TOO_SMALL);
ReturnErrorCodeIf(sizeof(appDescription->version) > ConfigurationManager::kMaxSoftwareVersionStringLength, CHIP_ERROR_INTERNAL);
strcpy(buf, appDescription->version);
Expand All @@ -215,7 +231,7 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location)

return err;
#else
location = static_cast<uint8_t>(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
location = static_cast<uint8_t>(chip::app::Clusters::GeneralCommissioning::RegulatoryLocationType::kIndoor);
return CHIP_NO_ERROR;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/ESP32/ESP32Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ CHIP_ERROR ESP32Config::WriteConfigValueBin(Key key, const uint8_t * data, size_
// Commit the value to the persistent store.
ReturnMappedErrorOnFailure(nvs_commit(handle));

ChipLogProgress(DeviceLayer, "NVS set: %s/%s = (blob length %" PRId32 ")", StringOrNullMarker(key.Namespace),
ChipLogProgress(DeviceLayer, "NVS set: %s/%s = (blob length %u)", StringOrNullMarker(key.Namespace),
StringOrNullMarker(key.Name), dataLen);
return CHIP_NO_ERROR;
}
Expand Down
Loading