From 050b64fd462423cb370a583326a624c07705a0b3 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Mon, 13 Dec 2021 16:51:03 -0800 Subject: [PATCH] Implement user lable cluser server callback --- .../all-clusters-common/all-clusters-app.zap | 51 ++++++++++ .../esp32/main/CMakeLists.txt | 3 +- examples/all-clusters-app/mbed/CMakeLists.txt | 1 + .../bridge-app/bridge-common/bridge-app.zap | 51 ++++++++++ examples/bridge-app/esp32/main/CMakeLists.txt | 1 + .../lighting-common/lighting-app.zap | 51 ++++++++++ examples/lighting-app/mbed/CMakeLists.txt | 1 + examples/lighting-app/telink/CMakeLists.txt | 1 + examples/lock-app/esp32/main/CMakeLists.txt | 4 +- examples/lock-app/lock-common/lock-app.zap | 51 ++++++++++ examples/lock-app/mbed/CMakeLists.txt | 1 + .../esp32/main/CMakeLists.txt | 1 + .../ota-provider-common/ota-provider-app.zap | 51 ++++++++++ .../esp32/main/CMakeLists.txt | 1 + .../ota-requestor-app.zap | 51 ++++++++++ examples/pump-app/pump-common/pump-app.zap | 51 ++++++++++ .../pump-controller-app.zap | 51 ++++++++++ .../esp32/main/CMakeLists.txt | 1 + .../esp32/main/temperature-measurement.zap | 51 ++++++++++ .../thermostat-common/thermostat.zap | 51 ++++++++++ examples/tv-app/tv-common/tv-app.zap | 51 ++++++++++ .../tv-casting-common/tv-casting-app.zap | 51 ++++++++++ examples/window-app/common/window-app.zap | 51 ++++++++++ .../fixed-label-server/fixed-label-server.cpp | 2 +- .../user-label-server/user-label-server.cpp | 99 +++++++++++++++++++ .../tests/suites/TestDescriptorCluster.yaml | 1 + src/app/util/util.cpp | 1 - src/app/zap_cluster_list.py | 2 +- .../data_model/controller-clusters.zap | 51 ++++++++++ src/include/platform/LabelList.h | 54 +++++----- src/include/platform/PlatformManager.h | 16 ++- .../internal/GenericPlatformManagerImpl.h | 16 ++- src/platform/Linux/PlatformManagerImpl.cpp | 33 ++++++- src/platform/Linux/PlatformManagerImpl.h | 5 +- src/platform/fake/PlatformManagerImpl.h | 10 +- 35 files changed, 928 insertions(+), 40 deletions(-) create mode 100644 src/app/clusters/user-label-server/user-label-server.cpp diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 1f0fceb2f5e542..9b82a1c065a12c 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -4430,6 +4430,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Door Lock", "code": 257, diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 38b3240b3a0d14..6e5deacb0edf4e 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -36,7 +36,8 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/application-basic-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/test-cluster-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/on-off-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/level-control" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index 8116c17ec7be00..cb3fec04753396 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -103,6 +103,7 @@ target_sources(${APP_TARGET} PRIVATE ${APP_CLUSTERS}/descriptor/descriptor.cpp ${APP_CLUSTERS}/door-lock-server/door-lock-server.cpp ${APP_CLUSTERS}/fixed-label-server/fixed-label-server.cpp + ${APP_CLUSTERS}/user-label-server/user-label-server.cpp ${APP_CLUSTERS}/general-commissioning-server/general-commissioning-server.cpp ${APP_CLUSTERS}/groups-server/groups-server.cpp ${APP_CLUSTERS}/ias-zone-server/ias-zone-server.cpp diff --git a/examples/bridge-app/bridge-common/bridge-app.zap b/examples/bridge-app/bridge-common/bridge-app.zap index ccc70459f8a9e4..752bb80bb1505e 100644 --- a/examples/bridge-app/bridge-common/bridge-app.zap +++ b/examples/bridge-app/bridge-common/bridge-app.zap @@ -3009,6 +3009,57 @@ "reportableChange": 0 } ] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] } ] }, diff --git a/examples/bridge-app/esp32/main/CMakeLists.txt b/examples/bridge-app/esp32/main/CMakeLists.txt index a5f68e764ed8c7..4587054f593b5c 100644 --- a/examples/bridge-app/esp32/main/CMakeLists.txt +++ b/examples/bridge-app/esp32/main/CMakeLists.txt @@ -31,6 +31,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${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/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" diff --git a/examples/lighting-app/lighting-common/lighting-app.zap b/examples/lighting-app/lighting-common/lighting-app.zap index 532b6154c9e573..94dcee9b9675be 100644 --- a/examples/lighting-app/lighting-common/lighting-app.zap +++ b/examples/lighting-app/lighting-common/lighting-app.zap @@ -4017,6 +4017,57 @@ "reportableChange": 0 } ] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] } ] }, diff --git a/examples/lighting-app/mbed/CMakeLists.txt b/examples/lighting-app/mbed/CMakeLists.txt index 8f99e04be9a39e..bc11cc1b1e0e07 100644 --- a/examples/lighting-app/mbed/CMakeLists.txt +++ b/examples/lighting-app/mbed/CMakeLists.txt @@ -81,6 +81,7 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp ${CHIP_ROOT}/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/fixed-label-server/fixed-label-server.cpp + ${CHIP_ROOT}/src/app/clusters/user-label-server/user-label-server.cpp ${CHIP_ROOT}/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/software-diagnostics-server/software-diagnostics-server.cpp diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index cd989b2931b1c5..e1a2865c22ebe0 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -81,6 +81,7 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp ${CHIP_ROOT}/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/fixed-label-server/fixed-label-server.cpp + ${CHIP_ROOT}/src/app/clusters/user-label-server/user-label-server.cpp ${CHIP_ROOT}/src/app/clusters/thread-network-diagnostics-server/thread-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/wifi-network-diagnostics-server/wifi-network-diagnostics-server.cpp ${CHIP_ROOT}/src/app/clusters/software-diagnostics-server/software-diagnostics-server.cpp diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index 0fad08b3acbf83..fbca6b270d9315 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -54,7 +54,8 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" PRIV_REQUIRES bt chip QRCode) get_filename_component(CHIP_ROOT ../third_party/connectedhomeip REALPATH) @@ -146,6 +147,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/power-source-configuration-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" PRIV_REQUIRES chip QRCode bt) set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap index 4b063f34f452c4..f578fd674bc29e 100644 --- a/examples/lock-app/lock-common/lock-app.zap +++ b/examples/lock-app/lock-common/lock-app.zap @@ -3977,6 +3977,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Occupancy Sensing", "code": 1030, diff --git a/examples/lock-app/mbed/CMakeLists.txt b/examples/lock-app/mbed/CMakeLists.txt index a4864ee6fd4c88..30b0e3651e9e16 100644 --- a/examples/lock-app/mbed/CMakeLists.txt +++ b/examples/lock-app/mbed/CMakeLists.txt @@ -89,6 +89,7 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off-server.cpp ${CHIP_ROOT}/src/app/clusters/power-source-configuration-server/power-source-configuration-server.cpp + ${CHIP_ROOT}/src/app/clusters/user-label-server/user-label-server.cpp ) target_link_libraries(${APP_TARGET} mbed-os-posix-socket mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip) diff --git a/examples/ota-provider-app/esp32/main/CMakeLists.txt b/examples/ota-provider-app/esp32/main/CMakeLists.txt index 5f3c6b6fee0ad2..a25dde36db364e 100644 --- a/examples/ota-provider-app/esp32/main/CMakeLists.txt +++ b/examples/ota-provider-app/esp32/main/CMakeLists.txt @@ -35,6 +35,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${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/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" diff --git a/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap b/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap index e1682c08c8b3fd..0e83a9e108bcbe 100644 --- a/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap +++ b/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap @@ -1813,6 +1813,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Door Lock", "code": 257, diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index a1b516aa80d958..8fb4bddfe2c230 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -35,6 +35,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${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/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" diff --git a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap index 9adc31407ad272..562c31df99298c 100644 --- a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap +++ b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap @@ -1852,6 +1852,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Door Lock", "code": 257, diff --git a/examples/pump-app/pump-common/pump-app.zap b/examples/pump-app/pump-common/pump-app.zap index d7d9e3257980d3..fd0115915980d8 100644 --- a/examples/pump-app/pump-common/pump-app.zap +++ b/examples/pump-app/pump-common/pump-app.zap @@ -3753,6 +3753,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Pump Configuration and Control", "code": 512, diff --git a/examples/pump-controller-app/pump-controller-common/pump-controller-app.zap b/examples/pump-controller-app/pump-controller-common/pump-controller-app.zap index 4ec221dcb73d3a..704e347a2bc1c8 100644 --- a/examples/pump-controller-app/pump-controller-common/pump-controller-app.zap +++ b/examples/pump-controller-app/pump-controller-common/pump-controller-app.zap @@ -3753,6 +3753,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Pump Configuration and Control", "code": 512, diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index 201e04dfdd933c..6d8637cd18caf2 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -35,6 +35,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${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/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" diff --git a/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap b/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap index fa11646db002fb..b60856faaa8232 100644 --- a/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap +++ b/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap @@ -2365,6 +2365,57 @@ "reportableChange": 0 } ] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] } ] }, diff --git a/examples/thermostat/thermostat-common/thermostat.zap b/examples/thermostat/thermostat-common/thermostat.zap index d3557c4c848ddf..063efbc6075ea5 100644 --- a/examples/thermostat/thermostat-common/thermostat.zap +++ b/examples/thermostat/thermostat-common/thermostat.zap @@ -4165,6 +4165,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Door Lock", "code": 257, diff --git a/examples/tv-app/tv-common/tv-app.zap b/examples/tv-app/tv-common/tv-app.zap index 781836187c7ce8..782c98d7fca93b 100644 --- a/examples/tv-app/tv-common/tv-app.zap +++ b/examples/tv-app/tv-common/tv-app.zap @@ -4180,6 +4180,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Door Lock", "code": 257, diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap index 15959e5b9cf8e5..ae8d70b000b154 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap @@ -4165,6 +4165,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Door Lock", "code": 257, diff --git a/examples/window-app/common/window-app.zap b/examples/window-app/common/window-app.zap index 52c5c43f463608..4cf527075c1a45 100644 --- a/examples/window-app/common/window-app.zap +++ b/examples/window-app/common/window-app.zap @@ -3758,6 +3758,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Window Covering", "code": 258, diff --git a/src/app/clusters/fixed-label-server/fixed-label-server.cpp b/src/app/clusters/fixed-label-server/fixed-label-server.cpp index 0713999752fba5..fb57d67f24b4f5 100644 --- a/src/app/clusters/fixed-label-server/fixed-label-server.cpp +++ b/src/app/clusters/fixed-label-server/fixed-label-server.cpp @@ -53,7 +53,7 @@ class FixedLabelAttrAccess : public AttributeAccessInterface CHIP_ERROR FixedLabelAttrAccess::ReadLabelList(EndpointId endpoint, AttributeValueEncoder & aEncoder) { CHIP_ERROR err = CHIP_NO_ERROR; - DeviceLayer::LabelList labelList; + DeviceLayer::LabelList labelList; if (DeviceLayer::PlatformMgr().GetFixedLabelList(endpoint, labelList) == CHIP_NO_ERROR) { diff --git a/src/app/clusters/user-label-server/user-label-server.cpp b/src/app/clusters/user-label-server/user-label-server.cpp new file mode 100644 index 00000000000000..d5caa4b83e6c59 --- /dev/null +++ b/src/app/clusters/user-label-server/user-label-server.cpp @@ -0,0 +1,99 @@ +/* + * + * Copyright (c) 2021 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. + */ + +/**************************************************************************** + * @file + * @brief Implementation for the User Label Server Cluster + ***************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::UserLabel; +using namespace chip::app::Clusters::UserLabel::Attributes; + +namespace { + +class UserLabelAttrAccess : public AttributeAccessInterface +{ +public: + // Register for the User Label cluster on all endpoints. + UserLabelAttrAccess() : AttributeAccessInterface(Optional::Missing(), UserLabel::Id) {} + + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + +private: + CHIP_ERROR ReadLabelList(EndpointId endpoint, AttributeValueEncoder & aEncoder); +}; + +CHIP_ERROR UserLabelAttrAccess::ReadLabelList(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + DeviceLayer::LabelList labelList; + + if (DeviceLayer::PlatformMgr().GetUserLabelList(endpoint, labelList) == CHIP_NO_ERROR) + { + err = aEncoder.EncodeList([&labelList](const auto & encoder) -> CHIP_ERROR { + for (auto label : labelList) + { + ReturnErrorOnFailure(encoder.Encode(label)); + } + + return CHIP_NO_ERROR; + }); + } + else + { + err = aEncoder.Encode(DataModel::List()); + } + + return err; +} + +UserLabelAttrAccess gAttrAccess; + +CHIP_ERROR UserLabelAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + VerifyOrDie(aPath.mClusterId == UserLabel::Id); + + switch (aPath.mAttributeId) + { + case LabelList::Id: { + return ReadLabelList(aPath.mEndpointId, aEncoder); + } + default: { + break; + } + } + return CHIP_NO_ERROR; +} +} // anonymous namespace + +void MatterUserLabelPluginServerInitCallback(void) +{ + registerAttributeAccessOverride(&gAttrAccess); +} diff --git a/src/app/tests/suites/TestDescriptorCluster.yaml b/src/app/tests/suites/TestDescriptorCluster.yaml index 4523d04f1bc4da..bdf73fc21717cc 100644 --- a/src/app/tests/suites/TestDescriptorCluster.yaml +++ b/src/app/tests/suites/TestDescriptorCluster.yaml @@ -55,6 +55,7 @@ tests: 0x003E, # Operational Credentials 0x003F, # Group Key Management 0x0040, # Fixed Label + 0x0041, # User Label 0x0405, # Relative Humidity Measurement (why on EP0?) ] diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index 715762b473a5f6..4f44413a853b4d 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -318,7 +318,6 @@ void MatterPollControlPluginServerInitCallback() {} void MatterLocalizationConfigurationPluginServerInitCallback() {} void MatterLocalizationUnitPluginServerInitCallback() {} void MatterLocalizationTimeFormatPluginServerInitCallback() {} -void MatterUserLabelPluginServerInitCallback() {} void MatterTimeSynchronizationPluginServerInitCallback() {} void MatterProxyValidPluginServerInitCallback() {} void MatterProxyDiscoveryPluginServerInitCallback() {} diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index e3acf5c64a747c..990d882af6dae9 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -82,7 +82,7 @@ 'TIME_CLUSTER': [], 'TIME_SYNCHRONIZATION_CLUSTER': [], 'TV_CHANNEL_CLUSTER': ['tv-channel-server'], - 'USER_LABEL_CLUSTER': [], + 'USER_LABEL_CLUSTER': ['user-label-server'], 'WAKE_ON_LAN_CLUSTER': [], 'WIFI_NETWORK_DIAGNOSTICS_CLUSTER': ['wifi-network-diagnostics-server'], 'WINDOW_COVERING_CLUSTER': ['window-covering-server'], diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index dbe87f36aefe45..cd2ee0e48eb350 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -6284,6 +6284,57 @@ } ] }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [], + "attributes": [] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Boolean State", "code": 69, diff --git a/src/include/platform/LabelList.h b/src/include/platform/LabelList.h index 4d610e413c4747..98096441db0ab6 100644 --- a/src/include/platform/LabelList.h +++ b/src/include/platform/LabelList.h @@ -31,7 +31,7 @@ namespace DeviceLayer { static constexpr size_t kMaxFixedLabels = 10; static constexpr size_t kMaxUserLabels = 10; -template +template class LabelList { public: @@ -39,13 +39,13 @@ class LabelList class Iterator { public: - Iterator(const LabelList * LabelList, int index); - app::Clusters::FixedLabel::Structs::LabelStruct::Type operator*() const; + Iterator(const LabelList * LabelList, int index); + T operator*() const; Iterator & operator++(); bool operator!=(const Iterator & other) const; private: - const LabelList * mLabelListPtr; + const LabelList * mLabelListPtr; int mIndex = -1; }; @@ -53,24 +53,24 @@ class LabelList LabelList() = default; ~LabelList() { mSize = 0; } - CHIP_ERROR add(const app::Clusters::FixedLabel::Structs::LabelStruct::Type & label); + CHIP_ERROR add(const T & label); size_t size() const; - const app::Clusters::FixedLabel::Structs::LabelStruct::Type & operator[](int index) const; + const T & operator[](int index) const; Iterator begin() const; Iterator end() const; private: - app::Clusters::FixedLabel::Structs::LabelStruct::Type mList[N]; + T mList[N]; int mSize = 0; }; /* * LabelList methods **/ -template -inline CHIP_ERROR LabelList::add(const app::Clusters::FixedLabel::Structs::LabelStruct::Type & label) +template +inline CHIP_ERROR LabelList::add(const T & label) { if (mSize == N) { @@ -83,53 +83,53 @@ inline CHIP_ERROR LabelList::add(const app::Clusters::FixedLabel::Structs::La return CHIP_NO_ERROR; } -template -inline size_t LabelList::size() const +template +inline size_t LabelList::size() const { return static_cast(mSize); } -template -inline const app::Clusters::FixedLabel::Structs::LabelStruct::Type & LabelList::operator[](int index) const +template +inline const T & LabelList::operator[](int index) const { VerifyOrDie(index < mSize); return mList[index]; } -template -inline typename LabelList::Iterator LabelList::begin() const +template +inline typename LabelList::Iterator LabelList::begin() const { - return LabelList::Iterator{ this, 0 }; + return LabelList::Iterator{ this, 0 }; } -template -inline typename LabelList::Iterator LabelList::end() const +template +inline typename LabelList::Iterator LabelList::end() const { - return LabelList::Iterator{ this, mSize }; + return LabelList::Iterator{ this, mSize }; } /* * Iterator methods **/ -template -inline LabelList::Iterator::Iterator(const LabelList * pLabelList, int index) : mLabelListPtr(pLabelList), mIndex(index) +template +inline LabelList::Iterator::Iterator(const LabelList * pLabelList, int index) : mLabelListPtr(pLabelList), mIndex(index) {} -template -inline app::Clusters::FixedLabel::Structs::LabelStruct::Type LabelList::Iterator::operator*() const +template +inline T LabelList::Iterator::operator*() const { return mLabelListPtr->operator[](mIndex); } -template -inline typename LabelList::Iterator & LabelList::Iterator::operator++() +template +inline typename LabelList::Iterator & LabelList::Iterator::operator++() { ++mIndex; return *this; } -template -inline bool LabelList::Iterator::operator!=(const LabelList::Iterator & other) const +template +inline bool LabelList::Iterator::operator!=(const LabelList::Iterator & other) const { return mIndex != other.mIndex; } diff --git a/src/include/platform/PlatformManager.h b/src/include/platform/PlatformManager.h index 9a80002490af87..b90a6098939bb3 100644 --- a/src/include/platform/PlatformManager.h +++ b/src/include/platform/PlatformManager.h @@ -180,7 +180,10 @@ class PlatformManager bool IsChipStackLockedByCurrentThread() const; #endif - CHIP_ERROR GetFixedLabelList(EndpointId endpoint, LabelList & labelList); + CHIP_ERROR GetFixedLabelList(EndpointId endpoint, + LabelList & labelList); + CHIP_ERROR GetUserLabelList(EndpointId endpoint, + LabelList & labelList); private: bool mInitialized = false; @@ -424,10 +427,19 @@ inline CHIP_ERROR PlatformManager::StartChipTimer(System::Clock::Timeout duratio return static_cast(this)->_StartChipTimer(duration); } -inline CHIP_ERROR PlatformManager::GetFixedLabelList(EndpointId endpoint, LabelList & labelList) +inline CHIP_ERROR +PlatformManager::GetFixedLabelList(EndpointId endpoint, + LabelList & labelList) { return static_cast(this)->_GetFixedLabelList(endpoint, labelList); } +inline CHIP_ERROR +PlatformManager::GetUserLabelList(EndpointId endpoint, + LabelList & labelList) +{ + return static_cast(this)->_GetUserLabelList(endpoint, labelList); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/include/platform/internal/GenericPlatformManagerImpl.h b/src/include/platform/internal/GenericPlatformManagerImpl.h index 890deb1140ac62..d4444dfa987430 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl.h +++ b/src/include/platform/internal/GenericPlatformManagerImpl.h @@ -58,7 +58,10 @@ class GenericPlatformManagerImpl void _ScheduleWork(AsyncWorkFunct workFunct, intptr_t arg); void _DispatchEvent(const ChipDeviceEvent * event); - CHIP_ERROR _GetFixedLabelList(EndpointId endpoint, LabelList & labelList); + CHIP_ERROR _GetFixedLabelList(EndpointId endpoint, + LabelList & labelList); + CHIP_ERROR _GetUserLabelList(EndpointId endpoint, + LabelList & labelList); // ===== Support methods that can be overridden by the implementation subclass. @@ -76,8 +79,15 @@ class GenericPlatformManagerImpl extern template class GenericPlatformManagerImpl; template -inline CHIP_ERROR GenericPlatformManagerImpl::_GetFixedLabelList(EndpointId endpoint, - LabelList & labelList) +inline CHIP_ERROR GenericPlatformManagerImpl::_GetFixedLabelList( + EndpointId endpoint, LabelList & labelList) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} + +template +inline CHIP_ERROR GenericPlatformManagerImpl::_GetUserLabelList( + EndpointId endpoint, LabelList & labelList) { return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } diff --git a/src/platform/Linux/PlatformManagerImpl.cpp b/src/platform/Linux/PlatformManagerImpl.cpp index 0f1a6db420d5f4..574a8ce58fd632 100644 --- a/src/platform/Linux/PlatformManagerImpl.cpp +++ b/src/platform/Linux/PlatformManagerImpl.cpp @@ -268,7 +268,8 @@ CHIP_ERROR PlatformManagerImpl::_Shutdown() return Internal::GenericPlatformManagerImpl_POSIX::_Shutdown(); } -CHIP_ERROR PlatformManagerImpl::_GetFixedLabelList(EndpointId endpoint, LabelList & labelList) +CHIP_ERROR PlatformManagerImpl::_GetFixedLabelList( + EndpointId endpoint, LabelList & labelList) { // In Linux simulation, return following hardcoded labelList on all endpoints. FixedLabel::Structs::LabelStruct::Type room; @@ -296,6 +297,36 @@ CHIP_ERROR PlatformManagerImpl::_GetFixedLabelList(EndpointId endpoint, LabelLis return CHIP_NO_ERROR; } +CHIP_ERROR +PlatformManagerImpl::_GetUserLabelList(EndpointId endpoint, + LabelList & labelList) +{ + // In Linux simulation, return following hardcoded labelList on all endpoints. + UserLabel::Structs::LabelStruct::Type room; + UserLabel::Structs::LabelStruct::Type orientation; + UserLabel::Structs::LabelStruct::Type floor; + UserLabel::Structs::LabelStruct::Type direction; + + room.label = CharSpan("room", strlen("room")); + room.value = CharSpan("bedroom 2", strlen("bedroom 2")); + + orientation.label = CharSpan("orientation", strlen("orientation")); + orientation.value = CharSpan("North", strlen("North")); + + floor.label = CharSpan("floor", strlen("floor")); + floor.value = CharSpan("2", strlen("2")); + + direction.label = CharSpan("direction", strlen("direction")); + direction.value = CharSpan("up", strlen("up")); + + labelList.add(room); + labelList.add(orientation); + labelList.add(floor); + labelList.add(direction); + + return CHIP_NO_ERROR; +} + void PlatformManagerImpl::HandleDeviceRebooted(intptr_t arg) { PlatformManagerDelegate * platformManagerDelegate = PlatformMgr().GetDelegate(); diff --git a/src/platform/Linux/PlatformManagerImpl.h b/src/platform/Linux/PlatformManagerImpl.h index 884f2e135f5cd1..a3017e97029c5b 100644 --- a/src/platform/Linux/PlatformManagerImpl.h +++ b/src/platform/Linux/PlatformManagerImpl.h @@ -64,7 +64,10 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener CHIP_ERROR _InitChipStack(); CHIP_ERROR _Shutdown(); - CHIP_ERROR _GetFixedLabelList(EndpointId endpoint, LabelList & labelList); + CHIP_ERROR _GetFixedLabelList(EndpointId endpoint, + LabelList & labelList); + CHIP_ERROR _GetUserLabelList(EndpointId endpoint, + LabelList & labelList); // ===== Members for internal use by the following friends. diff --git a/src/platform/fake/PlatformManagerImpl.h b/src/platform/fake/PlatformManagerImpl.h index 27694219c3259e..204b49e176e221 100644 --- a/src/platform/fake/PlatformManagerImpl.h +++ b/src/platform/fake/PlatformManagerImpl.h @@ -97,7 +97,15 @@ class PlatformManagerImpl final : public PlatformManager } CHIP_ERROR _StartChipTimer(System::Clock::Timeout duration) { return CHIP_ERROR_NOT_IMPLEMENTED; } - CHIP_ERROR _GetFixedLabelList(EndpointId endpoint, LabelList & labelList) + + CHIP_ERROR _GetFixedLabelList(EndpointId endpoint, + LabelList & labelList) + { + return CHIP_ERROR_NOT_IMPLEMENTED; + } + + CHIP_ERROR _GetUserLabelList(EndpointId endpoint, + LabelList & labelList) { return CHIP_ERROR_NOT_IMPLEMENTED; }