diff --git a/docs/guides/esp32/build_app_and_commission.md b/docs/guides/esp32/build_app_and_commission.md index a79d503265319a..959a0e90173c74 100644 --- a/docs/guides/esp32/build_app_and_commission.md +++ b/docs/guides/esp32/build_app_and_commission.md @@ -31,8 +31,8 @@ and the ESP32S3. All the applications support variants of ESP32, ESP32C3, ESP32S3 chips. -ESP32H2 and ESP32C6 are only supported and tested with lighting-app and -all-clusters-app. +ESP32H2 and ESP32C6 are only supported and tested with lighting-app, +lit-icd-app, and all-clusters-app. Note: M5Stack Core 2 display is not supported in the tft component, while other functionality can still work fine. @@ -85,15 +85,6 @@ functionality can still work fine. $ idf.py set-target (target chip) ``` - All the example applications supports target chips: esp32, esp32s3, esp32c3 - - ESP32H2 and ESP32C6 are only supported in lighting-app, to set it as target - - ``` - $ idf.py --preview set-target esp32h2 - $ idf.py --preview set-target esp32c6 - ``` - - Configuration Options To build the default configuration (`sdkconfig.defaults`) skip this step. diff --git a/examples/lit-icd-app/esp32/.gitignore b/examples/lit-icd-app/esp32/.gitignore new file mode 100644 index 00000000000000..234526a082ad26 --- /dev/null +++ b/examples/lit-icd-app/esp32/.gitignore @@ -0,0 +1,5 @@ +*.vscode + +/build/ +/sdkconfig +/sdkconfig.old diff --git a/examples/lit-icd-app/esp32/CMakeLists.txt b/examples/lit-icd-app/esp32/CMakeLists.txt new file mode 100644 index 00000000000000..41cf5d2686db44 --- /dev/null +++ b/examples/lit-icd-app/esp32/CMakeLists.txt @@ -0,0 +1,42 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# 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. + +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(PROJECT_VER "v1.0") +set(PROJECT_VER_NUMBER 1) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) + + +set(EXTRA_COMPONENT_DIRS + "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" +) + +project(lit-icd-app) +idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H" APPEND) +idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND) +# For the RISC-V chips, project_include.cmake sets -Wno-format, but does not clear various +# flags that depend on -Wformat +idf_build_set_property(COMPILE_OPTIONS "-Wno-format-nonliteral;-Wno-format-security" APPEND) + +# -Wmaybe-uninitialized has too many false positives, including on std::optional +# and chip::Optional. Make it nonfatal. +# +# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 +idf_build_set_property(COMPILE_OPTIONS "-Wno-error=maybe-uninitialized" APPEND) diff --git a/examples/lit-icd-app/esp32/README.md b/examples/lit-icd-app/esp32/README.md new file mode 100644 index 00000000000000..405f208bc54ead --- /dev/null +++ b/examples/lit-icd-app/esp32/README.md @@ -0,0 +1,11 @@ +# Matter ESP32 LIT ICD Example + +This example is meant to represent a power-save application. + +Please +[setup ESP-IDF and CHIP Environment](../../../docs/guides/esp32/setup_idf_chip.md) +and refer +[building and commissioning](../../../docs/guides/esp32/build_app_and_commission.md) +guides to get started. + +**Note**: Currently only Thread devices can run this example. diff --git a/examples/lit-icd-app/esp32/main/CMakeLists.txt b/examples/lit-icd-app/esp32/main/CMakeLists.txt new file mode 100644 index 00000000000000..5f2850feff98b6 --- /dev/null +++ b/examples/lit-icd-app/esp32/main/CMakeLists.txt @@ -0,0 +1,68 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# 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. +# +# + +get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) + +set(PRIV_INCLUDE_DIRS_LIST + "${CMAKE_CURRENT_LIST_DIR}/include" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" +) +set(SRC_DIRS_LIST + "${CMAKE_CURRENT_LIST_DIR}" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/access-control-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/administrator-commissioning-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/basic-information" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/diagnostic-logs-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ethernet-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/icd-management-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" +) + +idf_component_register(PRIV_INCLUDE_DIRS ${PRIV_INCLUDE_DIRS_LIST} + SRC_DIRS ${SRC_DIRS_LIST}) + +include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") +chip_app_component_codegen("${CHIP_ROOT}/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.matter") +chip_app_component_zapgen("${CHIP_ROOT}/examples/lit-icd-app/lit-icd-common/lit-icd-server-app.zap") + +set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) +target_compile_options(${COMPONENT_LIB} PRIVATE "-DCHIP_HAVE_CONFIG_H") +target_compile_options(${COMPONENT_LIB} PUBLIC + "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" +) diff --git a/examples/lit-icd-app/esp32/main/DeviceCallbacks.cpp b/examples/lit-icd-app/esp32/main/DeviceCallbacks.cpp new file mode 100644 index 00000000000000..8b522b10364911 --- /dev/null +++ b/examples/lit-icd-app/esp32/main/DeviceCallbacks.cpp @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * 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 DeviceCallbacks.cpp + * + * Implements all the callbacks to the application from the CHIP Stack + * + **/ +#include "DeviceCallbacks.h" + +static const char TAG[] = "devicecallbacks"; + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::System; + +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%" PRIx32 "', EndPoint ID: '0x%x', Attribute ID: '0x%" PRIx32 "'", + clusterId, endpointId, attributeId); + + // TODO handle this callback in switch statement + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); + + ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT)); +} diff --git a/examples/lit-icd-app/esp32/main/Kconfig.projbuild b/examples/lit-icd-app/esp32/main/Kconfig.projbuild new file mode 100644 index 00000000000000..a563d7b2ae46ce --- /dev/null +++ b/examples/lit-icd-app/esp32/main/Kconfig.projbuild @@ -0,0 +1,47 @@ +# +# Copyright (c) 2020 Project CHIP Authors +# 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. +# +# Description: +# Configuration options CHIP ESP32 demo application. +# + +menu "Demo" + + choice + prompt "Rendezvous Mode" + default RENDEZVOUS_MODE_BLE + help + Specifies the Rendezvous mode of the peripheral. + + config RENDEZVOUS_MODE_WIFI + bool "Wi-Fi" + config RENDEZVOUS_MODE_BLE + bool "BLE" + config RENDEZVOUS_MODE_THREAD + bool "Thread" + config RENDEZVOUS_MODE_ETHERNET + bool "Ethernet" + endchoice + + config RENDEZVOUS_MODE + int + range 0 8 + default 1 if RENDEZVOUS_MODE_WIFI + default 2 if RENDEZVOUS_MODE_BLE + default 4 if RENDEZVOUS_MODE_THREAD + default 8 if RENDEZVOUS_MODE_ETHERNET + +endmenu diff --git a/examples/lit-icd-app/esp32/main/include/DeviceCallbacks.h b/examples/lit-icd-app/esp32/main/include/DeviceCallbacks.h new file mode 100644 index 00000000000000..2862e2b87a2fc4 --- /dev/null +++ b/examples/lit-icd-app/esp32/main/include/DeviceCallbacks.h @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * 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 DeviceCallbacks.h + * + * Implementations for the DeviceManager callbacks for this application + * + **/ + +#ifndef DEVICE_CALLBACKS_H +#define DEVICE_CALLBACKS_H + +#include +#include + +class AppDeviceCallbacks : public CommonDeviceCallbacks +{ +public: + virtual void PostAttributeChangeCallback(chip::EndpointId endpointId, chip::ClusterId clusterId, chip::AttributeId attributeId, + uint8_t type, uint16_t size, uint8_t * value); +}; + +#endif // DEVICE_CALLBACKS_H diff --git a/examples/lit-icd-app/esp32/main/main.cpp b/examples/lit-icd-app/esp32/main/main.cpp new file mode 100644 index 00000000000000..340ae124d816c3 --- /dev/null +++ b/examples/lit-icd-app/esp32/main/main.cpp @@ -0,0 +1,115 @@ +/* + * + * Copyright (c) 2024 Project CHIP Authors + * + * 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. + */ + +#include "esp_log.h" +#include "esp_netif.h" +#include "esp_system.h" +#include "esp_wifi.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "nvs_flash.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER +#include +#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + +#if CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER +#include +#else +#include +#endif // CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER + +namespace { +#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER +chip::DeviceLayer::ESP32FactoryDataProvider sFactoryDataProvider; +#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + +#if CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER +chip::DeviceLayer::ESP32DeviceInfoProvider gExampleDeviceInfoProvider; +#else +chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; +#endif // CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER +} // namespace + +#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD +#error "Currently this example only support Thread chips" +#endif + +using namespace ::chip; +using namespace ::chip::DeviceManager; +using namespace ::chip::Credentials; + +extern const char TAG[] = "lit-icd-app"; + +static AppDeviceCallbacks EchoCallbacks; + +static void InitServer(intptr_t context) +{ + Esp32AppServer::Init(); // Init ZCL Data Model and CHIP App Server AND Initialize device attestation config +} + +extern "C" void app_main() +{ + ESP_LOGI(TAG, "LIT ICD example"); + + // Initialize the ESP NVS layer. + esp_err_t err = nvs_flash_init(); + if (err != ESP_OK) + { + 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; + } + + DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + + CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance(); + + CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks); + if (error != CHIP_NO_ERROR) + { + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); + return; + } + +#if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + SetCommissionableDataProvider(&sFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider); +#if CONFIG_ENABLE_ESP32_DEVICE_INSTANCE_INFO_PROVIDER + SetDeviceInstanceInfoProvider(&sFactoryDataProvider); +#endif +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + ESPOpenThreadInit(); + + chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); +} diff --git a/examples/lit-icd-app/esp32/partitions.csv b/examples/lit-icd-app/esp32/partitions.csv new file mode 100644 index 00000000000000..0833935233b074 --- /dev/null +++ b/examples/lit-icd-app/esp32/partitions.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size, Flags +# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap +nvs, data, nvs, , 0xC000, +phy_init, data, phy, , 0x1000, +# Factory partition size about 2MB +factory, app, factory, , 2048K, diff --git a/examples/lit-icd-app/esp32/sdkconfig.defaults b/examples/lit-icd-app/esp32/sdkconfig.defaults new file mode 100644 index 00000000000000..330b6c27699f0b --- /dev/null +++ b/examples/lit-icd-app/esp32/sdkconfig.defaults @@ -0,0 +1,104 @@ +# Monitoring baud and flash size +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y + +# Enable BT +CONFIG_BT_ENABLED=y +CONFIG_BT_NIMBLE_ENABLED=y +CONFIG_BT_NIMBLE_EXT_ADV=n +CONFIG_BT_NIMBLE_HCI_EVT_BUF_SIZE=70 +CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING=y + +# Disable BT connection reattempt +CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n + +# BLE sleep +CONFIG_BT_LE_SLEEP_ENABLE=y +CONFIG_BT_LE_LP_CLK_SRC_MAIN_XTAL=y + +# Disable external 32K crystal +CONFIG_RTC_CLK_SRC_EXT_CRYS=n + +# FreeRTOS should use legacy API +CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y + +# FreeRTOS config for light sleep +CONFIG_FREERTOS_HZ=1000 +CONFIG_FREERTOS_USE_TICKLESS_IDLE=y + +# FreeRTOS config for light sleep +CONFIG_FREERTOS_HZ=1000 +CONFIG_FREERTOS_USE_TICKLESS_IDLE=y + +# Enable OpenThread +CONFIG_OPENTHREAD_ENABLED=y +CONFIG_OPENTHREAD_SRP_CLIENT=y +CONFIG_OPENTHREAD_DNS_CLIENT=y +CONFIG_OPENTHREAD_LOG_LEVEL_DYNAMIC=n +CONFIG_OPENTHREAD_LOG_LEVEL_NOTE=y +CONFIG_OPENTHREAD_CLI=n + +# Use OpenThread MTD +CONFIG_OPENTHREAD_MTD=y + +# Enable IEEE 802.15.4 sleep +CONFIG_IEEE802154_SLEEP_ENABLE=y + +# Use a custom partition table +CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_OFFSET=0xC000 + +# Disable STA and AP for ESP32H2 +CONFIG_ENABLE_WIFI_STATION=n +CONFIG_ENABLE_WIFI_AP=n +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n + +# Disable chip shell +CONFIG_ENABLE_CHIP_SHELL=n + +# Enable DS Peripheral +CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=y + +# Enable HKDF in mbedtls +CONFIG_MBEDTLS_HKDF_C=y + +# Disable hardware acceleration +CONFIG_MBEDTLS_HARDWARE_AES=n +CONFIG_MBEDTLS_HARDWARE_MPI=n +CONFIG_MBEDTLS_HARDWARE_SHA=n +CONFIG_MBEDTLS_HARDWARE_ECC=n +CONFIG_MBEDTLS_HARDWARE_ECDSA_VERIFY=n +CONFIG_MBEDTLS_SSL_PROTO_DTLS=y + +# LwIP config for OpenThread +CONFIG_LWIP_IPV6_NUM_ADDRESSES=8 +CONFIG_LWIP_MULTICAST_PING=y + +# LwIP config for light sleep +CONFIG_LWIP_ND6=n +CONFIG_LWIP_IPV4=n +CONFIG_DISABLE_IPV4=y + +# Disable lwip ipv6 autoconfig for Thread device +CONFIG_LWIP_IPV6_AUTOCONFIG=n + +# Use platform mDNS +CONFIG_USE_MINIMAL_MDNS=n +CONFIG_ENABLE_EXTENDED_DISCOVERY=y + +# Enable power management +CONFIG_PM_ENABLE=y +CONFIG_PM_DFS_INIT_AUTO=y +CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y +CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y + +# ICD configurations +CONFIG_ENABLE_ICD_SERVER=y +CONFIG_ICD_FAST_POLL_INTERVAL_MS=500 +CONFIG_ICD_SLOW_POLL_INTERVAL_MS=20000 +CONFIG_ICD_IDLE_MODE_INTERVAL_SEC=600 +CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS=0 +CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS=5000 +CONFIG_ENABLE_ICD_LIT=y +CONFIG_ENABLE_ICD_CIP=y diff --git a/examples/lit-icd-app/esp32/sdkconfig.defaults.esp32c6 b/examples/lit-icd-app/esp32/sdkconfig.defaults.esp32c6 new file mode 100644 index 00000000000000..6ebe84aaf6fe54 --- /dev/null +++ b/examples/lit-icd-app/esp32/sdkconfig.defaults.esp32c6 @@ -0,0 +1,5 @@ +# Disable power down flash when sleeping +CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=n + +# Power down MAC and baseband of Wi-Fi and Bluetooth when PHY is disabled +CONFIG_ESP_PHY_MAC_BB_PD=y diff --git a/examples/lit-icd-app/esp32/third_party/connectedhomeip b/examples/lit-icd-app/esp32/third_party/connectedhomeip new file mode 120000 index 00000000000000..11a54ed360106c --- /dev/null +++ b/examples/lit-icd-app/esp32/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../../ \ No newline at end of file diff --git a/examples/platform/esp32/common/Esp32AppServer.cpp b/examples/platform/esp32/common/Esp32AppServer.cpp index 038ff055413e64..53957784b8c5f5 100644 --- a/examples/platform/esp32/common/Esp32AppServer.cpp +++ b/examples/platform/esp32/common/Esp32AppServer.cpp @@ -25,9 +25,6 @@ #include #include #include -#if CONFIG_ENABLE_ICD_SERVER -#include -#endif #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #if CONFIG_BT_ENABLED @@ -69,9 +66,6 @@ static uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLe 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; #endif -#if CONFIG_ENABLE_ICD_SERVER -static ICDSubscriptionCallback sICDSubscriptionHandler; -#endif } // namespace #if CONFIG_TEST_EVENT_TRIGGER_ENABLED && CONFIG_ENABLE_OTA_REQUESTOR @@ -183,10 +177,6 @@ void Esp32AppServer::Init(AppDelegate * sAppDelegate) initParams.appDelegate = sAppDelegate; } chip::Server::GetInstance().Init(initParams); -#if CONFIG_ENABLE_ICD_SERVER - // Register ICD subscription callback to match subscription max intervals to its idle time interval - chip::app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&sICDSubscriptionHandler); -#endif // CONFIG_ENABLE_ICD_SERVER #if CHIP_DEVICE_CONFIG_ENABLE_WIFI sWiFiNetworkCommissioningInstance.Init(); diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index c2aa892ac04b13..041b8e99612891 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -90,9 +90,11 @@ #define CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS #endif // CHIP_CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS +#ifdef CONFIG_ENABLE_ICD_CIP #ifndef CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC #define CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC #endif // CHIP_CONFIG_ICD_CLIENTS_SUPPORTED_PER_FABRIC +#endif // CONFIG_ENABLE_ICD_CIP #endif // CONFIG_ENABLE_ICD_SERVER diff --git a/src/transport/SessionManager.cpp b/src/transport/SessionManager.cpp index 34237c048b11f2..dfcbd6082fa2db 100644 --- a/src/transport/SessionManager.cpp +++ b/src/transport/SessionManager.cpp @@ -450,8 +450,10 @@ CHIP_ERROR SessionManager::SendPreparedMessage(const SessionHandle & sessionHand #if CHIP_ERROR_LOGGING char addressStr[Transport::PeerAddress::kMaxToStringSize] = { 0 }; destination->ToString(addressStr); - - ChipLogError(Inet, "SendMessage() to %s failed: %" CHIP_ERROR_FORMAT, addressStr, err.Format()); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Inet, "SendMessage() to %s failed: %" CHIP_ERROR_FORMAT, addressStr, err.Format()); + } #endif // CHIP_ERROR_LOGGING return err; }