From 660dc84bab766ddf426ff2b7482bd3a2062f51ab Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Mon, 13 Feb 2023 19:20:34 +0530 Subject: [PATCH 01/53] [ESP32] ESP-IDF v5.0 support in reamining apps (#24983) * [ESP32] ota-requestor-app: changes to support idf v5.0 * [ESP32] ota-provider-app: changes to support idf v5.0 * [ESP32] temperature-measurement-app: changes to support idf v5.0 * [ESP32] lock-app: changes to support idf v5.0 * [ESP32] chef-app: changes to support idf v5.0 * Fix specifiers for endpoint/cluster/attribute ids --- .../esp32/main/DeviceCallbacks.cpp | 9 ++++----- .../esp32/main/DeviceCallbacks.cpp | 9 ++++----- .../bridge-app/esp32/main/DeviceCallbacks.cpp | 3 +-- examples/chef/esp32/CMakeLists.txt | 1 - examples/chef/esp32/main/CMakeLists.txt | 8 +++++++- examples/chef/esp32/main/idf_component.yml | 2 ++ .../esp32/main/DeviceCallbacks.cpp | 3 +-- .../lighting-app/esp32/main/DeviceCallbacks.cpp | 9 ++++----- examples/lock-app/esp32/main/CMakeLists.txt | 4 ++-- .../lock-app/esp32/main/DeviceCallbacks.cpp | 8 ++++---- examples/lock-app/esp32/main/main.cpp | 7 ++----- .../esp32/main/BdxOtaSender.cpp | 8 ++++---- .../ota-provider-app/esp32/main/CMakeLists.txt | 2 +- .../esp32/main/DeviceCallbacks.cpp | 2 +- examples/ota-provider-app/esp32/main/main.cpp | 13 ++++++------- examples/ota-provider-app/esp32/partitions.csv | 8 ++++---- .../ota-requestor-app/esp32/main/CMakeLists.txt | 2 +- .../esp32/main/DeviceCallbacks.cpp | 2 +- examples/ota-requestor-app/esp32/main/main.cpp | 15 +-------------- .../esp32/main/CMakeLists.txt | 2 +- .../esp32/main/DeviceCallbacks.cpp | 6 +++--- .../esp32/main/main.cpp | 17 +---------------- 22 files changed, 55 insertions(+), 85 deletions(-) create mode 100644 examples/chef/esp32/main/idf_component.yml diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index cb9a532961198d..2353028c1c5c89 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -92,8 +92,7 @@ Identify gIdentify1 = { 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%04" PRIx32 "', EndPoint ID: '0x%02x' , Attribute ID: '0x%04" PRIx32 "'", + ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%" PRIx32 "', EndPoint ID: '0x%x' , Attribute ID: '0x%" PRIx32 "'", clusterId, endpointId, attributeId); switch (clusterId) @@ -125,7 +124,7 @@ void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointI { using namespace app::Clusters::OnOff::Attributes; - VerifyOrExit(attributeId == OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); + VerifyOrExit(attributeId == OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -143,7 +142,7 @@ void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpoi bool onOffState = mEndpointOnOffState[endpointId - 1]; uint8_t brightness = onOffState ? *value : 0; - VerifyOrExit(attributeId == CurrentLevel::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); + VerifyOrExit(attributeId == CurrentLevel::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -161,7 +160,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi using namespace app::Clusters::ColorControl::Attributes; VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (endpointId == 1) { diff --git a/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp index 9acee43d2c2790..0e1d50952fa906 100644 --- a/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp @@ -91,8 +91,7 @@ Identify gIdentify1 = { 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%04" PRIx32 "', EndPoint ID: '0x%02x' , Attribute ID: '0x%04" PRIx32 "'", + ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%" PRIx32 "', EndPoint ID: '0x%x' , Attribute ID: '0x%" PRIx32 "'", clusterId, endpointId, attributeId); switch (clusterId) @@ -123,7 +122,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == Clusters::OnOff::Attributes::OnOff::Id, - ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -140,7 +139,7 @@ void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpoi uint8_t brightness = onOffState ? *value : 0; VerifyOrExit(attributeId == Clusters::LevelControl::Attributes::CurrentLevel::Id, - ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -158,7 +157,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi using namespace Clusters::ColorControl::Attributes; VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (endpointId == 1) { diff --git a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp index fa51be072f38ee..e6e1f8b218a992 100644 --- a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp @@ -39,8 +39,7 @@ 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%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'", + ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%" PRIx32 "', EndPoint ID: '0x%x', Attribute ID: '0x%" PRIx32 "'", clusterId, endpointId, attributeId); ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } diff --git a/examples/chef/esp32/CMakeLists.txt b/examples/chef/esp32/CMakeLists.txt index e34fa66537aeda..50b6dc0da3de7d 100644 --- a/examples/chef/esp32/CMakeLists.txt +++ b/examples/chef/esp32/CMakeLists.txt @@ -27,7 +27,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../common/cmake/idf_flashing.cmake) set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" "${CMAKE_CURRENT_LIST_DIR}/../../common/QRCode" - "${IDF_PATH}/examples/common_components/led_strip" ) if(${IDF_TARGET} STREQUAL "esp32") diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt index cf32321bb54baa..6d8925a0bfc9da 100644 --- a/examples/chef/esp32/main/CMakeLists.txt +++ b/examples/chef/esp32/main/CMakeLists.txt @@ -87,8 +87,14 @@ set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/../../common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/../../common/screen-framework/include/" "${CMAKE_SOURCE_DIR}/../../../src/lib/support" - "${IDF_PATH}/components/freertos/include/freertos" ) + +if (${IDF_VERSION_MAJOR} LESS 5) + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/include/freertos") +else() + list(APPEND PRIV_INCLUDE_DIRS_LIST "${IDF_PATH}/components/freertos/FreeRTOS-Kernel/include/freertos") +endif() + set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" "${CMAKE_SOURCE_DIR}/../../platform/esp32" "${CMAKE_SOURCE_DIR}/../../common/pigweed" diff --git a/examples/chef/esp32/main/idf_component.yml b/examples/chef/esp32/main/idf_component.yml new file mode 100644 index 00000000000000..1c539b8eb57668 --- /dev/null +++ b/examples/chef/esp32/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/led_strip: "^1.0.0-alpha" diff --git a/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp b/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp index c99c0fe1e42f23..b4f73ec65fdf6a 100644 --- a/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp @@ -36,8 +36,7 @@ using namespace chip::app::Clusters; void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask, uint8_t type, uint16_t size, uint8_t * value) { - ESP_LOGI(TAG, - "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'", + ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%" PRIx32 "', EndPoint ID: '0x%x', Attribute ID: '0x%" PRIx32 "'", clusterId, endpointId, attributeId); switch (clusterId) diff --git a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp index c61c3d3d5054b5..87f64f9e900b22 100644 --- a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp @@ -47,8 +47,7 @@ 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%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'", + ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%" PRIx32 "', EndPoint ID: '0x%x', Attribute ID: '0x%" PRIx32 "'", clusterId, endpointId, attributeId); switch (clusterId) @@ -78,7 +77,7 @@ 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%04" PRIx32 "'", attributeId)); + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); AppLED.Set(*value); @@ -90,7 +89,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%04" PRIx32 "'", attributeId)); + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); AppLED.SetBrightness(*value); @@ -107,7 +106,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi VerifyOrExit(attributeId == ColorControl::Attributes::CurrentHue::Id || attributeId == ColorControl::Attributes::CurrentSaturation::Id, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (attributeId == ColorControl::Attributes::CurrentHue::Id) diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index e15ee62a79f53b..2f4b237399370d 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -68,7 +68,7 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/door-lock-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" - PRIV_REQUIRES bt chip QRCode) + PRIV_REQUIRES bt chip QRCode nvs_flash driver) add_dependencies(${COMPONENT_LIB} app-codegen) set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") @@ -185,7 +185,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/lock" - PRIV_REQUIRES chip QRCode bt) + PRIV_REQUIRES chip QRCode bt nvs_flash driver) add_dependencies(${COMPONENT_LIB} app-codegen) diff --git a/examples/lock-app/esp32/main/DeviceCallbacks.cpp b/examples/lock-app/esp32/main/DeviceCallbacks.cpp index ba738c7acab4d1..1b28605f4c2701 100644 --- a/examples/lock-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/lock-app/esp32/main/DeviceCallbacks.cpp @@ -39,8 +39,8 @@ using namespace ::chip::DeviceLayer; 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%" PRIx32 "', EndPoint ID: '0x%x', Attribute ID: '0x%" PRIx32 "'", + clusterId, endpointId, attributeId); switch (clusterId) { @@ -49,7 +49,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus break; default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } @@ -59,7 +59,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == app::Clusters::OnOff::Attributes::OnOff::Id, - ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%" PRIx32, attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (*value) { diff --git a/examples/lock-app/esp32/main/main.cpp b/examples/lock-app/esp32/main/main.cpp index df47caa8fd2234..28964b4eeceeb2 100644 --- a/examples/lock-app/esp32/main/main.cpp +++ b/examples/lock-app/esp32/main/main.cpp @@ -20,7 +20,6 @@ #include "esp_heap_caps_init.h" #include "esp_log.h" #include "esp_netif.h" -#include "esp_spi_flash.h" #include "esp_system.h" #include "esp_wifi.h" #include "freertos/FreeRTOS.h" @@ -37,8 +36,6 @@ #include #include -#include - #if CONFIG_ENABLE_PW_RPC #include "PigweedLogger.h" #include "Rpc.h" @@ -82,7 +79,7 @@ static void InitServer(intptr_t context) CHIP_ERROR error = GetAppTask().StartAppTask(); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed: %" CHIP_ERROR_FORMAT, error.Format()); } } @@ -114,7 +111,7 @@ extern "C" void app_main() CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } diff --git a/examples/ota-provider-app/esp32/main/BdxOtaSender.cpp b/examples/ota-provider-app/esp32/main/BdxOtaSender.cpp index 37be9761aa81b8..272187870f49df 100644 --- a/examples/ota-provider-app/esp32/main/BdxOtaSender.cpp +++ b/examples/ota-provider-app/esp32/main/BdxOtaSender.cpp @@ -110,12 +110,12 @@ void BdxOtaSender::HandleTransferSessionOutput(TransferSession::OutputEvent & ev acceptData.StartOffset = mTransfer.GetStartOffset(); acceptData.Length = mTransfer.GetTransferLength(); VerifyOrReturn(mTransfer.AcceptTransfer(acceptData) == CHIP_NO_ERROR, - ChipLogError(BDX, "%s: %s", __FUNCTION__, chip::ErrorStr(err))); + ChipLogError(BDX, "AcceptTransfter failed error:%" CHIP_ERROR_FORMAT, err.Format())); // Store the file designator, used during block query uint16_t fdl = 0; const uint8_t * fd = mTransfer.GetFileDesignator(fdl); - VerifyOrReturn(fdl < sizeof(mFileDesignator), ChipLogError(BDX, "Cannot store file designator with length = %d", fdl)); + VerifyOrReturn(fdl < sizeof(mFileDesignator), ChipLogError(BDX, "Cannot store file designator with length = %u", fdl)); memcpy(mFileDesignator, fd, fdl); mFileDesignator[fdl] = 0; @@ -157,7 +157,7 @@ void BdxOtaSender::HandleTransferSessionOutput(TransferSession::OutputEvent & ev if (CHIP_NO_ERROR != mTransfer.PrepareBlock(blockData)) { - ChipLogError(BDX, "%s: PrepareBlock failed: %s", __FUNCTION__, chip::ErrorStr(err)); + ChipLogError(BDX, "PrepareBlock failed: %" CHIP_ERROR_FORMAT, err.Format()); mTransfer.AbortTransfer(StatusCode::kUnknown); } break; @@ -215,7 +215,7 @@ void BdxOtaSender::HandleTransferSessionOutput(TransferSession::OutputEvent & ev case TransferSession::OutputEventType::kBlockReceived: default: // TransferSession should prevent this case from happening. - ChipLogError(BDX, "%s: unsupported event type", __FUNCTION__); + ChipLogError(BDX, "unsupported event type"); } } diff --git a/examples/ota-provider-app/esp32/main/CMakeLists.txt b/examples/ota-provider-app/esp32/main/CMakeLists.txt index 7bbf39d18ab0e3..1cd8eae90953c6 100644 --- a/examples/ota-provider-app/esp32/main/CMakeLists.txt +++ b/examples/ota-provider-app/esp32/main/CMakeLists.txt @@ -55,7 +55,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" EXCLUDE_SRCS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/ota-provider-app/ota-provider-common/BdxOtaSender.cpp" - PRIV_REQUIRES chip QRCode bt console spiffs) + PRIV_REQUIRES chip QRCode bt console spiffs spi_flash nvs_flash) get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") diff --git a/examples/ota-provider-app/esp32/main/DeviceCallbacks.cpp b/examples/ota-provider-app/esp32/main/DeviceCallbacks.cpp index 94edc5595f37ae..c4f5e81ec09da2 100644 --- a/examples/ota-provider-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/ota-provider-app/esp32/main/DeviceCallbacks.cpp @@ -35,7 +35,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus { ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '" ChipLogFormatMEI - "', EndPoint ID: '0x%02x', Attribute ID: '" ChipLogFormatMEI "'", + "', EndPoint ID: '0x%x', Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(clusterId), endpointId, ChipLogValueMEI(attributeId)); // TODO handle this callback in switch statement diff --git a/examples/ota-provider-app/esp32/main/main.cpp b/examples/ota-provider-app/esp32/main/main.cpp index 17276f9ac6cb56..2a0f4d6e9bcc3c 100644 --- a/examples/ota-provider-app/esp32/main/main.cpp +++ b/examples/ota-provider-app/esp32/main/main.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -89,7 +88,7 @@ static void InitServer(intptr_t context) chip::Protocols::BDX::Id, bdxOtaSender); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "RegisterUnsolicitedMessageHandler failed: %s", chip::ErrorStr(error)); + ESP_LOGE(TAG, "RegisterUnsolicitedMessageHandler failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } @@ -114,7 +113,7 @@ static void InitServer(intptr_t context) } size_t total = 0, used = 0; err = esp_spiffs_info(NULL, &total, &used); - ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used); + ESP_LOGI(TAG, "Partition size: total: %u, used: %u", total, used); char otaImagePath[kMaxImagePathlen]; memset(otaImagePath, 0, sizeof(otaImagePath)); snprintf(otaImagePath, sizeof(otaImagePath), "/fs/%s", otaFilename); @@ -129,7 +128,7 @@ static void InitServer(intptr_t context) fseek(otaImageFile, 0, SEEK_END); otaImageLen = ftell(otaImageFile); rewind(otaImageFile); - ESP_LOGI(TAG, "The OTA image size: %d", otaImageLen); + ESP_LOGI(TAG, "The OTA image size: %" PRIu32, otaImageLen); if (otaImageLen > 0) { otaProvider.SetQueryImageStatus(OTAQueryStatus::kUpdateAvailable); @@ -203,12 +202,12 @@ CHIP_ERROR OnBlockQuery(void * context, chip::System::PacketBufferHandle & block size_t size_read = fread(blockBuf->Start(), 1, size, otaImageFile); if (size_read != size) { - ESP_LOGE(TAG, "Failed to read %d bytes from %s", size, otaFilename); + ESP_LOGE(TAG, "Failed to read %u bytes from %s", size, otaFilename); size = 0; isEof = false; return CHIP_ERROR_READ_FAILED; } - ESP_LOGI(TAG, "Read %d bytes from %s", size, otaFilename); + ESP_LOGI(TAG, "Read %u bytes from %s", size, otaFilename); return CHIP_NO_ERROR; } @@ -253,7 +252,7 @@ extern "C" void app_main() CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } diff --git a/examples/ota-provider-app/esp32/partitions.csv b/examples/ota-provider-app/esp32/partitions.csv index 074db5a06dbe17..0d8e94e5c1f16a 100644 --- a/examples/ota-provider-app/esp32/partitions.csv +++ b/examples/ota-provider-app/esp32/partitions.csv @@ -2,7 +2,7 @@ # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap nvs, data, nvs, , 0x6000, phy_init, data, phy, , 0x1000, -# Factory partition size about 1.5MB -factory, app, factory, , 1500K, -# spiffs partition to storage the image file size about 1.5MB -img_storage, data, spiffs, , 1500K, +# Factory partition size about 1.6MB +factory, app, factory, , 1600K, +# spiffs partition to storage the image file size about 1.6MB +img_storage, data, spiffs, , 1600K, diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index f2320f4c3785f4..e4fb78dc0d55f6 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -63,7 +63,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" ) -set(PRIV_REQUIRES_LIST chip QRCode bt console app_update) +set(PRIV_REQUIRES_LIST chip QRCode bt console app_update nvs_flash) if (CONFIG_ENABLE_PW_RPC) # Append additional directories for RPC build diff --git a/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp index 94edc5595f37ae..c4f5e81ec09da2 100644 --- a/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/esp32/main/DeviceCallbacks.cpp @@ -35,7 +35,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus { ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '" ChipLogFormatMEI - "', EndPoint ID: '0x%02x', Attribute ID: '" ChipLogFormatMEI "'", + "', EndPoint ID: '0x%x', Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(clusterId), endpointId, ChipLogValueMEI(attributeId)); // TODO handle this callback in switch statement diff --git a/examples/ota-requestor-app/esp32/main/main.cpp b/examples/ota-requestor-app/esp32/main/main.cpp index 4b3c4d7a331339..099984b86af621 100644 --- a/examples/ota-requestor-app/esp32/main/main.cpp +++ b/examples/ota-requestor-app/esp32/main/main.cpp @@ -21,7 +21,6 @@ #include "esp_heap_caps_init.h" #include "esp_log.h" #include "esp_netif.h" -#include "esp_spi_flash.h" #include "esp_system.h" #include "esp_wifi.h" #include "freertos/FreeRTOS.h" @@ -32,7 +31,6 @@ #include #include #include -#include #include #include @@ -128,17 +126,6 @@ extern "C" void app_main() ESP_LOGI(TAG, "OTA Requester!"); - /* Print chip information */ - esp_chip_info_t chip_info; - esp_chip_info(&chip_info); - ESP_LOGI(TAG, "This is ESP32 chip with %d CPU cores, WiFi%s%s, ", chip_info.cores, - (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); - - ESP_LOGI(TAG, "silicon revision %d, ", chip_info.revision); - - ESP_LOGI(TAG, "%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), - (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); - // Initialize the ESP NVS layer. esp_err_t err = nvs_flash_init(); if (err != ESP_OK) @@ -159,7 +146,7 @@ extern "C" void app_main() CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index 526c2825e462e9..18cfe375c224c1 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -55,7 +55,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" ) -set(PRIV_REQUIRES_LIST chip QRCode bt) +set(PRIV_REQUIRES_LIST chip QRCode bt nvs_flash) if (CONFIG_ENABLE_PW_RPC) # Append additional directories for RPC build diff --git a/examples/temperature-measurement-app/esp32/main/DeviceCallbacks.cpp b/examples/temperature-measurement-app/esp32/main/DeviceCallbacks.cpp index f5c05da05cb2a7..9f0472d6fb7532 100644 --- a/examples/temperature-measurement-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/temperature-measurement-app/esp32/main/DeviceCallbacks.cpp @@ -33,11 +33,11 @@ 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%04x', EndPoint ID: '0x%02x', Attribute ID: '0x%04x'", clusterId, - endpointId, attributeId); + 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: %d", clusterId); + 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/temperature-measurement-app/esp32/main/main.cpp b/examples/temperature-measurement-app/esp32/main/main.cpp index f42e3189b7c54c..2d1e2672d3a720 100644 --- a/examples/temperature-measurement-app/esp32/main/main.cpp +++ b/examples/temperature-measurement-app/esp32/main/main.cpp @@ -19,7 +19,6 @@ #include "esp_heap_caps_init.h" #include "esp_log.h" #include "esp_netif.h" -#include "esp_spi_flash.h" #include "esp_system.h" #include "esp_wifi.h" #include "freertos/FreeRTOS.h" @@ -36,8 +35,6 @@ #include #include -#include - #if CONFIG_ENABLE_PW_RPC #include "Rpc.h" #endif @@ -85,18 +82,6 @@ extern "C" void app_main() ESP_LOGI(TAG, "Temperature sensor!"); - /* Print chip information */ - esp_chip_info_t chip_info; - esp_chip_info(&chip_info); - - ESP_LOGI(TAG, "This is ESP32 chip with %d CPU cores, WiFi%s%s, ", chip_info.cores, - (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); - - ESP_LOGI(TAG, "silicon revision %d, ", chip_info.revision); - - ESP_LOGI(TAG, "%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), - (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); - // Initialize the ESP NVS layer. esp_err_t err = nvs_flash_init(); if (err != ESP_OK) @@ -112,7 +97,7 @@ extern "C" void app_main() CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } From 36d2d4d7b940def3918cda83ffe628edfcf25ef8 Mon Sep 17 00:00:00 2001 From: Timothy Maes Date: Mon, 13 Feb 2023 15:18:41 +0100 Subject: [PATCH 02/53] [crypto] Fix compile error in BufferWriter init (#25015) BufferWriter class expects a (uint8_t*, size_t) as initialization. The given parameter 'output' was a `P256SerializedKeypair` which throws a compiler error. Output: used compiler - gcc-arm-none-eabi-9-2019-q4-major In member function 'virtual CHIP_ERROR chip::Crypto::P256Keypair::Serialize(chip::Crypto::P256SerializedKeypair&) const': .../src/crypto/CHIPCryptoPALPSA.cpp:685:51: error: no matching function for call to 'chip::Encoding::BufferWriter::BufferWriter(chip::Crypto::P256SerializedKeypair&, const size_t&)' 685 | Encoding::BufferWriter bbuf(output, outputSize); Fix: Use the `Bytes` method to expose a uint8_t* for use of the BufferWriter. --- src/crypto/CHIPCryptoPALPSA.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crypto/CHIPCryptoPALPSA.cpp b/src/crypto/CHIPCryptoPALPSA.cpp index 1fb88421f34a89..1a063a97cb7cee 100644 --- a/src/crypto/CHIPCryptoPALPSA.cpp +++ b/src/crypto/CHIPCryptoPALPSA.cpp @@ -682,7 +682,7 @@ CHIP_ERROR P256Keypair::Serialize(P256SerializedKeypair & output) const psa_status_t status = PSA_SUCCESS; const PSAP256KeypairContext & context = toConstPSAContext(mKeypair); const size_t outputSize = output.Length() == 0 ? output.Capacity() : output.Length(); - Encoding::BufferWriter bbuf(output, outputSize); + Encoding::BufferWriter bbuf(output.Bytes(), outputSize); uint8_t privateKey[kP256_PrivateKey_Length]; size_t privateKeyLength = 0; From 5a23941d5228452197f971df6e810ac0884f5c2a Mon Sep 17 00:00:00 2001 From: Erwin Pan Date: Mon, 13 Feb 2023 22:44:58 +0800 Subject: [PATCH 03/53] [Chef] Support assigning product name when compiling Chef applications (#24731) * Chef support assigning product name Support assigning product name for chef applications. Now only linux, esp32, nrfconnect are supported * Show verbose err text when get product name failed * Restyled by clang-format * Print "err.Format()" when get product name failed * [Chef] Fix type when printing error message --------- Co-authored-by: Restyled.io --- examples/chef/chef.py | 6 +++++- examples/chef/esp32/CMakeLists.txt | 8 ++++++-- examples/chef/nrfconnect/CMakeLists.txt | 9 +++++++-- .../internal/GenericConfigurationManagerImpl.ipp | 13 +++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/examples/chef/chef.py b/examples/chef/chef.py index e8cfe07501ffe4..fb86d45d3e96e2 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -321,6 +321,8 @@ def main() -> int: help="specifies the Vendor ID. Default is 0xFFF1", metavar="VID", default=0xFFF1) parser.add_option("-p", "--pid", dest="pid", type=int, help="specifies the Product ID. Default is 0x8000", metavar="PID", default=0x8000) + parser.add_option("-P", "--pname", dest="pname", type=str, metavar="PRODUCT_NAME", + help="specifies the Product Name. Default is TEST_PRODUCT", default="TEST_PRODUCT") parser.add_option("", "--rpc_console", help="Opens PW RPC Console", action="store_true", dest="do_rpc_console") parser.add_option("-y", "--tty", help="Enumerated USB tty/serial interface enumerated for your physical device. E.g.: /dev/ACM0", @@ -626,6 +628,7 @@ def main() -> int: f.write(textwrap.dedent(f"""\ set(CONFIG_DEVICE_VENDOR_ID {options.vid}) set(CONFIG_DEVICE_PRODUCT_ID {options.pid}) + set(CONFIG_DEVICE_PRODUCT_NAME \"{options.pname}\") set(CONFIG_ENABLE_PW_RPC {"1" if options.do_rpc else "0"}) set(SAMPLE_NAME {options.sample_device_type_name}) set(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING \"{sw_ver_string}\")""")) @@ -716,7 +719,7 @@ def main() -> int: 'chip_shell_cmd_server = false', 'chip_build_libshell = true', 'chip_config_network_layer_ble = false', - f'target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={int(options.do_rpc)}"]', + f'target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={int(options.do_rpc)}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\\"{str(options.pname)}\\""]', ]) uname_resp = shell.run_cmd("uname -m", return_cmd_output=True) @@ -763,6 +766,7 @@ def main() -> int: if sw_ver_string: linux_args.append( f'chip_device_config_device_software_version_string = "{sw_ver_string}"') + with open(f"{_CHEF_SCRIPT_PATH}/linux/args.gni", "w") as f: f.write("\n".join(linux_args)) with open(f"{_CHEF_SCRIPT_PATH}/linux/sample.gni", "w") as f: diff --git a/examples/chef/esp32/CMakeLists.txt b/examples/chef/esp32/CMakeLists.txt index 50b6dc0da3de7d..f4ea7c13eefede 100644 --- a/examples/chef/esp32/CMakeLists.txt +++ b/examples/chef/esp32/CMakeLists.txt @@ -37,11 +37,15 @@ endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include(${CMAKE_CURRENT_LIST_DIR}/../project_include.cmake) -message(STATUS "Product ID " ${CONFIG_DEVICE_PRODUCT_ID}) message(STATUS "Vendor ID " ${CONFIG_DEVICE_VENDOR_ID}) +message(STATUS "Product ID " ${CONFIG_DEVICE_PRODUCT_ID}) +message(STATUS "Product Name " ${CONFIG_DEVICE_PRODUCT_NAME}) message(STATUS "SW Version String" ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}) -idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${CONFIG_DEVICE_PRODUCT_ID}" APPEND) idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${CONFIG_DEVICE_VENDOR_ID}" APPEND) +idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${CONFIG_DEVICE_PRODUCT_ID}" APPEND) +if(NOT ${CONFIG_DEVICE_PRODUCT_NAME} STREQUAL "") + idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\"${CONFIG_DEVICE_PRODUCT_NAME}\"" APPEND) +endif() if(NOT ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING} STREQUAL "") idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}\"" APPEND) endif() diff --git a/examples/chef/nrfconnect/CMakeLists.txt b/examples/chef/nrfconnect/CMakeLists.txt index a5473bed795eca..4249001f35a0ec 100644 --- a/examples/chef/nrfconnect/CMakeLists.txt +++ b/examples/chef/nrfconnect/CMakeLists.txt @@ -27,14 +27,18 @@ get_filename_component(GEN_DIR ${CHEF}/out/${SAMPLE_NAME}/zap-generated REALPATH set(CONF_FILE prj.conf) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${CONFIG_DEVICE_PRODUCT_ID}") set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID=${CONFIG_DEVICE_VENDOR_ID}") +set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=${CONFIG_DEVICE_PRODUCT_ID}") +if(NOT ${CONFIG_DEVICE_PRODUCT_NAME} STREQUAL "") + set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\"${CONFIG_DEVICE_PRODUCT_NAME}\"") +endif() set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_PLATFORM_NRFCONNECT=1") if(NOT ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING} STREQUAL "") set(CHIP_CFLAGS "${CHIP_CFLAGS} -DCHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}\"") endif() -message(STATUS "Product ID " ${CONFIG_DEVICE_PRODUCT_ID}) message(STATUS "Vendor ID " ${CONFIG_DEVICE_VENDOR_ID}) +message(STATUS "Product ID " ${CONFIG_DEVICE_PRODUCT_ID}) +message(STATUS "Product Name " ${CONFIG_DEVICE_PRODUCT_NAME}) message(STATUS "SW Version String" ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}) # Set Kconfig root files that will be processed as a first Kconfig for used child images. @@ -67,6 +71,7 @@ target_include_directories(app PRIVATE ${CHEF} ${GEN_DIR}/../ ${CHIP_ROOT}/src + ${CHIP_ROOT}/examples/shell/shell_common/include ${NRFCONNECT_COMMON}/util/include ${NRFCONNECT_COMMON}/app/include ) diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp index 0367f01318c88b..ca7d27ae47b332 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.ipp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.ipp @@ -699,6 +699,19 @@ void GenericConfigurationManagerImpl::LogDeviceConfig() ChipLogProgress(DeviceLayer, " Product Id: %u (0x%X)", productId, productId); } + { + char productName[ConfigurationManager::kMaxProductNameLength + 1]; + err = deviceInstanceInfoProvider->GetProductName(productName, sizeof(productName)); + if (CHIP_NO_ERROR == err) + { + ChipLogProgress(DeviceLayer, " Product Name: %s", productName); + } + else + { + ChipLogError(DeviceLayer, " Product Name: n/a (%" CHIP_ERROR_FORMAT ")", err.Format()); + } + } + { uint16_t hardwareVer; if (deviceInstanceInfoProvider->GetHardwareVersion(hardwareVer) != CHIP_NO_ERROR) From 9402e16d318f51d4fa7aa67aee56a12b58d36609 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 13 Feb 2023 09:58:12 -0500 Subject: [PATCH 04/53] Add a sample UI for linux apps - lighting app (#24979) * Initial version of a imgui UI in light app for linux. Also fixed linux app shutdown to handle signals by loop terminating instead of app killing. * remove some fixme comments * Fix unit tests ... with-ui variant was added * Restyle * Update text and remove some commented out code * Restyle --------- Co-authored-by: Andrei Litvin --- .gitmodules | 4 + examples/common/QRCode/BUILD.gn | 5 +- examples/lighting-app/linux/BUILD.gn | 13 + examples/lighting-app/linux/main.cpp | 13 + examples/lighting-app/linux/ui.cpp | 370 ++++++++++++++++++ examples/lighting-app/linux/ui.h | 28 ++ examples/platform/linux/AppMain.cpp | 7 + scripts/build/build/targets.py | 1 + scripts/build/builders/host.py | 4 + .../build/testdata/all_targets_linux_x64.txt | 2 +- third_party/imgui/BUILD.gn | 63 +++ third_party/imgui/imgui.gni | 23 ++ third_party/imgui/repo | 1 + 13 files changed, 532 insertions(+), 2 deletions(-) create mode 100644 examples/lighting-app/linux/ui.cpp create mode 100644 examples/lighting-app/linux/ui.h create mode 100644 third_party/imgui/BUILD.gn create mode 100644 third_party/imgui/imgui.gni create mode 160000 third_party/imgui/repo diff --git a/.gitmodules b/.gitmodules index b10429140c7edc..d9f332d45c1e8a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -289,3 +289,7 @@ path = third_party/libwebsockets/repo url = https://github.com/warmcat/libwebsockets platforms = linux,darwin,tizen +[submodule "third_party/imgui/repo"] + path = third_party/imgui/repo + url = https://github.com/ocornut/imgui + platforms = linux diff --git a/examples/common/QRCode/BUILD.gn b/examples/common/QRCode/BUILD.gn index d7918f55d5433e..b876f484357d0c 100644 --- a/examples/common/QRCode/BUILD.gn +++ b/examples/common/QRCode/BUILD.gn @@ -21,7 +21,10 @@ config("qrcode-common_config") { static_library("QRCode") { output_name = "libqrcode-common" - sources = [ "repo/c/qrcodegen.c" ] + sources = [ + "repo/c/qrcodegen.c", + "repo/c/qrcodegen.h", + ] public_configs = [ ":qrcode-common_config" ] diff --git a/examples/lighting-app/linux/BUILD.gn b/examples/lighting-app/linux/BUILD.gn index 721f408437d7c7..3b20243631b6de 100644 --- a/examples/lighting-app/linux/BUILD.gn +++ b/examples/lighting-app/linux/BUILD.gn @@ -16,6 +16,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/build/chip/tools.gni") import("${chip_root}/src/app/common_flags.gni") +import("${chip_root}/third_party/imgui/imgui.gni") assert(chip_build_tools) @@ -46,6 +47,18 @@ executable("chip-lighting-app") { "${chip_root}/src/lib", ] + if (chip_examples_enable_imgui_ui) { + deps += [ + "${chip_root}/examples/common/QRCode", + "${chip_root}/third_party/imgui", + ] + + sources += [ + "ui.cpp", + "ui.h", + ] + } + include_dirs = [ "include" ] if (chip_enable_pw_rpc) { diff --git a/examples/lighting-app/linux/main.cpp b/examples/lighting-app/linux/main.cpp index 7813c59979c929..a74aa5df4c3059 100644 --- a/examples/lighting-app/linux/main.cpp +++ b/examples/lighting-app/linux/main.cpp @@ -26,6 +26,10 @@ #include #include +#if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED +#include "ui.h" +#endif + using namespace chip; using namespace chip::app; using namespace chip::app::Clusters; @@ -81,7 +85,16 @@ int main(int argc, char * argv[]) } LightingMgr().Init(); + +#if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED + example::Ui::Start(); +#endif + ChipLinuxAppMainLoop(); +#if defined(CHIP_IMGUI_ENABLED) && CHIP_IMGUI_ENABLED + example::Ui::Stop(); +#endif + return 0; } diff --git a/examples/lighting-app/linux/ui.cpp b/examples/lighting-app/linux/ui.cpp new file mode 100644 index 00000000000000..32ff5f401bbe59 --- /dev/null +++ b/examples/lighting-app/linux/ui.cpp @@ -0,0 +1,370 @@ +/* + * Copyright (c) 2023 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. + */ + +#include "ui.h" + +#include // examples/platform/linux/Options.h +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace example { +namespace Ui { + +namespace { + +std::atomic gUiRunning{ false }; + +class DeviceState +{ +public: + DeviceState() { sem_init(&mChipLoopWaitSemaphore, 0 /* shared */, 0); } + ~DeviceState() { sem_destroy(&mChipLoopWaitSemaphore); } + + // Initialize. MUST be called within the CHIP main loop as it + // loads startup data. + void Init(); + + // Use ImgUI to show the current state + void ShowUi(); + + // Fetches the current state from Ember + void UpdateState(); + +private: + static constexpr int kQRCodeVersion = qrcodegen_VERSION_MAX; + static constexpr int kMaxQRBufferSize = qrcodegen_BUFFER_LEN_FOR_VERSION(kQRCodeVersion); + + sem_t mChipLoopWaitSemaphore; + + bool mHasQRCode = false; + uint8_t mQRData[kMaxQRBufferSize] = { 0 }; + + // light data: + bool mOnOff = false; + + // Updates the data (run in the chip event loop) + void ChipLoopUpdate(); + + void InitQRCode(); + + // Run in CHIPMainLoop to access ember in a single threaded + // fashion + static void ChipLoopUpdateCallback(intptr_t self); +}; + +DeviceState gDeviceState; + +void DeviceState::Init() +{ + InitQRCode(); +} + +void DeviceState::InitQRCode() +{ + + chip::PayloadContents payload = LinuxDeviceOptions::GetInstance().payload; + if (!payload.isValidQRCodePayload()) + { + return; + } + + char payloadBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; + chip::MutableCharSpan qrCode(payloadBuffer); + + CHIP_ERROR err = GetQRCode(qrCode, payload); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Failed to load QR code: %" CHIP_ERROR_FORMAT, err.Format()); + return; + } + + if (qrCode.size() > kMaxQRBufferSize) + { + ChipLogError(AppServer, "Insufficient qr code buffer size to encode"); + return; + } + + uint8_t tempAndData[kMaxQRBufferSize]; + memcpy(tempAndData, qrCode.data(), qrCode.size()); + + mHasQRCode = qrcodegen_encodeBinary(tempAndData, qrCode.size(), mQRData, qrcodegen_Ecc_MEDIUM, qrcodegen_VERSION_MIN, + qrcodegen_VERSION_MAX, qrcodegen_Mask_AUTO, true); + + if (!mHasQRCode) + { + ChipLogError(AppServer, "Failed to encode QR code"); + return; + } +} + +inline ImVec2 operator+(const ImVec2 & a, const ImVec2 & b) +{ + return ImVec2(a.x + b.x, a.y + b.y); +} + +void DeviceState::ShowUi() +{ + ImGui::Begin("Light app"); + ImGui::Text("Here is the current ember device state:"); + ImGui::Checkbox("Light is ON", &mOnOff); + ImGui::End(); + + if (mHasQRCode) + { + ImGui::Begin("QR Code."); + + ImDrawList * drawList = ImGui::GetWindowDrawList(); + + constexpr int kBorderSize = 35; + constexpr int kMinWindowSize = 200; + const int kQRCodeSize = qrcodegen_getSize(mQRData); + + ImVec2 pos = ImGui::GetWindowPos(); + ImVec2 size = ImGui::GetWindowSize(); + + if (size.y < kMinWindowSize) + { + size = ImVec2(kMinWindowSize, kMinWindowSize); + ImGui::SetWindowSize(size); + } + + // Fill the entire window white, then figure out borders + drawList->AddRectFilled(pos, pos + size, IM_COL32_WHITE); + + // add a border + if (size.x >= 2 * kBorderSize && size.y >= 2 * kBorderSize) + { + size.x -= 2 * kBorderSize; + size.y -= 2 * kBorderSize; + pos.x += kBorderSize; + pos.y += kBorderSize; + } + + // create a square rectangle: keep only the smaller side and adjust the + // other + if (size.x > size.y) + { + pos.x += (size.x - size.y) / 2; + size.x = size.y; + } + else if (size.y > size.x) + { + pos.y += (size.y - size.x) / 2; + size.y = size.x; + } + + const ImVec2 squareSize = ImVec2(size.x / static_cast(kQRCodeSize), size.y / static_cast(kQRCodeSize)); + + for (int y = 0; y < kQRCodeSize; ++y) + { + for (int x = 0; x < kQRCodeSize; ++x) + { + if (qrcodegen_getModule(mQRData, x, y)) + { + ImVec2 placement = + ImVec2(pos.x + static_cast(x) * squareSize.x, pos.y + static_cast(y) * squareSize.y); + drawList->AddRectFilled(placement, placement + squareSize, IM_COL32_BLACK); + } + } + } + + ImGui::End(); + } +} + +void DeviceState::ChipLoopUpdate() +{ + // This will contain a dimmable light + static constexpr chip::EndpointId kLightEndpointId = 1; + + // TODO: + // - consider error checking + // - add more attributes to the display (color? brightness?) + { + uint8_t value; + emberAfReadServerAttribute(kLightEndpointId, chip::app::Clusters::OnOff::Id, + chip::app::Clusters::OnOff::Attributes::OnOff::Id, &value, sizeof(value)); + mOnOff = (value != 0); + } +} + +void DeviceState::ChipLoopUpdateCallback(intptr_t self) +{ + DeviceState * _this = reinterpret_cast(self); + _this->ChipLoopUpdate(); + sem_post(&_this->mChipLoopWaitSemaphore); // notify complete +} + +void DeviceState::UpdateState() +{ + chip::DeviceLayer::PlatformMgr().ScheduleWork(&ChipLoopUpdateCallback, reinterpret_cast(this)); + // ensure update is done when existing + if (sem_trywait(&mChipLoopWaitSemaphore) != 0) + { + if (!gUiRunning.load()) + { + // UI should stop, no need to wait, probably chip main loop is stopped + return; + } + std::this_thread::yield(); + } +} + +void UiInit(SDL_GLContext * gl_context, SDL_Window ** window) +{ + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMECONTROLLER) != 0) + { + ChipLogError(AppServer, "SDL Init Error: %s\n", SDL_GetError()); + return; + } + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); +#ifdef SDL_HINT_IME_SHOW_UI + SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1"); +#endif + + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); + SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); + SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI); + *window = SDL_CreateWindow("Dear ImGui SDL2+OpenGL3 example", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 720, + window_flags); + *gl_context = SDL_GL_CreateContext(*window); + SDL_GL_MakeCurrent(*window, *gl_context); + SDL_GL_SetSwapInterval(1); // Enable vsync + + // Setup Dear ImGui context + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO & io = ImGui::GetIO(); + (void) io; + // io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls + // io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls + + // Setup Dear ImGui style + ImGui::StyleColorsDark(); + // ImGui::StyleColorsLight(); + + // Setup Platform/Renderer backends + ImGui_ImplSDL2_InitForOpenGL(*window, *gl_context); + ImGui_ImplOpenGL3_Init("#version 130"); +} + +void UiShutdown(SDL_GLContext * gl_context, SDL_Window ** window) +{ + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplSDL2_Shutdown(); + ImGui::DestroyContext(); + + SDL_GL_DeleteContext(*gl_context); + SDL_DestroyWindow(*window); + SDL_Quit(); +} + +void UiLoop() +{ + SDL_GLContext gl_context; + SDL_Window * window = nullptr; + + UiInit(&gl_context, &window); + + ImGuiIO & io = ImGui::GetIO(); + + while (gUiRunning.load()) + { + SDL_Event event; + while (SDL_PollEvent(&event)) + { + ImGui_ImplSDL2_ProcessEvent(&event); + if (event.type == SDL_QUIT) + { + chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); + } + if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && + event.window.windowID == SDL_GetWindowID(window)) + { + chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); + } + } + + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplSDL2_NewFrame(); + ImGui::NewFrame(); + + gDeviceState.UpdateState(); + gDeviceState.ShowUi(); + + // rendering + ImGui::Render(); + glViewport(0, 0, (int) io.DisplaySize.x, (int) io.DisplaySize.y); + glClearColor(0, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + SDL_GL_SwapWindow(window); + } + + UiShutdown(&gl_context, &window); + + ChipLogProgress(AppServer, "UI thread Stopped..."); +} + +static std::thread gUiThread; + +} // namespace + +void Start() +{ + // Init inside the "main" thread, so that it can access globals + // proparly (for QR code and such) + gDeviceState.Init(); + + gUiRunning = true; + std::thread uiThread(&UiLoop); + gUiThread.swap(uiThread); +} + +void Stop() +{ + gUiRunning = false; + gUiThread.join(); +} + +} // namespace Ui +} // namespace example diff --git a/examples/lighting-app/linux/ui.h b/examples/lighting-app/linux/ui.h new file mode 100644 index 00000000000000..85bf2aadf6ba30 --- /dev/null +++ b/examples/lighting-app/linux/ui.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 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. + */ + +#pragma once + +namespace example { +namespace Ui { + +void Start(); + +void Stop(); + +} // namespace Ui +} // namespace example diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index 876e0da8bc3751..05b8066f23bece 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -124,6 +124,11 @@ void Cleanup() // TODO(16968): Lifecycle management of storage-using components like GroupDataProvider, etc } +void StopSignalHandler(int signal) +{ + DeviceLayer::PlatformMgr().StopEventLoopTask(); +} + } // namespace #if CHIP_DEVICE_CONFIG_ENABLE_WPA @@ -389,6 +394,8 @@ void ChipLinuxAppMainLoop() ApplicationInit(); + signal(SIGTERM, StopSignalHandler); + signal(SIGINT, StopSignalHandler); DeviceLayer::PlatformMgr().RunEventLoop(); #if CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 2a6b1701de403e..db7053e9fdb301 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -148,6 +148,7 @@ def BuildHostTarget(): target.AppendModifier('clang', use_clang=True) target.AppendModifier('test', extra_tests=True) target.AppendModifier('rpc', enable_rpcs=True) + target.AppendModifier('with-ui', imgui_ui=True) return target diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index b05a034e41b6d0..b3bfbaa7a326ba 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -229,6 +229,7 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, use_coverage=False, use_dmalloc=False, minmdns_address_policy=None, minmdns_high_verbosity=False, + imgui_ui=False, crypto_library: HostCryptoLibrary = None): super(HostBuilder, self).__init__( root=os.path.join(root, 'examples', app.ExamplePath()), @@ -282,6 +283,9 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, if use_libfuzzer: self.extra_gn_options.append('is_libfuzzer=true') + if imgui_ui: + self.extra_gn_options.append('chip_examples_enable_imgui_ui=true') + self.use_coverage = use_coverage if use_coverage: self.extra_gn_options.append('use_coverage=true') diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index 7b7ae2126f1e85..77c780e3431b98 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -8,7 +8,7 @@ efr32-{brd4161a,brd4187c,brd4163a,brd4164a,brd4166a,brd4170a,brd4186a,brd4187a,b esp32-{m5stack,c3devkit,devkitc,qemu}-{all-clusters,all-clusters-minimal,ota-provider,ota-requestor,shell,light,lock,bridge,temperature-measurement,ota-requestor,tests}[-rpc][-ipv6only] genio-lighting-app linux-fake-tests[-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-coverage][-dmalloc][-clang] -linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,thermostat,java-matter-controller,minmdns,light,lock,shell,ota-provider,ota-requestor,python-bindings,tv-app,tv-casting-app,bridge,dynamic-bridge,tests,chip-cert,address-resolve-tool}[-nodeps][-platform-mdns][-minmdns-verbose][-libnl][-same-event-loop][-no-interactive][-ipv6only][-no-ble][-no-wifi][-no-thread][-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-coverage][-dmalloc][-clang][-test][-rpc] +linux-{x64,arm64}-{rpc-console,all-clusters,all-clusters-minimal,chip-tool,thermostat,java-matter-controller,minmdns,light,lock,shell,ota-provider,ota-requestor,python-bindings,tv-app,tv-casting-app,bridge,dynamic-bridge,tests,chip-cert,address-resolve-tool}[-nodeps][-platform-mdns][-minmdns-verbose][-libnl][-same-event-loop][-no-interactive][-ipv6only][-no-ble][-no-wifi][-no-thread][-mbedtls][-boringssl][-asan][-tsan][-ubsan][-libfuzzer][-coverage][-dmalloc][-clang][-test][-rpc][-with-ui] linux-x64-efr32-test-runner[-clang] imx-{chip-tool,lighting-app,thermostat,all-clusters-app,all-clusters-minimal-app,ota-provider-app}[-release] infineon-psoc6-{lock,light,all-clusters,all-clusters-minimal}[-ota][-updateimage] diff --git a/third_party/imgui/BUILD.gn b/third_party/imgui/BUILD.gn new file mode 100644 index 00000000000000..362e9641fc0091 --- /dev/null +++ b/third_party/imgui/BUILD.gn @@ -0,0 +1,63 @@ +# Copyright (c) 2023 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +config("imgui_config") { + include_dirs = [ + "repo", + "repo/backends", + ] + defines = [ "CHIP_IMGUI_ENABLED=1" ] + + # FUTURE: these should be parsed from `sdl2-config --cflags` + include_dirs += [ "/usr/include/SDL2" ] + defines += [ "_REENTRANT" ] +} + +source_set("imgui") { + sources = [ + "repo/imconfig.h", + "repo/imgui.cpp", + "repo/imgui.h", + "repo/imgui_draw.cpp", + "repo/imgui_internal.h", + "repo/imgui_tables.cpp", + "repo/imgui_widgets.cpp", + "repo/imstb_rectpack.h", + "repo/imstb_textedit.h", + "repo/imstb_truetype.h", + ] + + # SDL2 + OPENGL3 backend enabled directly here since + # the includes are circular (backend includes imgui) + sources += [ + "repo/backends/imgui_impl_opengl3.cpp", + "repo/backends/imgui_impl_opengl3.h", + "repo/backends/imgui_impl_sdl2.cpp", + "repo/backends/imgui_impl_sdl2.h", + ] + + # FUTURE: SDL2 libs should be from `sdl2-config --libs` + # Also different platforms may require different seettings (e.g. on mac this + # seems to need `-framework OpenGl -framework CoreFoundation` + libs = [ + "SDL2", + "GL", + "dl", + ] + + public_configs = [ ":imgui_config" ] +} diff --git a/third_party/imgui/imgui.gni b/third_party/imgui/imgui.gni new file mode 100644 index 00000000000000..6db92047d9747e --- /dev/null +++ b/third_party/imgui/imgui.gni @@ -0,0 +1,23 @@ +# Copyright (c) 2023 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +import("${chip_root}/src/platform/device.gni") + +declare_args() { + # Enable UI functionality for example apps + chip_examples_enable_imgui_ui = false +} diff --git a/third_party/imgui/repo b/third_party/imgui/repo new file mode 160000 index 00000000000000..85395b76b08111 --- /dev/null +++ b/third_party/imgui/repo @@ -0,0 +1 @@ +Subproject commit 85395b76b08111961aa6e0ff026fd5152d48aa15 From af1b471fa9baa73510b42cc1cf331d416ac69e2e Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Mon, 13 Feb 2023 10:04:14 -0500 Subject: [PATCH 05/53] Fix level control print out for strings (#24949) * fix level control logs * restyle --- .../clusters/level-control/level-control.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/app/clusters/level-control/level-control.cpp b/src/app/clusters/level-control/level-control.cpp index 497d3cb718f085..d569bb1a66efb0 100644 --- a/src/app/clusters/level-control/level-control.cpp +++ b/src/app/clusters/level-control/level-control.cpp @@ -348,7 +348,7 @@ static void setOnOffValue(EndpointId endpoint, bool onOff) #ifdef EMBER_AF_PLUGIN_ON_OFF if (emberAfContainsServer(endpoint, OnOff::Id)) { - emberAfLevelControlClusterPrintln("Setting on/off to %p due to level change", onOff ? "ON" : "OFF"); + emberAfLevelControlClusterPrintln("Setting on/off to %s due to level change", onOff ? "ON" : "OFF"); OnOffServer::Instance().setOnOffValue(endpoint, (onOff ? OnOff::Commands::On::Id : OnOff::Commands::Off::Id), true); } #endif // EMBER_AF_PLUGIN_ON_OFF @@ -450,12 +450,12 @@ bool emberAfLevelControlClusterMoveToLevelCallback(app::CommandHandler * command if (transitionTime.IsNull()) { - emberAfLevelControlClusterPrintln("%pMOVE_TO_LEVEL %x null %x %x", "RX level-control:", level, optionsMask.Raw(), + emberAfLevelControlClusterPrintln("%s MOVE_TO_LEVEL %x null %x %x", "RX level-control:", level, optionsMask.Raw(), optionsOverride.Raw()); } else { - emberAfLevelControlClusterPrintln("%pMOVE_TO_LEVEL %x %2x %x %x", "RX level-control:", level, transitionTime.Value(), + emberAfLevelControlClusterPrintln("%s MOVE_TO_LEVEL %x %2x %x %x", "RX level-control:", level, transitionTime.Value(), optionsMask.Raw(), optionsOverride.Raw()); } @@ -480,12 +480,12 @@ bool emberAfLevelControlClusterMoveToLevelWithOnOffCallback(app::CommandHandler if (transitionTime.IsNull()) { - emberAfLevelControlClusterPrintln("%pMOVE_TO_LEVEL_WITH_ON_OFF %x null %x %x", "RX level-control:", level, + emberAfLevelControlClusterPrintln("%s MOVE_TO_LEVEL_WITH_ON_OFF %x null %x %x", "RX level-control:", level, optionsMask.Raw(), optionsOverride.Raw()); } else { - emberAfLevelControlClusterPrintln("%pMOVE_TO_LEVEL_WITH_ON_OFF %x %2x %x %x", "RX level-control:", level, + emberAfLevelControlClusterPrintln("%s MOVE_TO_LEVEL_WITH_ON_OFF %x %2x %x %x", "RX level-control:", level, transitionTime.Value(), optionsMask.Raw(), optionsOverride.Raw()); } @@ -509,12 +509,12 @@ bool emberAfLevelControlClusterMoveCallback(app::CommandHandler * commandObj, co if (rate.IsNull()) { - emberAfLevelControlClusterPrintln("%pMOVE %x null %x %x", "RX level-control:", moveMode, optionsMask.Raw(), + emberAfLevelControlClusterPrintln("%s MOVE %x null %x %x", "RX level-control:", moveMode, optionsMask.Raw(), optionsOverride.Raw()); } else { - emberAfLevelControlClusterPrintln("%pMOVE %x %u %x %x", "RX level-control:", moveMode, rate.Value(), optionsMask.Raw(), + emberAfLevelControlClusterPrintln("%s MOVE %x %u %x %x", "RX level-control:", moveMode, rate.Value(), optionsMask.Raw(), optionsOverride.Raw()); } @@ -533,12 +533,12 @@ bool emberAfLevelControlClusterMoveWithOnOffCallback(app::CommandHandler * comma if (rate.IsNull()) { - emberAfLevelControlClusterPrintln("%pMOVE_WITH_ON_OFF %x null %x %x", "RX level-control:", moveMode, optionsMask.Raw(), + emberAfLevelControlClusterPrintln("%s MOVE_WITH_ON_OFF %x null %x %x", "RX level-control:", moveMode, optionsMask.Raw(), optionsOverride.Raw()); } else { - emberAfLevelControlClusterPrintln("%pMOVE_WITH_ON_OFF %u %2x %x %x", "RX level-control:", moveMode, rate.Value(), + emberAfLevelControlClusterPrintln("%s MOVE_WITH_ON_OFF %u %2x %x %x", "RX level-control:", moveMode, rate.Value(), optionsMask.Raw(), optionsOverride.Raw()); } @@ -558,13 +558,13 @@ bool emberAfLevelControlClusterStepCallback(app::CommandHandler * commandObj, co if (transitionTime.IsNull()) { - emberAfLevelControlClusterPrintln("%pSTEP %x %x null %x %x", "RX level-control:", stepMode, stepSize, optionsMask.Raw(), + emberAfLevelControlClusterPrintln("%s STEP %x %x null %x %x", "RX level-control:", stepMode, stepSize, optionsMask.Raw(), optionsOverride.Raw()); } else { - emberAfLevelControlClusterPrintln("%pSTEP %x %x %2x %x %x", "RX level-control:", stepMode, stepSize, transitionTime.Value(), - optionsMask.Raw(), optionsOverride.Raw()); + emberAfLevelControlClusterPrintln("%s STEP %x %x %2x %x %x", "RX level-control:", stepMode, stepSize, + transitionTime.Value(), optionsMask.Raw(), optionsOverride.Raw()); } stepHandler(commandPath.mEndpointId, Commands::Step::Id, stepMode, stepSize, transitionTime, @@ -583,12 +583,12 @@ bool emberAfLevelControlClusterStepWithOnOffCallback(app::CommandHandler * comma if (transitionTime.IsNull()) { - emberAfLevelControlClusterPrintln("%pSTEP_WITH_ON_OFF %x %x null %x %x", "RX level-control:", stepMode, stepSize, + emberAfLevelControlClusterPrintln("%s STEP_WITH_ON_OFF %x %x null %x %x", "RX level-control:", stepMode, stepSize, optionsMask.Raw(), optionsOverride.Raw()); } else { - emberAfLevelControlClusterPrintln("%pSTEP_WITH_ON_OFF %x %x %2x %x %x", "RX level-control:", stepMode, stepSize, + emberAfLevelControlClusterPrintln("%s STEP_WITH_ON_OFF %x %x %2x %x %x", "RX level-control:", stepMode, stepSize, transitionTime.Value(), optionsMask.Raw(), optionsOverride.Raw()); } @@ -603,7 +603,7 @@ bool emberAfLevelControlClusterStopCallback(app::CommandHandler * commandObj, co auto & optionsMask = commandData.optionsMask; auto & optionsOverride = commandData.optionsOverride; - emberAfLevelControlClusterPrintln("%pSTOP", "RX level-control:"); + emberAfLevelControlClusterPrintln("%s STOP", "RX level-control:"); stopHandler(commandPath.mEndpointId, Commands::Stop::Id, Optional>(optionsMask), Optional>(optionsOverride)); return true; @@ -614,7 +614,7 @@ bool emberAfLevelControlClusterStopWithOnOffCallback(app::CommandHandler * comma { auto & optionsMask = commandData.optionsMask; auto & optionsOverride = commandData.optionsOverride; - emberAfLevelControlClusterPrintln("%pSTOP_WITH_ON_OFF", "RX level-control:"); + emberAfLevelControlClusterPrintln("%s STOP_WITH_ON_OFF", "RX level-control:"); stopHandler(commandPath.mEndpointId, Commands::StopWithOnOff::Id, Optional>(optionsMask), Optional>(optionsOverride)); return true; From ccbef5b083e858dd52d40f9bac6d21207aff9e40 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 10:18:53 -0500 Subject: [PATCH 06/53] Bump third_party/openthread/repo from `eb6377f` to `3d7626f` (#25011) Bumps [third_party/openthread/repo](https://github.com/openthread/openthread) from `eb6377f` to `3d7626f`. - [Release notes](https://github.com/openthread/openthread/releases) - [Commits](https://github.com/openthread/openthread/compare/eb6377f1d7bf6bc7038a76e903af0bdf77c6f99f...3d7626f56097f867d72eec657b8986bd7c4abe8d) --- updated-dependencies: - dependency-name: third_party/openthread/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/openthread/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/openthread/repo b/third_party/openthread/repo index eb6377f1d7bf6b..3d7626f56097f8 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit eb6377f1d7bf6bc7038a76e903af0bdf77c6f99f +Subproject commit 3d7626f56097f867d72eec657b8986bd7c4abe8d From 262b71f666a63278a8455d1911eab68d0b84bc57 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Feb 2023 10:19:10 -0500 Subject: [PATCH 07/53] Bump third_party/mbedtls/repo from `c87dc5f` to `79e0433` (#25010) Bumps [third_party/mbedtls/repo](https://github.com/ARMmbed/mbedtls) from `c87dc5f` to `79e0433`. - [Release notes](https://github.com/ARMmbed/mbedtls/releases) - [Commits](https://github.com/ARMmbed/mbedtls/compare/c87dc5f0155e8e00851f00210cb029e061d776f5...79e0433bf85720b75a263ab874ef8826c384a8b8) --- updated-dependencies: - dependency-name: third_party/mbedtls/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/mbedtls/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index c87dc5f0155e8e..79e0433bf85720 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit c87dc5f0155e8e00851f00210cb029e061d776f5 +Subproject commit 79e0433bf85720b75a263ab874ef8826c384a8b8 From 8612d3c48eba4e2ff03332d1ecc84da2c98722ab Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 13 Feb 2023 10:21:53 -0500 Subject: [PATCH 08/53] Add FingerVein to LockDataTypeEnum. (#24988) Now that https://github.com/CHIP-Specifications/connectedhomeip-spec/pull/6240 is fixed and we have a value defined for it. --- .../all-clusters-common/all-clusters-app.matter | 1 + .../all-clusters-minimal-app.matter | 1 + .../chef/devices/rootnode_doorlock_aNKYAreMXE.matter | 1 + examples/lock-app/lock-common/lock-app.matter | 1 + examples/lock-app/nxp/zap/lock-app.matter | 1 + .../clusters/door-lock-server/door-lock-server.cpp | 5 +++-- .../zcl/data-model/chip/door-lock-cluster.xml | 1 + src/controller/data_model/controller-clusters.matter | 1 + src/controller/python/chip/clusters/Objects.py | 3 ++- src/darwin/Framework/CHIP/templates/availability.yaml | 11 +++++++++++ .../Framework/CHIP/zap-generated/MTRBaseClusters.h | 1 + .../app-common/zap-generated/cluster-enums-check.h | 3 ++- .../app-common/zap-generated/cluster-enums.h | 3 ++- 13 files changed, 28 insertions(+), 5 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index d88a105180764c..e1472b43aa5cf0 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -2134,6 +2134,7 @@ server cluster DoorLock = 257 { kPin = 6; kRfid = 7; kFingerprint = 8; + kFingerVein = 9; } enum LockOperationTypeEnum : ENUM8 { diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index cfedfe8eed5453..34ca3399dfcc31 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -1926,6 +1926,7 @@ server cluster DoorLock = 257 { kPin = 6; kRfid = 7; kFingerprint = 8; + kFingerVein = 9; } enum LockOperationTypeEnum : ENUM8 { diff --git a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter index e7df6f98a88a4c..6523f786491744 100644 --- a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter +++ b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter @@ -1229,6 +1229,7 @@ server cluster DoorLock = 257 { kPin = 6; kRfid = 7; kFingerprint = 8; + kFingerVein = 9; } enum LockOperationTypeEnum : ENUM8 { diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index 73387c9dedeb08..21e16d7bdaa102 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -1547,6 +1547,7 @@ server cluster DoorLock = 257 { kPin = 6; kRfid = 7; kFingerprint = 8; + kFingerVein = 9; } enum LockOperationTypeEnum : ENUM8 { diff --git a/examples/lock-app/nxp/zap/lock-app.matter b/examples/lock-app/nxp/zap/lock-app.matter index cffdb5274b26b8..41807705d58670 100644 --- a/examples/lock-app/nxp/zap/lock-app.matter +++ b/examples/lock-app/nxp/zap/lock-app.matter @@ -1006,6 +1006,7 @@ server cluster DoorLock = 257 { kPin = 6; kRfid = 7; kFingerprint = 8; + kFingerVein = 9; } enum LockOperationTypeEnum : ENUM8 { diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index 9c1b6be44bc0f7..884f7c38cfd1f5 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -3060,9 +3060,10 @@ LockDataTypeEnum DoorLockServer::credentialTypeToLockDataType(CredentialTypeEnum case CredentialTypeEnum::kFingerprint: return LockDataTypeEnum::kFingerprint; case CredentialTypeEnum::kFingerVein: - return LockDataTypeEnum::kFingerprint; + return LockDataTypeEnum::kFingerVein; case CredentialTypeEnum::kFace: - // So far there's no distinct data type for face credentials + // So far there's no distinct data type for face credentials. + // See https://github.com/CHIP-Specifications/connectedhomeip-spec/issues/6272 return LockDataTypeEnum::kUnspecified; case CredentialTypeEnum::kUnknownEnumValue: return LockDataTypeEnum::kUnspecified; diff --git a/src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml index 33c34f855a9994..08ad81e73e7e0a 100644 --- a/src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml @@ -521,6 +521,7 @@ limitations under the License. + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index b51f471244568f..3b1e0f994f72b4 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -2250,6 +2250,7 @@ client cluster DoorLock = 257 { kPin = 6; kRfid = 7; kFingerprint = 8; + kFingerVein = 9; } enum LockOperationTypeEnum : ENUM8 { diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index c14201e263a9b5..492253ff5815fb 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -14748,11 +14748,12 @@ class LockDataTypeEnum(MatterIntEnum): kPin = 0x06 kRfid = 0x07 kFingerprint = 0x08 + kFingerVein = 0x09 # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving and unknown # enum value. This specific should never be transmitted. - kUnknownEnumValue = 9, + kUnknownEnumValue = 10, class LockOperationTypeEnum(MatterIntEnum): kLock = 0x00 diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 656e472aeb75ed..9c858aa64f8d74 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -6651,3 +6651,14 @@ - EventList FaultInjection: - EventList + enum values: + DoorLock: + LockDataTypeEnum: + - FingerVein + removed: + enum values: + DoorLock: + DlLockDataType: + # This value never existed for this enum name so, don't start + # exposing it. It's exposed for LockDataTypeEnum + - FingerVein diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index c97bf537f8e975..29a46c7aa0c3f7 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -20874,6 +20874,7 @@ typedef NS_ENUM(uint8_t, MTRDoorLockLockDataType) { MTRDoorLockLockDataTypePIN API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x06, MTRDoorLockLockDataTypeRFID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x07, MTRDoorLockLockDataTypeFingerprint API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x08, + MTRDoorLockLockDataTypeFingerVein MTR_NEWLY_AVAILABLE = 0x09, } API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); typedef NS_ENUM(uint8_t, MTRDoorLockDlLockDataType) { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index a823faf417234f..f648bcea863766 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -1324,9 +1324,10 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::LockDataTypeE case EnumType::kPin: case EnumType::kRfid: case EnumType::kFingerprint: + case EnumType::kFingerVein: return val; default: - return static_cast(9); + return static_cast(10); } } static auto __attribute__((unused)) EnsureKnownEnumValue(DoorLock::LockOperationTypeEnum val) diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index 47a5293538d1e6..d9e16296348ae0 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -1511,11 +1511,12 @@ enum class LockDataTypeEnum : uint8_t kPin = 0x06, kRfid = 0x07, kFingerprint = 0x08, + kFingerVein = 0x09, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown // enum value. This specific should never be transmitted. - kUnknownEnumValue = 9, + kUnknownEnumValue = 10, }; // Enum for LockOperationTypeEnum From 181aa799ffcb2e4424fdf6eedfb36b9ae51af482 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Mon, 13 Feb 2023 16:31:25 +0100 Subject: [PATCH 09/53] [administrator-commissioning-cluster] Remove StatusCode from weak-enum-list.yaml (#24940) --- .../administrator-commissioning-server.cpp | 43 ++++++++----------- src/app/common/templates/config-data.yaml | 1 - .../zap-generated/cluster-enums-check.h | 8 ---- .../app-common/zap-generated/cluster-enums.h | 7 --- .../app-common/zap-generated/enums.h | 8 ---- 5 files changed, 19 insertions(+), 48 deletions(-) diff --git a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp index b38cc27407965a..67ee2c831c755a 100644 --- a/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp +++ b/src/app/clusters/administrator-commissioning-server/administrator-commissioning-server.cpp @@ -98,36 +98,31 @@ bool emberAfAdministratorCommissioningClusterOpenCommissioningWindowCallback( auto & failSafeContext = Server::GetInstance().GetFailSafeContext(); auto & commissionMgr = Server::GetInstance().GetCommissioningWindowManager(); - VerifyOrExit(fabricInfo != nullptr, status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(failSafeContext.IsFailSafeFullyDisarmed(), status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); - - VerifyOrExit(!commissionMgr.IsCommissioningWindowOpen(), status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); - VerifyOrExit(iterations >= kSpake2p_Min_PBKDF_Iterations, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(iterations <= kSpake2p_Max_PBKDF_Iterations, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(salt.size() >= kSpake2p_Min_PBKDF_Salt_Length, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); - VerifyOrExit(salt.size() <= kSpake2p_Max_PBKDF_Salt_Length, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + VerifyOrExit(fabricInfo != nullptr, status.Emplace(StatusCode::kPAKEParameterError)); + VerifyOrExit(failSafeContext.IsFailSafeFullyDisarmed(), status.Emplace(StatusCode::kBusy)); + + VerifyOrExit(!commissionMgr.IsCommissioningWindowOpen(), status.Emplace(StatusCode::kBusy)); + VerifyOrExit(iterations >= kSpake2p_Min_PBKDF_Iterations, status.Emplace(StatusCode::kPAKEParameterError)); + VerifyOrExit(iterations <= kSpake2p_Max_PBKDF_Iterations, status.Emplace(StatusCode::kPAKEParameterError)); + VerifyOrExit(salt.size() >= kSpake2p_Min_PBKDF_Salt_Length, status.Emplace(StatusCode::kPAKEParameterError)); + VerifyOrExit(salt.size() <= kSpake2p_Max_PBKDF_Salt_Length, status.Emplace(StatusCode::kPAKEParameterError)); VerifyOrExit(commissioningTimeout <= commissionMgr.MaxCommissioningTimeout(), globalStatus = InteractionModel::Status::InvalidCommand); VerifyOrExit(commissioningTimeout >= commissionMgr.MinCommissioningTimeout(), globalStatus = InteractionModel::Status::InvalidCommand); VerifyOrExit(discriminator <= kMaxDiscriminatorValue, globalStatus = InteractionModel::Status::InvalidCommand); - VerifyOrExit(verifier.Deserialize(pakeVerifier) == CHIP_NO_ERROR, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + VerifyOrExit(verifier.Deserialize(pakeVerifier) == CHIP_NO_ERROR, status.Emplace(StatusCode::kPAKEParameterError)); VerifyOrExit(commissionMgr.OpenEnhancedCommissioningWindow(commissioningTimeout, discriminator, verifier, iterations, salt, fabricIndex, fabricInfo->GetVendorId()) == CHIP_NO_ERROR, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + status.Emplace(StatusCode::kPAKEParameterError)); ChipLogProgress(Zcl, "Commissioning window is now open"); exit: if (status.HasValue()) { - ChipLogError(Zcl, "Failed to open commissioning window. Cluster status %d", status.Value()); - commandObj->AddClusterSpecificFailure(commandPath, status.Value()); + ChipLogError(Zcl, "Failed to open commissioning window. Cluster status 0x%02x", to_underlying(status.Value())); + commandObj->AddClusterSpecificFailure(commandPath, to_underlying(status.Value())); } else { @@ -156,24 +151,24 @@ bool emberAfAdministratorCommissioningClusterOpenBasicCommissioningWindowCallbac auto & failSafeContext = Server::GetInstance().GetFailSafeContext(); auto & commissionMgr = Server::GetInstance().GetCommissioningWindowManager(); - VerifyOrExit(fabricInfo != nullptr, status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + VerifyOrExit(fabricInfo != nullptr, status.Emplace(StatusCode::kPAKEParameterError)); - VerifyOrExit(!commissionMgr.IsCommissioningWindowOpen(), status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); - VerifyOrExit(failSafeContext.IsFailSafeFullyDisarmed(), status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_BUSY)); + VerifyOrExit(!commissionMgr.IsCommissioningWindowOpen(), status.Emplace(StatusCode::kBusy)); + VerifyOrExit(failSafeContext.IsFailSafeFullyDisarmed(), status.Emplace(StatusCode::kBusy)); VerifyOrExit(commissioningTimeout <= commissionMgr.MaxCommissioningTimeout(), globalStatus = InteractionModel::Status::InvalidCommand); VerifyOrExit(commissioningTimeout >= commissionMgr.MinCommissioningTimeout(), globalStatus = InteractionModel::Status::InvalidCommand); VerifyOrExit(commissionMgr.OpenBasicCommissioningWindowForAdministratorCommissioningCluster( commissioningTimeout, fabricIndex, fabricInfo->GetVendorId()) == CHIP_NO_ERROR, - status.Emplace(StatusCode::EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR)); + status.Emplace(StatusCode::kPAKEParameterError)); ChipLogProgress(Zcl, "Commissioning window is now open"); exit: if (status.HasValue()) { - ChipLogError(Zcl, "Failed to open commissioning window. Cluster status %d", status.Value()); - commandObj->AddClusterSpecificFailure(commandPath, status.Value()); + ChipLogError(Zcl, "Failed to open commissioning window. Cluster status 0x%02x", to_underlying(status.Value())); + commandObj->AddClusterSpecificFailure(commandPath, to_underlying(status.Value())); } else { @@ -198,7 +193,7 @@ bool emberAfAdministratorCommissioningClusterRevokeCommissioningCallback( if (!Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen()) { ChipLogError(Zcl, "Commissioning window is currently not open"); - commandObj->AddClusterSpecificFailure(commandPath, StatusCode::EMBER_ZCL_STATUS_CODE_WINDOW_NOT_OPEN); + commandObj->AddClusterSpecificFailure(commandPath, to_underlying(StatusCode::kWindowNotOpen)); } else { diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 063eadbb48e800..d21325e2ba812b 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -36,7 +36,6 @@ WeakEnums: - SaturationMoveMode - SaturationStepMode - SecurityType - - StatusCode - StepMode - TemperatureDisplayMode - WiFiVersionType diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index f648bcea863766..612c1653ca5f65 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -1034,17 +1034,9 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(AdministratorCommission using EnumType = AdministratorCommissioning::StatusCode; switch (val) { -// Need to convert consumers to using the new enum classes, so we -// don't just have casts all over. -#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM case EnumType::kBusy: case EnumType::kPAKEParameterError: case EnumType::kWindowNotOpen: -#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM - case EMBER_ZCL_STATUS_CODE_BUSY: - case EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR: - case EMBER_ZCL_STATUS_CODE_WINDOW_NOT_OPEN: -#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM return val; default: return static_cast(0); diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index d9e16296348ae0..1d02c01f3c0566 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -1192,9 +1192,6 @@ enum class CommissioningWindowStatusEnum : uint8_t kUnknownEnumValue = 3, }; -// Need to convert consumers to using the new enum classes, so we -// don't just have casts all over. -#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM // Enum for StatusCode enum class StatusCode : uint8_t { @@ -1207,10 +1204,6 @@ enum class StatusCode : uint8_t // enum value. This specific should never be transmitted. kUnknownEnumValue = 0, }; -#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using StatusCode = EmberAfStatusCode; -static StatusCode __attribute__((unused)) kStatusCodekUnknownEnumValue = static_cast(0); -#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM } // namespace AdministratorCommissioning namespace OperationalCredentials { diff --git a/zzz_generated/app-common/app-common/zap-generated/enums.h b/zzz_generated/app-common/app-common/zap-generated/enums.h index b1ef3423aeca0f..a80c53d062358e 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -269,14 +269,6 @@ enum EmberAfSecurityType : uint8_t EMBER_ZCL_SECURITY_TYPE_WPA3 = 5, }; -// Enum for StatusCode -enum EmberAfStatusCode : uint8_t -{ - EMBER_ZCL_STATUS_CODE_BUSY = 2, - EMBER_ZCL_STATUS_CODE_PAKE_PARAMETER_ERROR = 3, - EMBER_ZCL_STATUS_CODE_WINDOW_NOT_OPEN = 4, -}; - // Enum for StepMode enum EmberAfStepMode : uint8_t { From a6701d9941b6e5d7e0297c6b23bbf70a42b01f4b Mon Sep 17 00:00:00 2001 From: Jeonghwan Kim Date: Tue, 14 Feb 2023 00:38:56 +0900 Subject: [PATCH 10/53] [Android] Update Subscribe UI update to clarify options (#24460) * [Android] Update Subscribe UI update to clarify options * Make Dropbox Menu(Spinner) to clarify select options ('Keep Subscription' and 'is Fabric Filter') * [Android] Handle Crash when interval is empty and modify variable name * Handle Crash when interval * modify variable name --- .../clusterclient/WildcardFragment.kt | 20 +++++++--- .../app/src/main/res/layout/read_dialog.xml | 4 +- .../src/main/res/layout/subscribe_dialog.xml | 40 +++++++++++++++---- .../app/src/main/res/values/arrays.xml | 6 ++- 4 files changed, 54 insertions(+), 16 deletions(-) diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt index a0db80097b12b5..78af22e76fe742 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt @@ -8,12 +8,12 @@ import android.view.View import android.view.ViewGroup import android.widget.Button import android.widget.EditText +import android.widget.Spinner import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import chip.devicecontroller.ChipDeviceController import chip.devicecontroller.ChipIdLookup import chip.devicecontroller.ReportCallback -import chip.devicecontroller.ReportEventCallback import chip.devicecontroller.ResubscriptionAttemptCallback import chip.devicecontroller.SubscriptionEstablishedCallback import chip.devicecontroller.model.ChipAttributePath @@ -186,7 +186,7 @@ class WildcardFragment : Fragment() { setView(dialogView) }.create() - val isFabricFilteredEd = dialogView.findViewById(R.id.isFabricFilteredEd) + val isFabricFilteredEd = dialogView.findViewById(R.id.isFabricFilteredSp) dialogView.findViewById