Apply Upstream code (2021-04-06)
authorJihoon Jung <jh8801.jung@samsung.com>
Mon, 5 Apr 2021 23:21:59 +0000 (08:21 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Mon, 5 Apr 2021 23:22:36 +0000 (08:22 +0900)
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
298 files changed:
build/chip/chip_test.gni
build/chip/chip_test_group.gni
build/chip/chip_test_suite.gni
build/config/compiler/BUILD.gn
config/nrfconnect/.nrfconnect-recommended-revision
config/nrfconnect/app/release.conf
config/nrfconnect/app/sample-defaults.conf
config/nrfconnect/chip-module/CMakeLists.txt
config/nrfconnect/chip-module/Kconfig
docs/Doxyfile
docs/guides/nxp_k32w_android_commissioning.md
examples/all-clusters-app/all-clusters-common/BUILD.gn
examples/all-clusters-app/all-clusters-common/gen/af-structs.h
examples/all-clusters-app/all-clusters-common/gen/attribute-id.h
examples/all-clusters-app/all-clusters-common/gen/attribute-size.h
examples/all-clusters-app/all-clusters-common/gen/attribute-type.h
examples/all-clusters-app/all-clusters-common/gen/cluster-id.h
examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h
examples/all-clusters-app/all-clusters-common/gen/print-cluster.h
examples/all-clusters-app/esp32/main/component.mk
examples/all-clusters-app/esp32/main/main.cpp
examples/bridge-app/bridge-common/gen/af-structs.h
examples/bridge-app/bridge-common/gen/attribute-id.h
examples/bridge-app/bridge-common/gen/attribute-size.h
examples/bridge-app/bridge-common/gen/attribute-type.h
examples/bridge-app/bridge-common/gen/client-command-macro.h
examples/bridge-app/bridge-common/gen/cluster-id.h
examples/bridge-app/bridge-common/gen/command-id.h
examples/bridge-app/bridge-common/gen/endpoint_config.h
examples/bridge-app/bridge-common/gen/print-cluster.h
examples/bridge-app/linux/main.cpp
examples/chip-tool/gen/af-structs.h
examples/chip-tool/gen/attribute-id.h
examples/chip-tool/gen/attribute-size.h
examples/chip-tool/gen/attribute-type.h
examples/chip-tool/gen/cluster-id.h
examples/chip-tool/gen/endpoint_config.h
examples/chip-tool/gen/print-cluster.h
examples/lighting-app/efr32/BUILD.gn
examples/lighting-app/efr32/README.md
examples/lighting-app/efr32/include/AppConfig.h
examples/lighting-app/efr32/include/AppTask.h
examples/lighting-app/efr32/include/CHIPProjectConfig.h
examples/lighting-app/efr32/include/FreeRTOSConfig.h
examples/lighting-app/efr32/src/AppTask.cpp
examples/lighting-app/efr32/src/Rpc.cpp
examples/lighting-app/efr32/src/main.cpp
examples/lighting-app/k32w/README.md
examples/lighting-app/k32w/main/AppTask.cpp
examples/lighting-app/k32w/main/include/AppTask.h
examples/lighting-app/k32w/main/include/app_config.h
examples/lighting-app/lighting-common/BUILD.gn
examples/lighting-app/lighting-common/gen/af-structs.h
examples/lighting-app/lighting-common/gen/attribute-id.h
examples/lighting-app/lighting-common/gen/attribute-size.h
examples/lighting-app/lighting-common/gen/attribute-type.h
examples/lighting-app/lighting-common/gen/client-command-macro.h
examples/lighting-app/lighting-common/gen/cluster-id.h
examples/lighting-app/lighting-common/gen/command-id.h
examples/lighting-app/lighting-common/gen/endpoint_config.h
examples/lighting-app/lighting-common/gen/print-cluster.h
examples/lighting-app/lighting-common/lighting.gni [new file with mode: 0644]
examples/lighting-app/lighting-common/lighting_service/pigweed_lighting.options [moved from examples/lighting-app/lighting-common/pigweed_lighting.options with 100% similarity]
examples/lighting-app/lighting-common/lighting_service/pigweed_lighting.proto [moved from examples/lighting-app/lighting-common/pigweed_lighting.proto with 100% similarity]
examples/lighting-app/linux/main.cpp
examples/lighting-app/nrfconnect/main/AppTask.cpp
examples/lighting-app/nrfconnect/main/LightingManager.cpp
examples/lighting-app/nrfconnect/main/include/AppConfig.h
examples/lighting-app/nrfconnect/main/include/LightingManager.h
examples/lighting-app/nrfconnect/main/pigweed_lighting.options
examples/lighting-app/nrfconnect/main/pigweed_lighting.proto
examples/lighting-app/nrfconnect/prj.conf
examples/lighting-app/nrfconnect/rpc.overlay
examples/lock-app/efr32/BUILD.gn
examples/lock-app/efr32/README.md
examples/lock-app/efr32/include/AppConfig.h
examples/lock-app/efr32/include/AppTask.h
examples/lock-app/efr32/include/CHIPProjectConfig.h
examples/lock-app/efr32/ldscripts/efr32-lock-example-MG12P.ld [deleted file]
examples/lock-app/efr32/ldscripts/efr32-lock-example-MG21.ld [deleted file]
examples/lock-app/efr32/src/AppTask.cpp
examples/lock-app/k32w/README.md
examples/lock-app/k32w/main/AppTask.cpp
examples/lock-app/k32w/main/include/AppTask.h
examples/lock-app/k32w/main/include/app_config.h
examples/lock-app/lock-common/gen/af-structs.h
examples/lock-app/lock-common/gen/attribute-id.h
examples/lock-app/lock-common/gen/attribute-size.h
examples/lock-app/lock-common/gen/attribute-type.h
examples/lock-app/lock-common/gen/client-command-macro.h
examples/lock-app/lock-common/gen/cluster-id.h
examples/lock-app/lock-common/gen/command-id.h
examples/lock-app/lock-common/gen/endpoint_config.h
examples/lock-app/lock-common/gen/print-cluster.h
examples/lock-app/nrfconnect/main/AppTask.cpp
examples/lock-app/nrfconnect/prj.conf
examples/persistent-storage/efr32/BUILD.gn
examples/persistent-storage/efr32/README.md
examples/persistent-storage/efr32/ldscripts/efr32-persistent_storage-example-MG12P.ld [deleted file]
examples/persistent-storage/efr32/ldscripts/efr32-persistent_storage-example-MG21.ld [deleted file]
examples/pigweed-app/efr32/BUILD.gn
examples/pigweed-app/efr32/README.md
examples/pigweed-app/efr32/include/CHIPProjectConfig.h
examples/pigweed-app/efr32/ldscripts/efr32-pigweed-example-MG12P.ld [deleted file]
examples/pigweed-app/efr32/ldscripts/efr32-pigweed-example-MG21.ld [deleted file]
examples/pigweed-app/nrfconnect/prj.conf
examples/platform/efr32/MemMonitoring.cpp [new file with mode: 0644]
examples/platform/efr32/MemMonitoring.h [new file with mode: 0644]
examples/platform/efr32/Service.cpp
examples/platform/efr32/Service.h
examples/platform/efr32/efr32mg12/BRD4163A/hal-config.h
examples/platform/efr32/ldscripts/efr32-MG12P.ld [moved from examples/lighting-app/efr32/ldscripts/efr32-light-example-MG12P.ld with 99% similarity]
examples/platform/efr32/ldscripts/efr32-MG21.ld [moved from examples/lighting-app/efr32/ldscripts/efr32-light-example-MG21.ld with 99% similarity]
examples/platform/efr32/pw_sys_io/sys_io_efr32.cc
examples/platform/efr32/uart.c
examples/platform/efr32/uart.h
examples/platform/k32w/app/project_include/CHIPProjectConfig.h
examples/platform/nrfconnect/project_include/OpenThreadConfig.h
examples/platform/nrfconnect/pw_sys_io/CMakeLists.txt
examples/platform/nrfconnect/util/PigweedLogger.cpp
examples/shell/nrfconnect/prj.conf
examples/shell/shell_common/cmd_ping.cpp
examples/temperature-measurement-app/esp32/main/gen/af-structs.h
examples/temperature-measurement-app/esp32/main/gen/attribute-id.h
examples/temperature-measurement-app/esp32/main/gen/attribute-size.h
examples/temperature-measurement-app/esp32/main/gen/attribute-type.h
examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h
examples/temperature-measurement-app/esp32/main/gen/cluster-id.h
examples/temperature-measurement-app/esp32/main/gen/command-id.h
examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h
examples/temperature-measurement-app/esp32/main/gen/print-cluster.h
examples/tv-app/tv-common/gen/af-structs.h
examples/tv-app/tv-common/gen/attribute-id.h
examples/tv-app/tv-common/gen/attribute-size.h
examples/tv-app/tv-common/gen/attribute-type.h
examples/tv-app/tv-common/gen/cluster-id.h
examples/tv-app/tv-common/gen/endpoint_config.h
examples/tv-app/tv-common/gen/print-cluster.h
scripts/examples/gn_efr32_example.sh
scripts/examples/k32w_example.sh [new file with mode: 0755]
scripts/examples/nrfconnect_example.sh
scripts/flashing/nrfconnect_firmware_utils.py [new file with mode: 0755]
scripts/helpers/restyle-diff.sh
scripts/requirements.in
src/BUILD.gn
src/android/CHIPTool/app/build.gradle
src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/echoclient/EchoClientFragment.kt
src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/util/DeviceIdUtil.kt
src/app/Command.cpp
src/app/Command.h
src/app/CommandHandler.cpp
src/app/CommandHandler.h
src/app/CommandSender.cpp
src/app/InteractionModelDelegate.h
src/app/InteractionModelEngine.cpp
src/app/MessageDef/Builder.h
src/app/MessageDef/CommandDataElement.cpp
src/app/MessageDef/StatusElement.cpp
src/app/MessageDef/StatusElement.h
src/app/clusters/account-login-server/account-login-server.cpp [new file with mode: 0644]
src/app/clusters/application-launcher-server/application-launcher-server.cpp [new file with mode: 0644]
src/app/clusters/audio-output-server/audio-output-server.cpp [new file with mode: 0644]
src/app/clusters/keypad-input-server/keypad-input-server.cpp [new file with mode: 0644]
src/app/clusters/media-input-server/media-input-server.cpp [new file with mode: 0644]
src/app/clusters/target-navigator-server/target-navigator-server.cpp [new file with mode: 0644]
src/app/clusters/tv-channel-server/tv-channel-server.cpp [new file with mode: 0644]
src/app/common_flags.gni
src/app/server/BUILD.gn
src/app/server/Server.cpp
src/app/tests/BUILD.gn
src/app/tests/TestCommandInteraction.cpp [new file with mode: 0644]
src/app/tests/TestMessageDef.cpp
src/app/tests/TestReadInteraction.cpp
src/app/tests/integration/chip_im_initiator.cpp
src/app/tests/integration/chip_im_responder.cpp
src/app/tests/integration/common.cpp
src/app/tests/integration/common.h
src/app/util/CHIPDeviceCallbacksMgr.h
src/app/util/basic-types.h
src/app/zap-templates/chip-templates.json
src/app/zap-templates/common/ChipTypesHelper.js
src/app/zap-templates/common/override.js
src/app/zap-templates/templates/chip/CHIPClusters-src.zapt
src/app/zap-templates/templates/chip/python-CHIPClusters-cpp.zapt [moved from src/app/zap-templates/templates/chip/python-ChipDeviceController-ClusterCommands.zapt with 56% similarity]
src/app/zap-templates/templates/chip/python-CHIPClusters-py.zapt [moved from src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt with 60% similarity]
src/app/zap-templates/zcl/account-login-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/application-launcher-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/audio-output-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/content-launch-cluster.xml
src/app/zap-templates/zcl/custom-types.xml
src/app/zap-templates/zcl/descriptor-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/keypad-input-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/media-input-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/target-navigator-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/tv-channel-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/wake-on-lan-cluster.xml [new file with mode: 0644]
src/app/zap-templates/zcl/zcl.json
src/ble/CHIPBleServiceData.h
src/controller/BUILD.gn
src/controller/CHIPClusters.cpp
src/controller/CHIPDevice.cpp
src/controller/CHIPDevice.h
src/controller/CHIPDeviceController.cpp
src/controller/CHIPDeviceController.h
src/controller/java/AndroidDeviceControllerWrapper.cpp
src/controller/java/CHIPDeviceController-JNI.cpp
src/controller/java/src/chip/devicecontroller/ChipDeviceController.java
src/controller/python/BUILD.gn
src/controller/python/ChipDeviceController-ClusterCommands.cpp [deleted file]
src/controller/python/ChipDeviceController-ScriptBinding.cpp
src/controller/python/build-chip-wheel.py
src/controller/python/chip-device-ctrl.py
src/controller/python/chip/ChipDeviceCtrl.py
src/controller/python/chip/clusters/CHIPClusters.cpp [new file with mode: 0644]
src/controller/python/chip/clusters/CHIPClusters.py [moved from src/controller/python/chip/ChipCluster.py with 51% similarity]
src/controller/python/chip/clusters/__init__.py [new file with mode: 0644]
src/controller/python/chip/exceptions/__init__.py
src/controller/python/chip/internal/CommissionerImpl.cpp
src/darwin/Framework/CHIP/gen/af-structs.h
src/darwin/Framework/CHIP/gen/attribute-id.h
src/darwin/Framework/CHIP/gen/attribute-size.h
src/darwin/Framework/CHIP/gen/attribute-type.h
src/darwin/Framework/CHIP/gen/cluster-id.h
src/darwin/Framework/CHIP/gen/endpoint_config.h
src/darwin/Framework/CHIP/gen/print-cluster.h
src/darwin/Framework/chip_xcode_build_connector.sh
src/include/platform/internal/GenericConfigurationManagerImpl.cpp
src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.cpp
src/include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h
src/inet/tests/BUILD.gn
src/lib/core/BUILD.gn
src/lib/core/CHIPPersistentStorageDelegate.h
src/lib/core/core.gni
src/lib/support/BUILD.gn
src/lib/support/BitFlags.h
src/lib/support/BufferWriter.cpp
src/lib/support/CHIPMem-Malloc.cpp
src/lib/support/CHIPMem-Simple.cpp [new file with mode: 0644]
src/lib/support/CHIPMem-SimpleAlloc.cpp [deleted file]
src/lib/support/CHIPMem.h
src/lib/support/CHIPPlatformMemory.cpp
src/lib/support/CHIPPlatformMemory.h
src/lib/support/CodeUtils.h
src/lib/support/PrivateHeap.cpp
src/lib/support/PrivateHeap.h
src/lib/support/ScopedBuffer.h
src/lib/support/tests/TestCHIPMem.cpp
src/lib/support/tests/TestPrivateHeap.cpp
src/lib/support/tests/TestScopedBuffer.cpp
src/lwip/efr32/lwipopts.h
src/lwip/freertos/sys_arch.c
src/lwip/qpg6100/lwipopts.h
src/messaging/ChannelContext.cpp
src/messaging/ExchangeContext.cpp
src/messaging/ExchangeMgr.cpp
src/messaging/ExchangeMgr.h
src/messaging/ReliableMessageContext.cpp
src/messaging/tests/MessagingContext.cpp
src/messaging/tests/echo/echo_requester.cpp
src/messaging/tests/echo/echo_responder.cpp
src/platform/Darwin/BleConnectionDelegateImpl.mm
src/platform/EFR32/BLEManagerImpl.cpp
src/platform/EFR32/CHIPDevicePlatformConfig.h
src/platform/EFR32/CHIPMem-Platform.cpp [new file with mode: 0644]
src/platform/EFR32/CHIPPlatformConfig.h
src/platform/EFR32/EFR32Config.cpp
src/platform/EFR32/PlatformManagerImpl.cpp
src/platform/EFR32/ThreadStackManagerImpl.cpp
src/platform/EFR32/args.gni
src/platform/EFR32/freertos_bluetooth.c
src/platform/EFR32/freertos_bluetooth.h
src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.cpp
src/platform/FreeRTOS/GenericThreadStackManagerImpl_FreeRTOS.h
src/platform/K32W/BLEManagerImpl.cpp
src/platform/K32W/BLEManagerImpl.h
src/platform/K32W/CHIPDevicePlatformConfig.h
src/platform/Linux/KeyValueStoreManagerImpl.cpp
src/platform/Linux/MdnsImpl.cpp
src/platform/Linux/ThreadStackManagerImpl.h
src/platform/cc13x2_26x2/BLEManagerImpl.cpp
src/platform/cc13x2_26x2/BLEManagerImpl.h
src/platform/nrfconnect/CHIPDevicePlatformConfig.h
src/platform/qpg6100/qpg6100Config.cpp
src/platform/qpg6100/qpg6100Config.h
src/protocols/Protocols.h
src/protocols/interaction_model/Constants.h
src/system/SystemConfig.h
src/test_driver/nrfconnect/CMakeLists.txt
src/test_driver/nrfconnect/prj.conf
src/transport/NetworkProvisioning.cpp
src/transport/PASESession.cpp
src/transport/PeerConnections.h
src/transport/RendezvousSession.cpp
src/transport/SecureSessionMgr.cpp
src/transport/SecureSessionMgr.h
src/transport/raw/MessageHeader.cpp
src/transport/raw/MessageHeader.h
src/transport/raw/tests/TestMessageHeader.cpp

index 0291d12..5671567 100644 (file)
@@ -38,6 +38,9 @@ if (chip_link_tests) {
       output_dir = _test_output_dir
     }
 
+    group(_test_name + "_lib") {
+    }
+
     pw_python_action(_test_name + "_run") {
       deps = [ ":${_test_name}" ]
       inputs = [ pw_unit_test_AUTOMATIC_RUNNER ]
@@ -55,6 +58,8 @@ if (chip_link_tests) {
   template("chip_test") {
     group(target_name) {
     }
+    group(target_name + "_lib") {
+    }
     not_needed(invoker, "*")
   }
 }
index 4285f59..c570b4f 100644 (file)
@@ -21,8 +21,43 @@ assert(chip_build_tests)
 template("chip_test_group") {
   _test_group_name = target_name
 
+  # Generate a .a file with all of the tests in it.
+  _build_monolithic_library = defined(invoker.build_monolithic_library) &&
+                              invoker.build_monolithic_library
+
+  if (_build_monolithic_library) {
+    _target_type = "static_library"
+  } else {
+    _target_type = "group"
+  }
+
+  _lib_target_name = "${_test_group_name}_lib"
+
+  target(_target_type, _lib_target_name) {
+    forward_variables_from(invoker,
+                           "*",
+                           [
+                             "build_monolithic_library",
+                             "deps",
+                           ])
+
+    deps = []
+    foreach(_test, invoker.deps) {
+      deps += [ get_label_info(_test, "label_no_toolchain") + "_lib" ]
+    }
+
+    if (_build_monolithic_library) {
+      complete_static_lib = true
+    }
+  }
+
   group("${_test_group_name}") {
-    deps = invoker.deps
+    deps = []
+    data_deps = invoker.deps
+
+    if (_build_monolithic_library) {
+      deps += [ ":${_lib_target_name}" ]
+    }
   }
 
   if (chip_link_tests) {
index e52cb85..3488b36 100644 (file)
@@ -80,7 +80,7 @@ template("chip_test_suite") {
     invoker.sources += invoker.test_sources
   }
 
-  static_library("${_suite_name}_common") {
+  static_library("${_suite_name}_lib") {
     forward_variables_from(invoker, "*", [ "tests" ])
 
     output_dir = "${root_out_dir}/lib"
@@ -96,7 +96,9 @@ template("chip_test_suite") {
     #       Tests such as TestInetEndPoint need to exercise the system event
     #       loop however they do not seem to include a logging binding so this
     #       is forcefully added here.
-    public_deps += [ "${chip_root}/src/platform/logging:stdio" ]
+    if (current_os != "zephyr") {
+      public_deps += [ "${chip_root}/src/platform/logging:stdio" ]
+    }
   }
 
   if (chip_link_tests) {
@@ -122,7 +124,7 @@ template("chip_test_suite") {
         chip_test(_test_name) {
           sources = [ _driver_name ]
           public_deps = [
-            ":${_suite_name}_common",
+            ":${_suite_name}_lib",
             ":${_test_name}_generate_driver",
           ]
         }
@@ -136,7 +138,7 @@ template("chip_test_suite") {
         chip_test(_test) {
           sources = [ "${_test}Driver.cpp" ]
 
-          public_deps = [ ":${_suite_name}_common" ]
+          public_deps = [ ":${_suite_name}_lib" ]
         }
 
         tests += [ _test ]
@@ -158,7 +160,7 @@ template("chip_test_suite") {
     }
   } else {
     group(_suite_name) {
-      deps = [ ":${_suite_name}_common" ]
+      deps = [ ":${_suite_name}_lib" ]
     }
   }
 }
index 4763c01..a9117fb 100644 (file)
@@ -258,6 +258,9 @@ declare_args() {
   # Enable memory sanitizer
   is_msan = false
 
+  # enable undefined behavior sanitizer
+  is_ubsan = false
+
   # Exit on sanitize error. Generally standard libraries may get errors
   # so not stopping on the first error is often useful
   is_sanitize_fatal = true
@@ -280,6 +283,18 @@ config("sanitize_memory") {
   ldflags = cflags
 }
 
+config("sanitize_undefined_behavior") {
+  cflags = [
+    "-fvisibility=hidden",
+    "-fsanitize=undefined",
+    "-fsanitize=float-divide-by-zero",
+    "-fsanitize=unsigned-integer-overflow",
+    "-fsanitize=implicit-conversion",
+    "-fsanitize=nullability",
+  ]
+  ldflags = cflags
+}
+
 config("sanitize_recover_all") {
   cflags = [ "-fsanitize-recover=all" ]
   ldflags = cflags
@@ -296,6 +311,10 @@ config("sanitize_default") {
     configs += [ ":sanitize_memory" ]
   }
 
+  if (is_ubsan) {
+    configs += [ ":sanitize_undefined_behavior" ]
+  }
+
   if (!is_sanitize_fatal) {
     configs += [ ":sanitize_recover_all" ]
   }
index b0d3b32..22f3704 100644 (file)
@@ -31,7 +31,7 @@ CONFIG_SERIAL=n
 
 # Disable logs
 CONFIG_LOG=n
-CONFIG_LOG_MINIMAL=n
+CONFIG_LOG_MODE_MINIMAL=n
 
 # Disable other debugging features
 CONFIG_THREAD_NAME=n
index 901d5f6..fb45b4c 100644 (file)
@@ -19,7 +19,7 @@ CONFIG_CHIP=y
 CONFIG_STD_CPP14=y
 
 CONFIG_LOG=y
-CONFIG_LOG_MINIMAL=y
+CONFIG_LOG_MODE_MINIMAL=y
 CONFIG_ASSERT=y
 CONFIG_HW_STACK_PROTECTION=y
 CONFIG_SHELL=y
@@ -76,6 +76,7 @@ CONFIG_OPENTHREAD_MTD_NETDIAG=y
 CONFIG_OPENTHREAD_ENABLE_SERVICE=y
 CONFIG_OPENTHREAD_MANUAL_START=y
 CONFIG_OPENTHREAD_THREAD_STACK_SIZE=6144
+CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS=64
 
 # Use mbedTLS from nrf_security library
 CONFIG_NORDIC_SECURITY_BACKEND=y
index 3feee96..a9b5d58 100644 (file)
@@ -196,6 +196,7 @@ chip_gn_arg_bool  ("is_debug"                               CONFIG_DEBUG)
 chip_gn_arg_bool  ("chip_enable_openthread"                 CONFIG_NET_L2_OPENTHREAD)
 chip_gn_arg_bool  ("chip_inet_config_enable_ipv4"           CONFIG_NET_IPV4)
 chip_gn_arg_bool  ("chip_build_tests"                       CONFIG_CHIP_BUILD_TESTS)
+chip_gn_arg_bool  ("chip_monolithic_tests"                  CONFIG_CHIP_BUILD_TESTS)
 chip_gn_arg_bool  ("chip_inet_config_enable_raw_endpoint"   CONFIG_CHIP_BUILD_TESTS)
 chip_gn_arg_bool  ("chip_inet_config_enable_tcp_endpoint"   CONFIG_CHIP_BUILD_TESTS)
 chip_gn_arg_bool  ("chip_inet_config_enable_dns_resolver"   CONFIG_CHIP_BUILD_TESTS)
index f1d3d1b..719f670 100644 (file)
@@ -89,15 +89,9 @@ config CHIP_NFC_COMMISSIONING
        help
          Enables NFC commissioning by sharing onboarding payload in NFC tag.
 
-config CHIP_ENABLE_RENDEZVOUS_BYPASS
-       bool "Enable Rendezvous bypass"
-       default n
-       help
-         Enables bypassing rendezvous for the test purposes.
-
 config CHIP_ENABLE_DNSSD_SRP
        bool "Enable support for service registration"
-       default n
+       default y
        imply OPENTHREAD_ECDSA
        imply OPENTHREAD_SRP_CLIENT
        help
index 4482879..15bc171 100644 (file)
@@ -2296,7 +2296,7 @@ HIDE_UNDOC_RELATIONS   = YES
 # set to NO
 # The default value is: NO.
 
-HAVE_DOT               = YES
+HAVE_DOT               = NO
 
 # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
 # to run in parallel. When set to 0 doxygen will base this on the number of
index 6cad0ef..4d7b723 100644 (file)
@@ -27,7 +27,8 @@ onto a CHIP-enabled Thread network.
 
 The commissioning process is composed of the following main stages:
 
--   K32W061 (CHIP accessory) device is in BLE advertising mode;
+-   K32W061 (CHIP accessory) device is put in BLE advertisment mode by pressing
+    the USERINTERFACE button;
 -   CHIPTool discovers the CHIP accessory over BLE;
 -   CHIPTool establishes a secure channel with the accessory using a SPAKE2+
     handshake;
@@ -84,7 +85,8 @@ OpenThread RCP firmware is required to allow the PC to communicate with Thread
 devices. Run the commands mentioned in the following steps to build and program
 the RCP firmware onto an K32W061 DK6:
 
-1.  Clone the OpenThread repository into the current directory:
+1.  Clone the OpenThread repository into the current directory (we recommand
+    using commit ced158e65a00dd5394c04548b7b187d3a3f11eef):
 
         $ git clone https://github.com/openthread/openthread.git
 
@@ -122,8 +124,8 @@ To make your PC work as a Thread Border Router, complete the following tasks:
 1.  Set up Thread Border Router package by following steps
     [3,4,5](https://openthread.io/guides/border-router/build) from the official
     documentation. Use NETWORK_MANAGER=0 as the Wi-Fi AP will be set manually at
-    the next step.
-
+    the next step. Also, we recommend using commit
+    83babaf236cad8471be28185d8d4351d37564919 for ot-br-posix repository.
 2.  Configure the Wi-Fi AP
 
     -   Install the required package:
@@ -418,14 +420,16 @@ following steps:
 1. Enable _Bluetooth_ and _Location_ services on your smartphone;
 2. Connect the smartphone to _OT-BR_ WiFi network;
 3. Open the CHIPTool application on your smartphone;
-4. Tap the _PROVISION CHIP DEVICE WITH THREAD_ button and scan the commissioning
+4. Push the USERINTERFACE button on the K32W board. This will start the BLE
+   advertising process;
+5. Tap the _PROVISION CHIP DEVICE WITH THREAD_ button and scan the commissioning
    QR code. Several notifications will appear, informing you of commissioning
    progress with scanning, connection, and pairing. At the end of this process,
    the Thread network settings screen appears.
 
     ![chiptool_main_screen](../../examples/platform/k32w/doc/images/chiptool_main_screen.png)
 
-5. In the Thread network settings screen, use the default settings and tap the
+6. In the Thread network settings screen, use the default settings and tap the
    _SAVE NETWORK_ button to send a Thread provisioning message to the accessory
    device. You will see the "Network provisioning completed" message when the
    accessory device successfully joins the Thread network.
index 1575d1c..b0fdf86 100644 (file)
@@ -23,6 +23,9 @@ config("includes") {
 
 source_set("all-clusters-common") {
   sources = [
+    "${chip_root}/src/app/clusters/account-login-server/account-login-server.cpp",
+    "${chip_root}/src/app/clusters/application-launcher-server/application-launcher-server.cpp",
+    "${chip_root}/src/app/clusters/audio-output-server/audio-output-server.cpp",
     "${chip_root}/src/app/clusters/barrier-control-server/barrier-control-server.cpp",
     "${chip_root}/src/app/clusters/basic/basic.cpp",
     "${chip_root}/src/app/clusters/bindings/bindings.cpp",
@@ -36,14 +39,18 @@ source_set("all-clusters-common") {
     "${chip_root}/src/app/clusters/groups-server/groups-server.cpp",
     "${chip_root}/src/app/clusters/ias-zone-server/ias-zone-server.cpp",
     "${chip_root}/src/app/clusters/identify/identify.cpp",
+    "${chip_root}/src/app/clusters/keypad-input-server/keypad-input-server.cpp",
     "${chip_root}/src/app/clusters/level-control/level-control.cpp",
     "${chip_root}/src/app/clusters/low-power-server/low-power-server.cpp",
+    "${chip_root}/src/app/clusters/media-input-server/media-input-server.cpp",
     "${chip_root}/src/app/clusters/media-playback-server/media-playback-server.cpp",
     "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp",
     "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp",
     "${chip_root}/src/app/clusters/on-off-server/on-off.cpp",
     "${chip_root}/src/app/clusters/scenes/scenes.cpp",
+    "${chip_root}/src/app/clusters/target-navigator-server/target-navigator-server.cpp",
     "${chip_root}/src/app/clusters/temperature-measurement-server/temperature-measurement-server.cpp",
+    "${chip_root}/src/app/clusters/tv-channel-server/tv-channel-server.cpp",
     "${chip_root}/src/app/reporting/reporting-default-configuration.cpp",
     "${chip_root}/src/app/reporting/reporting.cpp",
     "${chip_root}/src/app/server/DataModelHandler.cpp",
index 2f9a5a6..8059674 100644 (file)
@@ -118,6 +118,13 @@ typedef struct _DeviceInformationRecord
     uint8_t sort;
 } EmberAfDeviceInformationRecord;
 
+// Struct for DeviceType
+typedef struct _DeviceType
+{
+    chip::DeviceTypeId type;
+    uint16_t revision;
+} EmberAfDeviceType;
+
 // Struct for DiscoverAttributesInfoRecord
 typedef struct _DiscoverAttributesInfoRecord
 {
index 0fd312a..cd1d95a 100644 (file)
 #define ZCL_FINISH_TIME_ATTRIBUTE_ID (0x0001)
 #define ZCL_REMAINING_TIME_ATTRIBUTE_ID (0x0002)
 
+// Attribute ids for cluster: Descriptor
+
+// Client attributes
+
+// Server attributes
+#define ZCL_DEVICE_LIST_ATTRIBUTE_ID (0x0000)
+#define ZCL_SERVER_LIST_ATTRIBUTE_ID (0x0001)
+#define ZCL_CLIENT_LIST_ATTRIBUTE_ID (0x0002)
+#define ZCL_PARTS_LIST_ATTRIBUTE_ID (0x0003)
+
 // Attribute ids for cluster: Poll Control
 
 // Client attributes
index a6caf3a..ee211ce 100644 (file)
@@ -34,4 +34,4 @@ ZCL_DATA8_ATTRIBUTE_TYPE, 1, ZCL_DATA16_ATTRIBUTE_TYPE, 2, ZCL_DATA24_ATTRIBUTE_
     ZCL_DATE_ATTRIBUTE_TYPE, 4, ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4, ZCL_CLUSTER_ID_ATTRIBUTE_TYPE, 2, ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE,
     2, ZCL_BACNET_OID_ATTRIBUTE_TYPE, 4, ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8, ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
     ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE, 1, ZCL_GROUP_ID_ATTRIBUTE_TYPE, 2, ZCL_COMMAND_ID_ATTRIBUTE_TYPE, 1, ZCL_NODE_ID_ATTRIBUTE_TYPE,
-    8,
+    8, ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE, 4,
index 56900dc..6f12999 100644 (file)
@@ -82,5 +82,6 @@ enum
     ZCL_GROUP_ID_ATTRIBUTE_TYPE          = 0xF3, // Group Id
     ZCL_COMMAND_ID_ATTRIBUTE_TYPE        = 0xF4, // Command Id
     ZCL_NODE_ID_ATTRIBUTE_TYPE           = 0xF5, // Node Id
+    ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE    = 0xF6, // Device Type Id
     ZCL_UNKNOWN_ATTRIBUTE_TYPE           = 0xFF, // Unknown
 };
index 499adf9..bbd16b6 100644 (file)
@@ -71,6 +71,9 @@
 // Definitions for cluster: Appliance Control
 #define ZCL_APPLIANCE_CONTROL_CLUSTER_ID (0x001B)
 
+// Definitions for cluster: Descriptor
+#define ZCL_DESCRIPTOR_CLUSTER_ID (0x001D)
+
 // Definitions for cluster: Poll Control
 #define ZCL_POLL_CONTROL_CLUSTER_ID (0x0020)
 
index 5353823..6ada6d4 100644 (file)
 #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x
 #define ZAP_REPORT_DIRECTION(x) ZRD(x)
 
-// Use this macro to check if Reporting plugin is included
-#define EMBER_AF_PLUGIN_REPORTING
 // User options for plugin Reporting
 #define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (10)
 #define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS
index 5cb5a91..4054969 100644 (file)
 #define CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER
 #endif
 
+#if defined(ZCL_USING_DESCRIPTOR_CLUSTER_SERVER) || defined(ZCL_USING_DESCRIPTOR_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER { ZCL_DESCRIPTOR_CLUSTER_ID, 29, "Descriptor" },
+#else
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER
+#endif
+
 #if defined(ZCL_USING_POLL_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_POLL_CONTROL_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER { ZCL_POLL_CONTROL_CLUSTER_ID, 32, "Poll Control" },
 #else
     CHIP_PRINTCLUSTER_OTA_BOOTLOAD_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_POWER_PROFILE_CLUSTER                                                                                        \
     CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER                                                                                    \
+    CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER                                                                                           \
     CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER                                                                                            \
index 2c99a76..7c436b3 100644 (file)
@@ -30,15 +30,22 @@ COMPONENT_SRCDIRS :=
   ../third_party/connectedhomeip/src/app/clusters/on-off-server                     \
   ../third_party/connectedhomeip/src/app/clusters/level-control                     \
   ../third_party/connectedhomeip/src/app/clusters/identify                          \
+  ../third_party/connectedhomeip/src/app/clusters/account-login-server              \
+  ../third_party/connectedhomeip/src/app/clusters/application-launcher-server       \
+  ../third_party/connectedhomeip/src/app/clusters/audio-output-server               \
   ../third_party/connectedhomeip/src/app/clusters/barrier-control-server            \
   ../third_party/connectedhomeip/src/app/clusters/general-commissioning-server      \
   ../third_party/connectedhomeip/src/app/clusters/groups-server                     \
   ../third_party/connectedhomeip/src/app/clusters/color-control-server              \
   ../third_party/connectedhomeip/src/app/clusters/content-launch-server             \
   ../third_party/connectedhomeip/src/app/clusters/low-power-server                  \
+  ../third_party/connectedhomeip/src/app/clusters/keypad-input-server               \
   ../third_party/connectedhomeip/src/app/clusters/media-playback-server             \
+  ../third_party/connectedhomeip/src/app/clusters/media-input-server                \
   ../third_party/connectedhomeip/src/app/clusters/network-commissioning             \
+  ../third_party/connectedhomeip/src/app/clusters/target-navigator-server           \
   ../third_party/connectedhomeip/src/app/clusters/temperature-measurement-server    \
+  ../third_party/connectedhomeip/src/app/clusters/tv-channel-server                 \
   ../third_party/connectedhomeip/src/app/clusters/scenes                            \
   ../third_party/connectedhomeip/src/app/clusters/basic                             \
   ../third_party/connectedhomeip/src/app/clusters/bindings                          \
index b23fb0b..d09e6ed 100644 (file)
@@ -403,7 +403,7 @@ std::string createSetupPayload()
     }
 
     SetupPayload payload;
-    payload.version               = 1;
+    payload.version               = 0;
     payload.discriminator         = discriminator;
     payload.setUpPINCode          = setupPINCode;
     payload.rendezvousInformation = static_cast<RendezvousInformationFlags>(CONFIG_RENDEZVOUS_MODE);
index 2f9a5a6..8059674 100644 (file)
@@ -118,6 +118,13 @@ typedef struct _DeviceInformationRecord
     uint8_t sort;
 } EmberAfDeviceInformationRecord;
 
+// Struct for DeviceType
+typedef struct _DeviceType
+{
+    chip::DeviceTypeId type;
+    uint16_t revision;
+} EmberAfDeviceType;
+
 // Struct for DiscoverAttributesInfoRecord
 typedef struct _DiscoverAttributesInfoRecord
 {
index 6ca0739..cd1d95a 100644 (file)
 #define ZCL_FINISH_TIME_ATTRIBUTE_ID (0x0001)
 #define ZCL_REMAINING_TIME_ATTRIBUTE_ID (0x0002)
 
+// Attribute ids for cluster: Descriptor
+
+// Client attributes
+
+// Server attributes
+#define ZCL_DEVICE_LIST_ATTRIBUTE_ID (0x0000)
+#define ZCL_SERVER_LIST_ATTRIBUTE_ID (0x0001)
+#define ZCL_CLIENT_LIST_ATTRIBUTE_ID (0x0002)
+#define ZCL_PARTS_LIST_ATTRIBUTE_ID (0x0003)
+
 // Attribute ids for cluster: Poll Control
 
 // Client attributes
 // Server attributes
 #define ZCL_MAX_DURATION_ATTRIBUTE_ID (0x0000)
 
+// Attribute ids for cluster: Media Playback
+
+// Client attributes
+
+// Server attributes
+#define ZCL_CURRENT_STATE_ATTRIBUTE_ID (0x0000)
+
 // Attribute ids for cluster: Low Power
 
 // Client attributes
 
 // Server attributes
 
+// Attribute ids for cluster: Content Launch
+
+// Client attributes
+
+// Server attributes
+
 // Attribute ids for cluster: Application Basic
 
 // Client attributes
 
 // Server attributes
 
-// Attribute ids for cluster: Media Playback
-
-// Client attributes
-
-// Server attributes
-#define ZCL_CURRENT_STATE_ATTRIBUTE_ID (0x0000)
-
-// Attribute ids for cluster: Content Launch
-
-// Client attributes
-
-// Server attributes
-
 // Attribute ids for cluster: Group Key Management
 
 // Client attributes
index a6caf3a..ee211ce 100644 (file)
@@ -34,4 +34,4 @@ ZCL_DATA8_ATTRIBUTE_TYPE, 1, ZCL_DATA16_ATTRIBUTE_TYPE, 2, ZCL_DATA24_ATTRIBUTE_
     ZCL_DATE_ATTRIBUTE_TYPE, 4, ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4, ZCL_CLUSTER_ID_ATTRIBUTE_TYPE, 2, ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE,
     2, ZCL_BACNET_OID_ATTRIBUTE_TYPE, 4, ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8, ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
     ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE, 1, ZCL_GROUP_ID_ATTRIBUTE_TYPE, 2, ZCL_COMMAND_ID_ATTRIBUTE_TYPE, 1, ZCL_NODE_ID_ATTRIBUTE_TYPE,
-    8,
+    8, ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE, 4,
index 56900dc..6f12999 100644 (file)
@@ -82,5 +82,6 @@ enum
     ZCL_GROUP_ID_ATTRIBUTE_TYPE          = 0xF3, // Group Id
     ZCL_COMMAND_ID_ATTRIBUTE_TYPE        = 0xF4, // Command Id
     ZCL_NODE_ID_ATTRIBUTE_TYPE           = 0xF5, // Node Id
+    ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE    = 0xF6, // Device Type Id
     ZCL_UNKNOWN_ATTRIBUTE_TYPE           = 0xFF, // Unknown
 };
index 79d1e15..775f29f 100644 (file)
                                                                                                                                    \
                                                           ZCL_SQUAWK_COMMAND_ID, "u", squawkInfo);
 
+/** @brief Command description for PlayRequest
+ *
+ * Command: PlayRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPlayRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_PLAY_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for PauseRequest
+ *
+ * Command: PauseRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPauseRequest() emberAfFillExternalBuffer(mask,                                                                  \
+                                                                                                                                   \
+                                                            ZCL_PAUSE_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for StopRequest
+ *
+ * Command: StopRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterStopRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_STOP_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for StartOverRequest
+ *
+ * Command: StartOverRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterStartOverRequest() emberAfFillExternalBuffer(mask,                                                              \
+                                                                                                                                   \
+                                                                ZCL_START_OVER_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for PreviousRequest
+ *
+ * Command: PreviousRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPreviousRequest() emberAfFillExternalBuffer(mask,                                                               \
+                                                                                                                                   \
+                                                               ZCL_PREVIOUS_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for NextRequest
+ *
+ * Command: NextRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterNextRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_NEXT_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for RewindRequest
+ *
+ * Command: RewindRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterRewindRequest() emberAfFillExternalBuffer(mask,                                                                 \
+                                                                                                                                   \
+                                                             ZCL_REWIND_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for FastForwardRequest
+ *
+ * Command: FastForwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterFastForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
+                                                                                                                                   \
+                                                                  ZCL_FAST_FORWARD_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for SkipForwardRequest
+ *
+ * Command: SkipForwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterSkipForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
+                                                                                                                                   \
+                                                                  ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for SkipBackwardRequest
+ *
+ * Command: SkipBackwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterSkipBackwardRequest() emberAfFillExternalBuffer(mask,                                                           \
+                                                                                                                                   \
+                                                                   ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID, "", );
+
 /** @brief Command description for Sleep
  *
  * Command: Sleep
                                                                                                                                    \
                                                   ZCL_SLEEP_COMMAND_ID, "", );
 
+/** @brief Command description for LaunchContent
+ *
+ * Command: LaunchContent
+ * @param contentLaunchStatus ContentLaunchStatus
+ */
+#define emberAfFillCommandContent                                                                                                  \
+    LaunchClusterLaunchContent(contentLaunchStatus)                                                                                \
+        emberAfFillExternalBuffer(mask,                                                                                            \
+                                                                                                                                   \
+                                  ZCL_LAUNCH_CONTENT_COMMAND_ID, "u", contentLaunchStatus);
+
+/** @brief Command description for LaunchURL
+ *
+ * Command: LaunchURL
+ * @param contentLaunchStatus ContentLaunchStatus
+ */
+#define emberAfFillCommandContent                                                                                                  \
+    LaunchClusterLaunchURL(contentLaunchStatus) emberAfFillExternalBuffer(mask,                                                    \
+                                                                                                                                   \
+                                                                          ZCL_LAUNCH_URL_COMMAND_ID, "u", contentLaunchStatus);
+
 /** @brief Command description for MatchProtocolAddress
  *
  * Command: MatchProtocolAddress
                                                                                                                                    \
                               ZCL_UNBIND_COMMAND_ID, "uuuu", nodeId, groupId, endpointId, clusterId);
 
-/** @brief Command description for PlayRequest
- *
- * Command: PlayRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPlayRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_PLAY_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for PauseRequest
- *
- * Command: PauseRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPauseRequest() emberAfFillExternalBuffer(mask,                                                                  \
-                                                                                                                                   \
-                                                            ZCL_PAUSE_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for StopRequest
- *
- * Command: StopRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterStopRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_STOP_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for StartOverRequest
- *
- * Command: StartOverRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterStartOverRequest() emberAfFillExternalBuffer(mask,                                                              \
-                                                                                                                                   \
-                                                                ZCL_START_OVER_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for PreviousRequest
- *
- * Command: PreviousRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPreviousRequest() emberAfFillExternalBuffer(mask,                                                               \
-                                                                                                                                   \
-                                                               ZCL_PREVIOUS_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for NextRequest
- *
- * Command: NextRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterNextRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_NEXT_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for RewindRequest
- *
- * Command: RewindRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterRewindRequest() emberAfFillExternalBuffer(mask,                                                                 \
-                                                                                                                                   \
-                                                             ZCL_REWIND_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for FastForwardRequest
- *
- * Command: FastForwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterFastForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
-                                                                                                                                   \
-                                                                  ZCL_FAST_FORWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for SkipForwardRequest
- *
- * Command: SkipForwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterSkipForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
-                                                                                                                                   \
-                                                                  ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for SkipBackwardRequest
- *
- * Command: SkipBackwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterSkipBackwardRequest() emberAfFillExternalBuffer(mask,                                                           \
-                                                                                                                                   \
-                                                                   ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for LaunchContent
- *
- * Command: LaunchContent
- * @param contentLaunchStatus ContentLaunchStatus
- */
-#define emberAfFillCommandContent                                                                                                  \
-    LaunchClusterLaunchContent(contentLaunchStatus)                                                                                \
-        emberAfFillExternalBuffer(mask,                                                                                            \
-                                                                                                                                   \
-                                  ZCL_LAUNCH_CONTENT_COMMAND_ID, "u", contentLaunchStatus);
-
-/** @brief Command description for LaunchURL
- *
- * Command: LaunchURL
- * @param contentLaunchStatus ContentLaunchStatus
- */
-#define emberAfFillCommandContent                                                                                                  \
-    LaunchClusterLaunchURL(contentLaunchStatus) emberAfFillExternalBuffer(mask,                                                    \
-                                                                                                                                   \
-                                                                          ZCL_LAUNCH_URL_COMMAND_ID, "u", contentLaunchStatus);
-
 /** @brief Command description for CommandOne
  *
  * Command: CommandOne
index 9e82931..bbd16b6 100644 (file)
@@ -71,6 +71,9 @@
 // Definitions for cluster: Appliance Control
 #define ZCL_APPLIANCE_CONTROL_CLUSTER_ID (0x001B)
 
+// Definitions for cluster: Descriptor
+#define ZCL_DESCRIPTOR_CLUSTER_ID (0x001D)
+
 // Definitions for cluster: Poll Control
 #define ZCL_POLL_CONTROL_CLUSTER_ID (0x0020)
 
 // Definitions for cluster: IAS WD
 #define ZCL_IAS_WD_CLUSTER_ID (0x0502)
 
+// Definitions for cluster: Media Playback
+#define ZCL_MEDIA_PLAYBACK_CLUSTER_ID (0x0506)
+
 // Definitions for cluster: Low Power
 #define ZCL_LOW_POWER_CLUSTER_ID (0x0508)
 
+// Definitions for cluster: Content Launch
+#define ZCL_CONTENT_LAUNCH_CLUSTER_ID (0x050A)
+
 // Definitions for cluster: Application Basic
 #define ZCL_APPLICATION_BASIC_CLUSTER_ID (0x050D)
 
 // Definitions for cluster: Binding
 #define ZCL_BINDING_CLUSTER_ID (0xF000)
 
-// Definitions for cluster: Media Playback
-#define ZCL_MEDIA_PLAYBACK_CLUSTER_ID (0xF001)
-
-// Definitions for cluster: Content Launch
-#define ZCL_CONTENT_LAUNCH_CLUSTER_ID (0xF002)
-
 // Definitions for cluster: Group Key Management
 #define ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID (0xF004)
 
index 864943b..268678a 100644 (file)
 #define ZCL_START_WARNING_COMMAND_ID (0x00)
 #define ZCL_SQUAWK_COMMAND_ID (0x01)
 
+// Commands for cluster: Media Playback
+#define ZCL_PLAY_REQUEST_COMMAND_ID (0x00)
+#define ZCL_PLAYBACK_COMMAND_ID (0x00)
+#define ZCL_PAUSE_REQUEST_COMMAND_ID (0x01)
+#define ZCL_STOP_REQUEST_COMMAND_ID (0x02)
+#define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03)
+#define ZCL_PREVIOUS_REQUEST_COMMAND_ID (0x04)
+#define ZCL_NEXT_REQUEST_COMMAND_ID (0x05)
+#define ZCL_REWIND_REQUEST_COMMAND_ID (0x06)
+#define ZCL_FAST_FORWARD_REQUEST_COMMAND_ID (0x07)
+#define ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID (0x08)
+#define ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID (0x09)
+
 // Commands for cluster: Low Power
 #define ZCL_SLEEP_COMMAND_ID (0x00)
 
+// Commands for cluster: Content Launch
+#define ZCL_LAUNCH_CONTENT_COMMAND_ID (0x00)
+#define ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID (0x00)
+#define ZCL_LAUNCH_URL_COMMAND_ID (0x01)
+#define ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID (0x01)
+
 // Commands for cluster: Generic Tunnel
 #define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00)
 #define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00)
 #define ZCL_BIND_COMMAND_ID (0x00)
 #define ZCL_UNBIND_COMMAND_ID (0x01)
 
-// Commands for cluster: Media Playback
-#define ZCL_PLAY_REQUEST_COMMAND_ID (0x00)
-#define ZCL_PLAYBACK_COMMAND_ID (0x00)
-#define ZCL_PAUSE_REQUEST_COMMAND_ID (0x01)
-#define ZCL_STOP_REQUEST_COMMAND_ID (0x02)
-#define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03)
-#define ZCL_PREVIOUS_REQUEST_COMMAND_ID (0x04)
-#define ZCL_NEXT_REQUEST_COMMAND_ID (0x05)
-#define ZCL_REWIND_REQUEST_COMMAND_ID (0x06)
-#define ZCL_FAST_FORWARD_REQUEST_COMMAND_ID (0x07)
-#define ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID (0x08)
-#define ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID (0x09)
-
-// Commands for cluster: Content Launch
-#define ZCL_LAUNCH_CONTENT_COMMAND_ID (0x00)
-#define ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID (0x00)
-#define ZCL_LAUNCH_URL_COMMAND_ID (0x01)
-#define ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID (0x01)
-
 // Commands for cluster: Sample Mfg Specific Cluster
 #define ZCL_COMMAND_ONE_COMMAND_ID (0x00)
 
index 2cfa655..5e806ff 100644 (file)
 #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x
 #define ZAP_REPORT_DIRECTION(x) ZRD(x)
 
-// Use this macro to check if Reporting plugin is included
-#define EMBER_AF_PLUGIN_REPORTING
 // User options for plugin Reporting
 #define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (2)
 #define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS
index e3207b7..4054969 100644 (file)
 #define CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER
 #endif
 
+#if defined(ZCL_USING_DESCRIPTOR_CLUSTER_SERVER) || defined(ZCL_USING_DESCRIPTOR_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER { ZCL_DESCRIPTOR_CLUSTER_ID, 29, "Descriptor" },
+#else
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER
+#endif
+
 #if defined(ZCL_USING_POLL_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_POLL_CONTROL_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER { ZCL_POLL_CONTROL_CLUSTER_ID, 32, "Poll Control" },
 #else
 #define CHIP_PRINTCLUSTER_IAS_WD_CLUSTER
 #endif
 
+#if defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_SERVER) || defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER { ZCL_MEDIA_PLAYBACK_CLUSTER_ID, 1286, "Media Playback" },
+#else
+#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER
+#endif
+
 #if defined(ZCL_USING_LOW_POWER_CLUSTER_SERVER) || defined(ZCL_USING_LOW_POWER_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER { ZCL_LOW_POWER_CLUSTER_ID, 1288, "Low Power" },
 #else
 #define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER
 #endif
 
+#if defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_SERVER) || defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER { ZCL_CONTENT_LAUNCH_CLUSTER_ID, 1290, "Content Launch" },
+#else
+#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER
+#endif
+
 #if defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER { ZCL_APPLICATION_BASIC_CLUSTER_ID, 1293, "Application Basic" },
 #else
 #define CHIP_PRINTCLUSTER_BINDING_CLUSTER
 #endif
 
-#if defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_SERVER) || defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT)
-#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER { ZCL_MEDIA_PLAYBACK_CLUSTER_ID, 61441, "Media Playback" },
-#else
-#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER
-#endif
-
-#if defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_SERVER) || defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT)
-#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER { ZCL_CONTENT_LAUNCH_CLUSTER_ID, 61442, "Content Launch" },
-#else
-#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER
-#endif
-
 #if defined(ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_SERVER) || defined(ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER { ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID, 61444, "Group Key Management" },
 #else
     CHIP_PRINTCLUSTER_OTA_BOOTLOAD_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_POWER_PROFILE_CLUSTER                                                                                        \
     CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER                                                                                    \
+    CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER                                                                                           \
     CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER                                                                                            \
     CHIP_PRINTCLUSTER_IAS_ZONE_CLUSTER                                                                                             \
     CHIP_PRINTCLUSTER_IAS_ACE_CLUSTER                                                                                              \
     CHIP_PRINTCLUSTER_IAS_WD_CLUSTER                                                                                               \
+    CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER                                                                                            \
+    CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER                                                                                    \
     CHIP_PRINTCLUSTER_GENERIC_TUNNEL_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_BACNET_PROTOCOL_TUNNEL_CLUSTER                                                                               \
     CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER                                                                                    \
     CHIP_PRINTCLUSTER_BINDING_CLUSTER                                                                                              \
-    CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER                                                                                       \
-    CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER                                                                                 \
     CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER                                                                                  \
     CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER_2                                                                                \
index 7857436..bc721b0 100644 (file)
@@ -122,7 +122,7 @@ CHIP_ERROR PrintQRCodeContent()
     err = ConfigurationMgr().GetProductId(productId);
     SuccessOrExit(err);
 
-    payload.version       = 1;
+    payload.version       = 0;
     payload.vendorID      = vendorId;
     payload.productID     = productId;
     payload.setUpPINCode  = setUpPINCode;
index 2f9a5a6..8059674 100644 (file)
@@ -118,6 +118,13 @@ typedef struct _DeviceInformationRecord
     uint8_t sort;
 } EmberAfDeviceInformationRecord;
 
+// Struct for DeviceType
+typedef struct _DeviceType
+{
+    chip::DeviceTypeId type;
+    uint16_t revision;
+} EmberAfDeviceType;
+
 // Struct for DiscoverAttributesInfoRecord
 typedef struct _DiscoverAttributesInfoRecord
 {
index 0fd312a..cd1d95a 100644 (file)
 #define ZCL_FINISH_TIME_ATTRIBUTE_ID (0x0001)
 #define ZCL_REMAINING_TIME_ATTRIBUTE_ID (0x0002)
 
+// Attribute ids for cluster: Descriptor
+
+// Client attributes
+
+// Server attributes
+#define ZCL_DEVICE_LIST_ATTRIBUTE_ID (0x0000)
+#define ZCL_SERVER_LIST_ATTRIBUTE_ID (0x0001)
+#define ZCL_CLIENT_LIST_ATTRIBUTE_ID (0x0002)
+#define ZCL_PARTS_LIST_ATTRIBUTE_ID (0x0003)
+
 // Attribute ids for cluster: Poll Control
 
 // Client attributes
index a6caf3a..ee211ce 100644 (file)
@@ -34,4 +34,4 @@ ZCL_DATA8_ATTRIBUTE_TYPE, 1, ZCL_DATA16_ATTRIBUTE_TYPE, 2, ZCL_DATA24_ATTRIBUTE_
     ZCL_DATE_ATTRIBUTE_TYPE, 4, ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4, ZCL_CLUSTER_ID_ATTRIBUTE_TYPE, 2, ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE,
     2, ZCL_BACNET_OID_ATTRIBUTE_TYPE, 4, ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8, ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
     ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE, 1, ZCL_GROUP_ID_ATTRIBUTE_TYPE, 2, ZCL_COMMAND_ID_ATTRIBUTE_TYPE, 1, ZCL_NODE_ID_ATTRIBUTE_TYPE,
-    8,
+    8, ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE, 4,
index 56900dc..6f12999 100644 (file)
@@ -82,5 +82,6 @@ enum
     ZCL_GROUP_ID_ATTRIBUTE_TYPE          = 0xF3, // Group Id
     ZCL_COMMAND_ID_ATTRIBUTE_TYPE        = 0xF4, // Command Id
     ZCL_NODE_ID_ATTRIBUTE_TYPE           = 0xF5, // Node Id
+    ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE    = 0xF6, // Device Type Id
     ZCL_UNKNOWN_ATTRIBUTE_TYPE           = 0xFF, // Unknown
 };
index 499adf9..bbd16b6 100644 (file)
@@ -71,6 +71,9 @@
 // Definitions for cluster: Appliance Control
 #define ZCL_APPLIANCE_CONTROL_CLUSTER_ID (0x001B)
 
+// Definitions for cluster: Descriptor
+#define ZCL_DESCRIPTOR_CLUSTER_ID (0x001D)
+
 // Definitions for cluster: Poll Control
 #define ZCL_POLL_CONTROL_CLUSTER_ID (0x0020)
 
index 0c5f81d..7f78df5 100644 (file)
 #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x
 #define ZAP_REPORT_DIRECTION(x) ZRD(x)
 
+// User options for plugin Reporting
+#define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (0)
+#define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS
+
 #define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (0)
 #define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS                                                                               \
     {                                                                                                                              \
index 5cb5a91..4054969 100644 (file)
 #define CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER
 #endif
 
+#if defined(ZCL_USING_DESCRIPTOR_CLUSTER_SERVER) || defined(ZCL_USING_DESCRIPTOR_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER { ZCL_DESCRIPTOR_CLUSTER_ID, 29, "Descriptor" },
+#else
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER
+#endif
+
 #if defined(ZCL_USING_POLL_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_POLL_CONTROL_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER { ZCL_POLL_CONTROL_CLUSTER_ID, 32, "Poll Control" },
 #else
     CHIP_PRINTCLUSTER_OTA_BOOTLOAD_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_POWER_PROFILE_CLUSTER                                                                                        \
     CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER                                                                                    \
+    CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER                                                                                           \
     CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER                                                                                            \
index c26608b..4ef9bef 100644 (file)
@@ -17,11 +17,12 @@ import("//build_overrides/chip.gni")
 import("//build_overrides/efr32_sdk.gni")
 import("//build_overrides/pigweed.gni")
 
-import("$dir_pw_protobuf_compiler/proto.gni")
 import("${build_root}/config/defaults.gni")
 import("${efr32_sdk_build_root}/efr32_executable.gni")
 import("${efr32_sdk_build_root}/efr32_sdk.gni")
 
+import("${chip_root}/examples/lighting-app/lighting-common/lighting.gni")
+
 assert(current_os == "freertos")
 
 efr32_project_dir = "${chip_root}/examples/lighting-app/efr32"
@@ -30,8 +31,8 @@ examples_plat_dir = "${chip_root}/examples/platform/efr32"
 declare_args() {
   # Dump memory usage at link time.
   chip_print_memory_usage = false
-  enable_pw_rpc = false
   setupPinCode = 73141520
+  enable_heap_monitoring = false
 }
 
 show_qr_code = true
@@ -57,9 +58,12 @@ efr32_sdk("sdk") {
   defines = [
     "BOARD_ID=${efr32_board}",
     "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
+    "SL_HEAP_SIZE=(10 * 1024)",
   ]
 
   if (enable_pw_rpc) {
+    sources +=
+        [ "${efr32_sdk_root}/hardware/kit/common/drivers/retargetserial.c" ]
     defines += [
       "HAL_VCOM_ENABLE = 1",
       "PW_RPC_ENABLED",
@@ -67,13 +71,6 @@ efr32_sdk("sdk") {
   }
 }
 
-if (enable_pw_rpc) {
-  pw_proto_library("pw_light_service_proto") {
-    sources = [ "${chip_root}/examples/lighting-app/lighting-common/pigweed_lighting.proto" ]
-    inputs = [ "${chip_root}/examples/lighting-app/lighting-common/pigweed_lighting.options" ]
-  }
-}
-
 efr32_executable("lighting_app") {
   include_dirs = []
   defines = []
@@ -103,6 +100,7 @@ efr32_executable("lighting_app") {
     "${examples_plat_dir}/LEDWidget.cpp",
     "${examples_plat_dir}/Service.cpp",
     "${examples_plat_dir}/init_efrPlatform.cpp",
+    "${examples_plat_dir}/uart.c",
     "src/AppTask.cpp",
     "src/ButtonHandler.cpp",
     "src/LightingManager.cpp",
@@ -118,53 +116,39 @@ efr32_executable("lighting_app") {
 
   if (enable_pw_rpc) {
     public_deps += [
-      ":pw_light_service_proto.nanopb_rpc",
       "$dir_pw_assert",
       "$dir_pw_checksum",
+      "$dir_pw_stream",
+      "$dir_pw_sys_io",
       "${chip_root}/config/efr32/lib/pw_rpc:pw_rpc",
+      "${chip_root}/examples/lighting-app/lighting-common:lighting_service.nanopb_rpc",
       "${examples_plat_dir}/pw_sys_io:pw_sys_io_efr32",
     ]
 
     include_dirs += [
-      "${examples_plat_dir}/pw_sys_io/public",
-      "${dir_pigweed}/pw_sys_io/public",
-      "${dir_pigweed}/pw_span/public_overrides",
-      "${dir_pigweed}/pw_span/public",
-      "${dir_pigweed}/pw_polyfill/public",
-      "${dir_pigweed}/pw_polyfill/standard_library_public",
-      "${dir_pigweed}/pw_polyfill/public_overrides",
-      "${dir_pigweed}/pw_status/public",
-      "${dir_pigweed}/pw_stream/public",
-      "${dir_pigweed}/pw_preprocessor/public",
-      "${dir_pigweed}/pw_rpc/public",
-      "${dir_pigweed}/pw_rpc/nanopb/public",
-      "${dir_pigweed}/pw_rpc/raw/public",
-      "${dir_pigweed}/pw_rpc/system_server/public",
-      "${dir_pigweed}/pw_protobuf/public",
-      "${dir_pigweed}/pw_result/public",
-      "${dir_pigweed}/pw_varint/public",
-      "${chip_root}/third_party/nanopb/repo",
-      "${chip_root}/src/lib/support",
       "${chip_root}/examples/common",
       "${chip_root}/examples/common/pigweed/efr32",
-      "out/debug/gen/pw_light_service_proto/third_party/connectedhomeip/examples/lighting-app/lighting-common",
     ]
 
     sources += [
       "${chip_root}/examples/common/pigweed/RpcService.cpp",
-      "${chip_root}/examples/common/pigweed/efr32/PigeedLoggerMutex.cpp",
+      "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp",
       "${examples_plat_dir}/PigweedLogger.cpp",
-      "${examples_plat_dir}/uart.c",
       "src/Rpc.cpp",
     ]
   }
 
   output_dir = root_out_dir
 
+  if (enable_heap_monitoring) {
+    defines += [ "HEAP_MONITORING" ]
+    sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ]
+  }
+
   if (efr32_family == "efr32mg12") {
-    ldscript = "${efr32_project_dir}/ldscripts/efr32-light-example-MG12P.ld"
+    ldscript = "${examples_plat_dir}/ldscripts/efr32-MG12P.ld"
   } else if (efr32_family == "efr32mg21") {
-    ldscript = "${efr32_project_dir}/ldscripts/efr32-light-example-MG21.ld"
+    ldscript = "${examples_plat_dir}/ldscripts/efr32-MG21.ld"
   }
 
   ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
index 632b605..5588c8b 100644 (file)
@@ -51,11 +51,9 @@ Silicon Labs platform.
 
 -   Install some additional tools(likely already present for CHIP developers):
 
-           # Linux
-           $ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
+#Linux \$ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
 
-           # Mac OS X
-           $ brew install ninja
+#Mac OS X \$ brew install ninja
 
 -   Supported hardware:
 
@@ -213,10 +211,13 @@ combination with JLinkRTTClient as follows:
         -   _Solid On_ ; Light is on
         -   _Off_ ; Light is off
 
-    **Push Button 0** - Press and Release : If not commissioned, start thread
-    with default configurations (DEBUG)
+    **Push Button 0**
 
-        -   Pressed and hold for 6 s: Initiates the factory reset of the device.
+        -   _Press and Release_ : Start, or restart, BLE advertisement in fast mode. It will advertise in this mode
+            for 30 seconds. The device will then switch to a slower interval advertisement.
+            After 15 minutes, the adverstiment stops.
+
+        -   _Pressed and hold for 6 s_ : Initiates the factory reset of the device.
             Releasing the button within the 6-second window cancels the factory reset
             procedure. **LEDs** blink in unison when the factory reset procedure is
             initiated.
@@ -268,14 +269,12 @@ combination with JLinkRTTClient as follows:
     need to add a static ipv6 addresses on both device and then an ipv6 route to
     the border router on your PC
 
-          # On Border Router :
-          $ sudo ip addr add dev <Network interface> 2002::2/64
+#On Border Router: \$ sudo ip addr add dev <Network interface> 2002::2/64
 
-          # On PC (Linux) :
-          $ sudo ip addr add dev <Network interface> 2002::1/64
+#On PC(Linux): \$ sudo ip addr add dev <Network interface> 2002::1/64
 
-          # Add Ipv6 route on PC (Linux)
-          $ sudo ip route add <Thread global ipv6 prefix>/64 via 2002::2
+#Add Ipv6 route on PC(Linux) \$ sudo ip route add <Thread global ipv6 prefix>/64
+via 2002::2
 
 <a name="running-pigweed-rpc-console"></a>
 
@@ -285,9 +284,25 @@ combination with JLinkRTTClient as follows:
     the example by UART using the RPC LightingService. Call the following
     command in your terminal
 
-    `python -m pw_hdlc.rpc_console --device /dev/tty.<SERIALDEVICE> -b 115200 /<CHIP_ROOT>/examples/lighting-app/lighting-common/pigweed_lighting.proto -o /<YourFolder>/pw_log.out`
+    `python -m pw_hdlc.rpc_console --device /dev/tty.<SERIALDEVICE> -b 115200 /<CHIP_ROOT>/examples/lighting-app/lighting-common/lighting_service/pigweed_lighting.proto -o /<YourFolder>/pw_log.out`
 
 -   Then you can simulate a button press or realease using the following command
     where : idx = 0 or 1 for Button PB0 or PB1 action = 0 for PRESSED, 1 for
     RELEASE Test toggling the LED with
     `rpcs.chip.rpc.LightingService.ButtonEvent(idx=1,action=0)`
+
+## Memory settings
+
+While most of the RAM usage in CHIP is static, allowing easier debugging and
+optimization with symbols analysis, we still need some HEAP for the crypto and
+OpenThread. Size of the HEAP can be modified by changing the value of the
+`SL_STACK_SIZE` define inside of the BUILD.gn file of this example. Please take
+note that a HEAP size smaller than 5k can and will cause a Mbedtls failure
+during the BLE rendez-vous.
+
+To track memory usage you can set `enable_heap_monitoring = true` either in the
+BUILD.gn file or pass it as a build argument to gn. This will print on the RTT
+console the RAM usage of each individual task and the number of Memory
+allocation and Free. While this is not extensive monitoring you're welcome to
+modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory
+tracking code inside the `trackAlloc` and `trackFree` function
index dcf56d8..0bd2466 100644 (file)
@@ -21,6 +21,8 @@
 
 // ---- Lighting Example App Config ----
 
+#define APP_TASK_NAME "APP"
+
 // EFR32 WSTK Buttons
 #define PB0 0
 #define PB1 1
index e286abf..d069e08 100644 (file)
@@ -67,7 +67,7 @@ private:
     {
         kFunction_NoneSelected   = 0,
         kFunction_SoftwareUpdate = 0,
-        kFunction_StartThread    = 1,
+        kFunction_StartBleAdv    = 1,
         kFunction_FactoryReset   = 2,
 
         kFunction_Invalid
index f2040cb..5a30f90 100644 (file)
  * A size, in bytes, of the individual debug event logging buffer.
  */
 #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512)
-
-/**
- * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL
- *
- * The interval (in units of 0.625ms) at which the device will send BLE advertisements while
- * in fast advertising mode.
- *
- * 40 (25ms).
- */
-#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL 40
-
-/**
- * CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL
- *
- * The interval (in units of 0.625ms) at which the device will send BLE advertisements while
- * in slow advertisement mode.
- *
- * 800 (500ms).
- */
-#define CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL 800
-
-/**
- * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT
- *
- * The amount of time in miliseconds after which BLE should change his advertisements
- * from fast interval to slow interval.
- *
- * 30000 (30 secondes).
- */
-#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT (30 * 1000)
-
-/**
- * CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT
- *
- * The amount of time in miliseconds after which BLE advertisement should be disabled, counting
- * from the moment of slow advertisement commencement.
- *
- * Defaults to 9000000 (15 minutes).
- */
-#define CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT (15 * 60 * 1000)
index 99203b4..07dbb15 100644 (file)
@@ -253,6 +253,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
 #define INCLUDE_eTaskGetState (1)
 #define INCLUDE_xEventGroupSetBitFromISR (1)
 #define INCLUDE_xTimerPendFunctionCall (1)
+#define INCLUDE_xTaskGetHandle (1)
 
 /* Stop if an assertion fails. */
 #define configASSERT(x)                                                                                                            \
index 96bda0f..9e3340d 100644 (file)
 #include <setup_payload/QRCodeSetupPayloadGenerator.h>
 #include <setup_payload/SetupPayload.h>
 
+#include <platform/EFR32/freertos_bluetooth.h>
+
+#include <lib/support/CodeUtils.h>
+
 #include <platform/CHIPDeviceLayer.h>
 #if CHIP_ENABLE_OPENTHREAD
 #include <platform/EFR32/ThreadStackManagerImpl.h>
 
 #define FACTORY_RESET_TRIGGER_TIMEOUT 3000
 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000
-#define APP_TASK_STACK_SIZE (2048)
+#define APP_TASK_STACK_SIZE (1536)
 #define APP_TASK_PRIORITY 2
 #define APP_EVENT_QUEUE_SIZE 10
 #define EXAMPLE_VENDOR_ID 0xcafe
+namespace {
 
 TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer.
 
-static TaskHandle_t sAppTaskHandle;
-static QueueHandle_t sAppEventQueue;
+TaskHandle_t sAppTaskHandle;
+QueueHandle_t sAppEventQueue;
+
+LEDWidget sStatusLED;
+LEDWidget sLightLED;
 
-static LEDWidget sStatusLED;
-static LEDWidget sLightLED;
+bool sIsThreadProvisioned     = false;
+bool sIsThreadEnabled         = false;
+bool sHaveBLEConnections      = false;
+bool sHaveServiceConnectivity = false;
 
-static bool sIsThreadProvisioned     = false;
-static bool sIsThreadEnabled         = false;
-static bool sHaveBLEConnections      = false;
-static bool sHaveServiceConnectivity = false;
+uint8_t sAppEventQueueBuffer[APP_EVENT_QUEUE_SIZE * sizeof(AppEvent)];
+StaticQueue_t sAppEventQueueStruct;
 
+StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)];
+StaticTask_t appTaskStruct;
+} // namespace
 using namespace chip::TLV;
 using namespace ::chip::DeviceLayer;
 
@@ -74,7 +85,7 @@ int AppTask::StartAppTask()
 {
     int err = CHIP_ERROR_MAX;
 
-    sAppEventQueue = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent));
+    sAppEventQueue = xQueueCreateStatic(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent), sAppEventQueueBuffer, &sAppEventQueueStruct);
     if (sAppEventQueue == NULL)
     {
         EFR32_LOG("Failed to allocate app event queue");
@@ -82,11 +93,11 @@ int AppTask::StartAppTask()
     }
 
     // Start App task.
-    if (xTaskCreate(AppTaskMain, "APP", APP_TASK_STACK_SIZE / sizeof(StackType_t), NULL, 1, &sAppTaskHandle) == pdPASS)
+    sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct);
+    if (sAppTaskHandle != NULL)
     {
         err = CHIP_NO_ERROR;
     }
-
     return err;
 }
 
@@ -321,7 +332,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent)
 
     // If we reached here, the button was held past FACTORY_RESET_TRIGGER_TIMEOUT,
     // initiate factory reset
-    if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartThread)
+    if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv)
     {
         EFR32_LOG("Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
 
@@ -366,29 +377,27 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
         if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_NoneSelected)
         {
             sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT);
-            sAppTask.mFunction = kFunction_StartThread;
+            sAppTask.mFunction = kFunction_StartBleAdv;
         }
     }
     else
     {
-        // If the button was released before factory reset got initiated, start Thread Network
-        if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartThread)
+        // If the button was released before factory reset got initiated, start BLE advertissement in fast mode
+        if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv)
         {
             sAppTask.CancelTimer();
             sAppTask.mFunction = kFunction_NoneSelected;
-#if CHIP_ENABLE_OPENTHREAD
-            if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned())
+
+            if (!ConnectivityMgr().IsThreadProvisioned())
             {
-                StartDefaultThreadNetwork();
-                EFR32_LOG("Device is not commissioned to a Thread network. Starting with the default configuration.");
+                // Enable BLE advertisements
+                ConnectivityMgr().SetBLEAdvertisingEnabled(true);
+                ConnectivityMgr().SetBLEAdvertisingMode(ConnectivityMgr().kFastAdvertising);
             }
             else
             {
-                EFR32_LOG("Device is commissioned to a Thread network.");
+                EFR32_LOG("Network is already provisioned, Ble advertissement not enabled");
             }
-#else
-            EFR32_LOG("Thread is not defined.");
-#endif
         }
         else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset)
         {
@@ -495,6 +504,10 @@ void AppTask::PostEvent(const AppEvent * aEvent)
             EFR32_LOG("Failed to post event to app task event queue");
         }
     }
+    else
+    {
+        EFR32_LOG("Event Queue is NULL should never happen");
+    }
 }
 
 void AppTask::DispatchEvent(AppEvent * aEvent)
index d943086..31fdc96 100644 (file)
@@ -22,7 +22,7 @@
 #include "PigweedLoggerMutex.h"
 #include "pigweed/RpcService.h"
 
-#include "pigweed_lighting.rpc.pb.h"
+#include "lighting_service/pigweed_lighting.rpc.pb.h"
 #include "pw_hdlc/rpc_channel.h"
 #include "pw_hdlc/rpc_packets.h"
 #include "pw_rpc/server.h"
index 4db0211..b9a5164 100644 (file)
 #include "Server.h"
 #include "init_efrPlatform.h"
 
+#ifdef HEAP_MONITORING
+#include "MemMonitoring.h"
+#endif
+
 #if DISPLAY_ENABLED
 #include "lcd.h"
 #endif
@@ -99,12 +103,15 @@ int main(void)
     int ret = CHIP_ERROR_MAX;
 
     init_efrPlatform();
+    mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);
 
 #if PW_RPC_ENABLED
     chip::rpc::Init();
 #endif
 
-    mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);
+#ifdef HEAP_MONITORING
+    MemMonitoring::startHeapMonitoring();
+#endif
 
     // Initialize mbedtls threading support on EFR32
     THREADING_setup();
@@ -162,7 +169,6 @@ int main(void)
         appError(ret);
     }
 #endif // CHIP_ENABLE_OPENTHREAD
-
     EFR32_LOG("Starting App Task");
     ret = GetAppTask().StartAppTask();
     if (ret != CHIP_NO_ERROR)
index a7ef3fa..a0fb873 100644 (file)
@@ -58,8 +58,9 @@ devices.
 ### Bluetooth LE Advertising
 
 In this example, to commission the device onto a Project CHIP network, it must
-be discoverable over Bluetooth LE. Bluetooth LE advertising is started
-automatically when the device is powered up.
+be discoverable over Bluetooth LE. For security reasons, you must start
+Bluetooth LE advertising manually after powering up the device by pressing
+Button USERINTERFACE.
 
 ### Bluetooth LE Rendezvous
 
@@ -105,23 +106,26 @@ states are depicted:
 **LED D3** shows the state of the simulated light bulb. When the LED is lit the
 light bulb is on; when not lit, the light bulb is off.
 
-**Button SW2** can be used to change the state of the simulated light bulb. This
-can be used to mimic a user manually operating a switch. The button behaves as a
-toggle, swapping the state every time it is pressed.
-
-**Button SW3** can be used to reset the device to a default state. Pressing and
+**Button SW2** can be used to reset the device to a default state. Pressing and
 holding Button SW3 for 6 seconds initiates a factory reset. After an initial
 period of 3 seconds, LED2 D2 and D3 will flash in unison to signal the pending
 reset. Holding the button past 6 seconds will cause the device to reset its
 persistent configuration and initiate a reboot. The reset action can be
 cancelled by releasing the button at any point before the 6 second limit.
 
+**Button SW3** can be used to change the state of the simulated light bulb. This
+can be used to mimic a user manually operating a switch. The button behaves as a
+toggle, swapping the state every time it is pressed.
+
 **Button SW4** can be used for joining a predefined Thread network advertised by
 a Border Router. Default parameters for a Thread network are hard-coded and are
 being used if this button is pressed.
 
 The remaining two LEDs (D1/D2) and button (SW1) are unused.
 
+Directly on the development board, **Button USERINTERFACE** can be used for
+enabling Bluetooth LE advertising for a predefined period of time.
+
 <a name="building"></a>
 
 ## Building
index 9a86612..fecb36a 100644 (file)
@@ -212,7 +212,7 @@ void AppTask::AppTaskMain(void * pvParameter)
 
 void AppTask::ButtonEventHandler(uint8_t pin_no, uint8_t button_action)
 {
-    if ((pin_no != RESET_BUTTON) && (pin_no != LIGHT_BUTTON) && (pin_no != JOIN_BUTTON))
+    if ((pin_no != RESET_BUTTON) && (pin_no != LIGHT_BUTTON) && (pin_no != JOIN_BUTTON) && (pin_no != BLE_BUTTON))
     {
         return;
     }
@@ -234,6 +234,10 @@ void AppTask::ButtonEventHandler(uint8_t pin_no, uint8_t button_action)
     {
         button_event.Handler = JoinHandler;
     }
+    else if (pin_no == BLE_BUTTON)
+    {
+        button_event.Handler = BleHandler;
+    }
 
     sAppTask.PostEvent(&button_event);
 }
@@ -271,6 +275,9 @@ void AppTask::HandleKeyboard(void)
         case gKBD_EventPB3_c:
             ButtonEventHandler(JOIN_BUTTON, JOIN_BUTTON_PUSH);
             break;
+        case gKBD_EventPB4_c:
+            ButtonEventHandler(BLE_BUTTON, BLE_BUTTON_PUSH);
+            break;
         default:
             break;
         }
@@ -452,6 +459,37 @@ void AppTask::JoinHandler(AppEvent * aEvent)
     ThreadStart();
 }
 
+void AppTask::BleHandler(AppEvent * aEvent)
+{
+    if (aEvent->ButtonEvent.PinNo != BLE_BUTTON)
+        return;
+
+    if (sAppTask.mFunction != kFunction_NoneSelected)
+    {
+        K32W_LOG("Another function is scheduled. Could not toggle BLE state!");
+        return;
+    }
+
+    if (ConnectivityMgr().IsBLEAdvertisingEnabled())
+    {
+        ConnectivityMgr().SetBLEAdvertisingEnabled(false);
+        K32W_LOG("Stopped BLE Advertising!");
+    }
+    else
+    {
+        ConnectivityMgr().SetBLEAdvertisingEnabled(true);
+
+        if (OpenDefaultPairingWindow(chip::ResetAdmins::kNo) == CHIP_NO_ERROR)
+        {
+            K32W_LOG("Started BLE Advertising!");
+        }
+        else
+        {
+            K32W_LOG("OpenDefaultPairingWindow() failed");
+        }
+    }
+}
+
 void AppTask::CancelTimer()
 {
     if (xTimerStop(sFunctionTimer, 0) == pdFAIL)
index 98f2c12..d032c58 100644 (file)
@@ -56,6 +56,7 @@ private:
     static void KBD_Callback(uint8_t events);
     static void HandleKeyboard(void);
     static void JoinHandler(AppEvent * aEvent);
+    static void BleHandler(AppEvent * aEvent);
     static void LightActionEventHandler(AppEvent * aEvent);
     static void ResetActionEventHandler(AppEvent * aEvent);
     static void InstallEventHandler(AppEvent * aEvent);
index abffcc9..9d463eb 100644 (file)
 #define RESET_BUTTON 1
 #define LIGHT_BUTTON 2
 #define JOIN_BUTTON 3
+#define BLE_BUTTON 4
 
 #define RESET_BUTTON_PUSH 1
 #define LIGHT_BUTTON_PUSH 2
 #define JOIN_BUTTON_PUSH 3
+#define BLE_BUTTON_PUSH 4
 
 #define APP_BUTTON_PUSH 1
 
index 4e77b89..7080d33 100644 (file)
 # limitations under the License.
 
 import("//build_overrides/chip.gni")
+import("${chip_root}/examples/lighting-app/lighting-common/lighting.gni")
 import("${chip_root}/src/app/common_flags.gni")
 import("${chip_root}/src/lib/core/core.gni")
 
+if (enable_pw_rpc) {
+  import("//build_overrides/pigweed.gni")
+  import("$dir_pw_protobuf_compiler/proto.gni")
+}
+
 config("includes") {
   include_dirs = [
     ".",
@@ -23,6 +29,13 @@ config("includes") {
   ]
 }
 
+if (enable_pw_rpc) {
+  pw_proto_library("lighting_service") {
+    sources = [ "lighting_service/pigweed_lighting.proto" ]
+    inputs = [ "lighting_service/pigweed_lighting.options" ]
+  }
+}
+
 source_set("lighting-common") {
   sources = [
     "${chip_root}/src/app/clusters/bindings/bindings.cpp",
@@ -50,7 +63,7 @@ source_set("lighting-common") {
     "gen/callback-stub.cpp",
   ]
 
-  if (chip_app_use_interaction_model) {
+  if (chip_enable_interaction_model) {
     sources += [
       "${chip_root}/src/app/util/ember-compatibility-functions.cpp",
       "gen/IMClusterCommandHandler.cpp",
index 2f9a5a6..8059674 100644 (file)
@@ -118,6 +118,13 @@ typedef struct _DeviceInformationRecord
     uint8_t sort;
 } EmberAfDeviceInformationRecord;
 
+// Struct for DeviceType
+typedef struct _DeviceType
+{
+    chip::DeviceTypeId type;
+    uint16_t revision;
+} EmberAfDeviceType;
+
 // Struct for DiscoverAttributesInfoRecord
 typedef struct _DiscoverAttributesInfoRecord
 {
index 6ca0739..cd1d95a 100644 (file)
 #define ZCL_FINISH_TIME_ATTRIBUTE_ID (0x0001)
 #define ZCL_REMAINING_TIME_ATTRIBUTE_ID (0x0002)
 
+// Attribute ids for cluster: Descriptor
+
+// Client attributes
+
+// Server attributes
+#define ZCL_DEVICE_LIST_ATTRIBUTE_ID (0x0000)
+#define ZCL_SERVER_LIST_ATTRIBUTE_ID (0x0001)
+#define ZCL_CLIENT_LIST_ATTRIBUTE_ID (0x0002)
+#define ZCL_PARTS_LIST_ATTRIBUTE_ID (0x0003)
+
 // Attribute ids for cluster: Poll Control
 
 // Client attributes
 // Server attributes
 #define ZCL_MAX_DURATION_ATTRIBUTE_ID (0x0000)
 
+// Attribute ids for cluster: Media Playback
+
+// Client attributes
+
+// Server attributes
+#define ZCL_CURRENT_STATE_ATTRIBUTE_ID (0x0000)
+
 // Attribute ids for cluster: Low Power
 
 // Client attributes
 
 // Server attributes
 
+// Attribute ids for cluster: Content Launch
+
+// Client attributes
+
+// Server attributes
+
 // Attribute ids for cluster: Application Basic
 
 // Client attributes
 
 // Server attributes
 
-// Attribute ids for cluster: Media Playback
-
-// Client attributes
-
-// Server attributes
-#define ZCL_CURRENT_STATE_ATTRIBUTE_ID (0x0000)
-
-// Attribute ids for cluster: Content Launch
-
-// Client attributes
-
-// Server attributes
-
 // Attribute ids for cluster: Group Key Management
 
 // Client attributes
index a6caf3a..ee211ce 100644 (file)
@@ -34,4 +34,4 @@ ZCL_DATA8_ATTRIBUTE_TYPE, 1, ZCL_DATA16_ATTRIBUTE_TYPE, 2, ZCL_DATA24_ATTRIBUTE_
     ZCL_DATE_ATTRIBUTE_TYPE, 4, ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4, ZCL_CLUSTER_ID_ATTRIBUTE_TYPE, 2, ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE,
     2, ZCL_BACNET_OID_ATTRIBUTE_TYPE, 4, ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8, ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
     ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE, 1, ZCL_GROUP_ID_ATTRIBUTE_TYPE, 2, ZCL_COMMAND_ID_ATTRIBUTE_TYPE, 1, ZCL_NODE_ID_ATTRIBUTE_TYPE,
-    8,
+    8, ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE, 4,
index 56900dc..6f12999 100644 (file)
@@ -82,5 +82,6 @@ enum
     ZCL_GROUP_ID_ATTRIBUTE_TYPE          = 0xF3, // Group Id
     ZCL_COMMAND_ID_ATTRIBUTE_TYPE        = 0xF4, // Command Id
     ZCL_NODE_ID_ATTRIBUTE_TYPE           = 0xF5, // Node Id
+    ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE    = 0xF6, // Device Type Id
     ZCL_UNKNOWN_ATTRIBUTE_TYPE           = 0xFF, // Unknown
 };
index 79d1e15..775f29f 100644 (file)
                                                                                                                                    \
                                                           ZCL_SQUAWK_COMMAND_ID, "u", squawkInfo);
 
+/** @brief Command description for PlayRequest
+ *
+ * Command: PlayRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPlayRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_PLAY_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for PauseRequest
+ *
+ * Command: PauseRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPauseRequest() emberAfFillExternalBuffer(mask,                                                                  \
+                                                                                                                                   \
+                                                            ZCL_PAUSE_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for StopRequest
+ *
+ * Command: StopRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterStopRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_STOP_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for StartOverRequest
+ *
+ * Command: StartOverRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterStartOverRequest() emberAfFillExternalBuffer(mask,                                                              \
+                                                                                                                                   \
+                                                                ZCL_START_OVER_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for PreviousRequest
+ *
+ * Command: PreviousRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPreviousRequest() emberAfFillExternalBuffer(mask,                                                               \
+                                                                                                                                   \
+                                                               ZCL_PREVIOUS_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for NextRequest
+ *
+ * Command: NextRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterNextRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_NEXT_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for RewindRequest
+ *
+ * Command: RewindRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterRewindRequest() emberAfFillExternalBuffer(mask,                                                                 \
+                                                                                                                                   \
+                                                             ZCL_REWIND_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for FastForwardRequest
+ *
+ * Command: FastForwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterFastForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
+                                                                                                                                   \
+                                                                  ZCL_FAST_FORWARD_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for SkipForwardRequest
+ *
+ * Command: SkipForwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterSkipForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
+                                                                                                                                   \
+                                                                  ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for SkipBackwardRequest
+ *
+ * Command: SkipBackwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterSkipBackwardRequest() emberAfFillExternalBuffer(mask,                                                           \
+                                                                                                                                   \
+                                                                   ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID, "", );
+
 /** @brief Command description for Sleep
  *
  * Command: Sleep
                                                                                                                                    \
                                                   ZCL_SLEEP_COMMAND_ID, "", );
 
+/** @brief Command description for LaunchContent
+ *
+ * Command: LaunchContent
+ * @param contentLaunchStatus ContentLaunchStatus
+ */
+#define emberAfFillCommandContent                                                                                                  \
+    LaunchClusterLaunchContent(contentLaunchStatus)                                                                                \
+        emberAfFillExternalBuffer(mask,                                                                                            \
+                                                                                                                                   \
+                                  ZCL_LAUNCH_CONTENT_COMMAND_ID, "u", contentLaunchStatus);
+
+/** @brief Command description for LaunchURL
+ *
+ * Command: LaunchURL
+ * @param contentLaunchStatus ContentLaunchStatus
+ */
+#define emberAfFillCommandContent                                                                                                  \
+    LaunchClusterLaunchURL(contentLaunchStatus) emberAfFillExternalBuffer(mask,                                                    \
+                                                                                                                                   \
+                                                                          ZCL_LAUNCH_URL_COMMAND_ID, "u", contentLaunchStatus);
+
 /** @brief Command description for MatchProtocolAddress
  *
  * Command: MatchProtocolAddress
                                                                                                                                    \
                               ZCL_UNBIND_COMMAND_ID, "uuuu", nodeId, groupId, endpointId, clusterId);
 
-/** @brief Command description for PlayRequest
- *
- * Command: PlayRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPlayRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_PLAY_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for PauseRequest
- *
- * Command: PauseRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPauseRequest() emberAfFillExternalBuffer(mask,                                                                  \
-                                                                                                                                   \
-                                                            ZCL_PAUSE_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for StopRequest
- *
- * Command: StopRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterStopRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_STOP_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for StartOverRequest
- *
- * Command: StartOverRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterStartOverRequest() emberAfFillExternalBuffer(mask,                                                              \
-                                                                                                                                   \
-                                                                ZCL_START_OVER_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for PreviousRequest
- *
- * Command: PreviousRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPreviousRequest() emberAfFillExternalBuffer(mask,                                                               \
-                                                                                                                                   \
-                                                               ZCL_PREVIOUS_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for NextRequest
- *
- * Command: NextRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterNextRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_NEXT_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for RewindRequest
- *
- * Command: RewindRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterRewindRequest() emberAfFillExternalBuffer(mask,                                                                 \
-                                                                                                                                   \
-                                                             ZCL_REWIND_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for FastForwardRequest
- *
- * Command: FastForwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterFastForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
-                                                                                                                                   \
-                                                                  ZCL_FAST_FORWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for SkipForwardRequest
- *
- * Command: SkipForwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterSkipForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
-                                                                                                                                   \
-                                                                  ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for SkipBackwardRequest
- *
- * Command: SkipBackwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterSkipBackwardRequest() emberAfFillExternalBuffer(mask,                                                           \
-                                                                                                                                   \
-                                                                   ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for LaunchContent
- *
- * Command: LaunchContent
- * @param contentLaunchStatus ContentLaunchStatus
- */
-#define emberAfFillCommandContent                                                                                                  \
-    LaunchClusterLaunchContent(contentLaunchStatus)                                                                                \
-        emberAfFillExternalBuffer(mask,                                                                                            \
-                                                                                                                                   \
-                                  ZCL_LAUNCH_CONTENT_COMMAND_ID, "u", contentLaunchStatus);
-
-/** @brief Command description for LaunchURL
- *
- * Command: LaunchURL
- * @param contentLaunchStatus ContentLaunchStatus
- */
-#define emberAfFillCommandContent                                                                                                  \
-    LaunchClusterLaunchURL(contentLaunchStatus) emberAfFillExternalBuffer(mask,                                                    \
-                                                                                                                                   \
-                                                                          ZCL_LAUNCH_URL_COMMAND_ID, "u", contentLaunchStatus);
-
 /** @brief Command description for CommandOne
  *
  * Command: CommandOne
index 9e82931..bbd16b6 100644 (file)
@@ -71,6 +71,9 @@
 // Definitions for cluster: Appliance Control
 #define ZCL_APPLIANCE_CONTROL_CLUSTER_ID (0x001B)
 
+// Definitions for cluster: Descriptor
+#define ZCL_DESCRIPTOR_CLUSTER_ID (0x001D)
+
 // Definitions for cluster: Poll Control
 #define ZCL_POLL_CONTROL_CLUSTER_ID (0x0020)
 
 // Definitions for cluster: IAS WD
 #define ZCL_IAS_WD_CLUSTER_ID (0x0502)
 
+// Definitions for cluster: Media Playback
+#define ZCL_MEDIA_PLAYBACK_CLUSTER_ID (0x0506)
+
 // Definitions for cluster: Low Power
 #define ZCL_LOW_POWER_CLUSTER_ID (0x0508)
 
+// Definitions for cluster: Content Launch
+#define ZCL_CONTENT_LAUNCH_CLUSTER_ID (0x050A)
+
 // Definitions for cluster: Application Basic
 #define ZCL_APPLICATION_BASIC_CLUSTER_ID (0x050D)
 
 // Definitions for cluster: Binding
 #define ZCL_BINDING_CLUSTER_ID (0xF000)
 
-// Definitions for cluster: Media Playback
-#define ZCL_MEDIA_PLAYBACK_CLUSTER_ID (0xF001)
-
-// Definitions for cluster: Content Launch
-#define ZCL_CONTENT_LAUNCH_CLUSTER_ID (0xF002)
-
 // Definitions for cluster: Group Key Management
 #define ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID (0xF004)
 
index 864943b..268678a 100644 (file)
 #define ZCL_START_WARNING_COMMAND_ID (0x00)
 #define ZCL_SQUAWK_COMMAND_ID (0x01)
 
+// Commands for cluster: Media Playback
+#define ZCL_PLAY_REQUEST_COMMAND_ID (0x00)
+#define ZCL_PLAYBACK_COMMAND_ID (0x00)
+#define ZCL_PAUSE_REQUEST_COMMAND_ID (0x01)
+#define ZCL_STOP_REQUEST_COMMAND_ID (0x02)
+#define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03)
+#define ZCL_PREVIOUS_REQUEST_COMMAND_ID (0x04)
+#define ZCL_NEXT_REQUEST_COMMAND_ID (0x05)
+#define ZCL_REWIND_REQUEST_COMMAND_ID (0x06)
+#define ZCL_FAST_FORWARD_REQUEST_COMMAND_ID (0x07)
+#define ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID (0x08)
+#define ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID (0x09)
+
 // Commands for cluster: Low Power
 #define ZCL_SLEEP_COMMAND_ID (0x00)
 
+// Commands for cluster: Content Launch
+#define ZCL_LAUNCH_CONTENT_COMMAND_ID (0x00)
+#define ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID (0x00)
+#define ZCL_LAUNCH_URL_COMMAND_ID (0x01)
+#define ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID (0x01)
+
 // Commands for cluster: Generic Tunnel
 #define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00)
 #define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00)
 #define ZCL_BIND_COMMAND_ID (0x00)
 #define ZCL_UNBIND_COMMAND_ID (0x01)
 
-// Commands for cluster: Media Playback
-#define ZCL_PLAY_REQUEST_COMMAND_ID (0x00)
-#define ZCL_PLAYBACK_COMMAND_ID (0x00)
-#define ZCL_PAUSE_REQUEST_COMMAND_ID (0x01)
-#define ZCL_STOP_REQUEST_COMMAND_ID (0x02)
-#define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03)
-#define ZCL_PREVIOUS_REQUEST_COMMAND_ID (0x04)
-#define ZCL_NEXT_REQUEST_COMMAND_ID (0x05)
-#define ZCL_REWIND_REQUEST_COMMAND_ID (0x06)
-#define ZCL_FAST_FORWARD_REQUEST_COMMAND_ID (0x07)
-#define ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID (0x08)
-#define ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID (0x09)
-
-// Commands for cluster: Content Launch
-#define ZCL_LAUNCH_CONTENT_COMMAND_ID (0x00)
-#define ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID (0x00)
-#define ZCL_LAUNCH_URL_COMMAND_ID (0x01)
-#define ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID (0x01)
-
 // Commands for cluster: Sample Mfg Specific Cluster
 #define ZCL_COMMAND_ONE_COMMAND_ID (0x00)
 
index dd6018f..d7e7ffe 100644 (file)
 #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x
 #define ZAP_REPORT_DIRECTION(x) ZRD(x)
 
-// Use this macro to check if Reporting plugin is included
-#define EMBER_AF_PLUGIN_REPORTING
 // User options for plugin Reporting
 #define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (2)
 #define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS
index e3207b7..4054969 100644 (file)
 #define CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER
 #endif
 
+#if defined(ZCL_USING_DESCRIPTOR_CLUSTER_SERVER) || defined(ZCL_USING_DESCRIPTOR_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER { ZCL_DESCRIPTOR_CLUSTER_ID, 29, "Descriptor" },
+#else
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER
+#endif
+
 #if defined(ZCL_USING_POLL_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_POLL_CONTROL_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER { ZCL_POLL_CONTROL_CLUSTER_ID, 32, "Poll Control" },
 #else
 #define CHIP_PRINTCLUSTER_IAS_WD_CLUSTER
 #endif
 
+#if defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_SERVER) || defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER { ZCL_MEDIA_PLAYBACK_CLUSTER_ID, 1286, "Media Playback" },
+#else
+#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER
+#endif
+
 #if defined(ZCL_USING_LOW_POWER_CLUSTER_SERVER) || defined(ZCL_USING_LOW_POWER_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER { ZCL_LOW_POWER_CLUSTER_ID, 1288, "Low Power" },
 #else
 #define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER
 #endif
 
+#if defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_SERVER) || defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER { ZCL_CONTENT_LAUNCH_CLUSTER_ID, 1290, "Content Launch" },
+#else
+#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER
+#endif
+
 #if defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER { ZCL_APPLICATION_BASIC_CLUSTER_ID, 1293, "Application Basic" },
 #else
 #define CHIP_PRINTCLUSTER_BINDING_CLUSTER
 #endif
 
-#if defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_SERVER) || defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT)
-#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER { ZCL_MEDIA_PLAYBACK_CLUSTER_ID, 61441, "Media Playback" },
-#else
-#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER
-#endif
-
-#if defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_SERVER) || defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT)
-#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER { ZCL_CONTENT_LAUNCH_CLUSTER_ID, 61442, "Content Launch" },
-#else
-#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER
-#endif
-
 #if defined(ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_SERVER) || defined(ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER { ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID, 61444, "Group Key Management" },
 #else
     CHIP_PRINTCLUSTER_OTA_BOOTLOAD_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_POWER_PROFILE_CLUSTER                                                                                        \
     CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER                                                                                    \
+    CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER                                                                                           \
     CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER                                                                                            \
     CHIP_PRINTCLUSTER_IAS_ZONE_CLUSTER                                                                                             \
     CHIP_PRINTCLUSTER_IAS_ACE_CLUSTER                                                                                              \
     CHIP_PRINTCLUSTER_IAS_WD_CLUSTER                                                                                               \
+    CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER                                                                                            \
+    CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER                                                                                    \
     CHIP_PRINTCLUSTER_GENERIC_TUNNEL_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_BACNET_PROTOCOL_TUNNEL_CLUSTER                                                                               \
     CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER                                                                                    \
     CHIP_PRINTCLUSTER_BINDING_CLUSTER                                                                                              \
-    CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER                                                                                       \
-    CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER                                                                                 \
     CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER                                                                                  \
     CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER_2                                                                                \
diff --git a/examples/lighting-app/lighting-common/lighting.gni b/examples/lighting-app/lighting-common/lighting.gni
new file mode 100644 (file)
index 0000000..8a8ed9a
--- /dev/null
@@ -0,0 +1,18 @@
+# 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.
+
+declare_args() {
+  # Enable Pigweed RPC integration.
+  enable_pw_rpc = false
+}
index b34a4bc..940a204 100644 (file)
@@ -122,7 +122,7 @@ CHIP_ERROR PrintQRCodeContent()
     err = ConfigurationMgr().GetProductId(productId);
     SuccessOrExit(err);
 
-    payload.version       = 1;
+    payload.version       = 0;
     payload.vendorID      = vendorId;
     payload.productID     = productId;
     payload.setUpPINCode  = setUpPINCode;
index 871d410..72dc0e3 100644 (file)
@@ -423,10 +423,13 @@ void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t
     ARG_UNUSED(arg);
     if ((event->Type == DeviceEventType::kServiceProvisioningChange) && ConnectivityMgr().IsThreadProvisioned())
     {
-        const int result = sNFC.StopTagEmulation();
-        if (result)
+        if (sNFC.IsTagEmulationStarted())
         {
-            LOG_ERR("Stopping NFC Tag emulation failed");
+            const int result = sNFC.StopTagEmulation();
+            if (result)
+            {
+                LOG_ERR("Stopping NFC Tag emulation failed");
+            }
         }
     }
 }
index a49f9aa..668afd5 100644 (file)
@@ -28,19 +28,19 @@ LOG_MODULE_DECLARE(app);
 
 LightingManager LightingManager::sLight;
 
-int LightingManager::Init(const char * pwmDeviceName, uint32_t pwmChannel)
+int LightingManager::Init(const device * pwmDevice, uint32_t pwmChannel)
 {
     // We use a gpioPin instead of a LEDWidget here because we want to use PWM
     // and other features instead of just on/off.
 
     mState      = kState_On;
     mLevel      = kMaxLevel;
-    mPwmDevice  = device_get_binding(pwmDeviceName);
+    mPwmDevice  = pwmDevice;
     mPwmChannel = pwmChannel;
 
-    if (!mPwmDevice)
+    if (!device_is_ready(mPwmDevice))
     {
-        LOG_ERR("Cannot find PWM device %s", log_strdup(pwmDeviceName));
+        LOG_ERR("PWM device %s is not ready", mPwmDevice->name);
         return -ENODEV;
     }
 
index 1ec504d..31430a5 100644 (file)
@@ -30,7 +30,7 @@
 #define BLE_ADVERTISEMENT_START_BUTTON_MASK DK_BTN4_MSK
 
 #define SYSTEM_STATE_LED DK_LED1 // led0 in device tree
-#define LIGHTING_PWM_DEVICE DT_PWMS_LABEL(DT_ALIAS(pwm_led1))
+#define LIGHTING_PWM_DEVICE DEVICE_DT_GET(DT_PWMS_CTLR(DT_ALIAS(pwm_led1)))
 #define LIGHTING_PWM_CHANNEL DT_PWMS_CHANNEL(DT_ALIAS(pwm_led1))
 
 // Time it takes in ms for the simulated actuator to move from one state to another.
index 06aabbf..3b22e11 100644 (file)
@@ -43,7 +43,7 @@ public:
 
     using LightingCallback_fn = void (*)(Action_t, int32_t);
 
-    int Init(const char * pwmDeviceName, uint32_t pwmChannel);
+    int Init(const device * pwmDevice, uint32_t pwmChannel);
     bool IsTurnedOn() const { return mState == kState_On; }
     uint8_t GetLevel() const { return mLevel; }
     bool InitiateAction(Action_t aAction, int32_t aActor, uint8_t size, uint8_t * value);
index ed02cb0..7f47411 120000 (symlink)
@@ -1 +1 @@
-../../lighting-common/pigweed_lighting.options
\ No newline at end of file
+../../lighting-common/lighting_service/pigweed_lighting.options
\ No newline at end of file
index 1acab2e..6cdddb3 120000 (symlink)
@@ -1 +1 @@
-../../lighting-common/pigweed_lighting.proto
\ No newline at end of file
+../../lighting-common/lighting_service/pigweed_lighting.proto
\ No newline at end of file
index 5072d04..6e40cd2 100644 (file)
@@ -37,4 +37,3 @@ CONFIG_MPU_STACK_GUARD=y
 
 # CHIP configuration
 CONFIG_CHIP_PROJECT_CONFIG="main/include/CHIPProjectConfig.h"
-CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/nrfconnect/project_include/OpenThreadConfig.h"
index a1c47c3..35dd449 100644 (file)
@@ -39,7 +39,7 @@ CONFIG_BOOT_BANNER=n
 # Configure Zephyr logger with defaults backends disabled as the app provides its own,
 # based on Pigweed HDLC.
 CONFIG_LOG=y
-CONFIG_LOG_MINIMAL=n
-CONFIG_LOG_IMMEDIATE=y
+CONFIG_LOG_MODE_MINIMAL=n
+CONFIG_LOG_MODE_IMMEDIATE=y
 CONFIG_LOG_BACKEND_UART=n
 CONFIG_LOG_BACKEND_RTT=n
index 0c6b436..62d4f2f 100644 (file)
@@ -29,6 +29,7 @@ declare_args() {
   # Dump memory usage at link time.
   chip_print_memory_usage = false
   setupPinCode = 73141520
+  enable_heap_monitoring = false
 }
 
 show_qr_code = true
@@ -54,6 +55,7 @@ efr32_sdk("sdk") {
   defines = [
     "BOARD_ID=${efr32_board}",
     "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}",
+    "SL_HEAP_SIZE=(10 * 1024)",
   ]
 }
 
@@ -86,6 +88,7 @@ efr32_executable("lock_app") {
     "${examples_plat_dir}/LEDWidget.cpp",
     "${examples_plat_dir}/Service.cpp",
     "${examples_plat_dir}/init_efrPlatform.cpp",
+    "${examples_plat_dir}/uart.c",
     "src/AppTask.cpp",
     "src/BoltLockManager.cpp",
     "src/ButtonHandler.cpp",
@@ -100,10 +103,15 @@ efr32_executable("lock_app") {
   }
   output_dir = root_out_dir
 
+  if (enable_heap_monitoring) {
+    defines += [ "HEAP_MONITORING" ]
+    sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ]
+  }
+
   if (efr32_family == "efr32mg12") {
-    ldscript = "${efr32_project_dir}/ldscripts/efr32-lock-example-MG12P.ld"
+    ldscript = "${examples_plat_dir}/ldscripts/efr32-MG12P.ld"
   } else if (efr32_family == "efr32mg21") {
-    ldscript = "${efr32_project_dir}/ldscripts/efr32-lock-example-MG21.ld"
+    ldscript = "${examples_plat_dir}/ldscripts/efr32-MG21.ld"
   }
 
   ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
index fa9c1b2..1f0961a 100644 (file)
@@ -1,4 +1,4 @@
-# CHIP EFR32 Lock Example
+#CHIP EFR32 Lock Example
 
 An example showing the use of CHIP on the Silicon Labs EFR32 MG12.
 
@@ -50,11 +50,9 @@ Silicon Labs platform.
 
 -   Install some additional tools(likely already present for CHIP developers):
 
-           # Linux
-           $ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
+#Linux \$ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
 
-           # Mac OS X
-           $ brew install ninja
+#Mac OS X \$ brew install ninja
 
 -   Supported hardware:
 
@@ -202,10 +200,13 @@ combination with JLinkRTTClient as follows:
         -   _Blinking_ ; Bolt is moving to the desired state
         -   _Off_ ; Bolt is unlocked
 
-    **Push Button 0** - Press and Release : If not commissioned, start thread
-    with default configurations (DEBUG)
+    **Push Button 0**
 
-        -   Pressed and hold for 6 s: Initiates the factory reset of the device.
+        -   _Press and Release_ : Start, or restart, BLE advertisement in fast mode. It will advertise in this mode
+            for 30 seconds. The device will then switch to a slower interval advertisement.
+            After 15 minutes, the adverstiment stops.
+
+        -   _Pressed and hold for 6 s_ : Initiates the factory reset of the device.
             Releasing the button within the 6-second window cancels the factory reset
             procedure. **LEDs** blink in unison when the factory reset procedure is
             initiated.
@@ -257,11 +258,25 @@ combination with JLinkRTTClient as follows:
     need to add a static ipv6 addresses on both device and then an ipv6 route to
     the border router on your PC
 
-          # On Border Router :
-          $ sudo ip addr add dev <Network interface> 2002::2/64
+#On Border Router: \$ sudo ip addr add dev <Network interface> 2002::2/64
+
+#On PC(Linux): \$ sudo ip addr add dev <Network interface> 2002::1/64
+
+#Add Ipv6 route on PC(Linux) \$ sudo ip route add <Thread global ipv6 prefix>/64
+via 2002::2
+
+## Memory settings
 
-          # On PC (Linux) :
-          $ sudo ip addr add dev <Network interface> 2002::1/64
+While most of the RAM usage in CHIP is static, allowing easier debugging and
+optimization with symbols analysis, we still need some HEAP for the crypto and
+OpenThread. Size of the HEAP can be modified by changing the value of the
+`SL_STACK_SIZE` define inside of the BUILD.gn file of this example. Please take
+note that a HEAP size smaller than 5k can and will cause a Mbedtls failure
+during the BLE rendez-vous.
 
-          # Add Ipv6 route on PC (Linux)
-          $ sudo ip route add <Thread global ipv6 prefix>/64 via 2002::2
+To track memory usage you can set `enable_heap_monitoring = true` either in the
+BUILD.gn file or pass it as a build argument to gn. This will print on the RTT
+console the RAM usage of each individual task and the number of Memory
+allocation and Free. While this is not extensive monitoring you're welcome to
+modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory
+tracking code inside the `trackAlloc` and `trackFree` function
index a07b8bd..6c41f4e 100644 (file)
@@ -21,6 +21,8 @@
 
 // ---- Lock Example App Config ----
 
+#define APP_TASK_NAME "APP"
+
 // EFR32 WSTK Buttons
 #define PB0 0
 #define PB1 1
index ae7659b..0a01b1e 100644 (file)
@@ -67,7 +67,7 @@ private:
     {
         kFunction_NoneSelected   = 0,
         kFunction_SoftwareUpdate = 0,
-        kFunction_StartThread    = 1,
+        kFunction_StartBleAdv    = 1,
         kFunction_FactoryReset   = 2,
 
         kFunction_Invalid
index 17da147..ffac445 100644 (file)
  * A size, in bytes, of the individual debug event logging buffer.
  */
 #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512)
-
-/**
- * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL
- *
- * The interval (in units of 0.625ms) at which the device will send BLE advertisements while
- * in fast advertising mode.
- *
- * 40 (25ms).
- */
-#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL 40
-
-/**
- * CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL
- *
- * The interval (in units of 0.625ms) at which the device will send BLE advertisements while
- * in slow advertisement mode.
- *
- * 800 (500ms).
- */
-#define CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL 800
-
-/**
- * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT
- *
- * The amount of time in miliseconds after which BLE should change his advertisements
- * from fast interval to slow interval.
- *
- * 30000 (30 secondes).
- */
-#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT (30 * 1000)
-
-/**
- * CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT
- *
- * The amount of time in miliseconds after which BLE advertisement should be disabled, counting
- * from the moment of slow advertisement commencement.
- *
- * Defaults to 9000000 (15 minutes).
- */
-#define CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT (15 * 60 * 1000)
diff --git a/examples/lock-app/efr32/ldscripts/efr32-lock-example-MG12P.ld b/examples/lock-app/efr32/ldscripts/efr32-lock-example-MG12P.ld
deleted file mode 100644 (file)
index 412d64d..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP Authors
- *    All rights reserved.
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/***************************************************************************//**
- * Linker script for Silicon Labs EFR32MG12P devices
- * @version 5.7.2
- *******************************************************************************
- * # License
- * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
- *******************************************************************************
- *
- * SPDX-License-Identifier: Zlib
- *
- * The licensor of this software is Silicon Laboratories Inc.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- *
- ******************************************************************************/
-
-MEMORY
-{
-  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576
-  RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 262144
-}
-
-/* Linker script to place sections and symbol values. Should be used together
- * with other linker script that defines memory regions FLASH and RAM.
- * It references following symbols, which must be defined in code:
- *   Reset_Handler : Entry of reset handler
- *
- * It defines following symbols, which code can use without definition:
- *   __exidx_start
- *   __exidx_end
- *   __copy_table_start__
- *   __copy_table_end__
- *   __zero_table_start__
- *   __zero_table_end__
- *   __etext
- *   __data_start__
- *   __preinit_array_start
- *   __preinit_array_end
- *   __init_array_start
- *   __init_array_end
- *   __fini_array_start
- *   __fini_array_end
- *   __data_end__
- *   __bss_start__
- *   __bss_end__
- *   __end__
- *   end
- *   __HeapBase
- *   __HeapLimit
- *   __StackLimit
- *   __StackTop
- *   __stack
- *   __Vectors_End
- *   __Vectors_Size
- */
-ENTRY(Reset_Handler)
-
-SECTIONS
-{
-  .text :
-  {
-    KEEP(*(.vectors))
-    __Vectors_End = .;
-    __Vectors_Size = __Vectors_End - __Vectors;
-    __end__ = .;
-
-    *(.text*)
-
-    KEEP(*(.init))
-    KEEP(*(.fini))
-
-    KEEP(*(.application_properties))
-         KEEP(*(.gecko_configuration))
-         KEEP(*(.xo_configuration))
-    KEEP(*(.gatt_header))
-    KEEP(*(.gatt_data))
-
-    /* .ctors */
-    *crtbegin.o(.ctors)
-    *crtbegin?.o(.ctors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
-    *(SORT(.ctors.*))
-    *(.ctors)
-
-    /* .dtors */
-    *crtbegin.o(.dtors)
-    *crtbegin?.o(.dtors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
-    *(SORT(.dtors.*))
-    *(.dtors)
-
-    *(.rodata*)
-
-
-    KEEP(*(.eh_frame*))
-  } > FLASH
-
-
-  .ARM.extab :
-  {
-    *(.ARM.extab* .gnu.linkonce.armextab.*)
-  } > FLASH
-
-  __exidx_start = .;
-  .ARM.exidx :
-  {
-    *(.ARM.exidx* .gnu.linkonce.armexidx.*)
-  } > FLASH
-  __exidx_end = .;
-
-
-
-  /* To copy multiple ROM to RAM sections,
-   * uncomment .copy.table section and,
-   * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .copy.table :
-  {
-    . = ALIGN(4);
-    __copy_table_start__ = .;
-    LONG (__etext)
-    LONG (__data_start__)
-    LONG (__data_end__ - __data_start__)
-    LONG (__etext2)
-    LONG (__data2_start__)
-    LONG (__data2_end__ - __data2_start__)
-    __copy_table_end__ = .;
-  } > FLASH
-  */
-
-  /* To clear multiple BSS sections,
-   * uncomment .zero.table section and,
-   * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .zero.table :
-  {
-    . = ALIGN(4);
-    __zero_table_start__ = .;
-    LONG (__bss_start__)
-    LONG (__bss_end__ - __bss_start__)
-    LONG (__bss2_start__)
-    LONG (__bss2_end__ - __bss2_start__)
-    __zero_table_end__ = .;
-  } > FLASH
-  */
-
-  __etext = .;
-
-  /*******************************************************************/
-  /* Define flash block for BLE-simee & chip-nvm3                    */
-  /* simee: 9000H (36k) bytes for BLE nvm3                           */
-  /* chipNvm3_section: 4000H (16k) bytes for chip nvm3.              */
-  /* 8K is reserved for OpenThread's NVM which is mapped directly at */
-  /* the top of flash                                                */
-  /*******************************************************************/
-
-  OPENTHREAD_NVM_SIZE = 8192;
-
-  .nvm_dummy (DSECT):
-  {
-    __nvm3_dummy_begin = .;
-    . = ALIGN (8192);
-    __nvm3_dummy_simee = .;
-    KEEP(*(.simee));
-    . = ALIGN (8192);
-    __nvm3_dummy_chip = .;
-    KEEP(*(chipNvm3_section));
-    . = ALIGN (8192);
-    . += OPENTHREAD_NVM_SIZE;
-    . = ALIGN (8192);
-  } > FLASH
-
-  /* Set NVM to end of FLASH */
-  __nvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_simee - __nvm3_dummy_begin);
-  __chipNvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_chip - __nvm3_dummy_begin);
-
-
-  /*******************************************************************/
-
-  .data : AT (__etext)
-  {
-    __data_start__ = .;
-    *(vtable)
-    *(.data*)
-    . = ALIGN (4);
-    PROVIDE (__ram_func_section_start = .);
-    *(.ram)
-    PROVIDE (__ram_func_section_end = .);
-
-    . = ALIGN(4);
-    /* preinit data */
-    PROVIDE_HIDDEN (__preinit_array_start = .);
-    KEEP(*(.preinit_array))
-    PROVIDE_HIDDEN (__preinit_array_end = .);
-
-    . = ALIGN(4);
-    /* init data */
-    PROVIDE_HIDDEN (__init_array_start = .);
-    KEEP(*(SORT(.init_array.*)))
-    KEEP(*(.init_array))
-    PROVIDE_HIDDEN (__init_array_end = .);
-
-    . = ALIGN(4);
-    /* finit data */
-    PROVIDE_HIDDEN (__fini_array_start = .);
-    KEEP(*(SORT(.fini_array.*)))
-    KEEP(*(.fini_array))
-    PROVIDE_HIDDEN (__fini_array_end = .);
-
-    KEEP(*(.jcr*))
-    . = ALIGN(4);
-    /* All data end */
-    __data_end__ = .;
-
-  } > RAM
-
-  .bss :
-  {
-    . = ALIGN(4);
-    __bss_start__ = .;
-    *(.bss*)
-    *(COMMON)
-    . = ALIGN(4);
-    __bss_end__ = .;
-  } > RAM
-
-  .heap (COPY):
-  {
-    __HeapBase = .;
-    __end__ = .;
-    end = __end__;
-    _end = __end__;
-    __HeapLimit = .;
-  } > RAM
-
-  /* .stack_dummy section doesn't contains any symbols. It is only
-   * used for linker to calculate size of stack sections, and assign
-   * values to stack symbols later */
-  .stack_dummy (COPY):
-  {
-    KEEP(*(.stack*))
-  } > RAM
-
-  /* Set stack top to end of RAM, and stack limit move down by
-   * size of stack_dummy section */
-  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
-  __StackLimit = __StackTop - SIZEOF(.stack_dummy);
-  PROVIDE(__stack = __StackTop);
-
-  /* Check if data + heap + stack exceeds RAM limit */
-  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
-
-
-  /* Check if FLASH usage exceeds FLASH size */
-  ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
-  ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
-}
diff --git a/examples/lock-app/efr32/ldscripts/efr32-lock-example-MG21.ld b/examples/lock-app/efr32/ldscripts/efr32-lock-example-MG21.ld
deleted file mode 100644 (file)
index e1a0511..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- *
- *    Copyright (c) 2020 Project CHIP Authors
- *    All rights reserved.
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/***************************************************************************//**
- * Linker script for Silicon Labs EFR32MG21 devices
- * @version 5.7.2
- *******************************************************************************
- * # License
- * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
- *******************************************************************************
- *
- * SPDX-License-Identifier: Zlib
- *
- * The licensor of this software is Silicon Laboratories Inc.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- *
- ******************************************************************************/
-
-MEMORY
-{
-  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576 - 8192  /* 8K is reserved at top of flash on MG21 */
-  RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 98304
-}
-
-/* Linker script to place sections and symbol values. Should be used together
- * with other linker script that defines memory regions FLASH and RAM.
- * It references following symbols, which must be defined in code:
- *   Reset_Handler : Entry of reset handler
- *
- * It defines following symbols, which code can use without definition:
- *   __exidx_start
- *   __exidx_end
- *   __copy_table_start__
- *   __copy_table_end__
- *   __zero_table_start__
- *   __zero_table_end__
- *   __etext
- *   __data_start__
- *   __preinit_array_start
- *   __preinit_array_end
- *   __init_array_start
- *   __init_array_end
- *   __fini_array_start
- *   __fini_array_end
- *   __data_end__
- *   __bss_start__
- *   __bss_end__
- *   __end__
- *   end
- *   __HeapBase
- *   __HeapLimit
- *   __StackLimit
- *   __StackTop
- *   __stack
- *   __Vectors_End
- *   __Vectors_Size
- */
-ENTRY(Reset_Handler)
-
-SECTIONS
-{
-  .text :
-  {
-    KEEP(*(.vectors))
-    __Vectors_End = .;
-    __Vectors_Size = __Vectors_End - __Vectors;
-    __end__ = .;
-
-    *(.text*)
-
-    KEEP(*(.init))
-    KEEP(*(.fini))
-
-    KEEP(*(.application_properties))
-       KEEP(*(.gecko_configuration))
-       KEEP(*(.xo_configuration))
-    KEEP(*(.gatt_header))
-    KEEP(*(.gatt_data))
-
-    /* .ctors */
-    *crtbegin.o(.ctors)
-    *crtbegin?.o(.ctors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
-    *(SORT(.ctors.*))
-    *(.ctors)
-
-    /* .dtors */
-    *crtbegin.o(.dtors)
-    *crtbegin?.o(.dtors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
-    *(SORT(.dtors.*))
-    *(.dtors)
-
-    *(.rodata*)
-
-
-    KEEP(*(.eh_frame*))
-  } > FLASH
-
-
-  .ARM.extab :
-  {
-    *(.ARM.extab* .gnu.linkonce.armextab.*)
-  } > FLASH
-
-  __exidx_start = .;
-  .ARM.exidx :
-  {
-    *(.ARM.exidx* .gnu.linkonce.armexidx.*)
-  } > FLASH
-  __exidx_end = .;
-
-
-
-  /* To copy multiple ROM to RAM sections,
-   * uncomment .copy.table section and,
-   * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .copy.table :
-  {
-    . = ALIGN(4);
-    __copy_table_start__ = .;
-    LONG (__etext)
-    LONG (__data_start__)
-    LONG (__data_end__ - __data_start__)
-    LONG (__etext2)
-    LONG (__data2_start__)
-    LONG (__data2_end__ - __data2_start__)
-    __copy_table_end__ = .;
-  } > FLASH
-  */
-
-  /* To clear multiple BSS sections,
-   * uncomment .zero.table section and,
-   * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .zero.table :
-  {
-    . = ALIGN(4);
-    __zero_table_start__ = .;
-    LONG (__bss_start__)
-    LONG (__bss_end__ - __bss_start__)
-    LONG (__bss2_start__)
-    LONG (__bss2_end__ - __bss2_start__)
-    __zero_table_end__ = .;
-  } > FLASH
-  */
-
-  __etext = .;
-
-  /*******************************************************************/
-  /* Define flash block for BLE-simee & CHIP-nvm3                    */
-  /* simee: 9000H (36k) bytes for BLE nvm3                           */
-  /* chipNvm3_section: 4000H (16k) bytes for CHIP nvm3.              */
-  /* 8K is reserved for OpenThread's NVM which is mapped directly at */
-  /* the top of flash                                                */
-  /*******************************************************************/
-
-  OPENTHREAD_NVM_SIZE = 8192;
-
-  .nvm_dummy (DSECT):
-  {
-    __nvm3_dummy_begin = .;
-    . = ALIGN (8192);
-    __nvm3_dummy_simee = .;
-    KEEP(*(.simee));
-    . = ALIGN (8192);
-    __nvm3_dummy_chip = .;
-    KEEP(*(chipNvm3_section));
-    . = ALIGN (8192);
-    . += OPENTHREAD_NVM_SIZE;
-    . = ALIGN (8192);
-  } > FLASH
-
-  /* Set NVM to end of FLASH */
-  __nvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_simee - __nvm3_dummy_begin);
-  __nvm3ChipBase = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_chip - __nvm3_dummy_begin);
-
-
-  /*******************************************************************/
-
-  .data : AT (__etext)
-  {
-    __data_start__ = .;
-    *(vtable)
-    *(.data*)
-    . = ALIGN (4);
-    PROVIDE (__ram_func_section_start = .);
-    *(.ram)
-    PROVIDE (__ram_func_section_end = .);
-
-    . = ALIGN(4);
-    /* preinit data */
-    PROVIDE_HIDDEN (__preinit_array_start = .);
-    KEEP(*(.preinit_array))
-    PROVIDE_HIDDEN (__preinit_array_end = .);
-
-    . = ALIGN(4);
-    /* init data */
-    PROVIDE_HIDDEN (__init_array_start = .);
-    KEEP(*(SORT(.init_array.*)))
-    KEEP(*(.init_array))
-    PROVIDE_HIDDEN (__init_array_end = .);
-
-    . = ALIGN(4);
-    /* finit data */
-    PROVIDE_HIDDEN (__fini_array_start = .);
-    KEEP(*(SORT(.fini_array.*)))
-    KEEP(*(.fini_array))
-    PROVIDE_HIDDEN (__fini_array_end = .);
-
-    KEEP(*(.jcr*))
-    . = ALIGN(4);
-    /* All data end */
-    __data_end__ = .;
-
-  } > RAM
-
-  .bss :
-  {
-    . = ALIGN(4);
-    __bss_start__ = .;
-    *(.bss*)
-    *(COMMON)
-    . = ALIGN(4);
-    __bss_end__ = .;
-  } > RAM
-
-  .heap (COPY):
-  {
-    __HeapBase = .;
-    __end__ = .;
-    end = __end__;
-    _end = __end__;
-    __HeapLimit = .;
-  } > RAM
-
-  /* .stack_dummy section doesn't contains any symbols. It is only
-   * used for linker to calculate size of stack sections, and assign
-   * values to stack symbols later */
-  .stack_dummy (COPY):
-  {
-    KEEP(*(.stack*))
-  } > RAM
-
-  /* Set stack top to end of RAM, and stack limit move down by
-   * size of stack_dummy section */
-  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
-  __StackLimit = __StackTop - SIZEOF(.stack_dummy);
-  PROVIDE(__stack = __StackTop);
-
-  /* Check if data + heap + stack exceeds RAM limit */
-  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
-
-
-  /* Check if FLASH usage exceeds FLASH size */
-  ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
-  ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
-}
index 4084f6b..0a6b7a4 100644 (file)
@@ -35,6 +35,8 @@
 
 #include <assert.h>
 
+#include <lib/support/CodeUtils.h>
+
 #include <setup_payload/QRCodeSetupPayloadGenerator.h>
 #include <setup_payload/SetupPayload.h>
 
 
 #define FACTORY_RESET_TRIGGER_TIMEOUT 3000
 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000
-#define APP_TASK_STACK_SIZE (2048)
+#define APP_TASK_STACK_SIZE (1536)
 #define APP_TASK_PRIORITY 2
 #define APP_EVENT_QUEUE_SIZE 10
 
+namespace {
 TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer.
 
-static TaskHandle_t sAppTaskHandle;
-static QueueHandle_t sAppEventQueue;
+TaskHandle_t sAppTaskHandle;
+QueueHandle_t sAppEventQueue;
+
+LEDWidget sStatusLED;
+LEDWidget sLockLED;
 
-static LEDWidget sStatusLED;
-static LEDWidget sLockLED;
+bool sIsThreadProvisioned     = false;
+bool sIsThreadEnabled         = false;
+bool sHaveBLEConnections      = false;
+bool sHaveServiceConnectivity = false;
 
-static bool sIsThreadProvisioned     = false;
-static bool sIsThreadEnabled         = false;
-static bool sHaveBLEConnections      = false;
-static bool sHaveServiceConnectivity = false;
+StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)];
+StaticTask_t appTaskStruct;
+} // namespace
 
 using namespace chip::TLV;
 using namespace ::chip::DeviceLayer;
@@ -81,7 +88,8 @@ int AppTask::StartAppTask()
     }
 
     // Start App task.
-    if (xTaskCreate(AppTaskMain, "APP", APP_TASK_STACK_SIZE / sizeof(StackType_t), NULL, 1, &sAppTaskHandle) == pdPASS)
+    sAppTaskHandle = xTaskCreateStatic(AppTaskMain, APP_TASK_NAME, ArraySize(appStack), NULL, 1, appStack, &appTaskStruct);
+    if (sAppTaskHandle != NULL)
     {
         err = CHIP_NO_ERROR;
     }
@@ -320,7 +328,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent)
 
     // If we reached here, the button was held past FACTORY_RESET_TRIGGER_TIMEOUT,
     // initiate factory reset
-    if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartThread)
+    if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv)
     {
         EFR32_LOG("Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT);
 
@@ -365,29 +373,27 @@ void AppTask::FunctionHandler(AppEvent * aEvent)
         if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_NoneSelected)
         {
             sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT);
-            sAppTask.mFunction = kFunction_StartThread;
+            sAppTask.mFunction = kFunction_StartBleAdv;
         }
     }
     else
     {
-        // If the button was released before factory reset got initiated, start Thread Network
-        if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartThread)
+        // If the button was released before factory reset got initiated, start BLE advertissement in fast mode
+        if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv)
         {
             sAppTask.CancelTimer();
             sAppTask.mFunction = kFunction_NoneSelected;
-#if CHIP_ENABLE_OPENTHREAD
-            if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned())
+
+            if (!ConnectivityMgr().IsThreadProvisioned())
             {
-                StartDefaultThreadNetwork();
-                EFR32_LOG("Device is not commissioned to a Thread network. Starting with the default configuration.");
+                // Enable BLE advertisements
+                ConnectivityMgr().SetBLEAdvertisingEnabled(true);
+                ConnectivityMgr().SetBLEAdvertisingMode(ConnectivityMgr().kFastAdvertising);
             }
             else
             {
-                EFR32_LOG("Device is commissioned to a Thread network.");
+                EFR32_LOG("Network is already provisioned, Ble advertissement not enabled");
             }
-#else
-            EFR32_LOG("Thread is not defined.");
-#endif
         }
         else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset)
         {
index 6259710..4506905 100644 (file)
@@ -58,8 +58,9 @@ devices.
 ### Bluetooth LE Advertising
 
 In this example, to commission the device onto a Project CHIP network, it must
-be discoverable over Bluetooth LE. Bluetooth LE advertising is started
-automatically when the device is powered up.
+be discoverable over Bluetooth LE. For security reasons, you must start
+Bluetooth LE advertising manually after powering up the device by pressing
+Button USERINTERFACE.
 
 ### Bluetooth LE Rendezvous
 
@@ -107,23 +108,26 @@ bolt is extended (i.e. door locked); when not lit, the bolt is retracted (door
 unlocked). The LED will flash whenever the simulated bolt is in motion from one
 position to another.
 
-**Button SW2** can be used to change the state of the simulated bolt. This can
-be used to mimic a user manually operating the lock. The button behaves as a
-toggle, swapping the state every time it is pressed.
-
-**Button SW3** can be used to reset the device to a default state. Pressing and
+**Button SW2** can be used to reset the device to a default state. Pressing and
 holding Button SW3 for 6 seconds initiates a factory reset. After an initial
 period of 3 seconds, LED2 D2 and D3 will flash in unison to signal the pending
 reset. Holding the button past 6 seconds will cause the device to reset its
 persistent configuration and initiate a reboot. The reset action can be
 cancelled by releasing the button at any point before the 6 second limit.
 
+**Button SW3** can be used to change the state of the simulated bolt. This can
+be used to mimic a user manually operating the lock. The button behaves as a
+toggle, swapping the state every time it is pressed.
+
 **Button SW4** can be used for joining a predefined Thread network advertised by
 a Border Router. Default parameters for a Thread network are hard-coded and are
 being used if this button is pressed.
 
 The remaining two LEDs (D1/D2) and button (SW1) are unused.
 
+Directly on the development board, **Button USERINTERFACE** can be used for
+enabling Bluetooth LE advertising for a predefined period of time.
+
 <a name="building"></a>
 
 ## Building
index c01fb80..d7919b6 100644 (file)
@@ -216,7 +216,7 @@ void AppTask::AppTaskMain(void * pvParameter)
 
 void AppTask::ButtonEventHandler(uint8_t pin_no, uint8_t button_action)
 {
-    if ((pin_no != RESET_BUTTON) && (pin_no != LOCK_BUTTON) && (pin_no != JOIN_BUTTON))
+    if ((pin_no != RESET_BUTTON) && (pin_no != LOCK_BUTTON) && (pin_no != JOIN_BUTTON) && (pin_no != BLE_BUTTON))
     {
         return;
     }
@@ -238,6 +238,10 @@ void AppTask::ButtonEventHandler(uint8_t pin_no, uint8_t button_action)
     {
         button_event.Handler = JoinHandler;
     }
+    else if (pin_no == BLE_BUTTON)
+    {
+        button_event.Handler = BleHandler;
+    }
 
     sAppTask.PostEvent(&button_event);
 }
@@ -275,6 +279,9 @@ void AppTask::HandleKeyboard(void)
         case gKBD_EventPB3_c:
             ButtonEventHandler(JOIN_BUTTON, JOIN_BUTTON_PUSH);
             break;
+        case gKBD_EventPB4_c:
+            ButtonEventHandler(BLE_BUTTON, BLE_BUTTON_PUSH);
+            break;
         default:
             break;
         }
@@ -456,6 +463,37 @@ void AppTask::JoinHandler(AppEvent * aEvent)
     ThreadStart();
 }
 
+void AppTask::BleHandler(AppEvent * aEvent)
+{
+    if (aEvent->ButtonEvent.PinNo != BLE_BUTTON)
+        return;
+
+    if (sAppTask.mFunction != kFunction_NoneSelected)
+    {
+        K32W_LOG("Another function is scheduled. Could not toggle BLE state!");
+        return;
+    }
+
+    if (ConnectivityMgr().IsBLEAdvertisingEnabled())
+    {
+        ConnectivityMgr().SetBLEAdvertisingEnabled(false);
+        K32W_LOG("Stopped BLE Advertising!");
+    }
+    else
+    {
+        ConnectivityMgr().SetBLEAdvertisingEnabled(true);
+
+        if (OpenDefaultPairingWindow(chip::ResetAdmins::kNo) == CHIP_NO_ERROR)
+        {
+            K32W_LOG("Started BLE Advertising!");
+        }
+        else
+        {
+            K32W_LOG("OpenDefaultPairingWindow() failed");
+        }
+    }
+}
+
 void AppTask::CancelTimer()
 {
     if (xTimerStop(sFunctionTimer, 0) == pdFAIL)
index 9b4c881..9cf1e0f 100644 (file)
@@ -56,6 +56,7 @@ private:
     static void KBD_Callback(uint8_t events);
     static void HandleKeyboard(void);
     static void JoinHandler(AppEvent * aEvent);
+    static void BleHandler(AppEvent * aEvent);
     static void LockActionEventHandler(AppEvent * aEvent);
     static void ResetActionEventHandler(AppEvent * aEvent);
     static void InstallEventHandler(AppEvent * aEvent);
index eb069f7..6e8d55c 100644 (file)
 #define RESET_BUTTON 1
 #define LOCK_BUTTON 2
 #define JOIN_BUTTON 3
+#define BLE_BUTTON 4
 
 #define RESET_BUTTON_PUSH 1
 #define LOCK_BUTTON_PUSH 2
 #define JOIN_BUTTON_PUSH 3
+#define BLE_BUTTON_PUSH 4
 
 #define APP_BUTTON_PUSH 1
 
index 2f9a5a6..8059674 100644 (file)
@@ -118,6 +118,13 @@ typedef struct _DeviceInformationRecord
     uint8_t sort;
 } EmberAfDeviceInformationRecord;
 
+// Struct for DeviceType
+typedef struct _DeviceType
+{
+    chip::DeviceTypeId type;
+    uint16_t revision;
+} EmberAfDeviceType;
+
 // Struct for DiscoverAttributesInfoRecord
 typedef struct _DiscoverAttributesInfoRecord
 {
index 6ca0739..cd1d95a 100644 (file)
 #define ZCL_FINISH_TIME_ATTRIBUTE_ID (0x0001)
 #define ZCL_REMAINING_TIME_ATTRIBUTE_ID (0x0002)
 
+// Attribute ids for cluster: Descriptor
+
+// Client attributes
+
+// Server attributes
+#define ZCL_DEVICE_LIST_ATTRIBUTE_ID (0x0000)
+#define ZCL_SERVER_LIST_ATTRIBUTE_ID (0x0001)
+#define ZCL_CLIENT_LIST_ATTRIBUTE_ID (0x0002)
+#define ZCL_PARTS_LIST_ATTRIBUTE_ID (0x0003)
+
 // Attribute ids for cluster: Poll Control
 
 // Client attributes
 // Server attributes
 #define ZCL_MAX_DURATION_ATTRIBUTE_ID (0x0000)
 
+// Attribute ids for cluster: Media Playback
+
+// Client attributes
+
+// Server attributes
+#define ZCL_CURRENT_STATE_ATTRIBUTE_ID (0x0000)
+
 // Attribute ids for cluster: Low Power
 
 // Client attributes
 
 // Server attributes
 
+// Attribute ids for cluster: Content Launch
+
+// Client attributes
+
+// Server attributes
+
 // Attribute ids for cluster: Application Basic
 
 // Client attributes
 
 // Server attributes
 
-// Attribute ids for cluster: Media Playback
-
-// Client attributes
-
-// Server attributes
-#define ZCL_CURRENT_STATE_ATTRIBUTE_ID (0x0000)
-
-// Attribute ids for cluster: Content Launch
-
-// Client attributes
-
-// Server attributes
-
 // Attribute ids for cluster: Group Key Management
 
 // Client attributes
index a6caf3a..ee211ce 100644 (file)
@@ -34,4 +34,4 @@ ZCL_DATA8_ATTRIBUTE_TYPE, 1, ZCL_DATA16_ATTRIBUTE_TYPE, 2, ZCL_DATA24_ATTRIBUTE_
     ZCL_DATE_ATTRIBUTE_TYPE, 4, ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4, ZCL_CLUSTER_ID_ATTRIBUTE_TYPE, 2, ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE,
     2, ZCL_BACNET_OID_ATTRIBUTE_TYPE, 4, ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8, ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
     ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE, 1, ZCL_GROUP_ID_ATTRIBUTE_TYPE, 2, ZCL_COMMAND_ID_ATTRIBUTE_TYPE, 1, ZCL_NODE_ID_ATTRIBUTE_TYPE,
-    8,
+    8, ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE, 4,
index 56900dc..6f12999 100644 (file)
@@ -82,5 +82,6 @@ enum
     ZCL_GROUP_ID_ATTRIBUTE_TYPE          = 0xF3, // Group Id
     ZCL_COMMAND_ID_ATTRIBUTE_TYPE        = 0xF4, // Command Id
     ZCL_NODE_ID_ATTRIBUTE_TYPE           = 0xF5, // Node Id
+    ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE    = 0xF6, // Device Type Id
     ZCL_UNKNOWN_ATTRIBUTE_TYPE           = 0xFF, // Unknown
 };
index 79d1e15..775f29f 100644 (file)
                                                                                                                                    \
                                                           ZCL_SQUAWK_COMMAND_ID, "u", squawkInfo);
 
+/** @brief Command description for PlayRequest
+ *
+ * Command: PlayRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPlayRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_PLAY_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for PauseRequest
+ *
+ * Command: PauseRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPauseRequest() emberAfFillExternalBuffer(mask,                                                                  \
+                                                                                                                                   \
+                                                            ZCL_PAUSE_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for StopRequest
+ *
+ * Command: StopRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterStopRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_STOP_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for StartOverRequest
+ *
+ * Command: StartOverRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterStartOverRequest() emberAfFillExternalBuffer(mask,                                                              \
+                                                                                                                                   \
+                                                                ZCL_START_OVER_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for PreviousRequest
+ *
+ * Command: PreviousRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPreviousRequest() emberAfFillExternalBuffer(mask,                                                               \
+                                                                                                                                   \
+                                                               ZCL_PREVIOUS_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for NextRequest
+ *
+ * Command: NextRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterNextRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_NEXT_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for RewindRequest
+ *
+ * Command: RewindRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterRewindRequest() emberAfFillExternalBuffer(mask,                                                                 \
+                                                                                                                                   \
+                                                             ZCL_REWIND_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for FastForwardRequest
+ *
+ * Command: FastForwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterFastForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
+                                                                                                                                   \
+                                                                  ZCL_FAST_FORWARD_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for SkipForwardRequest
+ *
+ * Command: SkipForwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterSkipForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
+                                                                                                                                   \
+                                                                  ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for SkipBackwardRequest
+ *
+ * Command: SkipBackwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterSkipBackwardRequest() emberAfFillExternalBuffer(mask,                                                           \
+                                                                                                                                   \
+                                                                   ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID, "", );
+
 /** @brief Command description for Sleep
  *
  * Command: Sleep
                                                                                                                                    \
                                                   ZCL_SLEEP_COMMAND_ID, "", );
 
+/** @brief Command description for LaunchContent
+ *
+ * Command: LaunchContent
+ * @param contentLaunchStatus ContentLaunchStatus
+ */
+#define emberAfFillCommandContent                                                                                                  \
+    LaunchClusterLaunchContent(contentLaunchStatus)                                                                                \
+        emberAfFillExternalBuffer(mask,                                                                                            \
+                                                                                                                                   \
+                                  ZCL_LAUNCH_CONTENT_COMMAND_ID, "u", contentLaunchStatus);
+
+/** @brief Command description for LaunchURL
+ *
+ * Command: LaunchURL
+ * @param contentLaunchStatus ContentLaunchStatus
+ */
+#define emberAfFillCommandContent                                                                                                  \
+    LaunchClusterLaunchURL(contentLaunchStatus) emberAfFillExternalBuffer(mask,                                                    \
+                                                                                                                                   \
+                                                                          ZCL_LAUNCH_URL_COMMAND_ID, "u", contentLaunchStatus);
+
 /** @brief Command description for MatchProtocolAddress
  *
  * Command: MatchProtocolAddress
                                                                                                                                    \
                               ZCL_UNBIND_COMMAND_ID, "uuuu", nodeId, groupId, endpointId, clusterId);
 
-/** @brief Command description for PlayRequest
- *
- * Command: PlayRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPlayRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_PLAY_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for PauseRequest
- *
- * Command: PauseRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPauseRequest() emberAfFillExternalBuffer(mask,                                                                  \
-                                                                                                                                   \
-                                                            ZCL_PAUSE_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for StopRequest
- *
- * Command: StopRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterStopRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_STOP_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for StartOverRequest
- *
- * Command: StartOverRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterStartOverRequest() emberAfFillExternalBuffer(mask,                                                              \
-                                                                                                                                   \
-                                                                ZCL_START_OVER_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for PreviousRequest
- *
- * Command: PreviousRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPreviousRequest() emberAfFillExternalBuffer(mask,                                                               \
-                                                                                                                                   \
-                                                               ZCL_PREVIOUS_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for NextRequest
- *
- * Command: NextRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterNextRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_NEXT_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for RewindRequest
- *
- * Command: RewindRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterRewindRequest() emberAfFillExternalBuffer(mask,                                                                 \
-                                                                                                                                   \
-                                                             ZCL_REWIND_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for FastForwardRequest
- *
- * Command: FastForwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterFastForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
-                                                                                                                                   \
-                                                                  ZCL_FAST_FORWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for SkipForwardRequest
- *
- * Command: SkipForwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterSkipForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
-                                                                                                                                   \
-                                                                  ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for SkipBackwardRequest
- *
- * Command: SkipBackwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterSkipBackwardRequest() emberAfFillExternalBuffer(mask,                                                           \
-                                                                                                                                   \
-                                                                   ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for LaunchContent
- *
- * Command: LaunchContent
- * @param contentLaunchStatus ContentLaunchStatus
- */
-#define emberAfFillCommandContent                                                                                                  \
-    LaunchClusterLaunchContent(contentLaunchStatus)                                                                                \
-        emberAfFillExternalBuffer(mask,                                                                                            \
-                                                                                                                                   \
-                                  ZCL_LAUNCH_CONTENT_COMMAND_ID, "u", contentLaunchStatus);
-
-/** @brief Command description for LaunchURL
- *
- * Command: LaunchURL
- * @param contentLaunchStatus ContentLaunchStatus
- */
-#define emberAfFillCommandContent                                                                                                  \
-    LaunchClusterLaunchURL(contentLaunchStatus) emberAfFillExternalBuffer(mask,                                                    \
-                                                                                                                                   \
-                                                                          ZCL_LAUNCH_URL_COMMAND_ID, "u", contentLaunchStatus);
-
 /** @brief Command description for CommandOne
  *
  * Command: CommandOne
index 9e82931..bbd16b6 100644 (file)
@@ -71,6 +71,9 @@
 // Definitions for cluster: Appliance Control
 #define ZCL_APPLIANCE_CONTROL_CLUSTER_ID (0x001B)
 
+// Definitions for cluster: Descriptor
+#define ZCL_DESCRIPTOR_CLUSTER_ID (0x001D)
+
 // Definitions for cluster: Poll Control
 #define ZCL_POLL_CONTROL_CLUSTER_ID (0x0020)
 
 // Definitions for cluster: IAS WD
 #define ZCL_IAS_WD_CLUSTER_ID (0x0502)
 
+// Definitions for cluster: Media Playback
+#define ZCL_MEDIA_PLAYBACK_CLUSTER_ID (0x0506)
+
 // Definitions for cluster: Low Power
 #define ZCL_LOW_POWER_CLUSTER_ID (0x0508)
 
+// Definitions for cluster: Content Launch
+#define ZCL_CONTENT_LAUNCH_CLUSTER_ID (0x050A)
+
 // Definitions for cluster: Application Basic
 #define ZCL_APPLICATION_BASIC_CLUSTER_ID (0x050D)
 
 // Definitions for cluster: Binding
 #define ZCL_BINDING_CLUSTER_ID (0xF000)
 
-// Definitions for cluster: Media Playback
-#define ZCL_MEDIA_PLAYBACK_CLUSTER_ID (0xF001)
-
-// Definitions for cluster: Content Launch
-#define ZCL_CONTENT_LAUNCH_CLUSTER_ID (0xF002)
-
 // Definitions for cluster: Group Key Management
 #define ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID (0xF004)
 
index 864943b..268678a 100644 (file)
 #define ZCL_START_WARNING_COMMAND_ID (0x00)
 #define ZCL_SQUAWK_COMMAND_ID (0x01)
 
+// Commands for cluster: Media Playback
+#define ZCL_PLAY_REQUEST_COMMAND_ID (0x00)
+#define ZCL_PLAYBACK_COMMAND_ID (0x00)
+#define ZCL_PAUSE_REQUEST_COMMAND_ID (0x01)
+#define ZCL_STOP_REQUEST_COMMAND_ID (0x02)
+#define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03)
+#define ZCL_PREVIOUS_REQUEST_COMMAND_ID (0x04)
+#define ZCL_NEXT_REQUEST_COMMAND_ID (0x05)
+#define ZCL_REWIND_REQUEST_COMMAND_ID (0x06)
+#define ZCL_FAST_FORWARD_REQUEST_COMMAND_ID (0x07)
+#define ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID (0x08)
+#define ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID (0x09)
+
 // Commands for cluster: Low Power
 #define ZCL_SLEEP_COMMAND_ID (0x00)
 
+// Commands for cluster: Content Launch
+#define ZCL_LAUNCH_CONTENT_COMMAND_ID (0x00)
+#define ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID (0x00)
+#define ZCL_LAUNCH_URL_COMMAND_ID (0x01)
+#define ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID (0x01)
+
 // Commands for cluster: Generic Tunnel
 #define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00)
 #define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00)
 #define ZCL_BIND_COMMAND_ID (0x00)
 #define ZCL_UNBIND_COMMAND_ID (0x01)
 
-// Commands for cluster: Media Playback
-#define ZCL_PLAY_REQUEST_COMMAND_ID (0x00)
-#define ZCL_PLAYBACK_COMMAND_ID (0x00)
-#define ZCL_PAUSE_REQUEST_COMMAND_ID (0x01)
-#define ZCL_STOP_REQUEST_COMMAND_ID (0x02)
-#define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03)
-#define ZCL_PREVIOUS_REQUEST_COMMAND_ID (0x04)
-#define ZCL_NEXT_REQUEST_COMMAND_ID (0x05)
-#define ZCL_REWIND_REQUEST_COMMAND_ID (0x06)
-#define ZCL_FAST_FORWARD_REQUEST_COMMAND_ID (0x07)
-#define ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID (0x08)
-#define ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID (0x09)
-
-// Commands for cluster: Content Launch
-#define ZCL_LAUNCH_CONTENT_COMMAND_ID (0x00)
-#define ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID (0x00)
-#define ZCL_LAUNCH_URL_COMMAND_ID (0x01)
-#define ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID (0x01)
-
 // Commands for cluster: Sample Mfg Specific Cluster
 #define ZCL_COMMAND_ONE_COMMAND_ID (0x00)
 
index abc2762..a3ff756 100644 (file)
 #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x
 #define ZAP_REPORT_DIRECTION(x) ZRD(x)
 
-// Use this macro to check if Reporting plugin is included
-#define EMBER_AF_PLUGIN_REPORTING
 // User options for plugin Reporting
 #define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (1)
 #define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS
index e3207b7..4054969 100644 (file)
 #define CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER
 #endif
 
+#if defined(ZCL_USING_DESCRIPTOR_CLUSTER_SERVER) || defined(ZCL_USING_DESCRIPTOR_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER { ZCL_DESCRIPTOR_CLUSTER_ID, 29, "Descriptor" },
+#else
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER
+#endif
+
 #if defined(ZCL_USING_POLL_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_POLL_CONTROL_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER { ZCL_POLL_CONTROL_CLUSTER_ID, 32, "Poll Control" },
 #else
 #define CHIP_PRINTCLUSTER_IAS_WD_CLUSTER
 #endif
 
+#if defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_SERVER) || defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER { ZCL_MEDIA_PLAYBACK_CLUSTER_ID, 1286, "Media Playback" },
+#else
+#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER
+#endif
+
 #if defined(ZCL_USING_LOW_POWER_CLUSTER_SERVER) || defined(ZCL_USING_LOW_POWER_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER { ZCL_LOW_POWER_CLUSTER_ID, 1288, "Low Power" },
 #else
 #define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER
 #endif
 
+#if defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_SERVER) || defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER { ZCL_CONTENT_LAUNCH_CLUSTER_ID, 1290, "Content Launch" },
+#else
+#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER
+#endif
+
 #if defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER { ZCL_APPLICATION_BASIC_CLUSTER_ID, 1293, "Application Basic" },
 #else
 #define CHIP_PRINTCLUSTER_BINDING_CLUSTER
 #endif
 
-#if defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_SERVER) || defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT)
-#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER { ZCL_MEDIA_PLAYBACK_CLUSTER_ID, 61441, "Media Playback" },
-#else
-#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER
-#endif
-
-#if defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_SERVER) || defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT)
-#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER { ZCL_CONTENT_LAUNCH_CLUSTER_ID, 61442, "Content Launch" },
-#else
-#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER
-#endif
-
 #if defined(ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_SERVER) || defined(ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER { ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID, 61444, "Group Key Management" },
 #else
     CHIP_PRINTCLUSTER_OTA_BOOTLOAD_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_POWER_PROFILE_CLUSTER                                                                                        \
     CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER                                                                                    \
+    CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER                                                                                           \
     CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER                                                                                            \
     CHIP_PRINTCLUSTER_IAS_ZONE_CLUSTER                                                                                             \
     CHIP_PRINTCLUSTER_IAS_ACE_CLUSTER                                                                                              \
     CHIP_PRINTCLUSTER_IAS_WD_CLUSTER                                                                                               \
+    CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER                                                                                            \
+    CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER                                                                                    \
     CHIP_PRINTCLUSTER_GENERIC_TUNNEL_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_BACNET_PROTOCOL_TUNNEL_CLUSTER                                                                               \
     CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER                                                                                    \
     CHIP_PRINTCLUSTER_BINDING_CLUSTER                                                                                              \
-    CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER                                                                                       \
-    CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER                                                                                 \
     CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER                                                                                  \
     CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER_2                                                                                \
index cbe7415..301a43f 100644 (file)
@@ -423,10 +423,13 @@ void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t
     ARG_UNUSED(arg);
     if ((event->Type == DeviceEventType::kServiceProvisioningChange) && ConnectivityMgr().IsThreadProvisioned())
     {
-        const int result = sNFC.StopTagEmulation();
-        if (result)
+        if (sNFC.IsTagEmulationStarted())
         {
-            LOG_ERR("Stopping NFC Tag emulation failed");
+            const int result = sNFC.StopTagEmulation();
+            if (result)
+            {
+                LOG_ERR("Stopping NFC Tag emulation failed");
+            }
         }
     }
 }
index 8b1bb05..9c11b4d 100644 (file)
@@ -36,4 +36,3 @@ CONFIG_MPU_STACK_GUARD=y
 
 # CHIP configuration
 CONFIG_CHIP_PROJECT_CONFIG="main/include/CHIPProjectConfig.h"
-CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/nrfconnect/project_include/OpenThreadConfig.h"
index 79be07d..851cd34 100644 (file)
@@ -41,7 +41,10 @@ efr32_sdk("sdk") {
     "${efr32_project_dir}/include/FreeRTOSConfig.h",
   ]
 
-  defines = [ "BOARD_ID=${efr32_board}" ]
+  defines = [
+    "BOARD_ID=${efr32_board}",
+    "SL_HEAP_SIZE=(10 * 1024)",
+  ]
 }
 
 efr32_executable("persistent_storage") {
@@ -66,15 +69,16 @@ efr32_executable("persistent_storage") {
   sources = [
     "${efr32_project_dir}/../KeyValueStorageTest.cpp",
     "${examples_plat_dir}/init_efrPlatform.cpp",
+    "${examples_plat_dir}/uart.c",
     "main.cpp",
   ]
 
   output_dir = root_out_dir
 
   if (efr32_family == "efr32mg12") {
-    ldscript = "${efr32_project_dir}/ldscripts/efr32-persistent_storage-example-MG12P.ld"
+    ldscript = "${examples_plat_dir}/ldscripts/efr32-MG12P.ld"
   } else if (efr32_family == "efr32mg21") {
-    ldscript = "${efr32_project_dir}/ldscripts/efr32-persistent_storage-example-MG21.ld"
+    ldscript = "${examples_plat_dir}/ldscripts/efr32-MG21.ld"
   }
 
   ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
index 744aa1b..5b03331 100644 (file)
@@ -1,4 +1,4 @@
-# CHIP EFR32 Persistent Storage Example
+#CHIP EFR32 Persistent Storage Example
 
 An example testing and demonstrating the key value storage API.
 
@@ -53,11 +53,9 @@ defines = [
 
 -   Install some additional tools(likely already present for CHIP developers):
 
-           # Linux
-           $ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
+#Linux \$ sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
 
-           # Mac OS X
-           $ brew install ninja
+#Mac OS X \$ brew install ninja
 
 -   Supported hardware:
 
@@ -155,3 +153,12 @@ combination with JLinkRTTClient as follows:
 -   In a second terminal, run the JLinkRTTClient to view logs:
 
           $ JLinkRTTClient
+
+## Memory settings
+
+While most of the RAM usage in CHIP is static, allowing easier debugging and
+optimization with symbols analysis, we still need some HEAP for the crypto and
+OpenThread. Size of the HEAP can be modified by changing the value of the
+`SL_STACK_SIZE` define inside of the BUILD.gn file of this example. Please take
+note that a HEAP size smaller than 5k can and will cause a Mbedtls failure
+during the BLE rendez-vous.
diff --git a/examples/persistent-storage/efr32/ldscripts/efr32-persistent_storage-example-MG12P.ld b/examples/persistent-storage/efr32/ldscripts/efr32-persistent_storage-example-MG12P.ld
deleted file mode 100644 (file)
index d20e4f8..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- *
- *    Copyright (c) 2021 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.
- */
-/***************************************************************************//**
- * Linker script for Silicon Labs EFR32MG12P devices
- * @version 5.7.2
- *******************************************************************************
- * # License
- * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
- *******************************************************************************
- *
- * SPDX-License-Identifier: Zlib
- *
- * The licensor of this software is Silicon Laboratories Inc.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- *
- ******************************************************************************/
-
-MEMORY
-{
-  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576
-  RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 262144
-}
-
-/* Linker script to place sections and symbol values. Should be used together
- * with other linker script that defines memory regions FLASH and RAM.
- * It references following symbols, which must be defined in code:
- *   Reset_Handler : Entry of reset handler
- *
- * It defines following symbols, which code can use without definition:
- *   __exidx_start
- *   __exidx_end
- *   __copy_table_start__
- *   __copy_table_end__
- *   __zero_table_start__
- *   __zero_table_end__
- *   __etext
- *   __data_start__
- *   __preinit_array_start
- *   __preinit_array_end
- *   __init_array_start
- *   __init_array_end
- *   __fini_array_start
- *   __fini_array_end
- *   __data_end__
- *   __bss_start__
- *   __bss_end__
- *   __end__
- *   end
- *   __HeapBase
- *   __HeapLimit
- *   __StackLimit
- *   __StackTop
- *   __stack
- *   __Vectors_End
- *   __Vectors_Size
- */
-ENTRY(Reset_Handler)
-
-SECTIONS
-{
-  .text :
-  {
-    KEEP(*(.vectors))
-    __Vectors_End = .;
-    __Vectors_Size = __Vectors_End - __Vectors;
-    __end__ = .;
-
-    *(.text*)
-
-    KEEP(*(.init))
-    KEEP(*(.fini))
-
-    KEEP(*(.application_properties))
-         KEEP(*(.gecko_configuration))
-         KEEP(*(.xo_configuration))
-    KEEP(*(.gatt_header))
-    KEEP(*(.gatt_data))
-
-    /* .ctors */
-    *crtbegin.o(.ctors)
-    *crtbegin?.o(.ctors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
-    *(SORT(.ctors.*))
-    *(.ctors)
-
-    /* .dtors */
-    *crtbegin.o(.dtors)
-    *crtbegin?.o(.dtors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
-    *(SORT(.dtors.*))
-    *(.dtors)
-
-    *(.rodata*)
-
-
-    KEEP(*(.eh_frame*))
-  } > FLASH
-
-
-  .ARM.extab :
-  {
-    *(.ARM.extab* .gnu.linkonce.armextab.*)
-  } > FLASH
-
-  __exidx_start = .;
-  .ARM.exidx :
-  {
-    *(.ARM.exidx* .gnu.linkonce.armexidx.*)
-  } > FLASH
-  __exidx_end = .;
-
-
-
-  /* To copy multiple ROM to RAM sections,
-   * uncomment .copy.table section and,
-   * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .copy.table :
-  {
-    . = ALIGN(4);
-    __copy_table_start__ = .;
-    LONG (__etext)
-    LONG (__data_start__)
-    LONG (__data_end__ - __data_start__)
-    LONG (__etext2)
-    LONG (__data2_start__)
-    LONG (__data2_end__ - __data2_start__)
-    __copy_table_end__ = .;
-  } > FLASH
-  */
-
-  /* To clear multiple BSS sections,
-   * uncomment .zero.table section and,
-   * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .zero.table :
-  {
-    . = ALIGN(4);
-    __zero_table_start__ = .;
-    LONG (__bss_start__)
-    LONG (__bss_end__ - __bss_start__)
-    LONG (__bss2_start__)
-    LONG (__bss2_end__ - __bss2_start__)
-    __zero_table_end__ = .;
-  } > FLASH
-  */
-
-  __etext = .;
-
-  /*******************************************************************/
-  /* Define flash block for BLE-simee & chip-nvm3                    */
-  /* simee: 9000H (36k) bytes for BLE nvm3                           */
-  /* chipNvm3_section: 4000H (16k) bytes for chip nvm3.              */
-  /* 8K is reserved for OpenThread's NVM which is mapped directly at */
-  /* the top of flash                                                */
-  /*******************************************************************/
-
-  OPENTHREAD_NVM_SIZE = 8192;
-
-  .nvm_dummy (DSECT):
-  {
-    __nvm3_dummy_begin = .;
-    . = ALIGN (8192);
-    __nvm3_dummy_simee = .;
-    KEEP(*(.simee));
-    . = ALIGN (8192);
-    __nvm3_dummy_chip = .;
-    KEEP(*(chipNvm3_section));
-    . = ALIGN (8192);
-    . += OPENTHREAD_NVM_SIZE;
-    . = ALIGN (8192);
-  } > FLASH
-
-  /* Set NVM to end of FLASH */
-  __nvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_simee - __nvm3_dummy_begin);
-  __chipNvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_chip - __nvm3_dummy_begin);
-
-
-  /*******************************************************************/
-
-  .data : AT (__etext)
-  {
-    __data_start__ = .;
-    *(vtable)
-    *(.data*)
-    . = ALIGN (4);
-    PROVIDE (__ram_func_section_start = .);
-    *(.ram)
-    PROVIDE (__ram_func_section_end = .);
-
-    . = ALIGN(4);
-    /* preinit data */
-    PROVIDE_HIDDEN (__preinit_array_start = .);
-    KEEP(*(.preinit_array))
-    PROVIDE_HIDDEN (__preinit_array_end = .);
-
-    . = ALIGN(4);
-    /* init data */
-    PROVIDE_HIDDEN (__init_array_start = .);
-    KEEP(*(SORT(.init_array.*)))
-    KEEP(*(.init_array))
-    PROVIDE_HIDDEN (__init_array_end = .);
-
-    . = ALIGN(4);
-    /* finit data */
-    PROVIDE_HIDDEN (__fini_array_start = .);
-    KEEP(*(SORT(.fini_array.*)))
-    KEEP(*(.fini_array))
-    PROVIDE_HIDDEN (__fini_array_end = .);
-
-    KEEP(*(.jcr*))
-    . = ALIGN(4);
-    /* All data end */
-    __data_end__ = .;
-
-  } > RAM
-
-  .bss :
-  {
-    . = ALIGN(4);
-    __bss_start__ = .;
-    *(.bss*)
-    *(COMMON)
-    . = ALIGN(4);
-    __bss_end__ = .;
-  } > RAM
-
-  .heap (COPY):
-  {
-    __HeapBase = .;
-    __end__ = .;
-    end = __end__;
-    _end = __end__;
-    __HeapLimit = .;
-  } > RAM
-
-  /* .stack_dummy section doesn't contains any symbols. It is only
-   * used for linker to calculate size of stack sections, and assign
-   * values to stack symbols later */
-  .stack_dummy (COPY):
-  {
-    KEEP(*(.stack*))
-  } > RAM
-
-  /* Set stack top to end of RAM, and stack limit move down by
-   * size of stack_dummy section */
-  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
-  __StackLimit = __StackTop - SIZEOF(.stack_dummy);
-  PROVIDE(__stack = __StackTop);
-
-  /* Check if data + heap + stack exceeds RAM limit */
-  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
-
-
-  /* Check if FLASH usage exceeds FLASH size */
-  ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
-  ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
-}
diff --git a/examples/persistent-storage/efr32/ldscripts/efr32-persistent_storage-example-MG21.ld b/examples/persistent-storage/efr32/ldscripts/efr32-persistent_storage-example-MG21.ld
deleted file mode 100644 (file)
index e8e870f..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- *
- *    Copyright (c) 2021 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.
- */
-/***************************************************************************//**
- * Linker script for Silicon Labs EFR32MG21 devices
- * @version 5.7.2
- *******************************************************************************
- * # License
- * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
- *******************************************************************************
- *
- * SPDX-License-Identifier: Zlib
- *
- * The licensor of this software is Silicon Laboratories Inc.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- *
- ******************************************************************************/
-
-MEMORY
-{
-  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576 - 8192  /* 8K is reserved at top of flash on MG21 */
-  RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 98304
-}
-
-/* Linker script to place sections and symbol values. Should be used together
- * with other linker script that defines memory regions FLASH and RAM.
- * It references following symbols, which must be defined in code:
- *   Reset_Handler : Entry of reset handler
- *
- * It defines following symbols, which code can use without definition:
- *   __exidx_start
- *   __exidx_end
- *   __copy_table_start__
- *   __copy_table_end__
- *   __zero_table_start__
- *   __zero_table_end__
- *   __etext
- *   __data_start__
- *   __preinit_array_start
- *   __preinit_array_end
- *   __init_array_start
- *   __init_array_end
- *   __fini_array_start
- *   __fini_array_end
- *   __data_end__
- *   __bss_start__
- *   __bss_end__
- *   __end__
- *   end
- *   __HeapBase
- *   __HeapLimit
- *   __StackLimit
- *   __StackTop
- *   __stack
- *   __Vectors_End
- *   __Vectors_Size
- */
-ENTRY(Reset_Handler)
-
-SECTIONS
-{
-  .text :
-  {
-    KEEP(*(.vectors))
-    __Vectors_End = .;
-    __Vectors_Size = __Vectors_End - __Vectors;
-    __end__ = .;
-
-    *(.text*)
-
-    KEEP(*(.init))
-    KEEP(*(.fini))
-
-    KEEP(*(.application_properties))
-       KEEP(*(.gecko_configuration))
-       KEEP(*(.xo_configuration))
-    KEEP(*(.gatt_header))
-    KEEP(*(.gatt_data))
-
-    /* .ctors */
-    *crtbegin.o(.ctors)
-    *crtbegin?.o(.ctors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
-    *(SORT(.ctors.*))
-    *(.ctors)
-
-    /* .dtors */
-    *crtbegin.o(.dtors)
-    *crtbegin?.o(.dtors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
-    *(SORT(.dtors.*))
-    *(.dtors)
-
-    *(.rodata*)
-
-
-    KEEP(*(.eh_frame*))
-  } > FLASH
-
-
-  .ARM.extab :
-  {
-    *(.ARM.extab* .gnu.linkonce.armextab.*)
-  } > FLASH
-
-  __exidx_start = .;
-  .ARM.exidx :
-  {
-    *(.ARM.exidx* .gnu.linkonce.armexidx.*)
-  } > FLASH
-  __exidx_end = .;
-
-
-
-  /* To copy multiple ROM to RAM sections,
-   * uncomment .copy.table section and,
-   * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .copy.table :
-  {
-    . = ALIGN(4);
-    __copy_table_start__ = .;
-    LONG (__etext)
-    LONG (__data_start__)
-    LONG (__data_end__ - __data_start__)
-    LONG (__etext2)
-    LONG (__data2_start__)
-    LONG (__data2_end__ - __data2_start__)
-    __copy_table_end__ = .;
-  } > FLASH
-  */
-
-  /* To clear multiple BSS sections,
-   * uncomment .zero.table section and,
-   * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .zero.table :
-  {
-    . = ALIGN(4);
-    __zero_table_start__ = .;
-    LONG (__bss_start__)
-    LONG (__bss_end__ - __bss_start__)
-    LONG (__bss2_start__)
-    LONG (__bss2_end__ - __bss2_start__)
-    __zero_table_end__ = .;
-  } > FLASH
-  */
-
-  __etext = .;
-
-  /*******************************************************************/
-  /* Define flash block for BLE-simee & CHIP-nvm3                    */
-  /* simee: 9000H (36k) bytes for BLE nvm3                           */
-  /* chipNvm3_section: 4000H (16k) bytes for CHIP nvm3.              */
-  /* 8K is reserved for OpenThread's NVM which is mapped directly at */
-  /* the top of flash                                                */
-  /*******************************************************************/
-
-  OPENTHREAD_NVM_SIZE = 8192;
-
-  .nvm_dummy (DSECT):
-  {
-    __nvm3_dummy_begin = .;
-    . = ALIGN (8192);
-    __nvm3_dummy_simee = .;
-    KEEP(*(.simee));
-    . = ALIGN (8192);
-    __nvm3_dummy_chip = .;
-    KEEP(*(chipNvm3_section));
-    . = ALIGN (8192);
-    . += OPENTHREAD_NVM_SIZE;
-    . = ALIGN (8192);
-  } > FLASH
-
-  /* Set NVM to end of FLASH */
-  __nvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_simee - __nvm3_dummy_begin);
-  __nvm3ChipBase = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_chip - __nvm3_dummy_begin);
-
-
-  /*******************************************************************/
-
-  .data : AT (__etext)
-  {
-    __data_start__ = .;
-    *(vtable)
-    *(.data*)
-    . = ALIGN (4);
-    PROVIDE (__ram_func_section_start = .);
-    *(.ram)
-    PROVIDE (__ram_func_section_end = .);
-
-    . = ALIGN(4);
-    /* preinit data */
-    PROVIDE_HIDDEN (__preinit_array_start = .);
-    KEEP(*(.preinit_array))
-    PROVIDE_HIDDEN (__preinit_array_end = .);
-
-    . = ALIGN(4);
-    /* init data */
-    PROVIDE_HIDDEN (__init_array_start = .);
-    KEEP(*(SORT(.init_array.*)))
-    KEEP(*(.init_array))
-    PROVIDE_HIDDEN (__init_array_end = .);
-
-    . = ALIGN(4);
-    /* finit data */
-    PROVIDE_HIDDEN (__fini_array_start = .);
-    KEEP(*(SORT(.fini_array.*)))
-    KEEP(*(.fini_array))
-    PROVIDE_HIDDEN (__fini_array_end = .);
-
-    KEEP(*(.jcr*))
-    . = ALIGN(4);
-    /* All data end */
-    __data_end__ = .;
-
-  } > RAM
-
-  .bss :
-  {
-    . = ALIGN(4);
-    __bss_start__ = .;
-    *(.bss*)
-    *(COMMON)
-    . = ALIGN(4);
-    __bss_end__ = .;
-  } > RAM
-
-  .heap (COPY):
-  {
-    __HeapBase = .;
-    __end__ = .;
-    end = __end__;
-    _end = __end__;
-    __HeapLimit = .;
-  } > RAM
-
-  /* .stack_dummy section doesn't contains any symbols. It is only
-   * used for linker to calculate size of stack sections, and assign
-   * values to stack symbols later */
-  .stack_dummy (COPY):
-  {
-    KEEP(*(.stack*))
-  } > RAM
-
-  /* Set stack top to end of RAM, and stack limit move down by
-   * size of stack_dummy section */
-  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
-  __StackLimit = __StackTop - SIZEOF(.stack_dummy);
-  PROVIDE(__stack = __StackTop);
-
-  /* Check if data + heap + stack exceeds RAM limit */
-  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
-
-
-  /* Check if FLASH usage exceeds FLASH size */
-  ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
-  ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
-}
index 0fcca37..e687771 100644 (file)
@@ -38,7 +38,6 @@ efr32_sdk("sdk") {
   sources = [
     "${efr32_project_dir}/include/CHIPProjectConfig.h",
     "${efr32_project_dir}/include/FreeRTOSConfig.h",
-    "${efr32_sdk_root}/hardware/kit/common/drivers/retargetserial.c",
   ]
 
   defines = [
@@ -46,6 +45,7 @@ efr32_sdk("sdk") {
     "HAL_VCOM_ENABLE=1",
     "EFR32_LOG_ENABLED=1",
     "PW_RPC_ENABLED",
+    "SL_HEAP_SIZE=(10 * 1024)",
   ]
 }
 
@@ -79,9 +79,9 @@ efr32_executable("pigweed_app") {
   output_dir = root_out_dir
 
   if (efr32_family == "efr32mg12") {
-    ldscript = "${efr32_project_dir}/ldscripts/efr32-pigweed-example-MG12P.ld"
+    ldscript = "${examples_plat_dir}/ldscripts/efr32-MG12P.ld"
   } else if (efr32_family == "efr32mg21") {
-    ldscript = "${efr32_project_dir}/ldscripts/efr32-pigweed-example-MG21.ld"
+    ldscript = "${examples_plat_dir}/ldscripts/efr32-MG21.ld"
   }
 
   ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ]
index 0a75bfd..e152dfa 100644 (file)
@@ -1,4 +1,4 @@
-# CHIP EFR32 Pigweed Example Application
+#CHIP EFR32 Pigweed Example Application
 
 The EFR32 example demonstrates the usage of Pigweed module functionalities in an
 application.
@@ -32,9 +32,9 @@ following features are available:
 
 -   Download or clone the
     [sdk_support](https://github.com/SiliconLabs/sdk_support) from GitHub
-    $ git clone https://github.com/SiliconLabs/sdk_support.git
-    and export the path with :
-            $
+    $ git
+    clone https://github.com/SiliconLabs/sdk_support.git and export the path
+    with : $
     export EFR32_SDK_ROOT=<Path to cloned git repo>
 
 -   Download the
@@ -50,11 +50,9 @@ following features are available:
 
 -   Install some additional tools(likely already present for CHIP developers):
 
-           # Linux
-           sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
+#Linux sudo apt-get install git libwebkitgtk-1.0-0 ninja-build
 
-           # Mac OS X
-           brew install ninja
+#Mac OS X brew install ninja
 
 -   Supported hardware:
 
@@ -122,3 +120,12 @@ following features are available:
     Note: Some users might have to install the
     [VCP driver](https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers)
     before the device shows up on `/dev/tty`.
+
+## Memory settings
+
+While most of the RAM usage in CHIP is static, allowing easier debugging and
+optimization with symbols analysis, we still need some HEAP for the crypto and
+OpenThread. Size of the HEAP can be modified by changing the value of the
+`SL_STACK_SIZE` define inside of the BUILD.gn file of this example. Please take
+note that a HEAP size smaller than 5k can and will cause a Mbedtls failure
+during the BLE rendez-vous.
index dc96c79..5365d5a 100644 (file)
  * A size, in bytes, of the individual debug event logging buffer.
  */
 #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512)
+
+/**
+ * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL
+ *
+ * The interval (in units of 0.625ms) at which the device will send BLE advertisements while
+ * in fast advertising mode.
+ *
+ * 40 (25ms).
+ */
+#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL 40
+
+/**
+ * CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL
+ *
+ * The interval (in units of 0.625ms) at which the device will send BLE advertisements while
+ * in slow advertisement mode.
+ *
+ * 800 (500ms).
+ */
+#define CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL 800
+
+/**
+ * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT
+ *
+ * The amount of time in miliseconds after which BLE should change his advertisements
+ * from fast interval to slow interval.
+ *
+ * 30000 (30 secondes).
+ */
+#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT (30 * 1000)
+
+/**
+ * CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT
+ *
+ * The amount of time in miliseconds after which BLE advertisement should be disabled, counting
+ * from the moment of slow advertisement commencement.
+ *
+ * Defaults to 9000000 (15 minutes).
+ */
+#define CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT (15 * 60 * 1000)
diff --git a/examples/pigweed-app/efr32/ldscripts/efr32-pigweed-example-MG12P.ld b/examples/pigweed-app/efr32/ldscripts/efr32-pigweed-example-MG12P.ld
deleted file mode 100644 (file)
index d20e4f8..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- *
- *    Copyright (c) 2021 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.
- */
-/***************************************************************************//**
- * Linker script for Silicon Labs EFR32MG12P devices
- * @version 5.7.2
- *******************************************************************************
- * # License
- * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
- *******************************************************************************
- *
- * SPDX-License-Identifier: Zlib
- *
- * The licensor of this software is Silicon Laboratories Inc.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- *
- ******************************************************************************/
-
-MEMORY
-{
-  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576
-  RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 262144
-}
-
-/* Linker script to place sections and symbol values. Should be used together
- * with other linker script that defines memory regions FLASH and RAM.
- * It references following symbols, which must be defined in code:
- *   Reset_Handler : Entry of reset handler
- *
- * It defines following symbols, which code can use without definition:
- *   __exidx_start
- *   __exidx_end
- *   __copy_table_start__
- *   __copy_table_end__
- *   __zero_table_start__
- *   __zero_table_end__
- *   __etext
- *   __data_start__
- *   __preinit_array_start
- *   __preinit_array_end
- *   __init_array_start
- *   __init_array_end
- *   __fini_array_start
- *   __fini_array_end
- *   __data_end__
- *   __bss_start__
- *   __bss_end__
- *   __end__
- *   end
- *   __HeapBase
- *   __HeapLimit
- *   __StackLimit
- *   __StackTop
- *   __stack
- *   __Vectors_End
- *   __Vectors_Size
- */
-ENTRY(Reset_Handler)
-
-SECTIONS
-{
-  .text :
-  {
-    KEEP(*(.vectors))
-    __Vectors_End = .;
-    __Vectors_Size = __Vectors_End - __Vectors;
-    __end__ = .;
-
-    *(.text*)
-
-    KEEP(*(.init))
-    KEEP(*(.fini))
-
-    KEEP(*(.application_properties))
-         KEEP(*(.gecko_configuration))
-         KEEP(*(.xo_configuration))
-    KEEP(*(.gatt_header))
-    KEEP(*(.gatt_data))
-
-    /* .ctors */
-    *crtbegin.o(.ctors)
-    *crtbegin?.o(.ctors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
-    *(SORT(.ctors.*))
-    *(.ctors)
-
-    /* .dtors */
-    *crtbegin.o(.dtors)
-    *crtbegin?.o(.dtors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
-    *(SORT(.dtors.*))
-    *(.dtors)
-
-    *(.rodata*)
-
-
-    KEEP(*(.eh_frame*))
-  } > FLASH
-
-
-  .ARM.extab :
-  {
-    *(.ARM.extab* .gnu.linkonce.armextab.*)
-  } > FLASH
-
-  __exidx_start = .;
-  .ARM.exidx :
-  {
-    *(.ARM.exidx* .gnu.linkonce.armexidx.*)
-  } > FLASH
-  __exidx_end = .;
-
-
-
-  /* To copy multiple ROM to RAM sections,
-   * uncomment .copy.table section and,
-   * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .copy.table :
-  {
-    . = ALIGN(4);
-    __copy_table_start__ = .;
-    LONG (__etext)
-    LONG (__data_start__)
-    LONG (__data_end__ - __data_start__)
-    LONG (__etext2)
-    LONG (__data2_start__)
-    LONG (__data2_end__ - __data2_start__)
-    __copy_table_end__ = .;
-  } > FLASH
-  */
-
-  /* To clear multiple BSS sections,
-   * uncomment .zero.table section and,
-   * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .zero.table :
-  {
-    . = ALIGN(4);
-    __zero_table_start__ = .;
-    LONG (__bss_start__)
-    LONG (__bss_end__ - __bss_start__)
-    LONG (__bss2_start__)
-    LONG (__bss2_end__ - __bss2_start__)
-    __zero_table_end__ = .;
-  } > FLASH
-  */
-
-  __etext = .;
-
-  /*******************************************************************/
-  /* Define flash block for BLE-simee & chip-nvm3                    */
-  /* simee: 9000H (36k) bytes for BLE nvm3                           */
-  /* chipNvm3_section: 4000H (16k) bytes for chip nvm3.              */
-  /* 8K is reserved for OpenThread's NVM which is mapped directly at */
-  /* the top of flash                                                */
-  /*******************************************************************/
-
-  OPENTHREAD_NVM_SIZE = 8192;
-
-  .nvm_dummy (DSECT):
-  {
-    __nvm3_dummy_begin = .;
-    . = ALIGN (8192);
-    __nvm3_dummy_simee = .;
-    KEEP(*(.simee));
-    . = ALIGN (8192);
-    __nvm3_dummy_chip = .;
-    KEEP(*(chipNvm3_section));
-    . = ALIGN (8192);
-    . += OPENTHREAD_NVM_SIZE;
-    . = ALIGN (8192);
-  } > FLASH
-
-  /* Set NVM to end of FLASH */
-  __nvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_simee - __nvm3_dummy_begin);
-  __chipNvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_chip - __nvm3_dummy_begin);
-
-
-  /*******************************************************************/
-
-  .data : AT (__etext)
-  {
-    __data_start__ = .;
-    *(vtable)
-    *(.data*)
-    . = ALIGN (4);
-    PROVIDE (__ram_func_section_start = .);
-    *(.ram)
-    PROVIDE (__ram_func_section_end = .);
-
-    . = ALIGN(4);
-    /* preinit data */
-    PROVIDE_HIDDEN (__preinit_array_start = .);
-    KEEP(*(.preinit_array))
-    PROVIDE_HIDDEN (__preinit_array_end = .);
-
-    . = ALIGN(4);
-    /* init data */
-    PROVIDE_HIDDEN (__init_array_start = .);
-    KEEP(*(SORT(.init_array.*)))
-    KEEP(*(.init_array))
-    PROVIDE_HIDDEN (__init_array_end = .);
-
-    . = ALIGN(4);
-    /* finit data */
-    PROVIDE_HIDDEN (__fini_array_start = .);
-    KEEP(*(SORT(.fini_array.*)))
-    KEEP(*(.fini_array))
-    PROVIDE_HIDDEN (__fini_array_end = .);
-
-    KEEP(*(.jcr*))
-    . = ALIGN(4);
-    /* All data end */
-    __data_end__ = .;
-
-  } > RAM
-
-  .bss :
-  {
-    . = ALIGN(4);
-    __bss_start__ = .;
-    *(.bss*)
-    *(COMMON)
-    . = ALIGN(4);
-    __bss_end__ = .;
-  } > RAM
-
-  .heap (COPY):
-  {
-    __HeapBase = .;
-    __end__ = .;
-    end = __end__;
-    _end = __end__;
-    __HeapLimit = .;
-  } > RAM
-
-  /* .stack_dummy section doesn't contains any symbols. It is only
-   * used for linker to calculate size of stack sections, and assign
-   * values to stack symbols later */
-  .stack_dummy (COPY):
-  {
-    KEEP(*(.stack*))
-  } > RAM
-
-  /* Set stack top to end of RAM, and stack limit move down by
-   * size of stack_dummy section */
-  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
-  __StackLimit = __StackTop - SIZEOF(.stack_dummy);
-  PROVIDE(__stack = __StackTop);
-
-  /* Check if data + heap + stack exceeds RAM limit */
-  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
-
-
-  /* Check if FLASH usage exceeds FLASH size */
-  ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
-  ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
-}
diff --git a/examples/pigweed-app/efr32/ldscripts/efr32-pigweed-example-MG21.ld b/examples/pigweed-app/efr32/ldscripts/efr32-pigweed-example-MG21.ld
deleted file mode 100644 (file)
index e8e870f..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- *
- *    Copyright (c) 2021 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.
- */
-/***************************************************************************//**
- * Linker script for Silicon Labs EFR32MG21 devices
- * @version 5.7.2
- *******************************************************************************
- * # License
- * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
- *******************************************************************************
- *
- * SPDX-License-Identifier: Zlib
- *
- * The licensor of this software is Silicon Laboratories Inc.
- *
- * This software is provided 'as-is', without any express or implied
- * warranty. In no event will the authors be held liable for any damages
- * arising from the use of this software.
- *
- * Permission is granted to anyone to use this software for any purpose,
- * including commercial applications, and to alter it and redistribute it
- * freely, subject to the following restrictions:
- *
- * 1. The origin of this software must not be misrepresented; you must not
- *    claim that you wrote the original software. If you use this software
- *    in a product, an acknowledgment in the product documentation would be
- *    appreciated but is not required.
- * 2. Altered source versions must be plainly marked as such, and must not be
- *    misrepresented as being the original software.
- * 3. This notice may not be removed or altered from any source distribution.
- *
- ******************************************************************************/
-
-MEMORY
-{
-  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 1048576 - 8192  /* 8K is reserved at top of flash on MG21 */
-  RAM (rwx)  : ORIGIN = 0x20000000, LENGTH = 98304
-}
-
-/* Linker script to place sections and symbol values. Should be used together
- * with other linker script that defines memory regions FLASH and RAM.
- * It references following symbols, which must be defined in code:
- *   Reset_Handler : Entry of reset handler
- *
- * It defines following symbols, which code can use without definition:
- *   __exidx_start
- *   __exidx_end
- *   __copy_table_start__
- *   __copy_table_end__
- *   __zero_table_start__
- *   __zero_table_end__
- *   __etext
- *   __data_start__
- *   __preinit_array_start
- *   __preinit_array_end
- *   __init_array_start
- *   __init_array_end
- *   __fini_array_start
- *   __fini_array_end
- *   __data_end__
- *   __bss_start__
- *   __bss_end__
- *   __end__
- *   end
- *   __HeapBase
- *   __HeapLimit
- *   __StackLimit
- *   __StackTop
- *   __stack
- *   __Vectors_End
- *   __Vectors_Size
- */
-ENTRY(Reset_Handler)
-
-SECTIONS
-{
-  .text :
-  {
-    KEEP(*(.vectors))
-    __Vectors_End = .;
-    __Vectors_Size = __Vectors_End - __Vectors;
-    __end__ = .;
-
-    *(.text*)
-
-    KEEP(*(.init))
-    KEEP(*(.fini))
-
-    KEEP(*(.application_properties))
-       KEEP(*(.gecko_configuration))
-       KEEP(*(.xo_configuration))
-    KEEP(*(.gatt_header))
-    KEEP(*(.gatt_data))
-
-    /* .ctors */
-    *crtbegin.o(.ctors)
-    *crtbegin?.o(.ctors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
-    *(SORT(.ctors.*))
-    *(.ctors)
-
-    /* .dtors */
-    *crtbegin.o(.dtors)
-    *crtbegin?.o(.dtors)
-    *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
-    *(SORT(.dtors.*))
-    *(.dtors)
-
-    *(.rodata*)
-
-
-    KEEP(*(.eh_frame*))
-  } > FLASH
-
-
-  .ARM.extab :
-  {
-    *(.ARM.extab* .gnu.linkonce.armextab.*)
-  } > FLASH
-
-  __exidx_start = .;
-  .ARM.exidx :
-  {
-    *(.ARM.exidx* .gnu.linkonce.armexidx.*)
-  } > FLASH
-  __exidx_end = .;
-
-
-
-  /* To copy multiple ROM to RAM sections,
-   * uncomment .copy.table section and,
-   * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .copy.table :
-  {
-    . = ALIGN(4);
-    __copy_table_start__ = .;
-    LONG (__etext)
-    LONG (__data_start__)
-    LONG (__data_end__ - __data_start__)
-    LONG (__etext2)
-    LONG (__data2_start__)
-    LONG (__data2_end__ - __data2_start__)
-    __copy_table_end__ = .;
-  } > FLASH
-  */
-
-  /* To clear multiple BSS sections,
-   * uncomment .zero.table section and,
-   * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
-  /*
-  .zero.table :
-  {
-    . = ALIGN(4);
-    __zero_table_start__ = .;
-    LONG (__bss_start__)
-    LONG (__bss_end__ - __bss_start__)
-    LONG (__bss2_start__)
-    LONG (__bss2_end__ - __bss2_start__)
-    __zero_table_end__ = .;
-  } > FLASH
-  */
-
-  __etext = .;
-
-  /*******************************************************************/
-  /* Define flash block for BLE-simee & CHIP-nvm3                    */
-  /* simee: 9000H (36k) bytes for BLE nvm3                           */
-  /* chipNvm3_section: 4000H (16k) bytes for CHIP nvm3.              */
-  /* 8K is reserved for OpenThread's NVM which is mapped directly at */
-  /* the top of flash                                                */
-  /*******************************************************************/
-
-  OPENTHREAD_NVM_SIZE = 8192;
-
-  .nvm_dummy (DSECT):
-  {
-    __nvm3_dummy_begin = .;
-    . = ALIGN (8192);
-    __nvm3_dummy_simee = .;
-    KEEP(*(.simee));
-    . = ALIGN (8192);
-    __nvm3_dummy_chip = .;
-    KEEP(*(chipNvm3_section));
-    . = ALIGN (8192);
-    . += OPENTHREAD_NVM_SIZE;
-    . = ALIGN (8192);
-  } > FLASH
-
-  /* Set NVM to end of FLASH */
-  __nvm3Base = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_simee - __nvm3_dummy_begin);
-  __nvm3ChipBase = LENGTH(FLASH) - SIZEOF(.nvm_dummy) + (__nvm3_dummy_chip - __nvm3_dummy_begin);
-
-
-  /*******************************************************************/
-
-  .data : AT (__etext)
-  {
-    __data_start__ = .;
-    *(vtable)
-    *(.data*)
-    . = ALIGN (4);
-    PROVIDE (__ram_func_section_start = .);
-    *(.ram)
-    PROVIDE (__ram_func_section_end = .);
-
-    . = ALIGN(4);
-    /* preinit data */
-    PROVIDE_HIDDEN (__preinit_array_start = .);
-    KEEP(*(.preinit_array))
-    PROVIDE_HIDDEN (__preinit_array_end = .);
-
-    . = ALIGN(4);
-    /* init data */
-    PROVIDE_HIDDEN (__init_array_start = .);
-    KEEP(*(SORT(.init_array.*)))
-    KEEP(*(.init_array))
-    PROVIDE_HIDDEN (__init_array_end = .);
-
-    . = ALIGN(4);
-    /* finit data */
-    PROVIDE_HIDDEN (__fini_array_start = .);
-    KEEP(*(SORT(.fini_array.*)))
-    KEEP(*(.fini_array))
-    PROVIDE_HIDDEN (__fini_array_end = .);
-
-    KEEP(*(.jcr*))
-    . = ALIGN(4);
-    /* All data end */
-    __data_end__ = .;
-
-  } > RAM
-
-  .bss :
-  {
-    . = ALIGN(4);
-    __bss_start__ = .;
-    *(.bss*)
-    *(COMMON)
-    . = ALIGN(4);
-    __bss_end__ = .;
-  } > RAM
-
-  .heap (COPY):
-  {
-    __HeapBase = .;
-    __end__ = .;
-    end = __end__;
-    _end = __end__;
-    __HeapLimit = .;
-  } > RAM
-
-  /* .stack_dummy section doesn't contains any symbols. It is only
-   * used for linker to calculate size of stack sections, and assign
-   * values to stack symbols later */
-  .stack_dummy (COPY):
-  {
-    KEEP(*(.stack*))
-  } > RAM
-
-  /* Set stack top to end of RAM, and stack limit move down by
-   * size of stack_dummy section */
-  __StackTop = ORIGIN(RAM) + LENGTH(RAM);
-  __StackLimit = __StackTop - SIZEOF(.stack_dummy);
-  PROVIDE(__stack = __StackTop);
-
-  /* Check if data + heap + stack exceeds RAM limit */
-  ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
-
-
-  /* Check if FLASH usage exceeds FLASH size */
-  ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
-  ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
-}
index 8ef8c3f..58a0fe6 100644 (file)
@@ -43,7 +43,7 @@ CONFIG_BOOT_BANNER=n
 # Configure Zephyr logger with defaults backends disabled as the app provides its own,
 # based on Pigweed HDLC.
 CONFIG_LOG=y
-CONFIG_LOG_MINIMAL=n
-CONFIG_LOG_IMMEDIATE=y
+CONFIG_LOG_MODE_MINIMAL=n
+CONFIG_LOG_MODE_IMMEDIATE=y
 CONFIG_LOG_BACKEND_UART=n
 CONFIG_LOG_BACKEND_RTT=n
diff --git a/examples/platform/efr32/MemMonitoring.cpp b/examples/platform/efr32/MemMonitoring.cpp
new file mode 100644 (file)
index 0000000..edeea2d
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ *
+ *    Copyright (c) 2021 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 "MemMonitoring.h"
+
+#include "AppConfig.h"
+#include "FreeRTOS.h"
+#include <platform/CHIPDeviceLayer.h>
+#include <platform/EFR32/freertos_bluetooth.h>
+
+static StackType_t monitoringStack[MONITORING_STACK_SIZE_byte / sizeof(StackType_t)];
+static StaticTask_t monitoringTaskStruct;
+
+size_t nbAllocSuccess        = 0;
+size_t nbFreeSuccess         = 0;
+size_t largestBlockAllocated = 0;
+
+void MemMonitoring::startHeapMonitoring()
+{
+    xTaskCreateStatic(HeapMonitoring, "Monitoring", MONITORING_STACK_SIZE_byte / sizeof(StackType_t), NULL, 1, monitoringStack,
+                      &monitoringTaskStruct);
+}
+
+void MemMonitoring::HeapMonitoring(void * pvParameter)
+{
+
+    UBaseType_t appTaskValue;
+    UBaseType_t bleEventTaskValue;
+    UBaseType_t bleTaskValue;
+    UBaseType_t linkLayerTaskValue;
+    UBaseType_t openThreadTaskValue;
+    UBaseType_t eventLoopTaskValue;
+    UBaseType_t lwipTaskValue;
+
+    TaskHandle_t eventLoopHandleStruct = xTaskGetHandle(CHIP_DEVICE_CONFIG_CHIP_TASK_NAME);
+    TaskHandle_t lwipHandle            = xTaskGetHandle(TCPIP_THREAD_NAME);
+    TaskHandle_t otTaskHandle          = xTaskGetHandle(CHIP_DEVICE_CONFIG_THREAD_TASK_NAME);
+    TaskHandle_t appTaskHandle         = xTaskGetHandle(APP_TASK_NAME);
+    TaskHandle_t bleStackTaskHandle    = xTaskGetHandle(BLE_STACK_TASK_NAME);
+    TaskHandle_t bleLinkTaskHandle     = xTaskGetHandle(BLE_LINK_TASK_NAME);
+    TaskHandle_t bleEventTaskHandle    = xTaskGetHandle(CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME);
+
+    while (1)
+    {
+        appTaskValue        = uxTaskGetStackHighWaterMark(appTaskHandle);
+        bleEventTaskValue   = uxTaskGetStackHighWaterMark(bleEventTaskHandle);
+        bleTaskValue        = uxTaskGetStackHighWaterMark(bleStackTaskHandle);
+        linkLayerTaskValue  = uxTaskGetStackHighWaterMark(bleLinkTaskHandle);
+        openThreadTaskValue = uxTaskGetStackHighWaterMark(otTaskHandle);
+        eventLoopTaskValue  = uxTaskGetStackHighWaterMark(eventLoopHandleStruct);
+        lwipTaskValue       = uxTaskGetStackHighWaterMark(lwipHandle);
+
+        EFR32_LOG("=============================");
+        EFR32_LOG("     ");
+        EFR32_LOG("Largest Block allocated              0x%x", largestBlockAllocated);
+        EFR32_LOG("Number Of Successful Alloc           0x%x", nbAllocSuccess);
+        EFR32_LOG("Number Of Successful Frees           0x%x", nbFreeSuccess);
+        EFR32_LOG("     ");
+        EFR32_LOG("App Task most bytes ever Free         0x%x", (appTaskValue * 4));
+        EFR32_LOG("BLE Event most bytes ever Free        0x%x", (bleEventTaskValue * 4));
+        EFR32_LOG("BLE Stack most bytes ever Free        0x%x", (bleTaskValue * 4));
+        EFR32_LOG("Link Layer Task most bytes ever Free  0x%x", (linkLayerTaskValue * 4));
+        EFR32_LOG("OpenThread Task most bytes ever Free  0x%x", (openThreadTaskValue * 4));
+        EFR32_LOG("Event Loop Task most bytes ever Free  0x%x", (eventLoopTaskValue * 4));
+        EFR32_LOG("LWIP Task most bytes ever Free        0x%x", (lwipTaskValue * 4));
+        EFR32_LOG("     ");
+        EFR32_LOG("=============================");
+        vTaskDelay(pdMS_TO_TICKS(5000));
+    }
+}
+
+extern "C" void memMonitoringTrackAlloc(void * ptr, size_t size)
+{
+    if (ptr != NULL)
+    {
+        nbAllocSuccess++;
+        if (largestBlockAllocated < size)
+        {
+            largestBlockAllocated = size;
+        }
+    }
+}
+
+extern "C" void memMonitoringTrackFree(void * ptr, size_t size)
+{
+    nbFreeSuccess++;
+}
diff --git a/examples/platform/efr32/MemMonitoring.h b/examples/platform/efr32/MemMonitoring.h
new file mode 100644 (file)
index 0000000..ffc430c
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ *
+ *    Copyright (c) 2021 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
+
+#ifdef HEAP_MONITORING
+#include "FreeRTOS.h"
+
+#define MONITORING_STACK_SIZE_byte 1024
+
+class MemMonitoring
+{
+public:
+    static void startHeapMonitoring();
+
+private:
+    static void HeapMonitoring(void * pvParameter);
+};
+
+#endif
index e810c1b..27884b1 100644 (file)
@@ -106,32 +106,3 @@ void PublishService()
     }
     ThreadStackMgrImpl().UnlockThreadStack();
 }
-
-void StartDefaultThreadNetwork(void)
-{
-    // Set default thread network Info and enable/start thread
-
-    chip::DeviceLayer::Internal::DeviceNetworkInfo deviceNetworkInfo;
-    memset(&deviceNetworkInfo, 0, sizeof(deviceNetworkInfo));
-    const char * networkName                                                     = "OpenThread";
-    const uint8_t masterKey[chip::DeviceLayer::Internal::kThreadMasterKeyLength] = {
-        0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
-    };
-    const uint8_t threadMeshPrefix[chip::DeviceLayer::Internal::kThreadMeshPrefixLength] = { 0xfd, 0xde, 0xad, 0x00,
-                                                                                             0xbe, 0xef, 0x00, 0x00 };
-
-    const uint8_t extendedPanId[chip::DeviceLayer::Internal::kThreadExtendedPANIdLength] = { 0xDE, 0xAD, 0x00, 0xBE,
-                                                                                             0xEF, 0x00, 0xCA, 0xFE };
-    memcpy(deviceNetworkInfo.ThreadNetworkName, networkName, strlen(networkName));
-    memcpy(deviceNetworkInfo.ThreadExtendedPANId, extendedPanId, sizeof(extendedPanId));
-    deviceNetworkInfo.FieldPresent.ThreadExtendedPANId = true;
-    memcpy(deviceNetworkInfo.ThreadMasterKey, masterKey, sizeof(masterKey));
-    deviceNetworkInfo.FieldPresent.ThreadMeshPrefix = true;
-    memcpy(deviceNetworkInfo.ThreadMeshPrefix, threadMeshPrefix, sizeof(threadMeshPrefix));
-    deviceNetworkInfo.ThreadPANId   = 0x1234;
-    deviceNetworkInfo.ThreadChannel = 11;
-
-    chip::DeviceLayer::ThreadStackMgr().SetThreadEnabled(false);
-    chip::DeviceLayer::ThreadStackMgr().SetThreadProvision(deviceNetworkInfo);
-    chip::DeviceLayer::ThreadStackMgr().SetThreadEnabled(true);
-}
index 14abfb0..1426ec6 100644 (file)
@@ -19,4 +19,3 @@
 
 void SetDeviceName(const char * newDeviceName);
 void PublishService();
-void StartDefaultThreadNetwork(void);
index 97b7062..4fb5873 100644 (file)
 #define HAL_USART1_ENABLE (1)
 #define HAL_USART1_FREQUENCY (1000000UL)
 
+#ifndef HAL_VCOM_ENABLE
 #define HAL_VCOM_ENABLE (1)
+#endif
 
 // $[BTL_BUTTON]
 
@@ -261,6 +261,7 @@ SECTIONS
     __end__ = .;
     end = __end__;
     _end = __end__;
+    KEEP(*(.heap*))
     __HeapLimit = .;
   } > RAM
 
@@ -285,4 +286,4 @@ SECTIONS
   /* Check if FLASH usage exceeds FLASH size */
   ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
   ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
-}
+}
\ No newline at end of file
@@ -261,6 +261,7 @@ SECTIONS
     __end__ = .;
     end = __end__;
     _end = __end__;
+    KEEP(*(.heap*))
     __HeapLimit = .;
   } > RAM
 
@@ -285,4 +286,4 @@ SECTIONS
   /* Check if FLASH usage exceeds FLASH size */
   ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")
   ASSERT((__etext + SIZEOF(.data)) <= __nvm3Base, "FLASH memory overlapped with NVM section.")
-}
+}
\ No newline at end of file
index a7a99d0..aff5327 100644 (file)
 
 int16_t console_getchar(char * chr)
 {
-    return uartConsoleRead(chr, 1);
+    int16_t retVal = 0;
+
+    // Busy wait for pw_rcp reads
+    while (retVal == 0)
+    {
+        retVal = uartConsoleRead(chr, 1);
+    }
+    return retVal;
 }
 
 int16_t console_putchar(const char * chr)
index 09bb46c..89390b2 100644 (file)
  *    limitations under the License.
  */
 #include "uart.h"
+#include "AppConfig.h"
+#include "assert.h"
 #include "em_core.h"
 #include "em_usart.h"
 #include "hal-config.h"
 #include "uartdrv.h"
-#include <retargetserial.h>
 #include <stddef.h>
+#include <string.h>
 
+#if !defined(MIN)
+#define MIN(A, B) ((A) < (B) ? (A) : (B))
+#endif
+
+DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_RX_BUFS, sUartRxQueue);
+DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_TX_BUFS, sUartTxQueue);
+
+typedef struct
+{
+    // The data buffer
+    uint8_t * pBuffer;
+    // The offset of the first item written to the list.
+    volatile uint16_t Head;
+    // The offset of the next item to be written to the list.
+    volatile uint16_t Tail;
+    // Maxium size of data that can be hold in buffer before overwriting
+    uint16_t MaxSize;
+} Fifo_t;
+
+#define UART_CONSOLE_ERR -1 // Negative value in case of UART Console action failed. Triggers a failure for PW_RPC
+#define MAX_BUFFER_SIZE 256
+#define MAX_DMA_BUFFER_SIZE (MAX_BUFFER_SIZE / 2)
+// In order to reduce the probability of data loss during the dmaFull callback handler we use
+// two duplicate receive buffers so we can always have one "active" receive queue.
+static uint8_t sRxDmaBuffer[MAX_DMA_BUFFER_SIZE];
+static uint8_t sRxDmaBuffer2[MAX_DMA_BUFFER_SIZE];
+static uint16_t lastCount; // Nb of bytes already processed from the active dmaBuffer
+
+// Rx buffer for the receive Fifo
+static uint8_t sRxFifoBuffer[MAX_BUFFER_SIZE];
+static Fifo_t sReceiveFifo;
+
+static UARTDRV_HandleData_t sUartHandleData;
+static UARTDRV_Handle_t sUartHandle = &sUartHandleData;
+
+static void UART_rx_callback(UARTDRV_Handle_t handle, Ecode_t transferStatus, uint8_t * data, UARTDRV_Count_t transferCount);
+
+static bool InitFifo(Fifo_t * fifo, uint8_t * pDataBuffer, uint16_t bufferSize)
+{
+    if (fifo == NULL || pDataBuffer == NULL)
+    {
+        return false;
+    }
+
+    fifo->pBuffer = pDataBuffer;
+    fifo->MaxSize = bufferSize;
+    fifo->Tail = fifo->Head = 0;
+
+    return true;
+}
+
+/*
+ *   @brief Get the amount of unprocessed bytes in the fifo buffer
+ *   @param Ptr to the fifo
+ *   @return Nb of "unread" bytes available in the fifo
+ */
+static uint16_t AvailableDataCount(Fifo_t * fifo)
+{
+    uint16_t size = 0;
+
+    // if equal there is no data return 0 directly
+    if (fifo->Tail != fifo->Head)
+    {
+        // determine if a wrap around occured to get the right data size avalaible.
+        size = (fifo->Tail < fifo->Head) ? (fifo->MaxSize - fifo->Head + fifo->Tail) : (fifo->Tail - fifo->Head);
+    }
+
+    return size;
+}
+
+/*
+ *   @brief Get the available space in the fifo buffer to insert new data
+ *   @param Ptr to the fifo
+ *   @return Nb of free bytes left in te buffer
+ */
+static uint16_t RemainingSpace(Fifo_t * fifo)
+{
+    return fifo->MaxSize - AvailableDataCount(fifo);
+}
+
+/*
+ *   @brief Write data in the fifo as a circular buffer
+ *   @param Ptr to the fifo, ptr of the data to write, nb of bytes to write
+ */
+static void WriteToFifo(Fifo_t * fifo, uint8_t * pDataToWrite, uint16_t SizeToWrite)
+{
+    assert(fifo);
+    assert(pDataToWrite);
+    assert(SizeToWrite <= fifo->MaxSize);
+
+    // Overwrite is not allowed
+    if (RemainingSpace(fifo) >= SizeToWrite)
+    {
+        uint16_t nBytesBeforWrap = (fifo->MaxSize - fifo->Tail);
+        if (SizeToWrite > nBytesBeforWrap)
+        {
+            // The number of bytes to write is bigger than the remaining bytes
+            // in the buffer, we have to wrap around
+            memcpy(fifo->pBuffer + fifo->Tail, pDataToWrite, nBytesBeforWrap);
+            memcpy(fifo->pBuffer, pDataToWrite + nBytesBeforWrap, SizeToWrite - nBytesBeforWrap);
+        }
+        else
+        {
+            memcpy(fifo->pBuffer + fifo->Tail, pDataToWrite, SizeToWrite);
+        }
+
+        fifo->Tail = (fifo->Tail + SizeToWrite) % fifo->MaxSize; // increment tail with wraparound
+    }
+}
+
+/*
+ *   @brief Write data in the fifo as a circular buffer
+ *   @param Ptr to the fifo, ptr to contain the data to process, nb of bytes to pull from the fifo
+ *   @return Nb of bytes that were retrieved.
+ */
+static uint8_t RetrieveFromFifo(Fifo_t * fifo, uint8_t * pData, uint16_t SizeToRead)
+{
+    assert(fifo);
+    assert(pData);
+    assert(SizeToRead <= fifo->MaxSize);
+
+    uint16_t ReadSize        = MIN(SizeToRead, AvailableDataCount(fifo));
+    uint16_t nBytesBeforWrap = (fifo->MaxSize - fifo->Head);
+
+    if (ReadSize > nBytesBeforWrap)
+    {
+        memcpy(pData, fifo->pBuffer + fifo->Head, nBytesBeforWrap);
+        memcpy(pData + nBytesBeforWrap, fifo->pBuffer, ReadSize - nBytesBeforWrap);
+    }
+    else
+    {
+        memcpy(pData, (fifo->pBuffer + fifo->Head), ReadSize);
+    }
+
+    fifo->Head = (fifo->Head + ReadSize) % fifo->MaxSize; // increment tail with wraparound
+
+    return ReadSize;
+}
+
+/*
+ *   @brief Init the the UART for serial communication, Start DMA reception
+ *          and init Fifo to handle the received data from this uart
+ *
+ *   @Note This UART is used for pigweed rpc
+ */
 void uartConsoleInit(void)
 {
-    RETARGET_SerialCrLf(0);
-    RETARGET_SerialInit();
+    UARTDRV_Init_t uartInit = {
+        .port     = USART0,
+        .baudRate = HAL_SERIAL_APP_BAUD_RATE,
+#if defined(_USART_ROUTELOC0_MASK)
+        .portLocationTx = BSP_SERIAL_APP_TX_LOC,
+        .portLocationRx = BSP_SERIAL_APP_RX_LOC,
+#elif defined(_USART_ROUTE_MASK)
+        portLocation = BSP_SERIAL_APP_PORT,
+#endif
+#if defined(USART_CTRL_MVDIS)
+        .mvdis = false,
+#endif
+        .stopBits     = (USART_Stopbits_TypeDef) USART_FRAME_STOPBITS_ONE,
+        .parity       = (USART_Parity_TypeDef) USART_FRAME_PARITY_NONE,
+        .oversampling = (USART_OVS_TypeDef) USART_CTRL_OVS_X16,
+        .fcType       = HAL_SERIAL_APP_FLOW_CONTROL,
+        .ctsPort      = BSP_SERIAL_APP_CTS_PORT,
+        .ctsPin       = BSP_SERIAL_APP_CTS_PIN,
+        .rtsPort      = BSP_SERIAL_APP_RTS_PORT,
+        .rtsPin       = BSP_SERIAL_APP_RTS_PIN,
+        .rxQueue      = (UARTDRV_Buffer_FifoQueue_t *) &sUartRxQueue,
+        .txQueue      = (UARTDRV_Buffer_FifoQueue_t *) &sUartTxQueue,
+#if defined(_USART_ROUTELOC1_MASK)
+        .portLocationCts = BSP_SERIAL_APP_CTS_LOC,
+        .portLocationRts = BSP_SERIAL_APP_RTS_LOC,
+#endif
+    };
+
+    // Init a fifo for the data received on the uart
+    InitFifo(&sReceiveFifo, sRxFifoBuffer, MAX_BUFFER_SIZE);
+
+    UARTDRV_InitUart(sUartHandle, &uartInit);
+    // Activate 2 dma queues to always have one active
+    UARTDRV_Receive(sUartHandle, sRxDmaBuffer, MAX_DMA_BUFFER_SIZE, UART_rx_callback);
+    UARTDRV_Receive(sUartHandle, sRxDmaBuffer2, MAX_DMA_BUFFER_SIZE, UART_rx_callback);
 }
 
+/*
+ *   @brief Callback triggered when a UARTDRV DMA buffer is full
+ */
+static void UART_rx_callback(UARTDRV_Handle_t handle, Ecode_t transferStatus, uint8_t * data, UARTDRV_Count_t transferCount)
+{
+    (void) transferStatus;
+
+    uint8_t writeSize = (transferCount - lastCount);
+    if (RemainingSpace(&sReceiveFifo) >= writeSize)
+    {
+        WriteToFifo(&sReceiveFifo, data + lastCount, writeSize);
+        lastCount = 0;
+    }
+
+    UARTDRV_Receive(sUartHandle, data, transferCount, UART_rx_callback);
+}
+
+/*
+ *   @brief Read the data available from the console Uart
+ *   @param Buffer that contains the data to write, number bytes to write.
+ *   @return Amount of bytes written or ERROR (-1)
+ */
 int16_t uartConsoleWrite(const char * Buf, uint16_t BufLength)
 {
     if (Buf == NULL || BufLength < 1)
     {
-        return -1;
+        return UART_CONSOLE_ERR;
     }
 
-    for (int i = 0; i < BufLength; i++)
+    // Use of ForceTransmit here. Transmit with DMA was causing errors with PW_RPC
+    // TODO Use DMA and find/fix what causes the issue with PW
+    if (UARTDRV_ForceTransmit(sUartHandle, (uint8_t *) Buf, BufLength) == ECODE_EMDRV_UARTDRV_OK)
     {
-        RETARGET_WriteChar(Buf[i]);
+        return BufLength;
     }
-    return (int16_t) BufLength;
+
+    return UART_CONSOLE_ERR;
 }
 
-int16_t uartConsoleRead(char * Buf, uint16_t BufLength)
+/*
+ *   @brief Read the data available from the console Uart
+ *   @param Buffer for the data to be read, number bytes to read.
+ *   @return Amount of bytes that was read from the rx fifo or ERROR (-1)
+ */
+int16_t uartConsoleRead(char * Buf, uint16_t NbBytesToRead)
 {
-    if (Buf == NULL || BufLength < 1)
+    uint8_t * data;
+    UARTDRV_Count_t count, remaining;
+
+    if (Buf == NULL || NbBytesToRead < 1)
     {
-        return -1;
+        return UART_CONSOLE_ERR;
     }
 
-    for (int i = 0; i < BufLength; i++)
+    if (NbBytesToRead > AvailableDataCount(&sReceiveFifo))
     {
-        int readVal = -1;
-        while (readVal == -1)
-        {
-            readVal = RETARGET_ReadChar();
-        }
-        Buf[i] = (char) readVal;
+        // Not enough data available in the fifo for the read size request
+        // If there is data available in dma buffer, get it now.
+        CORE_ATOMIC_SECTION(UARTDRV_GetReceiveStatus(sUartHandle, &data, &count, &remaining); if (count > lastCount) {
+            WriteToFifo(&sReceiveFifo, data + lastCount, count - lastCount);
+            lastCount = count;
+        })
     }
-    return (int16_t) BufLength;
+
+    return (int16_t) RetrieveFromFifo(&sReceiveFifo, (uint8_t *) Buf, NbBytesToRead);
 }
index 76e83b7..3ff3062 100644 (file)
@@ -26,7 +26,11 @@ extern "C" {
 
 void uartConsoleInit(void);
 int16_t uartConsoleWrite(const char * Buf, uint16_t BufLength);
-int16_t uartConsoleRead(char * Buf, uint16_t BufLength);
+int16_t uartConsoleRead(char * Buf, uint16_t NbBytesToRead);
+
+// Implemented by in openthread code
+extern void otPlatUartReceived(const uint8_t * aBuf, uint16_t aBufLength);
+extern void otPlatUartSendDone(void);
 
 #ifdef __cplusplus
 } // extern "C"
index 164995f..a8405e4 100644 (file)
 #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512)
 
 /**
+ * CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT
+ *
+ * The amount of time in miliseconds after which BLE should change his advertisements
+ * from fast interval to slow interval.
+ *
+ * 30000 (30 secondes).
+ */
+#define CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT (30 * 1000)
+
+/**
+ * CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT
+ *
+ * The amount of time in miliseconds after which BLE advertisement should be disabled, counting
+ * from the moment of slow advertisement commencement.
+ *
+ * Defaults to 9000000 (15 minutes).
+ */
+#define CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT (15 * 60 * 1000)
+
+/**
  * CHIP_CONFIG_EVENT_LOGGING_DEFAULT_IMPORTANCE
  *
  * For a development build, set the default importance of events to be logged as Debug.
index 2144493..4cd1153 100644 (file)
@@ -23,6 +23,3 @@
 #include "openthread-core-zephyr-config.h"
 
 // Project-specific settings
-
-#undef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS
-#define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 64
index d4e7bcb..62b43a1 100644 (file)
@@ -2,8 +2,8 @@ include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
 
 add_library(suppress_zephyr_warnings INTERFACE)
 target_compile_options(suppress_zephyr_warnings INTERFACE
-    -Wno-undef
     -Wno-redundant-decls
+    -Wno-missing-field-initializers
 )
 
 pw_add_module_library(pw_sys_io.nrfconnect
index dbce625..146ec66 100644 (file)
@@ -44,8 +44,8 @@ namespace {
 
 #if CONFIG_LOG
 
-#if !CONFIG_LOG_IMMEDIATE
-#error "Backend of Zephyr logger based on Pigweed HDLC requires LOG_IMMEDIATE=y"
+#if !CONFIG_LOG_MODE_IMMEDIATE
+#error "Backend of Zephyr logger based on Pigweed HDLC requires LOG_MODE_IMMEDIATE=y"
 #endif
 
 constexpr uint8_t kLogHdlcAddress = 1;   // Send log messages to HDLC address 1 (other than RPC communication)
index 4ccaeae..900dddd 100644 (file)
@@ -38,4 +38,3 @@ CONFIG_MPU_STACK_GUARD=y
 
 # CHIP configuration
 CONFIG_CHIP_PROJECT_CONFIG="CHIPProjectConfig.h"
-CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/nrfconnect/project_include/OpenThreadConfig.h"
index da55860..9a61432 100644 (file)
@@ -42,7 +42,7 @@ using namespace Logging;
 constexpr size_t kMaxTcpActiveConnectionCount = 4;
 constexpr size_t kMaxTcpPendingPackets        = 4;
 #endif
-constexpr size_t kDecimalDigitsForUint64 = 20;
+constexpr size_t kMaxPayloadSize = 1280;
 
 namespace {
 
@@ -56,6 +56,7 @@ public:
         mLastEchoTime       = 0;
         mEchoCount          = 0;
         mEchoRespCount      = 0;
+        mEchoReqSize        = 32;
         mWaitingForEchoResp = false;
 #if INET_CONFIG_ENABLE_TCP_ENDPOINT
         mUsingTCP = false;
@@ -81,6 +82,9 @@ public:
     uint32_t GetEchoInterval() const { return mEchoInterval; }
     void SetEchoInterval(uint32_t value) { mEchoInterval = value; }
 
+    uint32_t GetEchoReqSize() const { return mEchoReqSize; }
+    void SetEchoReqSize(uint32_t value) { mEchoReqSize = value; }
+
     uint16_t GetEchoPort() const { return mEchoPort; }
     void SetEchoPort(uint16_t value) { mEchoPort = value; }
 
@@ -105,6 +109,9 @@ private:
     // Count of the number of echo responses received.
     uint64_t mEchoRespCount;
 
+    // The CHIP Echo request payload size in bytes.
+    uint32_t mEchoReqSize;
+
     // Max value for the number of echo requests sent.
     uint32_t mMaxEchoCount;
 
@@ -150,10 +157,19 @@ CHIP_ERROR SendEchoRequest(streamer_t * stream)
     CHIP_ERROR err = CHIP_NO_ERROR;
 
     Messaging::SendFlags sendFlags;
-    const char kRequestFormat[] = "Echo Message %" PRIu64 "\n";
-    char requestData[(sizeof kRequestFormat) + kDecimalDigitsForUint64];
-    snprintf(requestData, sizeof requestData, kRequestFormat, gPingArguments.GetEchoCount());
-    System::PacketBufferHandle payloadBuf = MessagePacketBuffer::NewWithData(requestData, strlen(requestData));
+    System::PacketBufferHandle payloadBuf;
+    char * requestData = nullptr;
+
+    uint32_t size = gPingArguments.GetEchoReqSize();
+    VerifyOrExit(size <= kMaxPayloadSize, err = CHIP_ERROR_INVALID_MESSAGE_LENGTH);
+
+    requestData = static_cast<char *>(chip::Platform::MemoryAlloc(size));
+    VerifyOrExit(requestData != nullptr, err = CHIP_ERROR_NO_MEMORY);
+
+    snprintf(requestData, size, "Echo Message %" PRIu64 "\n", gPingArguments.GetEchoCount());
+
+    payloadBuf = MessagePacketBuffer::NewWithData(requestData, size);
+    VerifyOrExit(!payloadBuf.IsNull(), err = CHIP_ERROR_NO_MEMORY);
 
     if (gPingArguments.IsUsingCRMP())
     {
@@ -164,15 +180,10 @@ CHIP_ERROR SendEchoRequest(streamer_t * stream)
         sendFlags.Set(Messaging::SendMessageFlags::kNoAutoRequestAck);
     }
 
-    if (payloadBuf.IsNull())
-    {
-        streamer_printf(stream, "Unable to allocate packet buffer\n");
-        return CHIP_ERROR_NO_MEMORY;
-    }
-
     gPingArguments.SetLastEchoTime(System::Timer::GetCurrentEpoch());
 
-    streamer_printf(stream, "\nSend echo request message to Node: %" PRIu64 "\n", kTestDeviceNodeId);
+    streamer_printf(stream, "\nSend echo request message with payload size: %d bytes to Node: %" PRIu64 "\n", size,
+                    kTestDeviceNodeId);
 
     err = gEchoClient.SendEchoRequest(std::move(payloadBuf), sendFlags);
 
@@ -181,7 +192,14 @@ CHIP_ERROR SendEchoRequest(streamer_t * stream)
         gPingArguments.SetWaitingForEchoResp(true);
         gPingArguments.IncrementEchoCount();
     }
-    else
+
+exit:
+    if (requestData != nullptr)
+    {
+        chip::Platform::MemoryFree(requestData);
+    }
+
+    if (err != CHIP_NO_ERROR)
     {
         streamer_printf(stream, "Send echo request failed, err: %s\n", ErrorStr(err));
     }
@@ -277,7 +295,7 @@ void StartPinging(streamer_t * stream, char * destination)
         err = gSessionManager.Init(kTestControllerNodeId, &DeviceLayer::SystemLayer, &gTCPManager, &admins);
         SuccessOrExit(err);
 
-        err = gExchangeManager.Init(kTestControllerNodeId, &gTCPManager, &gSessionManager);
+        err = gExchangeManager.Init(&gSessionManager);
         SuccessOrExit(err);
     }
     else
@@ -286,7 +304,7 @@ void StartPinging(streamer_t * stream, char * destination)
         err = gSessionManager.Init(kTestControllerNodeId, &DeviceLayer::SystemLayer, &gUDPManager, &admins);
         SuccessOrExit(err);
 
-        err = gExchangeManager.Init(kTestControllerNodeId, &gUDPManager, &gSessionManager);
+        err = gExchangeManager.Init(&gSessionManager);
         SuccessOrExit(err);
     }
 
@@ -355,6 +373,7 @@ void PrintUsage(streamer_t * stream)
     streamer_printf(stream, "  -i  <interval>  ping interval time in seconds\n");
     streamer_printf(stream, "  -c  <count>     stop after <count> replies\n");
     streamer_printf(stream, "  -r  <1|0>       enable or disable CRMP\n");
+    streamer_printf(stream, "  -s  <size>      payload size in bytes\n");
 }
 
 int cmd_ping(int argc, char ** argv)
@@ -413,6 +432,17 @@ int cmd_ping(int argc, char ** argv)
                 gPingArguments.SetEchoPort(atol(argv[optIndex]));
             }
             break;
+        case 's':
+            if (++optIndex >= argc || argv[optIndex][0] == '-')
+            {
+                streamer_printf(sout, "Invalid argument specified for -s\n");
+                return -1;
+            }
+            else
+            {
+                gPingArguments.SetEchoReqSize(atol(argv[optIndex]));
+            }
+            break;
         case 'r':
             if (++optIndex >= argc || argv[optIndex][0] == '-')
             {
index 2f9a5a6..8059674 100644 (file)
@@ -118,6 +118,13 @@ typedef struct _DeviceInformationRecord
     uint8_t sort;
 } EmberAfDeviceInformationRecord;
 
+// Struct for DeviceType
+typedef struct _DeviceType
+{
+    chip::DeviceTypeId type;
+    uint16_t revision;
+} EmberAfDeviceType;
+
 // Struct for DiscoverAttributesInfoRecord
 typedef struct _DiscoverAttributesInfoRecord
 {
index 6ca0739..cd1d95a 100644 (file)
 #define ZCL_FINISH_TIME_ATTRIBUTE_ID (0x0001)
 #define ZCL_REMAINING_TIME_ATTRIBUTE_ID (0x0002)
 
+// Attribute ids for cluster: Descriptor
+
+// Client attributes
+
+// Server attributes
+#define ZCL_DEVICE_LIST_ATTRIBUTE_ID (0x0000)
+#define ZCL_SERVER_LIST_ATTRIBUTE_ID (0x0001)
+#define ZCL_CLIENT_LIST_ATTRIBUTE_ID (0x0002)
+#define ZCL_PARTS_LIST_ATTRIBUTE_ID (0x0003)
+
 // Attribute ids for cluster: Poll Control
 
 // Client attributes
 // Server attributes
 #define ZCL_MAX_DURATION_ATTRIBUTE_ID (0x0000)
 
+// Attribute ids for cluster: Media Playback
+
+// Client attributes
+
+// Server attributes
+#define ZCL_CURRENT_STATE_ATTRIBUTE_ID (0x0000)
+
 // Attribute ids for cluster: Low Power
 
 // Client attributes
 
 // Server attributes
 
+// Attribute ids for cluster: Content Launch
+
+// Client attributes
+
+// Server attributes
+
 // Attribute ids for cluster: Application Basic
 
 // Client attributes
 
 // Server attributes
 
-// Attribute ids for cluster: Media Playback
-
-// Client attributes
-
-// Server attributes
-#define ZCL_CURRENT_STATE_ATTRIBUTE_ID (0x0000)
-
-// Attribute ids for cluster: Content Launch
-
-// Client attributes
-
-// Server attributes
-
 // Attribute ids for cluster: Group Key Management
 
 // Client attributes
index a6caf3a..ee211ce 100644 (file)
@@ -34,4 +34,4 @@ ZCL_DATA8_ATTRIBUTE_TYPE, 1, ZCL_DATA16_ATTRIBUTE_TYPE, 2, ZCL_DATA24_ATTRIBUTE_
     ZCL_DATE_ATTRIBUTE_TYPE, 4, ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4, ZCL_CLUSTER_ID_ATTRIBUTE_TYPE, 2, ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE,
     2, ZCL_BACNET_OID_ATTRIBUTE_TYPE, 4, ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8, ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
     ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE, 1, ZCL_GROUP_ID_ATTRIBUTE_TYPE, 2, ZCL_COMMAND_ID_ATTRIBUTE_TYPE, 1, ZCL_NODE_ID_ATTRIBUTE_TYPE,
-    8,
+    8, ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE, 4,
index 56900dc..6f12999 100644 (file)
@@ -82,5 +82,6 @@ enum
     ZCL_GROUP_ID_ATTRIBUTE_TYPE          = 0xF3, // Group Id
     ZCL_COMMAND_ID_ATTRIBUTE_TYPE        = 0xF4, // Command Id
     ZCL_NODE_ID_ATTRIBUTE_TYPE           = 0xF5, // Node Id
+    ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE    = 0xF6, // Device Type Id
     ZCL_UNKNOWN_ATTRIBUTE_TYPE           = 0xFF, // Unknown
 };
index 79d1e15..775f29f 100644 (file)
                                                                                                                                    \
                                                           ZCL_SQUAWK_COMMAND_ID, "u", squawkInfo);
 
+/** @brief Command description for PlayRequest
+ *
+ * Command: PlayRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPlayRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_PLAY_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for PauseRequest
+ *
+ * Command: PauseRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPauseRequest() emberAfFillExternalBuffer(mask,                                                                  \
+                                                                                                                                   \
+                                                            ZCL_PAUSE_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for StopRequest
+ *
+ * Command: StopRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterStopRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_STOP_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for StartOverRequest
+ *
+ * Command: StartOverRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterStartOverRequest() emberAfFillExternalBuffer(mask,                                                              \
+                                                                                                                                   \
+                                                                ZCL_START_OVER_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for PreviousRequest
+ *
+ * Command: PreviousRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterPreviousRequest() emberAfFillExternalBuffer(mask,                                                               \
+                                                                                                                                   \
+                                                               ZCL_PREVIOUS_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for NextRequest
+ *
+ * Command: NextRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterNextRequest() emberAfFillExternalBuffer(mask,                                                                   \
+                                                                                                                                   \
+                                                           ZCL_NEXT_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for RewindRequest
+ *
+ * Command: RewindRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterRewindRequest() emberAfFillExternalBuffer(mask,                                                                 \
+                                                                                                                                   \
+                                                             ZCL_REWIND_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for FastForwardRequest
+ *
+ * Command: FastForwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterFastForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
+                                                                                                                                   \
+                                                                  ZCL_FAST_FORWARD_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for SkipForwardRequest
+ *
+ * Command: SkipForwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterSkipForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
+                                                                                                                                   \
+                                                                  ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID, "", );
+
+/** @brief Command description for SkipBackwardRequest
+ *
+ * Command: SkipBackwardRequest
+ */
+#define emberAfFillCommandMedia                                                                                                    \
+    PlaybackClusterSkipBackwardRequest() emberAfFillExternalBuffer(mask,                                                           \
+                                                                                                                                   \
+                                                                   ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID, "", );
+
 /** @brief Command description for Sleep
  *
  * Command: Sleep
                                                                                                                                    \
                                                   ZCL_SLEEP_COMMAND_ID, "", );
 
+/** @brief Command description for LaunchContent
+ *
+ * Command: LaunchContent
+ * @param contentLaunchStatus ContentLaunchStatus
+ */
+#define emberAfFillCommandContent                                                                                                  \
+    LaunchClusterLaunchContent(contentLaunchStatus)                                                                                \
+        emberAfFillExternalBuffer(mask,                                                                                            \
+                                                                                                                                   \
+                                  ZCL_LAUNCH_CONTENT_COMMAND_ID, "u", contentLaunchStatus);
+
+/** @brief Command description for LaunchURL
+ *
+ * Command: LaunchURL
+ * @param contentLaunchStatus ContentLaunchStatus
+ */
+#define emberAfFillCommandContent                                                                                                  \
+    LaunchClusterLaunchURL(contentLaunchStatus) emberAfFillExternalBuffer(mask,                                                    \
+                                                                                                                                   \
+                                                                          ZCL_LAUNCH_URL_COMMAND_ID, "u", contentLaunchStatus);
+
 /** @brief Command description for MatchProtocolAddress
  *
  * Command: MatchProtocolAddress
                                                                                                                                    \
                               ZCL_UNBIND_COMMAND_ID, "uuuu", nodeId, groupId, endpointId, clusterId);
 
-/** @brief Command description for PlayRequest
- *
- * Command: PlayRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPlayRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_PLAY_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for PauseRequest
- *
- * Command: PauseRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPauseRequest() emberAfFillExternalBuffer(mask,                                                                  \
-                                                                                                                                   \
-                                                            ZCL_PAUSE_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for StopRequest
- *
- * Command: StopRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterStopRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_STOP_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for StartOverRequest
- *
- * Command: StartOverRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterStartOverRequest() emberAfFillExternalBuffer(mask,                                                              \
-                                                                                                                                   \
-                                                                ZCL_START_OVER_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for PreviousRequest
- *
- * Command: PreviousRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterPreviousRequest() emberAfFillExternalBuffer(mask,                                                               \
-                                                                                                                                   \
-                                                               ZCL_PREVIOUS_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for NextRequest
- *
- * Command: NextRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterNextRequest() emberAfFillExternalBuffer(mask,                                                                   \
-                                                                                                                                   \
-                                                           ZCL_NEXT_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for RewindRequest
- *
- * Command: RewindRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterRewindRequest() emberAfFillExternalBuffer(mask,                                                                 \
-                                                                                                                                   \
-                                                             ZCL_REWIND_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for FastForwardRequest
- *
- * Command: FastForwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterFastForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
-                                                                                                                                   \
-                                                                  ZCL_FAST_FORWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for SkipForwardRequest
- *
- * Command: SkipForwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterSkipForwardRequest() emberAfFillExternalBuffer(mask,                                                            \
-                                                                                                                                   \
-                                                                  ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for SkipBackwardRequest
- *
- * Command: SkipBackwardRequest
- */
-#define emberAfFillCommandMedia                                                                                                    \
-    PlaybackClusterSkipBackwardRequest() emberAfFillExternalBuffer(mask,                                                           \
-                                                                                                                                   \
-                                                                   ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID, "", );
-
-/** @brief Command description for LaunchContent
- *
- * Command: LaunchContent
- * @param contentLaunchStatus ContentLaunchStatus
- */
-#define emberAfFillCommandContent                                                                                                  \
-    LaunchClusterLaunchContent(contentLaunchStatus)                                                                                \
-        emberAfFillExternalBuffer(mask,                                                                                            \
-                                                                                                                                   \
-                                  ZCL_LAUNCH_CONTENT_COMMAND_ID, "u", contentLaunchStatus);
-
-/** @brief Command description for LaunchURL
- *
- * Command: LaunchURL
- * @param contentLaunchStatus ContentLaunchStatus
- */
-#define emberAfFillCommandContent                                                                                                  \
-    LaunchClusterLaunchURL(contentLaunchStatus) emberAfFillExternalBuffer(mask,                                                    \
-                                                                                                                                   \
-                                                                          ZCL_LAUNCH_URL_COMMAND_ID, "u", contentLaunchStatus);
-
 /** @brief Command description for CommandOne
  *
  * Command: CommandOne
index 9e82931..bbd16b6 100644 (file)
@@ -71,6 +71,9 @@
 // Definitions for cluster: Appliance Control
 #define ZCL_APPLIANCE_CONTROL_CLUSTER_ID (0x001B)
 
+// Definitions for cluster: Descriptor
+#define ZCL_DESCRIPTOR_CLUSTER_ID (0x001D)
+
 // Definitions for cluster: Poll Control
 #define ZCL_POLL_CONTROL_CLUSTER_ID (0x0020)
 
 // Definitions for cluster: IAS WD
 #define ZCL_IAS_WD_CLUSTER_ID (0x0502)
 
+// Definitions for cluster: Media Playback
+#define ZCL_MEDIA_PLAYBACK_CLUSTER_ID (0x0506)
+
 // Definitions for cluster: Low Power
 #define ZCL_LOW_POWER_CLUSTER_ID (0x0508)
 
+// Definitions for cluster: Content Launch
+#define ZCL_CONTENT_LAUNCH_CLUSTER_ID (0x050A)
+
 // Definitions for cluster: Application Basic
 #define ZCL_APPLICATION_BASIC_CLUSTER_ID (0x050D)
 
 // Definitions for cluster: Binding
 #define ZCL_BINDING_CLUSTER_ID (0xF000)
 
-// Definitions for cluster: Media Playback
-#define ZCL_MEDIA_PLAYBACK_CLUSTER_ID (0xF001)
-
-// Definitions for cluster: Content Launch
-#define ZCL_CONTENT_LAUNCH_CLUSTER_ID (0xF002)
-
 // Definitions for cluster: Group Key Management
 #define ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID (0xF004)
 
index 864943b..268678a 100644 (file)
 #define ZCL_START_WARNING_COMMAND_ID (0x00)
 #define ZCL_SQUAWK_COMMAND_ID (0x01)
 
+// Commands for cluster: Media Playback
+#define ZCL_PLAY_REQUEST_COMMAND_ID (0x00)
+#define ZCL_PLAYBACK_COMMAND_ID (0x00)
+#define ZCL_PAUSE_REQUEST_COMMAND_ID (0x01)
+#define ZCL_STOP_REQUEST_COMMAND_ID (0x02)
+#define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03)
+#define ZCL_PREVIOUS_REQUEST_COMMAND_ID (0x04)
+#define ZCL_NEXT_REQUEST_COMMAND_ID (0x05)
+#define ZCL_REWIND_REQUEST_COMMAND_ID (0x06)
+#define ZCL_FAST_FORWARD_REQUEST_COMMAND_ID (0x07)
+#define ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID (0x08)
+#define ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID (0x09)
+
 // Commands for cluster: Low Power
 #define ZCL_SLEEP_COMMAND_ID (0x00)
 
+// Commands for cluster: Content Launch
+#define ZCL_LAUNCH_CONTENT_COMMAND_ID (0x00)
+#define ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID (0x00)
+#define ZCL_LAUNCH_URL_COMMAND_ID (0x01)
+#define ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID (0x01)
+
 // Commands for cluster: Generic Tunnel
 #define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00)
 #define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00)
 #define ZCL_BIND_COMMAND_ID (0x00)
 #define ZCL_UNBIND_COMMAND_ID (0x01)
 
-// Commands for cluster: Media Playback
-#define ZCL_PLAY_REQUEST_COMMAND_ID (0x00)
-#define ZCL_PLAYBACK_COMMAND_ID (0x00)
-#define ZCL_PAUSE_REQUEST_COMMAND_ID (0x01)
-#define ZCL_STOP_REQUEST_COMMAND_ID (0x02)
-#define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03)
-#define ZCL_PREVIOUS_REQUEST_COMMAND_ID (0x04)
-#define ZCL_NEXT_REQUEST_COMMAND_ID (0x05)
-#define ZCL_REWIND_REQUEST_COMMAND_ID (0x06)
-#define ZCL_FAST_FORWARD_REQUEST_COMMAND_ID (0x07)
-#define ZCL_SKIP_FORWARD_REQUEST_COMMAND_ID (0x08)
-#define ZCL_SKIP_BACKWARD_REQUEST_COMMAND_ID (0x09)
-
-// Commands for cluster: Content Launch
-#define ZCL_LAUNCH_CONTENT_COMMAND_ID (0x00)
-#define ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID (0x00)
-#define ZCL_LAUNCH_URL_COMMAND_ID (0x01)
-#define ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID (0x01)
-
 // Commands for cluster: Sample Mfg Specific Cluster
 #define ZCL_COMMAND_ONE_COMMAND_ID (0x00)
 
index 9a53800..fb4f633 100644 (file)
 #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x
 #define ZAP_REPORT_DIRECTION(x) ZRD(x)
 
-// Use this macro to check if Reporting plugin is included
-#define EMBER_AF_PLUGIN_REPORTING
 // User options for plugin Reporting
 #define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (1)
 #define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS
index e3207b7..4054969 100644 (file)
 #define CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER
 #endif
 
+#if defined(ZCL_USING_DESCRIPTOR_CLUSTER_SERVER) || defined(ZCL_USING_DESCRIPTOR_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER { ZCL_DESCRIPTOR_CLUSTER_ID, 29, "Descriptor" },
+#else
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER
+#endif
+
 #if defined(ZCL_USING_POLL_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_POLL_CONTROL_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER { ZCL_POLL_CONTROL_CLUSTER_ID, 32, "Poll Control" },
 #else
 #define CHIP_PRINTCLUSTER_IAS_WD_CLUSTER
 #endif
 
+#if defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_SERVER) || defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER { ZCL_MEDIA_PLAYBACK_CLUSTER_ID, 1286, "Media Playback" },
+#else
+#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER
+#endif
+
 #if defined(ZCL_USING_LOW_POWER_CLUSTER_SERVER) || defined(ZCL_USING_LOW_POWER_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER { ZCL_LOW_POWER_CLUSTER_ID, 1288, "Low Power" },
 #else
 #define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER
 #endif
 
+#if defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_SERVER) || defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER { ZCL_CONTENT_LAUNCH_CLUSTER_ID, 1290, "Content Launch" },
+#else
+#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER
+#endif
+
 #if defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER { ZCL_APPLICATION_BASIC_CLUSTER_ID, 1293, "Application Basic" },
 #else
 #define CHIP_PRINTCLUSTER_BINDING_CLUSTER
 #endif
 
-#if defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_SERVER) || defined(ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT)
-#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER { ZCL_MEDIA_PLAYBACK_CLUSTER_ID, 61441, "Media Playback" },
-#else
-#define CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER
-#endif
-
-#if defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_SERVER) || defined(ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT)
-#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER { ZCL_CONTENT_LAUNCH_CLUSTER_ID, 61442, "Content Launch" },
-#else
-#define CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER
-#endif
-
 #if defined(ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_SERVER) || defined(ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER { ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID, 61444, "Group Key Management" },
 #else
     CHIP_PRINTCLUSTER_OTA_BOOTLOAD_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_POWER_PROFILE_CLUSTER                                                                                        \
     CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER                                                                                    \
+    CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER                                                                                           \
     CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER                                                                                            \
     CHIP_PRINTCLUSTER_IAS_ZONE_CLUSTER                                                                                             \
     CHIP_PRINTCLUSTER_IAS_ACE_CLUSTER                                                                                              \
     CHIP_PRINTCLUSTER_IAS_WD_CLUSTER                                                                                               \
+    CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER                                                                                            \
+    CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER                                                                                    \
     CHIP_PRINTCLUSTER_GENERIC_TUNNEL_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_BACNET_PROTOCOL_TUNNEL_CLUSTER                                                                               \
     CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER                                                                                    \
     CHIP_PRINTCLUSTER_BINDING_CLUSTER                                                                                              \
-    CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER                                                                                       \
-    CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER                                                                                       \
     CHIP_PRINTCLUSTER_GROUP_KEY_MANAGEMENT_CLUSTER                                                                                 \
     CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER                                                                                  \
     CHIP_PRINTCLUSTER_SAMPLE_MFG_SPECIFIC_CLUSTER_2                                                                                \
index 2f9a5a6..8059674 100644 (file)
@@ -118,6 +118,13 @@ typedef struct _DeviceInformationRecord
     uint8_t sort;
 } EmberAfDeviceInformationRecord;
 
+// Struct for DeviceType
+typedef struct _DeviceType
+{
+    chip::DeviceTypeId type;
+    uint16_t revision;
+} EmberAfDeviceType;
+
 // Struct for DiscoverAttributesInfoRecord
 typedef struct _DiscoverAttributesInfoRecord
 {
index 0fd312a..cd1d95a 100644 (file)
 #define ZCL_FINISH_TIME_ATTRIBUTE_ID (0x0001)
 #define ZCL_REMAINING_TIME_ATTRIBUTE_ID (0x0002)
 
+// Attribute ids for cluster: Descriptor
+
+// Client attributes
+
+// Server attributes
+#define ZCL_DEVICE_LIST_ATTRIBUTE_ID (0x0000)
+#define ZCL_SERVER_LIST_ATTRIBUTE_ID (0x0001)
+#define ZCL_CLIENT_LIST_ATTRIBUTE_ID (0x0002)
+#define ZCL_PARTS_LIST_ATTRIBUTE_ID (0x0003)
+
 // Attribute ids for cluster: Poll Control
 
 // Client attributes
index a6caf3a..ee211ce 100644 (file)
@@ -34,4 +34,4 @@ ZCL_DATA8_ATTRIBUTE_TYPE, 1, ZCL_DATA16_ATTRIBUTE_TYPE, 2, ZCL_DATA24_ATTRIBUTE_
     ZCL_DATE_ATTRIBUTE_TYPE, 4, ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4, ZCL_CLUSTER_ID_ATTRIBUTE_TYPE, 2, ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE,
     2, ZCL_BACNET_OID_ATTRIBUTE_TYPE, 4, ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8, ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
     ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE, 1, ZCL_GROUP_ID_ATTRIBUTE_TYPE, 2, ZCL_COMMAND_ID_ATTRIBUTE_TYPE, 1, ZCL_NODE_ID_ATTRIBUTE_TYPE,
-    8,
+    8, ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE, 4,
index 56900dc..6f12999 100644 (file)
@@ -82,5 +82,6 @@ enum
     ZCL_GROUP_ID_ATTRIBUTE_TYPE          = 0xF3, // Group Id
     ZCL_COMMAND_ID_ATTRIBUTE_TYPE        = 0xF4, // Command Id
     ZCL_NODE_ID_ATTRIBUTE_TYPE           = 0xF5, // Node Id
+    ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE    = 0xF6, // Device Type Id
     ZCL_UNKNOWN_ATTRIBUTE_TYPE           = 0xFF, // Unknown
 };
index 499adf9..bbd16b6 100644 (file)
@@ -71,6 +71,9 @@
 // Definitions for cluster: Appliance Control
 #define ZCL_APPLIANCE_CONTROL_CLUSTER_ID (0x001B)
 
+// Definitions for cluster: Descriptor
+#define ZCL_DESCRIPTOR_CLUSTER_ID (0x001D)
+
 // Definitions for cluster: Poll Control
 #define ZCL_POLL_CONTROL_CLUSTER_ID (0x0020)
 
index a7afe9b..952c1dc 100644 (file)
 #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x
 #define ZAP_REPORT_DIRECTION(x) ZRD(x)
 
-// Use this macro to check if Reporting plugin is included
-#define EMBER_AF_PLUGIN_REPORTING
 // User options for plugin Reporting
 #define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (9)
 #define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS
index 5cb5a91..4054969 100644 (file)
 #define CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER
 #endif
 
+#if defined(ZCL_USING_DESCRIPTOR_CLUSTER_SERVER) || defined(ZCL_USING_DESCRIPTOR_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER { ZCL_DESCRIPTOR_CLUSTER_ID, 29, "Descriptor" },
+#else
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER
+#endif
+
 #if defined(ZCL_USING_POLL_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_POLL_CONTROL_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER { ZCL_POLL_CONTROL_CLUSTER_ID, 32, "Poll Control" },
 #else
     CHIP_PRINTCLUSTER_OTA_BOOTLOAD_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_POWER_PROFILE_CLUSTER                                                                                        \
     CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER                                                                                    \
+    CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER                                                                                           \
     CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER                                                                                            \
index 6994eb9..16d8cee 100755 (executable)
@@ -26,11 +26,13 @@ set -x
 env
 
 if [ -z "$3" ]; then
-    gn gen --check --fail-on-unused-args --root="$1" "$2"/"$EFR32_BOARD"/
+    gn gen --check --fail-on-unused-args --root="$1" --args="" "$2"/"$EFR32_BOARD"/
     ninja -v -C "$2"/"$EFR32_BOARD"/
+    #print stats
     arm-none-eabi-size -A "$2"/"$EFR32_BOARD"/*.out
 else
     gn gen --check --fail-on-unused-args --root="$1" --args="efr32_board=\"$3\"" "$2/$3"
     ninja -v -C "$2/$3"
+    #print stats
     arm-none-eabi-size -A "$2"/"$3"/*.out
 fi
diff --git a/scripts/examples/k32w_example.sh b/scripts/examples/k32w_example.sh
new file mode 100755 (executable)
index 0000000..ef1f218
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+#
+#    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.
+#
+
+set -e
+
+# Build script for K32W examples GitHub workflow.
+
+source "$(dirname "$0")/../../scripts/activate.sh"
+
+set -x
+env
+
+./third_party/k32w_sdk/mr2_fixes/patch_k32w_mr2_sdk.sh
+gn gen --root="$1" "$2" --args="k32w_sdk_root=\"$K32W061_SDK_ROOT\" is_debug=true"
+ninja -C "$2"
index 5058ca5..2281b95 100755 (executable)
@@ -17,7 +17,6 @@
 #
 
 # Run bootstrap and activate to set up e.g. Pigweed correctly
-source "$(dirname "$0")/../../scripts/bootstrap.sh"
 source "$(dirname "$0")/../../scripts/activate.sh"
 
 cd "$(dirname "$0")/../../examples"
diff --git a/scripts/flashing/nrfconnect_firmware_utils.py b/scripts/flashing/nrfconnect_firmware_utils.py
new file mode 100755 (executable)
index 0000000..26763a9
--- /dev/null
@@ -0,0 +1,182 @@
+#!/usr/bin/env python3
+# Copyright (c) 2020-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.
+"""Flash an NRF5 device.
+
+This is layered so that a caller can perform individual operations
+through an `Flasher` instance, or operations according to a command line.
+For `Flasher`, see the class documentation. For the parse_command()
+interface or standalone execution:
+
+usage: nrfconnect_firmware_utils.py [-h] [--verbose] [--erase]
+                                    [--application FILE]
+                                    [--verify_application] [--reset]
+                                    [--skip_reset] [--nrfjprog FILE]
+                                    [--snr SERIAL] [--family FAMILY]
+
+Flash NRF5 device
+
+optional arguments:
+  -h, --help            show this help message and exit
+
+configuration:
+  --verbose, -v         Report more verbosely
+  --nrfjprog FILE       File name of the nrfjprog executable
+  --snr SERIAL, --serial SERIAL, -s SERIAL
+                        Serial number of device to flash
+  --family FAMILY       NRF5 device family
+
+operations:
+  --erase               Erase device
+  --application FILE    Flash an image
+  --verify_application, --verify-application
+                        Verify the image after flashing
+  --reset               Reset device after flashing
+  --skip_reset, --skip-reset
+                        Do not reset device after flashing
+"""
+
+import errno
+import os
+import sys
+
+import firmware_utils
+
+# Additional options that can be use to configure an `Flasher`
+# object (as dictionary keys) and/or passed as command line options.
+NRF5_OPTIONS = {
+    # Configuration options define properties used in flashing operations.
+    'configuration': {
+        # Tool configuration options.
+        'nrfjprog': {
+            'help': 'File name of the nrfjprog executable',
+            'default': 'nrfjprog',
+            'argparse': {
+                'metavar': 'FILE'
+            },
+            'command': [
+                '{nrfjprog}',
+                {'optional': 'family'},
+                {'optional': 'snr'},
+                ()
+            ],
+            'verify': ['{nrfjprog}', '--version'],
+            'error':
+                """\
+                Unable to execute {nrfjprog}.
+
+                Please ensure that this tool is installed and
+                available. See the NRF5 example README for
+                installation instructions.
+
+                """,
+        },
+        'snr': {
+            'help': 'Serial number of device to flash',
+            'default': None,
+            'alias': ['--serial', '-s'],
+            'argparse': {
+                'metavar': 'SERIAL'
+            },
+        },
+
+        # Device configuration options.
+        'family': {
+            'help': 'NRF5 device family',
+            'default': None,
+            'argparse': {
+                'metavar': 'FAMILY'
+            },
+        },
+    },
+}
+
+
+class Flasher(firmware_utils.Flasher):
+    """Manage nrf5 flashing."""
+
+    def __init__(self, **options):
+        super().__init__(platform='NRF5', module=__name__, **options)
+        self.define_options(NRF5_OPTIONS)
+
+    def erase(self):
+        """Perform nrfjprog --eraseall"""
+        return self.run_tool('nrfjprog', ['--eraseall'], name='Erase all')
+
+    def verify(self, image):
+        """Verify image."""
+        return self.run_tool('nrfjprog',
+                             ['--quiet', '--verify', image],
+                             name='Verify',
+                             pass_message='Verified',
+                             fail_message='Not verified',
+                             fail_level=2)
+
+    def flash(self, image):
+        """Flash image."""
+        return self.run_tool('nrfjprog',
+                             ['--program', image, '--sectoranduicrerase'],
+                             name='Flash')
+
+    def reset(self):
+        """Reset the device."""
+        return self.run_tool('nrfjprog', ['--pinresetenable'], name='Enable pin reset')
+        return self.run_tool('nrfjprog', ['--pinreset'], name='Apply pin reset')
+
+    def actions(self):
+        """Perform actions on the device according to self.option."""
+        self.log(3, 'Options:', self.option)
+
+        if self.option.erase:
+            if self.erase().err:
+                return self
+
+        application = self.optional_file(self.option.application)
+        if application:
+            if self.flash(application).err:
+                return self
+            if self.option.verify_application:
+                if self.verify(application).err:
+                    return self
+            if self.option.reset is None:
+                self.option.reset = True
+
+        if self.option.reset:
+            if self.reset().err:
+                return self
+
+        return self
+
+### Mobly integration
+class Nrf5Platform:
+  def __init__(self, flasher_args):
+      self.flasher = Flasher(**flasher_args)
+
+  def flash(self):
+      self.flasher.flash_command([os.getcwd()])
+
+def verify_platform_args(platform_args):
+    required_args = ['application']
+    for r in required_args:
+        if not r in platform_args:
+            raise ValueError("Required argument %s missing" % r)
+
+def create_platform(platform_args):
+    verify_platform_args(platform_args[0])
+    return Nrf5Platform(platform_args[0])
+
+### End of Mobly integration
+
+if __name__ == '__main__':
+    sys.exit(Flasher().flash_command(sys.argv))
index 75d7728..cfa7271 100755 (executable)
@@ -39,8 +39,6 @@ restyle-paths() {
 }
 
 cd "$CHIP_ROOT"
-declare -a paths=()
-
-readarray -t paths < <(git diff --ignore-submodules --name-only "${1:-master}")
+declare -a paths="($(git diff --ignore-submodules --name-only "${1:-master}"))"
 
 restyle-paths "${paths[@]}"
index 3db71e2..efe32f8 100644 (file)
@@ -31,7 +31,7 @@ portpicker
 mobly
 
 # zephyr
-west>=0.9.0
+west>=0.10.1
 intelhex
 
 # happy tests
index 6e1acf4..aba8b1d 100644 (file)
@@ -20,6 +20,11 @@ import("${chip_root}/src/ble/ble.gni")
 import("${chip_root}/src/lwip/lwip.gni")
 import("${chip_root}/src/platform/device.gni")
 
+declare_args() {
+  # Build monolithic test library.
+  chip_monolithic_tests = false
+}
+
 config("includes") {
   include_dirs = [
     "include",
@@ -42,20 +47,25 @@ if (chip_build_tests) {
       "${chip_root}/src/lib/asn1/tests",
       "${chip_root}/src/lib/core/tests",
       "${chip_root}/src/lib/mdns/minimal/core/tests",
-      "${chip_root}/src/lib/mdns/minimal/records/tests",
       "${chip_root}/src/lib/mdns/minimal/responders/tests",
       "${chip_root}/src/lib/mdns/minimal/tests",
       "${chip_root}/src/lib/support/tests",
       "${chip_root}/src/messaging/tests",
       "${chip_root}/src/protocols/bdx/tests",
       "${chip_root}/src/protocols/secure_channel/tests",
-      "${chip_root}/src/setup_payload/tests",
       "${chip_root}/src/system/tests",
-      "${chip_root}/src/transport/raw/tests",
       "${chip_root}/src/transport/retransmit/tests",
       "${chip_root}/src/transport/tests",
     ]
 
+    if (current_os != "zephyr") {
+      deps += [
+        "${chip_root}/src/lib/mdns/minimal/records/tests",
+        "${chip_root}/src/setup_payload/tests",
+        "${chip_root}/src/transport/raw/tests",
+      ]
+    }
+
     if (chip_device_platform != "none") {
       deps += [ "${chip_root}/src/lib/mdns/minimal/tests" ]
     }
@@ -75,6 +85,12 @@ if (chip_build_tests) {
     if (current_os != "zephyr" && chip_device_platform != "esp32") {
       deps += [ "${chip_root}/src/lib/shell/tests" ]
     }
+
+    if (chip_monolithic_tests) {
+      build_monolithic_library = true
+      output_name = "libCHIP_tests"
+      output_dir = "${root_out_dir}/lib"
+    }
   }
 
   if (chip_enable_happy_tests) {
index 064eadd..3c42d4e 100644 (file)
@@ -4,7 +4,7 @@ apply plugin: 'kotlin-android-extensions'
 
 android {
     compileSdkVersion 30
-    buildToolsVersion "30.0.0"
+    buildToolsVersion "30.0.2"
 
     defaultConfig {
         applicationId "com.google.chip.chiptool"
index 3d8ac9f..8daeb76 100644 (file)
@@ -84,7 +84,7 @@ class EchoClientFragment : Fragment() {
 
     val echoEditTextContents = inputTextEd.text.toString()
     val echoText = if (echoEditTextContents.isEmpty()) DEFAULT_ECHO_MSG else echoEditTextContents
-    deviceController.sendMessage(deviceIdEd.text.toString().toInt(), echoText)
+    deviceController.sendMessage(deviceIdEd.text.toString().toLong(), echoText)
   }
 
   companion object {
index 8b28b61..415662b 100644 (file)
@@ -6,24 +6,24 @@ import android.content.SharedPreferences
 /** Utils for storing and accessing available device IDs using shared preferences. */
 object DeviceIdUtil {
   private const val PREFERENCE_FILE_KEY = "com.google.chip.chiptool.PREFERENCE_FILE_KEY"
-  private const val DEVICE_ID_PREFS_KEY = "deviceId"
-  private const val DEFAULT_DEVICE_ID = 1
+  private const val DEVICE_ID_PREFS_KEY = "device_id"
+  private const val DEFAULT_DEVICE_ID = 1L
 
-  fun getNextAvailableId(context: Context): Int {
+  fun getNextAvailableId(context: Context): Long {
     val prefs = getPrefs(context)
     return if (prefs.contains(DEVICE_ID_PREFS_KEY)) {
-      prefs.getInt(DEVICE_ID_PREFS_KEY, DEFAULT_DEVICE_ID)
+      prefs.getLong(DEVICE_ID_PREFS_KEY, DEFAULT_DEVICE_ID)
     } else {
-      prefs.edit().putInt(DEVICE_ID_PREFS_KEY, DEFAULT_DEVICE_ID).apply()
+      prefs.edit().putLong(DEVICE_ID_PREFS_KEY, DEFAULT_DEVICE_ID).apply()
       DEFAULT_DEVICE_ID
     }
   }
 
-  fun setNextAvailableId(context: Context, newId: Int) {
-    getPrefs(context).edit().putInt(DEVICE_ID_PREFS_KEY, newId).apply()
+  fun setNextAvailableId(context: Context, newId: Long) {
+    getPrefs(context).edit().putLong(DEVICE_ID_PREFS_KEY, newId).apply()
   }
 
-  fun getLastDeviceId(context: Context) = getNextAvailableId(context) - 1
+  fun getLastDeviceId(context: Context): Long = getNextAvailableId(context) - 1
 
   private fun getPrefs(context: Context): SharedPreferences {
     return context.getSharedPreferences(PREFERENCE_FILE_KEY, Context.MODE_PRIVATE)
index f068ebb..bdb554d 100644 (file)
@@ -31,7 +31,7 @@
 namespace chip {
 namespace app {
 
-CHIP_ERROR Command::Init(Messaging::ExchangeManager * apExchangeMgr)
+CHIP_ERROR Command::Init(Messaging::ExchangeManager * apExchangeMgr, InteractionModelDelegate * apDelegate)
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
     // Error if already initialized.
@@ -40,8 +40,8 @@ CHIP_ERROR Command::Init(Messaging::ExchangeManager * apExchangeMgr)
     VerifyOrExit(mpExchangeCtx == nullptr, err = CHIP_ERROR_INCORRECT_STATE);
 
     mpExchangeMgr = apExchangeMgr;
-
-    err = Reset();
+    mpDelegate    = apDelegate;
+    err           = Reset();
     SuccessOrExit(err);
 
 exit:
@@ -69,6 +69,8 @@ CHIP_ERROR Command::Reset()
     mInvokeCommandBuilder.CreateCommandListBuilder();
     MoveToState(CommandState::Initialized);
 
+    mCommandIndex = 0;
+
 exit:
     ChipLogFunctError(err);
 
@@ -134,8 +136,10 @@ void Command::Shutdown()
     ClearExistingExchangeContext();
 
     mpExchangeMgr = nullptr;
+    mpDelegate    = nullptr;
     MoveToState(CommandState::Uninitialized);
 
+    mCommandIndex = 0;
 exit:
     return;
 }
@@ -163,21 +167,24 @@ CHIP_ERROR Command::AddCommand(chip::EndpointId aEndpointId, chip::GroupId aGrou
 
 CHIP_ERROR Command::AddCommand(CommandParams & aCommandParams)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
-    const uint8_t * apCommandData;
-    uint32_t apCommandLen;
+    CHIP_ERROR err              = CHIP_NO_ERROR;
+    const uint8_t * commandData = nullptr;
+    uint32_t commandLen         = 0;
 
-    apCommandData = mCommandDataBuf->Start();
-    apCommandLen  = mCommandDataBuf->DataLength();
+    if (!mCommandDataBuf.IsNull())
+    {
+        commandData = mCommandDataBuf->Start();
+        commandLen  = mCommandDataBuf->DataLength();
+    }
 
-    if (apCommandLen > 0)
+    if (commandLen > 0 && commandData != nullptr)
     {
         // Command argument list can be empty.
-        VerifyOrExit(apCommandLen >= 2, err = CHIP_ERROR_INVALID_ARGUMENT);
-        VerifyOrExit(apCommandData[0] == chip::TLV::kTLVType_Structure, err = CHIP_ERROR_INVALID_ARGUMENT);
+        VerifyOrExit(commandLen >= 2, err = CHIP_ERROR_INVALID_ARGUMENT);
+        VerifyOrExit(commandData[0] == chip::TLV::kTLVType_Structure, err = CHIP_ERROR_INVALID_ARGUMENT);
 
-        apCommandData += 1;
-        apCommandLen -= 1;
+        commandData += 1;
+        commandLen -= 1;
     }
 
     {
@@ -199,13 +206,13 @@ CHIP_ERROR Command::AddCommand(CommandParams & aCommandParams)
         err = commandPath.GetError();
         SuccessOrExit(err);
 
-        if (apCommandLen > 0)
+        if (commandLen > 0 && commandData != nullptr)
         {
             // Copy the application data into a new TLV structure field contained with the
             // command structure.  NOTE: The TLV writer will take care of moving the app data
             // to the correct location within the buffer.
-            err = mInvokeCommandBuilder.GetWriter()->PutPreEncodedContainer(
-                chip::TLV::ContextTag(CommandDataElement::kCsTag_Data), chip::TLV::kTLVType_Structure, apCommandData, apCommandLen);
+            err = mInvokeCommandBuilder.GetWriter()->PutPreEncodedContainer(chip::TLV::ContextTag(CommandDataElement::kCsTag_Data),
+                                                                            chip::TLV::kTLVType_Structure, commandData, commandLen);
             SuccessOrExit(err);
         }
         commandDataElement.EndOfCommandDataElement();
@@ -221,8 +228,8 @@ exit:
     return err;
 }
 
-CHIP_ERROR Command::AddStatusCode(const uint16_t aGeneralCode, Protocols::Id aProtocolId, const uint16_t aProtocolCode,
-                                  const chip::ClusterId aClusterId)
+CHIP_ERROR Command::AddStatusCode(const Protocols::SecureChannel::GeneralStatusCode aGeneralCode, Protocols::Id aProtocolId,
+                                  const uint16_t aProtocolCode)
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
     StatusElement::Builder statusElementBuilder;
@@ -230,7 +237,7 @@ CHIP_ERROR Command::AddStatusCode(const uint16_t aGeneralCode, Protocols::Id aPr
     err = statusElementBuilder.Init(mInvokeCommandBuilder.GetWriter());
     SuccessOrExit(err);
 
-    statusElementBuilder.EncodeStatusElement(aGeneralCode, aProtocolId.ToFullyQualifiedSpecForm(), aProtocolCode, aProtocolCode)
+    statusElementBuilder.EncodeStatusElement(aGeneralCode, aProtocolId.ToFullyQualifiedSpecForm(), aProtocolCode)
         .EndOfStatusElement();
     err = statusElementBuilder.GetError();
 
index caf0569..ee490aa 100644 (file)
@@ -36,6 +36,7 @@
 #include <system/SystemPacketBuffer.h>
 #include <system/TLVPacketBufferBackingStore.h>
 
+#include <app/InteractionModelDelegate.h>
 #include <app/MessageDef/CommandDataElement.h>
 #include <app/MessageDef/CommandList.h>
 #include <app/MessageDef/InvokeCommand.h>
@@ -92,13 +93,14 @@ public:
      *  instance.
      *
      *  @param[in]    apExchangeMgr    A pointer to the ExchangeManager object.
+     *  @param[in]    apDelegate       InteractionModelDelegate set by application.
      *
      *  @retval #CHIP_ERROR_INCORRECT_STATE If the state is not equal to
      *          CommandState::NotInitialized.
      *  @retval #CHIP_NO_ERROR On success.
      *
      */
-    CHIP_ERROR Init(Messaging::ExchangeManager * apExchangeMgr);
+    CHIP_ERROR Init(Messaging::ExchangeManager * apExchangeMgr, InteractionModelDelegate * apDelegate);
 
     /**
      *  Shutdown the CommandSender. This terminates this instance
@@ -119,8 +121,8 @@ public:
     CHIP_ERROR AddCommand(chip::EndpointId aEndpintId, chip::GroupId aGroupId, chip::ClusterId aClusterId,
                           chip::CommandId aCommandId, BitFlags<CommandPathFlags> Flags);
     CHIP_ERROR AddCommand(CommandParams & aCommandParams);
-    CHIP_ERROR AddStatusCode(const uint16_t aGeneralCode, Protocols::Id aProtocolId, const uint16_t aProtocolCode,
-                             const chip::ClusterId aClusterId);
+    CHIP_ERROR AddStatusCode(const Protocols::SecureChannel::GeneralStatusCode aGeneralCode, Protocols::Id aProtocolId,
+                             const uint16_t aProtocolCode);
 
     /**
      * Gets the inner exchange context object, without ownership.
@@ -147,9 +149,12 @@ protected:
 
     Messaging::ExchangeManager * mpExchangeMgr = nullptr;
     Messaging::ExchangeContext * mpExchangeCtx = nullptr;
+    InteractionModelDelegate * mpDelegate      = nullptr;
     chip::System::PacketBufferHandle mCommandMessageBuf;
+    uint8_t mCommandIndex = 0;
 
 private:
+    friend class TestCommandInteraction;
     chip::System::PacketBufferHandle mpBufHandle;
     InvokeCommand::Builder mInvokeCommandBuilder;
     CommandState mState;
index e7114d4..1ed06b2 100644 (file)
@@ -93,8 +93,7 @@ CHIP_ERROR CommandHandler::ProcessCommandDataElement(CommandDataElement::Parser
         // Empty Command, Add status code in invoke command response, notify cluster handler to hand it further.
         err = CHIP_NO_ERROR;
         ChipLogDetail(DataManagement, "Add Status code for empty command, cluster Id is %d", clusterId);
-        AddStatusCode(static_cast<uint16_t>(GeneralStatusCode::kSuccess), Protocols::SecureChannel::Id,
-                      Protocols::SecureChannel::kProtocolCodeSuccess, clusterId);
+        AddStatusCode(GeneralStatusCode::kSuccess, Protocols::SecureChannel::Id, Protocols::SecureChannel::kProtocolCodeSuccess);
     }
     else if (CHIP_NO_ERROR == err)
     {
index bb4a549..c7cac78 100644 (file)
@@ -42,11 +42,11 @@ namespace app {
 class CommandHandler : public Command
 {
 public:
-    CHIP_ERROR SendCommandResponse();
     void OnMessageReceived(Messaging::ExchangeContext * ec, const PacketHeader & packetHeader, const PayloadHeader & payloadHeader,
                            System::PacketBufferHandle payload);
 
 private:
+    CHIP_ERROR SendCommandResponse();
     CHIP_ERROR ProcessCommandDataElement(CommandDataElement::Parser & aCommandElement) override;
 };
 } // namespace app
index b19401f..c5b48e4 100644 (file)
@@ -103,6 +103,11 @@ void CommandSender::OnResponseTimeout(Messaging::ExchangeContext * apExchangeCon
     ChipLogProgress(DataManagement, "Time out! failed to receive invoke command response from Exchange: %d",
                     apExchangeContext->GetExchangeId());
     Reset();
+
+    if (mpDelegate != nullptr)
+    {
+        mpDelegate->CommandResponseTimeout(this);
+    }
 }
 
 CHIP_ERROR CommandSender::ProcessCommandDataElement(CommandDataElement::Parser & aCommandElement)
@@ -113,11 +118,25 @@ CHIP_ERROR CommandSender::ProcessCommandDataElement(CommandDataElement::Parser &
     chip::ClusterId clusterId;
     chip::CommandId commandId;
     chip::EndpointId endpointId;
-    uint16_t generalCode  = 0;
-    uint32_t protocolId   = 0;
-    uint16_t protocolCode = 0;
+    Protocols::SecureChannel::GeneralStatusCode generalCode = Protocols::SecureChannel::GeneralStatusCode::kSuccess;
+    uint32_t protocolId                                     = 0;
+    uint16_t protocolCode                                   = 0;
     StatusElement::Parser statusElementParser;
 
+    mCommandIndex++;
+
+    err = aCommandElement.GetCommandPath(&commandPath);
+    SuccessOrExit(err);
+
+    err = commandPath.GetClusterId(&clusterId);
+    SuccessOrExit(err);
+
+    err = commandPath.GetCommandId(&commandId);
+    SuccessOrExit(err);
+
+    err = commandPath.GetEndpointId(&endpointId);
+    SuccessOrExit(err);
+
     err = aCommandElement.GetStatusElement(&statusElementParser);
     if (CHIP_NO_ERROR == err)
     {
@@ -125,36 +144,28 @@ CHIP_ERROR CommandSender::ProcessCommandDataElement(CommandDataElement::Parser &
         err = statusElementParser.CheckSchemaValidity();
         SuccessOrExit(err);
 
-        err = statusElementParser.DecodeStatusElement(&generalCode, &protocolId, &protocolCode, &clusterId);
+        err = statusElementParser.DecodeStatusElement(&generalCode, &protocolId, &protocolCode);
         SuccessOrExit(err);
+        if (mpDelegate != nullptr)
+        {
+            mpDelegate->CommandResponseStatus(this, generalCode, protocolId, protocolCode, endpointId, clusterId, commandId,
+                                              mCommandIndex);
+        }
     }
     else if (CHIP_END_OF_TLV == err)
     {
-        err = aCommandElement.GetCommandPath(&commandPath);
-        SuccessOrExit(err);
-
-        err = commandPath.GetClusterId(&clusterId);
-        SuccessOrExit(err);
-
-        err = commandPath.GetCommandId(&commandId);
-        SuccessOrExit(err);
-
-        err = commandPath.GetEndpointId(&endpointId);
-        SuccessOrExit(err);
-
         err = aCommandElement.GetData(&commandDataReader);
-        if (CHIP_END_OF_TLV == err)
-        {
-            err = CHIP_NO_ERROR;
-            ChipLogDetail(DataManagement, "Add Status code for empty command, cluster Id is %d", clusterId);
-            AddStatusCode(static_cast<uint16_t>(GeneralStatusCode::kSuccess), Protocols::SecureChannel::Id,
-                          Protocols::SecureChannel::kProtocolCodeSuccess, clusterId);
-        }
+        SuccessOrExit(err);
         // TODO(#4503): Should call callbacks of cluster that sends the command.
         DispatchSingleClusterCommand(clusterId, commandId, endpointId, commandDataReader, this);
     }
 
 exit:
+    ChipLogFunctError(err);
+    if (err != CHIP_NO_ERROR && mpDelegate != nullptr)
+    {
+        mpDelegate->CommandResponseProtocolError(this, mCommandIndex);
+    }
     return err;
 }
 
index da2af3d..280afab 100644 (file)
@@ -30,6 +30,7 @@
 namespace chip {
 namespace app {
 class ReadClient;
+class CommandSender;
 struct EventPathParams;
 
 /**
@@ -75,6 +76,49 @@ public:
      */
     virtual CHIP_ERROR ReportError(const ReadClient * apReadClient, CHIP_ERROR aError) { return CHIP_ERROR_NOT_IMPLEMENTED; }
 
+    /**
+     * Notification that a Command Send has received an Invoke Command Response containing a status code.
+     * @param[in]  apCommandSender A current command sender which can identify the command sender to the consumer, particularly
+     * during multiple command interactions
+     * @param[in]  aGeneralCode   Status code defined by the standard
+     * @param[in]  aProtocolId    Protocol Id
+     * @param[in]  aProtocolCode  Detailed error information, protocol-specific.
+     * @param[in]  aEndpointId    Endpoint identifier
+     * @param[in]  aClusterId     Cluster identifier
+     * @param[in]  aCommandId     Command identifier
+     * @param[in]  aCommandIndex  Current processing command index which can identify command if there exists multiple commands with
+     * same command Id
+     * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
+     */
+    virtual CHIP_ERROR CommandResponseStatus(const CommandSender * apCommandSender,
+                                             const Protocols::SecureChannel::GeneralStatusCode aGeneralCode,
+                                             const uint32_t aProtocolId, const uint16_t aProtocolCode, chip::EndpointId aEndpointId,
+                                             const chip::ClusterId aClusterId, chip::CommandId aCommandId, uint8_t aCommandIndex)
+    {
+        return CHIP_ERROR_NOT_IMPLEMENTED;
+    }
+
+    /**
+     * Notification that a Command Send has received an Invoke Command Response and fails to process a command data element in that
+     * command response
+     * @param[in]  apCommandSender A current command sender which can identify the command sender to the consumer, particularly
+     * during multiple command interactions
+     * @param[in]  aCommandIndex  Current processing command index which can identify failed command
+     * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
+     */
+    virtual CHIP_ERROR CommandResponseProtocolError(const CommandSender * apCommandSender, uint8_t aCommandIndex)
+    {
+        return CHIP_ERROR_NOT_IMPLEMENTED;
+    }
+
+    /**
+     * Notification that a command sender encountered an asynchronous failure.
+     * @param[in]  apCommandSender A current command sender which can identify the command sender to the consumer, particularly
+     * during multiple command interactions
+     * @retval # CHIP_ERROR_NOT_IMPLEMENTED if not implemented
+     */
+    virtual CHIP_ERROR CommandResponseTimeout(const CommandSender * apCommandSender) { return CHIP_ERROR_NOT_IMPLEMENTED; }
+
     virtual ~InteractionModelDelegate() = default;
 };
 
index 3226c8d..7fbb790 100644 (file)
@@ -87,7 +87,7 @@ CHIP_ERROR InteractionModelEngine::NewCommandSender(CommandSender ** const apCom
         if (commandSender.IsFree())
         {
             *apCommandSender = &commandSender;
-            err              = commandSender.Init(mpExchangeMgr);
+            err              = commandSender.Init(mpExchangeMgr, mpDelegate);
             if (CHIP_NO_ERROR != err)
             {
                 *apCommandSender = nullptr;
@@ -155,7 +155,7 @@ void InteractionModelEngine::OnInvokeCommandRequest(Messaging::ExchangeContext *
     {
         if (commandHandler.IsFree())
         {
-            err = commandHandler.Init(mpExchangeMgr);
+            err = commandHandler.Init(mpExchangeMgr, mpDelegate);
             SuccessOrExit(err);
             commandHandler.OnMessageReceived(apExchangeContext, aPacketHeader, aPayloadHeader, std::move(aPayload));
             apExchangeContext = nullptr;
index bda248f..cd35e02 100644 (file)
@@ -73,6 +73,21 @@ public:
      */
     chip::TLV::TLVWriter * GetWriter() { return mpWriter; };
 
+    /**
+     * Checkpoint the current tlv state into a TLVWriter
+     *
+     * @param[out] aPoint A writer to checkpoint the state of the TLV writer into.
+     *                    This writer must not outlive the builder
+     */
+    void Checkpoint(chip::TLV::TLVWriter & aPoint) { aPoint = *mpWriter; };
+
+    /**
+     * Rollback the request state to the checkpointed TLVWriter
+     *
+     * @param[in] aPoint A that captured the state via Checkpoint() at some point in the past
+     */
+    void Rollback(const chip::TLV::TLVWriter & aPoint) { *mpWriter = aPoint; }
+
 protected:
     CHIP_ERROR mError;
     chip::TLV::TLVWriter * mpWriter;
index 9266819..ca56f9b 100644 (file)
@@ -276,7 +276,7 @@ CHIP_ERROR CommandDataElement::Parser::CheckSchemaValidity() const
             // check if this tag has appeared before
             VerifyOrExit(!(TagPresenceMask & (1 << kCsTag_StatusElement)), err = CHIP_ERROR_INVALID_TLV_TAG);
             TagPresenceMask |= (1 << kCsTag_StatusElement);
-            VerifyOrExit(chip::TLV::kTLVType_Structure == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);
+            VerifyOrExit(chip::TLV::kTLVType_Array == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);
 
             {
                 StatusElement::Parser status;
@@ -364,7 +364,7 @@ CHIP_ERROR CommandDataElement::Parser::GetStatusElement(StatusElement::Parser *
     err = mReader.FindElementWithTag(chip::TLV::ContextTag(kCsTag_StatusElement), reader);
     SuccessOrExit(err);
 
-    VerifyOrExit(chip::TLV::kTLVType_Structure == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);
+    VerifyOrExit(chip::TLV::kTLVType_Array == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);
 
     err = apStatusElement->Init(reader);
     SuccessOrExit(err);
index 7476f1a..3d58fb2 100644 (file)
@@ -51,19 +51,21 @@ exit:
     return err;
 }
 
-CHIP_ERROR StatusElement::Parser::DecodeStatusElement(uint16_t * apGeneralCode, uint32_t * apProtocolId, uint16_t * apProtocolCode,
-                                                      chip::ClusterId * apClusterId) const
+CHIP_ERROR StatusElement::Parser::DecodeStatusElement(Protocols::SecureChannel::GeneralStatusCode * apGeneralCode,
+                                                      uint32_t * apProtocolId, uint16_t * apProtocolCode) const
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
     chip::TLV::TLVReader lReader;
 
+    uint16_t generalCode;
     lReader.Init(mReader);
 
     err = lReader.Next();
     SuccessOrExit(err);
     VerifyOrExit(lReader.GetType() == chip::TLV::kTLVType_UnsignedInteger, err = CHIP_ERROR_WRONG_TLV_TYPE);
-    err = lReader.Get(*apGeneralCode);
+    err = lReader.Get(generalCode);
     SuccessOrExit(err);
+    *apGeneralCode = static_cast<Protocols::SecureChannel::GeneralStatusCode>(generalCode);
 
     err = lReader.Next();
     SuccessOrExit(err);
@@ -77,12 +79,6 @@ CHIP_ERROR StatusElement::Parser::DecodeStatusElement(uint16_t * apGeneralCode,
     err = lReader.Get(*apProtocolCode);
     SuccessOrExit(err);
 
-    err = lReader.Next();
-    SuccessOrExit(err);
-    VerifyOrExit(lReader.GetType() == chip::TLV::kTLVType_UnsignedInteger, err = CHIP_ERROR_WRONG_TLV_TYPE);
-    err = lReader.Get(*apClusterId);
-    SuccessOrExit(err);
-
 exit:
     ChipLogFunctError(err);
     return err;
@@ -151,22 +147,6 @@ CHIP_ERROR StatusElement::Parser::CheckSchemaValidity() const
             }
 #endif // CHIP_DETAIL_LOGGING
         }
-        else if (!(TagPresenceMask & (1 << kCsTag_ClusterId)))
-        {
-            TagPresenceMask |= (1 << kCsTag_ClusterId);
-
-            VerifyOrExit(chip::TLV::kTLVType_UnsignedInteger == reader.GetType(), err = CHIP_ERROR_WRONG_TLV_TYPE);
-
-#if CHIP_DETAIL_LOGGING
-            {
-                chip::ClusterId clusterId;
-                err = reader.Get(clusterId);
-                SuccessOrExit(err);
-
-                PRETTY_PRINT("\tClusterId = 0x%" PRIx32 ",", clusterId);
-            }
-#endif // CHIP_DETAIL_LOGGING
-        }
         else
         {
             PRETTY_PRINT("\tExtra element in StatusElement");
@@ -208,24 +188,20 @@ CHIP_ERROR StatusElement::Builder::Init(chip::TLV::TLVWriter * const apWriter, c
     return ListBuilder::Init(apWriter, aContextTagToUse);
 }
 
-StatusElement::Builder & StatusElement::Builder::EncodeStatusElement(const uint16_t aGeneralCode, const uint32_t aProtocolId,
-                                                                     const uint16_t aStatusElement,
-                                                                     const chip::ClusterId aClusterId)
+StatusElement::Builder & StatusElement::Builder::EncodeStatusElement(const Protocols::SecureChannel::GeneralStatusCode aGeneralCode,
+                                                                     const uint32_t aProtocolId, const uint16_t aProtocolCode)
 {
     uint64_t tag = chip::TLV::AnonymousTag;
 
     SuccessOrExit(mError);
 
-    mError = mpWriter->Put(tag, aGeneralCode);
+    mError = mpWriter->Put(tag, static_cast<uint16_t>(aGeneralCode));
     SuccessOrExit(mError);
 
     mError = mpWriter->Put(tag, aProtocolId);
     SuccessOrExit(mError);
 
-    mError = mpWriter->Put(tag, aStatusElement);
-    SuccessOrExit(mError);
-
-    mError = mpWriter->Put(tag, aClusterId);
+    mError = mpWriter->Put(tag, aProtocolCode);
     SuccessOrExit(mError);
 
 exit:
index e74a591..c23c689 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <core/CHIPCore.h>
 #include <core/CHIPTLV.h>
+#include <protocols/secure_channel/Constants.h>
 #include <support/CodeUtils.h>
 #include <support/logging/CHIPLogging.h>
 #include <util/basic-types.h>
@@ -85,8 +86,8 @@ public:
      *               element is missing. CHIP_ERROR_WRONG_TLV_TYPE if the elements are of the wrong
      *               type.
      */
-    CHIP_ERROR DecodeStatusElement(uint16_t * apGeneralCode, uint32_t * apProtocolId, uint16_t * apProtocolCode,
-                                   chip::ClusterId * apClusterId) const;
+    CHIP_ERROR DecodeStatusElement(Protocols::SecureChannel::GeneralStatusCode * apGeneralCode, uint32_t * apProtocolId,
+                                   uint16_t * apProtocolCode) const;
 };
 
 class Builder : public ListBuilder
@@ -118,14 +119,13 @@ public:
      * @param[in]   aGeneralCode    General status code
      * @param[in]   aProtocolId     A protocol ID (32-bit integer composed of a 16-bit vendor id and 16-bit Scoped id)
      * @param[in]   aProtocolCode   16-bit protocol-specific error code
-     * @param[in]   aClusterId      Cluster Id for ZCL
      *
      * @return       CHIP_ERROR codes returned by chip::TLV objects. CHIP_END_OF_TLV if either
      *               element is missing. CHIP_ERROR_WRONG_TLV_TYPE if the elements are of the wrong
      *               type.
      */
-    StatusElement::Builder & EncodeStatusElement(const uint16_t aGeneralCode, const uint32_t aProtocolId,
-                                                 const uint16_t aProtocolCode, const chip::ClusterId aClusterId);
+    StatusElement::Builder & EncodeStatusElement(const Protocols::SecureChannel::GeneralStatusCode aGeneralCode,
+                                                 const uint32_t aProtocolId, const uint16_t aProtocolCode);
 
     /**
      *  @brief Mark the end of this StatusElement
diff --git a/src/app/clusters/account-login-server/account-login-server.cpp b/src/app/clusters/account-login-server/account-login-server.cpp
new file mode 100644 (file)
index 0000000..13dd87a
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ *
+ *    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.
+ */
+
+/**
+ *
+ *    Copyright (c) 2021 Silicon Labs
+ *
+ *    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 Routines for the Application Launcher plugin, the
+ *server implementation of the Application Launcher cluster.
+ *******************************************************************************
+ ******************************************************************************/
+
+#include <app/util/af.h>
+
+bool emberAfAccountLoginClusterGetSetupPINCallback(unsigned char *)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
+
+bool emberAfAccountLoginClusterLoginCallback(unsigned char *, unsigned char *)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
diff --git a/src/app/clusters/application-launcher-server/application-launcher-server.cpp b/src/app/clusters/application-launcher-server/application-launcher-server.cpp
new file mode 100644 (file)
index 0000000..d2eb4e5
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ *
+ *    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.
+ */
+
+/**
+ *
+ *    Copyright (c) 2021 Silicon Labs
+ *
+ *    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 Routines for the Application Launcher plugin, the
+ *server implementation of the Application Launcher cluster.
+ *******************************************************************************
+ ******************************************************************************/
+
+#include <app/util/af.h>
+
+bool emberAfApplicationLauncherClusterLaunchAppCallback(unsigned char *, unsigned char *)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
diff --git a/src/app/clusters/audio-output-server/audio-output-server.cpp b/src/app/clusters/audio-output-server/audio-output-server.cpp
new file mode 100644 (file)
index 0000000..98770bc
--- /dev/null
@@ -0,0 +1,55 @@
+/**
+ *
+ *    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.
+ */
+
+/**
+ *
+ *    Copyright (c) 2021 Silicon Labs
+ *
+ *    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 Routines for the Audio Output plugin, the
+ *server implementation of the Audio Output cluster.
+ *******************************************************************************
+ ******************************************************************************/
+
+#include <app/util/af.h>
+
+bool emberAfAudioOutputClusterRenameOutputCallback(unsigned char, unsigned char *)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
+
+bool emberAfAudioOutputClusterSelectOutputCallback(unsigned char)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
diff --git a/src/app/clusters/keypad-input-server/keypad-input-server.cpp b/src/app/clusters/keypad-input-server/keypad-input-server.cpp
new file mode 100644 (file)
index 0000000..c8f92a4
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ *
+ *    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.
+ */
+
+/**
+ *
+ *    Copyright (c) 2021 Silicon Labs
+ *
+ *    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 Routines for the Keypad Input plugin, the
+ *server implementation of the Keypad Input cluster.
+ *******************************************************************************
+ ******************************************************************************/
+
+#include <app/util/af.h>
+
+bool emberAfKeypadInputClusterSendKeyCallback(unsigned char)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
diff --git a/src/app/clusters/media-input-server/media-input-server.cpp b/src/app/clusters/media-input-server/media-input-server.cpp
new file mode 100644 (file)
index 0000000..65f3348
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ *
+ *    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.
+ */
+
+/**
+ *
+ *    Copyright (c) 2021 Silicon Labs
+ *
+ *    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 Routines for the Media Input plugin, the
+ *server implementation of the Media Input cluster.
+ *******************************************************************************
+ ******************************************************************************/
+
+#include <app/util/af.h>
+
+bool emberAfMediaInputClusterSelectInputCallback(unsigned char)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
+bool emberAfMediaInputClusterHideInputStatusCallback()
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
+
+bool emberAfMediaInputClusterRenameInputCallback(unsigned char, unsigned char *)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
+
+bool emberAfMediaInputClusterShowInputStatusCallback()
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
diff --git a/src/app/clusters/target-navigator-server/target-navigator-server.cpp b/src/app/clusters/target-navigator-server/target-navigator-server.cpp
new file mode 100644 (file)
index 0000000..5d99271
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ *
+ *    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.
+ */
+
+/**
+ *
+ *    Copyright (c) 2021 Silicon Labs
+ *
+ *    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 Routines for the Target Navigator plugin, the
+ *server implementation of the Target Navigator cluster.
+ *******************************************************************************
+ ******************************************************************************/
+
+#include <app/util/af.h>
+
+bool emberAfTargetNavigatorClusterNavigateTargetCallback(unsigned char, unsigned char *)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
diff --git a/src/app/clusters/tv-channel-server/tv-channel-server.cpp b/src/app/clusters/tv-channel-server/tv-channel-server.cpp
new file mode 100644 (file)
index 0000000..52805ec
--- /dev/null
@@ -0,0 +1,61 @@
+/**
+ *
+ *    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.
+ */
+
+/**
+ *
+ *    Copyright (c) 2021 Silicon Labs
+ *
+ *    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 Routines for the TV Channel plugin, the
+ *server implementation of the TV Channel cluster.
+ *******************************************************************************
+ ******************************************************************************/
+
+#include <app/util/af.h>
+
+bool emberAfTvChannelClusterChangeChannelCallback(unsigned char *)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
+
+bool emberAfTvChannelClusterChangeChannelByNumberCallback(unsigned short, unsigned short)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
+bool emberAfTvChannelClusterSkipChannelCallback(unsigned short)
+{
+    EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
+    emberAfSendImmediateDefaultResponse(status);
+    return true;
+}
index 8063972..1d43098 100644 (file)
@@ -15,5 +15,4 @@
 declare_args() {
   # Temporary flag for interaction model and echo protocols, set it to true to enable
   chip_app_use_echo = false
-  chip_app_use_interaction_model = false
 }
index 498c929..d0c924e 100644 (file)
@@ -18,10 +18,6 @@ import("${chip_root}/src/app/common_flags.gni")
 config("server_config") {
   defines = []
 
-  if (chip_app_use_interaction_model) {
-    defines += [ "CHIP_APP_USE_INTERACTION_MODEL" ]
-  }
-
   if (chip_app_use_echo) {
     defines += [ "CHIP_APP_USE_ECHO" ]
   }
index 48c7176..accdfbe 100644 (file)
@@ -15,6 +15,8 @@
  *    limitations under the License.
  */
 
+#include <inttypes.h>
+
 #include <app/server/Server.h>
 
 #include <app/InteractionModelEngine.h>
@@ -66,6 +68,8 @@ constexpr bool useTestPairing()
 {
     // Use the test pairing whenever rendezvous is bypassed. Otherwise, there wouldn't be
     // any way to communicate with the device using CHIP protocol.
+    // This is used to bypass BLE in the cirque test.
+    // Only in the cirque test this is enabled with --args='bypass_rendezvous=true'.
     return isRendezvousBypassed();
 }
 
@@ -130,7 +134,8 @@ CHIP_ERROR RestoreAllAdminPairingsFromKVS(AdminPairingTable & adminPairings, Adm
         }
         else
         {
-            ChipLogProgress(AppServer, "Found admin pairing for %d, node ID %llu", admin->GetAdminId(), admin->GetNodeId());
+            ChipLogProgress(AppServer, "Found admin pairing for %d, node ID 0x%08" PRIx32 "%08" PRIx32, admin->GetAdminId(),
+                            static_cast<uint32_t>(admin->GetNodeId() >> 32), static_cast<uint32_t>(admin->GetNodeId()));
         }
     }
 
@@ -166,7 +171,9 @@ static CHIP_ERROR RestoreAllSessionsFromKVS(SecureSessionMgr & sessionMgr, Rende
         {
             connection.GetPASESession(session);
 
-            ChipLogProgress(AppServer, "Fetched the session information: from %llu", session->PeerConnection().GetPeerNodeId());
+            ChipLogProgress(AppServer, "Fetched the session information: from 0x%08" PRIx32 "%08" PRIx32,
+                            static_cast<uint32_t>(session->PeerConnection().GetPeerNodeId() >> 32),
+                            static_cast<uint32_t>(session->PeerConnection().GetPeerNodeId()));
             sessionMgr.NewPairing(Optional<Transport::PeerAddress>::Value(session->PeerConnection().GetPeerAddress()),
                                   session->PeerConnection().GetPeerNodeId(), session,
                                   SecureSessionMgr::PairingDirection::kResponder, connection.GetAdminId(), nullptr);
@@ -315,8 +322,7 @@ public:
     void OnMessageReceived(const PacketHeader & header, const PayloadHeader & payloadHeader, SecureSessionHandle session,
                            System::PacketBufferHandle buffer, SecureSessionMgr * mgr) override
     {
-        auto state            = mgr->GetPeerConnectionState(session);
-        const size_t data_len = buffer->DataLength();
+        auto state = mgr->GetPeerConnectionState(session);
         char src_addr[PeerAddress::kMaxToStringSize];
 
         // as soon as a client connects, assume it is connected
@@ -327,7 +333,7 @@ public:
 
         state->GetPeerAddress().ToString(src_addr);
 
-        ChipLogProgress(AppServer, "Packet received from %s: %zu bytes", src_addr, static_cast<size_t>(data_len));
+        ChipLogProgress(AppServer, "Packet received from %s: %u bytes", src_addr, buffer->DataLength());
 
         // TODO: This code is temporary, and must be updated to use the Cluster API.
         // Issue: https://github.com/project-chip/connectedhomeip/issues/4725
@@ -400,7 +406,7 @@ private:
     AppDelegate * mDelegate = nullptr;
 };
 
-#if defined(CHIP_APP_USE_INTERACTION_MODEL) || defined(CHIP_APP_USE_ECHO)
+#if CHIP_ENABLE_INTERACTION_MODEL || defined(CHIP_APP_USE_ECHO)
 Messaging::ExchangeManager gExchangeMgr;
 #endif
 ServerCallback gCallbacks;
@@ -476,15 +482,15 @@ void InitServer(AppDelegate * delegate)
     err = gSessions.Init(chip::kTestDeviceNodeId, &DeviceLayer::SystemLayer, &gTransports, &gAdminPairings);
     SuccessOrExit(err);
 
-#if defined(CHIP_APP_USE_INTERACTION_MODEL) || defined(CHIP_APP_USE_ECHO)
+#if CHIP_ENABLE_INTERACTION_MODEL || defined(CHIP_APP_USE_ECHO)
     err = gExchangeMgr.Init(&gSessions);
     SuccessOrExit(err);
 #else
     gSessions.SetDelegate(&gCallbacks);
 #endif
 
-#if defined(CHIP_APP_USE_INTERACTION_MODEL)
-    err = chip::app::InteractionModelEngine::GetInstance()->Init(&gExchangeMgr);
+#if CHIP_ENABLE_INTERACTION_MODEL
+    err = chip::app::InteractionModelEngine::GetInstance()->Init(&gExchangeMgr, nullptr);
     SuccessOrExit(err);
 #endif
 
@@ -495,14 +501,8 @@ void InitServer(AppDelegate * delegate)
 
     if (useTestPairing())
     {
-        SuccessOrExit(err = AddTestPairing());
-    }
-
-    // This flag is used to bypass BLE in the cirque test
-    // Only in the cirque test this is enabled with --args='bypass_rendezvous=true'
-    if (isRendezvousBypassed())
-    {
         ChipLogProgress(AppServer, "Rendezvous and secure pairing skipped");
+        SuccessOrExit(err = AddTestPairing());
     }
     else if (DeviceLayer::ConnectivityMgr().IsWiFiStationProvisioned() || DeviceLayer::ConnectivityMgr().IsThreadProvisioned())
     {
index a581bab..d3a83bf 100644 (file)
@@ -22,6 +22,7 @@ chip_test_suite("tests") {
   output_name = "libAppTests"
 
   test_sources = [
+    "TestCommandInteraction.cpp",
     "TestMessageDef.cpp",
     "TestReadInteraction.cpp",
   ]
diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp
new file mode 100644 (file)
index 0000000..6514fd8
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ *
+ *    Copyright (c) 2021 Project CHIP Authors
+ *    All rights reserved.
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+/**
+ *    @file
+ *      This file implements unit tests for CHIP Interaction Model Command Interaction
+ *
+ */
+
+#include <app/InteractionModelEngine.h>
+#include <core/CHIPCore.h>
+#include <core/CHIPTLV.h>
+#include <core/CHIPTLVDebug.hpp>
+#include <core/CHIPTLVUtilities.hpp>
+#include <messaging/ExchangeContext.h>
+#include <messaging/ExchangeMgr.h>
+#include <messaging/Flags.h>
+#include <platform/CHIPDeviceLayer.h>
+#include <support/ErrorStr.h>
+#include <support/UnitTestRegistration.h>
+#include <system/SystemPacketBuffer.h>
+#include <system/TLVPacketBufferBackingStore.h>
+#include <transport/PASESession.h>
+#include <transport/SecureSessionMgr.h>
+#include <transport/raw/UDP.h>
+
+#include <nlunit-test.h>
+
+namespace chip {
+static System::Layer gSystemLayer;
+static SecureSessionMgr gSessionManager;
+static Messaging::ExchangeManager gExchangeManager;
+static TransportMgr<Transport::UDP> gTransportManager;
+static Transport::AdminId gAdminId = 0;
+
+namespace app {
+class TestCommandInteraction
+{
+public:
+    static void TestCommandSender(nlTestSuite * apSuite, void * apContext);
+    static void TestCommandHandler(nlTestSuite * apSuite, void * apContext);
+
+private:
+    static void GenerateCommandData(nlTestSuite * apSuite, void * apContext, System::PacketBufferHandle & aPayload);
+};
+
+void TestCommandInteraction::GenerateCommandData(nlTestSuite * apSuite, void * apContext, System::PacketBufferHandle & aPayload)
+{
+    CHIP_ERROR err = CHIP_NO_ERROR;
+    InvokeCommand::Builder invokeCommandBuilder;
+    System::PacketBufferTLVWriter writer;
+    writer.Init(std::move(aPayload));
+
+    err = invokeCommandBuilder.Init(&writer);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    CommandList::Builder commandList = invokeCommandBuilder.CreateCommandListBuilder();
+    NL_TEST_ASSERT(apSuite, invokeCommandBuilder.GetError() == CHIP_NO_ERROR);
+
+    CommandDataElement::Builder commandDataElementBuilder = commandList.CreateCommandDataElementBuilder();
+    NL_TEST_ASSERT(apSuite, commandList.GetError() == CHIP_NO_ERROR);
+    CommandPath::Builder commandPathBuilder = commandDataElementBuilder.CreateCommandPathBuilder();
+    NL_TEST_ASSERT(apSuite, commandDataElementBuilder.GetError() == CHIP_NO_ERROR);
+    commandPathBuilder.EndpointId(1).ClusterId(3).CommandId(4).EndOfCommandPath();
+    NL_TEST_ASSERT(apSuite, commandPathBuilder.GetError() == CHIP_NO_ERROR);
+
+    chip::TLV::TLVWriter * pWriter = commandDataElementBuilder.GetWriter();
+    chip::TLV::TLVType dummyType   = chip::TLV::kTLVType_NotSpecified;
+    err = pWriter->StartContainer(chip::TLV::ContextTag(CommandDataElement::kCsTag_Data), chip::TLV::kTLVType_Structure, dummyType);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    err = pWriter->PutBoolean(chip::TLV::ContextTag(1), true);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    err = pWriter->EndContainer(dummyType);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    commandDataElementBuilder.EndOfCommandDataElement();
+    NL_TEST_ASSERT(apSuite, commandDataElementBuilder.GetError() == CHIP_NO_ERROR);
+
+    commandList.EndOfCommandList();
+    NL_TEST_ASSERT(apSuite, commandList.GetError() == CHIP_NO_ERROR);
+
+    invokeCommandBuilder.EndOfInvokeCommand();
+    NL_TEST_ASSERT(apSuite, invokeCommandBuilder.GetError() == CHIP_NO_ERROR);
+
+    err = writer.Finalize(&aPayload);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+}
+
+void TestCommandInteraction::TestCommandSender(nlTestSuite * apSuite, void * apContext)
+{
+    CHIP_ERROR err = CHIP_NO_ERROR;
+
+    app::CommandSender commandSender;
+
+    System::PacketBufferHandle buf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);
+    err                            = commandSender.Init(&gExchangeManager, nullptr);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    err = commandSender.SendCommandRequest(kTestDeviceNodeId, gAdminId);
+    NL_TEST_ASSERT(apSuite, err == CHIP_ERROR_NOT_CONNECTED);
+
+    GenerateCommandData(apSuite, apContext, buf);
+
+    err = commandSender.ProcessCommandMessage(std::move(buf), Command::CommandRoleId::SenderId);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    commandSender.Shutdown();
+}
+
+void TestCommandInteraction::TestCommandHandler(nlTestSuite * apSuite, void * apContext)
+{
+    CHIP_ERROR err = CHIP_NO_ERROR;
+    app::CommandHandler commandHandler;
+    System::PacketBufferTLVWriter writer;
+    System::PacketBufferHandle commandDatabuf = System::PacketBufferHandle::New(System::PacketBuffer::kMaxSize);
+    err                                       = commandHandler.Init(&chip::gExchangeManager, nullptr);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    GenerateCommandData(apSuite, apContext, commandDatabuf);
+
+    err = commandHandler.ProcessCommandMessage(std::move(commandDatabuf), Command::CommandRoleId::HandlerId);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+}
+
+} // namespace app
+} // namespace chip
+
+namespace {
+
+void InitializeChip(nlTestSuite * apSuite)
+{
+    CHIP_ERROR err = CHIP_NO_ERROR;
+    chip::Optional<chip::Transport::PeerAddress> peer(chip::Transport::Type::kUndefined);
+    chip::Transport::AdminPairingTable admins;
+    chip::Transport::AdminPairingInfo * adminInfo = admins.AssignAdminId(chip::gAdminId, chip::kTestDeviceNodeId);
+
+    NL_TEST_ASSERT(apSuite, adminInfo != nullptr);
+
+    err = chip::Platform::MemoryInit();
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    chip::gSystemLayer.Init(nullptr);
+
+    err = chip::gSessionManager.Init(chip::kTestDeviceNodeId, &chip::gSystemLayer, &chip::gTransportManager, &admins);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    err = chip::gExchangeManager.Init(&chip::gSessionManager);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    err = chip::app::InteractionModelEngine::GetInstance()->Init(&chip::gExchangeManager, nullptr);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+}
+
+// clang-format off
+const nlTest sTests[] =
+{
+    NL_TEST_DEF("CheckCommandSender", chip::app::TestCommandInteraction::TestCommandSender),
+    NL_TEST_DEF("CheckCommandHandler", chip::app::TestCommandInteraction::TestCommandHandler),
+    NL_TEST_SENTINEL()
+};
+// clang-format on
+
+} // namespace
+
+int TestCommandInteraction()
+{
+    // clang-format off
+    nlTestSuite theSuite =
+       {
+        "CommandInteraction",
+        &sTests[0],
+        nullptr,
+        nullptr
+    };
+    // clang-format on
+
+    InitializeChip(&theSuite);
+
+    nlTestRunner(&theSuite, nullptr);
+
+    return (nlTestRunnerStats(&theSuite));
+}
+
+CHIP_REGISTER_TEST_SUITE(TestCommandInteraction)
index 38da5d4..0b53c06 100644 (file)
@@ -324,7 +324,8 @@ void BuildStatusElement(nlTestSuite * apSuite, StatusElement::Builder & aStatusE
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
 
-    aStatusElementBuilder.EncodeStatusElement(1, 2, 3, 4).EndOfStatusElement();
+    aStatusElementBuilder.EncodeStatusElement(chip::Protocols::SecureChannel::GeneralStatusCode::kFailure, 2, 3)
+        .EndOfStatusElement();
     err = aStatusElementBuilder.GetError();
     NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
 }
@@ -334,16 +335,19 @@ void ParseStatusElement(nlTestSuite * apSuite, StatusElement::Parser & aStatusEl
     CHIP_ERROR err = CHIP_NO_ERROR;
     StatusElement::Parser StatusElementParser;
 
-    uint16_t generalCode      = 0;
-    uint32_t protocolId       = 0;
-    uint16_t protocolCode     = 0;
-    chip::ClusterId clusterId = 0;
+    chip::Protocols::SecureChannel::GeneralStatusCode generalCode = chip::Protocols::SecureChannel::GeneralStatusCode::kFailure;
+    uint32_t protocolId                                           = 0;
+    uint16_t protocolCode                                         = 0;
 
     err = aStatusElementParser.CheckSchemaValidity();
     NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
 
-    err = aStatusElementParser.DecodeStatusElement(&generalCode, &protocolId, &protocolCode, &clusterId);
-    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR && generalCode == 1 && protocolId == 2 && protocolCode == 3 && clusterId == 4);
+    err = aStatusElementParser.DecodeStatusElement(&generalCode, &protocolId, &protocolCode);
+    NL_TEST_ASSERT(apSuite,
+                   err == CHIP_NO_ERROR &&
+                       static_cast<uint16_t>(generalCode) ==
+                           static_cast<uint16_t>(chip::Protocols::SecureChannel::GeneralStatusCode::kFailure) &&
+                       protocolId == 2 && protocolCode == 3);
 }
 
 void BuildAttributeStatusElement(nlTestSuite * apSuite, AttributeStatusElement::Builder & aAttributeStatusElementBuilder)
@@ -574,6 +578,35 @@ void ParseCommandDataElement(nlTestSuite * apSuite, CommandDataElement::Parser &
     }
 }
 
+void BuildCommandDataElementWithStatusCode(nlTestSuite * apSuite, CommandDataElement::Builder & aCommandDataElementBuilder)
+{
+    CommandPath::Builder commandPathBuilder = aCommandDataElementBuilder.CreateCommandPathBuilder();
+    NL_TEST_ASSERT(apSuite, aCommandDataElementBuilder.GetError() == CHIP_NO_ERROR);
+    BuildCommandPath(apSuite, commandPathBuilder);
+
+    StatusElement::Builder statusElementBuilder = aCommandDataElementBuilder.CreateStatusElementBuilder();
+    NL_TEST_ASSERT(apSuite, statusElementBuilder.GetError() == CHIP_NO_ERROR);
+    BuildStatusElement(apSuite, statusElementBuilder);
+
+    aCommandDataElementBuilder.EndOfCommandDataElement();
+    NL_TEST_ASSERT(apSuite, aCommandDataElementBuilder.GetError() == CHIP_NO_ERROR);
+}
+
+void ParseCommandDataElementWithStatusCode(nlTestSuite * apSuite, CommandDataElement::Parser & aCommandDataElementParser)
+{
+    CHIP_ERROR err = CHIP_NO_ERROR;
+    CommandPath::Parser commandPathParser;
+    StatusElement::Parser statusElementParser;
+    err = aCommandDataElementParser.CheckSchemaValidity();
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    err = aCommandDataElementParser.GetCommandPath(&commandPathParser);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    err = aCommandDataElementParser.GetStatusElement(&statusElementParser);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+}
+
 void BuildCommandList(nlTestSuite * apSuite, CommandList::Builder & aCommandListBuilder)
 {
     CommandDataElement::Builder commandDataElementBuilder = aCommandListBuilder.CreateCommandDataElementBuilder();
@@ -1073,6 +1106,30 @@ void CommandDataElementTest(nlTestSuite * apSuite, void * apContext)
     ParseCommandDataElement(apSuite, commandDataElementParser);
 }
 
+void CommandDataElementWithStatusCodeTest(nlTestSuite * apSuite, void * apContext)
+{
+    CHIP_ERROR err = CHIP_NO_ERROR;
+    CommandDataElement::Builder commandDataElementBuilder;
+    CommandDataElement::Parser commandDataElementParser;
+    chip::System::PacketBufferTLVWriter writer;
+    chip::System::PacketBufferTLVReader reader;
+    writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
+    commandDataElementBuilder.Init(&writer);
+    BuildCommandDataElementWithStatusCode(apSuite, commandDataElementBuilder);
+    chip::System::PacketBufferHandle buf;
+    err = writer.Finalize(&buf);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    DebugPrettyPrint(buf);
+
+    reader.Init(std::move(buf));
+    err = reader.Next();
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    commandDataElementParser.Init(reader);
+    ParseCommandDataElementWithStatusCode(apSuite, commandDataElementParser);
+}
+
 void CommandListTest(nlTestSuite * apSuite, void * apContext)
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
@@ -1151,6 +1208,56 @@ void ReadRequestTest(nlTestSuite * apSuite, void * apContext)
     ParseReadRequest(apSuite, reader);
 }
 
+void CheckPointRollbackTest(nlTestSuite * apSuite, void * apContext)
+{
+    CHIP_ERROR err        = CHIP_NO_ERROR;
+    size_t NumDataElement = 0;
+    chip::System::PacketBufferTLVWriter writer;
+    chip::System::PacketBufferTLVReader reader;
+    AttributeDataList::Parser attributeDataListParser;
+    chip::TLV::TLVWriter checkpoint;
+    writer.Init(chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSize));
+    AttributeDataList::Builder attributeDataListBuilder;
+    attributeDataListBuilder.Init(&writer);
+
+    // encode one attribute element
+    AttributeDataElement::Builder attributeDataElementBuilder1 = attributeDataListBuilder.CreateAttributeDataElementBuilder();
+    NL_TEST_ASSERT(apSuite, attributeDataListBuilder.GetError() == CHIP_NO_ERROR);
+    BuildAttributeDataElement(apSuite, attributeDataElementBuilder1);
+    // checkpoint
+    attributeDataListBuilder.Checkpoint(checkpoint);
+    // encode another attribute element
+    AttributeDataElement::Builder attributeDataElementBuilder2 = attributeDataListBuilder.CreateAttributeDataElementBuilder();
+    NL_TEST_ASSERT(apSuite, attributeDataListBuilder.GetError() == CHIP_NO_ERROR);
+    BuildAttributeDataElement(apSuite, attributeDataElementBuilder2);
+    // rollback to previous checkpoint
+    attributeDataListBuilder.Rollback(checkpoint);
+
+    attributeDataListBuilder.EndOfAttributeDataList();
+    NL_TEST_ASSERT(apSuite, attributeDataListBuilder.GetError() == CHIP_NO_ERROR);
+
+    chip::System::PacketBufferHandle buf;
+    err = writer.Finalize(&buf);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    DebugPrettyPrint(buf);
+
+    reader.Init(std::move(buf));
+    err = reader.Next();
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+
+    err = attributeDataListParser.Init(reader);
+    NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
+    attributeDataListParser.CheckSchemaValidity();
+
+    while (CHIP_NO_ERROR == (err = attributeDataListParser.Next()))
+    {
+        ++NumDataElement;
+    }
+
+    NL_TEST_ASSERT(apSuite, NumDataElement == 1);
+}
+
 /**
  *   Test Suite. It lists all the test functions.
  */
@@ -1172,10 +1279,12 @@ const nlTest sTests[] =
                 NL_TEST_DEF("AttributeDataListTest", AttributeDataListTest),
                 NL_TEST_DEF("AttributeDataVersionListTest", AttributeDataVersionListTest),
                 NL_TEST_DEF("CommandDataElementTest", CommandDataElementTest),
+                NL_TEST_DEF("CommandDataElementWithStatusCodeTest", CommandDataElementWithStatusCodeTest),
                 NL_TEST_DEF("CommandListTest", CommandListTest),
                 NL_TEST_DEF("ReportDataTest", ReportDataTest),
                 NL_TEST_DEF("InvokeCommandTest", InvokeCommandTest),
                 NL_TEST_DEF("ReadRequestTest", ReadRequestTest),
+                NL_TEST_DEF("CheckPointRollbackTest", CheckPointRollbackTest),
                 NL_TEST_SENTINEL()
         };
 // clang-format on
index cf7860b..e5cb5d6 100644 (file)
@@ -42,6 +42,7 @@
 #include <nlunit-test.h>
 
 namespace chip {
+System::Layer gSystemLayer;
 SecureSessionMgr gSessionManager;
 Messaging::ExchangeManager gExchangeManager;
 TransportMgr<Transport::UDP> gTransportManager;
@@ -135,6 +136,7 @@ void TestReadInteraction::TestReadHandler(nlTestSuite * apSuite, void * apContex
 } // namespace chip
 
 namespace {
+
 void InitializeChip(nlTestSuite * apSuite)
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
@@ -147,10 +149,12 @@ void InitializeChip(nlTestSuite * apSuite)
     err = chip::Platform::MemoryInit();
     NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
 
-    err = chip::gSessionManager.Init(chip::kTestDeviceNodeId, nullptr, nullptr, &admins);
+    chip::gSystemLayer.Init(nullptr);
+
+    err = chip::gSessionManager.Init(chip::kTestDeviceNodeId, &chip::gSystemLayer, &chip::gTransportManager, &admins);
     NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
 
-    err = chip::gExchangeManager.Init(chip::kTestDeviceNodeId, &chip::gTransportManager, &chip::gSessionManager);
+    err = chip::gExchangeManager.Init(&chip::gSessionManager);
     NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
 }
 
@@ -160,12 +164,13 @@ void InitializeChip(nlTestSuite * apSuite)
 
 // clang-format off
 const nlTest sTests[] =
-        {
-                NL_TEST_DEF("CheckReadClient", chip::app::TestReadInteraction::TestReadClient),
-                NL_TEST_DEF("CheckReadHandler", chip::app::TestReadInteraction::TestReadHandler),
-                NL_TEST_SENTINEL()
-        };
+{
+    NL_TEST_DEF("CheckReadClient", chip::app::TestReadInteraction::TestReadClient),
+    NL_TEST_DEF("CheckReadHandler", chip::app::TestReadInteraction::TestReadHandler),
+    NL_TEST_SENTINEL()
+};
 // clang-format on
+
 } // namespace
 
 int TestEventLogging()
index 5a7d5cb..53035af 100644 (file)
 #include <app/CommandSender.h>
 #include <app/InteractionModelEngine.h>
 #include <app/tests/integration/common.h>
+#include <chrono>
+#include <condition_variable>
 #include <core/CHIPCore.h>
+#include <mutex>
 #include <platform/CHIPDeviceLayer.h>
 
 #include <support/ErrorStr.h>
 
 namespace {
 // Max value for the number of message request sent.
-constexpr size_t kMaxCommandMessageCount = 3;
-constexpr size_t kMaxReadMessageCount    = 0;
-
-// The CHIP Message interval time in milliseconds.
-constexpr int32_t gMessageInterval = 1000;
-
+constexpr size_t kMaxCommandMessageCount    = 3;
+constexpr size_t kMaxReadMessageCount       = 0;
+constexpr int32_t gMessageIntervalSeconds   = 1;
 constexpr chip::Transport::AdminId gAdminId = 0;
 
 // The CommandSender object.
@@ -64,14 +64,6 @@ chip::Inet::IPAddress gDestAddr;
 // The last time a CHIP Command was attempted to be sent.
 uint64_t gLastMessageTime = 0;
 
-// True, if the CommandSender is waiting for an CommandResponse
-// after sending an CommandRequest, false otherwise.
-bool gWaitingForCommandResp = false;
-
-// True, if the ReadClient is waiting for an Report Data
-// after sending an ReadRequest, false otherwise.
-bool gWaitingForReadResp = false;
-
 // Count of the number of CommandRequests sent.
 uint64_t gCommandCount = 0;
 
@@ -84,12 +76,7 @@ uint64_t gReadCount = 0;
 // Count of the number of CommandResponses received.
 uint64_t gReadRespCount = 0;
 
-bool MessageIntervalExpired(void)
-{
-    uint64_t now = chip::System::Timer::GetCurrentEpoch();
-
-    return (now >= gLastMessageTime + gMessageInterval);
-}
+std::condition_variable gCond;
 
 CHIP_ERROR SendCommandRequest(void)
 {
@@ -137,7 +124,6 @@ CHIP_ERROR SendCommandRequest(void)
 
     if (err == CHIP_NO_ERROR)
     {
-        gWaitingForCommandResp = true;
         gCommandCount++;
     }
     else
@@ -161,7 +147,6 @@ CHIP_ERROR SendReadRequest(void)
 
     if (err == CHIP_NO_ERROR)
     {
-        gWaitingForReadResp = true;
         gReadCount++;
     }
     else
@@ -204,11 +189,12 @@ void HandleReadComplete()
     uint32_t respTime    = chip::System::Timer::GetCurrentEpoch();
     uint32_t transitTime = respTime - gLastMessageTime;
 
-    gWaitingForReadResp = false;
     gReadRespCount++;
 
     printf("Read Response: %" PRIu64 "/%" PRIu64 "(%.2f%%) time=%.3fms\n", gReadRespCount, gReadCount,
            static_cast<double>(gReadRespCount) * 100 / gReadCount, static_cast<double>(transitTime) / 1000);
+
+    gCond.notify_one();
 }
 
 class MockInteractionModelApp : public chip::app::InteractionModelDelegate
@@ -229,6 +215,29 @@ public:
         printf("ReportError with err %d", aError);
         return CHIP_NO_ERROR;
     }
+    CHIP_ERROR CommandResponseStatus(const chip::app::CommandSender * apCommandSender,
+                                     const chip::Protocols::SecureChannel::GeneralStatusCode aGeneralCode,
+                                     const uint32_t aProtocolId, const uint16_t aProtocolCode, const chip::EndpointId aEndpointId,
+                                     const chip::ClusterId aClusterId, const chip::CommandId aCommandId,
+                                     uint8_t aCommandIndex) override
+    {
+        printf("CommandResponseStatus with GeneralCode %d, ProtocolId %d, ProtocolCode %d, EndpointId %d, ClusterId %d, CommandId "
+               "%d, CommandIndex %d",
+               static_cast<uint16_t>(aGeneralCode), aProtocolId, aProtocolCode, aEndpointId, aClusterId, aCommandId, aCommandIndex);
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR CommandResponseProtocolError(const chip::app::CommandSender * apCommandSender, uint8_t aCommandIndex) override
+    {
+        printf("CommandResponseProtocolError happens with CommandIndex %d", aCommandIndex);
+        return CHIP_NO_ERROR;
+    }
+
+    CHIP_ERROR CommandResponseTimeout(const chip::app::CommandSender * apCommandSender) override
+    {
+        printf("CommandResponseTimeout happens");
+        return CHIP_NO_ERROR;
+    }
 };
 
 } // namespace
@@ -251,11 +260,12 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC
     {
         chip::TLV::Debug::Dump(aReader, TLVPrettyPrinter);
     }
-    gWaitingForCommandResp = false;
     gCommandRespCount++;
 
     printf("Command Response: %" PRIu64 "/%" PRIu64 "(%.2f%%) time=%.3fms\n", gCommandRespCount, gCommandCount,
            static_cast<double>(gCommandRespCount) * 100 / gCommandCount, static_cast<double>(transitTime) / 1000);
+
+    gCond.notify_one();
 }
 } // namespace app
 } // namespace chip
@@ -263,6 +273,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC
 int main(int argc, char * argv[])
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
+
+    std::mutex mutex;
+    std::unique_lock<std::mutex> lock(mutex);
     MockInteractionModelApp mockDelegate;
     chip::Transport::AdminPairingTable admins;
     chip::Transport::AdminPairingInfo * adminInfo = admins.AssignAdminId(gAdminId, chip::kTestControllerNodeId);
@@ -282,6 +295,8 @@ int main(int argc, char * argv[])
 
     InitializeChip();
 
+    chip::DeviceLayer::PlatformMgr().StartEventLoopTask();
+
     err = gTransportManager.Init(chip::Transport::UdpListenParameters(&chip::DeviceLayer::InetLayer)
                                      .SetAddressType(chip::Inet::kIPAddressType_IPv4)
                                      .SetListenPort(IM_CLIENT_PORT));
@@ -290,7 +305,7 @@ int main(int argc, char * argv[])
     err = gSessionManager.Init(chip::kTestControllerNodeId, &chip::DeviceLayer::SystemLayer, &gTransportManager, &admins);
     SuccessOrExit(err);
 
-    err = gExchangeManager.Init(chip::kTestControllerNodeId, &gTransportManager, &gSessionManager);
+    err = gExchangeManager.Init(&gSessionManager);
     SuccessOrExit(err);
 
     err = chip::app::InteractionModelEngine::GetInstance()->Init(&gExchangeManager, &mockDelegate);
@@ -316,17 +331,9 @@ int main(int argc, char * argv[])
             goto exit;
         }
 
-        // Wait for response until the Message interval.
-        while (!MessageIntervalExpired())
-        {
-            DriveIO();
-        }
-
-        // Check if expected response was received.
-        if (gWaitingForCommandResp)
+        if (gCond.wait_for(lock, std::chrono::seconds(gMessageIntervalSeconds)) == std::cv_status::timeout)
         {
             printf("Invoke Command: No response received\n");
-            gWaitingForCommandResp = false;
         }
     }
 
@@ -340,17 +347,9 @@ int main(int argc, char * argv[])
             goto exit;
         }
 
-        // Wait for response until the Message interval.
-        while (!MessageIntervalExpired())
-        {
-            DriveIO();
-        }
-
-        // Check if expected response was received.
-        if (gWaitingForReadResp)
+        if (gCond.wait_for(lock, std::chrono::seconds(gMessageIntervalSeconds)) == std::cv_status::timeout)
         {
             printf("read request: No response received\n");
-            gWaitingForReadResp = false;
         }
     }
 
index 55a546c..666a1d2 100644 (file)
@@ -122,7 +122,7 @@ int main(int argc, char * argv[])
     err = gSessionManager.Init(chip::kTestDeviceNodeId, &chip::DeviceLayer::SystemLayer, &gTransportManager, &admins);
     SuccessOrExit(err);
 
-    err = gExchangeManager.Init(chip::kTestDeviceNodeId, &gTransportManager, &gSessionManager);
+    err = gExchangeManager.Init(&gSessionManager);
     SuccessOrExit(err);
 
     err = chip::app::InteractionModelEngine::GetInstance()->Init(&gExchangeManager, nullptr);
index 1182e76..cd1aa56 100644 (file)
@@ -58,45 +58,7 @@ exit:
 void ShutdownChip(void)
 {
     gExchangeManager.Shutdown();
-    chip::DeviceLayer::SystemLayer.Shutdown();
-}
-
-void DriveIO(void)
-{
-    struct timeval sleepTime;
-    fd_set readFDs, writeFDs, exceptFDs;
-    int numFDs = 0;
-    int selectRes;
-
-    sleepTime.tv_sec  = 0;
-    sleepTime.tv_usec = NETWORK_SLEEP_TIME_MSECS;
-
-    FD_ZERO(&readFDs);
-    FD_ZERO(&writeFDs);
-    FD_ZERO(&exceptFDs);
-
-    if (chip::DeviceLayer::SystemLayer.State() == chip::System::kLayerState_Initialized)
-        chip::DeviceLayer::SystemLayer.PrepareSelect(numFDs, &readFDs, &writeFDs, &exceptFDs, sleepTime);
-
-    if (chip::DeviceLayer::InetLayer.State == chip::Inet::InetLayer::kState_Initialized)
-        chip::DeviceLayer::InetLayer.PrepareSelect(numFDs, &readFDs, &writeFDs, &exceptFDs, sleepTime);
-
-    selectRes = select(numFDs, &readFDs, &writeFDs, &exceptFDs, &sleepTime);
-    if (selectRes < 0)
-    {
-        printf("select failed: %s\n", chip::ErrorStr(chip::System::MapErrorPOSIX(errno)));
-        return;
-    }
-
-    if (chip::DeviceLayer::SystemLayer.State() == chip::System::kLayerState_Initialized)
-    {
-        chip::DeviceLayer::SystemLayer.HandleSelectResult(selectRes, &readFDs, &writeFDs, &exceptFDs);
-    }
-
-    if (chip::DeviceLayer::InetLayer.State == chip::Inet::InetLayer::kState_Initialized)
-    {
-        chip::DeviceLayer::InetLayer.HandleSelectResult(selectRes, &readFDs, &writeFDs, &exceptFDs);
-    }
+    chip::DeviceLayer::PlatformMgr().Shutdown();
 }
 
 void TLVPrettyPrinter(const char * aFormat, ...)
index 4c64805..e3646db 100644 (file)
@@ -39,5 +39,4 @@ constexpr chip::GroupId kTestGroupId       = 0;
 
 void InitializeChip(void);
 void ShutdownChip(void);
-void DriveIO(void);
 void TLVPrettyPrinter(const char * aFormat, ...);
index dfb9b67..af783a3 100644 (file)
@@ -68,6 +68,7 @@ private:
         if (CHIP_NO_ERROR == err)
         {
             ca->Cancel();
+            queue.Dequeue(ca);
         }
 
         return err;
index 9449af5..ee5abe1 100644 (file)
@@ -37,4 +37,5 @@ typedef uint8_t CommandId;
 typedef uint16_t EventId;
 typedef uint64_t EventNumber;
 typedef uint64_t DataVersion;
+typedef uint32_t DeviceTypeId;
 } // namespace chip
index 812d1db..788b79e 100644 (file)
             "output": "src/app/encoder.cpp"
         },
         {
-            "path": "templates/chip/python-ChipDeviceController-ClusterCommands.zapt",
-            "name": "CHIP ZCL API for CPython",
-            "output": "src/controller/python/ChipDeviceController-ClusterCommands.cpp"
+            "path": "templates/chip/python-CHIPClusters-cpp.zapt",
+            "name": "CHIP ZCL API for Python (native code)",
+            "output": "src/controller/python/chip/clusters/CHIPClusters.cpp"
         },
         {
-            "path": "templates/chip/python-chip-ChipCluster.zapt",
+            "path": "templates/chip/python-CHIPClusters-py.zapt",
             "name": "CHIP ZCL API for Python",
-            "output": "src/controller/python/chip/ChipCluster.py"
+            "output": "src/controller/python/chip/clusters/CHIPClusters.py"
         }
     ]
 }
index fdeaf09..2c45056 100644 (file)
@@ -26,6 +26,8 @@ function asBasicType(type)
   case 'chip::EventId':
   case 'chip::GroupId':
     return 'uint16_t';
+  case 'chip::DeviceTypeId':
+    return 'uint32_t';
   case 'chip::NodeId':
     return 'uint64_t';
   default:
index f2cefdf..cfa36dc 100644 (file)
@@ -28,6 +28,8 @@ function atomicType(arg)
     return 'chip::AttributeId';
   case 'cluster_id':
     return 'chip::ClusterId';
+  case 'device_type_id':
+    return 'chip::DeviceTypeId';
   case 'ieee_address':
     return 'uint64_t';
   default:
index f5e9e7b..c430ae2 100644 (file)
@@ -19,7 +19,7 @@ namespace Controller {
 {{#chip_server_cluster_commands}}
 CHIP_ERROR {{asCamelCased clusterName false}}Cluster::{{asCamelCased name false}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback{{#chip_server_cluster_command_arguments}}, {{chipType}} {{asCamelCased label}}{{/chip_server_cluster_command_arguments}})
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
 (void) onFailureCallback;
@@ -38,11 +38,7 @@ CHIP_ERROR {{asCamelCased clusterName false}}Cluster::{{asCamelCased name false}
     uint8_t argSeqNumber = 0;
 {{/first}}
     // {{asCamelCased label}}: {{asCamelCased type}}
-{{#if (isCharString type)}}
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), {{asCamelCased label}}));
-{{else}}
     ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), {{asCamelCased label}}));
-{{/if}}
 {{else}}
     // Command takes no arguments.
 {{/chip_server_cluster_command_arguments}}
@@ -16,19 +16,31 @@ extern "C" {
 
 {{#chip_server_clusters}}
 // Cluster {{asCamelCased name false}}
+
 {{#chip_server_cluster_commands}}
 CHIP_ERROR chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId{{#chip_server_cluster_command_arguments}}, {{#if (isString type)}}const uint8_t * {{asCamelCased label}}, uint32_t {{asCamelCased label}}_Len{{else}}{{chipType}} {{asCamelCased label}}{{/if}}{{/chip_server_cluster_command_arguments}})
 {
     VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::{{asCamelCased clusterName false}}Cluster cluster{{asCamelCased clusterName false}};
+    chip::Controller::{{asCamelCased clusterName false}}Cluster cluster;
     (void) ZCLgroupId;
-    cluster{{asCamelCased clusterName false}}.Associate(device, ZCLendpointId);
-    return cluster{{asCamelCased clusterName false}}.{{asCamelCased name false}}(nullptr, nullptr{{#chip_server_cluster_command_arguments}}, {{#if (isString type)}}chip::ByteSpan({{asCamelCased label}}, {{asCamelCased label}}_Len){{else}}{{asCamelCased label}}{{/if}}
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.{{asCamelCased name false}}(nullptr, nullptr{{#chip_server_cluster_command_arguments}}, {{#if (isString type)}}chip::ByteSpan({{asCamelCased label}}, {{asCamelCased label}}_Len){{else}}{{asCamelCased label}}{{/if}}
     {{/chip_server_cluster_command_arguments}});
 }
 {{/chip_server_cluster_commands}}
-// End of Cluster {{asCamelCased name false}}
 
+{{#chip_server_cluster_attributes}}
+CHIP_ERROR chip_ime_ReadAttribute_{{asCamelCased parent.name false}}_{{asCamelCased name false}}(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::{{asCamelCased parent.name false}}Cluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttribute{{asCamelCased name false}}(nullptr, nullptr);
+}
+{{/chip_server_cluster_attributes}}
+
+// End of Cluster {{asCamelCased name false}}
 {{/chip_server_clusters}}
 
 }
@@ -3,20 +3,20 @@
 '''
 
 import ctypes
-from .ChipStack import *
-from .exceptions import *
+from chip.ChipStack import *
+from chip.exceptions import *
 
 '''
 TODO(#4511): This file only sends cluster commands, should add more functions.
 '''
 
-__all__ = ["ChipCluster"]
+__all__ = ["ChipClusters"]
 
-class ChipCluster:
+class ChipClusters:
     def __init__(self, chipstack):
         self._ChipStack = chipstack
 
-    def ListClusters(self):
+    def ListClusterCommands(self):
         return {
 {{#chip_server_clusters}}
             "{{asCamelCased name false}}": {
@@ -31,12 +31,31 @@ class ChipCluster:
 {{/chip_server_clusters}}
         }
 
+    def ListClusterAttributes(self):
+        return {
+{{#chip_server_clusters}}
+            "{{asCamelCased name false}}": [
+{{#chip_server_cluster_attributes}}
+                "{{asCamelCased name false}}",
+{{/chip_server_cluster_attributes}}
+            ],
+{{/chip_server_clusters}}
+        }
+
     def SendCommand(self, device: ctypes.c_void_p, cluster: str, command: str, endpoint: int, groupid: int, args):
         func = getattr(self, "Cluster{}_Command{}".format(cluster, command), None)
         if not func:
             raise UnknownCommand(cluster, command)
         func(device, endpoint, groupid, **args)
 
+    def ReadAttribute(self, device: ctypes.c_void_p, cluster: str, attribute: str, endpoint: int, groupid: int):
+        func = getattr(self, "Cluster{}_ReadAttribute{}".format(cluster, attribute), None)
+        if not func:
+            raise UnknownAttribute(cluster, attribute)
+        func(device, endpoint, groupid)
+
+    # Cluster commands
+
 {{#chip_server_clusters}}
 {{#chip_server_cluster_commands}}
     def Cluster{{asCamelCased clusterName false}}_Command{{asCamelCased name false}}(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int{{#chip_server_cluster_command_arguments}}, {{asCamelCased label}}: {{asPythonType chipType}}{{/chip_server_cluster_command_arguments}}):
@@ -50,9 +69,22 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid{{#chip_server_cluster_command_arguments}}, {{asCamelCased label}}{{#if (isString type)}}, len({{asCamelCased label}}){{/if}}{{/chip_server_cluster_command_arguments}}
             )
         )
-
 {{/chip_server_cluster_commands}}
 {{/chip_server_clusters}}
+
+    # Cluster attributes
+
+{{#chip_server_clusters}}
+{{#chip_server_cluster_attributes}}
+    def Cluster{{asCamelCased parent.name false}}_ReadAttribute{{asCamelCased name false}}(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_{{asCamelCased parent.name false}}_{{asCamelCased name false}}(device, ZCLendpoint, ZCLgroupid)
+        )
+{{/chip_server_cluster_attributes}}
+{{/chip_server_clusters}}
+
+    # Init native functions
+
     def InitLib(self, chipLib):
         self._chipLib = chipLib
 {{#chip_server_clusters}}
@@ -62,4 +94,9 @@ class ChipCluster:
         self._chipLib.chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16{{#chip_server_cluster_command_arguments}}{{#if (isString type)}}, ctypes.c_char_p, ctypes.c_uint32{{else}}, ctypes.{{asPythonCType chipType}}{{/if}}{{/chip_server_cluster_command_arguments}}]
         self._chipLib.chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}.restype = ctypes.c_uint32
 {{/chip_server_cluster_commands}}
+{{#chip_server_cluster_attributes}}
+        # Cluster {{asCamelCased parent.name false}} ReadAttribute {{asCamelCased name false}}
+        self._chipLib.chip_ime_ReadAttribute_{{asCamelCased parent.name false}}_{{asCamelCased name false}}.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_{{asCamelCased parent.name false}}_{{asCamelCased name false}}.restype = ctypes.c_uint32
+{{/chip_server_cluster_attributes}}
 {{/chip_server_clusters}}
diff --git a/src/app/zap-templates/zcl/account-login-cluster.xml b/src/app/zap-templates/zcl/account-login-cluster.xml
new file mode 100644 (file)
index 0000000..c668d5d
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>Account Login</name>
+    <code>0x050e</code>
+    <define>ACCOUNT_LOGIN_CLUSTER</define>
+    <client init="false" tick="false">true</client>
+    <server init="false" tick="false">true</server>
+    <description>This cluster provides commands that facilitate user account login on a Content App or a node. For example, a Content App running on a Video Player device, which is represented as an endpoint (see [TV Architecture]), can use this cluster to help make the user account on the Content App match the user account on the Client.</description>
+
+    <command source="client" code="0x00" name="GetSetupPIN" optional="false">
+      <description>Upon receipt, the Content App checks if the account associated with the client Temp Account Identifier Rotating ID is the same acount that is active on the given Content App. If the accounts are the same, then the Content App includes the Setup PIN in the GetSetupPIN Response.</description>
+      <arg name="tempAccountIdentifier" type="CHAR_STRING"/>
+    </command>
+
+    <command source="client" code="0x01" name="Login" optional="false">
+      <description>Upon receipt, the Content App checks if the account associated with the client’s Temp Account Identifier (Rotating ID) has a current active Setup PIN with the given value. If the Setup PIN is valid for the user account associated with the Temp Account Identifier, then the Content App MAY make that user account active.</description>
+      <arg name="tempAccountIdentifier" type="CHAR_STRING"/>
+      <arg name="setupPIN" type="CHAR_STRING"/>
+    </command>
+
+    <command source="server" code="0x00" name="GetSetupPINResponse" optional="false" disableDefaultResponse="true">
+      <description>This message is sent in response to the GetSetupPIN Request, and contains the Setup PIN code, or null when the accounts identified in the request does not match the active account of the running Content App.</description>
+      <arg name="setupPIN" type="CHAR_STRING"/>
+    </command>
+
+  </cluster>
+</configurator>
diff --git a/src/app/zap-templates/zcl/application-launcher-cluster.xml b/src/app/zap-templates/zcl/application-launcher-cluster.xml
new file mode 100644 (file)
index 0000000..f0851f5
--- /dev/null
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>Application Launcher</name>
+    <code>0x050c</code>
+    <define>APPLICATION_LAUNCHER_CLUSTER</define>
+    <client init="false" tick="false">true</client>
+    <server init="false" tick="false">true</server>
+    <description>This cluster provides an interface for launching content on a media player device such as a TV or Speaker.</description>
+
+    <attribute side="server" code="0x0000" define="APPLICATION_LAUNCHER_LIST" type="OCTET_STRING" length="32" writable="false" optional="false">application launcher list</attribute>
+    <attribute side="server" code="0x0001" define="APPLICATION_LAUNCHER_CURRENT_APP" type="INT8U" min="0x00" max="0xFF" writable="false" default="0x00" optional="true">current app</attribute>
+
+    <command source="client" code="0x00" name="LaunchApp" optional="false">
+      <description>Upon receipt, this SHALL launch the specified app with optional data. The TV Device SHALL launch and bring to foreground the identified application in the command if the application is not already launched and in foreground. The TV Device SHALL update state attribute on the Application Basic cluster of the Endpoint corresponding to the launched application. This command returns a Launch Response.</description>
+      <arg name="application" type="ApplicationLauncherApp" array="true"/>
+      <arg name="data" type="CHAR_STRING"/>
+    </command>
+
+    <command source="server" code="0x00" name="LaunchAppResponse" optional="false">
+      <description>This command SHALL be generated in response to LaunchApp commands.</description>
+      <arg name="status" type="ApplicationLauncherStatus"/>
+      <arg name="data" type="CHAR_STRING"/>
+    </command>
+
+  </cluster>
+      
+  <struct name="ApplicationLauncherApp">
+    <item name="catalogVendorId" type="INT16U"/>
+    <item name="applicationId" type="CHAR_STRING"/>
+  </struct>
+
+  <enum name="ApplicationLauncherStatus" type="ENUM8">
+    <item name="Success" value="0x00"/>
+    <item name="AppNotAvailable" value="0x01"/>
+    <item name="SystemBusy" value="0x02"/>
+  </enum>
+</configurator>
diff --git a/src/app/zap-templates/zcl/audio-output-cluster.xml b/src/app/zap-templates/zcl/audio-output-cluster.xml
new file mode 100644 (file)
index 0000000..2bd8412
--- /dev/null
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>Audio Output</name>
+    <code>0x050b</code>
+    <define>AUDIO_OUTPUT_CLUSTER</define>
+    <client init="false" tick="false">true</client>
+    <server init="false" tick="false">true</server>
+    <description>This cluster provides an interface for controlling the Output on a media device such as a TV.</description>
+    <attribute side="server" code="0x0000" define="AUDIO_OUTPUT_LIST" type="OCTET_STRING" length="32" writable="false" optional="false">audio output list</attribute>
+    <attribute side="server" code="0x0001" define="AUDIO_OUTPUT_CURRENT_OUTPUT" type="INT8U" min="0x00" max="0xFF" writable="false" default="0x00" optional="true">current audio output</attribute>
+
+    <command source="client" code="0x00" name="SelectOutput" optional="false">
+      <description>Upon receipt, this SHALL change the output on the media device to the output at a specific index in the Output List.</description>
+      <arg name="index" type="INT8U"/>
+    </command>
+
+    <command source="client" code="0x01" name="RenameOutput" optional="false">
+      <description>Upon receipt, this SHALL rename the output at a specific index in the Output List. Updates to the output name SHALL appear in the TV settings menus.</description>
+      <arg name="index" type="INT8U"/>
+      <arg name="name" type="CHAR_STRING"/>
+    </command>
+
+  </cluster>
+
+  <struct name="AudioOutputInfo">
+    <item name="Index" type="INT8U"/>
+    <item name="OutputType" type="AudioOutputType"/>
+    <item name="Name" type="CHAR_STRING"/>
+  </struct>
+
+  <enum name="AudioOutputType" type="ENUM8">
+    <item name="Hdmi" value="0x00"/>
+    <item name="Bt" value="0x01"/>
+    <item name="Optical" value="0x02"/>
+    <item name="Headphone" value="0x03"/>
+    <item name="Internal" value="0x04"/>
+    <item name="Other" value="0x05"/>
+  </enum>
+
+</configurator>
\ No newline at end of file
index 6f505e4..e073607 100644 (file)
@@ -81,11 +81,4 @@ limitations under the License.
     <item name="SportsTeam" value="0x009"/>
     <item name="Video" value="0x0A"/>
   </enum>
-
-  <enum name="MediaPlaybackStatus" type="ENUM8">
-    <item name="Success" value="0x00"/>
-    <item name="InvalidStateForCommand" value="0x01"/>
-    <item name="NotAllowed" value="0x02"/>
-    <item name="NotActive" value="0x03"/>
-  </enum>
 </configurator>
index b95f2e2..2d21d87 100644 (file)
@@ -20,6 +20,7 @@ limitations under the License.
     <type id="0xF3" name="group_id" size="2" description="Group Id" discrete="true" />
     <type id="0xF4" name="command_id" size="1" description="Command Id" discrete="true" />
     <type id="0xF5" name="node_id" size="8" description="Node Id" discrete="true" />
+    <type id="0xF6" name="device_type_id" size="4" description="Device Type Id" discrete="true" />
   </atomic>
   <enum name="GroupKeySecurityPolicy" type="ENUM8">
     <item name="Standard" value="0x00"/>
@@ -37,4 +38,8 @@ limitations under the License.
     <item name="GroupKeyEpochStartTime" type="INT64U"/>
     <item name="GroupKeySecurityPolicy" type="GroupKeySecurityPolicy"/>    
   </struct>
+   <struct name="DeviceType">
+     <item name="type" type="DEVICE_TYPE_ID"/>
+     <item name="revision" type="INT16U"/>
+   </struct>
 </configurator>
diff --git a/src/app/zap-templates/zcl/descriptor-cluster.xml b/src/app/zap-templates/zcl/descriptor-cluster.xml
new file mode 100644 (file)
index 0000000..dd0a1a9
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>Descriptor</name>
+    <code>0x001d</code>
+    <define>DESCRIPTOR_CLUSTER</define>
+    <description>The Descriptor Cluster is meant to replace the support from the Zigbee Device Object (ZDO) for describing a node, its endpoints and clusters.</description>
+    <attribute side="server" code="0x0000" define="DEVICE_LIST" type="ARRAY" entryType="DeviceType" length="254" writable="false" optional="false">device list</attribute>
+    <attribute side="server" code="0x0001" define="SERVER_LIST" type="ARRAY" entryType="CLUSTER_ID" length="254" writable="false" optional="false">server list</attribute>
+    <attribute side="server" code="0x0002" define="CLIENT_LIST" type="ARRAY" entryType="CLUSTER_ID" length="254" writable="false" optional="false">client list</attribute>
+    <attribute side="server" code="0x0003" define="PARTS_LIST" type="ARRAY" entryType="ENDPOINT_ID" length="254" writable="false" optional="false">parts list</attribute>
+  </cluster>
+</configurator>
diff --git a/src/app/zap-templates/zcl/keypad-input-cluster.xml b/src/app/zap-templates/zcl/keypad-input-cluster.xml
new file mode 100644 (file)
index 0000000..49b56d3
--- /dev/null
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>Keypad Input</name>
+    <code>0x0509</code>
+    <define>KEYPAD_INPUT_CLUSTER</define>
+    <client init="false" tick="false">true</client>
+    <server init="false" tick="false">true</server>
+    <description>This cluster provides an interface for controlling a device like a TV using action commands such as UP, DOWN, and SELECT.</description>
+
+    <command source="client" code="0x00" name="SendKey" optional="false">
+      <description>Upon receipt, this SHALL process a keycode as input to the media device.</description>
+      <arg name="keyCode" type="INT8U"/>
+    </command>
+
+    <command source="server" code="0x00" name="SendKeyResponse" optional="false">
+      <description>This command SHALL be generated in response to a SendKey Request command.</description>
+      <arg name="status" type="KeypadInputStatus"/>
+    </command>
+
+  </cluster>
+
+  <enum name="KeypadInputStatus" type="ENUM8">
+    <item name="Success" value="0x00"/>
+    <item name="UnsupportedKey" value="0x01"/>
+    <item name="InvalidKeyInCurrentState" value="0x02"/>
+  </enum>
+</configurator>
diff --git a/src/app/zap-templates/zcl/media-input-cluster.xml b/src/app/zap-templates/zcl/media-input-cluster.xml
new file mode 100644 (file)
index 0000000..0070bbf
--- /dev/null
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>Media Input</name>
+    <code>0x0507</code>
+    <define>MEDIA_INPUT_CLUSTER</define>
+    <client init="false" tick="false">true</client>
+    <server init="false" tick="false">true</server>
+    <description>This cluster provides an interface for controlling the Input Selector on a media device such as a TV.</description>
+    <attribute side="server" code="0x0000" define="MEDIA_INPUT_LIST" type="OCTET_STRING" length="32" writable="false" optional="false">media input list</attribute>
+    <attribute side="server" code="0x0001" define="MEDIA_INPUT_CURRENT_INPUT" type="INT8U" min="0x00" max="0xFF" writable="false" default="0x00" optional="true">current media input</attribute>
+
+    <command source="client" code="0x00" name="SelectInput" optional="false">
+      <description>Upon receipt, this SHALL change the input on the media device to the input at a specific index in the Input List.</description>
+      <arg name="index" type="INT8U"/>
+    </command>
+
+    <command source="client" code="0x01" name="ShowInputStatus" optional="false">
+      <description>Upon receipt, this SHALL display the active status of the input list on screen.</description>
+    </command>
+
+    <command source="client" code="0x02" name="HideInputStatus" optional="false">
+      <description>Upon receipt, this SHALL hide the input list from the screen.</description>
+    </command>
+
+    <command source="client" code="0x03" name="RenameInput" optional="false">
+      <description>Upon receipt, this SHALL rename the input at a specific index in the Input List. Updates to the input name SHALL appear in the TV settings menus.    </description>
+      <arg name="index" type="INT8U"/>
+      <arg name="name" type="CHAR_STRING"/>
+    </command>
+
+  </cluster>
+
+  <struct name="MediaInputInfo">
+    <item name="Index" type="INT8U"/>
+    <item name="InputType" type="MediaInputType"/>
+    <item name="Name" type="CHAR_STRING"/>
+    <item name="Description" type="CHAR_STRING"/>
+  </struct>
+
+  <enum name="MediaInputType" type="ENUM8">
+    <item name="Internal" value="0x00"/>
+    <item name="Aux" value="0x01"/>
+    <item name="Coax" value="0x02"/>
+    <item name="Composite" value="0x03"/>
+    <item name="Hdmi" value="0x04"/>
+    <item name="Input" value="0x05"/>
+    <item name="Line" value="0x06"/>
+    <item name="Optical" value="0x07"/>
+    <item name="Video" value="0x08"/>
+    <item name="Scart" value="0x09"/>
+    <item name="Usb" value="0x0A"/>
+    <item name="Other" value="0x0B"/>
+  </enum>
+
+</configurator>
\ No newline at end of file
diff --git a/src/app/zap-templates/zcl/target-navigator-cluster.xml b/src/app/zap-templates/zcl/target-navigator-cluster.xml
new file mode 100644 (file)
index 0000000..4c084df
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>Target Navigator</name>
+    <code>0x0505</code>
+    <define>TARGET_NAVIGATOR_CLUSTER</define>
+    <client init="false" tick="false">true</client>
+    <server init="false" tick="false">true</server>
+    <description>This cluster provides an interface for UX navigation within a set of targets on a device or endpoint.</description>
+
+    <attribute side="server" code="0x0000" define="TARGET_NAVIGATOR_LIST" type="OCTET_STRING" length="32" writable="false" optional="false">target navigator list</attribute>
+    <attribute side="server" code="0x0001" define="TARGET_NAVIGATOR_CURRENT_TARGET" type="INT8U" min="0x00" max="0xFF" writable="false" default="0x00" optional="true">current navigator target</attribute>
+
+    <command source="client" code="0x00" name="NavigateTarget" optional="false">
+      <description>Upon receipt, this SHALL navigation the UX to the target identified.</description>
+      <arg name="target" type="INT8U"/>
+      <arg name="data" type="CHAR_STRING"/>
+    </command>
+
+    <command source="server" code="0x00" name="NavigateTargetResponse" optional="false">
+      <description>This command SHALL be generated in response to NavigateTarget commands.</description>
+      <arg name="status" type="NavigateTargetStatus"/>
+      <arg name="data" type="CHAR_STRING"/>
+    </command>
+  </cluster>
+  
+  <enum name="NavigateTargetStatus" type="ENUM8">
+      <item name="Success" value="0x00"/>
+      <item name="AppNotAvailable" value="0x01"/>
+      <item name="SystemBusy" value="0x02"/>
+  </enum>
+
+  <struct name="NavigateTargetTargetInfo">
+      <item name="identifier" type="INT8U"/>
+      <item name="name" type="CHAR_STRING"/>
+  </struct>
+</configurator>
diff --git a/src/app/zap-templates/zcl/tv-channel-cluster.xml b/src/app/zap-templates/zcl/tv-channel-cluster.xml
new file mode 100644 (file)
index 0000000..380f322
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>TV Channel</name>
+    <code>0x0504</code>
+    <define>TV_CHANNEL_CLUSTER</define>
+    <client init="false" tick="false">true</client>
+    <server init="false" tick="false">true</server>
+    <description>This cluster provides an interface for controlling the current TV Channel on a device.</description>
+    <attribute side="server" code="0x0000" define="TV_CHANNEL_LIST" type="OCTET_STRING" length="32" writable="false" optional="false">tv channel list</attribute>
+    <attribute side="server" code="0x0001" define="TV_CHANNEL_LINEUP" type="OCTET_STRING" length="32" writable="false" optional="false">tv channel lineup</attribute>
+    <attribute side="server" code="0x0002" define="TV_CHANNEL_CURRENT_CHANNEL" type="OCTET_STRING" length="32" writable="false" optional="false">current tv channel</attribute>
+
+    <command source="client" code="0x00" name="ChangeChannel" optional="false">
+      <description>Change the channel on the TV to the channel case-insensitive exact matching the value passed as an argument. </description>
+      <arg name="match" type="CHAR_STRING"/>
+    </command>
+
+
+    <command source="client" code="0x01" name="ChangeChannelByNumber" optional="false">
+      <description>Change the channel on the TV to the channel with the given Number in the ChannelList attribute.</description>
+      <arg name="majorNumber" type="INT16U"/>
+      <arg name="minorNumber" type="INT16U"/>
+    </command>
+
+    <command source="client" code="0x02" name="SkipChannel" optional="false">
+      <description>This command provides channel up and channel down functionality, but allows channel index jumps of size Count. When the value of the increase or decrease is larger than the number of channels remaining in the given direction, then the behavior SHALL be to return to the beginning (or end) of the channel list and continue. For example, if the current channel is at index 0 and count value of -1 is given, then the current channel should change to the last channel.</description>
+      <arg name="Count" type="INT16U"/>
+    </command>
+
+    <command source="server" code="0x00" name="ChangeChannelResponse" optional="false">
+      <description>Upon receipt, this SHALL display the active status of the input list on screen.</description>
+      <arg name="ChannelMatch" type="TvChannelInfo" array="true"/>
+      <arg name="ErrorType" type="TvChannelErrorType"/>
+    </command>
+
+  </cluster>
+
+  <struct name="TvChannelInfo">
+    <item name="MajorNumber" type="INT16U"/>
+    <item name="MinorNumber" type="INT16U"/>
+    <item name="Name" type="CHAR_STRING"/>
+    <item name="CallSign" type="CHAR_STRING"/>
+    <item name="AffiliateCallSign" type="CHAR_STRING"/>
+  </struct>
+
+  <struct name="TvChannelLineupInfo">
+    <item name="OperatorName" type="CHAR_STRING"/>
+    <item name="LineupName" type="CHAR_STRING"/>
+    <item name="PostalCode" type="CHAR_STRING"/>
+    <item name="LineupInfoType" type="TvChannelLineupInfoType"/>
+  </struct>
+
+  <enum name="TvChannelLineupInfoType" type="ENUM8">
+    <item name="Mso" value="0x00"/>
+  </enum>
+
+  <enum name="TvChannelErrorType" type="ENUM8">
+    <item name="MultipleMatches" value="0x00"/>
+    <item name="NoMatches" value="0x01"/>
+  </enum>
+
+</configurator>
\ No newline at end of file
diff --git a/src/app/zap-templates/zcl/wake-on-lan-cluster.xml b/src/app/zap-templates/zcl/wake-on-lan-cluster.xml
new file mode 100644 (file)
index 0000000..903799c
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<configurator>
+  <domain name="CHIP"/>
+  <cluster>
+    <domain>General</domain>
+    <name>Wake on LAN</name>
+    <code>0x0503</code>
+    <define>WAKE_ON_LAN_CLUSTER</define>
+    <client init="false" tick="false">true</client>
+    <server init="false" tick="false">true</server>
+    <description>This cluster provides an interface for managing low power mode on a device that supports the Wake On LAN protocol.</description>
+    <attribute side="server" code="0x0000" define="WAKE_ON_LAN_MAC_ADDRESS" type="CHAR_STRING" length="32" writable="false" optional="false">wake on lan mac address</attribute>
+  </cluster>
+</configurator>
\ No newline at end of file
index 4e97585..126bd3e 100644 (file)
@@ -2,14 +2,23 @@
     "version": "ZCL Test Data",
     "xmlRoot": [".", "./data-model/silabs/"],
     "xmlFile": [
+        "account-login-cluster.xml",
+        "application-launcher-cluster.xml",
+        "audio-output-cluster.xml",
         "application-basic-cluster.xml",
         "binding-cluster.xml",
         "clusters-extensions.xml",
         "content-launch-cluster.xml",
         "media-playback-cluster.xml",
         "low-power-cluster.xml",
+        "keypad-input-cluster.xml",
+        "wake-on-lan-cluster.xml",
+        "media-input-cluster.xml",
+        "tv-channel-cluster.xml",
+        "target-navigator-cluster.xml",
         "custom-types.xml",
         "chip-devices.xml",
+        "descriptor-cluster.xml",
         "types.xml",
         "general.xml",
         "general-commissioning-cluster.xml",
index 1293e14..2ad72b5 100644 (file)
@@ -47,13 +47,7 @@ struct ChipBLEDeviceIdentificationInfo
 {
     constexpr static uint16_t kDiscriminatorMask = 0xfff;
 
-    enum
-    {
-        kPairingStatus_Unpaired = 0,
-        kPairingStatus_Paired   = 1,
-    };
-
-    uint8_t PairingStatus;
+    uint8_t OpCode;
     uint8_t DeviceDiscriminator[2];
     uint8_t DeviceVendorId[2];
     uint8_t DeviceProductId[2];
index 88a835a..0f1293b 100644 (file)
@@ -13,7 +13,6 @@
 # limitations under the License.
 
 import("//build_overrides/chip.gni")
-import("${chip_root}/src/app/common_flags.gni")
 
 static_library("controller") {
   output_name = "libChipController"
@@ -47,8 +46,4 @@ static_library("controller") {
   ]
 
   defines = []
-
-  if (chip_app_use_interaction_model) {
-    defines += [ "CHIP_APP_USE_INTERACTION_MODEL" ]
-  }
 }
index a2bac1c..adb6a8d 100644 (file)
@@ -107,7 +107,7 @@ CHIP_ERROR ApplicationBasicCluster::ReadAttributeClusterRevision(Callback::Cance
 CHIP_ERROR BarrierControlCluster::BarrierControlGoToPercent(Callback::Cancelable * onSuccessCallback,
                                                             Callback::Cancelable * onFailureCallback, uint8_t percentOpen)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -141,7 +141,7 @@ CHIP_ERROR BarrierControlCluster::BarrierControlGoToPercent(Callback::Cancelable
 CHIP_ERROR BarrierControlCluster::BarrierControlStop(Callback::Cancelable * onSuccessCallback,
                                                      Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -220,7 +220,7 @@ CHIP_ERROR BarrierControlCluster::ReadAttributeClusterRevision(Callback::Cancela
 // Basic Cluster Commands
 CHIP_ERROR BasicCluster::MfgSpecificPing(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -366,7 +366,7 @@ CHIP_ERROR BasicCluster::ReadAttributeClusterRevision(Callback::Cancelable * onS
 CHIP_ERROR BindingCluster::Bind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                 chip::NodeId nodeId, chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -407,7 +407,7 @@ CHIP_ERROR BindingCluster::Unbind(Callback::Cancelable * onSuccessCallback, Call
                                   chip::NodeId nodeId, chip::GroupId groupId, chip::EndpointId endpointId,
                                   chip::ClusterId clusterId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -463,7 +463,7 @@ CHIP_ERROR BindingCluster::ReadAttributeClusterRevision(Callback::Cancelable * o
 CHIP_ERROR ColorControlCluster::MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                           int16_t rateX, int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -505,7 +505,7 @@ CHIP_ERROR ColorControlCluster::MoveColorTemperature(Callback::Cancelable * onSu
                                                      uint16_t colorTemperatureMinimum, uint16_t colorTemperatureMaximum,
                                                      uint8_t optionsMask, uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -549,7 +549,7 @@ CHIP_ERROR ColorControlCluster::MoveColorTemperature(Callback::Cancelable * onSu
 CHIP_ERROR ColorControlCluster::MoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                         uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -589,7 +589,7 @@ CHIP_ERROR ColorControlCluster::MoveHue(Callback::Cancelable * onSuccessCallback
 CHIP_ERROR ColorControlCluster::MoveSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -630,7 +630,7 @@ CHIP_ERROR ColorControlCluster::MoveToColor(Callback::Cancelable * onSuccessCall
                                             uint16_t colorX, uint16_t colorY, uint16_t transitionTime, uint8_t optionsMask,
                                             uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -673,7 +673,7 @@ CHIP_ERROR ColorControlCluster::MoveToColorTemperature(Callback::Cancelable * on
                                                        Callback::Cancelable * onFailureCallback, uint16_t colorTemperature,
                                                        uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -714,7 +714,7 @@ CHIP_ERROR ColorControlCluster::MoveToHue(Callback::Cancelable * onSuccessCallba
                                           uint8_t hue, uint8_t direction, uint16_t transitionTime, uint8_t optionsMask,
                                           uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -757,7 +757,7 @@ CHIP_ERROR ColorControlCluster::MoveToHueAndSaturation(Callback::Cancelable * on
                                                        Callback::Cancelable * onFailureCallback, uint8_t hue, uint8_t saturation,
                                                        uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -800,7 +800,7 @@ CHIP_ERROR ColorControlCluster::MoveToSaturation(Callback::Cancelable * onSucces
                                                  uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask,
                                                  uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -841,7 +841,7 @@ CHIP_ERROR ColorControlCluster::StepColor(Callback::Cancelable * onSuccessCallba
                                           int16_t stepX, int16_t stepY, uint16_t transitionTime, uint8_t optionsMask,
                                           uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -885,7 +885,7 @@ CHIP_ERROR ColorControlCluster::StepColorTemperature(Callback::Cancelable * onSu
                                                      uint16_t transitionTime, uint16_t colorTemperatureMinimum,
                                                      uint16_t colorTemperatureMaximum, uint8_t optionsMask, uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -933,7 +933,7 @@ CHIP_ERROR ColorControlCluster::StepHue(Callback::Cancelable * onSuccessCallback
                                         uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask,
                                         uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -976,7 +976,7 @@ CHIP_ERROR ColorControlCluster::StepSaturation(Callback::Cancelable * onSuccessC
                                                uint8_t stepMode, uint8_t stepSize, uint8_t transitionTime, uint8_t optionsMask,
                                                uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1018,7 +1018,7 @@ CHIP_ERROR ColorControlCluster::StepSaturation(Callback::Cancelable * onSuccessC
 CHIP_ERROR ColorControlCluster::StopMoveStep(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                              uint8_t optionsMask, uint8_t optionsOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1657,7 +1657,7 @@ CHIP_ERROR ColorControlCluster::ReadAttributeClusterRevision(Callback::Cancelabl
 // DoorLock Cluster Commands
 CHIP_ERROR DoorLockCluster::ClearAllPins(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1687,7 +1687,7 @@ CHIP_ERROR DoorLockCluster::ClearAllPins(Callback::Cancelable * onSuccessCallbac
 
 CHIP_ERROR DoorLockCluster::ClearAllRfids(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1718,7 +1718,7 @@ CHIP_ERROR DoorLockCluster::ClearAllRfids(Callback::Cancelable * onSuccessCallba
 CHIP_ERROR DoorLockCluster::ClearHolidaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                  uint8_t scheduleId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1751,7 +1751,7 @@ CHIP_ERROR DoorLockCluster::ClearHolidaySchedule(Callback::Cancelable * onSucces
 CHIP_ERROR DoorLockCluster::ClearPin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1784,7 +1784,7 @@ CHIP_ERROR DoorLockCluster::ClearPin(Callback::Cancelable * onSuccessCallback, C
 CHIP_ERROR DoorLockCluster::ClearRfid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1817,7 +1817,7 @@ CHIP_ERROR DoorLockCluster::ClearRfid(Callback::Cancelable * onSuccessCallback,
 CHIP_ERROR DoorLockCluster::ClearWeekdaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                  uint8_t scheduleId, uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1853,7 +1853,7 @@ CHIP_ERROR DoorLockCluster::ClearWeekdaySchedule(Callback::Cancelable * onSucces
 CHIP_ERROR DoorLockCluster::ClearYeardaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                  uint8_t scheduleId, uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1889,7 +1889,7 @@ CHIP_ERROR DoorLockCluster::ClearYeardaySchedule(Callback::Cancelable * onSucces
 CHIP_ERROR DoorLockCluster::GetHolidaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                uint8_t scheduleId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1922,7 +1922,7 @@ CHIP_ERROR DoorLockCluster::GetHolidaySchedule(Callback::Cancelable * onSuccessC
 CHIP_ERROR DoorLockCluster::GetLogRecord(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                          uint16_t logIndex)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1955,7 +1955,7 @@ CHIP_ERROR DoorLockCluster::GetLogRecord(Callback::Cancelable * onSuccessCallbac
 CHIP_ERROR DoorLockCluster::GetPin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                    uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -1988,7 +1988,7 @@ CHIP_ERROR DoorLockCluster::GetPin(Callback::Cancelable * onSuccessCallback, Cal
 CHIP_ERROR DoorLockCluster::GetRfid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                     uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2021,7 +2021,7 @@ CHIP_ERROR DoorLockCluster::GetRfid(Callback::Cancelable * onSuccessCallback, Ca
 CHIP_ERROR DoorLockCluster::GetUserType(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                         uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2054,7 +2054,7 @@ CHIP_ERROR DoorLockCluster::GetUserType(Callback::Cancelable * onSuccessCallback
 CHIP_ERROR DoorLockCluster::GetWeekdaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                uint8_t scheduleId, uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2090,7 +2090,7 @@ CHIP_ERROR DoorLockCluster::GetWeekdaySchedule(Callback::Cancelable * onSuccessC
 CHIP_ERROR DoorLockCluster::GetYeardaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                uint8_t scheduleId, uint16_t userId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2126,7 +2126,7 @@ CHIP_ERROR DoorLockCluster::GetYeardaySchedule(Callback::Cancelable * onSuccessC
 CHIP_ERROR DoorLockCluster::LockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      chip::ByteSpan pin)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2142,7 +2142,7 @@ CHIP_ERROR DoorLockCluster::LockDoor(Callback::Cancelable * onSuccessCallback, C
 
     uint8_t argSeqNumber = 0;
     // pin: charString
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), pin));
+    ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), pin));
 
     ReturnErrorOnFailure(writer.EndContainer(dummyType));
     ReturnErrorOnFailure(writer.Finalize());
@@ -2160,7 +2160,7 @@ CHIP_ERROR DoorLockCluster::SetHolidaySchedule(Callback::Cancelable * onSuccessC
                                                uint8_t scheduleId, uint32_t localStartTime, uint32_t localEndTime,
                                                uint8_t operatingModeDuringHoliday)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2200,7 +2200,7 @@ CHIP_ERROR DoorLockCluster::SetHolidaySchedule(Callback::Cancelable * onSuccessC
 CHIP_ERROR DoorLockCluster::SetPin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                    uint16_t userId, uint8_t userStatus, uint8_t userType, chip::ByteSpan pin)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2222,7 +2222,7 @@ CHIP_ERROR DoorLockCluster::SetPin(Callback::Cancelable * onSuccessCallback, Cal
     // userType: doorLockUserType
     ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userType));
     // pin: charString
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), pin));
+    ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), pin));
 
     ReturnErrorOnFailure(writer.EndContainer(dummyType));
     ReturnErrorOnFailure(writer.Finalize());
@@ -2240,7 +2240,7 @@ CHIP_ERROR DoorLockCluster::SetPin(Callback::Cancelable * onSuccessCallback, Cal
 CHIP_ERROR DoorLockCluster::SetRfid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                     uint16_t userId, uint8_t userStatus, uint8_t userType, chip::ByteSpan id)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2262,7 +2262,7 @@ CHIP_ERROR DoorLockCluster::SetRfid(Callback::Cancelable * onSuccessCallback, Ca
     // userType: doorLockUserType
     ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), userType));
     // id: charString
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), id));
+    ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), id));
 
     ReturnErrorOnFailure(writer.EndContainer(dummyType));
     ReturnErrorOnFailure(writer.Finalize());
@@ -2280,7 +2280,7 @@ CHIP_ERROR DoorLockCluster::SetRfid(Callback::Cancelable * onSuccessCallback, Ca
 CHIP_ERROR DoorLockCluster::SetUserType(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                         uint16_t userId, uint8_t userType)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2316,7 +2316,7 @@ CHIP_ERROR DoorLockCluster::SetWeekdaySchedule(Callback::Cancelable * onSuccessC
                                                uint8_t scheduleId, uint16_t userId, uint8_t daysMask, uint8_t startHour,
                                                uint8_t startMinute, uint8_t endHour, uint8_t endMinute)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2362,7 +2362,7 @@ CHIP_ERROR DoorLockCluster::SetWeekdaySchedule(Callback::Cancelable * onSuccessC
 CHIP_ERROR DoorLockCluster::SetYeardaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                uint8_t scheduleId, uint16_t userId, uint32_t localStartTime, uint32_t localEndTime)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2402,7 +2402,7 @@ CHIP_ERROR DoorLockCluster::SetYeardaySchedule(Callback::Cancelable * onSuccessC
 CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                        chip::ByteSpan pin)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2418,7 +2418,7 @@ CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback,
 
     uint8_t argSeqNumber = 0;
     // pin: charString
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), pin));
+    ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), pin));
 
     ReturnErrorOnFailure(writer.EndContainer(dummyType));
     ReturnErrorOnFailure(writer.Finalize());
@@ -2435,7 +2435,7 @@ CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback,
 CHIP_ERROR DoorLockCluster::UnlockWithTimeout(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                               uint16_t timeoutInSeconds, chip::ByteSpan pin)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2453,7 +2453,7 @@ CHIP_ERROR DoorLockCluster::UnlockWithTimeout(Callback::Cancelable * onSuccessCa
     // timeoutInSeconds: int16u
     ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), timeoutInSeconds));
     // pin: charString
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), pin));
+    ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), pin));
 
     ReturnErrorOnFailure(writer.EndContainer(dummyType));
     ReturnErrorOnFailure(writer.Finalize());
@@ -2527,7 +2527,7 @@ CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuc
                                                     Callback::Cancelable * onFailureCallback, uint16_t expiryLengthSeconds,
                                                     uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2565,7 +2565,7 @@ CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuc
 CHIP_ERROR GeneralCommissioningCluster::CommissioningComplete(Callback::Cancelable * onSuccessCallback,
                                                               Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2597,7 +2597,7 @@ CHIP_ERROR GeneralCommissioningCluster::SetFabric(Callback::Cancelable * onSucce
                                                   Callback::Cancelable * onFailureCallback, chip::ByteSpan fabricId,
                                                   chip::ByteSpan fabricSecret, uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2711,7 +2711,7 @@ CHIP_ERROR GroupKeyManagementCluster::ReadAttributeClusterRevision(Callback::Can
 CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                    uint16_t groupId, chip::ByteSpan groupName)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2729,7 +2729,7 @@ CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Cal
     // groupId: int16u
     ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId));
     // groupName: charString
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), groupName));
+    ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupName));
 
     ReturnErrorOnFailure(writer.EndContainer(dummyType));
     ReturnErrorOnFailure(writer.Finalize());
@@ -2746,7 +2746,7 @@ CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Cal
 CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                                 uint16_t groupId, chip::ByteSpan groupName)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2764,7 +2764,7 @@ CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccess
     // groupId: int16u
     ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupId));
     // groupName: charString
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), groupName));
+    ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), groupName));
 
     ReturnErrorOnFailure(writer.EndContainer(dummyType));
     ReturnErrorOnFailure(writer.Finalize());
@@ -2782,7 +2782,7 @@ CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccess
 CHIP_ERROR GroupsCluster::GetGroupMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                              uint8_t groupCount, uint16_t groupList)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2817,7 +2817,7 @@ CHIP_ERROR GroupsCluster::GetGroupMembership(Callback::Cancelable * onSuccessCal
 
 CHIP_ERROR GroupsCluster::RemoveAllGroups(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2848,7 +2848,7 @@ CHIP_ERROR GroupsCluster::RemoveAllGroups(Callback::Cancelable * onSuccessCallba
 CHIP_ERROR GroupsCluster::RemoveGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint16_t groupId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -2881,7 +2881,7 @@ CHIP_ERROR GroupsCluster::RemoveGroup(Callback::Cancelable * onSuccessCallback,
 CHIP_ERROR GroupsCluster::ViewGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                     uint16_t groupId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3000,7 +3000,7 @@ CHIP_ERROR IasZoneCluster::ReadAttributeClusterRevision(Callback::Cancelable * o
 CHIP_ERROR IdentifyCluster::Identify(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint16_t identifyTime)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3032,7 +3032,7 @@ CHIP_ERROR IdentifyCluster::Identify(Callback::Cancelable * onSuccessCallback, C
 
 CHIP_ERROR IdentifyCluster::IdentifyQuery(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3095,7 +3095,7 @@ CHIP_ERROR IdentifyCluster::ReadAttributeClusterRevision(Callback::Cancelable *
 CHIP_ERROR LevelControlCluster::Move(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint8_t moveMode, uint8_t rate, uint8_t optionMask, uint8_t optionOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3135,7 +3135,7 @@ CHIP_ERROR LevelControlCluster::Move(Callback::Cancelable * onSuccessCallback, C
 CHIP_ERROR LevelControlCluster::MoveToLevel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                             uint8_t level, uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3176,7 +3176,7 @@ CHIP_ERROR LevelControlCluster::MoveToLevelWithOnOff(Callback::Cancelable * onSu
                                                      Callback::Cancelable * onFailureCallback, uint8_t level,
                                                      uint16_t transitionTime)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3212,7 +3212,7 @@ CHIP_ERROR LevelControlCluster::MoveToLevelWithOnOff(Callback::Cancelable * onSu
 CHIP_ERROR LevelControlCluster::MoveWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                               uint8_t moveMode, uint8_t rate)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3248,7 +3248,7 @@ CHIP_ERROR LevelControlCluster::Step(Callback::Cancelable * onSuccessCallback, C
                                      uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime, uint8_t optionMask,
                                      uint8_t optionOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3290,7 +3290,7 @@ CHIP_ERROR LevelControlCluster::Step(Callback::Cancelable * onSuccessCallback, C
 CHIP_ERROR LevelControlCluster::StepWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                               uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3328,7 +3328,7 @@ CHIP_ERROR LevelControlCluster::StepWithOnOff(Callback::Cancelable * onSuccessCa
 CHIP_ERROR LevelControlCluster::Stop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint8_t optionMask, uint8_t optionOverride)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3362,7 +3362,7 @@ CHIP_ERROR LevelControlCluster::Stop(Callback::Cancelable * onSuccessCallback, C
 
 CHIP_ERROR LevelControlCluster::StopWithOnOff(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3432,7 +3432,7 @@ CHIP_ERROR LevelControlCluster::ReadAttributeClusterRevision(Callback::Cancelabl
 // LowPower Cluster Commands
 CHIP_ERROR LowPowerCluster::Sleep(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3480,7 +3480,7 @@ CHIP_ERROR NetworkCommissioningCluster::AddThreadNetwork(Callback::Cancelable *
                                                          Callback::Cancelable * onFailureCallback,
                                                          chip::ByteSpan operationalDataset, uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3519,7 +3519,7 @@ CHIP_ERROR NetworkCommissioningCluster::AddWiFiNetwork(Callback::Cancelable * on
                                                        Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid,
                                                        chip::ByteSpan credentials, uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3560,7 +3560,7 @@ CHIP_ERROR NetworkCommissioningCluster::DisableNetwork(Callback::Cancelable * on
                                                        Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID,
                                                        uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3599,7 +3599,7 @@ CHIP_ERROR NetworkCommissioningCluster::EnableNetwork(Callback::Cancelable * onS
                                                       Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID,
                                                       uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3638,7 +3638,7 @@ CHIP_ERROR NetworkCommissioningCluster::GetLastNetworkCommissioningResult(Callba
                                                                           Callback::Cancelable * onFailureCallback,
                                                                           uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3673,7 +3673,7 @@ CHIP_ERROR NetworkCommissioningCluster::RemoveNetwork(Callback::Cancelable * onS
                                                       Callback::Cancelable * onFailureCallback, chip::ByteSpan networkID,
                                                       uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3712,7 +3712,7 @@ CHIP_ERROR NetworkCommissioningCluster::ScanNetworks(Callback::Cancelable * onSu
                                                      Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid,
                                                      uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3752,7 +3752,7 @@ CHIP_ERROR NetworkCommissioningCluster::UpdateThreadNetwork(Callback::Cancelable
                                                             chip::ByteSpan operationalDataset, uint64_t breadcrumb,
                                                             uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3791,7 +3791,7 @@ CHIP_ERROR NetworkCommissioningCluster::UpdateWiFiNetwork(Callback::Cancelable *
                                                           Callback::Cancelable * onFailureCallback, chip::ByteSpan ssid,
                                                           chip::ByteSpan credentials, uint64_t breadcrumb, uint32_t timeoutMs)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3847,7 +3847,7 @@ CHIP_ERROR NetworkCommissioningCluster::ReadAttributeClusterRevision(Callback::C
 // OnOff Cluster Commands
 CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3877,7 +3877,7 @@ CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback:
 
 CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3907,7 +3907,7 @@ CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback::
 
 CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3976,7 +3976,7 @@ CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Cal
                                    uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, chip::ByteSpan sceneName,
                                    chip::ClusterId clusterId, uint8_t length, uint8_t value)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -3998,7 +3998,7 @@ CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Cal
     // transitionTime: int16u
     ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), transitionTime));
     // sceneName: charString
-    ReturnErrorOnFailure(writer.PutString(TLV::ContextTag(argSeqNumber++), sceneName));
+    ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), sceneName));
     // clusterId: clusterId
     ReturnErrorOnFailure(writer.Put(TLV::ContextTag(argSeqNumber++), clusterId));
     // length: int8u
@@ -4022,7 +4022,7 @@ CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Cal
 CHIP_ERROR ScenesCluster::GetSceneMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                              uint16_t groupId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -4055,7 +4055,7 @@ CHIP_ERROR ScenesCluster::GetSceneMembership(Callback::Cancelable * onSuccessCal
 CHIP_ERROR ScenesCluster::RecallScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint16_t groupId, uint8_t sceneId, uint16_t transitionTime)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -4093,7 +4093,7 @@ CHIP_ERROR ScenesCluster::RecallScene(Callback::Cancelable * onSuccessCallback,
 CHIP_ERROR ScenesCluster::RemoveAllScenes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                           uint16_t groupId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -4126,7 +4126,7 @@ CHIP_ERROR ScenesCluster::RemoveAllScenes(Callback::Cancelable * onSuccessCallba
 CHIP_ERROR ScenesCluster::RemoveScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                       uint16_t groupId, uint8_t sceneId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -4161,7 +4161,7 @@ CHIP_ERROR ScenesCluster::RemoveScene(Callback::Cancelable * onSuccessCallback,
 CHIP_ERROR ScenesCluster::StoreScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                      uint16_t groupId, uint8_t sceneId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
@@ -4196,7 +4196,7 @@ CHIP_ERROR ScenesCluster::StoreScene(Callback::Cancelable * onSuccessCallback, C
 CHIP_ERROR ScenesCluster::ViewScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback,
                                     uint16_t groupId, uint8_t sceneId)
 {
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE);
     (void) onSuccessCallback;
     (void) onFailureCallback;
index a2746e4..36cf324 100644 (file)
@@ -285,7 +285,7 @@ CHIP_ERROR Device::OpenPairingWindow(uint32_t timeout, PairingWindowOption optio
 
     ReturnErrorOnFailure(SendMessage(std::move(outBuffer), header));
 
-    setupPayload.version               = 1;
+    setupPayload.version               = 0;
     setupPayload.rendezvousInformation = RendezvousInformationFlags::kBLE;
 
     return CHIP_NO_ERROR;
index 27d40da..b3d494f 100644 (file)
@@ -55,6 +55,13 @@ using DeviceTransportMgr = TransportMgr<Transport::UDP /* IPv6 */
 #endif
                                         >;
 
+struct ControllerDeviceInitParams
+{
+    DeviceTransportMgr * transportMgr = nullptr;
+    SecureSessionMgr * sessionMgr     = nullptr;
+    Inet::InetLayer * inetLayer       = nullptr;
+};
+
 class DLL_EXPORT Device
 {
 public:
@@ -112,7 +119,7 @@ public:
             mCommandSender->Shutdown();
             mCommandSender = nullptr;
         }
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
         chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&mCommandSender);
 #endif
     }
@@ -140,18 +147,15 @@ public:
      *   that of this device object. If these objects are freed, while the device object is
      *   still using them, it can lead to unknown behavior and crashes.
      *
-     * @param[in] transportMgr Transport manager object pointer
-     * @param[in] sessionMgr   Secure session manager object pointer
-     * @param[in] inetLayer    InetLayer object pointer
+     * @param[in] params       Wrapper object for transport manager etc.
      * @param[in] listenPort   Port on which controller is listening (typically CHIP_PORT)
      * @param[in] admin        Local administrator that's initializing this device object
      */
-    void Init(DeviceTransportMgr * transportMgr, SecureSessionMgr * sessionMgr, Inet::InetLayer * inetLayer, uint16_t listenPort,
-              Transport::AdminId admin)
+    void Init(ControllerDeviceInitParams params, uint16_t listenPort, Transport::AdminId admin)
     {
-        mTransportMgr   = transportMgr;
-        mSessionManager = sessionMgr;
-        mInetLayer      = inetLayer;
+        mTransportMgr   = params.transportMgr;
+        mSessionManager = params.sessionMgr;
+        mInetLayer      = params.inetLayer;
         mListenPort     = listenPort;
         mAdminId        = admin;
     }
@@ -167,18 +171,16 @@ public:
      *   uninitialzed/unpaired device objects. The object is initialized only when the device
      *   is actually paired.
      *
-     * @param[in] transportMgr Transport manager object pointer
-     * @param[in] sessionMgr   Secure session manager object pointer
-     * @param[in] inetLayer    InetLayer object pointer
+     * @param[in] params       Wrapper object for transport manager etc.
      * @param[in] listenPort   Port on which controller is listening (typically CHIP_PORT)
      * @param[in] deviceId     Node ID of the device
      * @param[in] peerAddress  The location of the peer. MUST be of type Transport::Type::kUdp
      * @param[in] admin        Local administrator that's initializing this device object
      */
-    void Init(DeviceTransportMgr * transportMgr, SecureSessionMgr * sessionMgr, Inet::InetLayer * inetLayer, uint16_t listenPort,
-              NodeId deviceId, const Transport::PeerAddress & peerAddress, Transport::AdminId admin)
+    void Init(ControllerDeviceInitParams params, uint16_t listenPort, NodeId deviceId, const Transport::PeerAddress & peerAddress,
+              Transport::AdminId admin)
     {
-        Init(transportMgr, sessionMgr, inetLayer, mListenPort, admin);
+        Init(params, mListenPort, admin);
         mDeviceId = deviceId;
         mState    = ConnectionState::Connecting;
 
index 8fe5274..2525ea3 100644 (file)
@@ -101,16 +101,22 @@ DeviceController::DeviceController()
 CHIP_ERROR DeviceController::Init(NodeId localDeviceId, PersistentStorageDelegate * storageDelegate, System::Layer * systemLayer,
                                   Inet::InetLayer * inetLayer)
 {
+    return Init(localDeviceId,
+                ControllerInitParams{ .storageDelegate = storageDelegate, .systemLayer = systemLayer, .inetLayer = inetLayer });
+}
+
+CHIP_ERROR DeviceController::Init(NodeId localDeviceId, ControllerInitParams params)
+{
     CHIP_ERROR err = CHIP_NO_ERROR;
 
     Transport::AdminPairingInfo * admin = nullptr;
 
     VerifyOrExit(mState == State::NotInitialized, err = CHIP_ERROR_INCORRECT_STATE);
 
-    if (systemLayer != nullptr && inetLayer != nullptr)
+    if (params.systemLayer != nullptr && params.inetLayer != nullptr)
     {
-        mSystemLayer = systemLayer;
-        mInetLayer   = inetLayer;
+        mSystemLayer = params.systemLayer;
+        mInetLayer   = params.inetLayer;
     }
     else
     {
@@ -126,7 +132,7 @@ CHIP_ERROR DeviceController::Init(NodeId localDeviceId, PersistentStorageDelegat
     VerifyOrExit(mSystemLayer != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
     VerifyOrExit(mInetLayer != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
 
-    mStorageDelegate = storageDelegate;
+    mStorageDelegate = params.storageDelegate;
 
     if (mStorageDelegate != nullptr)
     {
@@ -136,7 +142,7 @@ CHIP_ERROR DeviceController::Init(NodeId localDeviceId, PersistentStorageDelegat
     mTransportMgr   = chip::Platform::New<DeviceTransportMgr>();
     mSessionManager = chip::Platform::New<SecureSessionMgr>();
 
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     mExchangeManager = chip::Platform::New<Messaging::ExchangeManager>();
 #endif
 
@@ -155,10 +161,10 @@ CHIP_ERROR DeviceController::Init(NodeId localDeviceId, PersistentStorageDelegat
     err = mSessionManager->Init(localDeviceId, mSystemLayer, mTransportMgr, &mAdmins);
     SuccessOrExit(err);
 
-#ifdef CHIP_APP_USE_INTERACTION_MODEL
+#if CHIP_ENABLE_INTERACTION_MODEL
     err = mExchangeManager->Init(mSessionManager);
     SuccessOrExit(err);
-    err = chip::app::InteractionModelEngine::GetInstance()->Init(mExchangeManager);
+    err = chip::app::InteractionModelEngine::GetInstance()->Init(mExchangeManager, nullptr);
     SuccessOrExit(err);
 #else
     mSessionManager->SetDelegate(this);
@@ -257,7 +263,7 @@ CHIP_ERROR DeviceController::GetDevice(NodeId deviceId, const SerializedDevice &
             ReturnErrorOnFailure(err);
         }
 
-        device->Init(mTransportMgr, mSessionManager, mInetLayer, mListenPort, mAdminId);
+        device->Init(GetControllerDeviceInitParams(), mListenPort, mAdminId);
     }
 
     *out_device = device;
@@ -300,7 +306,7 @@ CHIP_ERROR DeviceController::GetDevice(NodeId deviceId, Device ** out_device)
             err = device->Deserialize(deviceInfo);
             VerifyOrExit(err == CHIP_NO_ERROR, ReleaseDevice(device));
 
-            device->Init(mTransportMgr, mSessionManager, mInetLayer, mListenPort, mAdminId);
+            device->Init(GetControllerDeviceInitParams(), mListenPort, mAdminId);
         }
     }
 
@@ -511,6 +517,11 @@ exit:
 
 void DeviceController::OnPersistentStorageStatus(const char * key, Operation op, CHIP_ERROR err) {}
 
+ControllerDeviceInitParams DeviceController::GetControllerDeviceInitParams()
+{
+    return ControllerDeviceInitParams{ .transportMgr = mTransportMgr, .sessionMgr = mSessionManager, .inetLayer = mInetLayer };
+}
+
 DeviceCommissioner::DeviceCommissioner()
 {
     mPairingDelegate      = nullptr;
@@ -537,7 +548,14 @@ CHIP_ERROR DeviceCommissioner::Init(NodeId localDeviceId, PersistentStorageDeleg
                                     DevicePairingDelegate * pairingDelegate, System::Layer * systemLayer,
                                     Inet::InetLayer * inetLayer)
 {
-    ReturnErrorOnFailure(DeviceController::Init(localDeviceId, storageDelegate, systemLayer, inetLayer));
+    return Init(localDeviceId,
+                ControllerInitParams{ .storageDelegate = storageDelegate, .systemLayer = systemLayer, .inetLayer = inetLayer },
+                pairingDelegate);
+}
+
+CHIP_ERROR DeviceCommissioner::Init(NodeId localDeviceId, ControllerInitParams params, DevicePairingDelegate * pairingDelegate)
+{
+    ReturnErrorOnFailure(DeviceController::Init(localDeviceId, params));
 
     if (LoadKeyId(mStorageDelegate, mNextKeyId) != CHIP_NO_ERROR)
     {
@@ -611,7 +629,7 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam
                                    mSessionManager, admin);
     SuccessOrExit(err);
 
-    device->Init(mTransportMgr, mSessionManager, mInetLayer, mListenPort, remoteDeviceId, udpPeerAddress, admin->GetAdminId());
+    device->Init(GetControllerDeviceInitParams(), mListenPort, remoteDeviceId, udpPeerAddress, admin->GetAdminId());
 
     // TODO: BLE rendezvous and IP rendezvous should have same logic in the future after BLE becomes a transport and network
     // provisiong cluster is ready.
@@ -662,7 +680,7 @@ CHIP_ERROR DeviceCommissioner::PairTestDeviceWithoutSecurity(NodeId remoteDevice
 
     testSecurePairingSecret->ToSerializable(device->GetPairing());
 
-    device->Init(mTransportMgr, mSessionManager, mInetLayer, mListenPort, remoteDeviceId, peerAddress, mAdminId);
+    device->Init(GetControllerDeviceInitParams(), mListenPort, remoteDeviceId, peerAddress, mAdminId);
 
     device->Serialize(serialized);
 
index 05fa3cd..129ee96 100644 (file)
@@ -49,6 +49,13 @@ namespace Controller {
 constexpr uint16_t kNumMaxActiveDevices = 64;
 constexpr uint16_t kNumMaxPairedDevices = 128;
 
+struct ControllerInitParams
+{
+    PersistentStorageDelegate * storageDelegate = nullptr;
+    System::Layer * systemLayer                 = nullptr;
+    Inet::InetLayer * inetLayer                 = nullptr;
+};
+
 class DLL_EXPORT DevicePairingDelegate
 {
 public:
@@ -116,6 +123,9 @@ public:
      * Init function to be used when there exists a device layer that takes care of initializing
      * System::Layer and InetLayer.
      */
+    CHIP_ERROR Init(NodeId localDeviceId, ControllerInitParams params);
+
+    // Note: Future modifications should be made to ControllerInitParams
     CHIP_ERROR Init(NodeId localDeviceId, PersistentStorageDelegate * storageDelegate = nullptr,
                     System::Layer * systemLayer = nullptr, Inet::InetLayer * inetLayer = nullptr);
 
@@ -201,6 +211,7 @@ protected:
     void ReleaseDeviceById(NodeId remoteDeviceId);
     CHIP_ERROR InitializePairedDeviceList();
     CHIP_ERROR SetPairedDeviceList(const char * pairedDeviceSerializedSet);
+    ControllerDeviceInitParams GetControllerDeviceInitParams();
 
     Transport::AdminId mAdminId = 0;
     Transport::AdminPairingTable mAdmins;
@@ -258,6 +269,9 @@ public:
      * Init function to be used when there exists a device layer that takes care of initializing
      * System::Layer and InetLayer.
      */
+    CHIP_ERROR Init(NodeId localDeviceId, ControllerInitParams params, DevicePairingDelegate * pairingDelegate = nullptr);
+
+    // Note: Future modifications should be made to ControllerInitParams
     CHIP_ERROR Init(NodeId localDeviceId, PersistentStorageDelegate * storageDelegate = nullptr,
                     DevicePairingDelegate * pairingDelegate = nullptr, System::Layer * systemLayer = nullptr,
                     Inet::InetLayer * inetLayer = nullptr);
index 320005d..9dfd6db 100644 (file)
@@ -309,17 +309,30 @@ CHIP_ERROR AndroidDeviceControllerWrapper::SyncGetKeyValue(const char * key, cha
 
     if (valueString != NULL)
     {
-        if (value != nullptr)
+        size_t stringLength = GetJavaEnv()->GetStringUTFLength(valueString);
+        if (stringLength > UINT16_MAX - 1)
         {
-            valueChars = GetJavaEnv()->GetStringUTFChars(valueString, 0);
-            size       = strlcpy(value, GetJavaEnv()->GetStringUTFChars(valueString, 0), size);
+            err = CHIP_ERROR_BUFFER_TOO_SMALL;
         }
         else
         {
-            size = GetJavaEnv()->GetStringUTFLength(valueString);
+            if (value != nullptr)
+            {
+                valueChars = GetJavaEnv()->GetStringUTFChars(valueString, 0);
+                size       = strlcpy(value, valueChars, size);
+                if (size < stringLength)
+                {
+                    err = CHIP_ERROR_NO_MEMORY;
+                }
+            }
+            else
+            {
+                size = stringLength;
+                err  = CHIP_ERROR_NO_MEMORY;
+            }
+            // Increment size to account for null termination
+            size += 1;
         }
-        // Increment size to account for null termination
-        size += 1;
     }
     else
     {
index 8de5426..be724a1 100644 (file)
@@ -57,7 +57,7 @@ using namespace chip::Controller;
 
 #define CDC_JNI_CALLBACK_LOCAL_REF_COUNT 256
 
-static void GetCHIPDevice(JNIEnv * env, long wrapperHandle, int deviceId, Device ** device);
+static void GetCHIPDevice(JNIEnv * env, long wrapperHandle, uint64_t deviceId, Device ** device);
 static void HandleNotifyChipConnectionClosed(BLE_CONNECTION_OBJECT connObj);
 static bool HandleSendCharacteristic(BLE_CONNECTION_OBJECT connObj, const uint8_t * svcId, const uint8_t * charId,
                                      const uint8_t * characteristicData, uint32_t characteristicDataLen);
@@ -276,7 +276,7 @@ exit:
     return result;
 }
 
-JNI_METHOD(void, pairDevice)(JNIEnv * env, jobject self, jlong handle, jint deviceId, jint connObj, jlong pinCode)
+JNI_METHOD(void, pairDevice)(JNIEnv * env, jobject self, jlong handle, jlong deviceId, jint connObj, jlong pinCode)
 {
     CHIP_ERROR err                           = CHIP_NO_ERROR;
     AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle);
@@ -301,7 +301,7 @@ JNI_METHOD(void, pairDevice)(JNIEnv * env, jobject self, jlong handle, jint devi
     }
 }
 
-JNI_METHOD(void, unpairDevice)(JNIEnv * env, jobject self, jlong handle, jint deviceId)
+JNI_METHOD(void, unpairDevice)(JNIEnv * env, jobject self, jlong handle, jlong deviceId)
 {
     CHIP_ERROR err                           = CHIP_NO_ERROR;
     AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle);
@@ -320,7 +320,7 @@ JNI_METHOD(void, unpairDevice)(JNIEnv * env, jobject self, jlong handle, jint de
     }
 }
 
-JNI_METHOD(void, stopDevicePairing)(JNIEnv * env, jobject self, jlong handle, jint deviceId)
+JNI_METHOD(void, stopDevicePairing)(JNIEnv * env, jobject self, jlong handle, jlong deviceId)
 {
     CHIP_ERROR err                           = CHIP_NO_ERROR;
     AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle);
@@ -345,7 +345,10 @@ JNI_METHOD(void, sendWiFiCredentials)(JNIEnv * env, jobject self, jlong handle,
     JniUtfString passwordStr(env, password);
 
     ChipLogProgress(Controller, "Sending Wi-Fi credentials for: %s", ssidStr.c_str());
-    AndroidDeviceControllerWrapper::FromJNIHandle(handle)->SendNetworkCredentials(ssidStr.c_str(), passwordStr.c_str());
+    {
+        ScopedPthreadLock lock(&sStackLock);
+        AndroidDeviceControllerWrapper::FromJNIHandle(handle)->SendNetworkCredentials(ssidStr.c_str(), passwordStr.c_str());
+    }
 }
 
 JNI_METHOD(void, sendThreadCredentials)
@@ -400,7 +403,7 @@ JNI_METHOD(void, pairTestDeviceWithoutSecurity)(JNIEnv * env, jobject self, jlon
     }
 }
 
-JNI_METHOD(void, disconnectDevice)(JNIEnv * env, jobject self, jlong handle, jint deviceId)
+JNI_METHOD(void, disconnectDevice)(JNIEnv * env, jobject self, jlong handle, jlong deviceId)
 {
     AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle);
     CHIP_ERROR err                           = CHIP_NO_ERROR;
@@ -432,7 +435,7 @@ JNI_METHOD(jboolean, isActive)(JNIEnv * env, jobject self, jlong handle)
     }
 }
 
-void GetCHIPDevice(JNIEnv * env, long wrapperHandle, int deviceId, Device ** chipDevice)
+void GetCHIPDevice(JNIEnv * env, long wrapperHandle, uint64_t deviceId, Device ** chipDevice)
 {
     AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(wrapperHandle);
     CHIP_ERROR err                           = CHIP_NO_ERROR;
@@ -449,7 +452,7 @@ void GetCHIPDevice(JNIEnv * env, long wrapperHandle, int deviceId, Device ** chi
     }
 }
 
-JNI_METHOD(jstring, getIpAddress)(JNIEnv * env, jobject self, jlong handle, jint deviceId)
+JNI_METHOD(jstring, getIpAddress)(JNIEnv * env, jobject self, jlong handle, jlong deviceId)
 {
     Device * chipDevice = nullptr;
 
@@ -469,7 +472,7 @@ JNI_METHOD(jstring, getIpAddress)(JNIEnv * env, jobject self, jlong handle, jint
     return env->NewStringUTF(addrStr);
 }
 
-JNI_METHOD(void, sendMessage)(JNIEnv * env, jobject self, jlong handle, jint deviceId, jstring messageObj)
+JNI_METHOD(void, sendMessage)(JNIEnv * env, jobject self, jlong handle, jlong deviceId, jstring messageObj)
 {
     CHIP_ERROR err      = CHIP_NO_ERROR;
     Device * chipDevice = nullptr;
@@ -504,7 +507,7 @@ JNI_METHOD(void, sendMessage)(JNIEnv * env, jobject self, jlong handle, jint dev
     }
 }
 
-JNI_METHOD(void, sendCommand)(JNIEnv * env, jobject self, jlong handle, jint deviceId, jobject commandObj, jint aValue)
+JNI_METHOD(void, sendCommand)(JNIEnv * env, jobject self, jlong handle, jlong deviceId, jobject commandObj, jint aValue)
 {
     CHIP_ERROR err      = CHIP_NO_ERROR;
     Device * chipDevice = nullptr;
@@ -560,7 +563,7 @@ JNI_METHOD(void, sendCommand)(JNIEnv * env, jobject self, jlong handle, jint dev
     }
 }
 
-JNI_METHOD(jboolean, openPairingWindow)(JNIEnv * env, jobject self, jlong handle, jint deviceId, jint duration)
+JNI_METHOD(jboolean, openPairingWindow)(JNIEnv * env, jobject self, jlong handle, jlong deviceId, jint duration)
 {
     CHIP_ERROR err      = CHIP_NO_ERROR;
     Device * chipDevice = nullptr;
index 12bbb99..2872fc3 100644 (file)
@@ -46,7 +46,7 @@ public class ChipDeviceController {
     return AndroidChipStack.getInstance().getCallback();
   }
 
-  public void pairDevice(BluetoothGatt bleServer, int deviceId, long setupPincode) {
+  public void pairDevice(BluetoothGatt bleServer, long deviceId, long setupPincode) {
     if (connectionId == 0) {
       bleGatt = bleServer;
 
@@ -66,7 +66,7 @@ public class ChipDeviceController {
     }
   }
 
-  public void unpairDevice(int deviceId) {
+  public void unpairDevice(long deviceId) {
     unpairDevice(deviceControllerPtr, deviceId);
   }
 
@@ -74,7 +74,7 @@ public class ChipDeviceController {
     pairTestDeviceWithoutSecurity(deviceControllerPtr, ipAddress);
   }
 
-  public void pairDevice(int deviceId, int connectionId, long pinCode) {
+  public void pairDevice(long deviceId, int connectionId, long pinCode) {
     pairDevice(deviceControllerPtr, deviceId, connectionId, pinCode);
   }
 
@@ -86,7 +86,7 @@ public class ChipDeviceController {
     sendThreadCredentials(deviceControllerPtr, channel, panId, xpanId, masterKey);
   }
 
-  public boolean disconnectDevice(int deviceId) {
+  public boolean disconnectDevice(long deviceId) {
     return disconnectDevice(deviceControllerPtr, deviceId);
   }
 
@@ -172,32 +172,32 @@ public class ChipDeviceController {
     return true;
   }
 
-  public String getIpAddress(int deviceId) {
+  public String getIpAddress(long deviceId) {
     return getIpAddress(deviceControllerPtr, deviceId);
   }
 
-  public void sendMessage(int deviceId, String message) {
+  public void sendMessage(long deviceId, String message) {
     sendMessage(deviceControllerPtr, deviceId, message);
   }
 
-  public void sendCommand(int deviceId, ChipCommandType command, int value) {
+  public void sendCommand(long deviceId, ChipCommandType command, int value) {
     sendCommand(deviceControllerPtr, deviceId, command, value);
   }
 
-  public boolean openPairingWindow(int deviceId, int duration) {
+  public boolean openPairingWindow(long deviceId, int duration) {
     return openPairingWindow(deviceControllerPtr, deviceId, duration);
   }
 
-  public boolean isActive(int deviceId) {
+  public boolean isActive(long deviceId) {
     return isActive(deviceControllerPtr, deviceId);
   }
 
   private native long newDeviceController();
 
   private native void pairDevice(
-      long deviceControllerPtr, int deviceId, int connectionId, long pinCode);
+      long deviceControllerPtr, long deviceId, int connectionId, long pinCode);
 
-  private native void unpairDevice(long deviceControllerPtr, int deviceId);
+  private native void unpairDevice(long deviceControllerPtr, long deviceId);
 
   private native void pairTestDeviceWithoutSecurity(long deviceControllerPtr, String ipAddress);
 
@@ -206,20 +206,20 @@ public class ChipDeviceController {
   private native void sendThreadCredentials(
       long deviceControllerPtr, int channel, int panId, byte[] xpanId, byte[] masterKey);
 
-  private native boolean disconnectDevice(long deviceControllerPtr, int deviceId);
+  private native boolean disconnectDevice(long deviceControllerPtr, long deviceId);
 
   private native void deleteDeviceController(long deviceControllerPtr);
 
-  private native String getIpAddress(long deviceControllerPtr, int deviceId);
+  private native String getIpAddress(long deviceControllerPtr, long deviceId);
 
-  private native void sendMessage(long deviceControllerPtr, int deviceId, String message);
+  private native void sendMessage(long deviceControllerPtr, long deviceId, String message);
 
   private native void sendCommand(
-      long deviceControllerPtr, int deviceId, ChipCommandType command, int value);
+      long deviceControllerPtr, long deviceId, ChipCommandType command, int value);
 
-  private native boolean openPairingWindow(long deviceControllerPtr, int deviceId, int duration);
+  private native boolean openPairingWindow(long deviceControllerPtr, long deviceId, int duration);
 
-  private native boolean isActive(long deviceControllerPtr, int deviceId);
+  private native boolean isActive(long deviceControllerPtr, long deviceId);
 
   static {
     System.loadLibrary("CHIPController");
index f621c16..80be54f 100644 (file)
@@ -36,7 +36,6 @@ shared_library("ChipDeviceCtrl") {
   include_dirs = [ "." ]
 
   sources = [
-    "ChipDeviceController-ClusterCommands.cpp",
     "ChipDeviceController-ScriptBinding.cpp",
     "ChipDeviceController-ScriptDeviceAddressUpdateDelegate.cpp",
     "ChipDeviceController-ScriptDeviceAddressUpdateDelegate.h",
@@ -44,6 +43,7 @@ shared_library("ChipDeviceCtrl") {
     "ChipDeviceController-ScriptDevicePairingDelegate.h",
     "ChipDeviceController-StorageDelegate.cpp",
     "ChipDeviceController-StorageDelegate.h",
+    "chip/clusters/CHIPClusters.cpp",
     "chip/internal/ChipThreadWork.cpp",
     "chip/internal/ChipThreadWork.h",
     "chip/internal/CommissionerImpl.cpp",
@@ -89,7 +89,6 @@ pw_python_action("python") {
         "chip/ChipBleBase.py",
         "chip/ChipBleUtility.py",
         "chip/ChipBluezMgr.py",
-        "chip/ChipCluster.py",
         "chip/ChipCoreBluetoothMgr.py",
         "chip/ChipDeviceCtrl.py",
         "chip/ChipStack.py",
@@ -101,6 +100,8 @@ pw_python_action("python") {
         "chip/ble/library_handle.py",
         "chip/ble/scan_devices.py",
         "chip/ble/types.py",
+        "chip/clusters/CHIPClusters.py",
+        "chip/clusters/__init__.py",
         "chip/configuration/__init__.py",
         "chip/exceptions/__init__.py",
         "chip/internal/__init__.py",
diff --git a/src/controller/python/ChipDeviceController-ClusterCommands.cpp b/src/controller/python/ChipDeviceController-ClusterCommands.cpp
deleted file mode 100644 (file)
index 937f63c..0000000
+++ /dev/null
@@ -1,894 +0,0 @@
-/*
- *
- *    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.
- */
-
-// THIS FILE IS GENERATED BY ZAP
-
-#include <core/CHIPCore.h>
-
-#include <app/CommandSender.h>
-#include <app/InteractionModelEngine.h>
-#include <lib/support/Span.h>
-
-#include <controller/CHIPClusters.h>
-#include <controller/CHIPDevice.h>
-
-using namespace chip;
-using namespace chip::app;
-
-extern "C" {
-
-// Cluster ApplicationBasic
-// End of Cluster ApplicationBasic
-
-// Cluster BarrierControl
-CHIP_ERROR chip_ime_AppendCommand_BarrierControl_BarrierControlGoToPercent(chip::Controller::Device * device,
-                                                                           chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                           uint8_t percentOpen)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::BarrierControlCluster clusterBarrierControl;
-    (void) ZCLgroupId;
-    clusterBarrierControl.Associate(device, ZCLendpointId);
-    return clusterBarrierControl.BarrierControlGoToPercent(nullptr, nullptr, percentOpen);
-}
-CHIP_ERROR chip_ime_AppendCommand_BarrierControl_BarrierControlStop(chip::Controller::Device * device,
-                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::BarrierControlCluster clusterBarrierControl;
-    (void) ZCLgroupId;
-    clusterBarrierControl.Associate(device, ZCLendpointId);
-    return clusterBarrierControl.BarrierControlStop(nullptr, nullptr);
-}
-// End of Cluster BarrierControl
-
-// Cluster Basic
-CHIP_ERROR chip_ime_AppendCommand_Basic_MfgSpecificPing(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                        chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::BasicCluster clusterBasic;
-    (void) ZCLgroupId;
-    clusterBasic.Associate(device, ZCLendpointId);
-    return clusterBasic.MfgSpecificPing(nullptr, nullptr);
-}
-// End of Cluster Basic
-
-// Cluster Binding
-CHIP_ERROR chip_ime_AppendCommand_Binding_Bind(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                               chip::GroupId ZCLgroupId, chip::NodeId nodeId, chip::GroupId groupId,
-                                               chip::EndpointId endpointId, chip::ClusterId clusterId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::BindingCluster clusterBinding;
-    (void) ZCLgroupId;
-    clusterBinding.Associate(device, ZCLendpointId);
-    return clusterBinding.Bind(nullptr, nullptr, nodeId, groupId, endpointId, clusterId);
-}
-CHIP_ERROR chip_ime_AppendCommand_Binding_Unbind(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                 chip::GroupId ZCLgroupId, chip::NodeId nodeId, chip::GroupId groupId,
-                                                 chip::EndpointId endpointId, chip::ClusterId clusterId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::BindingCluster clusterBinding;
-    (void) ZCLgroupId;
-    clusterBinding.Associate(device, ZCLendpointId);
-    return clusterBinding.Unbind(nullptr, nullptr, nodeId, groupId, endpointId, clusterId);
-}
-// End of Cluster Binding
-
-// Cluster ColorControl
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveColor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                         chip::GroupId ZCLgroupId, int16_t rateX, int16_t rateY,
-                                                         uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveColor(nullptr, nullptr, rateX, rateY, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveColorTemperature(
-    chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint8_t moveMode, uint16_t rate,
-    uint16_t colorTemperatureMinimum, uint16_t colorTemperatureMaximum, uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveColorTemperature(nullptr, nullptr, moveMode, rate, colorTemperatureMinimum,
-                                                    colorTemperatureMaximum, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveHue(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                       chip::GroupId ZCLgroupId, uint8_t moveMode, uint8_t rate,
-                                                       uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveHue(nullptr, nullptr, moveMode, rate, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveSaturation(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                              chip::GroupId ZCLgroupId, uint8_t moveMode, uint8_t rate,
-                                                              uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveSaturation(nullptr, nullptr, moveMode, rate, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToColor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                           chip::GroupId ZCLgroupId, uint16_t colorX, uint16_t colorY,
-                                                           uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveToColor(nullptr, nullptr, colorX, colorY, transitionTime, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToColorTemperature(chip::Controller::Device * device,
-                                                                      chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                      uint16_t colorTemperature, uint16_t transitionTime,
-                                                                      uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveToColorTemperature(nullptr, nullptr, colorTemperature, transitionTime, optionsMask,
-                                                      optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToHue(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                         chip::GroupId ZCLgroupId, uint8_t hue, uint8_t direction,
-                                                         uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveToHue(nullptr, nullptr, hue, direction, transitionTime, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToHueAndSaturation(chip::Controller::Device * device,
-                                                                      chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                      uint8_t hue, uint8_t saturation, uint16_t transitionTime,
-                                                                      uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveToHueAndSaturation(nullptr, nullptr, hue, saturation, transitionTime, optionsMask,
-                                                      optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToSaturation(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                                chip::GroupId ZCLgroupId, uint8_t saturation,
-                                                                uint16_t transitionTime, uint8_t optionsMask,
-                                                                uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.MoveToSaturation(nullptr, nullptr, saturation, transitionTime, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_StepColor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                         chip::GroupId ZCLgroupId, int16_t stepX, int16_t stepY,
-                                                         uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.StepColor(nullptr, nullptr, stepX, stepY, transitionTime, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_StepColorTemperature(chip::Controller::Device * device,
-                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                    uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime,
-                                                                    uint16_t colorTemperatureMinimum,
-                                                                    uint16_t colorTemperatureMaximum, uint8_t optionsMask,
-                                                                    uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.StepColorTemperature(nullptr, nullptr, stepMode, stepSize, transitionTime, colorTemperatureMinimum,
-                                                    colorTemperatureMaximum, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_StepHue(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                       chip::GroupId ZCLgroupId, uint8_t stepMode, uint8_t stepSize,
-                                                       uint8_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.StepHue(nullptr, nullptr, stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_StepSaturation(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                              chip::GroupId ZCLgroupId, uint8_t stepMode, uint8_t stepSize,
-                                                              uint8_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.StepSaturation(nullptr, nullptr, stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_ColorControl_StopMoveStep(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                            chip::GroupId ZCLgroupId, uint8_t optionsMask, uint8_t optionsOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ColorControlCluster clusterColorControl;
-    (void) ZCLgroupId;
-    clusterColorControl.Associate(device, ZCLendpointId);
-    return clusterColorControl.StopMoveStep(nullptr, nullptr, optionsMask, optionsOverride);
-}
-// End of Cluster ColorControl
-
-// Cluster DoorLock
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearAllPins(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                        chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.ClearAllPins(nullptr, nullptr);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearAllRfids(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                         chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.ClearAllRfids(nullptr, nullptr);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearHolidaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                                chip::GroupId ZCLgroupId, uint8_t scheduleId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.ClearHolidaySchedule(nullptr, nullptr, scheduleId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearPin(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                    chip::GroupId ZCLgroupId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.ClearPin(nullptr, nullptr, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearRfid(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                     chip::GroupId ZCLgroupId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.ClearRfid(nullptr, nullptr, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearWeekdaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                                chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.ClearWeekdaySchedule(nullptr, nullptr, scheduleId, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearYeardaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                                chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.ClearYeardaySchedule(nullptr, nullptr, scheduleId, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetHolidaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.GetHolidaySchedule(nullptr, nullptr, scheduleId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetLogRecord(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                        chip::GroupId ZCLgroupId, uint16_t logIndex)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.GetLogRecord(nullptr, nullptr, logIndex);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetPin(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                  chip::GroupId ZCLgroupId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.GetPin(nullptr, nullptr, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetRfid(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                   chip::GroupId ZCLgroupId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.GetRfid(nullptr, nullptr, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetUserType(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                       chip::GroupId ZCLgroupId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.GetUserType(nullptr, nullptr, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetWeekdaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.GetWeekdaySchedule(nullptr, nullptr, scheduleId, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetYeardaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.GetYeardaySchedule(nullptr, nullptr, scheduleId, userId);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_LockDoor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                    chip::GroupId ZCLgroupId, const uint8_t * pin, uint32_t pin_Len)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.LockDoor(nullptr, nullptr, chip::ByteSpan(pin, pin_Len));
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetHolidaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint32_t localStartTime,
-                                                              uint32_t localEndTime, uint8_t operatingModeDuringHoliday)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.SetHolidaySchedule(nullptr, nullptr, scheduleId, localStartTime, localEndTime,
-                                              operatingModeDuringHoliday);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetPin(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                  chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userStatus, uint8_t userType,
-                                                  const uint8_t * pin, uint32_t pin_Len)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.SetPin(nullptr, nullptr, userId, userStatus, userType, chip::ByteSpan(pin, pin_Len));
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetRfid(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                   chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userStatus, uint8_t userType,
-                                                   const uint8_t * id, uint32_t id_Len)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.SetRfid(nullptr, nullptr, userId, userStatus, userType, chip::ByteSpan(id, id_Len));
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetUserType(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                       chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userType)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.SetUserType(nullptr, nullptr, userId, userType);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetWeekdaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId,
-                                                              uint8_t daysMask, uint8_t startHour, uint8_t startMinute,
-                                                              uint8_t endHour, uint8_t endMinute)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.SetWeekdaySchedule(nullptr, nullptr, scheduleId, userId, daysMask, startHour, startMinute, endHour,
-                                              endMinute);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetYeardaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId,
-                                                              uint32_t localStartTime, uint32_t localEndTime)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.SetYeardaySchedule(nullptr, nullptr, scheduleId, userId, localStartTime, localEndTime);
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_UnlockDoor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                      chip::GroupId ZCLgroupId, const uint8_t * pin, uint32_t pin_Len)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.UnlockDoor(nullptr, nullptr, chip::ByteSpan(pin, pin_Len));
-}
-CHIP_ERROR chip_ime_AppendCommand_DoorLock_UnlockWithTimeout(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                             chip::GroupId ZCLgroupId, uint16_t timeoutInSeconds,
-                                                             const uint8_t * pin, uint32_t pin_Len)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::DoorLockCluster clusterDoorLock;
-    (void) ZCLgroupId;
-    clusterDoorLock.Associate(device, ZCLendpointId);
-    return clusterDoorLock.UnlockWithTimeout(nullptr, nullptr, timeoutInSeconds, chip::ByteSpan(pin, pin_Len));
-}
-// End of Cluster DoorLock
-
-// Cluster GeneralCommissioning
-CHIP_ERROR chip_ime_AppendCommand_GeneralCommissioning_ArmFailSafe(chip::Controller::Device * device,
-                                                                   chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                   uint16_t expiryLengthSeconds, uint64_t breadcrumb,
-                                                                   uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GeneralCommissioningCluster clusterGeneralCommissioning;
-    (void) ZCLgroupId;
-    clusterGeneralCommissioning.Associate(device, ZCLendpointId);
-    return clusterGeneralCommissioning.ArmFailSafe(nullptr, nullptr, expiryLengthSeconds, breadcrumb, timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_GeneralCommissioning_CommissioningComplete(chip::Controller::Device * device,
-                                                                             chip::EndpointId ZCLendpointId,
-                                                                             chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GeneralCommissioningCluster clusterGeneralCommissioning;
-    (void) ZCLgroupId;
-    clusterGeneralCommissioning.Associate(device, ZCLendpointId);
-    return clusterGeneralCommissioning.CommissioningComplete(nullptr, nullptr);
-}
-CHIP_ERROR chip_ime_AppendCommand_GeneralCommissioning_SetFabric(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                                 chip::GroupId ZCLgroupId, const uint8_t * fabricId,
-                                                                 uint32_t fabricId_Len, const uint8_t * fabricSecret,
-                                                                 uint32_t fabricSecret_Len, uint64_t breadcrumb, uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GeneralCommissioningCluster clusterGeneralCommissioning;
-    (void) ZCLgroupId;
-    clusterGeneralCommissioning.Associate(device, ZCLendpointId);
-    return clusterGeneralCommissioning.SetFabric(nullptr, nullptr, chip::ByteSpan(fabricId, fabricId_Len),
-                                                 chip::ByteSpan(fabricSecret, fabricSecret_Len), breadcrumb, timeoutMs);
-}
-// End of Cluster GeneralCommissioning
-
-// Cluster GroupKeyManagement
-// End of Cluster GroupKeyManagement
-
-// Cluster Groups
-CHIP_ERROR chip_ime_AppendCommand_Groups_AddGroup(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                  chip::GroupId ZCLgroupId, uint16_t groupId, const uint8_t * groupName,
-                                                  uint32_t groupName_Len)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GroupsCluster clusterGroups;
-    (void) ZCLgroupId;
-    clusterGroups.Associate(device, ZCLendpointId);
-    return clusterGroups.AddGroup(nullptr, nullptr, groupId, chip::ByteSpan(groupName, groupName_Len));
-}
-CHIP_ERROR chip_ime_AppendCommand_Groups_AddGroupIfIdentifying(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                               chip::GroupId ZCLgroupId, uint16_t groupId,
-                                                               const uint8_t * groupName, uint32_t groupName_Len)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GroupsCluster clusterGroups;
-    (void) ZCLgroupId;
-    clusterGroups.Associate(device, ZCLendpointId);
-    return clusterGroups.AddGroupIfIdentifying(nullptr, nullptr, groupId, chip::ByteSpan(groupName, groupName_Len));
-}
-CHIP_ERROR chip_ime_AppendCommand_Groups_GetGroupMembership(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                            chip::GroupId ZCLgroupId, uint8_t groupCount, uint16_t groupList)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GroupsCluster clusterGroups;
-    (void) ZCLgroupId;
-    clusterGroups.Associate(device, ZCLendpointId);
-    return clusterGroups.GetGroupMembership(nullptr, nullptr, groupCount, groupList);
-}
-CHIP_ERROR chip_ime_AppendCommand_Groups_RemoveAllGroups(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                         chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GroupsCluster clusterGroups;
-    (void) ZCLgroupId;
-    clusterGroups.Associate(device, ZCLendpointId);
-    return clusterGroups.RemoveAllGroups(nullptr, nullptr);
-}
-CHIP_ERROR chip_ime_AppendCommand_Groups_RemoveGroup(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                     chip::GroupId ZCLgroupId, uint16_t groupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GroupsCluster clusterGroups;
-    (void) ZCLgroupId;
-    clusterGroups.Associate(device, ZCLendpointId);
-    return clusterGroups.RemoveGroup(nullptr, nullptr, groupId);
-}
-CHIP_ERROR chip_ime_AppendCommand_Groups_ViewGroup(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                   chip::GroupId ZCLgroupId, uint16_t groupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::GroupsCluster clusterGroups;
-    (void) ZCLgroupId;
-    clusterGroups.Associate(device, ZCLendpointId);
-    return clusterGroups.ViewGroup(nullptr, nullptr, groupId);
-}
-// End of Cluster Groups
-
-// Cluster IasZone
-// End of Cluster IasZone
-
-// Cluster Identify
-CHIP_ERROR chip_ime_AppendCommand_Identify_Identify(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                    chip::GroupId ZCLgroupId, uint16_t identifyTime)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::IdentifyCluster clusterIdentify;
-    (void) ZCLgroupId;
-    clusterIdentify.Associate(device, ZCLendpointId);
-    return clusterIdentify.Identify(nullptr, nullptr, identifyTime);
-}
-CHIP_ERROR chip_ime_AppendCommand_Identify_IdentifyQuery(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                         chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::IdentifyCluster clusterIdentify;
-    (void) ZCLgroupId;
-    clusterIdentify.Associate(device, ZCLendpointId);
-    return clusterIdentify.IdentifyQuery(nullptr, nullptr);
-}
-// End of Cluster Identify
-
-// Cluster LevelControl
-CHIP_ERROR chip_ime_AppendCommand_LevelControl_Move(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                    chip::GroupId ZCLgroupId, uint8_t moveMode, uint8_t rate, uint8_t optionMask,
-                                                    uint8_t optionOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LevelControlCluster clusterLevelControl;
-    (void) ZCLgroupId;
-    clusterLevelControl.Associate(device, ZCLendpointId);
-    return clusterLevelControl.Move(nullptr, nullptr, moveMode, rate, optionMask, optionOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_LevelControl_MoveToLevel(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                           chip::GroupId ZCLgroupId, uint8_t level, uint16_t transitionTime,
-                                                           uint8_t optionMask, uint8_t optionOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LevelControlCluster clusterLevelControl;
-    (void) ZCLgroupId;
-    clusterLevelControl.Associate(device, ZCLendpointId);
-    return clusterLevelControl.MoveToLevel(nullptr, nullptr, level, transitionTime, optionMask, optionOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_LevelControl_MoveToLevelWithOnOff(chip::Controller::Device * device,
-                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                    uint8_t level, uint16_t transitionTime)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LevelControlCluster clusterLevelControl;
-    (void) ZCLgroupId;
-    clusterLevelControl.Associate(device, ZCLendpointId);
-    return clusterLevelControl.MoveToLevelWithOnOff(nullptr, nullptr, level, transitionTime);
-}
-CHIP_ERROR chip_ime_AppendCommand_LevelControl_MoveWithOnOff(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                             chip::GroupId ZCLgroupId, uint8_t moveMode, uint8_t rate)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LevelControlCluster clusterLevelControl;
-    (void) ZCLgroupId;
-    clusterLevelControl.Associate(device, ZCLendpointId);
-    return clusterLevelControl.MoveWithOnOff(nullptr, nullptr, moveMode, rate);
-}
-CHIP_ERROR chip_ime_AppendCommand_LevelControl_Step(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                    chip::GroupId ZCLgroupId, uint8_t stepMode, uint8_t stepSize,
-                                                    uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LevelControlCluster clusterLevelControl;
-    (void) ZCLgroupId;
-    clusterLevelControl.Associate(device, ZCLendpointId);
-    return clusterLevelControl.Step(nullptr, nullptr, stepMode, stepSize, transitionTime, optionMask, optionOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_LevelControl_StepWithOnOff(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                             chip::GroupId ZCLgroupId, uint8_t stepMode, uint8_t stepSize,
-                                                             uint16_t transitionTime)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LevelControlCluster clusterLevelControl;
-    (void) ZCLgroupId;
-    clusterLevelControl.Associate(device, ZCLendpointId);
-    return clusterLevelControl.StepWithOnOff(nullptr, nullptr, stepMode, stepSize, transitionTime);
-}
-CHIP_ERROR chip_ime_AppendCommand_LevelControl_Stop(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                    chip::GroupId ZCLgroupId, uint8_t optionMask, uint8_t optionOverride)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LevelControlCluster clusterLevelControl;
-    (void) ZCLgroupId;
-    clusterLevelControl.Associate(device, ZCLendpointId);
-    return clusterLevelControl.Stop(nullptr, nullptr, optionMask, optionOverride);
-}
-CHIP_ERROR chip_ime_AppendCommand_LevelControl_StopWithOnOff(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                             chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LevelControlCluster clusterLevelControl;
-    (void) ZCLgroupId;
-    clusterLevelControl.Associate(device, ZCLendpointId);
-    return clusterLevelControl.StopWithOnOff(nullptr, nullptr);
-}
-// End of Cluster LevelControl
-
-// Cluster LowPower
-CHIP_ERROR chip_ime_AppendCommand_LowPower_Sleep(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                 chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::LowPowerCluster clusterLowPower;
-    (void) ZCLgroupId;
-    clusterLowPower.Associate(device, ZCLendpointId);
-    return clusterLowPower.Sleep(nullptr, nullptr);
-}
-// End of Cluster LowPower
-
-// Cluster NetworkCommissioning
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_AddThreadNetwork(chip::Controller::Device * device,
-                                                                        chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                        const uint8_t * operationalDataset,
-                                                                        uint32_t operationalDataset_Len, uint64_t breadcrumb,
-                                                                        uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.AddThreadNetwork(
-        nullptr, nullptr, chip::ByteSpan(operationalDataset, operationalDataset_Len), breadcrumb, timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_AddWiFiNetwork(chip::Controller::Device * device,
-                                                                      chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                      const uint8_t * ssid, uint32_t ssid_Len,
-                                                                      const uint8_t * credentials, uint32_t credentials_Len,
-                                                                      uint64_t breadcrumb, uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.AddWiFiNetwork(nullptr, nullptr, chip::ByteSpan(ssid, ssid_Len),
-                                                      chip::ByteSpan(credentials, credentials_Len), breadcrumb, timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_DisableNetwork(chip::Controller::Device * device,
-                                                                      chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                      const uint8_t * networkID, uint32_t networkID_Len,
-                                                                      uint64_t breadcrumb, uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.DisableNetwork(nullptr, nullptr, chip::ByteSpan(networkID, networkID_Len), breadcrumb,
-                                                      timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_EnableNetwork(chip::Controller::Device * device,
-                                                                     chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                     const uint8_t * networkID, uint32_t networkID_Len,
-                                                                     uint64_t breadcrumb, uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.EnableNetwork(nullptr, nullptr, chip::ByteSpan(networkID, networkID_Len), breadcrumb,
-                                                     timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_GetLastNetworkCommissioningResult(chip::Controller::Device * device,
-                                                                                         chip::EndpointId ZCLendpointId,
-                                                                                         chip::GroupId ZCLgroupId,
-                                                                                         uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.GetLastNetworkCommissioningResult(nullptr, nullptr, timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_RemoveNetwork(chip::Controller::Device * device,
-                                                                     chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                     const uint8_t * networkID, uint32_t networkID_Len,
-                                                                     uint64_t breadcrumb, uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.RemoveNetwork(nullptr, nullptr, chip::ByteSpan(networkID, networkID_Len), breadcrumb,
-                                                     timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_ScanNetworks(chip::Controller::Device * device,
-                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                    const uint8_t * ssid, uint32_t ssid_Len, uint64_t breadcrumb,
-                                                                    uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.ScanNetworks(nullptr, nullptr, chip::ByteSpan(ssid, ssid_Len), breadcrumb, timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_UpdateThreadNetwork(chip::Controller::Device * device,
-                                                                           chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                           const uint8_t * operationalDataset,
-                                                                           uint32_t operationalDataset_Len, uint64_t breadcrumb,
-                                                                           uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.UpdateThreadNetwork(
-        nullptr, nullptr, chip::ByteSpan(operationalDataset, operationalDataset_Len), breadcrumb, timeoutMs);
-}
-CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_UpdateWiFiNetwork(chip::Controller::Device * device,
-                                                                         chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
-                                                                         const uint8_t * ssid, uint32_t ssid_Len,
-                                                                         const uint8_t * credentials, uint32_t credentials_Len,
-                                                                         uint64_t breadcrumb, uint32_t timeoutMs)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::NetworkCommissioningCluster clusterNetworkCommissioning;
-    (void) ZCLgroupId;
-    clusterNetworkCommissioning.Associate(device, ZCLendpointId);
-    return clusterNetworkCommissioning.UpdateWiFiNetwork(nullptr, nullptr, chip::ByteSpan(ssid, ssid_Len),
-                                                         chip::ByteSpan(credentials, credentials_Len), breadcrumb, timeoutMs);
-}
-// End of Cluster NetworkCommissioning
-
-// Cluster OnOff
-CHIP_ERROR chip_ime_AppendCommand_OnOff_Off(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                            chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::OnOffCluster clusterOnOff;
-    (void) ZCLgroupId;
-    clusterOnOff.Associate(device, ZCLendpointId);
-    return clusterOnOff.Off(nullptr, nullptr);
-}
-CHIP_ERROR chip_ime_AppendCommand_OnOff_On(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                           chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::OnOffCluster clusterOnOff;
-    (void) ZCLgroupId;
-    clusterOnOff.Associate(device, ZCLendpointId);
-    return clusterOnOff.On(nullptr, nullptr);
-}
-CHIP_ERROR chip_ime_AppendCommand_OnOff_Toggle(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                               chip::GroupId ZCLgroupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::OnOffCluster clusterOnOff;
-    (void) ZCLgroupId;
-    clusterOnOff.Associate(device, ZCLendpointId);
-    return clusterOnOff.Toggle(nullptr, nullptr);
-}
-// End of Cluster OnOff
-
-// Cluster Scenes
-CHIP_ERROR chip_ime_AppendCommand_Scenes_AddScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                  chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId,
-                                                  uint16_t transitionTime, const uint8_t * sceneName, uint32_t sceneName_Len,
-                                                  chip::ClusterId clusterId, uint8_t length, uint8_t value)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ScenesCluster clusterScenes;
-    (void) ZCLgroupId;
-    clusterScenes.Associate(device, ZCLendpointId);
-    return clusterScenes.AddScene(nullptr, nullptr, groupId, sceneId, transitionTime, chip::ByteSpan(sceneName, sceneName_Len),
-                                  clusterId, length, value);
-}
-CHIP_ERROR chip_ime_AppendCommand_Scenes_GetSceneMembership(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                            chip::GroupId ZCLgroupId, uint16_t groupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ScenesCluster clusterScenes;
-    (void) ZCLgroupId;
-    clusterScenes.Associate(device, ZCLendpointId);
-    return clusterScenes.GetSceneMembership(nullptr, nullptr, groupId);
-}
-CHIP_ERROR chip_ime_AppendCommand_Scenes_RecallScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                     chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId,
-                                                     uint16_t transitionTime)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ScenesCluster clusterScenes;
-    (void) ZCLgroupId;
-    clusterScenes.Associate(device, ZCLendpointId);
-    return clusterScenes.RecallScene(nullptr, nullptr, groupId, sceneId, transitionTime);
-}
-CHIP_ERROR chip_ime_AppendCommand_Scenes_RemoveAllScenes(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                         chip::GroupId ZCLgroupId, uint16_t groupId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ScenesCluster clusterScenes;
-    (void) ZCLgroupId;
-    clusterScenes.Associate(device, ZCLendpointId);
-    return clusterScenes.RemoveAllScenes(nullptr, nullptr, groupId);
-}
-CHIP_ERROR chip_ime_AppendCommand_Scenes_RemoveScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                     chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ScenesCluster clusterScenes;
-    (void) ZCLgroupId;
-    clusterScenes.Associate(device, ZCLendpointId);
-    return clusterScenes.RemoveScene(nullptr, nullptr, groupId, sceneId);
-}
-CHIP_ERROR chip_ime_AppendCommand_Scenes_StoreScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                    chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ScenesCluster clusterScenes;
-    (void) ZCLgroupId;
-    clusterScenes.Associate(device, ZCLendpointId);
-    return clusterScenes.StoreScene(nullptr, nullptr, groupId, sceneId);
-}
-CHIP_ERROR chip_ime_AppendCommand_Scenes_ViewScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
-                                                   chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId)
-{
-    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
-    chip::Controller::ScenesCluster clusterScenes;
-    (void) ZCLgroupId;
-    clusterScenes.Associate(device, ZCLendpointId);
-    return clusterScenes.ViewScene(nullptr, nullptr, groupId, sceneId);
-}
-// End of Cluster Scenes
-
-// Cluster TemperatureMeasurement
-// End of Cluster TemperatureMeasurement
-}
index 6972f1c..47b6424 100644 (file)
@@ -137,7 +137,8 @@ CHIP_ERROR pychip_DeviceController_NewDeviceController(chip::Controller::DeviceC
     {
         localDeviceId = kDefaultLocalDeviceId;
     }
-    SuccessOrExit(err = (*outDevCtrl)->Init(localDeviceId, &sStorageDelegate, &sPairingDelegate));
+    SuccessOrExit(
+        err = (*outDevCtrl)->Init(localDeviceId, ControllerInitParams{ .storageDelegate = &sStorageDelegate }, &sPairingDelegate));
     SuccessOrExit(err = (*outDevCtrl)->ServiceEvents());
 
 exit:
index 9b03894..ad77216 100644 (file)
@@ -129,6 +129,7 @@ try:
             'chip.ble',
             'chip.ble.commissioning',
             'chip.configuration',
+            'chip.clusters',
             'chip.exceptions',
             'chip.internal',
             'chip.logging',
index 5967bcb..5de5b29 100755 (executable)
@@ -175,6 +175,7 @@ class DeviceMgrCmd(Cmd):
         "connect",
         "resolve",
         "zcl",
+        "zclread",
 
         "set-pairing-wifi-credential",
         "set-pairing-thread-credential",
@@ -431,13 +432,13 @@ class DeviceMgrCmd(Cmd):
         """
         try:
             args = shlex.split(line)
+            all_commands = self.devCtrl.ZCLCommandList()
             if len(args) == 1 and args[0] == '?':
-                print(self.devCtrl.ZCLList().keys())
+                print('\n'.join(all_commands.keys()))
             elif len(args) == 2 and args[0] == '?':
-                cluster = self.devCtrl.ZCLList().get(args[1], None)
-                if not cluster:
+                if args[1] not in all_commands:
                     raise exceptions.UnknownCluster(args[1])
-                for commands in cluster.items():
+                for commands in all_commands.get(args[1]).items():
                     args = ", ".join(["{}: {}".format(argName, argType)
                                       for argName, argType in commands[1].items()])
                     print(commands[0])
@@ -446,10 +447,9 @@ class DeviceMgrCmd(Cmd):
                     else:
                         print("  <no arguments>")
             elif len(args) > 4:
-                cluster = self.devCtrl.ZCLList().get(args[0], None)
-                if not cluster:
+                if args[0] not in all_commands:
                     raise exceptions.UnknownCluster(args[0])
-                command = cluster.get(args[1], None)
+                command = all_commands.get(args[0]).get(args[1], None)
                 # When command takes no arguments, (not command) is True
                 if command == None:
                     raise exceptions.UnknownCommand(args[0], args[1])
@@ -464,6 +464,33 @@ class DeviceMgrCmd(Cmd):
             print("An exception occurred during processing input:")
             print(str(ex))
 
+    def do_zclread(self, line):
+        """
+        To read ZCL attribute:
+        zclread <cluster> <attribute> <nodeid> <endpoint> <groupid>
+        """
+        try:
+            args = shlex.split(line)
+            all_attrs = self.devCtrl.ZCLAttributeList()
+            if len(args) == 1 and args[0] == '?':
+                print('\n'.join(all_attrs.keys()))
+            elif len(args) == 2 and args[0] == '?':
+                if args[1] not in all_attrs:
+                    raise exceptions.UnknownCluster(args[1])
+                print('\n'.join(all_attrs.get(args[1])))
+            elif len(args) == 5:
+                if args[0] not in all_attrs:
+                    raise exceptions.UnknownCluster(args[0])
+                self.devCtrl.ZCLReadAttribute(args[0], args[1], int(args[2]), int(args[3]), int(args[4]))
+            else:
+                self.do_help("zclread")
+        except exceptions.ChipStackException as ex:
+            print("An exception occurred during reading ZCL attribute:")
+            print(str(ex))
+        except Exception as ex:
+            print("An exception occurred during processing input:")
+            print(str(ex))
+
     def do_setpairingwificredential(self, line):
         """
         set-pairing-wifi-credential <ssid> <password>
index 1f14fde..bbd8494 100644 (file)
@@ -31,7 +31,7 @@ import time
 from threading import Thread
 from ctypes import *
 from .ChipStack import *
-from .ChipCluster import *
+from .clusters.CHIPClusters import *
 import enum
 
 
@@ -84,7 +84,7 @@ class ChipDeviceController(object):
         self.addressUpdater = addressUpdater
         self._ChipStack.devCtrl = devCtrl
 
-        self._Cluster = ChipCluster(self._ChipStack)
+        self._Cluster = ChipClusters(self._ChipStack)
         self._Cluster.InitLib(self._dmLib)
 
         def HandleKeyExchangeComplete(err):
@@ -170,8 +170,19 @@ class ChipDeviceController(object):
 
         self._Cluster.SendCommand(device, cluster, command, endpoint, groupid, args)
 
-    def ZCLList(self):
-        return self._Cluster.ListClusters()
+    def ZCLReadAttribute(self, cluster, attribute, nodeid, endpoint, groupid):
+        device = c_void_p(None)
+        self._ChipStack.Call(
+            lambda: self._dmLib.pychip_GetDeviceByNodeId(self.devCtrl, nodeid, pointer(device))
+        )
+
+        self._Cluster.ReadAttribute(device, cluster, attribute, endpoint, groupid)
+
+    def ZCLCommandList(self):
+        return self._Cluster.ListClusterCommands()
+
+    def ZCLAttributeList(self):
+        return self._Cluster.ListClusterAttributes()
 
     def SetLogFilter(self, category):
         if category < 0 or category > pow(2, 8):
diff --git a/src/controller/python/chip/clusters/CHIPClusters.cpp b/src/controller/python/chip/clusters/CHIPClusters.cpp
new file mode 100644 (file)
index 0000000..95e52b4
--- /dev/null
@@ -0,0 +1,1937 @@
+/*
+ *
+ *    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.
+ */
+
+// THIS FILE IS GENERATED BY ZAP
+
+#include <core/CHIPCore.h>
+
+#include <app/CommandSender.h>
+#include <app/InteractionModelEngine.h>
+#include <lib/support/Span.h>
+
+#include <controller/CHIPClusters.h>
+#include <controller/CHIPDevice.h>
+
+using namespace chip;
+using namespace chip::app;
+
+extern "C" {
+
+// Cluster ApplicationBasic
+
+CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_VendorName(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ApplicationBasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeVendorName(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_VendorId(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ApplicationBasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeVendorId(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_ApplicationName(chip::Controller::Device * device,
+                                                                   chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ApplicationBasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeApplicationName(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_ProductId(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                             chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ApplicationBasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeProductId(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_ApplicationId(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ApplicationBasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeApplicationId(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_CatalogVendorId(chip::Controller::Device * device,
+                                                                   chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ApplicationBasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCatalogVendorId(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_ApplicationSatus(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ApplicationBasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeApplicationSatus(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_ClusterRevision(chip::Controller::Device * device,
+                                                                   chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ApplicationBasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster ApplicationBasic
+// Cluster BarrierControl
+
+CHIP_ERROR chip_ime_AppendCommand_BarrierControl_BarrierControlGoToPercent(chip::Controller::Device * device,
+                                                                           chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                           uint8_t percentOpen)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BarrierControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.BarrierControlGoToPercent(nullptr, nullptr, percentOpen);
+}
+CHIP_ERROR chip_ime_AppendCommand_BarrierControl_BarrierControlStop(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BarrierControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.BarrierControlStop(nullptr, nullptr);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_BarrierControl_BarrierMovingState(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BarrierControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeBarrierMovingState(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_BarrierControl_BarrierSafetyStatus(chip::Controller::Device * device,
+                                                                     chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BarrierControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeBarrierSafetyStatus(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_BarrierControl_BarrierCapabilities(chip::Controller::Device * device,
+                                                                     chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BarrierControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeBarrierCapabilities(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_BarrierControl_BarrierPosition(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BarrierControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeBarrierPosition(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_BarrierControl_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BarrierControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster BarrierControl
+// Cluster Basic
+
+CHIP_ERROR chip_ime_AppendCommand_Basic_MfgSpecificPing(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MfgSpecificPing(nullptr, nullptr);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_Basic_InteractionModelVersion(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeInteractionModelVersion(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_VendorName(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                   chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeVendorName(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_VendorID(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeVendorID(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_ProductName(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeProductName(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_ProductID(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                  chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeProductID(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_UserLabel(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                  chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeUserLabel(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_Location(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeLocation(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_HardwareVersion(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeHardwareVersion(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_HardwareVersionString(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeHardwareVersionString(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_SoftwareVersion(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeSoftwareVersion(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_SoftwareVersionString(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeSoftwareVersionString(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Basic_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BasicCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster Basic
+// Cluster Binding
+
+CHIP_ERROR chip_ime_AppendCommand_Binding_Bind(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                               chip::GroupId ZCLgroupId, chip::NodeId nodeId, chip::GroupId groupId,
+                                               chip::EndpointId endpointId, chip::ClusterId clusterId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BindingCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Bind(nullptr, nullptr, nodeId, groupId, endpointId, clusterId);
+}
+CHIP_ERROR chip_ime_AppendCommand_Binding_Unbind(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                 chip::GroupId ZCLgroupId, chip::NodeId nodeId, chip::GroupId groupId,
+                                                 chip::EndpointId endpointId, chip::ClusterId clusterId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BindingCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Unbind(nullptr, nullptr, nodeId, groupId, endpointId, clusterId);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_Binding_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                          chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::BindingCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster Binding
+// Cluster ColorControl
+
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveColor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId, int16_t rateX, int16_t rateY,
+                                                         uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveColor(nullptr, nullptr, rateX, rateY, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveColorTemperature(
+    chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint8_t moveMode, uint16_t rate,
+    uint16_t colorTemperatureMinimum, uint16_t colorTemperatureMaximum, uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveColorTemperature(nullptr, nullptr, moveMode, rate, colorTemperatureMinimum, colorTemperatureMaximum,
+                                        optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveHue(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                       chip::GroupId ZCLgroupId, uint8_t moveMode, uint8_t rate,
+                                                       uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveHue(nullptr, nullptr, moveMode, rate, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveSaturation(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId, uint8_t moveMode, uint8_t rate,
+                                                              uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveSaturation(nullptr, nullptr, moveMode, rate, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToColor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                           chip::GroupId ZCLgroupId, uint16_t colorX, uint16_t colorY,
+                                                           uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveToColor(nullptr, nullptr, colorX, colorY, transitionTime, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToColorTemperature(chip::Controller::Device * device,
+                                                                      chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                      uint16_t colorTemperature, uint16_t transitionTime,
+                                                                      uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveToColorTemperature(nullptr, nullptr, colorTemperature, transitionTime, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToHue(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId, uint8_t hue, uint8_t direction,
+                                                         uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveToHue(nullptr, nullptr, hue, direction, transitionTime, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToHueAndSaturation(chip::Controller::Device * device,
+                                                                      chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                      uint8_t hue, uint8_t saturation, uint16_t transitionTime,
+                                                                      uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveToHueAndSaturation(nullptr, nullptr, hue, saturation, transitionTime, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_MoveToSaturation(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                chip::GroupId ZCLgroupId, uint8_t saturation,
+                                                                uint16_t transitionTime, uint8_t optionsMask,
+                                                                uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveToSaturation(nullptr, nullptr, saturation, transitionTime, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_StepColor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId, int16_t stepX, int16_t stepY,
+                                                         uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.StepColor(nullptr, nullptr, stepX, stepY, transitionTime, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_StepColorTemperature(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                    uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime,
+                                                                    uint16_t colorTemperatureMinimum,
+                                                                    uint16_t colorTemperatureMaximum, uint8_t optionsMask,
+                                                                    uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.StepColorTemperature(nullptr, nullptr, stepMode, stepSize, transitionTime, colorTemperatureMinimum,
+                                        colorTemperatureMaximum, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_StepHue(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                       chip::GroupId ZCLgroupId, uint8_t stepMode, uint8_t stepSize,
+                                                       uint8_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.StepHue(nullptr, nullptr, stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_StepSaturation(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId, uint8_t stepMode, uint8_t stepSize,
+                                                              uint8_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.StepSaturation(nullptr, nullptr, stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_ColorControl_StopMoveStep(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId, uint8_t optionsMask, uint8_t optionsOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.StopMoveStep(nullptr, nullptr, optionsMask, optionsOverride);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_CurrentHue(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                          chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCurrentHue(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_CurrentSaturation(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCurrentSaturation(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_RemainingTime(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                             chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeRemainingTime(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_CurrentX(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCurrentX(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_CurrentY(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCurrentY(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_DriftCompensation(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeDriftCompensation(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_CompensationText(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCompensationText(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorTemperature(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorTemperature(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorMode(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorMode(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorControlOptions(chip::Controller::Device * device,
+                                                                   chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorControlOptions(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_NumberOfPrimaries(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeNumberOfPrimaries(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary1X(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary1X(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary1Y(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary1Y(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary1Intensity(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary1Intensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary2X(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary2X(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary2Y(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary2Y(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary2Intensity(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary2Intensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary3X(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary3X(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary3Y(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary3Y(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary3Intensity(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary3Intensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary4X(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary4X(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary4Y(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary4Y(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary4Intensity(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary4Intensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary5X(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary5X(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary5Y(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary5Y(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary5Intensity(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary5Intensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary6X(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary6X(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary6Y(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary6Y(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_Primary6Intensity(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributePrimary6Intensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_WhitePointX(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                           chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeWhitePointX(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_WhitePointY(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                           chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeWhitePointY(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointRX(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointRX(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointRY(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointRY(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointRIntensity(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointRIntensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointGX(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointGX(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointGY(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointGY(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointGIntensity(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointGIntensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointBX(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointBX(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointBY(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointBY(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorPointBIntensity(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorPointBIntensity(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_EnhancedCurrentHue(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                  chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeEnhancedCurrentHue(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_EnhancedColorMode(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeEnhancedColorMode(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorLoopActive(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                               chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorLoopActive(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorLoopDirection(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                  chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorLoopDirection(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorLoopTime(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                             chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorLoopTime(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorCapabilities(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorCapabilities(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMin(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorTempPhysicalMin(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMax(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeColorTempPhysicalMax(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_CoupleColorTempToLevelMinMireds(chip::Controller::Device * device,
+                                                                               chip::EndpointId ZCLendpointId,
+                                                                               chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCoupleColorTempToLevelMinMireds(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_StartUpColorTemperatureMireds(chip::Controller::Device * device,
+                                                                             chip::EndpointId ZCLendpointId,
+                                                                             chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeStartUpColorTemperatureMireds(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_ColorControl_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                               chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ColorControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster ColorControl
+// Cluster DoorLock
+
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearAllPins(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ClearAllPins(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearAllRfids(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ClearAllRfids(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearHolidaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                chip::GroupId ZCLgroupId, uint8_t scheduleId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ClearHolidaySchedule(nullptr, nullptr, scheduleId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearPin(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ClearPin(nullptr, nullptr, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearRfid(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                     chip::GroupId ZCLgroupId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ClearRfid(nullptr, nullptr, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearWeekdaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ClearWeekdaySchedule(nullptr, nullptr, scheduleId, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_ClearYeardaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ClearYeardaySchedule(nullptr, nullptr, scheduleId, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetHolidaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetHolidaySchedule(nullptr, nullptr, scheduleId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetLogRecord(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId, uint16_t logIndex)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetLogRecord(nullptr, nullptr, logIndex);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetPin(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                  chip::GroupId ZCLgroupId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetPin(nullptr, nullptr, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetRfid(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                   chip::GroupId ZCLgroupId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetRfid(nullptr, nullptr, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetUserType(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                       chip::GroupId ZCLgroupId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetUserType(nullptr, nullptr, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetWeekdaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetWeekdaySchedule(nullptr, nullptr, scheduleId, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetYeardaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetYeardaySchedule(nullptr, nullptr, scheduleId, userId);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_LockDoor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId, const uint8_t * pin, uint32_t pin_Len)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.LockDoor(nullptr, nullptr, chip::ByteSpan(pin, pin_Len));
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetHolidaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint32_t localStartTime,
+                                                              uint32_t localEndTime, uint8_t operatingModeDuringHoliday)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.SetHolidaySchedule(nullptr, nullptr, scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetPin(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                  chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userStatus, uint8_t userType,
+                                                  const uint8_t * pin, uint32_t pin_Len)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.SetPin(nullptr, nullptr, userId, userStatus, userType, chip::ByteSpan(pin, pin_Len));
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetRfid(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                   chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userStatus, uint8_t userType,
+                                                   const uint8_t * id, uint32_t id_Len)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.SetRfid(nullptr, nullptr, userId, userStatus, userType, chip::ByteSpan(id, id_Len));
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetUserType(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                       chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userType)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.SetUserType(nullptr, nullptr, userId, userType);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetWeekdaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId,
+                                                              uint8_t daysMask, uint8_t startHour, uint8_t startMinute,
+                                                              uint8_t endHour, uint8_t endMinute)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.SetWeekdaySchedule(nullptr, nullptr, scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetYeardaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                              chip::GroupId ZCLgroupId, uint8_t scheduleId, uint16_t userId,
+                                                              uint32_t localStartTime, uint32_t localEndTime)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.SetYeardaySchedule(nullptr, nullptr, scheduleId, userId, localStartTime, localEndTime);
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_UnlockDoor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                      chip::GroupId ZCLgroupId, const uint8_t * pin, uint32_t pin_Len)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.UnlockDoor(nullptr, nullptr, chip::ByteSpan(pin, pin_Len));
+}
+CHIP_ERROR chip_ime_AppendCommand_DoorLock_UnlockWithTimeout(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                             chip::GroupId ZCLgroupId, uint16_t timeoutInSeconds,
+                                                             const uint8_t * pin, uint32_t pin_Len)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.UnlockWithTimeout(nullptr, nullptr, timeoutInSeconds, chip::ByteSpan(pin, pin_Len));
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_DoorLock_LockState(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                     chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeLockState(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_DoorLock_LockType(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeLockType(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_DoorLock_ActuatorEnabled(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                           chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeActuatorEnabled(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_DoorLock_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                           chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::DoorLockCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster DoorLock
+// Cluster GeneralCommissioning
+
+CHIP_ERROR chip_ime_AppendCommand_GeneralCommissioning_ArmFailSafe(chip::Controller::Device * device,
+                                                                   chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                   uint16_t expiryLengthSeconds, uint64_t breadcrumb,
+                                                                   uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GeneralCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ArmFailSafe(nullptr, nullptr, expiryLengthSeconds, breadcrumb, timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_GeneralCommissioning_CommissioningComplete(chip::Controller::Device * device,
+                                                                             chip::EndpointId ZCLendpointId,
+                                                                             chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GeneralCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.CommissioningComplete(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_AppendCommand_GeneralCommissioning_SetFabric(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                 chip::GroupId ZCLgroupId, const uint8_t * fabricId,
+                                                                 uint32_t fabricId_Len, const uint8_t * fabricSecret,
+                                                                 uint32_t fabricSecret_Len, uint64_t breadcrumb, uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GeneralCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.SetFabric(nullptr, nullptr, chip::ByteSpan(fabricId, fabricId_Len),
+                             chip::ByteSpan(fabricSecret, fabricSecret_Len), breadcrumb, timeoutMs);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_GeneralCommissioning_FabricId(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GeneralCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeFabricId(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_GeneralCommissioning_Breadcrumb(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                                  chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GeneralCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeBreadcrumb(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_GeneralCommissioning_ClusterRevision(chip::Controller::Device * device,
+                                                                       chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GeneralCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster GeneralCommissioning
+// Cluster GroupKeyManagement
+
+CHIP_ERROR chip_ime_ReadAttribute_GroupKeyManagement_Groups(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupKeyManagementCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeGroups(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_GroupKeyManagement_GroupKeys(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                               chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupKeyManagementCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeGroupKeys(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_GroupKeyManagement_ClusterRevision(chip::Controller::Device * device,
+                                                                     chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupKeyManagementCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster GroupKeyManagement
+// Cluster Groups
+
+CHIP_ERROR chip_ime_AppendCommand_Groups_AddGroup(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                  chip::GroupId ZCLgroupId, uint16_t groupId, const uint8_t * groupName,
+                                                  uint32_t groupName_Len)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupsCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.AddGroup(nullptr, nullptr, groupId, chip::ByteSpan(groupName, groupName_Len));
+}
+CHIP_ERROR chip_ime_AppendCommand_Groups_AddGroupIfIdentifying(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                               chip::GroupId ZCLgroupId, uint16_t groupId,
+                                                               const uint8_t * groupName, uint32_t groupName_Len)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupsCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.AddGroupIfIdentifying(nullptr, nullptr, groupId, chip::ByteSpan(groupName, groupName_Len));
+}
+CHIP_ERROR chip_ime_AppendCommand_Groups_GetGroupMembership(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId, uint8_t groupCount, uint16_t groupList)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupsCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetGroupMembership(nullptr, nullptr, groupCount, groupList);
+}
+CHIP_ERROR chip_ime_AppendCommand_Groups_RemoveAllGroups(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupsCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.RemoveAllGroups(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_AppendCommand_Groups_RemoveGroup(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                     chip::GroupId ZCLgroupId, uint16_t groupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupsCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.RemoveGroup(nullptr, nullptr, groupId);
+}
+CHIP_ERROR chip_ime_AppendCommand_Groups_ViewGroup(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                   chip::GroupId ZCLgroupId, uint16_t groupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupsCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ViewGroup(nullptr, nullptr, groupId);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_Groups_NameSupport(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                     chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupsCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeNameSupport(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Groups_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::GroupsCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster Groups
+// Cluster IasZone
+
+CHIP_ERROR chip_ime_ReadAttribute_IasZone_ZoneState(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IasZoneCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeZoneState(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_IasZone_ZoneType(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                   chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IasZoneCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeZoneType(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_IasZone_ZoneStatus(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                     chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IasZoneCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeZoneStatus(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_IasZone_IasCieAddress(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IasZoneCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeIasCieAddress(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_IasZone_ZoneId(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IasZoneCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeZoneId(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_IasZone_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                          chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IasZoneCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster IasZone
+// Cluster Identify
+
+CHIP_ERROR chip_ime_AppendCommand_Identify_Identify(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId, uint16_t identifyTime)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IdentifyCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Identify(nullptr, nullptr, identifyTime);
+}
+CHIP_ERROR chip_ime_AppendCommand_Identify_IdentifyQuery(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IdentifyCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.IdentifyQuery(nullptr, nullptr);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_Identify_IdentifyTime(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IdentifyCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeIdentifyTime(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Identify_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                           chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::IdentifyCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster Identify
+// Cluster LevelControl
+
+CHIP_ERROR chip_ime_AppendCommand_LevelControl_Move(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId, uint8_t moveMode, uint8_t rate, uint8_t optionMask,
+                                                    uint8_t optionOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Move(nullptr, nullptr, moveMode, rate, optionMask, optionOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_LevelControl_MoveToLevel(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                           chip::GroupId ZCLgroupId, uint8_t level, uint16_t transitionTime,
+                                                           uint8_t optionMask, uint8_t optionOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveToLevel(nullptr, nullptr, level, transitionTime, optionMask, optionOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_LevelControl_MoveToLevelWithOnOff(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                    uint8_t level, uint16_t transitionTime)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveToLevelWithOnOff(nullptr, nullptr, level, transitionTime);
+}
+CHIP_ERROR chip_ime_AppendCommand_LevelControl_MoveWithOnOff(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                             chip::GroupId ZCLgroupId, uint8_t moveMode, uint8_t rate)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.MoveWithOnOff(nullptr, nullptr, moveMode, rate);
+}
+CHIP_ERROR chip_ime_AppendCommand_LevelControl_Step(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId, uint8_t stepMode, uint8_t stepSize,
+                                                    uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Step(nullptr, nullptr, stepMode, stepSize, transitionTime, optionMask, optionOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_LevelControl_StepWithOnOff(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                             chip::GroupId ZCLgroupId, uint8_t stepMode, uint8_t stepSize,
+                                                             uint16_t transitionTime)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.StepWithOnOff(nullptr, nullptr, stepMode, stepSize, transitionTime);
+}
+CHIP_ERROR chip_ime_AppendCommand_LevelControl_Stop(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId, uint8_t optionMask, uint8_t optionOverride)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Stop(nullptr, nullptr, optionMask, optionOverride);
+}
+CHIP_ERROR chip_ime_AppendCommand_LevelControl_StopWithOnOff(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                             chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.StopWithOnOff(nullptr, nullptr);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_LevelControl_CurrentLevel(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCurrentLevel(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_LevelControl_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                               chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LevelControlCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster LevelControl
+// Cluster LowPower
+
+CHIP_ERROR chip_ime_AppendCommand_LowPower_Sleep(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                 chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LowPowerCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Sleep(nullptr, nullptr);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_LowPower_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                           chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::LowPowerCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster LowPower
+// Cluster NetworkCommissioning
+
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_AddThreadNetwork(chip::Controller::Device * device,
+                                                                        chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                        const uint8_t * operationalDataset,
+                                                                        uint32_t operationalDataset_Len, uint64_t breadcrumb,
+                                                                        uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.AddThreadNetwork(nullptr, nullptr, chip::ByteSpan(operationalDataset, operationalDataset_Len), breadcrumb,
+                                    timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_AddWiFiNetwork(chip::Controller::Device * device,
+                                                                      chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                      const uint8_t * ssid, uint32_t ssid_Len,
+                                                                      const uint8_t * credentials, uint32_t credentials_Len,
+                                                                      uint64_t breadcrumb, uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.AddWiFiNetwork(nullptr, nullptr, chip::ByteSpan(ssid, ssid_Len), chip::ByteSpan(credentials, credentials_Len),
+                                  breadcrumb, timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_DisableNetwork(chip::Controller::Device * device,
+                                                                      chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                      const uint8_t * networkID, uint32_t networkID_Len,
+                                                                      uint64_t breadcrumb, uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.DisableNetwork(nullptr, nullptr, chip::ByteSpan(networkID, networkID_Len), breadcrumb, timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_EnableNetwork(chip::Controller::Device * device,
+                                                                     chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                     const uint8_t * networkID, uint32_t networkID_Len,
+                                                                     uint64_t breadcrumb, uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.EnableNetwork(nullptr, nullptr, chip::ByteSpan(networkID, networkID_Len), breadcrumb, timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_GetLastNetworkCommissioningResult(chip::Controller::Device * device,
+                                                                                         chip::EndpointId ZCLendpointId,
+                                                                                         chip::GroupId ZCLgroupId,
+                                                                                         uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetLastNetworkCommissioningResult(nullptr, nullptr, timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_RemoveNetwork(chip::Controller::Device * device,
+                                                                     chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                     const uint8_t * networkID, uint32_t networkID_Len,
+                                                                     uint64_t breadcrumb, uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.RemoveNetwork(nullptr, nullptr, chip::ByteSpan(networkID, networkID_Len), breadcrumb, timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_ScanNetworks(chip::Controller::Device * device,
+                                                                    chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                    const uint8_t * ssid, uint32_t ssid_Len, uint64_t breadcrumb,
+                                                                    uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ScanNetworks(nullptr, nullptr, chip::ByteSpan(ssid, ssid_Len), breadcrumb, timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_UpdateThreadNetwork(chip::Controller::Device * device,
+                                                                           chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                           const uint8_t * operationalDataset,
+                                                                           uint32_t operationalDataset_Len, uint64_t breadcrumb,
+                                                                           uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.UpdateThreadNetwork(nullptr, nullptr, chip::ByteSpan(operationalDataset, operationalDataset_Len), breadcrumb,
+                                       timeoutMs);
+}
+CHIP_ERROR chip_ime_AppendCommand_NetworkCommissioning_UpdateWiFiNetwork(chip::Controller::Device * device,
+                                                                         chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId,
+                                                                         const uint8_t * ssid, uint32_t ssid_Len,
+                                                                         const uint8_t * credentials, uint32_t credentials_Len,
+                                                                         uint64_t breadcrumb, uint32_t timeoutMs)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.UpdateWiFiNetwork(nullptr, nullptr, chip::ByteSpan(ssid, ssid_Len), chip::ByteSpan(credentials, credentials_Len),
+                                     breadcrumb, timeoutMs);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_NetworkCommissioning_ClusterRevision(chip::Controller::Device * device,
+                                                                       chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::NetworkCommissioningCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster NetworkCommissioning
+// Cluster OnOff
+
+CHIP_ERROR chip_ime_AppendCommand_OnOff_Off(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                            chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::OnOffCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Off(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_AppendCommand_OnOff_On(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                           chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::OnOffCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.On(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_AppendCommand_OnOff_Toggle(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                               chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::OnOffCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.Toggle(nullptr, nullptr);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_OnOff_OnOff(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                              chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::OnOffCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeOnOff(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_OnOff_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                        chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::OnOffCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster OnOff
+// Cluster Scenes
+
+CHIP_ERROR chip_ime_AppendCommand_Scenes_AddScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                  chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId,
+                                                  uint16_t transitionTime, const uint8_t * sceneName, uint32_t sceneName_Len,
+                                                  chip::ClusterId clusterId, uint8_t length, uint8_t value)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.AddScene(nullptr, nullptr, groupId, sceneId, transitionTime, chip::ByteSpan(sceneName, sceneName_Len), clusterId,
+                            length, value);
+}
+CHIP_ERROR chip_ime_AppendCommand_Scenes_GetSceneMembership(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                            chip::GroupId ZCLgroupId, uint16_t groupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.GetSceneMembership(nullptr, nullptr, groupId);
+}
+CHIP_ERROR chip_ime_AppendCommand_Scenes_RecallScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                     chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId,
+                                                     uint16_t transitionTime)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.RecallScene(nullptr, nullptr, groupId, sceneId, transitionTime);
+}
+CHIP_ERROR chip_ime_AppendCommand_Scenes_RemoveAllScenes(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId, uint16_t groupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.RemoveAllScenes(nullptr, nullptr, groupId);
+}
+CHIP_ERROR chip_ime_AppendCommand_Scenes_RemoveScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                     chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.RemoveScene(nullptr, nullptr, groupId, sceneId);
+}
+CHIP_ERROR chip_ime_AppendCommand_Scenes_StoreScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.StoreScene(nullptr, nullptr, groupId, sceneId);
+}
+CHIP_ERROR chip_ime_AppendCommand_Scenes_ViewScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                   chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ViewScene(nullptr, nullptr, groupId, sceneId);
+}
+
+CHIP_ERROR chip_ime_ReadAttribute_Scenes_SceneCount(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeSceneCount(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Scenes_CurrentScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                      chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCurrentScene(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Scenes_CurrentGroup(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                      chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeCurrentGroup(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Scenes_SceneValid(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                    chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeSceneValid(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Scenes_NameSupport(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                     chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeNameSupport(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_Scenes_ClusterRevision(chip::Controller::Device * device, chip::EndpointId ZCLendpointId,
+                                                         chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::ScenesCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster Scenes
+// Cluster TemperatureMeasurement
+
+CHIP_ERROR chip_ime_ReadAttribute_TemperatureMeasurement_MeasuredValue(chip::Controller::Device * device,
+                                                                       chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::TemperatureMeasurementCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeMeasuredValue(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_TemperatureMeasurement_MinMeasuredValue(chip::Controller::Device * device,
+                                                                          chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::TemperatureMeasurementCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeMinMeasuredValue(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_TemperatureMeasurement_MaxMeasuredValue(chip::Controller::Device * device,
+                                                                          chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::TemperatureMeasurementCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeMaxMeasuredValue(nullptr, nullptr);
+}
+CHIP_ERROR chip_ime_ReadAttribute_TemperatureMeasurement_ClusterRevision(chip::Controller::Device * device,
+                                                                         chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId)
+{
+    VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    chip::Controller::TemperatureMeasurementCluster cluster;
+    (void) ZCLgroupId;
+    cluster.Associate(device, ZCLendpointId);
+    return cluster.ReadAttributeClusterRevision(nullptr, nullptr);
+}
+
+// End of Cluster TemperatureMeasurement
+}
 '''
 
 import ctypes
-from .ChipStack import *
-from .exceptions import *
+from chip.ChipStack import *
+from chip.exceptions import *
 
 '''
 TODO(#4511): This file only sends cluster commands, should add more functions.
 '''
 
-__all__ = ["ChipCluster"]
+__all__ = ["ChipClusters"]
 
-class ChipCluster:
+class ChipClusters:
     def __init__(self, chipstack):
         self._ChipStack = chipstack
 
-    def ListClusters(self):
+    def ListClusterCommands(self):
         return {
             "ApplicationBasic": {
             },
@@ -435,243 +435,369 @@ class ChipCluster:
             },
         }
 
+    def ListClusterAttributes(self):
+        return {
+            "ApplicationBasic": [
+                "VendorName",
+                "VendorId",
+                "ApplicationName",
+                "ProductId",
+                "ApplicationId",
+                "CatalogVendorId",
+                "ApplicationSatus",
+                "ClusterRevision",
+            ],
+            "BarrierControl": [
+                "BarrierMovingState",
+                "BarrierSafetyStatus",
+                "BarrierCapabilities",
+                "BarrierPosition",
+                "ClusterRevision",
+            ],
+            "Basic": [
+                "InteractionModelVersion",
+                "VendorName",
+                "VendorID",
+                "ProductName",
+                "ProductID",
+                "UserLabel",
+                "Location",
+                "HardwareVersion",
+                "HardwareVersionString",
+                "SoftwareVersion",
+                "SoftwareVersionString",
+                "ClusterRevision",
+            ],
+            "Binding": [
+                "ClusterRevision",
+            ],
+            "ColorControl": [
+                "CurrentHue",
+                "CurrentSaturation",
+                "RemainingTime",
+                "CurrentX",
+                "CurrentY",
+                "DriftCompensation",
+                "CompensationText",
+                "ColorTemperature",
+                "ColorMode",
+                "ColorControlOptions",
+                "NumberOfPrimaries",
+                "Primary1X",
+                "Primary1Y",
+                "Primary1Intensity",
+                "Primary2X",
+                "Primary2Y",
+                "Primary2Intensity",
+                "Primary3X",
+                "Primary3Y",
+                "Primary3Intensity",
+                "Primary4X",
+                "Primary4Y",
+                "Primary4Intensity",
+                "Primary5X",
+                "Primary5Y",
+                "Primary5Intensity",
+                "Primary6X",
+                "Primary6Y",
+                "Primary6Intensity",
+                "WhitePointX",
+                "WhitePointY",
+                "ColorPointRX",
+                "ColorPointRY",
+                "ColorPointRIntensity",
+                "ColorPointGX",
+                "ColorPointGY",
+                "ColorPointGIntensity",
+                "ColorPointBX",
+                "ColorPointBY",
+                "ColorPointBIntensity",
+                "EnhancedCurrentHue",
+                "EnhancedColorMode",
+                "ColorLoopActive",
+                "ColorLoopDirection",
+                "ColorLoopTime",
+                "ColorCapabilities",
+                "ColorTempPhysicalMin",
+                "ColorTempPhysicalMax",
+                "CoupleColorTempToLevelMinMireds",
+                "StartUpColorTemperatureMireds",
+                "ClusterRevision",
+            ],
+            "DoorLock": [
+                "LockState",
+                "LockType",
+                "ActuatorEnabled",
+                "ClusterRevision",
+            ],
+            "GeneralCommissioning": [
+                "FabricId",
+                "Breadcrumb",
+                "ClusterRevision",
+            ],
+            "GroupKeyManagement": [
+                "Groups",
+                "GroupKeys",
+                "ClusterRevision",
+            ],
+            "Groups": [
+                "NameSupport",
+                "ClusterRevision",
+            ],
+            "IasZone": [
+                "ZoneState",
+                "ZoneType",
+                "ZoneStatus",
+                "IasCieAddress",
+                "ZoneId",
+                "ClusterRevision",
+            ],
+            "Identify": [
+                "IdentifyTime",
+                "ClusterRevision",
+            ],
+            "LevelControl": [
+                "CurrentLevel",
+                "ClusterRevision",
+            ],
+            "LowPower": [
+                "ClusterRevision",
+            ],
+            "NetworkCommissioning": [
+                "ClusterRevision",
+            ],
+            "OnOff": [
+                "OnOff",
+                "ClusterRevision",
+            ],
+            "Scenes": [
+                "SceneCount",
+                "CurrentScene",
+                "CurrentGroup",
+                "SceneValid",
+                "NameSupport",
+                "ClusterRevision",
+            ],
+            "TemperatureMeasurement": [
+                "MeasuredValue",
+                "MinMeasuredValue",
+                "MaxMeasuredValue",
+                "ClusterRevision",
+            ],
+        }
+
     def SendCommand(self, device: ctypes.c_void_p, cluster: str, command: str, endpoint: int, groupid: int, args):
         func = getattr(self, "Cluster{}_Command{}".format(cluster, command), None)
         if not func:
             raise UnknownCommand(cluster, command)
         func(device, endpoint, groupid, **args)
 
+    def ReadAttribute(self, device: ctypes.c_void_p, cluster: str, attribute: str, endpoint: int, groupid: int):
+        func = getattr(self, "Cluster{}_ReadAttribute{}".format(cluster, attribute), None)
+        if not func:
+            raise UnknownAttribute(cluster, attribute)
+        func(device, endpoint, groupid)
+
+    # Cluster commands
+
     def ClusterBarrierControl_CommandBarrierControlGoToPercent(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, percentOpen: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_BarrierControl_BarrierControlGoToPercent(
                 device, ZCLendpoint, ZCLgroupid, percentOpen
             )
         )
-
     def ClusterBarrierControl_CommandBarrierControlStop(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_BarrierControl_BarrierControlStop(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterBasic_CommandMfgSpecificPing(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Basic_MfgSpecificPing(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterBinding_CommandBind(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, nodeId: int, groupId: int, endpointId: int, clusterId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Binding_Bind(
                 device, ZCLendpoint, ZCLgroupid, nodeId, groupId, endpointId, clusterId
             )
         )
-
     def ClusterBinding_CommandUnbind(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, nodeId: int, groupId: int, endpointId: int, clusterId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Binding_Unbind(
                 device, ZCLendpoint, ZCLgroupid, nodeId, groupId, endpointId, clusterId
             )
         )
-
     def ClusterColorControl_CommandMoveColor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, rateX: int, rateY: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveColor(
                 device, ZCLendpoint, ZCLgroupid, rateX, rateY, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandMoveColorTemperature(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, moveMode: int, rate: int, colorTemperatureMinimum: int, colorTemperatureMaximum: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveColorTemperature(
                 device, ZCLendpoint, ZCLgroupid, moveMode, rate, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandMoveHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, moveMode: int, rate: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveHue(
                 device, ZCLendpoint, ZCLgroupid, moveMode, rate, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandMoveSaturation(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, moveMode: int, rate: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveSaturation(
                 device, ZCLendpoint, ZCLgroupid, moveMode, rate, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandMoveToColor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, colorX: int, colorY: int, transitionTime: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveToColor(
                 device, ZCLendpoint, ZCLgroupid, colorX, colorY, transitionTime, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandMoveToColorTemperature(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, colorTemperature: int, transitionTime: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveToColorTemperature(
                 device, ZCLendpoint, ZCLgroupid, colorTemperature, transitionTime, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandMoveToHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, hue: int, direction: int, transitionTime: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveToHue(
                 device, ZCLendpoint, ZCLgroupid, hue, direction, transitionTime, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandMoveToHueAndSaturation(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, hue: int, saturation: int, transitionTime: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveToHueAndSaturation(
                 device, ZCLendpoint, ZCLgroupid, hue, saturation, transitionTime, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandMoveToSaturation(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, saturation: int, transitionTime: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_MoveToSaturation(
                 device, ZCLendpoint, ZCLgroupid, saturation, transitionTime, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandStepColor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, stepX: int, stepY: int, transitionTime: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_StepColor(
                 device, ZCLendpoint, ZCLgroupid, stepX, stepY, transitionTime, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandStepColorTemperature(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, stepMode: int, stepSize: int, transitionTime: int, colorTemperatureMinimum: int, colorTemperatureMaximum: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_StepColorTemperature(
                 device, ZCLendpoint, ZCLgroupid, stepMode, stepSize, transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandStepHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, stepMode: int, stepSize: int, transitionTime: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_StepHue(
                 device, ZCLendpoint, ZCLgroupid, stepMode, stepSize, transitionTime, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandStepSaturation(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, stepMode: int, stepSize: int, transitionTime: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_StepSaturation(
                 device, ZCLendpoint, ZCLgroupid, stepMode, stepSize, transitionTime, optionsMask, optionsOverride
             )
         )
-
     def ClusterColorControl_CommandStopMoveStep(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, optionsMask: int, optionsOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_ColorControl_StopMoveStep(
                 device, ZCLendpoint, ZCLgroupid, optionsMask, optionsOverride
             )
         )
-
     def ClusterDoorLock_CommandClearAllPins(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_ClearAllPins(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterDoorLock_CommandClearAllRfids(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_ClearAllRfids(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterDoorLock_CommandClearHolidaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_ClearHolidaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId
             )
         )
-
     def ClusterDoorLock_CommandClearPin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_ClearPin(
                 device, ZCLendpoint, ZCLgroupid, userId
             )
         )
-
     def ClusterDoorLock_CommandClearRfid(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_ClearRfid(
                 device, ZCLendpoint, ZCLgroupid, userId
             )
         )
-
     def ClusterDoorLock_CommandClearWeekdaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_ClearWeekdaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId, userId
             )
         )
-
     def ClusterDoorLock_CommandClearYeardaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_ClearYeardaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId, userId
             )
         )
-
     def ClusterDoorLock_CommandGetHolidaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_GetHolidaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId
             )
         )
-
     def ClusterDoorLock_CommandGetLogRecord(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, logIndex: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_GetLogRecord(
                 device, ZCLendpoint, ZCLgroupid, logIndex
             )
         )
-
     def ClusterDoorLock_CommandGetPin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_GetPin(
                 device, ZCLendpoint, ZCLgroupid, userId
             )
         )
-
     def ClusterDoorLock_CommandGetRfid(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_GetRfid(
                 device, ZCLendpoint, ZCLgroupid, userId
             )
         )
-
     def ClusterDoorLock_CommandGetUserType(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_GetUserType(
                 device, ZCLendpoint, ZCLgroupid, userId
             )
         )
-
     def ClusterDoorLock_CommandGetWeekdaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_GetWeekdaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId, userId
             )
         )
-
     def ClusterDoorLock_CommandGetYeardaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int, userId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_GetYeardaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId, userId
             )
         )
-
     def ClusterDoorLock_CommandLockDoor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, pin: bytes):
         pin = pin.encode("utf-8") + b'\x00'
         self._ChipStack.Call(
@@ -679,14 +805,12 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid, pin, len(pin)
             )
         )
-
     def ClusterDoorLock_CommandSetHolidaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int, localStartTime: int, localEndTime: int, operatingModeDuringHoliday: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_SetHolidaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday
             )
         )
-
     def ClusterDoorLock_CommandSetPin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int, userStatus: int, userType: int, pin: bytes):
         pin = pin.encode("utf-8") + b'\x00'
         self._ChipStack.Call(
@@ -694,7 +818,6 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid, userId, userStatus, userType, pin, len(pin)
             )
         )
-
     def ClusterDoorLock_CommandSetRfid(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int, userStatus: int, userType: int, id: bytes):
         id = id.encode("utf-8") + b'\x00'
         self._ChipStack.Call(
@@ -702,28 +825,24 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid, userId, userStatus, userType, id, len(id)
             )
         )
-
     def ClusterDoorLock_CommandSetUserType(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int, userType: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_SetUserType(
                 device, ZCLendpoint, ZCLgroupid, userId, userType
             )
         )
-
     def ClusterDoorLock_CommandSetWeekdaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int, userId: int, daysMask: int, startHour: int, startMinute: int, endHour: int, endMinute: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_SetWeekdaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute
             )
         )
-
     def ClusterDoorLock_CommandSetYeardaySchedule(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, scheduleId: int, userId: int, localStartTime: int, localEndTime: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_SetYeardaySchedule(
                 device, ZCLendpoint, ZCLgroupid, scheduleId, userId, localStartTime, localEndTime
             )
         )
-
     def ClusterDoorLock_CommandUnlockDoor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, pin: bytes):
         pin = pin.encode("utf-8") + b'\x00'
         self._ChipStack.Call(
@@ -731,7 +850,6 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid, pin, len(pin)
             )
         )
-
     def ClusterDoorLock_CommandUnlockWithTimeout(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, timeoutInSeconds: int, pin: bytes):
         pin = pin.encode("utf-8") + b'\x00'
         self._ChipStack.Call(
@@ -739,28 +857,24 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid, timeoutInSeconds, pin, len(pin)
             )
         )
-
     def ClusterGeneralCommissioning_CommandArmFailSafe(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, expiryLengthSeconds: int, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_GeneralCommissioning_ArmFailSafe(
                 device, ZCLendpoint, ZCLgroupid, expiryLengthSeconds, breadcrumb, timeoutMs
             )
         )
-
     def ClusterGeneralCommissioning_CommandCommissioningComplete(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_GeneralCommissioning_CommissioningComplete(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterGeneralCommissioning_CommandSetFabric(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, fabricId: bytes, fabricSecret: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_GeneralCommissioning_SetFabric(
                 device, ZCLendpoint, ZCLgroupid, fabricId, len(fabricId), fabricSecret, len(fabricSecret), breadcrumb, timeoutMs
             )
         )
-
     def ClusterGroups_CommandAddGroup(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, groupName: bytes):
         groupName = groupName.encode("utf-8") + b'\x00'
         self._ChipStack.Call(
@@ -768,7 +882,6 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid, groupId, groupName, len(groupName)
             )
         )
-
     def ClusterGroups_CommandAddGroupIfIdentifying(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, groupName: bytes):
         groupName = groupName.encode("utf-8") + b'\x00'
         self._ChipStack.Call(
@@ -776,196 +889,168 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid, groupId, groupName, len(groupName)
             )
         )
-
     def ClusterGroups_CommandGetGroupMembership(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupCount: int, groupList: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Groups_GetGroupMembership(
                 device, ZCLendpoint, ZCLgroupid, groupCount, groupList
             )
         )
-
     def ClusterGroups_CommandRemoveAllGroups(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Groups_RemoveAllGroups(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterGroups_CommandRemoveGroup(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Groups_RemoveGroup(
                 device, ZCLendpoint, ZCLgroupid, groupId
             )
         )
-
     def ClusterGroups_CommandViewGroup(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Groups_ViewGroup(
                 device, ZCLendpoint, ZCLgroupid, groupId
             )
         )
-
     def ClusterIdentify_CommandIdentify(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, identifyTime: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Identify_Identify(
                 device, ZCLendpoint, ZCLgroupid, identifyTime
             )
         )
-
     def ClusterIdentify_CommandIdentifyQuery(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Identify_IdentifyQuery(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterLevelControl_CommandMove(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, moveMode: int, rate: int, optionMask: int, optionOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LevelControl_Move(
                 device, ZCLendpoint, ZCLgroupid, moveMode, rate, optionMask, optionOverride
             )
         )
-
     def ClusterLevelControl_CommandMoveToLevel(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, level: int, transitionTime: int, optionMask: int, optionOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LevelControl_MoveToLevel(
                 device, ZCLendpoint, ZCLgroupid, level, transitionTime, optionMask, optionOverride
             )
         )
-
     def ClusterLevelControl_CommandMoveToLevelWithOnOff(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, level: int, transitionTime: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LevelControl_MoveToLevelWithOnOff(
                 device, ZCLendpoint, ZCLgroupid, level, transitionTime
             )
         )
-
     def ClusterLevelControl_CommandMoveWithOnOff(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, moveMode: int, rate: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LevelControl_MoveWithOnOff(
                 device, ZCLendpoint, ZCLgroupid, moveMode, rate
             )
         )
-
     def ClusterLevelControl_CommandStep(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, stepMode: int, stepSize: int, transitionTime: int, optionMask: int, optionOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LevelControl_Step(
                 device, ZCLendpoint, ZCLgroupid, stepMode, stepSize, transitionTime, optionMask, optionOverride
             )
         )
-
     def ClusterLevelControl_CommandStepWithOnOff(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, stepMode: int, stepSize: int, transitionTime: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LevelControl_StepWithOnOff(
                 device, ZCLendpoint, ZCLgroupid, stepMode, stepSize, transitionTime
             )
         )
-
     def ClusterLevelControl_CommandStop(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, optionMask: int, optionOverride: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LevelControl_Stop(
                 device, ZCLendpoint, ZCLgroupid, optionMask, optionOverride
             )
         )
-
     def ClusterLevelControl_CommandStopWithOnOff(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LevelControl_StopWithOnOff(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterLowPower_CommandSleep(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_LowPower_Sleep(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterNetworkCommissioning_CommandAddThreadNetwork(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, operationalDataset: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_AddThreadNetwork(
                 device, ZCLendpoint, ZCLgroupid, operationalDataset, len(operationalDataset), breadcrumb, timeoutMs
             )
         )
-
     def ClusterNetworkCommissioning_CommandAddWiFiNetwork(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, ssid: bytes, credentials: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_AddWiFiNetwork(
                 device, ZCLendpoint, ZCLgroupid, ssid, len(ssid), credentials, len(credentials), breadcrumb, timeoutMs
             )
         )
-
     def ClusterNetworkCommissioning_CommandDisableNetwork(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, networkID: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_DisableNetwork(
                 device, ZCLendpoint, ZCLgroupid, networkID, len(networkID), breadcrumb, timeoutMs
             )
         )
-
     def ClusterNetworkCommissioning_CommandEnableNetwork(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, networkID: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_EnableNetwork(
                 device, ZCLendpoint, ZCLgroupid, networkID, len(networkID), breadcrumb, timeoutMs
             )
         )
-
     def ClusterNetworkCommissioning_CommandGetLastNetworkCommissioningResult(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_GetLastNetworkCommissioningResult(
                 device, ZCLendpoint, ZCLgroupid, timeoutMs
             )
         )
-
     def ClusterNetworkCommissioning_CommandRemoveNetwork(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, networkID: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_RemoveNetwork(
                 device, ZCLendpoint, ZCLgroupid, networkID, len(networkID), breadcrumb, timeoutMs
             )
         )
-
     def ClusterNetworkCommissioning_CommandScanNetworks(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, ssid: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_ScanNetworks(
                 device, ZCLendpoint, ZCLgroupid, ssid, len(ssid), breadcrumb, timeoutMs
             )
         )
-
     def ClusterNetworkCommissioning_CommandUpdateThreadNetwork(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, operationalDataset: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_UpdateThreadNetwork(
                 device, ZCLendpoint, ZCLgroupid, operationalDataset, len(operationalDataset), breadcrumb, timeoutMs
             )
         )
-
     def ClusterNetworkCommissioning_CommandUpdateWiFiNetwork(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, ssid: bytes, credentials: bytes, breadcrumb: int, timeoutMs: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_UpdateWiFiNetwork(
                 device, ZCLendpoint, ZCLgroupid, ssid, len(ssid), credentials, len(credentials), breadcrumb, timeoutMs
             )
         )
-
     def ClusterOnOff_CommandOff(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_OnOff_Off(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterOnOff_CommandOn(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_OnOff_On(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterOnOff_CommandToggle(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_OnOff_Toggle(
                 device, ZCLendpoint, ZCLgroupid
             )
         )
-
     def ClusterScenes_CommandAddScene(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, sceneId: int, transitionTime: int, sceneName: bytes, clusterId: int, length: int, value: int):
         sceneName = sceneName.encode("utf-8") + b'\x00'
         self._ChipStack.Call(
@@ -973,42 +1058,36 @@ class ChipCluster:
                 device, ZCLendpoint, ZCLgroupid, groupId, sceneId, transitionTime, sceneName, len(sceneName), clusterId, length, value
             )
         )
-
     def ClusterScenes_CommandGetSceneMembership(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Scenes_GetSceneMembership(
                 device, ZCLendpoint, ZCLgroupid, groupId
             )
         )
-
     def ClusterScenes_CommandRecallScene(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, sceneId: int, transitionTime: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Scenes_RecallScene(
                 device, ZCLendpoint, ZCLgroupid, groupId, sceneId, transitionTime
             )
         )
-
     def ClusterScenes_CommandRemoveAllScenes(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Scenes_RemoveAllScenes(
                 device, ZCLendpoint, ZCLgroupid, groupId
             )
         )
-
     def ClusterScenes_CommandRemoveScene(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, sceneId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Scenes_RemoveScene(
                 device, ZCLendpoint, ZCLgroupid, groupId, sceneId
             )
         )
-
     def ClusterScenes_CommandStoreScene(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, sceneId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Scenes_StoreScene(
                 device, ZCLendpoint, ZCLgroupid, groupId, sceneId
             )
         )
-
     def ClusterScenes_CommandViewScene(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, sceneId: int):
         self._ChipStack.Call(
             lambda: self._chipLib.chip_ime_AppendCommand_Scenes_ViewScene(
@@ -1016,9 +1095,490 @@ class ChipCluster:
             )
         )
 
+    # Cluster attributes
+
+    def ClusterApplicationBasic_ReadAttributeVendorName(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_VendorName(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterApplicationBasic_ReadAttributeVendorId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_VendorId(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterApplicationBasic_ReadAttributeApplicationName(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationName(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterApplicationBasic_ReadAttributeProductId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ProductId(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterApplicationBasic_ReadAttributeApplicationId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationId(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterApplicationBasic_ReadAttributeCatalogVendorId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_CatalogVendorId(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterApplicationBasic_ReadAttributeApplicationSatus(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationSatus(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterApplicationBasic_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBarrierControl_ReadAttributeBarrierMovingState(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierMovingState(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBarrierControl_ReadAttributeBarrierSafetyStatus(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierSafetyStatus(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBarrierControl_ReadAttributeBarrierCapabilities(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierCapabilities(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBarrierControl_ReadAttributeBarrierPosition(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierPosition(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBarrierControl_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_BarrierControl_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeInteractionModelVersion(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_InteractionModelVersion(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeVendorName(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_VendorName(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeVendorID(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_VendorID(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeProductName(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_ProductName(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeProductID(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_ProductID(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeUserLabel(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_UserLabel(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeLocation(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_Location(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeHardwareVersion(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_HardwareVersion(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeHardwareVersionString(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_HardwareVersionString(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeSoftwareVersion(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_SoftwareVersion(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeSoftwareVersionString(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_SoftwareVersionString(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBasic_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Basic_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterBinding_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Binding_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeCurrentHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentHue(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeCurrentSaturation(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentSaturation(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeRemainingTime(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_RemainingTime(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeCurrentX(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentX(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeCurrentY(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentY(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeDriftCompensation(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_DriftCompensation(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeCompensationText(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_CompensationText(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorTemperature(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTemperature(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorMode(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorMode(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorControlOptions(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorControlOptions(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeNumberOfPrimaries(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_NumberOfPrimaries(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary1X(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1X(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary1Y(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1Y(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary1Intensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1Intensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary2X(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2X(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary2Y(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2Y(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary2Intensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2Intensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary3X(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3X(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary3Y(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3Y(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary3Intensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3Intensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary4X(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4X(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary4Y(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4Y(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary4Intensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4Intensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary5X(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5X(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary5Y(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5Y(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary5Intensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5Intensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary6X(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6X(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary6Y(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6Y(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributePrimary6Intensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6Intensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeWhitePointX(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_WhitePointX(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeWhitePointY(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_WhitePointY(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointRX(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRX(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointRY(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRY(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointRIntensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRIntensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointGX(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGX(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointGY(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGY(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointGIntensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGIntensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointBX(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBX(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointBY(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBY(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorPointBIntensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBIntensity(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeEnhancedCurrentHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedCurrentHue(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeEnhancedColorMode(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedColorMode(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorLoopActive(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopActive(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorLoopDirection(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopDirection(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorLoopTime(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopTime(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorCapabilities(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorCapabilities(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorTempPhysicalMin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMin(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeColorTempPhysicalMax(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMax(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeCoupleColorTempToLevelMinMireds(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_CoupleColorTempToLevelMinMireds(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeStartUpColorTemperatureMireds(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_StartUpColorTemperatureMireds(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterColorControl_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_ColorControl_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterDoorLock_ReadAttributeLockState(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_DoorLock_LockState(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterDoorLock_ReadAttributeLockType(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_DoorLock_LockType(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterDoorLock_ReadAttributeActuatorEnabled(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_DoorLock_ActuatorEnabled(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterDoorLock_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_DoorLock_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterGeneralCommissioning_ReadAttributeFabricId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_FabricId(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterGeneralCommissioning_ReadAttributeBreadcrumb(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_Breadcrumb(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterGeneralCommissioning_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterGroupKeyManagement_ReadAttributeGroups(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_Groups(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterGroupKeyManagement_ReadAttributeGroupKeys(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_GroupKeys(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterGroupKeyManagement_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterGroups_ReadAttributeNameSupport(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Groups_NameSupport(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterGroups_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Groups_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterIasZone_ReadAttributeZoneState(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneState(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterIasZone_ReadAttributeZoneType(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneType(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterIasZone_ReadAttributeZoneStatus(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneStatus(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterIasZone_ReadAttributeIasCieAddress(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_IasZone_IasCieAddress(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterIasZone_ReadAttributeZoneId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneId(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterIasZone_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_IasZone_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterIdentify_ReadAttributeIdentifyTime(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Identify_IdentifyTime(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterIdentify_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Identify_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterLevelControl_ReadAttributeCurrentLevel(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_LevelControl_CurrentLevel(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterLevelControl_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_LevelControl_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterLowPower_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_LowPower_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterNetworkCommissioning_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_NetworkCommissioning_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterOnOff_ReadAttributeOnOff(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_OnOff_OnOff(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterOnOff_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_OnOff_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterScenes_ReadAttributeSceneCount(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Scenes_SceneCount(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterScenes_ReadAttributeCurrentScene(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Scenes_CurrentScene(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterScenes_ReadAttributeCurrentGroup(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Scenes_CurrentGroup(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterScenes_ReadAttributeSceneValid(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Scenes_SceneValid(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterScenes_ReadAttributeNameSupport(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Scenes_NameSupport(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterScenes_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_Scenes_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterTemperatureMeasurement_ReadAttributeMeasuredValue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MeasuredValue(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterTemperatureMeasurement_ReadAttributeMinMeasuredValue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MinMeasuredValue(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterTemperatureMeasurement_ReadAttributeMaxMeasuredValue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MaxMeasuredValue(device, ZCLendpoint, ZCLgroupid)
+        )
+    def ClusterTemperatureMeasurement_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int):
+        self._ChipStack.Call(
+            lambda: self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_ClusterRevision(device, ZCLendpoint, ZCLgroupid)
+        )
+
+    # Init native functions
+
     def InitLib(self, chipLib):
         self._chipLib = chipLib
         # Cluster ApplicationBasic
+        # Cluster ApplicationBasic ReadAttribute VendorName
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_VendorName.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_VendorName.restype = ctypes.c_uint32
+        # Cluster ApplicationBasic ReadAttribute VendorId
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_VendorId.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_VendorId.restype = ctypes.c_uint32
+        # Cluster ApplicationBasic ReadAttribute ApplicationName
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationName.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationName.restype = ctypes.c_uint32
+        # Cluster ApplicationBasic ReadAttribute ProductId
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ProductId.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ProductId.restype = ctypes.c_uint32
+        # Cluster ApplicationBasic ReadAttribute ApplicationId
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationId.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationId.restype = ctypes.c_uint32
+        # Cluster ApplicationBasic ReadAttribute CatalogVendorId
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_CatalogVendorId.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_CatalogVendorId.restype = ctypes.c_uint32
+        # Cluster ApplicationBasic ReadAttribute ApplicationSatus
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationSatus.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationSatus.restype = ctypes.c_uint32
+        # Cluster ApplicationBasic ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ClusterRevision.restype = ctypes.c_uint32
         # Cluster BarrierControl
         # Cluster BarrierControl Command BarrierControlGoToPercent
         self._chipLib.chip_ime_AppendCommand_BarrierControl_BarrierControlGoToPercent.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8]
@@ -1026,10 +1586,61 @@ class ChipCluster:
         # Cluster BarrierControl Command BarrierControlStop
         self._chipLib.chip_ime_AppendCommand_BarrierControl_BarrierControlStop.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
         self._chipLib.chip_ime_AppendCommand_BarrierControl_BarrierControlStop.restype = ctypes.c_uint32
+        # Cluster BarrierControl ReadAttribute BarrierMovingState
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierMovingState.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierMovingState.restype = ctypes.c_uint32
+        # Cluster BarrierControl ReadAttribute BarrierSafetyStatus
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierSafetyStatus.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierSafetyStatus.restype = ctypes.c_uint32
+        # Cluster BarrierControl ReadAttribute BarrierCapabilities
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierCapabilities.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierCapabilities.restype = ctypes.c_uint32
+        # Cluster BarrierControl ReadAttribute BarrierPosition
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierPosition.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_BarrierPosition.restype = ctypes.c_uint32
+        # Cluster BarrierControl ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_BarrierControl_ClusterRevision.restype = ctypes.c_uint32
         # Cluster Basic
         # Cluster Basic Command MfgSpecificPing
         self._chipLib.chip_ime_AppendCommand_Basic_MfgSpecificPing.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
         self._chipLib.chip_ime_AppendCommand_Basic_MfgSpecificPing.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute InteractionModelVersion
+        self._chipLib.chip_ime_ReadAttribute_Basic_InteractionModelVersion.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_InteractionModelVersion.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute VendorName
+        self._chipLib.chip_ime_ReadAttribute_Basic_VendorName.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_VendorName.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute VendorID
+        self._chipLib.chip_ime_ReadAttribute_Basic_VendorID.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_VendorID.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute ProductName
+        self._chipLib.chip_ime_ReadAttribute_Basic_ProductName.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_ProductName.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute ProductID
+        self._chipLib.chip_ime_ReadAttribute_Basic_ProductID.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_ProductID.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute UserLabel
+        self._chipLib.chip_ime_ReadAttribute_Basic_UserLabel.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_UserLabel.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute Location
+        self._chipLib.chip_ime_ReadAttribute_Basic_Location.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_Location.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute HardwareVersion
+        self._chipLib.chip_ime_ReadAttribute_Basic_HardwareVersion.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_HardwareVersion.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute HardwareVersionString
+        self._chipLib.chip_ime_ReadAttribute_Basic_HardwareVersionString.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_HardwareVersionString.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute SoftwareVersion
+        self._chipLib.chip_ime_ReadAttribute_Basic_SoftwareVersion.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_SoftwareVersion.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute SoftwareVersionString
+        self._chipLib.chip_ime_ReadAttribute_Basic_SoftwareVersionString.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_SoftwareVersionString.restype = ctypes.c_uint32
+        # Cluster Basic ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_Basic_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Basic_ClusterRevision.restype = ctypes.c_uint32
         # Cluster Binding
         # Cluster Binding Command Bind
         self._chipLib.chip_ime_AppendCommand_Binding_Bind.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint64, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16]
@@ -1037,6 +1648,9 @@ class ChipCluster:
         # Cluster Binding Command Unbind
         self._chipLib.chip_ime_AppendCommand_Binding_Unbind.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint64, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16]
         self._chipLib.chip_ime_AppendCommand_Binding_Unbind.restype = ctypes.c_uint32
+        # Cluster Binding ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_Binding_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Binding_ClusterRevision.restype = ctypes.c_uint32
         # Cluster ColorControl
         # Cluster ColorControl Command MoveColor
         self._chipLib.chip_ime_AppendCommand_ColorControl_MoveColor.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_int16, ctypes.c_int16, ctypes.c_uint8, ctypes.c_uint8]
@@ -1080,6 +1694,159 @@ class ChipCluster:
         # Cluster ColorControl Command StopMoveStep
         self._chipLib.chip_ime_AppendCommand_ColorControl_StopMoveStep.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8]
         self._chipLib.chip_ime_AppendCommand_ColorControl_StopMoveStep.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute CurrentHue
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentHue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentHue.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute CurrentSaturation
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentSaturation.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentSaturation.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute RemainingTime
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_RemainingTime.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_RemainingTime.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute CurrentX
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentX.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentX.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute CurrentY
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentY.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CurrentY.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute DriftCompensation
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_DriftCompensation.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_DriftCompensation.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute CompensationText
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CompensationText.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CompensationText.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorTemperature
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTemperature.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTemperature.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorMode
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorMode.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorMode.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorControlOptions
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorControlOptions.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorControlOptions.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute NumberOfPrimaries
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_NumberOfPrimaries.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_NumberOfPrimaries.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary1X
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1X.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1X.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary1Y
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1Y.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1Y.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary1Intensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1Intensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary1Intensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary2X
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2X.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2X.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary2Y
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2Y.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2Y.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary2Intensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2Intensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary2Intensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary3X
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3X.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3X.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary3Y
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3Y.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3Y.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary3Intensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3Intensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary3Intensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary4X
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4X.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4X.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary4Y
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4Y.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4Y.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary4Intensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4Intensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary4Intensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary5X
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5X.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5X.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary5Y
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5Y.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5Y.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary5Intensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5Intensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary5Intensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary6X
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6X.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6X.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary6Y
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6Y.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6Y.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute Primary6Intensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6Intensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_Primary6Intensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute WhitePointX
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_WhitePointX.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_WhitePointX.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute WhitePointY
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_WhitePointY.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_WhitePointY.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointRX
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRX.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRX.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointRY
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRY.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRY.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointRIntensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRIntensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointRIntensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointGX
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGX.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGX.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointGY
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGY.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGY.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointGIntensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGIntensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointGIntensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointBX
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBX.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBX.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointBY
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBY.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBY.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorPointBIntensity
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBIntensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBIntensity.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute EnhancedCurrentHue
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedCurrentHue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedCurrentHue.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute EnhancedColorMode
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedColorMode.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedColorMode.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorLoopActive
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopActive.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopActive.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorLoopDirection
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopDirection.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopDirection.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorLoopTime
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopTime.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopTime.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorCapabilities
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorCapabilities.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorCapabilities.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorTempPhysicalMin
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMin.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMin.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ColorTempPhysicalMax
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMax.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMax.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute CoupleColorTempToLevelMinMireds
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CoupleColorTempToLevelMinMireds.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_CoupleColorTempToLevelMinMireds.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute StartUpColorTemperatureMireds
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_StartUpColorTemperatureMireds.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_StartUpColorTemperatureMireds.restype = ctypes.c_uint32
+        # Cluster ColorControl ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_ColorControl_ClusterRevision.restype = ctypes.c_uint32
         # Cluster DoorLock
         # Cluster DoorLock Command ClearAllPins
         self._chipLib.chip_ime_AppendCommand_DoorLock_ClearAllPins.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
@@ -1150,6 +1917,18 @@ class ChipCluster:
         # Cluster DoorLock Command UnlockWithTimeout
         self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockWithTimeout.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32]
         self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockWithTimeout.restype = ctypes.c_uint32
+        # Cluster DoorLock ReadAttribute LockState
+        self._chipLib.chip_ime_ReadAttribute_DoorLock_LockState.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_DoorLock_LockState.restype = ctypes.c_uint32
+        # Cluster DoorLock ReadAttribute LockType
+        self._chipLib.chip_ime_ReadAttribute_DoorLock_LockType.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_DoorLock_LockType.restype = ctypes.c_uint32
+        # Cluster DoorLock ReadAttribute ActuatorEnabled
+        self._chipLib.chip_ime_ReadAttribute_DoorLock_ActuatorEnabled.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_DoorLock_ActuatorEnabled.restype = ctypes.c_uint32
+        # Cluster DoorLock ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_DoorLock_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_DoorLock_ClusterRevision.restype = ctypes.c_uint32
         # Cluster GeneralCommissioning
         # Cluster GeneralCommissioning Command ArmFailSafe
         self._chipLib.chip_ime_AppendCommand_GeneralCommissioning_ArmFailSafe.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint64, ctypes.c_uint32]
@@ -1160,7 +1939,25 @@ class ChipCluster:
         # Cluster GeneralCommissioning Command SetFabric
         self._chipLib.chip_ime_AppendCommand_GeneralCommissioning_SetFabric.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32, ctypes.c_char_p, ctypes.c_uint32, ctypes.c_uint64, ctypes.c_uint32]
         self._chipLib.chip_ime_AppendCommand_GeneralCommissioning_SetFabric.restype = ctypes.c_uint32
+        # Cluster GeneralCommissioning ReadAttribute FabricId
+        self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_FabricId.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_FabricId.restype = ctypes.c_uint32
+        # Cluster GeneralCommissioning ReadAttribute Breadcrumb
+        self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_Breadcrumb.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_Breadcrumb.restype = ctypes.c_uint32
+        # Cluster GeneralCommissioning ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_GeneralCommissioning_ClusterRevision.restype = ctypes.c_uint32
         # Cluster GroupKeyManagement
+        # Cluster GroupKeyManagement ReadAttribute Groups
+        self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_Groups.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_Groups.restype = ctypes.c_uint32
+        # Cluster GroupKeyManagement ReadAttribute GroupKeys
+        self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_GroupKeys.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_GroupKeys.restype = ctypes.c_uint32
+        # Cluster GroupKeyManagement ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_GroupKeyManagement_ClusterRevision.restype = ctypes.c_uint32
         # Cluster Groups
         # Cluster Groups Command AddGroup
         self._chipLib.chip_ime_AppendCommand_Groups_AddGroup.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32]
@@ -1180,7 +1977,31 @@ class ChipCluster:
         # Cluster Groups Command ViewGroup
         self._chipLib.chip_ime_AppendCommand_Groups_ViewGroup.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16]
         self._chipLib.chip_ime_AppendCommand_Groups_ViewGroup.restype = ctypes.c_uint32
+        # Cluster Groups ReadAttribute NameSupport
+        self._chipLib.chip_ime_ReadAttribute_Groups_NameSupport.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Groups_NameSupport.restype = ctypes.c_uint32
+        # Cluster Groups ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_Groups_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Groups_ClusterRevision.restype = ctypes.c_uint32
         # Cluster IasZone
+        # Cluster IasZone ReadAttribute ZoneState
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneState.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneState.restype = ctypes.c_uint32
+        # Cluster IasZone ReadAttribute ZoneType
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneType.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneType.restype = ctypes.c_uint32
+        # Cluster IasZone ReadAttribute ZoneStatus
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneStatus.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneStatus.restype = ctypes.c_uint32
+        # Cluster IasZone ReadAttribute IasCieAddress
+        self._chipLib.chip_ime_ReadAttribute_IasZone_IasCieAddress.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_IasZone_IasCieAddress.restype = ctypes.c_uint32
+        # Cluster IasZone ReadAttribute ZoneId
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneId.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ZoneId.restype = ctypes.c_uint32
+        # Cluster IasZone ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_IasZone_ClusterRevision.restype = ctypes.c_uint32
         # Cluster Identify
         # Cluster Identify Command Identify
         self._chipLib.chip_ime_AppendCommand_Identify_Identify.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16]
@@ -1188,6 +2009,12 @@ class ChipCluster:
         # Cluster Identify Command IdentifyQuery
         self._chipLib.chip_ime_AppendCommand_Identify_IdentifyQuery.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
         self._chipLib.chip_ime_AppendCommand_Identify_IdentifyQuery.restype = ctypes.c_uint32
+        # Cluster Identify ReadAttribute IdentifyTime
+        self._chipLib.chip_ime_ReadAttribute_Identify_IdentifyTime.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Identify_IdentifyTime.restype = ctypes.c_uint32
+        # Cluster Identify ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_Identify_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Identify_ClusterRevision.restype = ctypes.c_uint32
         # Cluster LevelControl
         # Cluster LevelControl Command Move
         self._chipLib.chip_ime_AppendCommand_LevelControl_Move.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8]
@@ -1213,10 +2040,19 @@ class ChipCluster:
         # Cluster LevelControl Command StopWithOnOff
         self._chipLib.chip_ime_AppendCommand_LevelControl_StopWithOnOff.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
         self._chipLib.chip_ime_AppendCommand_LevelControl_StopWithOnOff.restype = ctypes.c_uint32
+        # Cluster LevelControl ReadAttribute CurrentLevel
+        self._chipLib.chip_ime_ReadAttribute_LevelControl_CurrentLevel.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_LevelControl_CurrentLevel.restype = ctypes.c_uint32
+        # Cluster LevelControl ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_LevelControl_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_LevelControl_ClusterRevision.restype = ctypes.c_uint32
         # Cluster LowPower
         # Cluster LowPower Command Sleep
         self._chipLib.chip_ime_AppendCommand_LowPower_Sleep.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
         self._chipLib.chip_ime_AppendCommand_LowPower_Sleep.restype = ctypes.c_uint32
+        # Cluster LowPower ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_LowPower_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_LowPower_ClusterRevision.restype = ctypes.c_uint32
         # Cluster NetworkCommissioning
         # Cluster NetworkCommissioning Command AddThreadNetwork
         self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_AddThreadNetwork.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32, ctypes.c_uint64, ctypes.c_uint32]
@@ -1245,6 +2081,9 @@ class ChipCluster:
         # Cluster NetworkCommissioning Command UpdateWiFiNetwork
         self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_UpdateWiFiNetwork.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32, ctypes.c_char_p, ctypes.c_uint32, ctypes.c_uint64, ctypes.c_uint32]
         self._chipLib.chip_ime_AppendCommand_NetworkCommissioning_UpdateWiFiNetwork.restype = ctypes.c_uint32
+        # Cluster NetworkCommissioning ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_NetworkCommissioning_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_NetworkCommissioning_ClusterRevision.restype = ctypes.c_uint32
         # Cluster OnOff
         # Cluster OnOff Command Off
         self._chipLib.chip_ime_AppendCommand_OnOff_Off.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
@@ -1255,6 +2094,12 @@ class ChipCluster:
         # Cluster OnOff Command Toggle
         self._chipLib.chip_ime_AppendCommand_OnOff_Toggle.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
         self._chipLib.chip_ime_AppendCommand_OnOff_Toggle.restype = ctypes.c_uint32
+        # Cluster OnOff ReadAttribute OnOff
+        self._chipLib.chip_ime_ReadAttribute_OnOff_OnOff.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_OnOff_OnOff.restype = ctypes.c_uint32
+        # Cluster OnOff ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_OnOff_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_OnOff_ClusterRevision.restype = ctypes.c_uint32
         # Cluster Scenes
         # Cluster Scenes Command AddScene
         self._chipLib.chip_ime_AppendCommand_Scenes_AddScene.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8]
@@ -1277,4 +2122,34 @@ class ChipCluster:
         # Cluster Scenes Command ViewScene
         self._chipLib.chip_ime_AppendCommand_Scenes_ViewScene.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8]
         self._chipLib.chip_ime_AppendCommand_Scenes_ViewScene.restype = ctypes.c_uint32
+        # Cluster Scenes ReadAttribute SceneCount
+        self._chipLib.chip_ime_ReadAttribute_Scenes_SceneCount.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Scenes_SceneCount.restype = ctypes.c_uint32
+        # Cluster Scenes ReadAttribute CurrentScene
+        self._chipLib.chip_ime_ReadAttribute_Scenes_CurrentScene.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Scenes_CurrentScene.restype = ctypes.c_uint32
+        # Cluster Scenes ReadAttribute CurrentGroup
+        self._chipLib.chip_ime_ReadAttribute_Scenes_CurrentGroup.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Scenes_CurrentGroup.restype = ctypes.c_uint32
+        # Cluster Scenes ReadAttribute SceneValid
+        self._chipLib.chip_ime_ReadAttribute_Scenes_SceneValid.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Scenes_SceneValid.restype = ctypes.c_uint32
+        # Cluster Scenes ReadAttribute NameSupport
+        self._chipLib.chip_ime_ReadAttribute_Scenes_NameSupport.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Scenes_NameSupport.restype = ctypes.c_uint32
+        # Cluster Scenes ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_Scenes_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_Scenes_ClusterRevision.restype = ctypes.c_uint32
         # Cluster TemperatureMeasurement
+        # Cluster TemperatureMeasurement ReadAttribute MeasuredValue
+        self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MeasuredValue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MeasuredValue.restype = ctypes.c_uint32
+        # Cluster TemperatureMeasurement ReadAttribute MinMeasuredValue
+        self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MinMeasuredValue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MinMeasuredValue.restype = ctypes.c_uint32
+        # Cluster TemperatureMeasurement ReadAttribute MaxMeasuredValue
+        self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MaxMeasuredValue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_MaxMeasuredValue.restype = ctypes.c_uint32
+        # Cluster TemperatureMeasurement ReadAttribute ClusterRevision
+        self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16]
+        self._chipLib.chip_ime_ReadAttribute_TemperatureMeasurement_ClusterRevision.restype = ctypes.c_uint32
diff --git a/src/controller/python/chip/clusters/__init__.py b/src/controller/python/chip/clusters/__init__.py
new file mode 100644 (file)
index 0000000..e7b0f8a
--- /dev/null
@@ -0,0 +1,23 @@
+#
+#    Copyright (c) 2021 Project CHIP Authors
+#    All rights reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License");
+#    you may not use this file except in compliance with the License.
+#    You may obtain a copy of the License at
+#
+#        http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+
+#
+#    @file
+#      Provides Python APIs for CHIP.
+#
+
+"""Provides Python APIs for CHIP."""
index 3af67b0..3d16a05 100644 (file)
@@ -21,6 +21,7 @@ __all__ = [
     "DeviceError",
     "InvalidArgumentCount",
     "InvalidArgumentType",
+    "UnknownAttribute",
     "UnknownCluster",
     "UnknownCommand",
 ]
@@ -92,4 +93,13 @@ class UnknownCommand(ClusterError):
         self.command = command
 
     def __str__(self):
-        return "UnknownCommand: cluster: {} command: {}".format(self.cluster, self.command)
+        return "UnknownCommand: cluster: {}, command: {}".format(self.cluster, self.command)
+
+
+class UnknownAttribute(ClusterError):
+    def __init__(self, cluster: str, attribute: str):
+        self.cluster = cluster
+        self.attribute = attribute
+
+    def __str__(self):
+        return "UnknownAttribute: cluster: {}, attribute: {}".format(self.cluster, self.attribute)
index 0aa1ab4..f789045 100644 (file)
@@ -216,8 +216,13 @@ extern "C" chip::Controller::DeviceCommissioner * pychip_internal_Commissioner_N
 
         // System and Inet layers explicitly passed to indicate that the CHIP stack is
         // already assumed initialized
-        err = result->Init(localDeviceId, &gServerStorage, &gPairingDelegate, &chip::DeviceLayer::SystemLayer,
-                           &chip::DeviceLayer::InetLayer);
+        err = result->Init(localDeviceId,
+                           chip::Controller::ControllerInitParams{
+                               .storageDelegate = &gServerStorage,
+                               .systemLayer     = &chip::DeviceLayer::SystemLayer,
+                               .inetLayer       = &chip::DeviceLayer::InetLayer,
+                           },
+                           &gPairingDelegate);
     });
 
     if (err != CHIP_NO_ERROR)
index 2f9a5a6..8059674 100644 (file)
@@ -118,6 +118,13 @@ typedef struct _DeviceInformationRecord
     uint8_t sort;
 } EmberAfDeviceInformationRecord;
 
+// Struct for DeviceType
+typedef struct _DeviceType
+{
+    chip::DeviceTypeId type;
+    uint16_t revision;
+} EmberAfDeviceType;
+
 // Struct for DiscoverAttributesInfoRecord
 typedef struct _DiscoverAttributesInfoRecord
 {
index 0fd312a..cd1d95a 100644 (file)
 #define ZCL_FINISH_TIME_ATTRIBUTE_ID (0x0001)
 #define ZCL_REMAINING_TIME_ATTRIBUTE_ID (0x0002)
 
+// Attribute ids for cluster: Descriptor
+
+// Client attributes
+
+// Server attributes
+#define ZCL_DEVICE_LIST_ATTRIBUTE_ID (0x0000)
+#define ZCL_SERVER_LIST_ATTRIBUTE_ID (0x0001)
+#define ZCL_CLIENT_LIST_ATTRIBUTE_ID (0x0002)
+#define ZCL_PARTS_LIST_ATTRIBUTE_ID (0x0003)
+
 // Attribute ids for cluster: Poll Control
 
 // Client attributes
index a6caf3a..ee211ce 100644 (file)
@@ -34,4 +34,4 @@ ZCL_DATA8_ATTRIBUTE_TYPE, 1, ZCL_DATA16_ATTRIBUTE_TYPE, 2, ZCL_DATA24_ATTRIBUTE_
     ZCL_DATE_ATTRIBUTE_TYPE, 4, ZCL_UTC_TIME_ATTRIBUTE_TYPE, 4, ZCL_CLUSTER_ID_ATTRIBUTE_TYPE, 2, ZCL_ATTRIBUTE_ID_ATTRIBUTE_TYPE,
     2, ZCL_BACNET_OID_ATTRIBUTE_TYPE, 4, ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, 8, ZCL_SECURITY_KEY_ATTRIBUTE_TYPE, 16,
     ZCL_ENDPOINT_ID_ATTRIBUTE_TYPE, 1, ZCL_GROUP_ID_ATTRIBUTE_TYPE, 2, ZCL_COMMAND_ID_ATTRIBUTE_TYPE, 1, ZCL_NODE_ID_ATTRIBUTE_TYPE,
-    8,
+    8, ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE, 4,
index 56900dc..6f12999 100644 (file)
@@ -82,5 +82,6 @@ enum
     ZCL_GROUP_ID_ATTRIBUTE_TYPE          = 0xF3, // Group Id
     ZCL_COMMAND_ID_ATTRIBUTE_TYPE        = 0xF4, // Command Id
     ZCL_NODE_ID_ATTRIBUTE_TYPE           = 0xF5, // Node Id
+    ZCL_DEVICE_TYPE_ID_ATTRIBUTE_TYPE    = 0xF6, // Device Type Id
     ZCL_UNKNOWN_ATTRIBUTE_TYPE           = 0xFF, // Unknown
 };
index 499adf9..bbd16b6 100644 (file)
@@ -71,6 +71,9 @@
 // Definitions for cluster: Appliance Control
 #define ZCL_APPLIANCE_CONTROL_CLUSTER_ID (0x001B)
 
+// Definitions for cluster: Descriptor
+#define ZCL_DESCRIPTOR_CLUSTER_ID (0x001D)
+
 // Definitions for cluster: Poll Control
 #define ZCL_POLL_CONTROL_CLUSTER_ID (0x0020)
 
index 0c5f81d..7f78df5 100644 (file)
 #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x
 #define ZAP_REPORT_DIRECTION(x) ZRD(x)
 
+// User options for plugin Reporting
+#define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (0)
+#define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS
+
 #define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (0)
 #define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS                                                                               \
     {                                                                                                                              \
index 5cb5a91..4054969 100644 (file)
 #define CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER
 #endif
 
+#if defined(ZCL_USING_DESCRIPTOR_CLUSTER_SERVER) || defined(ZCL_USING_DESCRIPTOR_CLUSTER_CLIENT)
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER { ZCL_DESCRIPTOR_CLUSTER_ID, 29, "Descriptor" },
+#else
+#define CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER
+#endif
+
 #if defined(ZCL_USING_POLL_CONTROL_CLUSTER_SERVER) || defined(ZCL_USING_POLL_CONTROL_CLUSTER_CLIENT)
 #define CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER { ZCL_POLL_CONTROL_CLUSTER_ID, 32, "Poll Control" },
 #else
     CHIP_PRINTCLUSTER_OTA_BOOTLOAD_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_POWER_PROFILE_CLUSTER                                                                                        \
     CHIP_PRINTCLUSTER_APPLIANCE_CONTROL_CLUSTER                                                                                    \
+    CHIP_PRINTCLUSTER_DESCRIPTOR_CLUSTER                                                                                           \
     CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER                                                                                         \
     CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER                                                                                          \
     CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER                                                                                            \
index fbf640d..eec3483 100755 (executable)
@@ -101,7 +101,7 @@ declare -a args=(
 
 [[ $CONFIGURATION != Debug* ]] && args+='is_debug=true'
 
-[[ $PLATFORM_FAMILY_NAME == iOS || $PLATFORM_FAMILY_NAME == watchOS || $PLATFORM_FAMILY_NAME == tvOS ]] && {
+[[ $PLATFORM_FAMILY_NAME != macOS ]] && {
     args+=(
         'target_os="ios"'
         'import("//config/ios/args.gni")'
index 9cde2a4..739cebf 100644 (file)
@@ -829,20 +829,6 @@ GenericConfigurationManagerImpl<ImplClass>::_GetBLEDeviceIdentificationInfo(Ble:
     SuccessOrExit(err);
     deviceIdInfo.SetDeviceDiscriminator(discriminator);
 
-    // TODO: Update when CHIP service/fabric provision is implemented
-#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
-    deviceIdInfo.PairingStatus = ThreadStackMgr().IsThreadAttached()
-        ? Ble::ChipBLEDeviceIdentificationInfo::kPairingStatus_Paired
-        : Ble::ChipBLEDeviceIdentificationInfo::kPairingStatus_Unpaired;
-#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
-    deviceIdInfo.PairingStatus = ConnectivityMgr().IsWiFiStationConnected()
-        ? Ble::ChipBLEDeviceIdentificationInfo::kPairingStatus_Paired
-        : Ble::ChipBLEDeviceIdentificationInfo::kPairingStatus_Unpaired;
-#else
-    deviceIdInfo.PairingStatus = Impl()->_IsPairedToAccount() ? Ble::ChipBLEDeviceIdentificationInfo::kPairingStatus_Paired
-                                                              : Ble::ChipBLEDeviceIdentificationInfo::kPairingStatus_Unpaired;
-#endif
-
 exit:
     return err;
 }
index 3afa06c..dae75bd 100644 (file)
@@ -29,6 +29,8 @@
 #include <platform/internal/CHIPDeviceLayerInternal.h>
 #include <platform/internal/GenericPlatformManagerImpl_FreeRTOS.h>
 
+#include <lib/support/CodeUtils.h>
+
 // Include the non-inline definitions for the GenericPlatformManagerImpl<> template,
 // from which the GenericPlatformManagerImpl_FreeRTOS<> template inherits.
 #include <platform/internal/GenericPlatformManagerImpl.cpp>
@@ -57,7 +59,12 @@ CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_InitChipStack(void)
         ExitNow(err = CHIP_ERROR_NO_MEMORY);
     }
 
+#if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_QUEUE) && CHIP_CONFIG_FREERTOS_USE_STATIC_QUEUE
+    mChipEventQueue =
+        xQueueCreateStatic(CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE, sizeof(ChipDeviceEvent), mEventQueueBuffer, &mEventQueueStruct);
+#else
     mChipEventQueue = xQueueCreate(CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE, sizeof(ChipDeviceEvent));
+#endif
     if (mChipEventQueue == NULL)
     {
         ChipLogError(DeviceLayer, "Failed to allocate CHIP event queue");
@@ -108,10 +115,7 @@ void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_RunEventLoop(void)
     CHIP_ERROR err;
     ChipDeviceEvent event;
 
-    VerifyOrDie(mEventLoopTask == NULL);
-
-    // Capture the task handle.
-    mEventLoopTask = xTaskGetCurrentTaskHandle();
+    VerifyOrDie(mEventLoopTask != NULL);
 
     // Lock the CHIP stack.
     Impl()->LockChipStack();
@@ -182,13 +186,15 @@ void GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_RunEventLoop(void)
 template <class ImplClass>
 CHIP_ERROR GenericPlatformManagerImpl_FreeRTOS<ImplClass>::_StartEventLoopTask(void)
 {
-    BaseType_t res;
-
-    res = xTaskCreate(EventLoopTaskMain, CHIP_DEVICE_CONFIG_CHIP_TASK_NAME,
-                      CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE / sizeof(StackType_t), this, CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY,
-                      NULL);
-
-    return (res == pdPASS) ? CHIP_NO_ERROR : CHIP_ERROR_NO_MEMORY;
+#if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_TASK) && CHIP_CONFIG_FREERTOS_USE_STATIC_TASK
+    mEventLoopTask = xTaskCreateStatic(EventLoopTaskMain, CHIP_DEVICE_CONFIG_CHIP_TASK_NAME, ArraySize(mEventLoopStack), this,
+                                       CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY, mEventLoopStack, &mventLoopTaskStruct);
+#else
+    xTaskCreate(EventLoopTaskMain, CHIP_DEVICE_CONFIG_CHIP_TASK_NAME, CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE / sizeof(StackType_t),
+                this, CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY, &mEventLoopTask);
+#endif
+
+    return (mEventLoopTask != NULL) ? CHIP_NO_ERROR : CHIP_ERROR_NO_MEMORY;
 }
 
 template <class ImplClass>
index 11dba84..0d4b83b 100644 (file)
@@ -53,6 +53,7 @@ namespace Internal {
 template <class ImplClass>
 class GenericPlatformManagerImpl_FreeRTOS : public GenericPlatformManagerImpl<ImplClass>
 {
+
 protected:
     TimeOut_t mNextTimerBaseTime;
     TickType_t mNextTimerDurationTicks;
@@ -83,6 +84,16 @@ private:
     inline ImplClass * Impl() { return static_cast<ImplClass *>(this); }
 
     static void EventLoopTaskMain(void * arg);
+
+#if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_QUEUE) && CHIP_CONFIG_FREERTOS_USE_STATIC_QUEUE
+    uint8_t mEventQueueBuffer[CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE * sizeof(ChipDeviceEvent)];
+    StaticQueue_t mEventQueueStruct;
+#endif
+
+#if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_TASK) && CHIP_CONFIG_FREERTOS_USE_STATIC_TASK
+    StackType_t mEventLoopStack[CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE / sizeof(StackType_t)];
+    StaticTask_t mventLoopTaskStruct;
+#endif
 };
 
 // Instruct the compiler to instantiate the template only when explicitly told to do so.
index eb3497d..d0c2605 100644 (file)
@@ -94,7 +94,7 @@ if (chip_enable_happy_tests) {
     public_configs = [ ":tests_config" ]
 
     public_deps = [
-      ":tests_common",
+      ":tests_lib",
       "${chip_root}/src/inet",
       "${chip_root}/src/lib/core",
       "${nlunit_test_root}:nlunit-test",
index 529c5e0..d3ea487 100644 (file)
@@ -56,6 +56,7 @@ buildconfig_header("chip_buildconfig") {
     "CHIP_CONFIG_MEMORY_DEBUG_CHECKS=${chip_config_memory_debug_checks}",
     "CHIP_CONFIG_MEMORY_DEBUG_DMALLOC=${chip_config_memory_debug_dmalloc}",
     "CHIP_CONFIG_PROVIDE_OBSOLESCENT_INTERFACES=false",
+    "CHIP_ENABLE_INTERACTION_MODEL=${chip_enable_interaction_model}",
   ]
 }
 
index a8ecb4c..54079c8 100644 (file)
@@ -85,6 +85,8 @@ public:
      * @return CHIP_ERROR_KEY_NOT_FOUND there is no value for the given key.
      * @return CHIP_ERROR_NO_MEMORY if the input buffer is not big enough for
      *                              the value.
+     * @return CHIP_ERROR_BUFFER_TOO_SMALL if the value's size is too large to
+     *                                     be expressed as a uint16_t.
      */
     virtual CHIP_ERROR SyncGetKeyValue(const char * key, char * value, uint16_t & size) { return CHIP_ERROR_NOT_IMPLEMENTED; }
 
index 15d6ea2..5b4b795 100644 (file)
@@ -44,6 +44,9 @@ declare_args() {
 
   # Memory management debug option: use dmalloc
   chip_config_memory_debug_dmalloc = false
+
+  # Overall experimental options for CHIP
+  chip_enable_interaction_model = false
 }
 
 if (chip_target_style == "") {
index 9ba5e5c..d5d2612 100644 (file)
@@ -133,7 +133,7 @@ static_library("support") {
   ]
 
   if (chip_config_memory_management == "simple") {
-    sources += [ "CHIPMem-SimpleAlloc.cpp" ]
+    sources += [ "CHIPMem-Simple.cpp" ]
   }
   if (chip_config_memory_management == "malloc") {
     sources += [ "CHIPMem-Malloc.cpp" ]
index 8de9fb1..3d9d7e0 100644 (file)
@@ -132,7 +132,7 @@ public:
      * @param flag      Flag(s) to test.
      * @returns         True if any flag in @a flag is set, otherwise false.
      */
-    bool Has(FlagsEnum flag) const { return (mValue & static_cast<IntegerType>(flag)) != 0; }
+    constexpr bool Has(FlagsEnum flag) const { return (mValue & static_cast<IntegerType>(flag)) != 0; }
 
     /**
      * Check that no flags outside the arguments are set.
index ce42482..a8db80c 100644 (file)
@@ -55,11 +55,12 @@ BufferWriter & BufferWriter::Put(uint8_t c)
 
 LittleEndian::BufferWriter & LittleEndian::BufferWriter::EndianPut(uint64_t x, size_t size)
 {
-    while (size-- > 0)
+    while (size > 0)
     {
         uint8_t c = x & 0xff;
         Put(c);
         x >>= 8;
+        size--;
     }
     return *this;
 }
index 2d8b6b9..7a8c5d7 100644 (file)
@@ -103,12 +103,6 @@ void MemoryAllocatorShutdown()
 void * MemoryAlloc(size_t size)
 {
     VERIFY_INITIALIZED();
-    return MemoryAlloc(size, false);
-}
-
-void * MemoryAlloc(size_t size, bool isLongTermAlloc)
-{
-    VERIFY_INITIALIZED();
     return malloc(size);
 }
 
diff --git a/src/lib/support/CHIPMem-Simple.cpp b/src/lib/support/CHIPMem-Simple.cpp
new file mode 100644 (file)
index 0000000..e2b41cd
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ *
+ *    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.
+ */
+
+#include "CHIPMem.h"
+#include "PrivateHeap.h"
+
+#include <string.h>
+
+#include <support/CodeUtils.h>
+#include <system/SystemMutex.h>
+
+namespace chip {
+namespace Platform {
+
+namespace {
+
+void * gPrivateHeap = nullptr;
+
+#if CHIP_SYSTEM_CONFIG_NO_LOCKING
+
+class HeapLocked
+{
+public:
+    HeapLocked() {}
+    ~HeapLocked() {}
+};
+
+#else
+
+chip::System::Mutex gHeapLock;
+
+class HeapLocked
+{
+public:
+    HeapLocked() { gHeapLock.Lock(); }
+    ~HeapLocked() { gHeapLock.Unlock(); }
+};
+#endif
+
+} // namespace
+
+CHIP_ERROR MemoryAllocatorInit(void * buf, size_t bufSize)
+{
+    ReturnErrorCodeIf(buf == nullptr, CHIP_ERROR_INVALID_ARGUMENT);
+    ReturnErrorCodeIf(gPrivateHeap != nullptr, CHIP_ERROR_INCORRECT_STATE);
+
+    PrivateHeapInit(buf, bufSize);
+    gPrivateHeap = buf;
+
+#if CHIP_SYSTEM_CONFIG_NO_LOCKING
+    return CHIP_NO_ERROR;
+#else
+    return chip::System::Mutex::Init(gHeapLock);
+#endif
+}
+
+void MemoryAllocatorShutdown()
+{
+    gPrivateHeap = nullptr;
+}
+
+void * MemoryAlloc(size_t size)
+{
+    HeapLocked lock;
+
+    if (gPrivateHeap == nullptr)
+    {
+        return nullptr;
+    }
+
+    return PrivateHeapAlloc(gPrivateHeap, size);
+}
+
+void * MemoryCalloc(size_t num, size_t size)
+{
+    size_t total = num * size;
+
+    // check for multiplication overflow
+    if (size != total / num)
+    {
+        return nullptr;
+    }
+
+    void * result = MemoryAlloc(total);
+    if (result != nullptr)
+    {
+        memset(result, 0, total);
+    }
+    return result;
+}
+
+void * MemoryRealloc(void * p, size_t size)
+{
+    HeapLocked lock;
+
+    if (gPrivateHeap == nullptr)
+    {
+        return nullptr;
+    }
+
+    return PrivateHeapRealloc(gPrivateHeap, p, size);
+}
+
+void MemoryFree(void * p)
+{
+    HeapLocked lock;
+
+    if (gPrivateHeap == nullptr)
+    {
+        return;
+    }
+    PrivateHeapFree(p);
+}
+
+} // namespace Platform
+} // namespace chip
diff --git a/src/lib/support/CHIPMem-SimpleAlloc.cpp b/src/lib/support/CHIPMem-SimpleAlloc.cpp
deleted file mode 100644 (file)
index 4099e74..0000000
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- *
- *    Copyright (c) 2020-2021 Project CHIP Authors
- *    Copyright (c) 2019-2020 Google LLC.
- *    Copyright (c) 2018 Nest Labs, Inc.
- *    All rights reserved.
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-
-/**
- *    @file
- *      This file implements memory management functions for the CHIP.
- *      This implementation, known as the "Simple Allocator", is based on temporary
- *      network buffer allocation/release. This implementation is used when
- *      #CHIP_CONFIG_MEMORY_MGMT_SIMPLE is enabled (1).
- *
- *      The simple allocator was designed for highly memory-constrained embedded systems.
- *      This allocator assumes that the number of memory blocks, their sizes and
- *      the order in which they are requested/released by the CHIP is known and doesn't change.
- *      If memory blocks sizes or their allocation order changes this
- *      implementation should be reviewed and adjusted accordingly.
- *
- *      Where available, the library can also consume dedicated memory buffer during memory initialization
- *      with MemoryAllocatorInit() function.
- *
- *      The Simple Allocator design is highly parametrized and the number of
- *      buffers, number and sizes of memory blocks can be changed according to new
- *      requirements.
- *
- */
-
-#include <core/CHIPConfig.h>
-#include <support/CHIPMem.h>
-#include <system/SystemPacketBuffer.h>
-
-#include <string.h>
-
-#if CHIP_CONFIG_MEMORY_MGMT_SIMPLE
-
-namespace chip {
-namespace Platform {
-
-using ::chip::System::PacketBuffer;
-
-/**
- * This type is used to encode block set information. A block set is a group of memory
- * chunks that have same properties (size, type, and belong to the same buffer).
- * Diagram below presents how block set information encoded in an 8-bit format:
- *
- * | Is Long Term | Block Index | Number of Blocks | Block Size |
- * | :----------: | :---------: | :--------------: | :--------: |
- * |     [7]      |   [6:5]     |      [4:3]       |   [2:0]    |
- *
- * [2:0] - Size of memory block in a set. Size value is encoded with 128-byte granularity.
- * | [2:0] | Decoding  |
- * |-------|-----------|
- * |  000  | 0 bytes   |
- * |  001  | 128 bytes |
- * |  010  | 256 bytes |
- * |  ...  | -         |
- * |  111  | 896 bytes |
- *
- * [4:3] - Number of blocks in a set.
- * | [4:3] | Decoding |
- * |-------|----------|
- * |  00   | 4 blocks |
- * |  01   | 1 block  |
- * |  10   | 2 blocks |
- * |  11   | 3 blocks |
- *
- * [6:5] - Network buffer index where memory blocks reside. Note that when dedicated buffer
- *         is used all memory blocks are allocated from dedicated buffer and this index
- *         parameter is ignored.
- * | [6:5] | Decoding          |
- * |-------|-------------------|
- * |  00   | Network buffer #0 |
- * |  ...  | -                 |
- * |  11   | Network buffer #3 |
- *
- * [7] - Specifies if blocks are for long/short term storage.
- * |  [7]  | Decoding                 |
- * |-------|--------------------------|
- * |   0   | Short term memory blocks |
- * |   1   | Long term memory blocks  |
- *
- */
-typedef uint8_t BlockSetParams_t;
-
-/**
- * Block set parameter fields location in an 8-bit encoded form.
- */
-enum BlockSetParamFields
-{
-    kBlockSetSizeMask         = 0x07, /**< Size field mask. */
-    kBlockSetSizeShift        = 0,    /**< Size field shift. */
-    kBlockSetSizeValueShift   = 7,    /**< Size field decoding shift (multiply by 128). */
-    kBlockSetCountMask        = 0x18, /**< Count field mask. */
-    kBlockSetCountShift       = 3,    /**< Count field shift. */
-    kBlockSetBufferIndexMask  = 0x60, /**< Buffer index field mask. */
-    kBlockSetBufferIndexShift = 5,    /**< Buffer index field shift. */
-    kBlockSetIsLongTermMask   = 0x80, /**< Type field mask. */
-    kBlockSetIsLongTermShift  = 7,    /**< Type field shift. */
-};
-
-/**
- * Defines block set parameters.
- */
-#if CHIP_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS
-enum BlockSetParams
-{
-    // Simple Allocator parameters
-    kNumberOfNetworkBuffers            = 4,    /**< Number of network buffers used by Simple Allocator. */
-    kNumberOfBlockSets                 = 5,    /**< Number of block sets used by Simple Allocator. */
-    kNetworkBuffer0BlockAllocationMask = 0x03, /**< This mask identifies all memory blocks allocated from network buffer #0. */
-    kNetworkBuffer1BlockAllocationMask = 0x04, /**< This mask identifies all memory blocks allocated from network buffer #1. */
-    kNetworkBuffer2BlockAllocationMask = 0x08, /**< This mask identifies all memory blocks allocated from network buffer #2. */
-    kNetworkBuffer3BlockAllocationMask = 0x10, /**< This mask identifies all memory blocks allocated from network buffer #3. */
-    // Block Set #1 (1 long-term blocks of 128 bytes)
-    kBlockSet1Size        = 1, /**< Set #1 size is 128 bytes. */
-    kBlockSet1Count       = 1, /**< Set #1 block count is 1. */
-    kBlockSet1BufferIndex = 0, /**< Set #1 buffer index is 0. */
-    kBlockSet1isLongTerm  = 1, /**< Set #1 type is long term. */
-    // Block Set #2 (1 long-term block of 512 bytes)
-    kBlockSet2Size        = 4, /**< Set #2 size is 512 bytes. */
-    kBlockSet2Count       = 1, /**< Set #2 block count is 1. */
-    kBlockSet2BufferIndex = 0, /**< Set #2 buffer index is 0. */
-    kBlockSet2isLongTerm  = 1, /**< Set #2 type is long term. */
-    // Block Set #3 (1 short-term block of 512 bytes)
-    kBlockSet3Size        = 4, /**< Set #3 size is 512 bytes. */
-    kBlockSet3Count       = 1, /**< Set #3 block count is 1. */
-    kBlockSet3BufferIndex = 1, /**< Set #3 buffer index is 1. */
-    kBlockSet3isLongTerm  = 0, /**< Set #3 type is short term. */
-    // Block Set #4 (1 short-term blocks of 640 bytes)
-    kBlockSet4Size        = 5, /**< Set #4 size is 640 bytes. */
-    kBlockSet4Count       = 1, /**< Set #4 block count is 1. */
-    kBlockSet4BufferIndex = 2, /**< Set #4 buffer index is 2. */
-    kBlockSet4isLongTerm  = 0, /**< Set #4 type is short term. */
-    // Block Set #5 (1 short-term blocks of 640 bytes)
-    kBlockSet5Size        = 5, /**< Set #5 size is 640 bytes. */
-    kBlockSet5Count       = 1, /**< Set #5 block count is 1. */
-    kBlockSet5BufferIndex = 3, /**< Set #5 buffer index is 3. */
-    kBlockSet5isLongTerm  = 0, /**< Set #5 type is short term. */
-    /** Total memory used by Simple Allocator. */
-    kTotalMemorySize = (kBlockSet1Size * kBlockSet1Count + kBlockSet2Size * kBlockSet2Count + kBlockSet3Size * kBlockSet3Count +
-                        kBlockSet4Size * kBlockSet4Count + kBlockSet5Size * kBlockSet5Count)
-        << kBlockSetSizeValueShift,
-    /** Maximum block size supported by Simple Allocator. */
-    kMaxBlockSize = 600,
-    /** Minimum network buffer size required to support Simple Allocator use cases. */
-    kMinBufferSize = 600,
-};
-#else  // CHIP_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS
-enum BlockSetParams
-{
-    // Simple Allocator parameters
-    kNumberOfNetworkBuffers            = 2,    /**< Number of network buffers used by Simple Allocator. */
-    kNumberOfBlockSets                 = 4,    /**< Number of block sets used by Simple Allocator. */
-    kNetworkBuffer0BlockAllocationMask = 0x07, /**< This mask identifies all memory blocks allocated from network buffer #0. */
-    kNetworkBuffer1BlockAllocationMask = 0x18, /**< This mask identifies all memory blocks allocated from network buffer #1. */
-    // Block Set #1 (1 long-term blocks of 128 bytes)
-    kBlockSet1Size        = 1, /**< Set #1 size is 128 bytes. */
-    kBlockSet1Count       = 1, /**< Set #1 block count is 1. */
-    kBlockSet1BufferIndex = 0, /**< Set #1 buffer index is 0. */
-    kBlockSet1isLongTerm  = 1, /**< Set #1 type is long term. */
-    // Block Set #2 (1 long-term block of 512 bytes)
-    kBlockSet2Size        = 4, /**< Set #2 size is 512 bytes. */
-    kBlockSet2Count       = 1, /**< Set #2 block count is 1. */
-    kBlockSet2BufferIndex = 0, /**< Set #2 buffer index is 0. */
-    kBlockSet2isLongTerm  = 1, /**< Set #2 type is long term. */
-    // Block Set #3 (1 short-term block of 512 bytes)
-    kBlockSet3Size        = 4, /**< Set #3 size is 512 bytes. */
-    kBlockSet3Count       = 1, /**< Set #3 block count is 1. */
-    kBlockSet3BufferIndex = 0, /**< Set #3 buffer index is 0. */
-    kBlockSet3isLongTerm  = 0, /**< Set #3 type is short term. */
-    // Block Set #4 (2 short-term blocks of 640 bytes)
-    kBlockSet4Size        = 5, /**< Set #4 size is 640 bytes. */
-    kBlockSet4Count       = 2, /**< Set #4 block count is 2. */
-    kBlockSet4BufferIndex = 1, /**< Set #4 buffer index is 1. */
-    kBlockSet4isLongTerm  = 0, /**< Set #4 type is short term. */
-    /** Total memory used by Simple Allocator. */
-    kTotalMemorySize = (kBlockSet1Size * kBlockSet1Count + kBlockSet2Size * kBlockSet2Count + kBlockSet3Size * kBlockSet3Count +
-                        kBlockSet4Size * kBlockSet4Count)
-        << kBlockSetSizeValueShift,
-    /** Maximum block size supported by Simple Allocator. */
-    kMaxBlockSize = 600,
-    /** Minimum network buffer size required to support Simple Allocator use cases. This parameter
-     *  is derived from sizes of two memory block (640 + 600) allocated in the network buffer #1. */
-    kMinBufferSize = 1240,
-};
-#endif // CHIP_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS
-
-/**
- * Encoded block sets parameters.
- */
-static const BlockSetParams_t sBlockSetParams[kNumberOfBlockSets] = {
-    // Parameters for memory block set #1
-    ((kBlockSet1Size << kBlockSetSizeShift) & kBlockSetSizeMask) | ((kBlockSet1Count << kBlockSetCountShift) & kBlockSetCountMask) |
-        ((kBlockSet1BufferIndex << kBlockSetBufferIndexShift) & kBlockSetBufferIndexMask) |
-        ((kBlockSet1isLongTerm << kBlockSetIsLongTermShift) & kBlockSetIsLongTermMask),
-    // Parameters for memory block set #2
-    ((kBlockSet2Size << kBlockSetSizeShift) & kBlockSetSizeMask) | ((kBlockSet2Count << kBlockSetCountShift) & kBlockSetCountMask) |
-        ((kBlockSet2BufferIndex << kBlockSetBufferIndexShift) & kBlockSetBufferIndexMask) |
-        ((kBlockSet2isLongTerm << kBlockSetIsLongTermShift) & kBlockSetIsLongTermMask),
-    // Parameters for memory block set #3
-    ((kBlockSet3Size << kBlockSetSizeShift) & kBlockSetSizeMask) | ((kBlockSet3Count << kBlockSetCountShift) & kBlockSetCountMask) |
-        ((kBlockSet3BufferIndex << kBlockSetBufferIndexShift) & kBlockSetBufferIndexMask) |
-        ((kBlockSet3isLongTerm << kBlockSetIsLongTermShift) & kBlockSetIsLongTermMask),
-    // Parameters for memory block set #4
-    ((kBlockSet4Size << kBlockSetSizeShift) & kBlockSetSizeMask) | ((kBlockSet4Count << kBlockSetCountShift) & kBlockSetCountMask) |
-        ((kBlockSet4BufferIndex << kBlockSetBufferIndexShift) & kBlockSetBufferIndexMask) |
-        ((kBlockSet4isLongTerm << kBlockSetIsLongTermShift) & kBlockSetIsLongTermMask),
-#if CHIP_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS
-    // Parameters for memory block set #5
-    ((kBlockSet5Size << kBlockSetSizeShift) & kBlockSetSizeMask) | ((kBlockSet5Count << kBlockSetCountShift) & kBlockSetCountMask) |
-        ((kBlockSet5BufferIndex << kBlockSetBufferIndexShift) & kBlockSetBufferIndexMask) |
-        ((kBlockSet5isLongTerm << kBlockSetIsLongTermShift) & kBlockSetIsLongTermMask),
-#endif
-};
-
-/**
- * The type used to mark which block is currently allocated/unallocated.
- *   uint8_t  - supports upto 8 memory blocks total
- *   uint16_t - supports upto 16 memory blocks total
- *   uint32_t - supports upto 32 memory blocks total
- *
- */
-typedef uint8_t BlockMark_t;
-
-/**
- * Indicates which block is allocated/unallocated.
- * Initialized to 0 - means that all memory blocks and unallocated.
- *
- */
-static BlockMark_t sMemBlocksAllocated = 0;
-
-/**
- * Set of buffer block masks.
- * Identifies if all blocks in the buffer and unallocated and then the buffer can be relieazed.
- *
- */
-static const BlockMark_t sBufferAllocationMask[kNumberOfNetworkBuffers] = {
-    kNetworkBuffer0BlockAllocationMask,
-    kNetworkBuffer1BlockAllocationMask,
-#if CHIP_CONFIG_SIMPLE_ALLOCATOR_USE_SMALL_BUFFERS
-    kNetworkBuffer2BlockAllocationMask,
-    kNetworkBuffer3BlockAllocationMask,
-#endif
-};
-
-/**
- * A boolean indicating whether (true) or not (false) the network buffers are used by Simple Allocator.
- * When false - dedicated buffer provided with MemoryAllocatorInit() function is used.
- *
- */
-static bool sNetworkBuffersUsed = true;
-
-/**
- * Pointers to memory buffers initialized to NULL.
- * When network buffers are used sMemBufs[] point to the PacketBuffer objects.
- * When dedicated buffer is used sMemBufs[0] points to that buffer and other sMemBufs[] pointers are ignored.
- *
- */
-static void * sMemBufs[kNumberOfNetworkBuffers] = { NULL };
-
-static void DecodeBlockSetParams(BlockSetParams_t blockSetParams, uint16_t & blockSize, uint8_t & blockCount,
-                                 uint8_t & blockBufferIndex, bool & blockIsLongTerm)
-{
-    blockSize  = ((blockSetParams & kBlockSetSizeMask) >> kBlockSetSizeShift) << kBlockSetSizeValueShift;
-    blockCount = (blockSetParams & kBlockSetCountMask) >> kBlockSetCountShift;
-    if (sNetworkBuffersUsed)
-        blockBufferIndex = (blockSetParams & kBlockSetBufferIndexMask) >> kBlockSetBufferIndexShift;
-    else
-        blockBufferIndex = 0;
-    blockIsLongTerm = (blockSetParams & kBlockSetIsLongTermMask) == kBlockSetIsLongTermMask;
-}
-
-static uint16_t GetBlockSize(void * p)
-{
-    BlockMark_t blockIndex                         = 0x01;
-    uint16_t bufferOffset[kNumberOfNetworkBuffers] = { 0 };
-    uint16_t blockSize;
-    uint8_t blockCount;
-    uint8_t blockBufferIndex;
-    bool blockIsLongTerm;
-    uint8_t * memBufStart;
-    uint8_t i;
-
-    for (i = 0; i < kNumberOfBlockSets; i++)
-    {
-        DecodeBlockSetParams(sBlockSetParams[i], blockSize, blockCount, blockBufferIndex, blockIsLongTerm);
-
-        if (sMemBufs[blockBufferIndex] != NULL)
-        {
-            if (sNetworkBuffersUsed)
-                memBufStart = ((PacketBuffer *) sMemBufs[blockBufferIndex])->Start();
-            else
-                memBufStart = (uint8_t *) sMemBufs[blockBufferIndex];
-
-            if (p >= memBufStart + bufferOffset[blockBufferIndex] &&
-                p < memBufStart + bufferOffset[blockBufferIndex] + blockSize * blockCount)
-            {
-                for (uint8_t j = 0; j < blockCount; j++)
-                {
-                    if (p == memBufStart + bufferOffset[blockBufferIndex])
-                    {
-                        return blockSize;
-                    }
-                    else
-                    {
-                        blockIndex <<= 1;
-                        bufferOffset[blockBufferIndex] += blockSize;
-                    }
-                }
-            }
-        }
-        blockIndex <<= blockCount;
-        bufferOffset[blockBufferIndex] += blockSize * blockCount;
-    }
-
-    return 0;
-}
-
-CHIP_ERROR MemoryAllocatorInit(void * buf, size_t bufSize)
-{
-    if (buf != NULL)
-    {
-        // align on 4-byte boundary
-        const uint8_t bufByteOffset = ((unsigned long) buf) % 4;
-
-        if (bufByteOffset != 0)
-        {
-            const uint8_t bufBytePadding = 4 - bufByteOffset;
-
-            buf = (void *) (((uint8_t *) buf) + bufBytePadding);
-            bufSize -= bufBytePadding;
-        }
-
-        if (bufSize < kTotalMemorySize)
-            return CHIP_ERROR_BUFFER_TOO_SMALL;
-
-        sMemBufs[0]         = buf;
-        sNetworkBuffersUsed = false;
-    }
-
-    return CHIP_NO_ERROR;
-}
-
-void MemoryAllocatorShutdown()
-{
-    if (sNetworkBuffersUsed)
-    {
-        for (uint8_t i = 0; i < kNumberOfNetworkBuffers; i++)
-            if (sMemBufs[i] != NULL)
-            {
-                PacketBuffer::Free((PacketBuffer *) sMemBufs[i]);
-                sMemBufs[i] = NULL;
-            }
-    }
-    else
-    {
-        sMemBufs[0] = NULL;
-    }
-
-    sNetworkBuffersUsed = true;
-    sMemBlocksAllocated = 0;
-}
-
-void * MemoryAlloc(size_t size)
-{
-    return MemoryAlloc(size, false);
-}
-
-void * MemoryAlloc(size_t size, bool isLongTermAlloc)
-{
-    BlockMark_t blockIndex                         = 0x01;
-    uint16_t bufferOffset[kNumberOfNetworkBuffers] = { 0 };
-    uint16_t blockSize;
-    uint8_t blockCount;
-    uint8_t blockBufferIndex;
-    bool blockIsLongTerm;
-    uint8_t * memBufStart;
-
-    if (size == 0 || size > kMaxBlockSize)
-        return NULL;
-
-    for (uint8_t i = 0; i < kNumberOfBlockSets; i++)
-    {
-        DecodeBlockSetParams(sBlockSetParams[i], blockSize, blockCount, blockBufferIndex, blockIsLongTerm);
-
-        if (size <= blockSize && (isLongTermAlloc || !blockIsLongTerm))
-        {
-            for (uint8_t j = 0; j < blockCount; j++)
-            {
-                if (!(blockIndex & sMemBlocksAllocated))
-                {
-                    if (sNetworkBuffersUsed)
-                    {
-                        if (sMemBufs[blockBufferIndex] == NULL)
-                        {
-                            sMemBufs[blockBufferIndex] = PacketBufferHandle::New(kMinBufferSize, 0).UnsafeRelease();
-                            if (sMemBufs[blockBufferIndex] == NULL)
-                                return NULL;
-                        }
-                        memBufStart = ((PacketBuffer *) sMemBufs[blockBufferIndex])->Start();
-                    }
-                    else
-                    {
-                        memBufStart = (uint8_t *) sMemBufs[blockBufferIndex];
-                    }
-
-                    // Mark memory block as allocated and return pointer to this block
-                    sMemBlocksAllocated |= blockIndex;
-                    return (memBufStart + bufferOffset[blockBufferIndex]);
-                }
-                else
-                {
-                    blockIndex <<= 1;
-                    bufferOffset[blockBufferIndex] += blockSize;
-                }
-            }
-        }
-        else
-        {
-            blockIndex <<= blockCount;
-            bufferOffset[blockBufferIndex] += blockSize * blockCount;
-        }
-    }
-
-    return NULL;
-}
-
-void * MemoryCalloc(size_t num, size_t size)
-{
-    size_t len;
-    void * block;
-
-    if (!num || !size)
-        return NULL;
-
-    len = num * size;
-
-    /* check mul overflow */
-    if (size != len / num)
-        return NULL;
-
-    block = MemoryAlloc(len);
-    if (!block)
-        return NULL;
-
-    memset(block, 0, len);
-
-    return block;
-}
-
-void * MemoryRealloc(void * p, size_t size)
-{
-    void * ret;
-    uint16_t blockSize;
-
-    if (!p || !size)
-        return MemoryAlloc(size);
-
-    blockSize = GetBlockSize(p);
-    if (blockSize >= size)
-        return p;
-
-    ret = MemoryAlloc(size);
-    if (ret)
-    {
-        memcpy(ret, p, blockSize);
-        MemoryFree(p);
-    }
-
-    return ret;
-}
-
-void MemoryFree(void * p)
-{
-    BlockMark_t blockIndex                         = 0x01;
-    uint16_t bufferOffset[kNumberOfNetworkBuffers] = { 0 };
-    uint16_t blockSize;
-    uint8_t blockCount;
-    uint8_t blockBufferIndex;
-    bool blockIsLongTerm;
-    uint8_t * memBufStart;
-    uint8_t i;
-
-    for (i = 0; i < kNumberOfBlockSets; i++)
-    {
-        DecodeBlockSetParams(sBlockSetParams[i], blockSize, blockCount, blockBufferIndex, blockIsLongTerm);
-
-        if (sMemBufs[blockBufferIndex] != NULL)
-        {
-            if (sNetworkBuffersUsed)
-                memBufStart = ((PacketBuffer *) sMemBufs[blockBufferIndex])->Start();
-            else
-                memBufStart = (uint8_t *) sMemBufs[blockBufferIndex];
-
-            if (p >= memBufStart + bufferOffset[blockBufferIndex] &&
-                p < memBufStart + bufferOffset[blockBufferIndex] + blockSize * blockCount)
-            {
-                for (uint8_t j = 0; j < blockCount; j++)
-                {
-                    if (p == memBufStart + bufferOffset[blockBufferIndex])
-                    {
-                        // Mark memory block as unallocated
-                        sMemBlocksAllocated &= ~blockIndex;
-                        // Release network buffer if all its memory blocks are unallocated
-                        if (sNetworkBuffersUsed && !(sMemBlocksAllocated & sBufferAllocationMask[blockBufferIndex]))
-                        {
-                            PacketBuffer::Free((PacketBuffer *) sMemBufs[blockBufferIndex]);
-                            sMemBufs[blockBufferIndex] = NULL;
-                        }
-                        return;
-                    }
-                    else
-                    {
-                        blockIndex <<= 1;
-                        bufferOffset[blockBufferIndex] += blockSize;
-                    }
-                }
-            }
-        }
-        blockIndex <<= blockCount;
-        bufferOffset[blockBufferIndex] += blockSize * blockCount;
-    }
-}
-
-bool MemoryInternalCheckPointer(const void * p, size_t min_size)
-{
-    // TODO: check that \a p is actually an allocated pointer,
-    // by factoring the allocation-finding out of MemoryFree().
-    return p != nullptr;
-}
-
-} // namespace Platform
-} // namespace chip
-
-#endif // CHIP_CONFIG_MEMORY_MGMT_SIMPLE
index 8604260..1e2f99b 100644 (file)
@@ -81,30 +81,6 @@ extern void MemoryShutdown();
  *
  * @param[in]  size             Specifies requested memory size in bytes.
  *
- * @param[in]  isLongTermAlloc  A Boolean indicating whether (true) or not (false) the
- *                              requested memory block is for long term use. A long term
- *                              allocation is memory that should stay allocated until secure
- *                              session/handshake is complete. Examples of a long term
- *                              allocation include blocks allocated for CASE/PASE objects
- *                              and their context data. A short term allocation is a memory
- *                              needed to perform specific operation and can be released
- *                              immediately after that. This input helps to optimize memory
- *                              utilization in a memory constrained system. Use of this parameter
- *                              is arbitrary and depends on function implementer. For example,
- *                              this parameter is ignored when the C Standard Library malloc()
- *                              is used.
- *
- * @retval  Pointer to a memory block in case of success.
- * @retval  NULL-pointer if memory allocation fails.
- *
- */
-extern void * MemoryAlloc(size_t size, bool isLongTermAlloc);
-
-/**
- * This function is called by the CHIP layer to allocate a block of memory of "size" bytes.
- *
- * @param[in]  size             Specifies requested memory size in bytes.
- *
  * @retval  Pointer to a memory block in case of success.
  * @retval  NULL-pointer if memory allocation fails.
  *
index 53b4493..ff5c693 100644 (file)
@@ -34,11 +34,6 @@ extern void CHIPPlatformMemoryShutdown()
     return chip::Platform::MemoryShutdown();
 }
 
-extern void * CHIPPlatformMemoryAllocLongTerm(size_t size, bool isLongTermAlloc)
-{
-    return chip::Platform::MemoryAlloc(size, isLongTermAlloc);
-}
-
 extern void * CHIPPlatformMemoryAlloc(size_t size)
 {
     return chip::Platform::MemoryAlloc(size);
index 494890f..182ba31 100644 (file)
@@ -34,7 +34,6 @@ extern "C" {
 
 extern int CHIPPlatformMemoryInit(void * buf, size_t bufSize);
 extern void CHIPPlatformMemoryShutdown();
-extern void * CHIPPlatformMemoryAllocLongTerm(size_t size, bool isLongTermAlloc);
 extern void * CHIPPlatformMemoryAlloc(size_t size);
 extern void * CHIPPlatformMemoryCalloc(size_t num, size_t size);
 extern void * CHIPPlatformMemoryRealloc(void * p, size_t size);
index 9e198bc..79167a3 100644 (file)
@@ -26,6 +26,8 @@
 
 #pragma once
 
+#ifdef __cplusplus
+
 #include <core/CHIPError.h>
 #include <support/ErrorStr.h>
 #include <support/logging/CHIPLogging.h>
@@ -478,24 +480,7 @@ inline void chipDie(void)
 #define VerifyOrDieWithMsg(aCondition, aModule, aMessage, ...)                                                                     \
     nlABORT_ACTION(aCondition, ChipLogDetail(aModule, aMessage, ##__VA_ARGS__))
 
-/**
- * @def ArraySize(aArray)
- *
- * @brief
- *   Returns the size of an array in number of elements.
- *
- * Example Usage:
- *
- * @code
- * int numbers[10];
- * SortNumbers(numbers, ArraySize(numbers));
- * @endcode
- *
- * @return      The size of an array in number of elements.
- */
-#define ArraySize(a) (sizeof(a) / sizeof((a)[0]))
-
-#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#if (__cplusplus >= 201103L)
 
 #ifndef __FINAL
 #define __FINAL final
@@ -523,10 +508,9 @@ inline void chipDie(void)
 #define __CONSTEXPR constexpr
 #endif
 
-#endif // defined(__cplusplus) && (__cplusplus >= 201103L)
+#endif // (__cplusplus >= 201103L)
 
-#if defined(__cplusplus) &&                                                                                                        \
-    ((__cplusplus >= 201703L) || (defined(__GNUC__) && (__GNUC__ >= 7)) || (defined(__clang__)) && (__clang_major__ >= 4))
+#if ((__cplusplus >= 201703L) || (defined(__GNUC__) && (__GNUC__ >= 7)) || (defined(__clang__)) && (__clang_major__ >= 4))
 #define CHECK_RETURN_VALUE [[nodiscard]]
 #elif defined(__GNUC__) && (__GNUC__ >= 4)
 #define CHECK_RETURN_VALUE __attribute__((warn_unused_result))
@@ -541,3 +525,26 @@ inline void chipDie(void)
 #else
 #define FALLTHROUGH (void) 0
 #endif
+
+#endif // __cplusplus
+
+/**
+ * @def ArraySize(aArray)
+ *
+ * @brief
+ *   Returns the size of an array in number of elements.
+ *
+ * Example Usage:
+ *
+ * @code
+ * int numbers[10];
+ * SortNumbers(numbers, ArraySize(numbers));
+ * @endcode
+ *
+ * @return      The size of an array in number of elements.
+ *
+ * @note Clever template-based solutions seem to fail when ArraySize is used
+ *       with a variable-length array argument, so we just do the C-compatible
+ *       thing in C++ as well.
+ */
+#define ArraySize(a) (sizeof(a) / sizeof((a)[0]))
index e906792..b4c4535 100644 (file)
@@ -18,6 +18,8 @@
 
 #include "PrivateHeap.h"
 
+#include <string.h>
+
 #include <support/CodeUtils.h>
 #include <support/logging/CHIPLogging.h>
 
@@ -267,6 +269,43 @@ extern "C" void PrivateHeapFree(void * ptr)
     }
 }
 
+void * PrivateHeapRealloc(void * heap, void * ptr, size_t size)
+{
+    if (ptr == nullptr)
+    {
+        return PrivateHeapAlloc(heap, size);
+    }
+
+    if (size == 0)
+    {
+        PrivateHeapFree(ptr);
+        return nullptr;
+    }
+
+    PrivateHeapBlockHeader * header =
+        reinterpret_cast<PrivateHeapBlockHeader *>(static_cast<char *>(ptr) - sizeof(PrivateHeapBlockHeader));
+
+    ValidateHeader(header);
+
+    if (header->nextBytes >= size)
+    {
+        return ptr; // no reallocation needed
+    }
+
+    void * largerCopy = PrivateHeapAlloc(heap, size);
+    if (largerCopy == nullptr)
+    {
+        // NOTE: original is left untouched (not freed) to match realloc() libc
+        // functionality
+        return nullptr;
+    }
+
+    memcpy(largerCopy, ptr, header->nextBytes);
+    PrivateHeapFree(ptr);
+
+    return largerCopy;
+}
+
 extern "C" void PrivateHeapDump(void * top)
 {
     PrivateHeapBlockHeader * header = reinterpret_cast<PrivateHeapBlockHeader *>(top);
index e62c64b..864497a 100644 (file)
@@ -38,6 +38,12 @@ void * PrivateHeapAlloc(void * heap, size_t size);
 // Marks the specified block as free
 void PrivateHeapFree(void * ptr);
 
+// Reallocate a block to a new size
+// Special arguments:
+//    - null ptr value represents an Alloc
+//    - zero size represents a Free
+void * PrivateHeapRealloc(void * heap, void * ptr, size_t size);
+
 void PrivateHeapDump(void * ptr);
 
 #ifdef __cplusplus
index d6e3407..137aafe 100644 (file)
@@ -100,12 +100,6 @@ protected:
         mBuffer = Impl::MemoryAlloc(size);
     }
 
-    void LongTermAlloc(size_t size)
-    {
-        Free();
-        mBuffer = Impl::MemoryAlloc(size, true /* isLongTermAlloc */);
-    }
-
     void Calloc(size_t elementCount, size_t elementSize)
     {
         Free();
@@ -124,7 +118,6 @@ class PlatformMemoryManagement
 public:
     static void MemoryFree(void * p) { chip::Platform::MemoryFree(p); }
     static void * MemoryAlloc(size_t size) { return chip::Platform::MemoryAlloc(size); }
-    static void * MemoryAlloc(size_t size, bool longTerm) { return chip::Platform::MemoryAlloc(size, longTerm); }
     static void * MemoryCalloc(size_t num, size_t size) { return chip::Platform::MemoryCalloc(num, size); }
 };
 
@@ -165,12 +158,6 @@ public:
         Base::Alloc(size * sizeof(T));
         return *this;
     }
-
-    ScopedMemoryBuffer & LongTermAlloc(size_t size)
-    {
-        Base::LongTermAlloc(size * sizeof(T));
-        return *this;
-    }
 };
 
 } // namespace Platform
index 613f386..7c64a71 100644 (file)
@@ -49,10 +49,10 @@ static void TestMemAlloc_Malloc(nlTestSuite * inSuite, void * inContext)
     char * p3 = nullptr;
 
     // Verify long-term allocation
-    p1 = static_cast<char *>(MemoryAlloc(64, true));
+    p1 = static_cast<char *>(MemoryAlloc(64));
     NL_TEST_ASSERT(inSuite, p1 != nullptr);
 
-    p2 = static_cast<char *>(MemoryAlloc(256, true));
+    p2 = static_cast<char *>(MemoryAlloc(256));
     NL_TEST_ASSERT(inSuite, p2 != nullptr);
 
     chip::Platform::MemoryFree(p1);
@@ -86,7 +86,7 @@ static void TestMemAlloc_Calloc(nlTestSuite * inSuite, void * inContext)
 
 static void TestMemAlloc_Realloc(nlTestSuite * inSuite, void * inContext)
 {
-    char * pa = static_cast<char *>(MemoryAlloc(128, true));
+    char * pa = static_cast<char *>(MemoryAlloc(128));
     NL_TEST_ASSERT(inSuite, pa != nullptr);
 
     char * pb = static_cast<char *>(MemoryRealloc(pa, 256));
index 75aec86..dbf399c 100644 (file)
@@ -38,6 +38,7 @@ public:
     PrivateHeapAllocator() { PrivateHeapInit(mHeap.buffer, kSize); }
     void * HeapAlloc(size_t size) { return PrivateHeapAlloc(mHeap.buffer, size); }
     void HeapFree(void * buffer) { PrivateHeapFree(buffer); }
+    void * HeapRealloc(void * buffer, size_t size) { return PrivateHeapRealloc(mHeap.buffer, buffer, size); }
 
 private:
     struct alignas(kPrivateHeapAllocationAlignment)
@@ -264,6 +265,79 @@ void BackwardFreeAndRealloc(nlTestSuite * inSuite, void * inContext)
     allocator.HeapFree(ptrs[kNumBlocks - 1]);
 }
 
+// Fills the data with a known pattern
+void FillKnownPattern(void * buffer, size_t size, uint8_t start)
+{
+    uint8_t * p = static_cast<uint8_t *>(buffer);
+    size_t cnt  = start;
+    while (cnt++ < size)
+    {
+        uint8_t value = static_cast<uint8_t>(cnt * 31 + 7);
+        *p            = value;
+    }
+}
+
+// checks if the specified buffer has the given pattern in it
+bool IsKnownPattern(void * buffer, size_t size, uint8_t start)
+{
+    uint8_t * p = static_cast<uint8_t *>(buffer);
+    size_t cnt  = start;
+    while (cnt++ < size)
+    {
+        uint8_t value = static_cast<uint8_t>(cnt * 31 + 7);
+        if (*p != value)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+void Realloc(nlTestSuite * inSuite, void * inContext)
+{
+    PrivateHeapAllocator<6 * 16> allocator;
+
+    void * p1 = allocator.HeapRealloc(nullptr, 16); // malloc basically
+    NL_TEST_ASSERT(inSuite, p1 != nullptr);
+
+    FillKnownPattern(p1, 16, 11);
+
+    void * p2 = allocator.HeapRealloc(p1, 8); // resize, should fit
+    NL_TEST_ASSERT(inSuite, p1 == p2);
+    NL_TEST_ASSERT(inSuite, IsKnownPattern(p1, 8, 11));
+
+    p2 = allocator.HeapRealloc(p1, 16); // resize, should fit
+    NL_TEST_ASSERT(inSuite, p1 == p2);
+    NL_TEST_ASSERT(inSuite, IsKnownPattern(p2, 8, 11)); // only 8 bytes are guaranteed
+
+    FillKnownPattern(p1, 16, 33);
+    p2 = allocator.HeapRealloc(p1, 32); // resize, does not fit. This frees p1
+    NL_TEST_ASSERT(inSuite, p2 != nullptr);
+    NL_TEST_ASSERT(inSuite, p2 != p1); // new reallocation occured
+    NL_TEST_ASSERT(inSuite, IsKnownPattern(p2, 16, 33));
+
+    void * p3 = allocator.HeapAlloc(48); // insufficient heap for this
+    NL_TEST_ASSERT(inSuite, p3 == nullptr);
+
+    p1 = allocator.HeapRealloc(p2, 16); // reallocation does not change block size
+    NL_TEST_ASSERT(inSuite, p1 == p2);
+
+    p3 = allocator.HeapAlloc(48); // still insufficient heap for this
+    NL_TEST_ASSERT(inSuite, p3 == nullptr);
+
+    p2 = allocator.HeapRealloc(p1, 48); // insufficient heap, p1 is NOT freed
+    NL_TEST_ASSERT(inSuite, p2 == nullptr);
+
+    p2 = allocator.HeapRealloc(p1, 48); // Repeat the test to ensure p1 is not freed
+    NL_TEST_ASSERT(inSuite, p2 == nullptr);
+
+    allocator.HeapFree(p1);
+
+    p3 = allocator.HeapAlloc(48); // above free should have made sufficient space
+    NL_TEST_ASSERT(inSuite, p3 != nullptr);
+    allocator.HeapFree(p3);
+}
+
 const nlTest sTests[] = {
     NL_TEST_DEF("SingleHeapAllocAndFree", SingleHeapAllocAndFree),     //
     NL_TEST_DEF("SplitHeapAllocAndFree", SplitHeapAllocAndFree),       //
@@ -273,6 +347,7 @@ const nlTest sTests[] = {
     NL_TEST_DEF("MultipleMerge", MultipleMerge),                       //
     NL_TEST_DEF("ForwardFreeAndRealloc", ForwardFreeAndRealloc),       //
     NL_TEST_DEF("BackwardFreeAndRealloc", BackwardFreeAndRealloc),     //
+    NL_TEST_DEF("Realloc", Realloc),                                   //
     NL_TEST_SENTINEL()                                                 //
 };
 
index 41bf70b..676d2b3 100644 (file)
@@ -38,12 +38,6 @@ public:
         mAllocCount++;
         return chip::Platform::MemoryAlloc(size);
     }
-    static void * MemoryAlloc(size_t size, bool longTerm)
-    {
-
-        mAllocCount++;
-        return chip::Platform::MemoryAlloc(size, longTerm);
-    }
     static void * MemoryCalloc(size_t num, size_t size)
     {
 
@@ -84,8 +78,6 @@ void TestFreeDuringAllocs(nlTestSuite * inSuite, void * inContext)
         NL_TEST_ASSERT(inSuite, TestCounterMemoryManagement::Counter() == 1);
         NL_TEST_ASSERT(inSuite, buffer.Alloc(64));
         NL_TEST_ASSERT(inSuite, TestCounterMemoryManagement::Counter() == 1);
-        NL_TEST_ASSERT(inSuite, buffer.LongTermAlloc(256));
-        NL_TEST_ASSERT(inSuite, TestCounterMemoryManagement::Counter() == 1);
         NL_TEST_ASSERT(inSuite, buffer.Calloc(10));
         NL_TEST_ASSERT(inSuite, TestCounterMemoryManagement::Counter() == 1);
     }
index 6316eef..47a2d06 100644 (file)
 #define LWIP_TCPIP_CORE_LOCKING 1
 #define TCP_QUEUE_OOSEQ 0
 #define ARP_QUEUEING (0)
+#define TCPIP_THREAD_NAME "LWIP"
 
 #define LWIP_SOCKET 0
 
-#define LWIP_FREERTOS_USE_STATIC_TCPIP_TASK 0
+#define LWIP_FREERTOS_USE_STATIC_TCPIP_TASK 1
 
 // TODO: seems like this is unnecessary on Thread-only platforms
 #define LWIP_RAW 1
 #define SUB_ETHERNET_HEADER_SPACE (0)
 #define PBUF_LINK_HLEN (0)
 
-#define TCPIP_THREAD_STACKSIZE (4096)
+#define TCPIP_THREAD_STACKSIZE (2048)
 #define TCPIP_THREAD_PRIO (2)
 
 #define NETIF_MAX_HWADDR_LEN 8U
index 30d7c60..13b5646 100644 (file)
@@ -48,7 +48,7 @@
 
 #if LWIP_FREERTOS_USE_STATIC_TCPIP_TASK
 static StaticTask_t gTCPIPTask;
-static portSTACK_TYPE gTCPIPTaskStack[TCPIP_THREAD_STACKSIZE];
+static StackType_t gTCPIPTaskStack[TCPIP_THREAD_STACKSIZE / sizeof(StackType_t)];
 #endif
 
 #if LWIP_FREERTOS_USE_STATIC_TCPIP_QUEUE
@@ -265,7 +265,7 @@ sys_thread_t sys_thread_new(const char * name, lwip_thread_fn thread, void * arg
         return NULL;
 
 #if LWIP_FREERTOS_USE_STATIC_TCPIP_TASK
-    taskH = xTaskCreateStatic(thread, name, stacksizeWords, arg, (UBaseType_t) prio, (StackType_t *) gTCPIPTaskStack, &gTCPIPTask);
+    taskH = xTaskCreateStatic(thread, name, stacksizeWords, arg, (UBaseType_t) prio, gTCPIPTaskStack, &gTCPIPTask);
 #else  // LWIP_FREERTOS_USE_STATIC_TCPIP_TASK
     if (xTaskCreate(thread, name, stacksizeWords, arg, (UBaseType_t) prio, &taskH) != pdPASS)
         taskH = NULL;
index a5e6f20..c3597d4 100644 (file)
 #define MEMP_SEPARATE_POOLS (1)
 #define LWIP_PBUF_FROM_CUSTOM_POOLS (0)
 #define MEMP_USE_CUSTOM_POOLS (0)
-#define PBUF_POOL_SIZE (8)
+#define PBUF_POOL_SIZE (4)
 #define PBUF_POOL_BUFSIZE (1500)
-#define PBUF_POOL_SIZE_LARGE (3)
-#define PBUF_POOL_SIZE_MEDIUM (4)
-#define PBUF_POOL_SIZE_SMALL (5)
+#define PBUF_POOL_SIZE_LARGE (1)
+#define PBUF_POOL_SIZE_MEDIUM (2)
+#define PBUF_POOL_SIZE_SMALL (2)
 #define PBUF_POOL_BUFSIZE_LARGE (1280)
 #define PBUF_POOL_BUFSIZE_MEDIUM (640)
 #define PBUF_POOL_BUFSIZE_SMALL (256)
index 958de27..a061d28 100644 (file)
@@ -254,7 +254,7 @@ void ChannelContext::HandleNodeIdResolve(CHIP_ERROR error, uint64_t nodeId, cons
 CHIP_ERROR ChannelContext::SendSessionEstablishmentMessage(const PacketHeader & header, const Transport::PeerAddress & peerAddress,
                                                            System::PacketBufferHandle msgIn)
 {
-    return mExchangeManager->GetTransportManager()->SendMessage(header, peerAddress, std::move(msgIn));
+    return mExchangeManager->GetSessionMgr()->GetTransportManager()->SendMessage(header, peerAddress, std::move(msgIn));
 }
 
 CHIP_ERROR ChannelContext::HandlePairingMessage(const PacketHeader & packetHeader, const Transport::PeerAddress & peerAddress,
@@ -272,9 +272,9 @@ void ChannelContext::EnterCasePairingState()
     // TODO: currently only supports IP/UDP paring
     Transport::PeerAddress addr;
     addr.SetTransportType(Transport::Type::kUdp).SetIPAddress(mStateVars.mPreparing.mAddress);
-    CHIP_ERROR err = mStateVars.mPreparing.mCasePairingSession->EstablishSession(addr, mExchangeManager->GetLocalNodeId(),
-                                                                                 mStateVars.mPreparing.mBuilder.GetPeerNodeId(),
-                                                                                 mExchangeManager->GetNextKeyId(), this);
+    CHIP_ERROR err = mStateVars.mPreparing.mCasePairingSession->EstablishSession(
+        addr, mExchangeManager->GetSessionMgr()->GetLocalNodeId(), mStateVars.mPreparing.mBuilder.GetPeerNodeId(),
+        mExchangeManager->GetNextKeyId(), this);
     if (err != CHIP_NO_ERROR)
     {
         ExitCasePairingState();
index f58b148..216e92e 100644 (file)
@@ -49,11 +49,11 @@ using namespace chip::System;
 namespace chip {
 namespace Messaging {
 
-static void DefaultOnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, uint32_t protocolId, uint8_t msgType,
-                                     PacketBufferHandle payload)
+static void DefaultOnMessageReceived(ExchangeContext * ec, const PacketHeader & packetHeader, Protocols::Id protocolId,
+                                     uint8_t msgType, PacketBufferHandle payload)
 {
-    ChipLogError(ExchangeManager, "Dropping unexpected message %08" PRIX32 ":%d %04" PRIX16 " MsgId:%08" PRIX32, protocolId,
-                 msgType, ec->GetExchangeId(), packetHeader.GetMessageId());
+    ChipLogError(ExchangeManager, "Dropping unexpected message %08" PRIX32 ":%d %04" PRIX16 " MsgId:%08" PRIX32,
+                 protocolId.ToFullyQualifiedSpecForm(), msgType, ec->GetExchangeId(), packetHeader.GetMessageId());
 }
 
 bool ExchangeContext::IsInitiator() const
@@ -157,8 +157,11 @@ CHIP_ERROR ExchangeContext::SendMessageImpl(Protocols::Id protocolId, uint8_t ms
         mReliableMessageContext.SetAckPending(false);
 
 #if !defined(NDEBUG)
-        ChipLogProgress(ExchangeManager, "Piggybacking Ack for MsgId:%08" PRIX32 " with msg",
-                        mReliableMessageContext.mPendingPeerAckId);
+        if (!payloadHeader.HasMessageType(Protocols::SecureChannel::MsgType::StandaloneAck))
+        {
+            ChipLogProgress(ExchangeManager, "Piggybacking Ack for MsgId:%08" PRIX32 " with msg",
+                            mReliableMessageContext.mPendingPeerAckId);
+        }
 #endif
     }
 
@@ -405,10 +408,10 @@ void ExchangeContext::HandleResponseTimeout(System::Layer * aSystemLayer, void *
 CHIP_ERROR ExchangeContext::HandleMessage(const PacketHeader & packetHeader, const PayloadHeader & payloadHeader,
                                           PacketBufferHandle msgBuf)
 {
-    CHIP_ERROR err      = CHIP_NO_ERROR;
-    uint32_t messageId  = 0;
-    uint16_t protocolId = 0;
-    uint8_t messageType = 0;
+    CHIP_ERROR err           = CHIP_NO_ERROR;
+    uint32_t messageId       = packetHeader.GetMessageId();
+    Protocols::Id protocolId = payloadHeader.GetProtocolID();
+    uint8_t messageType      = payloadHeader.GetMessageType();
 
     // We hold a reference to the ExchangeContext here to
     // guard against Close() calls(decrementing the reference
@@ -416,10 +419,6 @@ CHIP_ERROR ExchangeContext::HandleMessage(const PacketHeader & packetHeader, con
     // layer has completed its work on the ExchangeContext.
     Retain();
 
-    messageId   = packetHeader.GetMessageId();
-    protocolId  = payloadHeader.GetProtocolID();
-    messageType = payloadHeader.GetMessageType();
-
     if (payloadHeader.IsAckMsg())
     {
         err = mReliableMessageContext.HandleRcvdAck(payloadHeader.GetAckId().Value());
index f5ea394..b562f32 100644 (file)
@@ -64,15 +64,13 @@ ExchangeManager::ExchangeManager() : mReliableMessageMgr(mContextPool)
     mState = State::kState_NotInitialized;
 }
 
-CHIP_ERROR ExchangeManager::Init(NodeId localNodeId, TransportMgrBase * transportMgr, SecureSessionMgr * sessionMgr)
+CHIP_ERROR ExchangeManager::Init(SecureSessionMgr * sessionMgr)
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
 
     VerifyOrReturnError(mState == State::kState_NotInitialized, err = CHIP_ERROR_INCORRECT_STATE);
 
-    mLocalNodeId  = localNodeId;
-    mTransportMgr = transportMgr;
-    mSessionMgr   = sessionMgr;
+    mSessionMgr = sessionMgr;
 
     mNextExchangeId = GetRandU16();
     mNextKeyId      = 0;
@@ -84,10 +82,10 @@ CHIP_ERROR ExchangeManager::Init(NodeId localNodeId, TransportMgrBase * transpor
         // Mark all handlers as unallocated.  This handles both initial
         // initialization and the case when the consumer shuts us down and
         // then re-initializes without removing registered handlers.
-        handler.Delegate = nullptr;
+        handler.Reset();
     }
 
-    mTransportMgr->SetRendezvousSession(this);
+    mSessionMgr->GetTransportManager()->SetRendezvousSession(this);
 
     sessionMgr->SetDelegate(this);
 
@@ -172,12 +170,12 @@ CHIP_ERROR ExchangeManager::RegisterUMH(Protocols::Id protocolId, int16_t msgTyp
 
     for (int i = 0; i < CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS; i++, umh++)
     {
-        if (umh->Delegate == nullptr)
+        if (!umh->IsInUse())
         {
             if (selected == nullptr)
                 selected = umh;
         }
-        else if (umh->ProtocolId == protocolId && umh->MessageType == msgType)
+        else if (umh->Matches(protocolId, msgType))
         {
             umh->Delegate = delegate;
             return CHIP_NO_ERROR;
@@ -202,9 +200,9 @@ CHIP_ERROR ExchangeManager::UnregisterUMH(Protocols::Id protocolId, int16_t msgT
 
     for (int i = 0; i < CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS; i++, umh++)
     {
-        if (umh->Delegate != nullptr && umh->ProtocolId == protocolId && umh->MessageType == msgType)
+        if (umh->IsInUse() && umh->Matches(protocolId, msgType))
         {
-            umh->Delegate = nullptr;
+            umh->Reset();
             SYSTEM_STATS_DECREMENT(chip::System::Stats::kExchangeMgr_NumUMHandlers);
             return CHIP_NO_ERROR;
         }
@@ -299,7 +297,7 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const
 
         for (int i = 0; i < CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS; i++, umh++)
         {
-            if (umh->Delegate != nullptr && payloadHeader.HasProtocol(umh->ProtocolId))
+            if (umh->IsInUse() && payloadHeader.HasProtocol(umh->ProtocolId))
             {
                 if (umh->MessageType == payloadHeader.GetMessageType())
                 {
@@ -442,7 +440,8 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & header, const Trans
         {
             CHIP_ERROR err = context->HandlePairingMessage(header, source, std::move(msgBuf));
             if (err != CHIP_NO_ERROR)
-                ChipLogError(ExchangeManager, "HandlePairingMessage error %s from node %llu.", chip::ErrorStr(err), node);
+                ChipLogError(ExchangeManager, "HandlePairingMessage error %s from node 0x%08" PRIx32 "%08" PRIx32 ".",
+                             chip::ErrorStr(err), static_cast<uint32_t>(node >> 32), static_cast<uint32_t>(node));
             return false;
         }
         return true;
@@ -452,8 +451,9 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & header, const Trans
     {
         char addrBuffer[Transport::PeerAddress::kMaxToStringSize];
         source.ToString(addrBuffer, sizeof(addrBuffer));
-        ChipLogError(ExchangeManager, "Unencrypted message from %s is dropped since no session found for node %llu.", addrBuffer,
-                     node);
+        ChipLogError(ExchangeManager,
+                     "Unencrypted message from %s is dropped since no session found for node 0x%08" PRIx32 "%08" PRIx32 ".",
+                     addrBuffer, static_cast<uint32_t>(node >> 32), static_cast<uint32_t>(node));
         return;
     }
 }
index a69a55a..82f896a 100644 (file)
@@ -71,7 +71,7 @@ public:
      *  @retval #CHIP_NO_ERROR On success.
      *
      */
-    CHIP_ERROR Init(NodeId localNodeId, TransportMgrBase * transportMgr, SecureSessionMgr * sessionMgr);
+    CHIP_ERROR Init(SecureSessionMgr * sessionMgr);
 
     /**
      *  Shutdown the ExchangeManager. This terminates this instance
@@ -210,7 +210,6 @@ public:
     void IncrementContextsInUse();
     void DecrementContextsInUse();
 
-    TransportMgrBase * GetTransportManager() const { return mTransportMgr; }
     SecureSessionMgr * GetSessionMgr() const { return mSessionMgr; }
 
     ReliableMessageMgr * GetReliableMessageMgr() { return &mReliableMessageMgr; };
@@ -218,7 +217,6 @@ public:
     MessageCounterSyncMgr * GetMessageCounterSyncMgr() { return &mMessageCounterSyncMgr; };
     Transport::AdminId GetAdminId() { return mAdminId; }
 
-    NodeId GetLocalNodeId() { return mLocalNodeId; }
     uint16_t GetNextKeyId() { return ++mNextKeyId; }
     size_t GetContextsInUse() const { return mContextsInUse; }
 
@@ -232,16 +230,27 @@ private:
     struct UnsolicitedMessageHandler
     {
         UnsolicitedMessageHandler() : ProtocolId(Protocols::NotSpecified) {}
+
+        constexpr void Reset() { Delegate = nullptr; }
+        constexpr bool IsInUse() const { return Delegate != nullptr; }
+        // Matches() only returns a sensible value if IsInUse() is true.
+        constexpr bool Matches(Protocols::Id aProtocolId, int16_t aMessageType) const
+        {
+            return ProtocolId == aProtocolId && MessageType == aMessageType;
+        }
+
         ExchangeDelegate * Delegate;
         Protocols::Id ProtocolId;
+        // Message types are normally 8-bit unsigned ints, but we use
+        // kAnyMessageType, which is negative, to represent a wildcard handler,
+        // so need a type that can store both that and all valid message type
+        // values.
         int16_t MessageType;
     };
 
-    NodeId mLocalNodeId; // < Id of the current node
     uint16_t mNextExchangeId;
     uint16_t mNextKeyId;
     State mState;
-    TransportMgrBase * mTransportMgr;
     SecureSessionMgr * mSessionMgr;
     ReliableMessageMgr mReliableMessageMgr;
     MessageCounterSyncMgr mMessageCounterSyncMgr;
index d1cefb9..23cc067 100644 (file)
@@ -259,6 +259,10 @@ CHIP_ERROR ReliableMessageContext::SendStandaloneAckMessage()
     // Send the null message
     if (mExchange != nullptr)
     {
+#if !defined(NDEBUG)
+        ChipLogProgress(ExchangeManager, "Sending Standalone Ack for MsgId:%08" PRIX32, mPendingPeerAckId);
+#endif
+
         err = mExchange->SendMessage(Protocols::SecureChannel::MsgType::StandaloneAck, std::move(msgBuf),
                                      BitFlags<SendMessageFlags>{ SendMessageFlags::kNoAutoRequestAck });
     }
index 1564ee9..b4450de 100644 (file)
@@ -37,7 +37,7 @@ CHIP_ERROR MessagingContext::Init(nlTestSuite * suite, TransportMgrBase * transp
 
     ReturnErrorOnFailure(mSecureSessionMgr.Init(GetSourceNodeId(), &GetSystemLayer(), transport, &mAdmins));
 
-    ReturnErrorOnFailure(mExchangeManager.Init(GetSourceNodeId(), transport, &mSecureSessionMgr));
+    ReturnErrorOnFailure(mExchangeManager.Init(&mSecureSessionMgr));
 
     ReturnErrorOnFailure(mSecureSessionMgr.NewPairing(mPeer, GetDestinationNodeId(), &mPairingLocalToPeer,
                                                       SecureSessionMgr::PairingDirection::kInitiator, mSrcAdminId));
index d9b10a6..f8eecbb 100644 (file)
@@ -255,7 +255,7 @@ int main(int argc, char * argv[])
         SuccessOrExit(err);
     }
 
-    err = gExchangeManager.Init(chip::kTestControllerNodeId, &gUDPManager, &gSessionManager);
+    err = gExchangeManager.Init(&gSessionManager);
     SuccessOrExit(err);
 
     // Start the CHIP connection to the CHIP echo responder.
index fee1a69..2de325c 100644 (file)
@@ -60,7 +60,8 @@ int main(int argc, char * argv[])
 {
     CHIP_ERROR err = CHIP_NO_ERROR;
     chip::Optional<chip::Transport::PeerAddress> peer(chip::Transport::Type::kUndefined);
-    bool useTCP = false;
+    bool useTCP      = false;
+    bool disableEcho = false;
 
     chip::Transport::AdminPairingTable admins;
     chip::Transport::AdminPairingInfo * adminInfo = nullptr;
@@ -78,6 +79,11 @@ int main(int argc, char * argv[])
         useTCP = true;
     }
 
+    if ((argc == 2) && (strcmp(argv[1], "--disable") == 0))
+    {
+        disableEcho = true;
+    }
+
     InitializeChip();
 
     adminInfo = admins.AssignAdminId(gAdminId, chip::kTestDeviceNodeId);
@@ -102,18 +108,24 @@ int main(int argc, char * argv[])
         SuccessOrExit(err);
     }
 
-    err = gExchangeManager.Init(chip::kTestDeviceNodeId, &gUDPManager, &gSessionManager);
+    err = gExchangeManager.Init(&gSessionManager);
     SuccessOrExit(err);
 
-    err = gEchoServer.Init(&gExchangeManager);
-    SuccessOrExit(err);
+    if (!disableEcho)
+    {
+        err = gEchoServer.Init(&gExchangeManager);
+        SuccessOrExit(err);
+    }
 
     err = gSessionManager.NewPairing(peer, chip::kTestControllerNodeId, &gTestPairing,
                                      chip::SecureSessionMgr::PairingDirection::kResponder, gAdminId);
     SuccessOrExit(err);
 
-    // Arrange to get a callback whenever an Echo Request is received.
-    gEchoServer.SetEchoRequestReceived(HandleEchoRequestReceived);
+    if (!disableEcho)
+    {
+        // Arrange to get a callback whenever an Echo Request is received.
+        gEchoServer.SetEchoRequestReceived(HandleEchoRequestReceived);
+    }
 
     printf("Listening for Echo requests...\n");
 
@@ -126,7 +138,10 @@ exit:
         exit(EXIT_FAILURE);
     }
 
-    gEchoServer.Shutdown();
+    if (!disableEcho)
+    {
+        gEchoServer.Shutdown();
+    }
 
     ShutdownChip();
 
index 5a1c3b4..d87e2de 100644 (file)
@@ -169,9 +169,12 @@ namespace DeviceLayer {
 
 - (BOOL)checkDiscriminator:(uint16_t)discriminator
 {
-    // If the setup discriminator is only 4 bits, only match the lower 4 from the BLE advertisement
-    constexpr uint16_t kManualSetupDiscriminatorFieldBitMask = (1 << chip::kManualSetupDiscriminatorFieldLengthInBits) - 1;
-    if (_deviceDiscriminator <= kManualSetupDiscriminatorFieldBitMask) {
+    // If the manual setup discriminator was passed in, only match the most significant 4 bits from the BLE advertisement
+    constexpr uint16_t manualSetupDiscriminatorOffsetInBits
+        = chip::kPayloadDiscriminatorFieldLengthInBits - chip::kManualSetupDiscriminatorFieldLengthInBits;
+    constexpr uint16_t maxManualDiscriminatorValue = (1 << chip::kManualSetupDiscriminatorFieldLengthInBits) - 1;
+    constexpr uint16_t kManualSetupDiscriminatorFieldBitMask = maxManualDiscriminatorValue << manualSetupDiscriminatorOffsetInBits;
+    if (_deviceDiscriminator == (_deviceDiscriminator & kManualSetupDiscriminatorFieldBitMask)) {
         return _deviceDiscriminator == (discriminator & kManualSetupDiscriminatorFieldBitMask);
     } else {
         // else compare the entire thing
index b34a4ad..2077fbd 100644 (file)
@@ -67,7 +67,7 @@ namespace {
 #define TIMER_MS_2_TIMERTICK(ms) ((TIMER_CLK_FREQ * ms) / 1000)
 #define TIMER_S_2_TIMERTICK(s) (TIMER_CLK_FREQ * s)
 
-#define BLE_MAX_BUFFER_SIZE (3150)
+#define BLE_MAX_BUFFER_SIZE (3076)
 #define BLE_MAX_ADVERTISERS (1)
 #define BLE_CONFIG_MAX_PERIODIC_ADVERTISING_SYNC (0)
 #define BLE_CONFIG_MAX_SOFTWARE_TIMERS (4)
@@ -82,6 +82,10 @@ TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer.
  * details on each parameter) */
 static sl_bt_configuration_t config;
 
+StackType_t bluetoothEventStack[CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE / sizeof(StackType_t)];
+StaticTask_t bluetoothEventTaskStruct;
+static TaskHandle_t BluetoothEventTaskHandle;
+
 const uint8_t UUID_CHIPoBLEService[]       = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
                                          0x00, 0x10, 0x00, 0x00, 0xAF, 0xFE, 0x00, 0x00 };
 const uint8_t ShortUUID_CHIPoBLEService[]  = { 0xAF, 0xFE };
@@ -168,12 +172,14 @@ CHIP_ERROR BLEManagerImpl::_Init()
     VerifyOrExit(ret == bg_err_success, err = MapBLEError(ret));
 
     // Create the Bluetooth Application task
-    xTaskCreate(bluetoothStackEventHandler,                                       /* Function that implements the task. */
-                CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME,                             /* Text name for the task. */
-                CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */
-                this,                                                             /* Parameter passed into the task. */
-                CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY,                         /* Priority at which the task is created. */
-                NULL);                                                            /* Variable to hold the task's data structure. */
+    BluetoothEventTaskHandle =
+        xTaskCreateStatic(bluetoothStackEventHandler,               /* Function that implements the task. */
+                          CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME,     /* Text name for the task. */
+                          ArraySize(bluetoothEventStack),           /* Number of indexes in the xStack array. */
+                          this,                                     /* Parameter passed into the task. */
+                          CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY, /* Priority at which the task is created. */
+                          bluetoothEventStack,                      /* Pointer to task heap */
+                          &bluetoothEventTaskStruct);               /* Variable that holds the task struct */
 
     // Create FreeRTOS sw timer for BLE timeouts and interval change.
     sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer",       // Just a text name, not used by the RTOS kernel
@@ -557,7 +563,8 @@ void BLEManagerImpl::DriveBLEState(void)
     VerifyOrExit(mFlags.Has(Flags::kEFRBLEStackInitialized), /* */);
 
     // Start advertising if needed...
-    if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && mFlags.Has(Flags::kAdvertisingEnabled))
+    if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && mFlags.Has(Flags::kAdvertisingEnabled) &&
+        NumConnections() < kMaxConnections)
     {
         // Start/re-start advertising if not already started, or if there is a pending change
         // to the advertising configuration.
@@ -695,10 +702,25 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
     bd_addr unusedBdAddr;                        // We can ignore this field when setting random address.
     uint32_t interval_min;
     uint32_t interval_max;
+    uint32_t BleAdvTimeoutMs;
     uint16_t numConnectionss = NumConnections();
     uint8_t connectableAdv =
         (numConnectionss < kMaxConnections) ? sl_bt_advertiser_connectable_scannable : sl_bt_advertiser_scannable_non_connectable;
 
+    // If already advertising, stop it, before changing values
+    if (mFlags.Has(Flags::kAdvertising))
+    {
+        sl_bt_advertiser_stop(sInstance.advertising_set_handle);
+    }
+    else
+    {
+        ChipLogDetail(DeviceLayer, "Start BLE advertissement");
+        // If necessary, inform the ThreadStackManager that CHIPoBLE advertising is about to start.
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+        ThreadStackMgr().OnCHIPoBLEAdvertisingStart();
+#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
+    }
+
     err = ConfigureAdvertisingData();
     SuccessOrExit(err);
 
@@ -707,15 +729,17 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
 
     mFlags.Clear(Flags::kRestartAdvertising);
 
-    if ((numConnectionss == 0 && !ConfigurationMgr().IsPairedToAccount()) || mFlags.Has(Flags::kFastAdvertisingEnabled))
+    if (mFlags.Has(Flags::kFastAdvertisingEnabled))
     {
-        interval_min = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN;
-        interval_max = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX;
+        interval_min    = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN;
+        interval_max    = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX;
+        BleAdvTimeoutMs = CHIP_DEVICE_CONFIG_BLE_ADVERTISING_INTERVAL_CHANGE_TIME;
     }
     else
     {
-        interval_min = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN;
-        interval_max = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX;
+        interval_min    = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN;
+        interval_max    = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX;
+        BleAdvTimeoutMs = CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT;
     }
 
     ret = sl_bt_advertiser_set_timing(advertising_set_handle, interval_min, interval_max, 0, 0);
@@ -726,8 +750,6 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
 
     if (SL_STATUS_OK == ret)
     {
-        uint32_t BleAdvTimeoutMs = (mFlags.Has(Flags::kFastAdvertisingEnabled) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT
-                                                                               : CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT);
         StartBleAdvTimeoutTimer(BleAdvTimeoutMs);
         mFlags.Set(Flags::kAdvertising);
     }
@@ -755,6 +777,10 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void)
         SuccessOrExit(err);
 
         CancelBleAdvTimeoutTimer();
+        // If necessary, inform the ThreadStackManager that CHIPoBLE advertising has stopped
+#if CHIP_DEVICE_CONFIG_ENABLE_THREAD
+        ThreadStackMgr().OnCHIPoBLEAdvertisingStop();
+#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD
     }
 
 exit:
@@ -799,7 +825,6 @@ void BLEManagerImpl::HandleConnectEvent(volatile sl_bt_msg_t * evt)
 
     AddConnection(connHandle, bondingHandle);
 
-    // mFlags.Set(Flags::kRestartAdvertising);
     PlatformMgr().ScheduleWork(DriveBLEState, 0);
 }
 
@@ -1061,42 +1086,16 @@ uint8_t BLEManagerImpl::GetTimerHandle(uint8_t connectionHandle, bool allocate)
 
 void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer)
 {
-    CHIP_ERROR err;
-    sl_status_t ret;
-
-    if (sInstance.mFlags.Has(Flags::kFastAdvertisingEnabled))
+    if (BLEMgrImpl().mFlags.Has(Flags::kFastAdvertisingEnabled))
     {
         ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertissment");
-
-        sInstance.mFlags.Clear(Flags::kFastAdvertisingEnabled);
-
-        // stop advertiser, change interval and restart it;
-        sl_bt_advertiser_stop(sInstance.advertising_set_handle);
-        ret = sl_bt_advertiser_set_timing(sInstance.advertising_set_handle, CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL,
-                                          CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL, 0, 0);
-
-        err = sInstance.MapBLEError(ret);
-        SuccessOrExit(err);
-
-        uint8_t connectableAdv = (sInstance.NumConnections() < kMaxConnections) ? sl_bt_advertiser_connectable_scannable
-                                                                                : sl_bt_advertiser_scannable_non_connectable;
-        ret = sl_bt_advertiser_start(sInstance.advertising_set_handle, sl_bt_advertiser_user_data, connectableAdv);
-        err = sInstance.MapBLEError(ret);
-        SuccessOrExit(err);
-
-        sInstance.StartBleAdvTimeoutTimer(CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT); // Slow advertise for 15 Minutesß
+        BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising);
     }
-    else if (sInstance._IsAdvertisingEnabled())
+    else if (BLEMgrImpl().mFlags.Has(Flags::kAdvertising))
     {
-        // advertissement expired. we stop advertissing
+        // Advertisement time expired. Stop advertising
         ChipLogDetail(DeviceLayer, "bleAdv Timeout : Stop advertissement");
-        sInstance.StopAdvertising();
-    }
-
-exit:
-    if (err != CHIP_NO_ERROR)
-    {
-        ChipLogError(DeviceLayer, "Changing Bl advertiser interval failed %s", ErrorStr(err));
+        BLEMgr().SetAdvertisingEnabled(false);
     }
 }
 
index 7ba6462..e15dde0 100644 (file)
 #endif // CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE
 
 #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
-#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 4096
+#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 3584
 #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
 
 #ifndef CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE
-#define CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE 4096
+#define CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE (3 * 1024)
 #endif // CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE
 
 #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0
 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0
 
 #ifndef CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME
-#define CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME "BLE App Task"
+#define CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME "BLE_EVENT"
 #endif // CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME
 #define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0
+
+#define CHIP_DEVICE_CONFIG_MAX_EVENT_QUEUE_SIZE 25
diff --git a/src/platform/EFR32/CHIPMem-Platform.cpp b/src/platform/EFR32/CHIPMem-Platform.cpp
new file mode 100644 (file)
index 0000000..3703459
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ *
+ *    Copyright (c) 2020 Project CHIP Authors
+ *    Copyright (c) 2019 Nest Labs, Inc.
+ *
+ *    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.
+ */
+
+/*
+ *
+ *    Copyright (c) 2020-2021 Project CHIP Authors
+ *    All rights reserved.
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+/**
+ *    @file
+ *      This file implements heap memory allocation APIs for CHIP. These functions are platform
+ *      specific and might be C Standard Library heap functions re-direction in most of cases.
+ *
+ */
+
+//#include <core/CHIPConfig.h>
+#include <support/CHIPMem.h>
+
+#include "FreeRTOS.h"
+#include "task.h"
+
+#include "sl_malloc.h"
+
+#include <atomic>
+#include <cstdio>
+#include <cstring>
+#include <stdlib.h>
+
+#if CHIP_CONFIG_MEMORY_MGMT_PLATFORM
+
+extern "C" void memMonitoringTrackAlloc(void * ptr, size_t size);
+extern "C" void memMonitoringTrackFree(void * ptr, size_t size);
+
+#ifndef trackAlloc
+#define trackAlloc(pvAddress, uiSize) memMonitoringTrackAlloc(pvAddress, uiSize)
+#endif
+#ifndef trackFree
+#define trackFree(pvAddress, uiSize) memMonitoringTrackFree(pvAddress, uiSize)
+#endif
+
+namespace chip {
+namespace Platform {
+
+#define VERIFY_INITIALIZED() VerifyInitialized(__func__)
+
+static std::atomic_int memoryInitialized{ 0 };
+
+static void VerifyInitialized(const char * func)
+{
+    if (!memoryInitialized)
+    {
+        fprintf(stderr, "ABORT: chip::Platform::%s() called before chip::Platform::MemoryInit()\n", func);
+        abort();
+    }
+}
+
+CHIP_ERROR MemoryAllocatorInit(void * buf, size_t bufSize)
+{
+#ifndef NDEBUG
+    if (memoryInitialized++ > 0)
+    {
+        fprintf(stderr, "ABORT: chip::Platform::MemoryInit() called twice.\n");
+        abort();
+    }
+#endif
+    return CHIP_NO_ERROR;
+}
+
+void MemoryAllocatorShutdown()
+{
+#ifndef NDEBUG
+    if (--memoryInitialized < 0)
+    {
+        fprintf(stderr, "ABORT: chip::Platform::MemoryShutdown() called twice.\n");
+        abort();
+    }
+#endif
+}
+
+void * MemoryAlloc(size_t size)
+{
+    void * ptr;
+    VERIFY_INITIALIZED();
+    ptr = sl_malloc(size);
+    trackAlloc(ptr, size);
+    return ptr;
+}
+
+void * MemoryAlloc(size_t size, bool isLongTermAlloc)
+{
+    void * ptr;
+    VERIFY_INITIALIZED();
+    ptr = sl_malloc(size);
+    trackAlloc(ptr, size);
+    return ptr;
+}
+
+void * MemoryCalloc(size_t num, size_t size)
+{
+    void * ptr;
+    VERIFY_INITIALIZED();
+    ptr = sl_calloc(num, size);
+    trackAlloc(ptr, size * num);
+    return ptr;
+}
+
+void * MemoryRealloc(void * p, size_t size)
+{
+    VERIFY_INITIALIZED();
+    return sl_realloc(p, size);
+}
+
+void MemoryFree(void * p)
+{
+    VERIFY_INITIALIZED();
+    trackFree(p, 0);
+    sl_free(p);
+}
+
+bool MemoryInternalCheckPointer(const void * p, size_t min_size)
+{
+    return (p != nullptr);
+}
+
+} // namespace Platform
+} // namespace chip
+
+extern "C" void * pvPortMalloc(size_t xWantedSize)
+{
+    void * pvReturn;
+
+    vTaskSuspendAll();
+    {
+        pvReturn = sl_malloc(xWantedSize);
+        trackAlloc(pvReturn, xWantedSize);
+    }
+    (void) xTaskResumeAll();
+
+#if (configUSE_MALLOC_FAILED_HOOK == 1)
+    {
+        if (pvReturn == NULL)
+        {
+            extern void vApplicationMallocFailedHook(void);
+            vApplicationMallocFailedHook();
+        }
+    }
+#endif
+
+    return pvReturn;
+}
+
+extern "C" void vPortFree(void * pv)
+{
+    if (pv)
+    {
+        vTaskSuspendAll();
+        {
+            trackFree(pv, 0);
+            sl_free(pv);
+        }
+        (void) xTaskResumeAll();
+    }
+}
+
+extern "C" __WEAK void memMonitoringTrackAlloc(void * ptr, size_t size) {}
+
+extern "C" __WEAK void memMonitoringTrackFree(void * ptr, size_t size) {}
+
+#endif // CHIP_CONFIG_MEMORY_MGMT_PLATFORM
index 6d37fa3..17a9cc8 100644 (file)
 #ifndef CHIP_CONFIG_ENABLE_CASE_RESPONDER
 #define CHIP_CONFIG_ENABLE_CASE_RESPONDER 1
 #endif // CHIP_CONFIG_ENABLE_CASE_RESPONDER
+
+// ==================== FreeRTOS Configuration Overrides ====================
+#ifndef CHIP_CONFIG_FREERTOS_USE_STATIC_TASK
+#define CHIP_CONFIG_FREERTOS_USE_STATIC_TASK 1
+#endif
+
+#ifndef CHIP_CONFIG_FREERTOS_USE_STATIC_QUEUE
+#define CHIP_CONFIG_FREERTOS_USE_STATIC_QUEUE 1
+#endif
index 1437403..0e4164d 100644 (file)
@@ -67,6 +67,7 @@ namespace Internal {
 
 static nvm3_Handle_t handle;
 static SemaphoreHandle_t nvm3_Sem;
+static StaticSemaphore_t nvm3_SemStruct;
 
 // Declare NVM3 data area and cache.
 
@@ -79,7 +80,7 @@ CHIP_ERROR EFR32Config::Init()
 {
     CHIP_ERROR err;
 
-    nvm3_Sem = xSemaphoreCreateBinary();
+    nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct);
 
     if (nvm3_Sem == NULL)
     {
index dc5d0f3..735ede6 100644 (file)
@@ -29,6 +29,8 @@
 
 #include <lwip/tcpip.h>
 
+#include "AppConfig.h"
+
 namespace chip {
 namespace DeviceLayer {
 
index 66edcea..a763550 100644 (file)
@@ -135,3 +135,66 @@ extern "C" void otPlatFree(void * aPtr)
 {
     CHIPPlatformMemoryFree(aPtr);
 }
+
+/**
+ * @brief Openthread UART implementation for the CLI is conflicting
+ *        with the UART implemented for Pigweed RPC as they use the same UART port
+ *
+ *        We now only build the uart as implemented in
+ *        connectedhomeip/examples/platform/efr32/uart.c
+ *        and remap OT functions to use our uart api.
+ *
+ *        For now OT CLI isn't usable when the examples are built with pw_rpc
+ */
+
+#ifndef PW_RPC_ENABLED
+#include "uart.h"
+#endif
+
+extern "C" __WEAK otError otPlatUartEnable(void)
+{
+#ifdef PW_RPC_ENABLED
+    return OT_ERROR_NOT_IMPLEMENTED;
+#else
+    uartConsoleInit();
+    return OT_ERROR_NONE;
+#endif
+}
+
+extern "C" __WEAK otError otPlatUartSend(const uint8_t * aBuf, uint16_t aBufLength)
+{
+#ifdef PW_RPC_ENABLED
+    return OT_ERROR_NOT_IMPLEMENTED;
+#else
+    if (uartConsoleWrite((const char *) aBuf, aBufLength) > 0)
+    {
+        otPlatUartSendDone();
+        return OT_ERROR_NONE;
+    }
+    return OT_ERROR_FAILED;
+#endif
+}
+
+extern "C" __WEAK void efr32UartProcess(void)
+{
+#ifndef PW_RPC_ENABLED
+    uint8_t tempBuf[128] = { 0 };
+    // will read the data available up to 128bytes
+    uint16_t count = uartConsoleRead((char *) tempBuf, 128);
+    if (count > 0)
+    {
+        // ot process Received data for CLI cmds
+        otPlatUartReceived(tempBuf, count);
+    }
+#endif
+}
+
+extern "C" __WEAK otError otPlatUartFlush(void)
+{
+    return OT_ERROR_NOT_IMPLEMENTED;
+}
+
+extern "C" __WEAK otError otPlatUartDisable(void)
+{
+    return OT_ERROR_NOT_IMPLEMENTED;
+}
index ed9ac5b..d6f5a41 100644 (file)
@@ -43,3 +43,5 @@ openthread_core_config_deps = [ "${chip_root}/examples/platform/efr32:openthread
 
 openthread_external_platform =
     "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32"
+
+chip_config_memory_management = "platform"
index 9d6c5be..d65b937 100644 (file)
@@ -47,6 +47,9 @@ static volatile sl_bgapi_handler command_handler_func = NULL;
 static void BluetoothTask(void * p_arg);
 static TaskHandle_t BluetoothTaskHandle = NULL;
 
+StackType_t bluetoothStack[BLUETOOTH_STACK_SIZE / sizeof(StackType_t)];
+StaticTask_t bluetoothTaskStruct;
+
 void sli_bt_cmd_handler_rtos_delegate(uint32_t header, sl_bgapi_handler handler, const void * payload);
 extern void sli_bgapi_cmd_handler_delegate(uint32_t header, sl_bgapi_handler, const void *);
 extern uint32_t sli_bt_can_sleep_ticks();
@@ -57,6 +60,9 @@ extern uint32_t sli_bt_can_sleep_ticks();
 #endif
 static void LinklayerTask(void * p_arg);
 static TaskHandle_t LinklayerTaskHandle = NULL;
+StackType_t linkLayerStack[LINKLAYER_STACK_SIZE / sizeof(StackType_t)];
+StaticTask_t linkLayerTaskStruct;
+StaticSemaphore_t bluetoothMutexStruct;
 //
 #define RTOS_TICK_HZ 1024
 #define BLUETOOTH_TICK_HZ 32768
@@ -71,27 +77,36 @@ sl_status_t bluetooth_start(UBaseType_t ll_priority, UBaseType_t stack_priority,
     bluetooth_event_flags = xEventGroupCreate();
     configASSERT(bluetooth_event_flags);
 
-    BluetoothMutex = xSemaphoreCreateMutex();
+    BluetoothMutex = xSemaphoreCreateMutexStatic(&bluetoothMutexStruct);
 
     err = initialize_bluetooth_stack();
 
     if (err == SL_STATUS_OK)
     {
         // create tasks for Bluetooth host stack
-        xTaskCreate(BluetoothTask,                              /* Function that implements the task. */
-                    "Bluetooth Task",                           /* Text name for the task. */
-                    BLUETOOTH_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */
-                    NULL,                                       /* Parameter passed into the task. */
-                    stack_priority,                             /* Priority at which the task is created. */
-                    &BluetoothTaskHandle);                      /* Variable to hold the task's data structure. */
+        BluetoothTaskHandle =
+            xTaskCreateStatic(BluetoothTask,                              /* Function that implements the task. */
+                              BLE_STACK_TASK_NAME,                        /* Text name for the task. */
+                              BLUETOOTH_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */
+                              NULL,                                       /* Parameter passed into the task. */
+                              stack_priority,                             /* Priority at which the task is created. */
+                              bluetoothStack,                             /* Pointer to task heap */
+                              &bluetoothTaskStruct);                      /* Variable that holds the task struct */
 
         // create tasks for Linklayer
-        xTaskCreate(LinklayerTask,                              /* Function that implements the task. */
-                    "Linklayer Task",                           /* Text name for the task. */
-                    LINKLAYER_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */
-                    NULL,                                       /* Parameter passed into the task. */
-                    ll_priority,                                /* Priority at which the task is created. */
-                    &LinklayerTaskHandle);                      /* Variable to hold the task's data structure. */
+        LinklayerTaskHandle =
+            xTaskCreateStatic(LinklayerTask,                              /* Function that implements the task. */
+                              BLE_LINK_TASK_NAME,                         /* Text name for the task. */
+                              LINKLAYER_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */
+                              NULL,                                       /* Parameter passed into the task. */
+                              ll_priority,                                /* Priority at which the task is created. */
+                              linkLayerStack,                             /* Pointer to task heap */
+                              &linkLayerTaskStruct);                      /* Variable that holds the task struct */
+
+        if (BluetoothTaskHandle == NULL || LinklayerTaskHandle == NULL)
+        {
+            err = SL_STATUS_FAIL;
+        }
     }
 
     return err;
@@ -222,6 +237,8 @@ void vApplicationMallocFailedHook(void)
     timers, and semaphores.  The size of the FreeRTOS heap is set by the
     configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
 
+    EFR32_LOG("Failed do a malloc on HEAP. Is it too small ?");
+
     /* Force an assert. */
     configASSERT((volatile void *) NULL);
 }
index eb99068..862b715 100644 (file)
@@ -31,6 +31,9 @@ extern "C" {
 
 #include "sl_bt_api.h"
 
+#define BLE_STACK_TASK_NAME "BLE_STACK"
+#define BLE_LINK_TASK_NAME "BLE_LINK"
+
 // Bluetooth event flag group
 extern EventGroupHandle_t bluetooth_event_flags;
 // Bluetooth event flag definitions
index 950d755..b7eff51 100644 (file)
@@ -43,9 +43,9 @@ template class GenericThreadStackManagerImpl_FreeRTOS<ThreadStackManagerImpl>;
 template <class ImplClass>
 CHIP_ERROR GenericThreadStackManagerImpl_FreeRTOS<ImplClass>::DoInit(void)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
-
+    CHIP_ERROR err   = CHIP_NO_ERROR;
     mThreadStackLock = xSemaphoreCreateMutex();
+
     if (mThreadStackLock == NULL)
     {
         ChipLogError(DeviceLayer, "Failed to create Thread stack lock");
@@ -61,18 +61,25 @@ exit:
 template <class ImplClass>
 CHIP_ERROR GenericThreadStackManagerImpl_FreeRTOS<ImplClass>::_StartThreadTask(void)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
-    BaseType_t res;
-
-    VerifyOrExit(mThreadTask == NULL, err = CHIP_ERROR_INCORRECT_STATE);
+    if (mThreadTask != NULL)
+    {
+        return CHIP_ERROR_INCORRECT_STATE;
+    }
+#if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_TASK) && CHIP_CONFIG_FREERTOS_USE_STATIC_TASK
+    mThreadTask = xTaskCreateStatic(ThreadTaskMain, CHIP_DEVICE_CONFIG_THREAD_TASK_NAME, ArraySize(mThreadStack), this,
+                                    CHIP_DEVICE_CONFIG_THREAD_TASK_PRIORITY, mThreadStack, &mThreadTaskStruct);
 
-    res = xTaskCreate(ThreadTaskMain, CHIP_DEVICE_CONFIG_THREAD_TASK_NAME,
-                      CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE / sizeof(StackType_t), this,
-                      CHIP_DEVICE_CONFIG_THREAD_TASK_PRIORITY, NULL);
-    VerifyOrExit(res == pdPASS, err = CHIP_ERROR_NO_MEMORY);
+#else
+    xTaskCreate(ThreadTaskMain, CHIP_DEVICE_CONFIG_THREAD_TASK_NAME,
+                CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE / sizeof(StackType_t), this, CHIP_DEVICE_CONFIG_THREAD_TASK_PRIORITY,
+                &mThreadTask);
+#endif
 
-exit:
-    return err;
+    if (mThreadTask == NULL)
+    {
+        return CHIP_ERROR_NO_MEMORY;
+    }
+    return CHIP_NO_ERROR;
 }
 
 template <class ImplClass>
@@ -144,12 +151,8 @@ void GenericThreadStackManagerImpl_FreeRTOS<ImplClass>::ThreadTaskMain(void * ar
     GenericThreadStackManagerImpl_FreeRTOS<ImplClass> * self =
         static_cast<GenericThreadStackManagerImpl_FreeRTOS<ImplClass> *>(arg);
 
-    VerifyOrDie(self->mThreadTask == NULL);
-
     ChipLogDetail(DeviceLayer, "Thread task running");
 
-    self->mThreadTask = xTaskGetCurrentTaskHandle();
-
     // Try starting joiner within 15m.
     self->mJoinerExpire = xTaskGetTickCount() + pdMS_TO_TICKS(15 * 60 * 1000);
 
index dfbe50c..b23b06d 100644 (file)
@@ -55,6 +55,7 @@ namespace Internal {
 template <class ImplClass>
 class GenericThreadStackManagerImpl_FreeRTOS
 {
+
 protected:
     // ===== Methods that implement the ThreadStackManager abstract interface.
 
@@ -82,6 +83,11 @@ private:
 
     portTickType mJoinerExpire;
     bool mJoinerStartPending = false;
+
+#if defined(CHIP_CONFIG_FREERTOS_USE_STATIC_TASK) && CHIP_CONFIG_FREERTOS_USE_STATIC_TASK
+    StackType_t mThreadStack[CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE / sizeof(StackType_t)];
+    StaticTask_t mThreadTaskStruct;
+#endif
 };
 
 // Instruct the compiler to instantiate the template only when explicitly told to do so.
index 1613044..55fc8a4 100644 (file)
@@ -37,6 +37,9 @@
 #include "gatt_db_app_interface.h"
 #include "gatt_db_handles.h"
 #include "stdio.h"
+#include "timers.h"
+
+#include "RNG_Interface.h"
 
 /*******************************************************************************
  * Local data types
@@ -105,6 +108,9 @@ namespace {
 #define BLEKW_MAX_ADV_DATA_LEN (31)
 #define CHIP_ADV_SHORT_UUID_LEN (2)
 
+/* FreeRTOS sw timer */
+TimerHandle_t sbleAdvTimeoutTimer;
+
 /* Message list used to synchronize asynchronous messages from the KW BLE tasks */
 anchor_t blekw_msg_list;
 
@@ -145,6 +151,9 @@ CHIP_ERROR BLEManagerImpl::_Init()
     err = BleLayer::Init(this, this, &SystemLayer);
     SuccessOrExit(err);
 
+    (void) RNG_Init();
+    RNG_SetPseudoRandomNoSeed(NULL);
+
     /* Initialization of message wait events -
      * used for receiving BLE Stack events */
     event_msg = OSA_EventCreate(TRUE);
@@ -195,9 +204,16 @@ CHIP_ERROR BLEManagerImpl::_Init()
 
     mFlags.Set(Flags::kK32WBLEStackInitialized);
     mFlags.Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? true : false);
-    mFlags.Set(Flags::kFastAdvertisingEnabled, true);
-    PlatformMgr().ScheduleWork(DriveBLEState, 0);
-
+    mFlags.Set(Flags::kFastAdvertisingEnabled);
+
+    // Create FreeRTOS sw timer for BLE timeouts and interval change.
+    sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer",       // Just a text name, not used by the RTOS kernel
+                                       1,                   // == default timer period (mS)
+                                       false,               // no timer reload (==one-shot)
+                                       (void *) this,       // init timer id = ble obj context
+                                       BleAdvTimeoutHandler // timer callback handler
+    );
+    VerifyOrExit(sbleAdvTimeoutTimer != NULL, err = CHIP_ERROR_INCORRECT_STATE);
 exit:
     return err;
 }
@@ -683,6 +699,16 @@ BLEManagerImpl::ble_err_t BLEManagerImpl::blekw_start_advertising(gapAdvertising
     /************* Start the advertising *************/
     OSA_EventClear(event_msg, (CHIP_BLE_KW_EVNT_ADV_CHANGED | CHIP_BLE_KW_EVNT_ADV_FAILED));
 
+    if (gBleSuccess_c != Gap_CreateRandomDeviceAddress(NULL, NULL))
+    {
+        return BLE_E_SET_ADV_PARAMS;
+    }
+
+    if (OSA_EventWait(event_msg, CHIP_BLE_KW_EVNT_RND_ADDR_SET, FALSE, CHIP_BLE_KW_EVNT_TIMEOUT, &event_mask) != osaStatus_Success)
+    {
+        return BLE_E_ADV_PARAMS_FAILED;
+    }
+
     /* Start the advertising */
     if (Gap_StartAdvertising(blekw_gap_advertising_cb, blekw_gap_connection_cb) != gBleSuccess_c)
     {
@@ -743,6 +769,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void)
     ble_err_t err;
     CHIP_ERROR chipErr;
     uint16_t discriminator;
+    uint16_t advInterval                                  = 0;
     gapAdvertisingData_t adv                              = { 0 };
     gapAdStructure_t adv_data[BLEKW_ADV_MAX_NO]           = { 0 };
     gapAdStructure_t scan_rsp_data[BLEKW_SCAN_RSP_MAX_NO] = { 0 };
@@ -805,20 +832,19 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void)
     scanRsp.aAdStructures = scan_rsp_data;
 
     /**************** Prepare advertising parameters *************************************/
-    if ((NumConnections() == 0 && !ConfigurationMgr().IsPairedToAccount()) || mFlags.Has(Flags::kFastAdvertisingEnabled))
+    if (mFlags.Has(Flags::kFastAdvertisingEnabled))
     {
-        adv_params.minInterval = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN;
-        adv_params.maxInterval = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX;
+        advInterval = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX;
     }
     else
     {
-        adv_params.minInterval = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN;
-        adv_params.maxInterval = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX;
+        advInterval = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX;
     }
 
-    adv_params.advertisingType = gAdvConnectableUndirected_c;
-    adv_params.ownAddressType  = gBleAddrTypePublic_c;
-    adv_params.peerAddressType = gBleAddrTypePublic_c;
+    adv_params.minInterval = adv_params.maxInterval = advInterval;
+    adv_params.advertisingType                      = gAdvConnectableUndirected_c;
+    adv_params.ownAddressType                       = gBleAddrTypePublic_c;
+    adv_params.peerAddressType                      = gBleAddrTypePublic_c;
     memset(adv_params.peerAddress, 0, gcBleDeviceAddressSize_c);
     adv_params.channelMap   = (gapAdvertisingChannelMapFlags_t)(gAdvChanMapFlag37_c | gAdvChanMapFlag38_c | gAdvChanMapFlag39_c);
     adv_params.filterPolicy = gProcessAll_c;
@@ -840,9 +866,21 @@ exit:
 
 CHIP_ERROR BLEManagerImpl::StartAdvertising(void)
 {
+    uint32_t bleAdvTimeoutMs = 0;
+
     mFlags.Set(Flags::kAdvertising);
     mFlags.Clear(Flags::kRestartAdvertising);
 
+    if (mFlags.Has(Flags::kFastAdvertisingEnabled))
+    {
+        bleAdvTimeoutMs = CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_TIMEOUT;
+    }
+    else
+    {
+        bleAdvTimeoutMs = CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT;
+    }
+    StartBleAdvTimeoutTimer(bleAdvTimeoutMs);
+
     return ConfigureAdvertisingData();
 }
 
@@ -853,7 +891,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void)
     if (mFlags.Has(Flags::kAdvertising))
     {
         mFlags.Clear(Flags::kAdvertising);
-        mFlags.Set(Flags::kFastAdvertisingEnabled, true);
+        mFlags.Clear(Flags::kFastAdvertisingEnabled);
         mFlags.Clear(Flags::kRestartAdvertising);
 
         err = blekw_stop_advertising();
@@ -862,6 +900,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void)
             return CHIP_ERROR_INCORRECT_STATE;
         }
     }
+    CancelBleAdvTimeoutTimer();
 
     return CHIP_NO_ERROR;
 }
@@ -997,6 +1036,7 @@ void BLEManagerImpl::HandleConnectionCloseEvent(blekw_msg_t * msg)
 
         PlatformMgr().PostEvent(&event);
         mFlags.Set(Flags::kRestartAdvertising);
+        mFlags.Set(Flags::kFastAdvertisingEnabled);
         PlatformMgr().ScheduleWork(DriveBLEState, 0);
     }
 }
@@ -1142,22 +1182,22 @@ void BLEManagerImpl::blekw_generic_cb(gapGenericEvent_t * pGenericEvent)
         break;
 
     case gAdvertisingSetupFailed_c:
-        /* Set the local synchronization event */
         OSA_EventSet(event_msg, CHIP_BLE_KW_EVNT_ADV_SETUP_FAILED);
         break;
 
     case gAdvertisingParametersSetupComplete_c:
-        /* Set the local synchronization event */
         OSA_EventSet(event_msg, CHIP_BLE_KW_EVNT_ADV_PAR_SETUP_COMPLETE);
         break;
 
     case gAdvertisingDataSetupComplete_c:
-        /* Set the local synchronization event */
         OSA_EventSet(event_msg, CHIP_BLE_KW_EVNT_ADV_DAT_SETUP_COMPLETE);
         break;
 
+    case gRandomAddressReady_c:
+        Gap_SetRandomAddress(pGenericEvent->eventData.addrReady.aAddress);
+        break;
+
     case gRandomAddressSet_c:
-        /* Set the local synchronization event */
         OSA_EventSet(event_msg, CHIP_BLE_KW_EVNT_RND_ADDR_SET);
         break;
 
@@ -1447,6 +1487,52 @@ void BLEManagerImpl::blekw_new_data_received_notification(uint32_t mask)
     }
 }
 
+void BLEManagerImpl::BleAdvTimeoutHandler(TimerHandle_t xTimer)
+{
+    if (sInstance.mFlags.Has(Flags::kFastAdvertisingEnabled))
+    {
+        ChipLogDetail(DeviceLayer, "bleAdv Timeout : Start slow advertisment");
+
+        sInstance.mFlags.Clear(Flags::kFastAdvertisingEnabled);
+        // stop advertiser, change interval and restart it;
+        sInstance.StopAdvertising();
+        sInstance.StartAdvertising();
+        sInstance.StartBleAdvTimeoutTimer(CHIP_DEVICE_CONFIG_BLE_ADVERTISING_TIMEOUT); // Slow advertise for 15 Minutes
+    }
+    else if (sInstance._IsAdvertisingEnabled())
+    {
+        // advertisement expired. we stop advertissing
+        ChipLogDetail(DeviceLayer, "bleAdv Timeout : Stop advertisement");
+        sInstance.StopAdvertising();
+    }
+
+    return;
+}
+
+void BLEManagerImpl::CancelBleAdvTimeoutTimer(void)
+{
+    if (xTimerStop(sbleAdvTimeoutTimer, 0) == pdFAIL)
+    {
+        ChipLogError(DeviceLayer, "Failed to stop BledAdv timeout timer");
+    }
+}
+
+void BLEManagerImpl::StartBleAdvTimeoutTimer(uint32_t aTimeoutInMs)
+{
+    if (xTimerIsTimerActive(sbleAdvTimeoutTimer))
+    {
+        CancelBleAdvTimeoutTimer();
+    }
+
+    // timer is not active, change its period to required value (== restart).
+    // FreeRTOS- Block for a maximum of 100 ticks if the change period command
+    // cannot immediately be sent to the timer command queue.
+    if (xTimerChangePeriod(sbleAdvTimeoutTimer, aTimeoutInMs / portTICK_PERIOD_MS, 100) != pdPASS)
+    {
+        ChipLogError(DeviceLayer, "Failed to start BledAdv timeout timer");
+    }
+}
+
 } // namespace Internal
 } // namespace DeviceLayer
 } // namespace chip
index ced04d3..320adfd 100644 (file)
@@ -228,6 +228,9 @@ private:
     static void blekw_connection_timeout_cb(TimerHandle_t timer);
     static CHIP_ERROR blekw_msg_add_u8(blekw_msg_type_t type, uint8_t data);
     static void blekw_new_data_received_notification(uint32_t mask);
+    static void BleAdvTimeoutHandler(TimerHandle_t xTimer);
+    static void CancelBleAdvTimeoutTimer(void);
+    static void StartBleAdvTimeoutTimer(uint32_t aTimeoutInMs);
     static CHIP_ERROR blekw_controller_init(void);
     static CHIP_ERROR blekw_host_init(void);
     static void Host_Task(osaTaskParam_t argument);
index 624065a..c0b18b0 100644 (file)
@@ -94,3 +94,7 @@
 #define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0
 
 #define CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED 1
+
+#define CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART 0
+
+#define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART 0
index 5fd78ff..d94bc2b 100644 (file)
@@ -39,36 +39,35 @@ KeyValueStoreManagerImpl KeyValueStoreManagerImpl::sInstance;
 CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t value_size, size_t * read_bytes_size,
                                           size_t offset_bytes)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
     size_t read_size;
-    size_t copy_size;
+
+    // Copy data into value buffer
+    VerifyOrReturnError(value != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
 
     // On linux read first without a buffer which returns the size, and then
     // use a local buffer to read the entire object, which allows partial and
     // offset reads.
-    err = mStorage.ReadValueBin(key, nullptr, 0, read_size);
-    uint8_t buf[read_size];
+    CHIP_ERROR err = mStorage.ReadValueBin(key, nullptr, 0, read_size);
     if (err == CHIP_ERROR_KEY_NOT_FOUND)
     {
-        ExitNow(err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND);
+        return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;
     }
-    err = mStorage.ReadValueBin(key, buf, read_size, read_size);
-    SuccessOrExit(err);
-
-    // Copy data into value buffer
-    if (!value)
+    else if (err != CHIP_NO_ERROR)
     {
-        ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT);
+        return err;
     }
-    copy_size = std::min(value_size, read_size - offset_bytes);
-    if (read_bytes_size)
+
+    uint8_t buf[read_size];
+    ReturnErrorOnFailure(mStorage.ReadValueBin(key, buf, read_size, read_size));
+
+    size_t copy_size = std::min(value_size, read_size - offset_bytes);
+    if (read_bytes_size != nullptr)
     {
         *read_bytes_size = copy_size;
     }
     ::memcpy(value, buf + offset_bytes, copy_size);
 
-exit:
-    return err;
+    return CHIP_NO_ERROR;
 }
 
 CHIP_ERROR KeyValueStoreManagerImpl::_Put(const char * key, const void * value, size_t value_size)
index c63b3be..bd608c7 100644 (file)
@@ -277,8 +277,8 @@ void Poller::UpdateFdSet(fd_set & readFdSet, fd_set & writeFdSet, fd_set & error
         }
     }
 
-    timeout.tv_sec  = (__time_t)(static_cast<uint64_t>(timeoutVal.count()) / kUsPerSec);
-    timeout.tv_usec = (__suseconds_t)(static_cast<uint64_t>(timeoutVal.count()) % kUsPerSec);
+    timeout.tv_sec  = static_cast<uint64_t>(timeoutVal.count()) / kUsPerSec;
+    timeout.tv_usec = static_cast<uint64_t>(timeoutVal.count()) % kUsPerSec;
 }
 
 void Poller::Process(const fd_set & readFdSet, const fd_set & writeFdSet, const fd_set & errorFdSet)
@@ -518,7 +518,7 @@ CHIP_ERROR MdnsAvahi::Browse(const char * type, MdnsServiceProtocol protocol, ch
                              chip::Inet::InterfaceId interface, MdnsBrowseCallback callback, void * context)
 {
     AvahiServiceBrowser * browser;
-    BrowseContext * browseContext = static_cast<BrowseContext *>(chip::Platform::MemoryAlloc(sizeof(BrowseContext)));
+    BrowseContext * browseContext = chip::Platform::New<BrowseContext>();
     AvahiIfIndex avahiInterface   = static_cast<AvahiIfIndex>(interface);
 
     browseContext->mInstance = this;
@@ -534,7 +534,7 @@ CHIP_ERROR MdnsAvahi::Browse(const char * type, MdnsServiceProtocol protocol, ch
     // Otherwise the browser will be freed in the callback
     if (browser == nullptr)
     {
-        chip::Platform::MemoryFree(browseContext);
+        chip::Platform::Delete(browseContext);
     }
 
     return browser == nullptr ? CHIP_ERROR_INTERNAL : CHIP_NO_ERROR;
@@ -572,13 +572,13 @@ void MdnsAvahi::HandleBrowse(AvahiServiceBrowser * browser, AvahiIfIndex interfa
     case AVAHI_BROWSER_FAILURE:
         context->mCallback(context->mContext, nullptr, 0, CHIP_ERROR_INTERNAL);
         avahi_service_browser_free(browser);
-        chip::Platform::MemoryFree(context);
+        chip::Platform::Delete(context);
         break;
     case AVAHI_BROWSER_NEW:
         ChipLogProgress(DeviceLayer, "Avahi browse: cache new");
         if (strcmp("local", domain) == 0)
         {
-            MdnsService service;
+            MdnsService service = {};
 
             strncpy(service.mName, name, sizeof(service.mName));
             strncpy(service.mType, type, sizeof(service.mType));
@@ -593,13 +593,13 @@ void MdnsAvahi::HandleBrowse(AvahiServiceBrowser * browser, AvahiIfIndex interfa
         ChipLogProgress(DeviceLayer, "Avahi browse: all for now");
         context->mCallback(context->mContext, context->mServices.data(), context->mServices.size(), CHIP_NO_ERROR);
         avahi_service_browser_free(browser);
-        chip::Platform::MemoryFree(context);
+        chip::Platform::Delete(context);
         break;
     case AVAHI_BROWSER_REMOVE:
         ChipLogProgress(DeviceLayer, "Avahi browse: remove");
         if (strcmp("local", domain) == 0)
         {
-            std::remove_if(context->mServices.begin(), context->mServices.end(), [name, type](const MdnsService service) {
+            std::remove_if(context->mServices.begin(), context->mServices.end(), [name, type](const MdnsService service) {
                 return strcmp(name, service.mName) == 0 && type == GetFullType(service.mType, service.mProtocol);
             });
         }
@@ -616,7 +616,7 @@ CHIP_ERROR MdnsAvahi::Resolve(const char * name, const char * type, MdnsServiceP
 {
     AvahiServiceResolver * resolver;
     AvahiIfIndex avahiInterface     = static_cast<AvahiIfIndex>(interface);
-    ResolveContext * resolveContext = static_cast<ResolveContext *>(chip::Platform::MemoryAlloc(sizeof(ResolveContext)));
+    ResolveContext * resolveContext = chip::Platform::New<ResolveContext>();
     CHIP_ERROR error                = CHIP_NO_ERROR;
 
     resolveContext->mInstance = this;
@@ -633,7 +633,7 @@ CHIP_ERROR MdnsAvahi::Resolve(const char * name, const char * type, MdnsServiceP
     if (resolver == nullptr)
     {
         error = CHIP_ERROR_INTERNAL;
-        chip::Platform::MemoryFree(resolver);
+        chip::Platform::Delete(resolveContext);
     }
 
     return error;
@@ -654,7 +654,7 @@ void MdnsAvahi::HandleResolve(AvahiServiceResolver * resolver, AvahiIfIndex inte
         context->mCallback(context->mContext, nullptr, CHIP_ERROR_INTERNAL);
         break;
     case AVAHI_RESOLVER_FOUND:
-        MdnsService result;
+        MdnsService result = {};
 
         result.mAddress.SetValue(chip::Inet::IPAddress());
         ChipLogError(DeviceLayer, "Avahi resolve found");
@@ -712,7 +712,7 @@ void MdnsAvahi::HandleResolve(AvahiServiceResolver * resolver, AvahiIfIndex inte
     }
 
     avahi_service_resolver_free(resolver);
-    chip::Platform::MemoryFree(context);
+    chip::Platform::Delete(context);
 }
 
 MdnsAvahi::~MdnsAvahi()
index 0f286c3..aa721dd 100644 (file)
@@ -99,7 +99,11 @@ public:
 private:
     struct DBusConnectionDeleter
     {
-        void operator()(DBusConnection * aConnection) { dbus_connection_unref(aConnection); }
+        void operator()(DBusConnection * aConnection)
+        {
+            dbus_connection_close(aConnection);
+            dbus_connection_unref(aConnection);
+        }
     };
 
     using UniqueDBusConnection = std::unique_ptr<DBusConnection, DBusConnectionDeleter>;
index 2037534..e2bcd58 100644 (file)
@@ -165,7 +165,7 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode)
     default:
         return CHIP_ERROR_INVALID_ARGUMENT;
     }
-    mFlags.Set(Flags::kFlag_AdvertisingRefreshNeeded);
+    mFlags.Set(Flags::kAdvertisingRefreshNeeded);
     ret = DriveBLEState();
     return ret;
 }
@@ -805,9 +805,9 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg)
                 Util_stopClock(&sInstance.clkAdvTimeout);
             }
             /* Other case is that advertising is already working, but should be restarted, as its settings changed */
-            else if (sInstance.mFlags.Has(Flags::kFlag_AdvertisingRefreshNeeded))
+            else if (sInstance.mFlags.Has(Flags::kAdvertisingRefreshNeeded))
             {
-                sInstance.mFlags.Clear(Flags::kFlag_AdvertisingRefreshNeeded);
+                sInstance.mFlags.Clear(Flags::kAdvertisingRefreshNeeded);
                 GapAdv_disable(sInstance.advHandleLegacy);
 
                 // Enable legacy advertising for set #1
@@ -1071,7 +1071,7 @@ void BLEManagerImpl::ProcessGapMessage(gapEventHdr_t * pMsg)
         {
             // Stop advertising since there is no room for more connections
             BLEMGR_LOG("BLEMGR: BLE event GAP_LINK_ESTABLISHED_EVENT: MAX connections");
-            sInstance.mFlags.Clear(Flags::kAdvertisingEnabled.Clear(Flags::kAdvertising);
+            sInstance.mFlags.Clear(Flags::kAdvertisingEnabled).Clear(Flags::kAdvertising);
             mFlags.Set(Flags::kFastAdvertisingEnabled, true);
         }
 
@@ -1697,7 +1697,7 @@ void BLEManagerImpl::AdvTimeoutHandler(uintptr_t arg)
         BLEMGR_LOG("BLEMGR: AdvTimeoutHandler ble adv 15 minute timeout");
 
         sInstance.mFlags.Clear(Flags::kAdvertisingEnabled);
-        mFlags.Set(Flags::kFastAdvertisingEnabled, true);
+        sInstance.mFlags.Set(Flags::kFastAdvertisingEnabled);
 
         /* Send event to process state change request */
         DriveBLEState();
index 43bcfe1..51f616e 100644 (file)
@@ -262,19 +262,19 @@ private:
     static chipOBleProfileCBs_t CHIPoBLEProfile_CBs;
     static gapBondCBs_t BLEMgr_BondMgrCBs;
 
-    enum
+    enum class Flags : uint16_t
     {
-        kFlag_AdvertisingEnabled       = 0x0001, /* App enabled CHIPoBLE advertising */
-        kFlag_FastAdvertisingEnabled   = 0x0002, /* App enabled Fash CHIPoBLE advertising */
-        kFlag_Advertising              = 0x0004, /* TI BLE stack actively advertising */
-        kFlag_BLEStackInitialized      = 0x0008, /* TI BLE Stack GAP Intilization complete */
-        kFlag_BLEStackGATTNameUpdate   = 0x0010, /* Trigger TI BLE Stack name update, must be performed prior to adv start */
-        kFlag_BLEStackGATTNameSet      = 0x0020, /* Device name has been set externally*/
-        kFlag_AdvertisingRefreshNeeded = 0x0040, /* Advertising settings changed and it should be restarted */
+        kAdvertisingEnabled       = 0x0001, /* App enabled CHIPoBLE advertising */
+        kFastAdvertisingEnabled   = 0x0002, /* App enabled Fash CHIPoBLE advertising */
+        kAdvertising              = 0x0004, /* TI BLE stack actively advertising */
+        kBLEStackInitialized      = 0x0008, /* TI BLE Stack GAP Intilization complete */
+        kBLEStackGATTNameUpdate   = 0x0010, /* Trigger TI BLE Stack name update, must be performed prior to adv start */
+        kBLEStackGATTNameSet      = 0x0020, /* Device name has been set externally*/
+        kAdvertisingRefreshNeeded = 0x0040, /* Advertising settings changed and it should be restarted */
 
     };
 
-    uint16_t mFlags;
+    BitFlags<Flags> mFlags;
     CHIPoBLEServiceMode mServiceMode;
     char mDeviceName[GAP_DEVICE_NAME_LEN];
 
index 3e03d21..1ac66e3 100644 (file)
 #define CHIP_DEVICE_CONFIG_ENABLE_PAIRING_AUTOSTART CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART
 #endif // CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART
 
-#ifdef CONFIG_CHIP_ENABLE_RENDEZVOUS_BYPASS
-#define CHIP_BYPASS_RENDEZVOUS CONFIG_CHIP_ENABLE_RENDEZVOUS_BYPASS
-#endif // CONFIG_CHIP_ENABLE_RENDEZVOUS_BYPASS
-
 #ifdef CONFIG_CHIP_ENABLE_DNSSD_SRP
 #define CHIP_DEVICE_CONFIG_ENABLE_MDNS 1
 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1
index 6fc4f08..0eea05b 100644 (file)
@@ -26,6 +26,7 @@
 #include <platform/qpg6100/qpg6100Config.h>
 
 #include <core/CHIPEncoding.h>
+#include <lib/core/CHIPSafeCasts.h>
 #include <platform/internal/testing/ConfigUnitTest.h>
 #include <support/CodeUtils.h>
 #include <support/logging/CHIPLogging.h>
@@ -46,106 +47,78 @@ CHIP_ERROR QPG6100Config::Init()
 
 uint16_t QPG6100Config::GetSettingsMaxValueLength(Key key)
 {
-    return qvCHIP_Nvm_GetMaxKeyLen(key);
+    uint16_t keyLen;
+
+    return (qvCHIP_Nvm_GetMaxKeyLen(key, &keyLen) == QV_STATUS_NO_ERROR) ? keyLen : 0;
 }
 
 CHIP_ERROR QPG6100Config::ReadConfigValue(Key key, bool & val)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
     uint16_t length;
-    bool res;
 
     length = sizeof(bool);
 
-    res = qvCHIP_Nvm_Restore(key, (uint8_t *) (&val), &length);
-    if (res == false)
-    {
-        err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
-    }
-
-    return err;
+    return MapNVMError(qvCHIP_Nvm_Restore(key, reinterpret_cast<uint8_t *>(&val), &length));
 }
 
 CHIP_ERROR QPG6100Config::ReadConfigValue(Key key, uint32_t & val)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
     uint16_t length;
-    bool res;
 
     length = sizeof(uint32_t);
 
-    res = qvCHIP_Nvm_Restore(key, (uint8_t *) (&val), &length);
-    if (res == false)
-    {
-        err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
-    }
-
-    return err;
+    return MapNVMError(qvCHIP_Nvm_Restore(key, reinterpret_cast<uint8_t *>(&val), &length));
 }
 
 CHIP_ERROR QPG6100Config::ReadConfigValue(Key key, uint64_t & val)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
     uint16_t length;
-    bool res;
 
     length = sizeof(uint64_t);
 
-    res = qvCHIP_Nvm_Restore(key, (uint8_t *) (&val), &length);
-    if (res == false)
-    {
-        err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
-    }
-
-    return err;
+    return MapNVMError(qvCHIP_Nvm_Restore(key, reinterpret_cast<uint8_t *>(&val), &length));
 }
 
 CHIP_ERROR QPG6100Config::ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
-    bool res;
+    qvStatus_t res;
     uint16_t length;
 
-    if (buf == NULL)
+    if ((buf == NULL) || (bufSize > UINT16_MAX))
     {
         return CHIP_ERROR_INVALID_ARGUMENT;
     }
 
-    length = (uint16_t) bufSize;
-    res    = qvCHIP_Nvm_Restore(key, (uint8_t *) buf, &length);
+    length = static_cast<uint16_t>(bufSize);
+    res    = qvCHIP_Nvm_Restore(key, Uint8::from_char(buf), &length);
     if (length > bufSize)
     {
         return CHIP_ERROR_BUFFER_TOO_SMALL;
     }
-    if (res == true)
+    if (res == QV_STATUS_NO_ERROR)
     {
         outLen      = length;
         buf[outLen] = 0;
     }
-    else
-    {
-        err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
-    }
 
-    return err;
+    return MapNVMError(res);
 }
 
 CHIP_ERROR QPG6100Config::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen)
 {
-    CHIP_ERROR err = CHIP_NO_ERROR;
     uint8_t buffer[255];
     uint16_t length;
-    bool res;
+    qvStatus_t res;
 
-    if (buf == NULL)
+    if ((buf == NULL) || (bufSize > UINT16_MAX))
     {
         return CHIP_ERROR_INVALID_ARGUMENT;
     }
 
-    length = (uint16_t) outLen;
+    length = static_cast<uint16_t>(bufSize);
 
     res = qvCHIP_Nvm_Restore(key, buffer, &length);
-    if (res == true)
+    if (res == QV_STATUS_NO_ERROR)
     {
         outLen = length;
         if (outLen > bufSize)
@@ -156,12 +129,8 @@ CHIP_ERROR QPG6100Config::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufS
         memcpy(buf, buffer, outLen);
         buf[outLen] = 0;
     }
-    else
-    {
-        err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND;
-    }
 
-    return err;
+    return MapNVMError(res);
 }
 
 CHIP_ERROR QPG6100Config::WriteConfigValue(Key key, bool val)
@@ -170,9 +139,7 @@ CHIP_ERROR QPG6100Config::WriteConfigValue(Key key, bool val)
 
     length = sizeof(bool);
 
-    qvCHIP_Nvm_Backup(key, (uint8_t *) (&val), length);
-
-    return CHIP_NO_ERROR;
+    return MapNVMError(qvCHIP_Nvm_Backup(key, reinterpret_cast<uint8_t *>(&val), length));
 }
 
 CHIP_ERROR QPG6100Config::WriteConfigValue(Key key, uint32_t val)
@@ -181,9 +148,7 @@ CHIP_ERROR QPG6100Config::WriteConfigValue(Key key, uint32_t val)
 
     length = sizeof(uint32_t);
 
-    qvCHIP_Nvm_Backup(key, (uint8_t *) (&val), length);
-
-    return CHIP_NO_ERROR;
+    return MapNVMError(qvCHIP_Nvm_Backup(key, reinterpret_cast<uint8_t *>(&val), length));
 }
 
 CHIP_ERROR QPG6100Config::WriteConfigValue(Key key, uint64_t val)
@@ -192,9 +157,7 @@ CHIP_ERROR QPG6100Config::WriteConfigValue(Key key, uint64_t val)
 
     length = sizeof(uint64_t);
 
-    qvCHIP_Nvm_Backup(key, (uint8_t *) (&val), length);
-
-    return CHIP_NO_ERROR;
+    return MapNVMError(qvCHIP_Nvm_Backup(key, reinterpret_cast<uint8_t *>(&val), length));
 }
 
 CHIP_ERROR QPG6100Config::WriteConfigValueStr(Key key, const char * str)
@@ -204,13 +167,17 @@ CHIP_ERROR QPG6100Config::WriteConfigValueStr(Key key, const char * str)
 
 CHIP_ERROR QPG6100Config::WriteConfigValueStr(Key key, const char * str, size_t strLen)
 {
+    if (strLen > UINT16_MAX)
+    {
+        return CHIP_ERROR_INVALID_ARGUMENT;
+    }
     if (str == NULL)
     {
         qvCHIP_Nvm_ClearValue(key);
     }
     else
     {
-        qvCHIP_Nvm_Backup(key, (uint8_t *) str, (uint16_t) strLen);
+        return MapNVMError(qvCHIP_Nvm_Backup(key, Uint8::from_const_char(str), static_cast<uint16_t>(strLen)));
     }
 
     return CHIP_NO_ERROR;
@@ -218,13 +185,17 @@ CHIP_ERROR QPG6100Config::WriteConfigValueStr(Key key, const char * str, size_t
 
 CHIP_ERROR QPG6100Config::WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen)
 {
+    if (dataLen > UINT16_MAX)
+    {
+        return CHIP_ERROR_BUFFER_TOO_SMALL;
+    }
     if (data == NULL)
     {
         qvCHIP_Nvm_ClearValue(key);
     }
     else
     {
-        qvCHIP_Nvm_Backup(key, (uint8_t *) data, (uint16_t) dataLen);
+        return MapNVMError(qvCHIP_Nvm_Backup(key, data, static_cast<uint16_t>(dataLen)));
     }
 
     return CHIP_NO_ERROR;
@@ -284,6 +255,26 @@ exit:
     return err;
 }
 
+CHIP_ERROR QPG6100Config::MapNVMError(qvStatus_t aStatus)
+{
+    switch (aStatus)
+    {
+    case QV_STATUS_NO_ERROR:
+        return CHIP_NO_ERROR;
+    case QV_STATUS_BUFFER_TOO_SMALL:
+        return CHIP_ERROR_BUFFER_TOO_SMALL;
+    case QV_STATUS_INVALID_ARGUMENT:
+        return CHIP_ERROR_INVALID_ARGUMENT;
+    case QV_STATUS_KEY_LEN_TOO_SMALL:
+        return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;
+    case QV_STATUS_INVALID_DATA:
+        return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;
+    default:
+        break;
+    }
+    return CHIP_ERROR_INTERNAL;
+}
+
 void QPG6100Config::RunConfigUnitTest()
 {
     // Run common unit test
index f393d4f..bcc5b05 100644 (file)
@@ -26,6 +26,7 @@
 #include <platform/internal/CHIPDeviceLayerInternal.h>
 
 #include "FreeRTOS.h"
+#include "qvCHIP.h"
 
 #include <functional>
 
@@ -125,6 +126,7 @@ public:
 protected:
     using ForEachRecordFunct = std::function<CHIP_ERROR(const Key & key, const size_t & length)>;
     static CHIP_ERROR ForEachRecord(uint16_t fileId, uint16_t recordKey, bool addNewRecord, ForEachRecordFunct funct);
+    static CHIP_ERROR MapNVMError(qvStatus_t status);
 
 private:
 };
index f546b00..2d51c7a 100644 (file)
@@ -37,7 +37,10 @@ class Id
 public:
     constexpr Id(VendorId aVendorId, uint16_t aProtocolId) : mVendorId(aVendorId), mProtocolId(aProtocolId) {}
 
-    constexpr bool operator==(const Id & aOther) { return mVendorId == aOther.mVendorId && mProtocolId == aOther.mProtocolId; }
+    constexpr bool operator==(const Id & aOther) const
+    {
+        return mVendorId == aOther.mVendorId && mProtocolId == aOther.mProtocolId;
+    }
 
     // Convert the Protocols::Id to a TLV profile id.
     // NOTE: We may want to change the TLV reader/writer to take Protocols::Id
index bed0119..e3b2ca5 100644 (file)
@@ -46,13 +46,15 @@ namespace InteractionModel {
  */
 enum class MsgType : uint8_t
 {
-    SubscribeRequest      = 0x01,
     ReadRequest           = 0x02,
-    ReportData            = 0x03,
-    WriteRequest          = 0x04,
-    WriteResponse         = 0x05,
-    InvokeCommandRequest  = 0x06,
-    InvokeCommandResponse = 0x07,
+    SubscribeRequest      = 0x03,
+    SubscribeResponse     = 0x04,
+    ReportData            = 0x05,
+    WriteRequest          = 0x06,
+    WriteResponse         = 0x07,
+    InvokeCommandRequest  = 0x08,
+    InvokeCommandResponse = 0x09,
+    TimedRequest          = 0x0a,
 };
 
 } // namespace InteractionModel
index 464e8bd..0c69ea4 100644 (file)
@@ -666,5 +666,7 @@ struct LwIPEvent;
 #ifndef CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
 #if (CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK) && !__ZEPHYR__
 #define CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS 1
+#else
+#define CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS 0
 #endif
 #endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
index 1d052f4..47d3059 100644 (file)
@@ -47,29 +47,11 @@ set(CHIP_CFLAGS
 )
 
 set(CHIP_TESTS
-    # TODO: this list is hard to maintain manually (and currently incomplete).
-    # An automated way that includes figuring out dependencies would be much better
-    -lAppTests
-    -lASN1Tests
-    -lBleLayerTests
-    -lChipCryptoTests
-    -lCoreTests
-    -lInetLayerTests
-    -lMessagingLayerTests
-    -lPlatformTests
-    # TODO: raw transport tests fail by running out of TCP/UDP endpoints
-    # -lRawTransportTests
-    -lRetransmitTests
-    -lSupportTests
-    -lSystemLayerTests
-    -lTransportLayerTests
+    -lCHIP_tests
 )
 
 set(CHIP_LIBRARIES
     -lCHIP
-    -lInetTestHelpers
-    -lNetworkTestHelpers
-    -lnlunit-test
     ${CHIP_TESTS}
 )
 
index 46dd5f8..cf84f21 100644 (file)
@@ -19,7 +19,7 @@ CONFIG_MAIN_STACK_SIZE=8192
 
 # Turn on the logger
 CONFIG_LOG=y
-CONFIG_LOG_IMMEDIATE=y
+CONFIG_LOG_MODE_IMMEDIATE=y
 
 # Set up IPv4/6 networking over BSD socket API
 CONFIG_NETWORKING=y
@@ -91,4 +91,4 @@ CONFIG_STD_CPP14=y
 # CHIP configuration
 CONFIG_CHIP=y
 CONFIG_CHIP_BUILD_TESTS=y
-
+CONFIG_CHIP_ENABLE_DNSSD_SRP=n
index e1dfabf..894b9aa 100644 (file)
@@ -167,7 +167,7 @@ CHIP_ERROR NetworkProvisioning::DecodeString(const uint8_t * input, size_t input
     bbuf.Put(&input[consumed], length);
 
     consumed += bbuf.Needed();
-    bbuf.Put('\0');
+    bbuf.Put(static_cast<uint8_t>('\0'));
 
     VerifyOrExit(bbuf.Fit(), err = CHIP_ERROR_BUFFER_TOO_SMALL);
 
index 7f61424..2d3b7bc 100644 (file)
@@ -196,7 +196,10 @@ exit:
 CHIP_ERROR PASESession::ComputePASEVerifier(uint32_t setUpPINCode, uint32_t pbkdf2IterCount, const uint8_t * salt, size_t saltLen,
                                             PASEVerifier & verifier)
 {
-    return pbkdf2_sha256(reinterpret_cast<const uint8_t *>(&setUpPINCode), sizeof(setUpPINCode), salt, saltLen, pbkdf2IterCount,
+    uint8_t littleEndianSetupPINCode[sizeof(uint32_t)];
+    Encoding::LittleEndian::Put32(littleEndianSetupPINCode, setUpPINCode);
+
+    return pbkdf2_sha256(littleEndianSetupPINCode, sizeof(littleEndianSetupPINCode), salt, saltLen, pbkdf2IterCount,
                          sizeof(PASEVerifier), &verifier[0][0]);
 }
 
index dede328..fe6b2bf 100644 (file)
@@ -115,7 +115,7 @@ public:
                 mStates[i].SetLocalKeyID(localKeyId);
                 mStates[i].SetLastActivityTimeMs(mTimeSource.GetCurrentMonotonicTimeMs());
 
-                if (peerNode.HasValue())
+                if (peerNode.ValueOr(kUndefinedNodeId) != kUndefinedNodeId)
                 {
                     mStates[i].SetPeerNodeId(peerNode.Value());
                 }
@@ -227,7 +227,8 @@ public:
             }
             if (peerKeyId == kAnyKeyId || iter->GetPeerKeyID() == peerKeyId)
             {
-                if (!nodeId.HasValue() || iter->GetPeerNodeId() == kUndefinedNodeId || iter->GetPeerNodeId() == nodeId.Value())
+                if (nodeId.ValueOr(kUndefinedNodeId) == kUndefinedNodeId || iter->GetPeerNodeId() == kUndefinedNodeId ||
+                    iter->GetPeerNodeId() == nodeId.Value())
                 {
                     state = iter;
                     break;
@@ -304,7 +305,8 @@ public:
             }
             if (iter->GetLocalKeyID() == localKeyId)
             {
-                if (!nodeId.HasValue() || iter->GetPeerNodeId() == kUndefinedNodeId || iter->GetPeerNodeId() == nodeId.Value())
+                if (nodeId.ValueOr(kUndefinedNodeId) == kUndefinedNodeId || iter->GetPeerNodeId() == kUndefinedNodeId ||
+                    iter->GetPeerNodeId() == nodeId.Value())
                 {
                     state = iter;
                     break;
index 221167c..dc3226e 100644 (file)
@@ -14,6 +14,9 @@
  *    See the License for the specific language governing permissions and
  *    limitations under the License.
  */
+
+#include <inttypes.h>
+
 #include <transport/RendezvousSession.h>
 
 #include <core/CHIPEncoding.h>
@@ -351,8 +354,10 @@ void RendezvousSession::OnRendezvousMessageReceived(const PacketHeader & packetH
         // already know the local node id).
         if (packetHeader.GetDestinationNodeId().HasValue())
         {
-            ChipLogProgress(Ble, "Received pairing message for %llu", packetHeader.GetDestinationNodeId().Value());
-            mAdmin->SetNodeId(packetHeader.GetDestinationNodeId().Value());
+            NodeId destNodeId = packetHeader.GetDestinationNodeId().Value();
+            ChipLogProgress(Ble, "Received pairing message for 0x%08" PRIx32 "%08" PRIx32, static_cast<uint32_t>(destNodeId >> 32),
+                            static_cast<uint32_t>(destNodeId));
+            mAdmin->SetNodeId(destNodeId);
         }
 
         err = HandlePairingMessage(packetHeader, peerAddress, std::move(msgBuf));
@@ -401,16 +406,20 @@ CHIP_ERROR RendezvousSession::HandleSecureMessage(const PacketHeader & packetHea
     // Use the node IDs from the packet header only after it's successfully decrypted
     if (packetHeader.GetDestinationNodeId().HasValue() && !mParams.HasLocalNodeId())
     {
-        ChipLogProgress(Ble, "Received rendezvous message for %llu", packetHeader.GetDestinationNodeId().Value());
-        mAdmin->SetNodeId(packetHeader.GetDestinationNodeId().Value());
-        mParams.SetLocalNodeId(packetHeader.GetDestinationNodeId().Value());
-        mSecureSessionMgr->SetLocalNodeID(packetHeader.GetDestinationNodeId().Value());
+        NodeId destNodeId = packetHeader.GetDestinationNodeId().Value();
+        ChipLogProgress(Ble, "Received rendezvous message for 0x%08" PRIx32 "%08" PRIx32, static_cast<uint32_t>(destNodeId >> 32),
+                        static_cast<uint32_t>(destNodeId));
+        mAdmin->SetNodeId(destNodeId);
+        mParams.SetLocalNodeId(destNodeId);
+        mSecureSessionMgr->SetLocalNodeId(destNodeId);
     }
 
     if (packetHeader.GetSourceNodeId().HasValue() && !mParams.HasRemoteNodeId())
     {
-        ChipLogProgress(Ble, "Received rendezvous message from %llu", packetHeader.GetSourceNodeId().Value());
-        mParams.SetRemoteNodeId(packetHeader.GetSourceNodeId().Value());
+        NodeId sourceNodeId = packetHeader.GetSourceNodeId().Value();
+        ChipLogProgress(Ble, "Received rendezvous message from  0x%08" PRIx32 "%08" PRIx32,
+                        static_cast<uint32_t>(sourceNodeId >> 32), static_cast<uint32_t>(sourceNodeId));
+        mParams.SetRemoteNodeId(sourceNodeId);
     }
 
     if (payloadHeader.HasProtocol(Protocols::NetworkProvisioning::Id))
index 872a738..24c65e2 100644 (file)
@@ -75,7 +75,8 @@ CHIP_ERROR SecureSessionMgr::Init(NodeId localNodeId, System::Layer * systemLaye
     mTransportMgr = transportMgr;
     mAdmins       = admins;
 
-    ChipLogProgress(Inet, "local node id is %llu\n", mLocalNodeId);
+    ChipLogProgress(Inet, "local node id is 0x%08" PRIx32 "%08" PRIx32, static_cast<uint32_t>(mLocalNodeId >> 32),
+                    static_cast<uint32_t>(mLocalNodeId));
 
     ScheduleExpiryTimer();
 
@@ -199,7 +200,9 @@ CHIP_ERROR SecureSessionMgr::SendMessage(SecureSessionHandle session, PayloadHea
         encryptedMsg.mMsgId = packetHeader.GetMessageId();
     }
 
-    ChipLogProgress(Inet, "Sending msg from %llu to %llu", localNodeId, state->GetPeerNodeId());
+    ChipLogProgress(Inet, "Sending msg from 0x%08" PRIx32 "%08" PRIx32 "to 0x%08" PRIx32 "%08" PRIx32,
+                    static_cast<uint32_t>(localNodeId >> 32), static_cast<uint32_t>(localNodeId),
+                    static_cast<uint32_t>(state->GetPeerNodeId() >> 32), static_cast<uint32_t>(state->GetPeerNodeId()));
 
     if (state->GetTransport() != nullptr)
     {
@@ -250,8 +253,8 @@ CHIP_ERROR SecureSessionMgr::NewPairing(const Optional<Transport::PeerAddress> &
             state, [this](const Transport::PeerConnectionState & state1) { HandleConnectionExpired(state1); });
     }
 
-    ChipLogDetail(Inet, "New pairing for device %llu, key %d!!", peerNodeId, peerKeyId);
-
+    ChipLogDetail(Inet, "New pairing for device 0x%08" PRIx32 "%08" PRIx32 ", key %d!!", static_cast<uint32_t>(peerNodeId >> 32),
+                  static_cast<uint32_t>(peerNodeId), peerKeyId);
     state = nullptr;
     ReturnErrorOnFailure(
         mPeerConnections.CreateNewPeerConnectionState(Optional<NodeId>::Value(peerNodeId), peerKeyId, localKeyId, &state));
index 64d4e57..dde09aa 100644 (file)
@@ -288,7 +288,9 @@ public:
      *
      * @param nodeId    Node id for the current node
      */
-    void SetLocalNodeID(NodeId nodeId) { mLocalNodeId = nodeId; }
+    void SetLocalNodeId(NodeId nodeId) { mLocalNodeId = nodeId; }
+
+    NodeId GetLocalNodeId() { return mLocalNodeId; }
 
     /**
      * @brief
@@ -298,6 +300,8 @@ public:
      */
     Transport::Type GetTransportType(NodeId peerNodeId);
 
+    TransportMgrBase * GetTransportManager() const { return mTransportMgr; }
+
 protected:
     /**
      * @brief
index 79f72bb..564e953 100644 (file)
@@ -112,7 +112,7 @@ uint16_t PayloadHeader::EncodeSizeBytes() const
 {
     size_t size = kEncryptedHeaderSizeBytes;
 
-    if (mVendorId.HasValue())
+    if (HaveVendorId())
     {
         size += kVendorIdSizeBytes;
     }
@@ -220,21 +220,25 @@ CHIP_ERROR PayloadHeader::Decode(const uint8_t * const data, uint16_t size, uint
 
     mExchangeFlags.SetRaw(header);
 
-    if (mExchangeFlags.Has(Header::ExFlagValues::kExchangeFlag_VendorIdPresent))
+    VendorId vendor_id;
+    if (HaveVendorId())
     {
-        uint16_t vendor_id;
-        err = reader.Read16(&vendor_id).StatusCode();
+        uint16_t vendor_id_raw;
+        err = reader.Read16(&vendor_id_raw).StatusCode();
         SuccessOrExit(err);
-        mVendorId.SetValue(vendor_id);
+        vendor_id = static_cast<VendorId>(vendor_id_raw);
     }
     else
     {
-        mVendorId.ClearValue();
+        vendor_id = VendorId::Common;
     }
 
-    err = reader.Read16(&mProtocolID).StatusCode();
+    uint16_t protocol_id;
+    err = reader.Read16(&protocol_id).StatusCode();
     SuccessOrExit(err);
 
+    mProtocolID = Protocols::Id(vendor_id, protocol_id);
+
     if (mExchangeFlags.Has(Header::ExFlagValues::kExchangeFlag_AckMsg))
     {
         uint32_t ack_id;
@@ -327,11 +331,11 @@ CHIP_ERROR PayloadHeader::Encode(uint8_t * data, uint16_t size, uint16_t * encod
     Write8(p, header);
     Write8(p, mMessageType);
     LittleEndian::Write16(p, mExchangeID);
-    if (mVendorId.HasValue())
+    if (HaveVendorId())
     {
-        LittleEndian::Write16(p, mVendorId.Value());
+        LittleEndian::Write16(p, static_cast<std::underlying_type_t<VendorId>>(mProtocolID.GetVendorId()));
     }
-    LittleEndian::Write16(p, mProtocolID);
+    LittleEndian::Write16(p, mProtocolID.GetProtocolId());
     if (mAckId.HasValue())
     {
         LittleEndian::Write32(p, mAckId.Value());
index a587a41..842b298 100644 (file)
@@ -325,27 +325,14 @@ public:
     constexpr PayloadHeader() { SetProtocol(Protocols::NotSpecified); }
     PayloadHeader & operator=(const PayloadHeader &) = default;
 
-    /**
-     * Gets the vendor id in the current message.
-     *
-     * NOTE: the vendor id is optional and may be missing.
-     */
-    const Optional<uint16_t> & GetVendorId() const { return mVendorId; }
-
     /** Get the Session ID from this header. */
     uint16_t GetExchangeID() const { return mExchangeID; }
 
     /** Get the Protocol ID from this header. */
-    // TODO: We should probably get rid of GetProtocolId and the
-    // current form of the mVendorId accessors.
-    uint16_t GetProtocolID() const { return mProtocolID; }
+    Protocols::Id GetProtocolID() const { return mProtocolID; }
 
     /** Check whether the header has a given protocol */
-    bool HasProtocol(Protocols::Id protocol) const
-    {
-        static_assert(std::is_same<std::underlying_type_t<VendorId>, uint16_t>::value, "Wrong type for VendorId");
-        return mProtocolID == protocol.GetProtocolId() && mVendorId.ValueOr(VendorId::Common) == protocol.GetVendorId();
-    }
+    bool HasProtocol(Protocols::Id protocol) const { return mProtocolID == protocol; }
 
     /** Get the secure msg type from this header. */
     uint8_t GetMessageType() const { return mMessageType; }
@@ -366,33 +353,6 @@ public:
      */
     const Optional<uint32_t> & GetAckId() const { return mAckId; }
 
-    /** Set the vendor id for this header. */
-    PayloadHeader & SetVendorId(uint16_t id)
-    {
-        mVendorId.SetValue(id);
-        mExchangeFlags.Set(Header::ExFlagValues::kExchangeFlag_VendorIdPresent);
-
-        return *this;
-    }
-
-    /** Set the vendor id for this header. */
-    constexpr PayloadHeader & SetVendorId(Optional<uint16_t> id)
-    {
-        mVendorId = id;
-        mExchangeFlags.Set(Header::ExFlagValues::kExchangeFlag_VendorIdPresent, id.HasValue());
-
-        return *this;
-    }
-
-    /** Clear the vendor id for this header. */
-    constexpr PayloadHeader & ClearVendorId()
-    {
-        mVendorId.ClearValue();
-        mExchangeFlags.Clear(Header::ExFlagValues::kExchangeFlag_VendorIdPresent);
-
-        return *this;
-    }
-
     /**
      * Set the message type for this header.  This requires setting the protocol
      * id as well, because the meaning of a message type is only relevant given
@@ -562,17 +522,12 @@ public:
 private:
     constexpr void SetProtocol(Protocols::Id protocol)
     {
-        if (protocol.GetVendorId() == VendorId::Common)
-        {
-            ClearVendorId();
-        }
-        else
-        {
-            SetVendorId(protocol.GetVendorId());
-        }
-        mProtocolID = protocol.GetProtocolId();
+        mExchangeFlags.Set(Header::ExFlagValues::kExchangeFlag_VendorIdPresent, protocol.GetVendorId() != VendorId::Common);
+        mProtocolID = protocol;
     }
 
+    constexpr bool HaveVendorId() const { return mExchangeFlags.Has(Header::ExFlagValues::kExchangeFlag_VendorIdPresent); }
+
     /// Packet type (application data, security control packets, e.g. pairing,
     /// configuration, rekey etc)
     uint8_t mMessageType = 0;
@@ -580,11 +535,8 @@ private:
     /// Security session identifier
     uint16_t mExchangeID = 0;
 
-    /// Vendor identifier
-    Optional<uint16_t> mVendorId;
-
     /// Protocol identifier
-    uint16_t mProtocolID = 0xFFFF;
+    Protocols::Id mProtocolID = Protocols::NotSpecified;
 
     /// Bit flag indicators for CHIP Exchange header
     Header::ExFlags mExchangeFlags;
index 64be967..edf0e3b 100644 (file)
@@ -147,7 +147,7 @@ void TestPayloadHeaderEncodeDecode(nlTestSuite * inSuite, void * inContext)
     uint16_t decodeLen;
 
     header.SetMessageType(Protocols::Id(VendorId::Common, 0), 112).SetExchangeID(2233);
-    NL_TEST_ASSERT(inSuite, !header.GetVendorId().HasValue());
+    NL_TEST_ASSERT(inSuite, header.GetProtocolID() == Protocols::Id(VendorId::Common, 0));
 
     header.SetMessageType(Protocols::Id(VendorId::Common, 1221), 112).SetExchangeID(2233).SetInitiator(true);
     NL_TEST_ASSERT(inSuite, header.Encode(buffer, &encodeLen) == CHIP_NO_ERROR);
@@ -157,30 +157,26 @@ void TestPayloadHeaderEncodeDecode(nlTestSuite * inSuite, void * inContext)
     NL_TEST_ASSERT(inSuite, encodeLen == decodeLen);
     NL_TEST_ASSERT(inSuite, header.GetMessageType() == 112);
     NL_TEST_ASSERT(inSuite, header.GetExchangeID() == 2233);
-    NL_TEST_ASSERT(inSuite, header.GetProtocolID() == 1221);
-    NL_TEST_ASSERT(inSuite, !header.GetVendorId().HasValue());
+    NL_TEST_ASSERT(inSuite, header.GetProtocolID() == Protocols::Id(VendorId::Common, 1221));
     NL_TEST_ASSERT(inSuite, header.IsInitiator());
 
     header.SetMessageType(Protocols::Id(VendorId::Common, 1221), 112).SetExchangeID(2233);
-    header.SetVendorId(6789);
 
     NL_TEST_ASSERT(inSuite, header.Encode(buffer, &encodeLen) == CHIP_NO_ERROR);
 
-    header.SetMessageType(Protocols::Id(VendorId::Common, 0), 111).SetExchangeID(222);
+    header.SetMessageType(Protocols::Id(VendorId::NotSpecified, 0), 111).SetExchangeID(222);
 
     NL_TEST_ASSERT(inSuite, header.Decode(buffer, &decodeLen) == CHIP_NO_ERROR);
     NL_TEST_ASSERT(inSuite, encodeLen == decodeLen);
     NL_TEST_ASSERT(inSuite, header.GetExchangeID() == 2233);
-    NL_TEST_ASSERT(inSuite, header.GetVendorId() == Optional<uint16_t>::Value(6789));
+    NL_TEST_ASSERT(inSuite, header.GetProtocolID() == Protocols::Id(VendorId::Common, 1221));
 
-    header.SetMessageType(Protocols::Id(VendorId::Common, 4567), 221).SetExchangeID(3322);
-    header.SetVendorId(8976);
+    header.SetMessageType(Protocols::Id(VendorId::NotSpecified, 4567), 221).SetExchangeID(3322);
 
     NL_TEST_ASSERT(inSuite, header.Decode(buffer, &decodeLen) == CHIP_NO_ERROR);
     NL_TEST_ASSERT(inSuite, encodeLen == decodeLen);
     NL_TEST_ASSERT(inSuite, header.GetExchangeID() == 2233);
-    NL_TEST_ASSERT(inSuite, header.GetProtocolID() == 1221);
-    NL_TEST_ASSERT(inSuite, header.GetVendorId() == Optional<uint16_t>::Value(6789));
+    NL_TEST_ASSERT(inSuite, header.GetProtocolID() == Protocols::Id(VendorId::Common, 1221));
 }
 
 void TestPacketHeaderEncodeDecodeBounds(nlTestSuite * inSuite, void * inContext)