From 9ac8ef4971da9df4909ff9dd1984b43a7613853c Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Mon, 7 Feb 2022 23:22:52 +0800 Subject: [PATCH 01/12] [Ameba] Support Rotating ID for BLE beaconing (#14310) * [Ameba] Support Rotating ID for BLE beaconing * Revert the change in CHIPDevicePlatformConfig.h Remote the definition of CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY. * [Ameba] Add more error returns in GetUniqueId function --- config/ameba/chip.cmake | 5 ++ .../all-clusters-app/ameba/chip_main.cmake | 1 + src/platform/Ameba/AmebaConfig.cpp | 1 + src/platform/Ameba/AmebaConfig.h | 1 + src/platform/Ameba/BLEManagerImpl.cpp | 50 +++++++++++++++++-- src/platform/Ameba/BLEManagerImpl.h | 5 +- src/platform/Ameba/BUILD.gn | 5 +- src/platform/Ameba/CHIPDevicePlatformConfig.h | 2 + .../Ameba/ConfigurationManagerImpl.cpp | 24 +++++++++ src/platform/Ameba/ConfigurationManagerImpl.h | 2 +- 10 files changed, 89 insertions(+), 7 deletions(-) diff --git a/config/ameba/chip.cmake b/config/ameba/chip.cmake index fa0258dd497fd2..f283a1f0d58dd4 100644 --- a/config/ameba/chip.cmake +++ b/config/ameba/chip.cmake @@ -118,6 +118,11 @@ if (matter_enable_ota_requestor) string(APPEND CHIP_GN_ARGS "chip_enable_ota_requestor = true\n") endif (matter_enable_ota_requestor) +if (CONFIG_ENABLE_ROTATING_DEVICE_ID) + string(APPEND CHIP_GN_ARGS "chip_enable_additional_data_advertising" "true") + string(APPEND CHIP_GN_ARGS "chip_enable_rotating_device_id" "true") +endif() + file(GENERATE OUTPUT ${CHIP_OUTPUT}/args.gn CONTENT ${CHIP_GN_ARGS}) ExternalProject_Add( diff --git a/examples/all-clusters-app/ameba/chip_main.cmake b/examples/all-clusters-app/ameba/chip_main.cmake index b549aab9af32a2..e201e96ada55d7 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -234,6 +234,7 @@ list( -DPW_RPC_LIGHTING_SERVICE=1 -DPW_RPC_LOCKING_SERVICE=1 -DCONFIG_ENABLE_PW_RPC=1 + -DCONFIG_ENABLE_ROTATING_DEVICE_ID=1 ) endif (matter_enable_rpc) diff --git a/src/platform/Ameba/AmebaConfig.cpp b/src/platform/Ameba/AmebaConfig.cpp index d85e9bd2c11159..3ee33e6931f11a 100644 --- a/src/platform/Ameba/AmebaConfig.cpp +++ b/src/platform/Ameba/AmebaConfig.cpp @@ -59,6 +59,7 @@ const AmebaConfig::Key AmebaConfig::kConfigKey_SetupDiscriminator = { kConfig const AmebaConfig::Key AmebaConfig::kConfigKey_Spake2pIterationCount = { kConfigNamespace_ChipFactory, "iteration-count" }; const AmebaConfig::Key AmebaConfig::kConfigKey_Spake2pSalt = { kConfigNamespace_ChipFactory, "salt" }; const AmebaConfig::Key AmebaConfig::kConfigKey_Spake2pVerifier = { kConfigNamespace_ChipFactory, "verifier" }; +const AmebaConfig::Key AmebaConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipFactory, "uniqueId" }; // Keys stored in the chip-config namespace const AmebaConfig::Key AmebaConfig::kConfigKey_FabricId = { kConfigNamespace_ChipConfig, "fabric-id" }; diff --git a/src/platform/Ameba/AmebaConfig.h b/src/platform/Ameba/AmebaConfig.h index c72663376b5c46..2ca0f0adbcc5a6 100755 --- a/src/platform/Ameba/AmebaConfig.h +++ b/src/platform/Ameba/AmebaConfig.h @@ -72,6 +72,7 @@ class AmebaConfig static const Key kConfigKey_Spake2pVerifier; // Counter keys + static const Key kConfigKey_UniqueId; static const Key kCounterKey_RebootCount; static const Key kCounterKey_UpTime; static const Key kCounterKey_TotalOperationalHours; diff --git a/src/platform/Ameba/BLEManagerImpl.cpp b/src/platform/Ameba/BLEManagerImpl.cpp index 0d487e4d1ee31b..7de47d529951d5 100755 --- a/src/platform/Ameba/BLEManagerImpl.cpp +++ b/src/platform/Ameba/BLEManagerImpl.cpp @@ -25,6 +25,7 @@ /* this file behaves like a config.h, comes first */ #include #include +#include #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #include @@ -48,7 +49,9 @@ #include "wifi_conf.h" //#include "complete_ble_service.h" #include "app_msg.h" - +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +#include +#endif extern void wifi_bt_coex_set_bt_on(void); /******************************************************************************* * Local data types @@ -116,6 +119,7 @@ typedef struct } ble_uuid16_t; const ble_uuid16_t ShortUUID_CHIPoBLEService = { BLE_UUID_TYPE_16, 0xFFF6 }; + const ChipBleUUID ChipUUID_CHIPoBLEChar_RX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, 0x9D, 0x11 } }; const ChipBleUUID ChipUUID_CHIPoBLEChar_TX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, @@ -153,7 +157,7 @@ CHIP_ERROR BLEManagerImpl::_Init() return err; } -void BLEManagerImpl::HandleTXCharRead(struct ble_gatt_char_context * param) +void BLEManagerImpl::HandleTXCharRead(void * param) { /* Not supported */ ChipLogError(DeviceLayer, "BLEManagerImpl::HandleTXCharRead() not supported"); @@ -614,6 +618,10 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) ExitNow(); } +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + deviceIdInfo.SetAdditionalDataFlag(true); +#endif + VerifyOrExit(index + sizeof(deviceIdInfo) <= sizeof(advData), err = CHIP_ERROR_OUTBOUND_MESSAGE_TOO_BIG); memcpy(&advData[index], &deviceIdInfo, sizeof(deviceIdInfo)); index = static_cast(index + sizeof(deviceIdInfo)); @@ -935,9 +943,7 @@ CHIP_ERROR BLEManagerImpl::ble_svr_gap_event(void * param, int cb_type, void * p CHIP_ERROR BLEManagerImpl::gatt_svr_chr_access(void * param, T_SERVER_ID service_id, TBTCONFIG_CALLBACK_DATA * p_data) { - CHIP_ERROR err = CHIP_NO_ERROR; - if (service_id == SERVICE_PROFILE_GENERAL_ID) { T_SERVER_APP_CB_DATA * p_param = (T_SERVER_APP_CB_DATA *) p_data; @@ -961,9 +967,13 @@ CHIP_ERROR BLEManagerImpl::gatt_svr_chr_access(void * param, T_SERVER_ID service uint8_t * p_value = p_data->msg_data.write.p_value; uint16_t len = p_data->msg_data.write.len; BLEManagerImpl * blemgr = static_cast(param); + switch (msg_type) { case SERVICE_CALLBACK_TYPE_READ_CHAR_VALUE: +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + sInstance.HandleC3CharRead(p_data); +#endif break; case SERVICE_CALLBACK_TYPE_WRITE_CHAR_VALUE: @@ -1019,6 +1029,38 @@ void BLEManagerImpl::HandleRXCharWrite(uint8_t * p_value, uint16_t len, uint8_t } } +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +void BLEManagerImpl::HandleC3CharRead(TBTCONFIG_CALLBACK_DATA * p_data) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + PacketBufferHandle bufferHandle; + char serialNumber[ConfigurationManager::kMaxSerialNumberLength + 1] = {}; + uint16_t lifetimeCounter = 0; + BitFlags additionalDataFields; + +#if CHIP_ENABLE_ROTATING_DEVICE_ID + err = ConfigurationMgr().GetSerialNumber(serialNumber, sizeof(serialNumber)); + SuccessOrExit(err); + err = ConfigurationMgr().GetLifetimeCounter(lifetimeCounter); + SuccessOrExit(err); + additionalDataFields.Set(AdditionalDataFields::RotatingDeviceId); +#endif /* CHIP_ENABLE_ROTATING_DEVICE_ID */ + + err = AdditionalDataPayloadGenerator().generateAdditionalDataPayload(lifetimeCounter, serialNumber, strlen(serialNumber), + bufferHandle, additionalDataFields); + SuccessOrExit(err); + p_data->msg_data.write.p_value = bufferHandle->Start(); + p_data->msg_data.write.len = bufferHandle->DataLength(); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to generate TLV encoded Additional Data (%s)", __func__); + } + return; +} +#endif /* CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING */ + int BLEManagerImpl::ble_callback_dispatcher(void * param, void * p_cb_data, int type, T_CHIP_BLEMGR_CALLBACK_TYPE callback_type) { BLEManagerImpl * blemgr = static_cast(param); diff --git a/src/platform/Ameba/BLEManagerImpl.h b/src/platform/Ameba/BLEManagerImpl.h index 8218f8e027a81e..375989f7db91e8 100755 --- a/src/platform/Ameba/BLEManagerImpl.h +++ b/src/platform/Ameba/BLEManagerImpl.h @@ -143,7 +143,10 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla CHIP_ERROR ConfigureAdvertisingData(void); void HandleRXCharWrite(uint8_t *, uint16_t, uint8_t); - void HandleTXCharRead(struct ble_gatt_char_context * param); + void HandleTXCharRead(void * param); +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + void HandleC3CharRead(TBTCONFIG_CALLBACK_DATA * p_data); +#endif void HandleTXCharCCCDRead(void * param); void HandleTXCharCCCDWrite(int, int, int); CHIP_ERROR HandleTXComplete(int); diff --git a/src/platform/Ameba/BUILD.gn b/src/platform/Ameba/BUILD.gn index 0faaf969128164..ec2349745c5329 100755 --- a/src/platform/Ameba/BUILD.gn +++ b/src/platform/Ameba/BUILD.gn @@ -48,7 +48,10 @@ static_library("Ameba") { "SystemTimeSupport.h", ] - deps = [ "${chip_root}/src/lib/dnssd:platform_header" ] + deps = [ + "${chip_root}/src/lib/dnssd:platform_header", + "${chip_root}/src/setup_payload", + ] public_deps = [ "${chip_root}/src/crypto", diff --git a/src/platform/Ameba/CHIPDevicePlatformConfig.h b/src/platform/Ameba/CHIPDevicePlatformConfig.h index 6e66ee9d6d7327..839321e78c079e 100644 --- a/src/platform/Ameba/CHIPDevicePlatformConfig.h +++ b/src/platform/Ameba/CHIPDevicePlatformConfig.h @@ -75,3 +75,5 @@ 0x7d, 0x0e, 0x38, 0x85, 0x6c, 0x12, 0xcd, 0x64, 0xc2, 0x25, 0xbb, 0x24, 0xef, 0x21, 0x41, 0x7e, 0x0e, 0x44, 0xe5 }" #define CONFIG_RENDEZVOUS_MODE 6 +#define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1 +//#define CHIP_DEVICE_CONFIG_UNIQUE_ID "00112233445566778899AABBCCDDEEFF" diff --git a/src/platform/Ameba/ConfigurationManagerImpl.cpp b/src/platform/Ameba/ConfigurationManagerImpl.cpp index aa6434c21c85c3..c9a3d91d5f5a9a 100644 --- a/src/platform/Ameba/ConfigurationManagerImpl.cpp +++ b/src/platform/Ameba/ConfigurationManagerImpl.cpp @@ -152,6 +152,30 @@ CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) return CHIP_NO_ERROR; } +CHIP_ERROR ConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize) +{ +#ifdef CHIP_DEVICE_CONFIG_UNIQUE_ID + ReturnErrorCodeIf(bufSize < sizeof(CHIP_DEVICE_CONFIG_UNIQUE_ID), CHIP_ERROR_BUFFER_TOO_SMALL); + strcpy(buf, CHIP_DEVICE_CONFIG_UNIQUE_ID); + return CHIP_NO_ERROR; +#else + ReturnErrorCodeIf(bufSize != 32, CHIP_ERROR_INVALID_MESSAGE_LENGTH); + char temp[32]; + int i = 0, j = 0; + + memset(&temp[0], 0, 32); + ReturnErrorCodeIf(wifi_get_mac_address(temp) != 0, CHIP_ERROR_INVALID_ARGUMENT); + + for (i = 0; i < bufSize; i++) + { + if (temp[i] != ':') + buf[j++] = temp[i]; + } + + return CHIP_NO_ERROR; +#endif +} + bool ConfigurationManagerImpl::CanFactoryReset() { // TODO: query the application to determine if factory reset is allowed. diff --git a/src/platform/Ameba/ConfigurationManagerImpl.h b/src/platform/Ameba/ConfigurationManagerImpl.h index 035f3313e7caae..c7cd2e2513ec97 100644 --- a/src/platform/Ameba/ConfigurationManagerImpl.h +++ b/src/platform/Ameba/ConfigurationManagerImpl.h @@ -55,7 +55,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override; CHIP_ERROR GetBootReason(uint32_t & bootReason) override; CHIP_ERROR StoreBootReason(uint32_t bootReason) override; - + CHIP_ERROR GetUniqueId(char * buf, size_t bufSize) override; // NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>. // ===== Members that implement the GenericConfigurationManagerImpl protected interface. From 4d365512d701292ad314bc07b9317c05734994e4 Mon Sep 17 00:00:00 2001 From: lucicop Date: Mon, 7 Feb 2022 17:28:22 +0200 Subject: [PATCH 02/12] Add OTA header generation when compiling (#14745) * Add OTA header generation when compiling * Correct path to qpg script * Restyled by gn * Fix gni to work even when OTA requestor is not defined Co-authored-by: Restyled.io --- third_party/qpg_sdk/qpg_executable.gni | 42 +++++++++++++++++++++++++- third_party/qpg_sdk/repo | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/third_party/qpg_sdk/qpg_executable.gni b/third_party/qpg_sdk/qpg_executable.gni index 068c857a6f9f16..21398b9d44075b 100644 --- a/third_party/qpg_sdk/qpg_executable.gni +++ b/third_party/qpg_sdk/qpg_executable.gni @@ -14,12 +14,26 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") import("${build_root}/toolchain/flashable_executable.gni") +import("${chip_root}/src/platform/device.gni") +import("${dir_pw_build}/python.gni") template("qpg_executable") { output_base_name = get_path_info(invoker.output_name, "name") + qpg_target_name = target_name + executable_target_name = "${target_name}.out" + if (chip_enable_ota_requestor) { + # Generate OTA image after executable + ota_target_name = "${target_name}_ota" + final_target = ota_target_name + } else { + # The executable is the final target. + final_target = executable_target_name + } + objcopy_image_name = invoker.output_name + ".hex" objcopy_image_format = "ihex" objcopy = "arm-none-eabi-objcopy" @@ -45,8 +59,34 @@ template("qpg_executable") { flashing_script_name = output_base_name + ".flash.py" flashing_options = [ "qpg" ] - flashable_executable(target_name) { + flashable_executable(executable_target_name) { forward_variables_from(invoker, "*") data_deps = [ ":${flashing_runtime_target}" ] } + + # If OTA requestor is enabled, generate OTA image from HEX + if (chip_enable_ota_requestor) { + pw_python_action(ota_target_name) { + public_deps = [ ":${qpg_target_name}.out.image" ] + sources = [ "${root_out_dir}/${objcopy_image_name}" ] + outputs = [ "${root_out_dir}/${objcopy_image_name}.ota" ] + script = + "${chip_root}/third_party/qpg_sdk/repo/Tools/ota/generate_ota_img.py" + out_dir = rebase_path(root_out_dir, root_build_dir) + + args = [ + rebase_path(chip_root, root_build_dir), + "${out_dir}/${invoker.output_name}.hex", + "${out_dir}/${invoker.output_name}.ota", + ] + } + } + + group(qpg_target_name) { + data_deps = [ ":$final_target" ] + + if (defined(invoker.data_deps)) { + data_deps += invoker.data_deps + } + } } diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index 2b463adb2a9323..e8b208b64acd70 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit 2b463adb2a9323fc54d435f359cd0f167845dfb1 +Subproject commit e8b208b64acd70da01780215164a270ca21935d2 From d5d9dc72368756d47dda9f0477a5b393b2e631a8 Mon Sep 17 00:00:00 2001 From: Lazar Kovacic Date: Mon, 7 Feb 2022 16:54:20 +0100 Subject: [PATCH 03/12] Media clusters & TV app minor attributes update (#14808) * Update attributes in xml and in code * Update code * Run zap regen code * Restyle fix * Fix tv android app --- .../all-clusters-app.matter | 6 +-- .../ApplicationLauncherManager.cpp | 24 +++++---- .../ApplicationLauncherManager.h | 18 +++---- .../ApplicationLauncherManager.cpp | 24 +++++---- .../ApplicationLauncherManager.h | 18 +++---- .../TargetNavigatorManager.cpp | 5 +- examples/tv-app/tv-common/tv-app.matter | 18 +++---- .../tv-casting-common/tv-casting-app.matter | 14 ++--- .../application-launcher-delegate.h | 16 +++--- .../application-launcher-server.cpp | 18 ++++--- .../data-model/chip/account-login-cluster.xml | 6 +-- .../chip/application-basic-cluster.xml | 2 +- .../chip/application-launcher-cluster.xml | 14 ++--- .../chip/target-navigator-cluster.xml | 4 +- .../data_model/controller-clusters.matter | 16 +++--- .../java/zap-generated/CHIPClusters-JNI.cpp | 6 +-- .../zap-generated/CHIPInvokeCallbacks.cpp | 8 +-- .../chip/devicecontroller/ChipClusters.java | 30 +++++------ .../chip/devicecontroller/ChipStructs.java | 12 ++--- .../devicecontroller/ClusterInfoMapping.java | 16 +++--- .../python/chip/clusters/CHIPClusters.py | 2 +- .../python/chip/clusters/Objects.py | 30 +++++------ .../CHIP/zap-generated/CHIPCallbackBridge.mm | 2 +- .../CHIP/zap-generated/CHIPClustersObjc.mm | 2 +- .../zap-generated/CHIPCommandPayloadsObjc.h | 10 ++-- .../zap-generated/CHIPCommandPayloadsObjc.mm | 10 ++-- .../CHIP/zap-generated/CHIPStructsObjc.h | 4 +- .../CHIP/zap-generated/CHIPStructsObjc.mm | 4 +- .../app-common/zap-generated/af-structs.h | 8 +-- .../app-common/zap-generated/callback.h | 2 +- .../zap-generated/cluster-objects.cpp | 12 ++--- .../zap-generated/cluster-objects.h | 36 ++++++------- .../zap-generated/cluster/Commands.h | 11 ++-- .../cluster/ComplexArgumentParser.cpp | 53 +++++++++---------- .../cluster/ComplexArgumentParser.h | 9 ++-- .../cluster/logging/DataModelLogger.cpp | 31 ++++++----- .../cluster/logging/DataModelLogger.h | 5 +- .../chip-tool/zap-generated/test/Commands.h | 15 +++--- 38 files changed, 259 insertions(+), 262 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 57424669a63bf5..a51a1a38380504 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -141,7 +141,7 @@ server cluster ApplicationLauncher = 1292 { kLineupInfo = 0x2; } - struct ApplicationLauncherApplication { + struct Application { INT16U catalogVendorId = 0; CHAR_STRING applicationId = 1; } @@ -2815,8 +2815,8 @@ server cluster Switch = 59 { server cluster TargetNavigator = 1285 { enum StatusEnum : ENUM8 { kSuccess = 0; - kAppNotAvailable = 1; - kSystemBusy = 2; + kTargetNotFound = 1; + kNotAllowed = 2; } struct TargetInfo { diff --git a/examples/tv-app/android/include/application-launcher/ApplicationLauncherManager.cpp b/examples/tv-app/android/include/application-launcher/ApplicationLauncherManager.cpp index 003a20d84ce3f7..20340e478cbae1 100644 --- a/examples/tv-app/android/include/application-launcher/ApplicationLauncherManager.cpp +++ b/examples/tv-app/android/include/application-launcher/ApplicationLauncherManager.cpp @@ -21,6 +21,7 @@ using namespace std; using namespace chip::app; using namespace chip::app::Clusters::ApplicationLauncher; +using namespace chip::Uint8; CHIP_ERROR ApplicationLauncherManager::HandleGetCatalogList(AttributeValueEncoder & aEncoder) { @@ -34,32 +35,35 @@ CHIP_ERROR ApplicationLauncherManager::HandleGetCatalogList(AttributeValueEncode }); } -void ApplicationLauncherManager::HandleLaunchApp(CommandResponseHelper & helper, const CharSpan & data, - const ApplicationLauncherApplicationType & application) +void ApplicationLauncherManager::HandleLaunchApp(CommandResponseHelper & helper, const ByteSpan & data, + const ApplicationType & application) { // TODO: Insert code here Commands::LauncherResponse::Type response; - response.data = chip::CharSpan::fromCharString("data"); - response.status = StatusEnum::kSuccess; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kSuccess; helper.Success(response); } void ApplicationLauncherManager::HandleStopApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) + const ApplicationType & application) { // TODO: Insert code here Commands::LauncherResponse::Type response; - response.data = chip::CharSpan::fromCharString("data"); - response.status = StatusEnum::kSuccess; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kSuccess; helper.Success(response); } void ApplicationLauncherManager::HandleHideApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) + const ApplicationType & application) { // TODO: Insert code here Commands::LauncherResponse::Type response; - response.data = chip::CharSpan::fromCharString("data"); - response.status = StatusEnum::kSuccess; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kSuccess; helper.Success(response); } diff --git a/examples/tv-app/android/include/application-launcher/ApplicationLauncherManager.h b/examples/tv-app/android/include/application-launcher/ApplicationLauncherManager.h index 529f4d440acbe6..84c65e7508aed7 100644 --- a/examples/tv-app/android/include/application-launcher/ApplicationLauncherManager.h +++ b/examples/tv-app/android/include/application-launcher/ApplicationLauncherManager.h @@ -21,22 +21,20 @@ #include #include -using chip::CharSpan; +using chip::ByteSpan; using chip::app::AttributeValueEncoder; using chip::app::CommandResponseHelper; -using ApplicationLauncherDelegate = chip::app::Clusters::ApplicationLauncher::Delegate; -using ApplicationLauncherApplicationType = chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::Type; -using LauncherResponseType = chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::Type; +using ApplicationLauncherDelegate = chip::app::Clusters::ApplicationLauncher::Delegate; +using ApplicationType = chip::app::Clusters::ApplicationLauncher::Structs::Application::Type; +using LauncherResponseType = chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::Type; class ApplicationLauncherManager : public ApplicationLauncherDelegate { public: CHIP_ERROR HandleGetCatalogList(AttributeValueEncoder & aEncoder) override; - void HandleLaunchApp(CommandResponseHelper & helper, const CharSpan & data, - const ApplicationLauncherApplicationType & application) override; - void HandleStopApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) override; - void HandleHideApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) override; + void HandleLaunchApp(CommandResponseHelper & helper, const ByteSpan & data, + const ApplicationType & application) override; + void HandleStopApp(CommandResponseHelper & helper, const ApplicationType & application) override; + void HandleHideApp(CommandResponseHelper & helper, const ApplicationType & application) override; }; diff --git a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp b/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp index 333160e12cedf4..b23134e839d892 100644 --- a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp +++ b/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp @@ -22,6 +22,7 @@ using namespace std; using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::ApplicationLauncher; +using namespace chip::Uint8; CHIP_ERROR ApplicationLauncherManager::HandleGetCatalogList(AttributeValueEncoder & aEncoder) { @@ -35,38 +36,41 @@ CHIP_ERROR ApplicationLauncherManager::HandleGetCatalogList(AttributeValueEncode }); } -void ApplicationLauncherManager::HandleLaunchApp(CommandResponseHelper & helper, const CharSpan & data, - const ApplicationLauncherApplicationType & application) +void ApplicationLauncherManager::HandleLaunchApp(CommandResponseHelper & helper, const ByteSpan & data, + const ApplicationType & application) { ChipLogError(Zcl, "ApplicationLauncherManager::HandleLaunchApp"); // TODO: Insert code here LauncherResponseType response; - response.data = CharSpan::fromCharString("data"); - response.status = StatusEnum::kSuccess; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kSuccess; helper.Success(response); } void ApplicationLauncherManager::HandleStopApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) + const ApplicationType & application) { ChipLogError(Zcl, "ApplicationLauncherManager::HandleStopApp"); // TODO: Insert code here LauncherResponseType response; - response.data = CharSpan::fromCharString("data"); - response.status = StatusEnum::kSuccess; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kSuccess; helper.Success(response); } void ApplicationLauncherManager::HandleHideApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) + const ApplicationType & application) { ChipLogError(Zcl, "ApplicationLauncherManager::HandleHideApp"); // TODO: Insert code here LauncherResponseType response; - response.data = CharSpan::fromCharString("data"); - response.status = StatusEnum::kSuccess; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kSuccess; helper.Success(response); } diff --git a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h b/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h index e3778d3e8fb05a..073c20c9831eb3 100644 --- a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h +++ b/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h @@ -21,12 +21,12 @@ #include #include -using chip::CharSpan; +using chip::ByteSpan; using chip::app::AttributeValueEncoder; using chip::app::CommandResponseHelper; -using ApplicationLauncherDelegate = chip::app::Clusters::ApplicationLauncher::Delegate; -using ApplicationLauncherApplicationType = chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::Type; -using LauncherResponseType = chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::Type; +using ApplicationLauncherDelegate = chip::app::Clusters::ApplicationLauncher::Delegate; +using ApplicationType = chip::app::Clusters::ApplicationLauncher::Structs::Application::Type; +using LauncherResponseType = chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::Type; class ApplicationLauncherManager : public ApplicationLauncherDelegate { @@ -36,10 +36,8 @@ class ApplicationLauncherManager : public ApplicationLauncherDelegate CHIP_ERROR HandleGetCatalogList(AttributeValueEncoder & aEncoder) override; - void HandleLaunchApp(CommandResponseHelper & helper, const CharSpan & data, - const ApplicationLauncherApplicationType & application) override; - void HandleStopApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) override; - void HandleHideApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) override; + void HandleLaunchApp(CommandResponseHelper & helper, const ByteSpan & data, + const ApplicationType & application) override; + void HandleStopApp(CommandResponseHelper & helper, const ApplicationType & application) override; + void HandleHideApp(CommandResponseHelper & helper, const ApplicationType & application) override; }; diff --git a/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp b/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp index 576fa443ca9fd4..99dd5a40239933 100644 --- a/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp +++ b/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp @@ -55,9 +55,8 @@ void TargetNavigatorManager::HandleNavigateTarget(CommandResponseHelper mTargets.size()) { - response.data = CharSpan::fromCharString("error"); - // TODO: should be TARGET_NOT_FOUND - response.status = StatusEnum::kAppNotAvailable; + response.data = CharSpan::fromCharString("error"); + response.status = StatusEnum::kTargetNotFound; helper.Success(response); return; } diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index 0990bab3085362..c15b12d97a5244 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -166,11 +166,11 @@ server cluster ApplicationLauncher = 1292 { } struct ApplicationEP { - ApplicationLauncherApplication application = 0; + Application application = 0; CHAR_STRING endpoint = 1; } - struct ApplicationLauncherApplication { + struct Application { INT16U catalogVendorId = 0; CHAR_STRING applicationId = 1; } @@ -180,21 +180,21 @@ server cluster ApplicationLauncher = 1292 { readonly global attribute int16u clusterRevision = 65533; request struct HideAppRequestRequest { - ApplicationLauncherApplication application = 0; + Application application = 0; } request struct LaunchAppRequestRequest { - CHAR_STRING data = 0; - ApplicationLauncherApplication application = 1; + Application application = 0; + OCTET_STRING data = 1; } request struct StopAppRequestRequest { - ApplicationLauncherApplication application = 0; + Application application = 0; } response struct LauncherResponse { StatusEnum status = 0; - CHAR_STRING data = 1; + OCTET_STRING data = 1; } command HideAppRequest(HideAppRequestRequest): LauncherResponse = 2; @@ -1671,8 +1671,8 @@ server cluster SoftwareDiagnostics = 52 { server cluster TargetNavigator = 1285 { enum StatusEnum : ENUM8 { kSuccess = 0; - kAppNotAvailable = 1; - kSystemBusy = 2; + kTargetNotFound = 1; + kNotAllowed = 2; } struct TargetInfo { diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index 72e903d463b8bd..5bb9d36960f58c 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -154,7 +154,7 @@ client cluster ApplicationLauncher = 1292 { kLineupInfo = 0x2; } - struct ApplicationLauncherApplication { + struct Application { INT16U catalogVendorId = 0; CHAR_STRING applicationId = 1; } @@ -163,16 +163,16 @@ client cluster ApplicationLauncher = 1292 { readonly global attribute int16u clusterRevision = 65533; request struct HideAppRequestRequest { - ApplicationLauncherApplication application = 0; + Application application = 0; } request struct LaunchAppRequestRequest { - CHAR_STRING data = 0; - ApplicationLauncherApplication application = 1; + Application application = 0; + OCTET_STRING data = 1; } request struct StopAppRequestRequest { - ApplicationLauncherApplication application = 0; + Application application = 0; } command HideAppRequest(HideAppRequestRequest): LauncherResponse = 2; @@ -2409,8 +2409,8 @@ server cluster Switch = 59 { client cluster TargetNavigator = 1285 { enum StatusEnum : ENUM8 { kSuccess = 0; - kAppNotAvailable = 1; - kSystemBusy = 2; + kTargetNotFound = 1; + kNotAllowed = 2; } struct TargetInfo { diff --git a/src/app/clusters/application-launcher-server/application-launcher-delegate.h b/src/app/clusters/application-launcher-server/application-launcher-delegate.h index c1b608c47d6886..fba8a994eef8de 100644 --- a/src/app/clusters/application-launcher-server/application-launcher-delegate.h +++ b/src/app/clusters/application-launcher-server/application-launcher-delegate.h @@ -30,9 +30,9 @@ namespace app { namespace Clusters { namespace ApplicationLauncher { -using ApplicationLauncherApplicationType = chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::Type; -using ApplicationEPType = chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::Type; -using LauncherResponseType = chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::Type; +using Application = chip::app::Clusters::ApplicationLauncher::Structs::Application::Type; +using ApplicationEPType = chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::Type; +using LauncherResponseType = chip::app::Clusters::ApplicationLauncher::Commands::LauncherResponse::Type; /** @brief * Defines methods for implementing application-specific logic for the Application Launcher Cluster. @@ -57,12 +57,10 @@ class Delegate virtual CHIP_ERROR HandleGetCatalogList(app::AttributeValueEncoder & aEncoder) = 0; - virtual void HandleLaunchApp(CommandResponseHelper & helper, const CharSpan & data, - const ApplicationLauncherApplicationType & application) = 0; - virtual void HandleStopApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) = 0; - virtual void HandleHideApp(CommandResponseHelper & helper, - const ApplicationLauncherApplicationType & application) = 0; + virtual void HandleLaunchApp(CommandResponseHelper & helper, const ByteSpan & data, + const Application & application) = 0; + virtual void HandleStopApp(CommandResponseHelper & helper, const Application & application) = 0; + virtual void HandleHideApp(CommandResponseHelper & helper, const Application & application) = 0; virtual ~Delegate() = default; diff --git a/src/app/clusters/application-launcher-server/application-launcher-server.cpp b/src/app/clusters/application-launcher-server/application-launcher-server.cpp index b114b48a54c300..20733e06cda681 100644 --- a/src/app/clusters/application-launcher-server/application-launcher-server.cpp +++ b/src/app/clusters/application-launcher-server/application-launcher-server.cpp @@ -42,6 +42,7 @@ using namespace chip::app::Clusters::ApplicationLauncher; #if CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED using namespace chip::AppPlatform; #endif // CHIP_DEVICE_CONFIG_APP_PLATFORM_ENABLED +using namespace chip::Uint8; // ----------------------------------------------------------------------------- // Delegate Implementation @@ -217,7 +218,7 @@ bool emberAfApplicationLauncherClusterLaunchAppRequestCallback(app::CommandHandl // chip-tool can't send structs from command line so treat data value as appid if appid is blank // TODO: fix this once chip-tool support sending structs from command line ChipLogError(Zcl, "ApplicationLauncher blank content id, taking data as appid"); - appId = std::string(data.data(), data.size()); + appId = std::string((char *) data.data(), data.size()); } CatalogVendorApp vendorApp(application.catalogVendorId, appId.c_str()); @@ -239,8 +240,9 @@ bool emberAfApplicationLauncherClusterLaunchAppRequestCallback(app::CommandHandl { ChipLogError(Zcl, "ApplicationLauncher target app not found"); LauncherResponseType response; - response.data = CharSpan("data", strlen("data")); - response.status = StatusEnum::kAppNotAvailable; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kAppNotAvailable; responder.Success(response); return true; } @@ -319,8 +321,9 @@ bool emberAfApplicationLauncherClusterStopAppRequestCallback(app::CommandHandler { ChipLogError(Zcl, "ApplicationLauncher target app not loaded"); LauncherResponseType response; - response.data = CharSpan("data", strlen("data")); - response.status = StatusEnum::kAppNotAvailable; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kAppNotAvailable; responder.Success(response); return true; } @@ -402,8 +405,9 @@ bool emberAfApplicationLauncherClusterHideAppRequestCallback(app::CommandHandler { ChipLogError(Zcl, "ApplicationLauncher target app not loaded"); LauncherResponseType response; - response.data = CharSpan("data", strlen("data")); - response.status = StatusEnum::kAppNotAvailable; + const char * buf = "data"; + response.data = ByteSpan(from_const_char(buf), strlen(buf)); + response.status = StatusEnum::kAppNotAvailable; responder.Success(response); return true; } diff --git a/src/app/zap-templates/zcl/data-model/chip/account-login-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/account-login-cluster.xml index a608c1e62652de..a9c29e2e032a92 100644 --- a/src/app/zap-templates/zcl/data-model/chip/account-login-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/account-login-cluster.xml @@ -27,13 +27,13 @@ limitations under the License. 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. - + 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. - - + + diff --git a/src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml index cf5f66e39dedd7..0df216ceda6178 100644 --- a/src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml @@ -26,7 +26,7 @@ limitations under the License. This cluster provides information about an application running on a TV or media player device which is represented as an endpoint. vendor name vendor id - application name + application name product id application app application status diff --git a/src/app/zap-templates/zcl/data-model/chip/application-launcher-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/application-launcher-cluster.xml index d83fcc6ecb5dd4..14ee57f72f0110 100644 --- a/src/app/zap-templates/zcl/data-model/chip/application-launcher-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/application-launcher-cluster.xml @@ -30,35 +30,35 @@ limitations under the License. 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. - - + + Upon receipt on a Video Player endpoint this SHALL stop the specified application if it is running. - + Upon receipt on a Video Player endpoint this SHALL hide the specified application if it is running and visible. - + This command SHALL be generated in response to LaunchApp commands. - + - + - + diff --git a/src/app/zap-templates/zcl/data-model/chip/target-navigator-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/target-navigator-cluster.xml index 24477d624342ab..49bcfe104bfc3d 100644 --- a/src/app/zap-templates/zcl/data-model/chip/target-navigator-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/target-navigator-cluster.xml @@ -44,8 +44,8 @@ limitations under the License. - - + + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 26c513740f0e1d..deda22970b2c33 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -176,7 +176,7 @@ client cluster ApplicationLauncher = 1292 { kLineupInfo = 0x2; } - struct ApplicationLauncherApplication { + struct Application { INT16U catalogVendorId = 0; CHAR_STRING applicationId = 1; } @@ -188,21 +188,21 @@ client cluster ApplicationLauncher = 1292 { readonly global attribute int16u clusterRevision = 65533; request struct HideAppRequestRequest { - ApplicationLauncherApplication application = 0; + Application application = 0; } request struct LaunchAppRequestRequest { - CHAR_STRING data = 0; - ApplicationLauncherApplication application = 1; + Application application = 0; + OCTET_STRING data = 1; } request struct StopAppRequestRequest { - ApplicationLauncherApplication application = 0; + Application application = 0; } response struct LauncherResponse { StatusEnum status = 0; - CHAR_STRING data = 1; + OCTET_STRING data = 1; } command HideAppRequest(HideAppRequestRequest): LauncherResponse = 2; @@ -3196,8 +3196,8 @@ client cluster Switch = 59 { client cluster TargetNavigator = 1285 { enum StatusEnum : ENUM8 { kSuccess = 0; - kAppNotAvailable = 1; - kSystemBusy = 2; + kTargetNotFound = 1; + kNotAllowed = 2; } struct TargetInfo { diff --git a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp index 4178721f9c9d33..3accb6c018eecc 100644 --- a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp +++ b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp @@ -1514,7 +1514,7 @@ JNI_METHOD(void, ApplicationLauncherCluster, hideAppRequest) onFailure.release(); } JNI_METHOD(void, ApplicationLauncherCluster, launchAppRequest) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jstring data, jobject application, jobject timedInvokeTimeoutMs) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject application, jbyteArray data, jobject timedInvokeTimeoutMs) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; @@ -1525,8 +1525,6 @@ JNI_METHOD(void, ApplicationLauncherCluster, launchAppRequest) std::vector> cleanupByteArrays; std::vector> cleanupStrings; - cleanupStrings.push_back(chip::Platform::MakeUnique(env, static_cast(data))); - request.data = cleanupStrings.back()->charSpan(); jobject application_catalogVendorIdItem_0; chip::JniReferences::GetInstance().GetObjectField(application, "catalogVendorId", "Ljava/lang/Integer;", application_catalogVendorIdItem_0); @@ -1538,6 +1536,8 @@ JNI_METHOD(void, ApplicationLauncherCluster, launchAppRequest) cleanupStrings.push_back( chip::Platform::MakeUnique(env, static_cast(application_applicationIdItem_0))); request.application.applicationId = cleanupStrings.back()->charSpan(); + cleanupByteArrays.push_back(chip::Platform::MakeUnique(env, static_cast(data))); + request.data = cleanupByteArrays.back()->byteSpan(); std::unique_ptr diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp index c1342ecb1c4362..450b27f118ae9f 100644 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp @@ -136,8 +136,7 @@ void CHIPApplicationLauncherClusterLauncherResponseCallback::CallbackFn( // Java callback is allowed to be null, exit early if this is the case. VerifyOrReturn(javaCallbackRef != nullptr); - err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;Ljava/lang/String;)V", - &javaMethod); + err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;[B)V", &javaMethod); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); jobject status; @@ -146,7 +145,10 @@ void CHIPApplicationLauncherClusterLauncherResponseCallback::CallbackFn( chip::JniReferences::GetInstance().CreateBoxedObject(statusClassName.c_str(), statusCtorSignature.c_str(), static_cast(dataResponse.status), status); jobject data; - data = env->NewStringUTF(std::string(dataResponse.data.data(), dataResponse.data.size()).c_str()); + jbyteArray dataByteArray = env->NewByteArray(static_cast(dataResponse.data.size())); + env->SetByteArrayRegion(dataByteArray, 0, static_cast(dataResponse.data.size()), + reinterpret_cast(dataResponse.data.data())); + data = dataByteArray; env->CallVoidMethod(javaCallbackRef, javaMethod, status, data); } diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index 41858b24ea9e33..f570c78e5fbc4f 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -918,41 +918,41 @@ public ApplicationLauncherCluster(long devicePtr, int endpointId) { public void hideAppRequest( LauncherResponseCallback callback, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application) { + ChipStructs.ApplicationLauncherClusterApplication application) { hideAppRequest(chipClusterPtr, callback, application, null); } public void hideAppRequest( LauncherResponseCallback callback, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application, + ChipStructs.ApplicationLauncherClusterApplication application, int timedInvokeTimeoutMs) { hideAppRequest(chipClusterPtr, callback, application, timedInvokeTimeoutMs); } public void launchAppRequest( LauncherResponseCallback callback, - String data, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application) { - launchAppRequest(chipClusterPtr, callback, data, application, null); + ChipStructs.ApplicationLauncherClusterApplication application, + byte[] data) { + launchAppRequest(chipClusterPtr, callback, application, data, null); } public void launchAppRequest( LauncherResponseCallback callback, - String data, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application, + ChipStructs.ApplicationLauncherClusterApplication application, + byte[] data, int timedInvokeTimeoutMs) { - launchAppRequest(chipClusterPtr, callback, data, application, timedInvokeTimeoutMs); + launchAppRequest(chipClusterPtr, callback, application, data, timedInvokeTimeoutMs); } public void stopAppRequest( LauncherResponseCallback callback, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application) { + ChipStructs.ApplicationLauncherClusterApplication application) { stopAppRequest(chipClusterPtr, callback, application, null); } public void stopAppRequest( LauncherResponseCallback callback, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application, + ChipStructs.ApplicationLauncherClusterApplication application, int timedInvokeTimeoutMs) { stopAppRequest(chipClusterPtr, callback, application, timedInvokeTimeoutMs); } @@ -960,24 +960,24 @@ public void stopAppRequest( private native void hideAppRequest( long chipClusterPtr, LauncherResponseCallback Callback, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application, + ChipStructs.ApplicationLauncherClusterApplication application, @Nullable Integer timedInvokeTimeoutMs); private native void launchAppRequest( long chipClusterPtr, LauncherResponseCallback Callback, - String data, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application, + ChipStructs.ApplicationLauncherClusterApplication application, + byte[] data, @Nullable Integer timedInvokeTimeoutMs); private native void stopAppRequest( long chipClusterPtr, LauncherResponseCallback Callback, - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application, + ChipStructs.ApplicationLauncherClusterApplication application, @Nullable Integer timedInvokeTimeoutMs); public interface LauncherResponseCallback { - void onSuccess(Integer status, String data); + void onSuccess(Integer status, byte[] data); void onError(Exception error); } diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java index 6806d59ebb9054..35a06a2be545ff 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipStructs.java @@ -147,12 +147,11 @@ public String toString() { } } - public static class ApplicationLauncherClusterApplicationLauncherApplication { + public static class ApplicationLauncherClusterApplication { public Integer catalogVendorId; public String applicationId; - public ApplicationLauncherClusterApplicationLauncherApplication( - Integer catalogVendorId, String applicationId) { + public ApplicationLauncherClusterApplication(Integer catalogVendorId, String applicationId) { this.catalogVendorId = catalogVendorId; this.applicationId = applicationId; } @@ -160,7 +159,7 @@ public ApplicationLauncherClusterApplicationLauncherApplication( @Override public String toString() { StringBuilder output = new StringBuilder(); - output.append("ApplicationLauncherClusterApplicationLauncherApplication {\n"); + output.append("ApplicationLauncherClusterApplication {\n"); output.append("\tcatalogVendorId: "); output.append(catalogVendorId); output.append("\n"); @@ -173,12 +172,11 @@ public String toString() { } public static class ApplicationLauncherClusterApplicationEP { - public ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application; + public ChipStructs.ApplicationLauncherClusterApplication application; public String endpoint; public ApplicationLauncherClusterApplicationEP( - ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication application, - String endpoint) { + ChipStructs.ApplicationLauncherClusterApplication application, String endpoint) { this.application = application; this.endpoint = endpoint; } diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java index ab1bca303604bf..ebedd116e7705d 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java @@ -625,11 +625,11 @@ public void setCallbackDelegate(ClusterCommandCallback callback) { } @Override - public void onSuccess(Integer status, String data) { + public void onSuccess(Integer status, byte[] data) { Map responseValues = new LinkedHashMap<>(); CommandResponseInfo statusResponseValue = new CommandResponseInfo("status", "Integer"); responseValues.put(statusResponseValue, status); - CommandResponseInfo dataResponseValue = new CommandResponseInfo("data", "String"); + CommandResponseInfo dataResponseValue = new CommandResponseInfo("data", "byte[]"); responseValues.put(dataResponseValue, data); callback.onSuccess(responseValues); } @@ -7609,7 +7609,7 @@ public Map> getCommandMap() { ((ChipClusters.ApplicationLauncherCluster) cluster) .hideAppRequest( (ChipClusters.ApplicationLauncherCluster.LauncherResponseCallback) callback, - (ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication) + (ChipStructs.ApplicationLauncherClusterApplication) commandArguments.get("application")); }, () -> new DelegatedLauncherResponseCallback(), @@ -7619,7 +7619,7 @@ public Map> getCommandMap() { Map applicationLauncherlaunchAppRequestCommandParams = new LinkedHashMap(); CommandParameterInfo applicationLauncherlaunchAppRequestdataCommandParameterInfo = - new CommandParameterInfo("data", String.class); + new CommandParameterInfo("data", byte[].class); applicationLauncherlaunchAppRequestCommandParams.put( "data", applicationLauncherlaunchAppRequestdataCommandParameterInfo); @@ -7629,9 +7629,9 @@ public Map> getCommandMap() { ((ChipClusters.ApplicationLauncherCluster) cluster) .launchAppRequest( (ChipClusters.ApplicationLauncherCluster.LauncherResponseCallback) callback, - (String) commandArguments.get("data"), - (ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication) - commandArguments.get("application")); + (ChipStructs.ApplicationLauncherClusterApplication) + commandArguments.get("application"), + (byte[]) commandArguments.get("data")); }, () -> new DelegatedLauncherResponseCallback(), applicationLauncherlaunchAppRequestCommandParams); @@ -7645,7 +7645,7 @@ public Map> getCommandMap() { ((ChipClusters.ApplicationLauncherCluster) cluster) .stopAppRequest( (ChipClusters.ApplicationLauncherCluster.LauncherResponseCallback) callback, - (ChipStructs.ApplicationLauncherClusterApplicationLauncherApplication) + (ChipStructs.ApplicationLauncherClusterApplication) commandArguments.get("application")); }, () -> new DelegatedLauncherResponseCallback(), diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index c2a620f3171f09..2d2245a7e21b2a 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -300,9 +300,9 @@ class ChipClusters: "commandId": 0x00000000, "commandName": "LaunchAppRequest", "args": { - "data": "str", "catalogVendorId": "int", "applicationId": "str", + "data": "bytes", }, }, 0x00000001: { diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index e7d550111e9be4..0926f5cf06560c 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -31596,8 +31596,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: class Enums: class StatusEnum(IntEnum): kSuccess = 0x00 - kAppNotAvailable = 0x01 - kSystemBusy = 0x02 + kTargetNotFound = 0x01 + kNotAllowed = 0x02 class Structs: @@ -33336,7 +33336,7 @@ class StatusEnum(IntEnum): class Structs: @dataclass - class ApplicationLauncherApplication(ClusterObject): + class Application(ClusterObject): @ChipUtility.classproperty def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( @@ -33354,11 +33354,11 @@ class ApplicationEP(ClusterObject): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ - ClusterObjectFieldDescriptor(Label="application", Tag=0, Type=ApplicationLauncher.Structs.ApplicationLauncherApplication), + ClusterObjectFieldDescriptor(Label="application", Tag=0, Type=ApplicationLauncher.Structs.Application), ClusterObjectFieldDescriptor(Label="endpoint", Tag=1, Type=str), ]) - application: 'ApplicationLauncher.Structs.ApplicationLauncherApplication' = field(default_factory=lambda: ApplicationLauncher.Structs.ApplicationLauncherApplication()) + application: 'ApplicationLauncher.Structs.Application' = field(default_factory=lambda: ApplicationLauncher.Structs.Application()) endpoint: 'str' = "" @@ -33374,12 +33374,12 @@ class LaunchAppRequest(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ - ClusterObjectFieldDescriptor(Label="data", Tag=0, Type=str), - ClusterObjectFieldDescriptor(Label="application", Tag=1, Type=ApplicationLauncher.Structs.ApplicationLauncherApplication), + ClusterObjectFieldDescriptor(Label="application", Tag=0, Type=ApplicationLauncher.Structs.Application), + ClusterObjectFieldDescriptor(Label="data", Tag=1, Type=bytes), ]) - data: 'str' = "" - application: 'ApplicationLauncher.Structs.ApplicationLauncherApplication' = field(default_factory=lambda: ApplicationLauncher.Structs.ApplicationLauncherApplication()) + application: 'ApplicationLauncher.Structs.Application' = field(default_factory=lambda: ApplicationLauncher.Structs.Application()) + data: 'bytes' = b"" @dataclass class StopAppRequest(ClusterCommand): @@ -33391,10 +33391,10 @@ class StopAppRequest(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ - ClusterObjectFieldDescriptor(Label="application", Tag=0, Type=ApplicationLauncher.Structs.ApplicationLauncherApplication), + ClusterObjectFieldDescriptor(Label="application", Tag=0, Type=ApplicationLauncher.Structs.Application), ]) - application: 'ApplicationLauncher.Structs.ApplicationLauncherApplication' = field(default_factory=lambda: ApplicationLauncher.Structs.ApplicationLauncherApplication()) + application: 'ApplicationLauncher.Structs.Application' = field(default_factory=lambda: ApplicationLauncher.Structs.Application()) @dataclass class HideAppRequest(ClusterCommand): @@ -33406,10 +33406,10 @@ class HideAppRequest(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ - ClusterObjectFieldDescriptor(Label="application", Tag=0, Type=ApplicationLauncher.Structs.ApplicationLauncherApplication), + ClusterObjectFieldDescriptor(Label="application", Tag=0, Type=ApplicationLauncher.Structs.Application), ]) - application: 'ApplicationLauncher.Structs.ApplicationLauncherApplication' = field(default_factory=lambda: ApplicationLauncher.Structs.ApplicationLauncherApplication()) + application: 'ApplicationLauncher.Structs.Application' = field(default_factory=lambda: ApplicationLauncher.Structs.Application()) @dataclass class LauncherResponse(ClusterCommand): @@ -33422,11 +33422,11 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ ClusterObjectFieldDescriptor(Label="status", Tag=0, Type=ApplicationLauncher.Enums.StatusEnum), - ClusterObjectFieldDescriptor(Label="data", Tag=1, Type=str), + ClusterObjectFieldDescriptor(Label="data", Tag=1, Type=bytes), ]) status: 'ApplicationLauncher.Enums.StatusEnum' = 0 - data: 'str' = "" + data: 'bytes' = b"" class Attributes: diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm index 7ad6dcb82117b1..1080ea741e6bdb 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm @@ -9727,7 +9727,7 @@ response.status = [NSNumber numberWithUnsignedChar:chip::to_underlying(data.status)]; } { - response.data = [[NSString alloc] initWithBytes:data.data.data() length:data.data.size() encoding:NSUTF8StringEncoding]; + response.data = [NSData dataWithBytes:data.data.data() length:data.data.size()]; } DispatchSuccess(context, response); }; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm index b9b1302ec08a7b..585a220b8ee1fa 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm @@ -1215,9 +1215,9 @@ - (void)launchAppRequestWithParams:(CHIPApplicationLauncherClusterLaunchAppReque { ListFreer listFreer; ApplicationLauncher::Commands::LaunchAppRequest::Type request; - request.data = [self asCharSpan:params.data]; request.application.catalogVendorId = params.application.catalogVendorId.unsignedShortValue; request.application.applicationId = [self asCharSpan:params.application.applicationId]; + request.data = [self asByteSpan:params.data]; new CHIPApplicationLauncherClusterLauncherResponseCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h index 6dcb060f86bc46..f2e5f778596ee5 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h @@ -1642,24 +1642,24 @@ NS_ASSUME_NONNULL_BEGIN @end @interface CHIPApplicationLauncherClusterLaunchAppRequestParams : NSObject -@property (strong, nonatomic) NSString * _Nonnull data; -@property (strong, nonatomic) CHIPApplicationLauncherClusterApplicationLauncherApplication * _Nonnull application; +@property (strong, nonatomic) CHIPApplicationLauncherClusterApplication * _Nonnull application; +@property (strong, nonatomic) NSData * _Nonnull data; - (instancetype)init; @end @interface CHIPApplicationLauncherClusterStopAppRequestParams : NSObject -@property (strong, nonatomic) CHIPApplicationLauncherClusterApplicationLauncherApplication * _Nonnull application; +@property (strong, nonatomic) CHIPApplicationLauncherClusterApplication * _Nonnull application; - (instancetype)init; @end @interface CHIPApplicationLauncherClusterHideAppRequestParams : NSObject -@property (strong, nonatomic) CHIPApplicationLauncherClusterApplicationLauncherApplication * _Nonnull application; +@property (strong, nonatomic) CHIPApplicationLauncherClusterApplication * _Nonnull application; - (instancetype)init; @end @interface CHIPApplicationLauncherClusterLauncherResponseParams : NSObject @property (strong, nonatomic) NSNumber * _Nonnull status; -@property (strong, nonatomic) NSString * _Nonnull data; +@property (strong, nonatomic) NSData * _Nonnull data; - (instancetype)init; @end diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm index e9da6aa7d0b800..4193d8b38eae62 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm @@ -3495,9 +3495,9 @@ - (instancetype)init { if (self = [super init]) { - _data = @""; + _application = [CHIPApplicationLauncherClusterApplication new]; - _application = [CHIPApplicationLauncherClusterApplicationLauncherApplication new]; + _data = [NSData data]; } return self; } @@ -3508,7 +3508,7 @@ - (instancetype)init { if (self = [super init]) { - _application = [CHIPApplicationLauncherClusterApplicationLauncherApplication new]; + _application = [CHIPApplicationLauncherClusterApplication new]; } return self; } @@ -3519,7 +3519,7 @@ - (instancetype)init { if (self = [super init]) { - _application = [CHIPApplicationLauncherClusterApplicationLauncherApplication new]; + _application = [CHIPApplicationLauncherClusterApplication new]; } return self; } @@ -3532,7 +3532,7 @@ - (instancetype)init _status = @(0); - _data = @""; + _data = [NSData data]; } return self; } diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h index 1c8b52bcfb7f3d..f5937dbce2cd52 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h @@ -406,14 +406,14 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init; @end -@interface CHIPApplicationLauncherClusterApplicationLauncherApplication : NSObject +@interface CHIPApplicationLauncherClusterApplication : NSObject @property (strong, nonatomic) NSNumber * _Nonnull catalogVendorId; @property (strong, nonatomic) NSString * _Nonnull applicationId; - (instancetype)init; @end @interface CHIPApplicationLauncherClusterApplicationEP : NSObject -@property (strong, nonatomic) CHIPApplicationLauncherClusterApplicationLauncherApplication * _Nonnull application; +@property (strong, nonatomic) CHIPApplicationLauncherClusterApplication * _Nonnull application; @property (strong, nonatomic) NSString * _Nonnull endpoint; - (instancetype)init; @end diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm index 907798ea50b9bd..f92b0921b81b5f 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm @@ -833,7 +833,7 @@ - (instancetype)init } @end -@implementation CHIPApplicationLauncherClusterApplicationLauncherApplication +@implementation CHIPApplicationLauncherClusterApplication - (instancetype)init { if (self = [super init]) { @@ -851,7 +851,7 @@ - (instancetype)init { if (self = [super init]) { - _application = [CHIPApplicationLauncherClusterApplicationLauncherApplication new]; + _application = [CHIPApplicationLauncherClusterApplication new]; _endpoint = @""; } diff --git a/zzz_generated/app-common/app-common/zap-generated/af-structs.h b/zzz_generated/app-common/app-common/zap-generated/af-structs.h index 296b69215fbb9c..bc17553e49e70a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/af-structs.h +++ b/zzz_generated/app-common/app-common/zap-generated/af-structs.h @@ -132,17 +132,17 @@ typedef struct _BrandingInformation StyleInformation waterMark; } BrandingInformation; -// Struct for ApplicationLauncherApplication -typedef struct _ApplicationLauncherApplication +// Struct for Application +typedef struct _Application { uint16_t catalogVendorId; chip::CharSpan applicationId; -} ApplicationLauncherApplication; +} Application; // Struct for ApplicationEP typedef struct _ApplicationEP { - ApplicationLauncherApplication application; + Application application; chip::CharSpan endpoint; } ApplicationEP; diff --git a/zzz_generated/app-common/app-common/zap-generated/callback.h b/zzz_generated/app-common/app-common/zap-generated/callback.h index b8333bdada471d..00c6799c9b5ab7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -14986,7 +14986,7 @@ bool emberAfApplicationLauncherClusterHideAppRequestCallback( * @brief Application Launcher Cluster LauncherResponse Command callback (from server) */ bool emberAfApplicationLauncherClusterLauncherResponseCallback(chip::EndpointId endpoint, chip::app::CommandSender * commandObj, - uint8_t status, chip::CharSpan data); + uint8_t status, chip::ByteSpan data); /** * @brief Account Login Cluster GetSetupPINRequest Command callback (from client) */ diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 25ee36863d9640..196f8dbc7d2374 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -21984,7 +21984,7 @@ namespace Events { } // namespace AudioOutput namespace ApplicationLauncher { namespace Structs { -namespace ApplicationLauncherApplication { +namespace Application { CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { TLV::TLVType outer; @@ -22024,7 +22024,7 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } -} // namespace ApplicationLauncherApplication +} // namespace Application namespace ApplicationEP { CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { @@ -22074,8 +22074,8 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kData)), data)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kApplication)), application)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kData)), data)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } @@ -22091,12 +22091,12 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); switch (TLV::TagNumFromTag(reader.GetTag())) { - case to_underlying(Fields::kData): - ReturnErrorOnFailure(DataModel::Decode(reader, data)); - break; case to_underlying(Fields::kApplication): ReturnErrorOnFailure(DataModel::Decode(reader, application)); break; + case to_underlying(Fields::kData): + ReturnErrorOnFailure(DataModel::Decode(reader, data)); + break; default: break; } diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 870765eba04bb0..a936ed900b8457 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -33732,9 +33732,9 @@ namespace TargetNavigator { // Enum for StatusEnum enum class StatusEnum : uint8_t { - kSuccess = 0x00, - kAppNotAvailable = 0x01, - kSystemBusy = 0x02, + kSuccess = 0x00, + kTargetNotFound = 0x01, + kNotAllowed = 0x02, }; namespace Structs { @@ -36007,7 +36007,7 @@ enum class ChannelFeature : uint32_t }; namespace Structs { -namespace ApplicationLauncherApplication { +namespace Application { enum class Fields { kCatalogVendorId = 0, @@ -36028,7 +36028,7 @@ struct Type using DecodableType = Type; -} // namespace ApplicationLauncherApplication +} // namespace Application namespace ApplicationEP { enum class Fields { @@ -36039,7 +36039,7 @@ enum class Fields struct Type { public: - Structs::ApplicationLauncherApplication::Type application; + Structs::Application::Type application; chip::CharSpan endpoint; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; @@ -36082,8 +36082,8 @@ namespace Commands { namespace LaunchAppRequest { enum class Fields { - kData = 0, - kApplication = 1, + kApplication = 0, + kData = 1, }; struct Type @@ -36093,8 +36093,8 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::LaunchAppRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ApplicationLauncher::Id; } - chip::CharSpan data; - Structs::ApplicationLauncherApplication::Type application; + Structs::Application::Type application; + chip::ByteSpan data; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; @@ -36109,8 +36109,8 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::LaunchAppRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ApplicationLauncher::Id; } - chip::CharSpan data; - Structs::ApplicationLauncherApplication::DecodableType application; + Structs::Application::DecodableType application; + chip::ByteSpan data; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace LaunchAppRequest @@ -36127,7 +36127,7 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::StopAppRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ApplicationLauncher::Id; } - Structs::ApplicationLauncherApplication::Type application; + Structs::Application::Type application; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; @@ -36142,7 +36142,7 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::StopAppRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ApplicationLauncher::Id; } - Structs::ApplicationLauncherApplication::DecodableType application; + Structs::Application::DecodableType application; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace StopAppRequest @@ -36159,7 +36159,7 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::HideAppRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ApplicationLauncher::Id; } - Structs::ApplicationLauncherApplication::Type application; + Structs::Application::Type application; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; @@ -36174,7 +36174,7 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::HideAppRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::ApplicationLauncher::Id; } - Structs::ApplicationLauncherApplication::DecodableType application; + Structs::Application::DecodableType application; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace HideAppRequest @@ -36193,7 +36193,7 @@ struct Type static constexpr ClusterId GetClusterId() { return Clusters::ApplicationLauncher::Id; } StatusEnum status = static_cast(0); - chip::CharSpan data; + chip::ByteSpan data; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; @@ -36209,7 +36209,7 @@ struct DecodableType static constexpr ClusterId GetClusterId() { return Clusters::ApplicationLauncher::Id; } StatusEnum status = static_cast(0); - chip::CharSpan data; + chip::ByteSpan data; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace LauncherResponse diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 9145962667aedb..a0893812f038d6 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -431,8 +431,7 @@ class ApplicationLauncherHideAppRequest : public ClusterCommand private: chip::app::Clusters::ApplicationLauncher::Commands::HideAppRequest::Type mRequest; - TypedComplexArgument - mComplex_Application; + TypedComplexArgument mComplex_Application; }; /* @@ -444,8 +443,8 @@ class ApplicationLauncherLaunchAppRequest : public ClusterCommand ApplicationLauncherLaunchAppRequest(CredentialIssuerCommands * credsIssuerConfig) : ClusterCommand("launch-app-request", credsIssuerConfig), mComplex_Application(&mRequest.application) { - AddArgument("Data", &mRequest.data); AddArgument("Application", &mComplex_Application); + AddArgument("Data", &mRequest.data); ClusterCommand::AddArguments(); } @@ -458,8 +457,7 @@ class ApplicationLauncherLaunchAppRequest : public ClusterCommand private: chip::app::Clusters::ApplicationLauncher::Commands::LaunchAppRequest::Type mRequest; - TypedComplexArgument - mComplex_Application; + TypedComplexArgument mComplex_Application; }; /* @@ -484,8 +482,7 @@ class ApplicationLauncherStopAppRequest : public ClusterCommand private: chip::app::Clusters::ApplicationLauncher::Commands::StopAppRequest::Type mRequest; - TypedComplexArgument - mComplex_Application; + TypedComplexArgument mComplex_Application; }; /*----------------------------------------------------------------------------*\ diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 56555680f45b41..da678af2c50459 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -127,6 +127,31 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Struc ComplexArgumentParser::Finalize(request.name); ComplexArgumentParser::Finalize(request.value); } +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ApplicationLauncher::Structs::Application::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("Application.catalogVendorId", value.isMember("catalogVendorId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Application.applicationId", value.isMember("applicationId"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "catalogVendorId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.catalogVendorId, value["catalogVendorId"])); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "applicationId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.applicationId, value["applicationId"])); + + return CHIP_NO_ERROR; +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::ApplicationLauncher::Structs::Application::Type & request) +{ + ComplexArgumentParser::Finalize(request.catalogVendorId); + ComplexArgumentParser::Finalize(request.applicationId); +} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::ApplicationBasic::Structs::ApplicationBasicApplication::Type & request, Json::Value & value) @@ -177,34 +202,6 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::ApplicationLauncher::S ComplexArgumentParser::Finalize(request.application); ComplexArgumentParser::Finalize(request.endpoint); } -CHIP_ERROR -ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationLauncherApplication.catalogVendorId", - value.isMember("catalogVendorId"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ApplicationLauncherApplication.applicationId", value.isMember("applicationId"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "catalogVendorId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.catalogVendorId, value["catalogVendorId"])); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "applicationId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.applicationId, value["applicationId"])); - - return CHIP_NO_ERROR; -} - -void ComplexArgumentParser::Finalize( - chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::Type & request) -{ - ComplexArgumentParser::Finalize(request.catalogVendorId); - ComplexArgumentParser::Finalize(request.applicationId); -} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, Json::Value & value) diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 6ba52de3b247d4..cc593f2433f75b 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -29,6 +29,10 @@ static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher Json::Value & value); static void Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfo::Type & request); +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ApplicationLauncher::Structs::Application::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::ApplicationLauncher::Structs::Application::Type & request); static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ApplicationBasic::Structs::ApplicationBasicApplication::Type & request, Json::Value & value); @@ -38,11 +42,6 @@ static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ApplicationLaun Json::Value & value); static void Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::Type & request, - Json::Value & value); - -static void Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::Type & request); static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, Json::Value & value); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index ae623759585441..6de350f58ba458 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -149,9 +149,8 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ApplicationBasic::Structs::ApplicationBasicApplication::DecodableType & value) +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ApplicationLauncher::Structs::Application::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { @@ -174,23 +173,24 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::DecodableType & value) +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ApplicationBasic::Structs::ApplicationBasicApplication::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Application", indent + 1, value.application); + CHIP_ERROR err = LogValue("CatalogVendorId", indent + 1, value.catalogVendorId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Application'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CatalogVendorId'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("ApplicationId", indent + 1, value.applicationId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ApplicationId'"); return err; } } @@ -198,24 +198,23 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue( - const char * label, size_t indent, - const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::DecodableType & value) +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CatalogVendorId", indent + 1, value.catalogVendorId); + CHIP_ERROR err = LogValue("Application", indent + 1, value.application); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CatalogVendorId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Application'"); return err; } } { - CHIP_ERROR err = LogValue("ApplicationId", indent + 1, value.applicationId); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ApplicationId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); return err; } } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index e044d993be6bc4..3431a1f14e0d37 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -23,14 +23,13 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::BridgedActions::Structs::ActionStruct::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfo::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::ApplicationLauncher::Structs::Application::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ApplicationBasic::Structs::ApplicationBasicApplication::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEP::DecodableType & value); -static CHIP_ERROR -LogValue(const char * label, size_t indent, - const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationLauncherApplication::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 2ce3bd59367f0a..3dce5ddec4cd69 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -44879,11 +44879,12 @@ class TV_ApplicationLauncherCluster : public TestCommand using RequestType = chip::app::Clusters::ApplicationLauncher::Commands::LaunchAppRequest::Type; RequestType request; - request.data = chip::Span("datagarbage: not in length on purpose", 4); request.application.catalogVendorId = 123U; request.application.applicationId = chip::Span("applicationIdgarbage: not in length on purpose", 13); + request.data = chip::ByteSpan(chip::Uint8::from_const_char("datagarbage: not in length on purpose"), 4); + auto success = [](void * context, const typename RequestType::ResponseType & data) { (static_cast(context))->OnSuccessResponse_2(data.status, data.data); }; @@ -44902,11 +44903,11 @@ class TV_ApplicationLauncherCluster : public TestCommand ThrowFailureResponse(); } - void OnSuccessResponse_2(chip::app::Clusters::ApplicationLauncher::StatusEnum status, chip::CharSpan data) + void OnSuccessResponse_2(chip::app::Clusters::ApplicationLauncher::StatusEnum status, chip::ByteSpan data) { VerifyOrReturn(CheckValue("status", status, 0)); - VerifyOrReturn(CheckValueAsString("data", data, chip::CharSpan("data", 4))); + VerifyOrReturn(CheckValueAsString("data", data, chip::ByteSpan(chip::Uint8::from_const_char("data"), 4))); NextTest(); } @@ -44939,11 +44940,11 @@ class TV_ApplicationLauncherCluster : public TestCommand ThrowFailureResponse(); } - void OnSuccessResponse_3(chip::app::Clusters::ApplicationLauncher::StatusEnum status, chip::CharSpan data) + void OnSuccessResponse_3(chip::app::Clusters::ApplicationLauncher::StatusEnum status, chip::ByteSpan data) { VerifyOrReturn(CheckValue("status", status, 0)); - VerifyOrReturn(CheckValueAsString("data", data, chip::CharSpan("data", 4))); + VerifyOrReturn(CheckValueAsString("data", data, chip::ByteSpan(chip::Uint8::from_const_char("data"), 4))); NextTest(); } @@ -44976,11 +44977,11 @@ class TV_ApplicationLauncherCluster : public TestCommand ThrowFailureResponse(); } - void OnSuccessResponse_4(chip::app::Clusters::ApplicationLauncher::StatusEnum status, chip::CharSpan data) + void OnSuccessResponse_4(chip::app::Clusters::ApplicationLauncher::StatusEnum status, chip::ByteSpan data) { VerifyOrReturn(CheckValue("status", status, 0)); - VerifyOrReturn(CheckValueAsString("data", data, chip::CharSpan("data", 4))); + VerifyOrReturn(CheckValueAsString("data", data, chip::ByteSpan(chip::Uint8::from_const_char("data"), 4))); NextTest(); } From 56be65c839fc3167d1c1255aaa53119d1fee394e Mon Sep 17 00:00:00 2001 From: fesseha-eve <88329315+fessehaeve@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:39:12 +0100 Subject: [PATCH 04/12] Put temporary fix for function pointer casting error in arm gcc (#14830) * Put temporary fix for function pointer casting error in arm gcc * Restyle and add comment to prevent future unintended change --- src/app/util/attribute-storage.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 7e2b07f0b81e14..1b8180dc9f64c5 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -371,11 +371,14 @@ EmberAfStatus emAfClusterPreAttributeChangedCallback(const app::ConcreteAttribut } else { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - EmberAfGenericClusterFunction f = emberAfFindClusterFunction(cluster, CLUSTER_MASK_PRE_ATTRIBUTE_CHANGED_FUNCTION); + EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + // Casting and calling a function pointer on the same line results in ignoring the return + // of the call on gcc-arm-none-eabi-9-2019-q4-major + EmberAfClusterPreAttributeChangedCallback f = (EmberAfClusterPreAttributeChangedCallback)( + emberAfFindClusterFunction(cluster, CLUSTER_MASK_PRE_ATTRIBUTE_CHANGED_FUNCTION)); if (f != NULL) { - status = ((EmberAfClusterPreAttributeChangedCallback) f)(attributePath, attributeType, size, value); + status = f(attributePath, attributeType, size, value); } return status; } From c7f7244b49e6b5cfa7dc265383d2d230c711e75c Mon Sep 17 00:00:00 2001 From: Michael Rupp <95718139+mykrupp@users.noreply.github.com> Date: Mon, 7 Feb 2022 12:33:17 -0500 Subject: [PATCH 05/12] Fix github issue #14321 - Thread end device (Requestor) crashes if it cannot reach the Provider (#14712) * Fix github issue #14321 * Updates from PR suggestions * Restyled by whitespace * Restyled by clang-format * Add verify or die calls to Discovery_ImplPlatform.cpp Co-authored-by: Restyled.io --- src/lib/dnssd/Discovery_ImplPlatform.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index 4e2174b974223d..3584e8f47a5178 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -83,22 +83,31 @@ static void HandleNodeIdResolve(void * context, DnssdService * result, CHIP_ERRO { proxy->OnNodeIdResolutionFailed(PeerId(), error); proxy->Release(); + return; } + VerifyOrDie(proxy != nullptr); + if (result == nullptr) { proxy->OnNodeIdResolutionFailed(PeerId(), CHIP_ERROR_UNKNOWN_RESOURCE_ID); proxy->Release(); + return; } + VerifyOrDie(proxy != nullptr); + PeerId peerId; error = ExtractIdFromInstanceName(result->mName, &peerId); if (CHIP_NO_ERROR != error) { proxy->OnNodeIdResolutionFailed(PeerId(), error); proxy->Release(); + return; } + VerifyOrDie(proxy != nullptr); + ResolvedNodeData nodeData; Platform::CopyString(nodeData.mHostName, result->mHostName); nodeData.mInterfaceId = result->mInterface; From c69b6f1b4f6c9574df719b9f984c69dcfe50c82c Mon Sep 17 00:00:00 2001 From: Evgeny Margolis Date: Mon, 7 Feb 2022 09:34:01 -0800 Subject: [PATCH 06/12] SPAKE2P Iteration Count Parameter Is 32-Bits (#14807) --- .../commands/pairing/OpenCommissioningWindowCommand.h | 6 +++--- .../chiptool/clusterclient/MultiAdminClientFragment.kt | 4 ++-- src/controller/CHIPDeviceController.cpp | 2 +- src/controller/CHIPDeviceController.h | 8 ++++---- src/controller/java/CHIPDeviceController-JNI.cpp | 7 ++++--- .../chip/devicecontroller/ChipDeviceController.java | 10 +++++----- .../python/ChipDeviceController-ScriptBinding.cpp | 6 +++--- src/controller/python/chip/ChipDeviceCtrl.py | 4 ++-- 8 files changed, 24 insertions(+), 23 deletions(-) diff --git a/examples/chip-tool/commands/pairing/OpenCommissioningWindowCommand.h b/examples/chip-tool/commands/pairing/OpenCommissioningWindowCommand.h index cec775fc9fae8a..2e8283a383e69d 100644 --- a/examples/chip-tool/commands/pairing/OpenCommissioningWindowCommand.h +++ b/examples/chip-tool/commands/pairing/OpenCommissioningWindowCommand.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2021-2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +31,7 @@ class OpenCommissioningWindowCommand : public CHIPCommand AddArgument("node-id", 0, UINT64_MAX, &mNodeId); AddArgument("option", 0, UINT8_MAX, &mCommissioningWindowOption); AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("iteration", 0, UINT16_MAX, &mIteration); + AddArgument("iteration", chip::kPBKDFMinimumIterations, chip::kPBKDFMaximumIterations, &mIteration); AddArgument("discriminator", 0, 4096, &mDiscriminator); } @@ -43,7 +43,7 @@ class OpenCommissioningWindowCommand : public CHIPCommand NodeId mNodeId; uint8_t mCommissioningWindowOption; uint16_t mTimeout; - uint16_t mIteration; + uint32_t mIteration; uint16_t mDiscriminator; CHIP_ERROR OpenCommissioningWindow(); diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt index eae531e6ed0e95..240553514740ff 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt @@ -89,11 +89,11 @@ class MultiAdminClientFragment : Fragment() { private suspend fun sendEnhancedCommissioningCommandClick() { val testDuration = 100 - val testIteration = 800 + val testIteration = 1000 val devicePointer = ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) deviceController.openPairingWindowWithPIN( - devicePointer, testDuration, testIteration, + devicePointer, testDuration, testIteration.toLong(), discriminatorEd.text.toString().toInt(), setupPinCodeEd.text.toString().toULong().toLong() ) } diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index f942ff83d3326d..f74d4cb8ef5d82 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -442,7 +442,7 @@ CHIP_ERROR DeviceController::ComputePASEVerifier(uint32_t iterations, uint32_t s return CHIP_NO_ERROR; } -CHIP_ERROR DeviceController::OpenCommissioningWindowWithCallback(NodeId deviceId, uint16_t timeout, uint16_t iteration, +CHIP_ERROR DeviceController::OpenCommissioningWindowWithCallback(NodeId deviceId, uint16_t timeout, uint32_t iteration, uint16_t discriminator, uint8_t option, chip::Callback::Callback * callback, bool readVIDPIDAttributes) diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 4bb2b850213dda..81170a48df4376 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2020-2022 Project CHIP Authors * Copyright (c) 2013-2017 Nest Labs, Inc. * All rights reserved. * @@ -270,7 +270,7 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate * * @return CHIP_ERROR CHIP_NO_ERROR on success, or corresponding error */ - CHIP_ERROR OpenCommissioningWindow(NodeId deviceId, uint16_t timeout, uint16_t iteration, uint16_t discriminator, + CHIP_ERROR OpenCommissioningWindow(NodeId deviceId, uint16_t timeout, uint32_t iteration, uint16_t discriminator, uint8_t option, SetupPayload & payload) { mSuggestedSetUpPINCode = payload.setUpPINCode; @@ -301,7 +301,7 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate * * @return CHIP_ERROR CHIP_NO_ERROR on success, or corresponding error */ - CHIP_ERROR OpenCommissioningWindowWithCallback(NodeId deviceId, uint16_t timeout, uint16_t iteration, uint16_t discriminator, + CHIP_ERROR OpenCommissioningWindowWithCallback(NodeId deviceId, uint16_t timeout, uint32_t iteration, uint16_t discriminator, uint8_t option, Callback::Callback * callback, bool readVIDPIDAttributes = false); @@ -405,7 +405,7 @@ class DLL_EXPORT DeviceController : public SessionRecoveryDelegate uint32_t mSuggestedSetUpPINCode = 0; uint16_t mCommissioningWindowTimeout; - uint16_t mCommissioningWindowIteration; + uint32_t mCommissioningWindowIteration; CommissioningWindowOption mCommissioningWindowOption; diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index afed84ae697536..73849bd74ce3d4 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -544,7 +544,7 @@ JNI_METHOD(jboolean, openPairingWindow)(JNIEnv * env, jobject self, jlong handle } JNI_METHOD(jboolean, openPairingWindowWithPIN) -(JNIEnv * env, jobject self, jlong handle, jlong devicePtr, jint duration, jint iteration, jint discriminator, jlong setupPinCode) +(JNIEnv * env, jobject self, jlong handle, jlong devicePtr, jint duration, jlong iteration, jint discriminator, jlong setupPinCode) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; @@ -560,7 +560,8 @@ JNI_METHOD(jboolean, openPairingWindowWithPIN) } AndroidDeviceControllerWrapper * wrapper = AndroidDeviceControllerWrapper::FromJNIHandle(handle); - err = wrapper->Controller()->OpenCommissioningWindow(chipDevice->GetDeviceId(), duration, 1000, discriminator, 1, setupPayload); + err = wrapper->Controller()->OpenCommissioningWindow(chipDevice->GetDeviceId(), duration, iteration, discriminator, 1, + setupPayload); if (err != CHIP_NO_ERROR) { @@ -585,7 +586,7 @@ JNI_METHOD(void, deleteDeviceController)(JNIEnv * env, jobject self, jlong handl } JNI_METHOD(jobject, computePaseVerifier) -(JNIEnv * env, jobject self, jlong handle, jlong devicePtr, jlong setupPincode, jint iterations, jbyteArray salt) +(JNIEnv * env, jobject self, jlong handle, jlong devicePtr, jlong setupPincode, jlong iterations, jbyteArray salt) { chip::DeviceLayer::StackLock lock; diff --git a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java index 843ee12ac12bd8..1e47838e2df2e7 100644 --- a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java +++ b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2020-2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -286,7 +286,7 @@ public boolean openPairingWindow(long devicePtr, int duration) { } public boolean openPairingWindowWithPIN( - long devicePtr, int duration, int iteration, int discriminator, long setupPinCode) { + long devicePtr, int duration, long iteration, int discriminator, long setupPinCode) { return openPairingWindowWithPIN( deviceControllerPtr, devicePtr, duration, iteration, discriminator, setupPinCode); } @@ -334,12 +334,12 @@ public void readPath(ReportCallback callback, long devicePtr, ChipAttributePath * @param salt the 16-byte salt */ public PaseVerifierParams computePaseVerifier( - long devicePtr, long setupPincode, int iterations, byte[] salt) { + long devicePtr, long setupPincode, long iterations, byte[] salt) { return computePaseVerifier(deviceControllerPtr, devicePtr, setupPincode, iterations, salt); } private native PaseVerifierParams computePaseVerifier( - long deviceControllerPtr, long devicePtr, long setupPincode, int iterations, byte[] salt); + long deviceControllerPtr, long devicePtr, long setupPincode, long iterations, byte[] salt); private native void subscribeToPath( long deviceControllerPtr, @@ -411,7 +411,7 @@ private native boolean openPairingWindowWithPIN( long deviceControllerPtr, long devicePtr, int duration, - int iteration, + long iteration, int discriminator, long setupPinCode); diff --git a/src/controller/python/ChipDeviceController-ScriptBinding.cpp b/src/controller/python/ChipDeviceController-ScriptBinding.cpp index 812eed32109079..72d579b1fdb72e 100644 --- a/src/controller/python/ChipDeviceController-ScriptBinding.cpp +++ b/src/controller/python/ChipDeviceController-ScriptBinding.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2020-2022 Project CHIP Authors * Copyright (c) 2019-2020 Google LLC. * Copyright (c) 2013-2018 Nest Labs, Inc. * All rights reserved. @@ -145,7 +145,7 @@ pychip_DeviceController_DiscoverCommissionableNodesCommissioningEnabled(chip::Co ChipError::StorageType pychip_DeviceController_PostTaskOnChipThread(ChipThreadTaskRunnerFunct callback, void * pythonContext); ChipError::StorageType pychip_DeviceController_OpenCommissioningWindow(chip::Controller::DeviceCommissioner * devCtrl, - chip::NodeId nodeid, uint16_t timeout, uint16_t iteration, + chip::NodeId nodeid, uint16_t timeout, uint32_t iteration, uint16_t discriminator, uint8_t option); void pychip_DeviceController_PrintDiscoveredDevices(chip::Controller::DeviceCommissioner * devCtrl); @@ -434,7 +434,7 @@ pychip_DeviceController_DiscoverCommissionableNodesCommissioningEnabled(chip::Co } ChipError::StorageType pychip_DeviceController_OpenCommissioningWindow(chip::Controller::DeviceCommissioner * devCtrl, - chip::NodeId nodeid, uint16_t timeout, uint16_t iteration, + chip::NodeId nodeid, uint16_t timeout, uint32_t iteration, uint16_t discriminator, uint8_t option) { SetupPayload payload; diff --git a/src/controller/python/chip/ChipDeviceCtrl.py b/src/controller/python/chip/ChipDeviceCtrl.py index 8361a28dd3aa5c..517debac1c01b4 100644 --- a/src/controller/python/chip/ChipDeviceCtrl.py +++ b/src/controller/python/chip/ChipDeviceCtrl.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2020-2021 Project CHIP Authors +# Copyright (c) 2020-2022 Project CHIP Authors # Copyright (c) 2019-2020 Google, LLC. # Copyright (c) 2013-2018 Nest Labs, Inc. # All rights reserved. @@ -921,7 +921,7 @@ def _InitLib(self): self._dmLib.pychip_DeviceController_GetCompressedFabricId.restype = c_uint32 self._dmLib.pychip_DeviceController_OpenCommissioningWindow.argtypes = [ - c_void_p, c_uint64, c_uint16, c_uint16, c_uint16, c_uint8] + c_void_p, c_uint64, c_uint16, c_uint32, c_uint16, c_uint8] self._dmLib.pychip_DeviceController_OpenCommissioningWindow.restype = c_uint32 self._dmLib.pychip_TestCommissionerUsed.argtypes = [] self._dmLib.pychip_TestCommissionerUsed.restype = c_bool From a92d1a816344792892d1f9f2fff89dad6e607739 Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Mon, 7 Feb 2022 12:50:17 -0500 Subject: [PATCH 07/12] Implement a Generic Network commissioning Thread Driver (#14713) * Create a generic Network commissioning Thread Driver * Add OnThreadAttachFinished to send Connect network response * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Fix linux build do not build GenericNetworkCommissioningThreadDriver for linux * Fix a few sample app builds * fix shell app for all * cleaner fix for shell * Remove OtScanResponseIterator, Scan handling not yet implement. Need rework to not use vector * address PR comments Co-authored-by: Restyled.io --- .../efr32/build_for_wifi_gnfile.gn | 2 +- examples/lighting-app/telink/CMakeLists.txt | 1 + .../lock-app/efr32/build_for_wifi_gnfile.gn | 2 +- examples/persistent-storage/qpg/args.gni | 1 + examples/shell/efr32/BUILD.gn | 1 - examples/shell/efr32/args.gni | 1 + .../shell/efr32/include/CHIPProjectConfig.h | 2 + examples/shell/mbed/CMakeLists.txt | 1 + .../mbed/main/include/CHIPProjectConfig.h | 4 + examples/shell/nrfconnect/CHIPProjectConfig.h | 4 + examples/shell/nxp/k32w/k32w0/BUILD.gn | 6 +- .../window-app/efr32/build_for_wifi_gnfile.gn | 2 +- src/include/platform/ThreadStackManager.h | 27 ++- .../GenericConnectivityManagerImpl_Thread.cpp | 5 + src/platform/BUILD.gn | 8 + src/platform/EFR32/BUILD.gn | 4 +- src/platform/EFR32/CHIPDevicePlatformConfig.h | 5 +- src/platform/EFR32/ThreadStackManagerImpl.cpp | 1 - src/platform/Linux/ThreadStackManagerImpl.cpp | 10 +- src/platform/Linux/ThreadStackManagerImpl.h | 14 +- ...enericNetworkCommissioningThreadDriver.cpp | 194 ++++++++++++++++++ .../GenericNetworkCommissioningThreadDriver.h | 72 +++++++ ...nericThreadStackManagerImpl_OpenThread.cpp | 75 +++++++ ...GenericThreadStackManagerImpl_OpenThread.h | 10 +- src/test_driver/efr32/BUILD.gn | 3 + 25 files changed, 434 insertions(+), 21 deletions(-) create mode 100644 src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.cpp create mode 100644 src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.h diff --git a/examples/light-switch-app/efr32/build_for_wifi_gnfile.gn b/examples/light-switch-app/efr32/build_for_wifi_gnfile.gn index 9752ee73e7c91d..d391814190d09f 100644 --- a/examples/light-switch-app/efr32/build_for_wifi_gnfile.gn +++ b/examples/light-switch-app/efr32/build_for_wifi_gnfile.gn @@ -23,6 +23,6 @@ check_system_includes = true default_args = { target_cpu = "arm" target_os = "freertos" - use_thread = false + chip_enable_wifi = true import("//build_for_wifi_args.gni") } diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index b5fff10891f123..94e98c8be5290f 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -94,6 +94,7 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/clusters/level-control/level-control.cpp ${CHIP_ROOT}/src/app/clusters/color-control-server/color-control-server.cpp ${CHIP_ROOT}/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp + ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp ${CHIP_ROOT}/src/app/clusters/network-commissioning-old/network-commissioning-ember.cpp ${CHIP_ROOT}/src/app/clusters/network-commissioning-old/network-commissioning-old.cpp ${CHIP_ROOT}/src/app/clusters/ota-requestor/ota-requestor-server.cpp diff --git a/examples/lock-app/efr32/build_for_wifi_gnfile.gn b/examples/lock-app/efr32/build_for_wifi_gnfile.gn index 9752ee73e7c91d..d391814190d09f 100644 --- a/examples/lock-app/efr32/build_for_wifi_gnfile.gn +++ b/examples/lock-app/efr32/build_for_wifi_gnfile.gn @@ -23,6 +23,6 @@ check_system_includes = true default_args = { target_cpu = "arm" target_os = "freertos" - use_thread = false + chip_enable_wifi = true import("//build_for_wifi_args.gni") } diff --git a/examples/persistent-storage/qpg/args.gni b/examples/persistent-storage/qpg/args.gni index b0d121b1029802..4918e5af9de27b 100644 --- a/examples/persistent-storage/qpg/args.gni +++ b/examples/persistent-storage/qpg/args.gni @@ -16,3 +16,4 @@ import("//build_overrides/chip.gni") import("${chip_root}/examples/platform/qpg/args.gni") qpg_sdk_target = get_label_info(":sdk", "label_no_toolchain") +chip_enable_openthread = false diff --git a/examples/shell/efr32/BUILD.gn b/examples/shell/efr32/BUILD.gn index 64e73d4cfbb981..ea683bed9362cf 100644 --- a/examples/shell/efr32/BUILD.gn +++ b/examples/shell/efr32/BUILD.gn @@ -49,7 +49,6 @@ efr32_sdk("sdk") { defines = [ "BOARD_ID=${efr32_board}", "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_CONSOLE", - "ENABLE_CHIP_SHELL", ] } diff --git a/examples/shell/efr32/args.gni b/examples/shell/efr32/args.gni index 1b73ad66dcea58..9d49561c413334 100644 --- a/examples/shell/efr32/args.gni +++ b/examples/shell/efr32/args.gni @@ -22,3 +22,4 @@ pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" pw_assert_BACKEND = "$dir_pw_assert_log" chip_enable_openthread = true chip_openthread_ftd = true +chip_build_libshell = true diff --git a/examples/shell/efr32/include/CHIPProjectConfig.h b/examples/shell/efr32/include/CHIPProjectConfig.h index e5be53a055f434..b47c348e6df34c 100644 --- a/examples/shell/efr32/include/CHIPProjectConfig.h +++ b/examples/shell/efr32/include/CHIPProjectConfig.h @@ -113,3 +113,5 @@ * A size, in bytes, of the individual debug event logging buffer. */ #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) + +#define _NO_NETWORK_COMMISSIONING_DRIVER_ diff --git a/examples/shell/mbed/CMakeLists.txt b/examples/shell/mbed/CMakeLists.txt index 18397ba9b8d689..fbd5b2576ecf9b 100644 --- a/examples/shell/mbed/CMakeLists.txt +++ b/examples/shell/mbed/CMakeLists.txt @@ -21,6 +21,7 @@ include(${MBED_PATH}/tools/cmake/app.cmake) project(${APP_TARGET}) + add_subdirectory(${MBED_PATH} ./mbed_build) add_subdirectory(${MBED_OS_POSIX_SOCKET_PATH} ./mbed_os_posix_socket_build) diff --git a/examples/shell/mbed/main/include/CHIPProjectConfig.h b/examples/shell/mbed/main/include/CHIPProjectConfig.h index ab3dbbecc38342..44bf03fc40b208 100644 --- a/examples/shell/mbed/main/include/CHIPProjectConfig.h +++ b/examples/shell/mbed/main/include/CHIPProjectConfig.h @@ -33,3 +33,7 @@ // Use a default pairing code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// shell app uses openthread but does not have the NETWORK_COMMISSIONING cluster or zap config +// Do not instantiate the NETWORK_COMMISSIONING thread driver +#define _NO_NETWORK_COMMISSIONING_DRIVER_ diff --git a/examples/shell/nrfconnect/CHIPProjectConfig.h b/examples/shell/nrfconnect/CHIPProjectConfig.h index cc90aa590dfd57..4b35fcd6a8cf58 100644 --- a/examples/shell/nrfconnect/CHIPProjectConfig.h +++ b/examples/shell/nrfconnect/CHIPProjectConfig.h @@ -42,3 +42,7 @@ * 0x4E53: nrfconnect shell */ #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x4E53 + +// shell app uses openthread but does not have the NETWORK_COMMISSIONING cluster or zap config +// Do not instantiate the NETWORK_COMMISSIONING thread driver +#define _NO_NETWORK_COMMISSIONING_DRIVER_ diff --git a/examples/shell/nxp/k32w/k32w0/BUILD.gn b/examples/shell/nxp/k32w/k32w0/BUILD.gn index dbb85ebe56be38..505373a42bf860 100644 --- a/examples/shell/nxp/k32w/k32w0/BUILD.gn +++ b/examples/shell/nxp/k32w/k32w0/BUILD.gn @@ -44,7 +44,11 @@ k32w0_sdk("sdk") { "${k32w0_platform_dir}/util/include", ] - defines = [] + defines = [ + # shell app uses openthread but does not have the NETWORK_COMMISSIONING cluster or zap config. + "_NO_NETWORK_COMMISSIONING_DRIVER_", + ] + if (is_debug) { defines += [ "BUILD_RELEASE=0" ] } else { diff --git a/examples/window-app/efr32/build_for_wifi_gnfile.gn b/examples/window-app/efr32/build_for_wifi_gnfile.gn index 9752ee73e7c91d..d391814190d09f 100644 --- a/examples/window-app/efr32/build_for_wifi_gnfile.gn +++ b/examples/window-app/efr32/build_for_wifi_gnfile.gn @@ -23,6 +23,6 @@ check_system_includes = true default_args = { target_cpu = "arm" target_os = "freertos" - use_thread = false + chip_enable_wifi = true import("//build_for_wifi_args.gni") } diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index f9db5e3df3c6e7..e4c0e4696ab3c0 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -27,6 +27,7 @@ #include #include #include +#include namespace chip { @@ -88,6 +89,9 @@ class ThreadStackManager bool TryLockThreadStack(); void UnlockThreadStack(); bool HaveRouteToAddress(const chip::Inet::IPAddress & destAddr); + bool IsThreadEnabled(); + bool IsThreadProvisioned(); + bool IsThreadAttached(); CHIP_ERROR GetThreadProvision(ByteSpan & netInfo); CHIP_ERROR GetAndLogThreadStatsCounters(); CHIP_ERROR GetAndLogThreadTopologyMinimal(); @@ -99,6 +103,9 @@ class ThreadStackManager CHIP_ERROR JoinerStart(); CHIP_ERROR SetThreadProvision(ByteSpan aDataset); CHIP_ERROR SetThreadEnabled(bool val); + CHIP_ERROR AttachToThreadNetwork(ByteSpan netInfo, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback); + CHIP_ERROR StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); + void OnThreadAttachFinished(void); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT CHIP_ERROR AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort, @@ -145,9 +152,6 @@ class ThreadStackManager friend class Internal::GenericThreadStackManagerImpl_FreeRTOS; void OnPlatformEvent(const ChipDeviceEvent * event); - bool IsThreadEnabled(); - bool IsThreadProvisioned(); - bool IsThreadAttached(); void ErasePersistentInfo(); ConnectivityManager::ThreadDeviceType GetThreadDeviceType(); CHIP_ERROR SetThreadDeviceType(ConnectivityManager::ThreadDeviceType threadRole); @@ -347,6 +351,23 @@ inline CHIP_ERROR ThreadStackManager::SetThreadProvision(ByteSpan netInfo) return static_cast(this)->_SetThreadProvision(netInfo); } +inline CHIP_ERROR +ThreadStackManager::AttachToThreadNetwork(ByteSpan netInfo, + NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) +{ + return static_cast(this)->_AttachToThreadNetwork(netInfo, callback); +} + +inline void ThreadStackManager::OnThreadAttachFinished(void) +{ + static_cast(this)->_OnThreadAttachFinished(); +} + +inline CHIP_ERROR ThreadStackManager::StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback) +{ + return static_cast(this)->_StartThreadScan(callback); +} + inline void ThreadStackManager::ErasePersistentInfo() { static_cast(this)->_ErasePersistentInfo(); diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp index b02aed72f903a3..1eb0f3f89242bb 100644 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp @@ -44,6 +44,11 @@ void GenericConnectivityManagerImpl_Thread::_OnPlatformEvent(const Ch (event->Type == DeviceEventType::kThreadStateChange && event->ThreadStateChange.NetDataChanged); const bool fabricMembershipChanged = (event->Type == DeviceEventType::kFabricMembershipChange); + if (threadConnChanged && event->ThreadConnectivityChange.Result == kConnectivity_Established) + { + ThreadStackMgrImpl().OnThreadAttachFinished(); + } + // If any of the above events has occurred, assess whether there's been a change in // service connectivity via Thread. if (threadConnChanged || threadAddrChanged || threadNetDataChanged || fabricMembershipChanged) diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 5709d0544f4b78..730c5df69932ff 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -301,6 +301,14 @@ if (chip_device_platform != "none") { "PlatformEventSupport.cpp", ] + # Linux has its own NetworkCommissioningThreadDriver + if (chip_enable_openthread && chip_device_platform != "linux") { + sources += [ + "OpenThread/GenericNetworkCommissioningThreadDriver.cpp", + "OpenThread/GenericNetworkCommissioningThreadDriver.h", + ] + } + if (chip_enable_ota_requestor) { sources += [ "GenericOTARequestorDriver.cpp", diff --git a/src/platform/EFR32/BUILD.gn b/src/platform/EFR32/BUILD.gn index 00469606e03597..172b94bdb82dce 100644 --- a/src/platform/EFR32/BUILD.gn +++ b/src/platform/EFR32/BUILD.gn @@ -95,7 +95,9 @@ static_library("EFR32") { sources += [ "../OpenThread/DnssdImpl.cpp" ] deps += [ "${chip_root}/src/lib/dnssd:platform_header" ] } - } else { + } + + if (chip_enable_wifi) { sources += [ "ConnectivityManagerImpl_WIFI.cpp", "ServiceProvisioning.cpp", diff --git a/src/platform/EFR32/CHIPDevicePlatformConfig.h b/src/platform/EFR32/CHIPDevicePlatformConfig.h index 74521d1da33f60..f6e5b9619ab079 100644 --- a/src/platform/EFR32/CHIPDevicePlatformConfig.h +++ b/src/platform/EFR32/CHIPDevicePlatformConfig.h @@ -29,12 +29,13 @@ #define CHIP_DEVICE_CONFIG_EFR32_NVM3_ERROR_MIN 0xB00000 #define CHIP_DEVICE_CONFIG_EFR32_BLE_ERROR_MIN 0xC00000 +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 + #if defined(SL_WIFI) #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 1 #elif CHIP_ENABLE_OPENTHREAD -#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 -#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT 1 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT 1 diff --git a/src/platform/EFR32/ThreadStackManagerImpl.cpp b/src/platform/EFR32/ThreadStackManagerImpl.cpp index da08ecfa0f930b..fbd89807260177 100644 --- a/src/platform/EFR32/ThreadStackManagerImpl.cpp +++ b/src/platform/EFR32/ThreadStackManagerImpl.cpp @@ -28,7 +28,6 @@ #include #include - #include #include diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index d50aed7be164c4..29114d00c7051a 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -289,7 +289,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadEnabled(bool val) VerifyOrReturnError(mProxy, CHIP_ERROR_INCORRECT_STATE); if (val) { - openthread_io_openthread_border_router_call_attach(mProxy.get(), nullptr, _OnThreadAttachFinished, this); + openthread_io_openthread_border_router_call_attach(mProxy.get(), nullptr, _OnThreadBrAttachFinished, this); } else { @@ -311,7 +311,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadEnabled(bool val) return CHIP_NO_ERROR; } -void ThreadStackManagerImpl::_OnThreadAttachFinished(GObject * source_object, GAsyncResult * res, gpointer user_data) +void ThreadStackManagerImpl::_OnThreadBrAttachFinished(GObject * source_object, GAsyncResult * res, gpointer user_data) { ThreadStackManagerImpl * this_ = reinterpret_cast(user_data); std::unique_ptr attachRes; @@ -507,7 +507,7 @@ CHIP_ERROR ThreadStackManagerImpl::_JoinerStart() return CHIP_ERROR_NOT_IMPLEMENTED; } -CHIP_ERROR ThreadStackManagerImpl::StartThreadScan(ThreadDriver::ScanCallback * callback) +CHIP_ERROR ThreadStackManagerImpl::_StartThreadScan(ThreadDriver::ScanCallback * callback) { // There is another ongoing scan request, reject the new one. VerifyOrReturnError(mpScanCallback == nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -637,8 +637,8 @@ CHIP_ERROR ThreadStackManagerImpl::_WriteThreadNetworkDiagnosticAttributeToTlv(A } CHIP_ERROR -ThreadStackManagerImpl::AttachToThreadNetwork(ByteSpan netInfo, - NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) +ThreadStackManagerImpl::_AttachToThreadNetwork(ByteSpan netInfo, + NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) { // There is another ongoing connect request, reject the new one. VerifyOrReturnError(mpConnectCallback == nullptr, CHIP_ERROR_INCORRECT_STATE); diff --git a/src/platform/Linux/ThreadStackManagerImpl.h b/src/platform/Linux/ThreadStackManagerImpl.h index caac53708b9922..e725bb5d72f64d 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.h +++ b/src/platform/Linux/ThreadStackManagerImpl.h @@ -65,10 +65,13 @@ class ThreadStackManagerImpl : public ThreadStackManager bool _IsThreadAttached(); - CHIP_ERROR AttachToThreadNetwork(ByteSpan netInfo, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback); + CHIP_ERROR _AttachToThreadNetwork(ByteSpan netInfo, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback); CHIP_ERROR _SetThreadEnabled(bool val); - static void _OnThreadAttachFinished(GObject * source_object, GAsyncResult * res, gpointer user_data); + + void _OnThreadAttachFinished(void); + + static void _OnThreadBrAttachFinished(GObject * source_object, GAsyncResult * res, gpointer user_data); ConnectivityManager::ThreadDeviceType _GetThreadDeviceType(); @@ -100,7 +103,7 @@ class ThreadStackManagerImpl : public ThreadStackManager CHIP_ERROR _WriteThreadNetworkDiagnosticAttributeToTlv(AttributeId attributeId, app::AttributeValueEncoder & encoder); - CHIP_ERROR StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); + CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); ~ThreadStackManagerImpl() = default; @@ -145,5 +148,10 @@ class ThreadStackManagerImpl : public ThreadStackManager bool mAttached; }; +inline void ThreadStackManagerImpl::_OnThreadAttachFinished(void) +{ + // stub for ThreadStackManager.h +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.cpp b/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.cpp new file mode 100644 index 00000000000000..ccb3a408e7ecc3 --- /dev/null +++ b/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.cpp @@ -0,0 +1,194 @@ +/* + * + * 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 +#include +#include +#include +#include +#include +#include + +#include + +using namespace chip; +using namespace chip::Thread; + +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { +// NOTE: For ThreadDriver, we use two network configs, one is mSavedNetwork, and another is mStagingNetwork, during init, it will +// load the network config from thread persistent info, and loads it into both mSavedNetwork and mStagingNetwork. When updating the +// networks, all changes are made on the staging network. When validated we can commit it and save it to the persistent info + +CHIP_ERROR GenericThreadDriver::Init() +{ + ByteSpan currentProvision; + VerifyOrReturnError(ThreadStackMgrImpl().IsThreadAttached(), CHIP_NO_ERROR); + VerifyOrReturnError(ThreadStackMgrImpl().GetThreadProvision(currentProvision) == CHIP_NO_ERROR, CHIP_NO_ERROR); + + mSavedNetwork.Init(currentProvision); + mStagingNetwork.Init(currentProvision); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR GenericThreadDriver::CommitConfiguration() +{ + // Note: on AttachToThreadNetwork OpenThread will persist the networks on its own, + // we don't have much to do for saving the networks (see Init() above, + // we just load the saved dataset from ot instance.) + mSavedNetwork = mStagingNetwork; + return CHIP_NO_ERROR; +} + +CHIP_ERROR GenericThreadDriver::RevertConfiguration() +{ + mStagingNetwork = mSavedNetwork; + return CHIP_NO_ERROR; +} + +Status GenericThreadDriver::AddOrUpdateNetwork(ByteSpan operationalDataset) +{ + uint8_t extpanid[kSizeExtendedPanId]; + uint8_t newExtpanid[kSizeExtendedPanId]; + Thread::OperationalDataset newDataset; + + newDataset.Init(operationalDataset); + VerifyOrReturnError(newDataset.IsCommissioned(), Status::kOutOfRange); + + newDataset.GetExtendedPanId(newExtpanid); + mStagingNetwork.GetExtendedPanId(extpanid); + + // We only support one active operational dataset. Add/Update based on either: + // Staging network not commissioned yet (active) or we are updating the dataset with same Extended Pan ID. + VerifyOrReturnError(!mStagingNetwork.IsCommissioned() || memcmp(extpanid, newExtpanid, kSizeExtendedPanId) == 0, + Status::kBoundsExceeded); + + mStagingNetwork = newDataset; + return Status::kSuccess; +} + +Status GenericThreadDriver::RemoveNetwork(ByteSpan networkId) +{ + uint8_t extpanid[kSizeExtendedPanId]; + if (!mStagingNetwork.IsCommissioned()) + { + return Status::kNetworkNotFound; + } + else if (mStagingNetwork.GetExtendedPanId(extpanid) != CHIP_NO_ERROR) + { + return Status::kUnknownError; + } + + VerifyOrReturnError(networkId.size() == kSizeExtendedPanId && memcmp(networkId.data(), extpanid, kSizeExtendedPanId) == 0, + Status::kNetworkNotFound); + mStagingNetwork.Clear(); + return Status::kSuccess; +} + +Status GenericThreadDriver::ReorderNetwork(ByteSpan networkId, uint8_t index) +{ + uint8_t extpanid[kSizeExtendedPanId]; + if (!mStagingNetwork.IsCommissioned()) + { + return Status::kNetworkNotFound; + } + else if (mStagingNetwork.GetExtendedPanId(extpanid) != CHIP_NO_ERROR) + { + return Status::kUnknownError; + } + + VerifyOrReturnError(networkId.size() == kSizeExtendedPanId && memcmp(networkId.data(), extpanid, kSizeExtendedPanId) == 0, + Status::kNetworkNotFound); + + return Status::kSuccess; +} + +void GenericThreadDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) +{ + NetworkCommissioning::Status status = Status::kSuccess; + uint8_t extpanid[kSizeExtendedPanId]; + if (!mStagingNetwork.IsCommissioned()) + { + ExitNow(status = Status::kNetworkNotFound); + } + else if (mStagingNetwork.GetExtendedPanId(extpanid) != CHIP_NO_ERROR) + { + ExitNow(status = Status::kUnknownError); + } + + VerifyOrExit((networkId.size() == kSizeExtendedPanId && memcmp(networkId.data(), extpanid, kSizeExtendedPanId) == 0), + status = Status::kNetworkNotFound); + + VerifyOrExit(DeviceLayer::ThreadStackMgrImpl().AttachToThreadNetwork(mStagingNetwork.AsByteSpan(), callback) == CHIP_NO_ERROR, + status = Status::kUnknownError); + +exit: + if (status != Status::kSuccess) + { + callback->OnResult(status, CharSpan(), 0); + } +} + +void GenericThreadDriver::ScanNetworks(ThreadDriver::ScanCallback * callback) +{ + CHIP_ERROR err = DeviceLayer::ThreadStackMgrImpl().StartThreadScan(callback); + if (err != CHIP_NO_ERROR) + { + callback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); + } +} + +size_t GenericThreadDriver::ThreadNetworkIterator::Count() +{ + return driver->mStagingNetwork.IsCommissioned() ? 1 : 0; +} + +bool GenericThreadDriver::ThreadNetworkIterator::Next(Network & item) +{ + if (exhausted || !driver->mStagingNetwork.IsCommissioned()) + { + return false; + } + uint8_t extpanid[kSizeExtendedPanId]; + VerifyOrReturnError(driver->mStagingNetwork.GetExtendedPanId(extpanid) == CHIP_NO_ERROR, false); + memcpy(item.networkID, extpanid, kSizeExtendedPanId); + item.networkIDLen = kSizeExtendedPanId; + item.connected = false; + exhausted = true; + + ByteSpan currentProvision; + Thread::OperationalDataset currentDataset; + uint8_t enabledExtPanId[Thread::kSizeExtendedPanId]; + + // The Thread network is not actually enabled. + VerifyOrReturnError(ConnectivityMgrImpl().IsThreadAttached(), true); + VerifyOrReturnError(ThreadStackMgrImpl().GetThreadProvision(currentProvision) == CHIP_NO_ERROR, true); + VerifyOrReturnError(currentDataset.Init(currentProvision) == CHIP_NO_ERROR, true); + // The Thread network is not enabled, but has a different extended pan id. + VerifyOrReturnError(currentDataset.GetExtendedPanId(enabledExtPanId) == CHIP_NO_ERROR, true); + VerifyOrReturnError(memcmp(extpanid, enabledExtPanId, kSizeExtendedPanId) == 0, true); + // The Thread network is enabled and has the same extended pan id as the one in our record. + item.connected = true; + + return true; +} + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.h b/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.h new file mode 100644 index 00000000000000..de70a3055af6f8 --- /dev/null +++ b/src/platform/OpenThread/GenericNetworkCommissioningThreadDriver.h @@ -0,0 +1,72 @@ +/* + * + * 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. + */ + +#pragma once + +#include + +namespace chip { +namespace DeviceLayer { +namespace NetworkCommissioning { + +class GenericThreadDriver final : public ThreadDriver +{ +public: + class ThreadNetworkIterator final : public NetworkIterator + { + public: + ThreadNetworkIterator(GenericThreadDriver * aDriver) : driver(aDriver) {} + size_t Count() override; + bool Next(Network & item) override; + void Release() override { delete this; } + ~ThreadNetworkIterator() = default; + + private: + GenericThreadDriver * driver; + bool exhausted = false; + }; + + // BaseDriver + NetworkIterator * GetNetworks() override { return new ThreadNetworkIterator(this); } + CHIP_ERROR Init() override; + CHIP_ERROR Shutdown() override { return CHIP_NO_ERROR; } // Nothing to do on EFR32 for shutdown. + + // WirelessDriver + uint8_t GetMaxNetworks() override { return 1; } + uint8_t GetScanNetworkTimeoutSeconds() override { return 10; } + uint8_t GetConnectNetworkTimeoutSeconds() override { return 20; } + + CHIP_ERROR CommitConfiguration() override; + CHIP_ERROR RevertConfiguration() override; + + Status RemoveNetwork(ByteSpan networkId) override; + Status ReorderNetwork(ByteSpan networkId, uint8_t index) override; + void ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) override; + + // ThreadDriver + Status AddOrUpdateNetwork(ByteSpan operationalDataset) override; + void ScanNetworks(ScanCallback * callback) override; + +private: + ThreadNetworkIterator mThreadIterator = ThreadNetworkIterator(this); + Thread::OperationalDataset mSavedNetwork; + Thread::OperationalDataset mStagingNetwork; +}; + +} // namespace NetworkCommissioning +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index b47e471f882473..7db260edea72bc 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -46,12 +46,14 @@ #endif #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -73,6 +75,7 @@ extern "C" void otAppCliInit(otInstance * aInstance); using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::DataModel; +using namespace chip::DeviceLayer::NetworkCommissioning; using chip::Inet::IPPrefix; @@ -80,6 +83,21 @@ namespace chip { namespace DeviceLayer { namespace Internal { +// Network commissioning +namespace { +#ifndef _NO_NETWORK_COMMISSIONING_DRIVER_ +NetworkCommissioning::GenericThreadDriver sGenericThreadDriver; +Clusters::NetworkCommissioning::Instance sThreadNetworkCommissioningInstance(0 /* Endpoint Id */, &sGenericThreadDriver); +#endif + +void initNetworkCommissioningThreadDriver(void) +{ +#ifndef _NO_NETWORK_COMMISSIONING_DRIVER_ + sThreadNetworkCommissioningInstance.Init(); +#endif +} + +} // namespace // Fully instantiate the generic implementation class in whatever compilation unit includes this file. template class GenericThreadStackManagerImpl_OpenThread; @@ -281,6 +299,26 @@ bool GenericThreadStackManagerImpl_OpenThread::_IsThreadProvisioned(v return provisioned; } +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_GetThreadProvision(ByteSpan & netInfo) +{ + VerifyOrReturnError(Impl()->IsThreadProvisioned(), CHIP_ERROR_INCORRECT_STATE); + otOperationalDatasetTlvs datasetTlv; + + Impl()->LockThreadStack(); + otError otErr = otDatasetGetActiveTlvs(mOTInst, &datasetTlv); + Impl()->UnlockThreadStack(); + if (otErr != OT_ERROR_NONE) + { + return MapOpenThreadError(otErr); + } + + ReturnErrorOnFailure(mActiveDataset.Init(ByteSpan(datasetTlv.mTlvs, datasetTlv.mLength))); + netInfo = mActiveDataset.AsByteSpan(); + + return CHIP_NO_ERROR; +} + template bool GenericThreadStackManagerImpl_OpenThread::_IsThreadAttached(void) { @@ -293,6 +331,41 @@ bool GenericThreadStackManagerImpl_OpenThread::_IsThreadAttached(void return (curRole != OT_DEVICE_ROLE_DISABLED && curRole != OT_DEVICE_ROLE_DETACHED); } +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AttachToThreadNetwork( + ByteSpan netInfo, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback) +{ + // There is another ongoing connect request, reject the new one. + VerifyOrReturnError(mpConnectCallback == nullptr, CHIP_ERROR_INCORRECT_STATE); + ReturnErrorOnFailure(Impl()->SetThreadEnabled(false)); + ReturnErrorOnFailure(Impl()->SetThreadProvision(netInfo)); + ReturnErrorOnFailure(Impl()->SetThreadEnabled(true)); + mpConnectCallback = callback; + return CHIP_NO_ERROR; +} + +template +void GenericThreadStackManagerImpl_OpenThread::_OnThreadAttachFinished() +{ + if (mpConnectCallback != nullptr) + { + DeviceLayer::SystemLayer().ScheduleLambda([this]() { + mpConnectCallback->OnResult(NetworkCommissioning::Status::kSuccess, CharSpan(), 0); + mpConnectCallback = nullptr; + }); + } +} + +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_StartThreadScan(ThreadDriver::ScanCallback * callback) +{ + // TODO END scan feature + _OnNetworkScanFinished callback for response + // There is another ongoing scan request, reject the new one. + VerifyOrReturnError(mpScanCallback == nullptr, CHIP_ERROR_INCORRECT_STATE); + mpScanCallback = callback; + return CHIP_NO_ERROR; +} + template ConnectivityManager::ThreadDeviceType GenericThreadStackManagerImpl_OpenThread::_GetThreadDeviceType(void) { @@ -1509,6 +1582,8 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::DoInit(otInstanc ChipLogProgress(DeviceLayer, "OpenThread ifconfig up and thread start"); } + initNetworkCommissioningThreadDriver(); + exit: ChipLogProgress(DeviceLayer, "OpenThread started: %s", otThreadErrorToString(otErr)); return err; diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index ca10b5d31cd3fe..d7c51fb8dbb6c9 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -39,6 +39,7 @@ #include #include #include +#include namespace chip { namespace DeviceLayer { @@ -82,9 +83,12 @@ class GenericThreadStackManagerImpl_OpenThread bool _IsThreadAttached(void); CHIP_ERROR _GetThreadProvision(ByteSpan & netInfo); CHIP_ERROR _SetThreadProvision(ByteSpan netInfo); + CHIP_ERROR _AttachToThreadNetwork(ByteSpan netInfo, NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * callback); + void _OnThreadAttachFinished(void); void _ErasePersistentInfo(void); ConnectivityManager::ThreadDeviceType _GetThreadDeviceType(void); CHIP_ERROR _SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType); + CHIP_ERROR _StartThreadScan(NetworkCommissioning::ThreadDriver::ScanCallback * callback); #if CHIP_DEVICE_CONFIG_ENABLE_SED CHIP_ERROR _GetSEDPollingConfig(ConnectivityManager::SEDPollingConfig & pollingConfig); @@ -136,7 +140,11 @@ class GenericThreadStackManagerImpl_OpenThread // ===== Private members for use by this class only. otInstance * mOTInst; - uint64_t mOverrunCount = 0; + uint64_t mOverrunCount = 0; + Thread::OperationalDataset mActiveDataset = {}; + + NetworkCommissioning::ThreadDriver::ScanCallback * mpScanCallback; + NetworkCommissioning::Internal::WirelessDriver::ConnectCallback * mpConnectCallback; #if CHIP_DEVICE_CONFIG_ENABLE_SED ConnectivityManager::SEDPollingConfig mPollingConfig; diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index ec5848855dcecd..67bbf521466712 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -57,6 +57,9 @@ efr32_sdk("sdk") { "BOARD_ID=${efr32_board}", "EFR32_LOG_ENABLED=1", "PW_RPC_ENABLED", + + # Thread is built but test driver do not have the NETWORK_COMMISSIONING cluster or zap config. + "_NO_NETWORK_COMMISSIONING_DRIVER_", ] } From c4a06e3381823115dc7ac554a2addca8af6ab994 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Mon, 7 Feb 2022 11:26:09 -0800 Subject: [PATCH 08/12] Align Ethernet Network Diagnostics cluster with the latest spec (#14818) * Align Ethernet Network Diagnostics cluster with the latest spec * Run codegen --- .../all-clusters-app.matter | 6 +- .../bridge-common/bridge-app.matter | 6 +- .../door-lock-common/door-lock-app.matter | 6 +- .../light-switch-app.matter | 6 +- .../lighting-common/lighting-app.matter | 6 +- examples/lock-app/lock-common/lock-app.matter | 6 +- .../pump-controller-app.matter | 6 +- .../esp32/main/temperature-measurement.matter | 6 +- .../thermostat-common/thermostat.matter | 6 +- examples/tv-app/tv-common/tv-app.matter | 6 +- .../tv-casting-common/tv-casting-app.matter | 6 +- examples/window-app/common/window-app.matter | 6 +- .../ethernet-network-diagnostics-server.cpp | 65 +++++- .../ethernet-network-diagnostics-cluster.xml | 6 +- .../data_model/controller-clusters.matter | 6 +- .../CHIPAttributeTLVValueDecoder.cpp | 45 ++-- .../java/zap-generated/CHIPClusters-JNI.cpp | 37 ++-- .../java/zap-generated/CHIPReadCallbacks.cpp | 201 ++++++++++++++++++ .../java/zap-generated/CHIPReadCallbacks.h | 92 ++++++++ .../chip/devicecontroller/ChipClusters.java | 54 +++-- .../devicecontroller/ClusterReadMapping.java | 13 +- .../python/chip/clusters/Objects.py | 24 +-- .../CHIPAttributeTLVValueDecoder.mm | 24 ++- .../CHIP/zap-generated/CHIPClustersObjc.mm | 61 +++--- .../CHIP/zap-generated/CHIPTestClustersObjc.h | 6 +- .../zap-generated/CHIPTestClustersObjc.mm | 27 ++- .../zap-generated/endpoint_config.h | 22 +- .../zap-generated/attributes/Accessors.cpp | 106 +++++++-- .../zap-generated/attributes/Accessors.h | 16 +- .../zap-generated/cluster-objects.h | 24 +-- .../zap-generated/endpoint_config.h | 22 +- .../cluster/logging/DataModelLogger.cpp | 6 +- .../zap-generated/endpoint_config.h | 22 +- .../zap-generated/endpoint_config.h | 22 +- .../zap-generated/endpoint_config.h | 22 +- .../lock-app/zap-generated/endpoint_config.h | 22 +- .../zap-generated/endpoint_config.h | 22 +- .../zap-generated/endpoint_config.h | 22 +- .../zap-generated/endpoint_config.h | 22 +- .../tv-app/zap-generated/endpoint_config.h | 22 +- .../zap-generated/endpoint_config.h | 22 +- .../zap-generated/endpoint_config.h | 22 +- 42 files changed, 839 insertions(+), 310 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index a51a1a38380504..68285788abe004 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -1318,14 +1318,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/bridge-app/bridge-common/bridge-app.matter b/examples/bridge-app/bridge-common/bridge-app.matter index c097c824910f5e..13a7f3d7804ad4 100644 --- a/examples/bridge-app/bridge-common/bridge-app.matter +++ b/examples/bridge-app/bridge-common/bridge-app.matter @@ -260,14 +260,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/door-lock-app/door-lock-common/door-lock-app.matter b/examples/door-lock-app/door-lock-common/door-lock-app.matter index 82cf27d5d76245..e994c385313be0 100644 --- a/examples/door-lock-app/door-lock-common/door-lock-app.matter +++ b/examples/door-lock-app/door-lock-common/door-lock-app.matter @@ -737,14 +737,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index 4d55543b099037..b46e9af6ca9b65 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -447,14 +447,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index 82aae8a7c09438..6e59dd7f6b3c2c 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -452,14 +452,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index d161f034fdb9f9..fdc976a4a65294 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -198,14 +198,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter index ea637490d1d035..65a2636078dcf5 100644 --- a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter +++ b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter @@ -198,14 +198,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter b/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter index 154ca83bea567c..785c64339fcfc6 100644 --- a/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter +++ b/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter @@ -198,14 +198,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index 2fe1a8271cb6b0..ab2b892dfd3ad8 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -219,14 +219,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index c15b12d97a5244..4f07fd6d020926 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -527,14 +527,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index 5bb9d36960f58c..b41a504fa3ea3a 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -1244,14 +1244,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index acdbe50dee1417..831a7526c5735c 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -168,14 +168,14 @@ server cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute bitmap32 featureMap = 65532; readonly global attribute int16u clusterRevision = 65533; diff --git a/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp b/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp index d22005ba58cbe6..d79a3129335050 100644 --- a/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp +++ b/src/app/clusters/ethernet-network-diagnostics-server/ethernet-network-diagnostics-server.cpp @@ -47,6 +47,10 @@ class EthernetDiagosticsAttrAccess : public AttributeAccessInterface private: template CHIP_ERROR ReadIfSupported(CHIP_ERROR (DiagnosticDataProvider::*getter)(T &), AttributeValueEncoder & aEncoder); + + CHIP_ERROR ReadPHYRate(AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadFullDuplex(AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadCarrierDetect(AttributeValueEncoder & aEncoder); }; template @@ -67,6 +71,61 @@ CHIP_ERROR EthernetDiagosticsAttrAccess::ReadIfSupported(CHIP_ERROR (DiagnosticD return aEncoder.Encode(data); } +CHIP_ERROR EthernetDiagosticsAttrAccess::ReadPHYRate(AttributeValueEncoder & aEncoder) +{ + Attributes::PHYRate::TypeInfo::Type pHYRate; + uint8_t value = 0; + + if (DeviceLayer::GetDiagnosticDataProvider().GetEthPHYRate(value) == CHIP_NO_ERROR) + { + pHYRate.SetNonNull(static_cast(value)); + ChipLogProgress(Zcl, "The current nominal, usable speed at the top of the physical layer of the Node: %d", value); + } + else + { + ChipLogProgress(Zcl, "The Ethernet interface is not currently configured or operational"); + } + + return aEncoder.Encode(pHYRate); +} + +CHIP_ERROR EthernetDiagosticsAttrAccess::ReadFullDuplex(AttributeValueEncoder & aEncoder) +{ + Attributes::FullDuplex::TypeInfo::Type fullDuplex; + bool value = 0; + + if (DeviceLayer::GetDiagnosticDataProvider().GetEthFullDuplex(value) == CHIP_NO_ERROR) + { + fullDuplex.SetNonNull(value); + ChipLogProgress(Zcl, "The full-duplex operating status of Node: %d", value); + } + else + { + ChipLogProgress(Zcl, "The Ethernet interface is not currently configured or operational"); + } + + return aEncoder.Encode(fullDuplex); +} + +CHIP_ERROR EthernetDiagosticsAttrAccess::ReadCarrierDetect(AttributeValueEncoder & aEncoder) +{ + Attributes::CarrierDetect::TypeInfo::Type carrierDetect; + bool value = 0; + + if (DeviceLayer::GetDiagnosticDataProvider().GetEthCarrierDetect(value) == CHIP_NO_ERROR) + { + carrierDetect.SetNonNull(value); + ChipLogProgress(Zcl, "The status of the Carrier Detect control signal present on the ethernet network interface: %d", + value); + } + else + { + ChipLogProgress(Zcl, "The Ethernet interface is not currently configured or operational"); + } + + return aEncoder.Encode(carrierDetect); +} + EthernetDiagosticsAttrAccess gAttrAccess; CHIP_ERROR EthernetDiagosticsAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) @@ -80,13 +139,13 @@ CHIP_ERROR EthernetDiagosticsAttrAccess::Read(const ConcreteReadAttributePath & switch (aPath.mAttributeId) { case PHYRate::Id: { - return ReadIfSupported(&DiagnosticDataProvider::GetEthPHYRate, aEncoder); + return ReadPHYRate(aEncoder); } case FullDuplex::Id: { - return ReadIfSupported(&DiagnosticDataProvider::GetEthFullDuplex, aEncoder); + return ReadFullDuplex(aEncoder); } case CarrierDetect::Id: { - return ReadIfSupported(&DiagnosticDataProvider::GetEthCarrierDetect, aEncoder); + return ReadCarrierDetect(aEncoder); } case TimeSinceReset::Id: { return ReadIfSupported(&DiagnosticDataProvider::GetEthTimeSinceReset, aEncoder); diff --git a/src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml index 5f1f0fe30dfade..ff74895c18fe29 100644 --- a/src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml @@ -35,14 +35,14 @@ limitations under the License. 0x0037 ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER The Ethernet Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. - PHYRate - FullDuplex + PHYRate + FullDuplex PacketRxCount PacketTxCount TxErrCount CollisionCount OverrunCount - CarrierDetect + CarrierDetect TimeSinceReset Reception of this command SHALL reset the attributes: PacketRxCount, PacketTxCount, TxErrCount, CollisionCount, OverrunCount to 0 diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index deda22970b2c33..aef5495dbe1b61 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -1619,14 +1619,14 @@ client cluster EthernetNetworkDiagnostics = 55 { k400g = 9; } - readonly attribute enum8 PHYRate = 0; - readonly attribute boolean fullDuplex = 1; + readonly attribute nullable PHYRateType PHYRate = 0; + readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; readonly attribute int64u txErrCount = 4; readonly attribute int64u collisionCount = 5; readonly attribute int64u overrunCount = 6; - readonly attribute boolean carrierDetect = 7; + readonly attribute nullable boolean carrierDetect = 7; readonly attribute int64u timeSinceReset = 8; readonly global attribute command_id serverGeneratedCommandList[] = 65528; readonly global attribute command_id clientGeneratedCommandList[] = 65529; diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 16c6954b0dddec..6c3329fe5028c0 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -4662,10 +4662,17 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - std::string valueClassName = "java/lang/Integer"; - std::string valueCtorSignature = "(I)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + static_cast(cppValue.Value()), value); + } return value; } case Attributes::FullDuplex::Id: { @@ -4677,10 +4684,17 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - std::string valueClassName = "java/lang/Boolean"; - std::string valueCtorSignature = "(Z)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), cppValue, - value); + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Boolean"; + std::string valueCtorSignature = "(Z)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue.Value(), value); + } return value; } case Attributes::PacketRxCount::Id: { @@ -4767,10 +4781,17 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - std::string valueClassName = "java/lang/Boolean"; - std::string valueCtorSignature = "(Z)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), cppValue, - value); + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Boolean"; + std::string valueCtorSignature = "(Z)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue.Value(), value); + } return value; } case Attributes::TimeSinceReset::Id: { diff --git a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp index 3accb6c018eecc..feb21490f5bad9 100644 --- a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp +++ b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp @@ -13065,8 +13065,10 @@ JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribePHYRateAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback, true), + chip::Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); @@ -13088,9 +13090,9 @@ JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribePHYRateAttribute) onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPInt8uAttributeCallback::OnSubscriptionEstablished); + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback::OnSubscriptionEstablished); VerifyOrReturn(err == CHIP_NO_ERROR, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error subscribing to attribute", err)); @@ -13102,8 +13104,10 @@ JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeFullDuplexAttribute (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback, true), + chip::Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); @@ -13125,9 +13129,9 @@ JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeFullDuplexAttribute onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback::OnSubscriptionEstablished); VerifyOrReturn(err == CHIP_NO_ERROR, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error subscribing to attribute", err)); @@ -13328,8 +13332,10 @@ JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeCarrierDetectAttrib (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback, true), + chip::Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); @@ -13352,9 +13358,10 @@ JNI_METHOD(void, EthernetNetworkDiagnosticsCluster, subscribeCarrierDetectAttrib onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback::OnSubscriptionEstablished); VerifyOrReturn(err == CHIP_NO_ERROR, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error subscribing to attribute", err)); diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp index 34ddf3fbb76759..22f8516e54f838 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -6434,6 +6434,207 @@ void CHIPElectricalMeasurementAttributeListAttributeCallback::CallbackFn( env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); } +CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback::CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback(jobject javaCallback, + bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback::~CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback::CallbackFn( + void * context, const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + std::string javaValueClassName = "java/lang/Integer"; + std::string javaValueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + static_cast(value.Value()), javaValue); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + +CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback::CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback( + jobject javaCallback, bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback::~CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + std::string javaValueClassName = "java/lang/Boolean"; + std::string javaValueCtorSignature = "(Z)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + value.Value(), javaValue); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + +CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback::CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback( + jobject javaCallback, bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback::~CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback::CallbackFn(void * context, + const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Boolean;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + if (value.IsNull()) + { + javaValue = nullptr; + } + else + { + std::string javaValueClassName = "java/lang/Boolean"; + std::string javaValueCtorSignature = "(Z)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + value.Value(), javaValue); + } + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + CHIPEthernetNetworkDiagnosticsServerGeneratedCommandListAttributeCallback:: CHIPEthernetNetworkDiagnosticsServerGeneratedCommandListAttributeCallback(jobject javaCallback, bool keepAlive) : chip::Callback::Callback(CallbackFn, diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.h b/src/controller/java/zap-generated/CHIPReadCallbacks.h index b64db9fec5fc1c..91f24b7ec5b8f7 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.h +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.h @@ -2715,6 +2715,98 @@ class CHIPElectricalMeasurementAttributeListAttributeCallback bool keepAlive; }; +class CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback + : public chip::Callback::Callback +{ +public: + CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback(jobject javaCallback, bool keepAlive = false); + + ~CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback(); + + static void maybeDestroy(CHIPEthernetNetworkDiagnosticsPHYRateAttributeCallback * callback) + { + if (!callback->keepAlive) + { + callback->Cancel(); + chip::Platform::Delete(callback); + } + } + + static void + CallbackFn(void * context, + const chip::app::DataModel::Nullable & value); + static void OnSubscriptionEstablished(void * context) + { + CHIP_ERROR err = chip::JniReferences::GetInstance().CallSubscriptionEstablished( + reinterpret_cast(context)->javaCallbackRef); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error calling onSubscriptionEstablished: %s", ErrorStr(err))); + }; + +private: + jobject javaCallbackRef; + bool keepAlive; +}; + +class CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback + : public chip::Callback::Callback +{ +public: + CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback(jobject javaCallback, bool keepAlive = false); + + ~CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback(); + + static void maybeDestroy(CHIPEthernetNetworkDiagnosticsFullDuplexAttributeCallback * callback) + { + if (!callback->keepAlive) + { + callback->Cancel(); + chip::Platform::Delete(callback); + } + } + + static void CallbackFn(void * context, const chip::app::DataModel::Nullable & value); + static void OnSubscriptionEstablished(void * context) + { + CHIP_ERROR err = chip::JniReferences::GetInstance().CallSubscriptionEstablished( + reinterpret_cast(context)->javaCallbackRef); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error calling onSubscriptionEstablished: %s", ErrorStr(err))); + }; + +private: + jobject javaCallbackRef; + bool keepAlive; +}; + +class CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback + : public chip::Callback::Callback +{ +public: + CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback(jobject javaCallback, bool keepAlive = false); + + ~CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback(); + + static void maybeDestroy(CHIPEthernetNetworkDiagnosticsCarrierDetectAttributeCallback * callback) + { + if (!callback->keepAlive) + { + callback->Cancel(); + chip::Platform::Delete(callback); + } + } + + static void CallbackFn(void * context, const chip::app::DataModel::Nullable & value); + static void OnSubscriptionEstablished(void * context) + { + CHIP_ERROR err = chip::JniReferences::GetInstance().CallSubscriptionEstablished( + reinterpret_cast(context)->javaCallbackRef); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error calling onSubscriptionEstablished: %s", ErrorStr(err))); + }; + +private: + jobject javaCallbackRef; + bool keepAlive; +}; + class CHIPEthernetNetworkDiagnosticsServerGeneratedCommandListAttributeCallback : public chip::Callback::Callback { diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index f570c78e5fbc4f..390b587cfefe67 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -7162,6 +7162,30 @@ private native void resetCounts( DefaultClusterCallback Callback, @Nullable Integer timedInvokeTimeoutMs); + public interface PHYRateAttributeCallback { + void onSuccess(@Nullable Integer value); + + void onError(Exception ex); + + default void onSubscriptionEstablished() {} + } + + public interface FullDuplexAttributeCallback { + void onSuccess(@Nullable Boolean value); + + void onError(Exception ex); + + default void onSubscriptionEstablished() {} + } + + public interface CarrierDetectAttributeCallback { + void onSuccess(@Nullable Boolean value); + + void onError(Exception ex); + + default void onSubscriptionEstablished() {} + } + public interface ServerGeneratedCommandListAttributeCallback { void onSuccess(List valueList); @@ -7186,21 +7210,21 @@ public interface AttributeListAttributeCallback { default void onSubscriptionEstablished() {} } - public void readPHYRateAttribute(IntegerAttributeCallback callback) { + public void readPHYRateAttribute(PHYRateAttributeCallback callback) { readPHYRateAttribute(chipClusterPtr, callback); } public void subscribePHYRateAttribute( - IntegerAttributeCallback callback, int minInterval, int maxInterval) { + PHYRateAttributeCallback callback, int minInterval, int maxInterval) { subscribePHYRateAttribute(chipClusterPtr, callback, minInterval, maxInterval); } - public void readFullDuplexAttribute(BooleanAttributeCallback callback) { + public void readFullDuplexAttribute(FullDuplexAttributeCallback callback) { readFullDuplexAttribute(chipClusterPtr, callback); } public void subscribeFullDuplexAttribute( - BooleanAttributeCallback callback, int minInterval, int maxInterval) { + FullDuplexAttributeCallback callback, int minInterval, int maxInterval) { subscribeFullDuplexAttribute(chipClusterPtr, callback, minInterval, maxInterval); } @@ -7249,12 +7273,12 @@ public void subscribeOverrunCountAttribute( subscribeOverrunCountAttribute(chipClusterPtr, callback, minInterval, maxInterval); } - public void readCarrierDetectAttribute(BooleanAttributeCallback callback) { + public void readCarrierDetectAttribute(CarrierDetectAttributeCallback callback) { readCarrierDetectAttribute(chipClusterPtr, callback); } public void subscribeCarrierDetectAttribute( - BooleanAttributeCallback callback, int minInterval, int maxInterval) { + CarrierDetectAttributeCallback callback, int minInterval, int maxInterval) { subscribeCarrierDetectAttribute(chipClusterPtr, callback, minInterval, maxInterval); } @@ -7317,16 +7341,19 @@ public void subscribeClusterRevisionAttribute( } private native void readPHYRateAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); + long chipClusterPtr, PHYRateAttributeCallback callback); private native void subscribePHYRateAttribute( - long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); + long chipClusterPtr, PHYRateAttributeCallback callback, int minInterval, int maxInterval); private native void readFullDuplexAttribute( - long chipClusterPtr, BooleanAttributeCallback callback); + long chipClusterPtr, FullDuplexAttributeCallback callback); private native void subscribeFullDuplexAttribute( - long chipClusterPtr, BooleanAttributeCallback callback, int minInterval, int maxInterval); + long chipClusterPtr, + FullDuplexAttributeCallback callback, + int minInterval, + int maxInterval); private native void readPacketRxCountAttribute( long chipClusterPtr, LongAttributeCallback callback); @@ -7359,10 +7386,13 @@ private native void subscribeOverrunCountAttribute( long chipClusterPtr, LongAttributeCallback callback, int minInterval, int maxInterval); private native void readCarrierDetectAttribute( - long chipClusterPtr, BooleanAttributeCallback callback); + long chipClusterPtr, CarrierDetectAttributeCallback callback); private native void subscribeCarrierDetectAttribute( - long chipClusterPtr, BooleanAttributeCallback callback, int minInterval, int maxInterval); + long chipClusterPtr, + CarrierDetectAttributeCallback callback, + int minInterval, + int maxInterval); private native void readTimeSinceResetAttribute( long chipClusterPtr, LongAttributeCallback callback); diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterReadMapping.java index aaf560126eeddf..9e5d35df547e54 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterReadMapping.java @@ -3254,7 +3254,9 @@ public Map> getReadAttributeMap() { new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.EthernetNetworkDiagnosticsCluster) cluster) - .readPHYRateAttribute((ChipClusters.IntegerAttributeCallback) callback); + .readPHYRateAttribute( + (ChipClusters.EthernetNetworkDiagnosticsCluster.PHYRateAttributeCallback) + callback); }, () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), readEthernetNetworkDiagnosticsPHYRateCommandParams); @@ -3266,7 +3268,9 @@ public Map> getReadAttributeMap() { new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.EthernetNetworkDiagnosticsCluster) cluster) - .readFullDuplexAttribute((ChipClusters.BooleanAttributeCallback) callback); + .readFullDuplexAttribute( + (ChipClusters.EthernetNetworkDiagnosticsCluster.FullDuplexAttributeCallback) + callback); }, () -> new ClusterInfoMapping.DelegatedBooleanAttributeCallback(), readEthernetNetworkDiagnosticsFullDuplexCommandParams); @@ -3344,7 +3348,10 @@ public Map> getReadAttributeMap() { new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.EthernetNetworkDiagnosticsCluster) cluster) - .readCarrierDetectAttribute((ChipClusters.BooleanAttributeCallback) callback); + .readCarrierDetectAttribute( + (ChipClusters.EthernetNetworkDiagnosticsCluster + .CarrierDetectAttributeCallback) + callback); }, () -> new ClusterInfoMapping.DelegatedBooleanAttributeCallback(), readEthernetNetworkDiagnosticsCarrierDetectCommandParams); diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 0926f5cf06560c..747590caaf8f0b 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -12652,14 +12652,14 @@ class EthernetNetworkDiagnostics(Cluster): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ - ClusterObjectFieldDescriptor(Label="PHYRate", Tag=0x00000000, Type=typing.Optional[uint]), - ClusterObjectFieldDescriptor(Label="fullDuplex", Tag=0x00000001, Type=typing.Optional[bool]), + ClusterObjectFieldDescriptor(Label="PHYRate", Tag=0x00000000, Type=typing.Union[None, Nullable, EthernetNetworkDiagnostics.Enums.PHYRateType]), + ClusterObjectFieldDescriptor(Label="fullDuplex", Tag=0x00000001, Type=typing.Union[None, Nullable, bool]), ClusterObjectFieldDescriptor(Label="packetRxCount", Tag=0x00000002, Type=uint), ClusterObjectFieldDescriptor(Label="packetTxCount", Tag=0x00000003, Type=uint), ClusterObjectFieldDescriptor(Label="txErrCount", Tag=0x00000004, Type=uint), ClusterObjectFieldDescriptor(Label="collisionCount", Tag=0x00000005, Type=uint), ClusterObjectFieldDescriptor(Label="overrunCount", Tag=0x00000006, Type=uint), - ClusterObjectFieldDescriptor(Label="carrierDetect", Tag=0x00000007, Type=typing.Optional[bool]), + ClusterObjectFieldDescriptor(Label="carrierDetect", Tag=0x00000007, Type=typing.Union[None, Nullable, bool]), ClusterObjectFieldDescriptor(Label="timeSinceReset", Tag=0x00000008, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="serverGeneratedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="clientGeneratedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), @@ -12668,14 +12668,14 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), ]) - PHYRate: 'typing.Optional[uint]' = None - fullDuplex: 'typing.Optional[bool]' = None + PHYRate: 'typing.Union[None, Nullable, EthernetNetworkDiagnostics.Enums.PHYRateType]' = None + fullDuplex: 'typing.Union[None, Nullable, bool]' = None packetRxCount: 'uint' = None packetTxCount: 'uint' = None txErrCount: 'uint' = None collisionCount: 'uint' = None overrunCount: 'uint' = None - carrierDetect: 'typing.Optional[bool]' = None + carrierDetect: 'typing.Union[None, Nullable, bool]' = None timeSinceReset: 'typing.Optional[uint]' = None serverGeneratedCommandList: 'typing.List[uint]' = None clientGeneratedCommandList: 'typing.List[uint]' = None @@ -12726,9 +12726,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, EthernetNetworkDiagnostics.Enums.PHYRateType]) - value: 'typing.Optional[uint]' = None + value: 'typing.Union[None, Nullable, EthernetNetworkDiagnostics.Enums.PHYRateType]' = None @dataclass class FullDuplex(ClusterAttributeDescriptor): @@ -12742,9 +12742,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[bool]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, bool]) - value: 'typing.Optional[bool]' = None + value: 'typing.Union[None, Nullable, bool]' = None @dataclass class PacketRxCount(ClusterAttributeDescriptor): @@ -12838,9 +12838,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=typing.Optional[bool]) + return ClusterObjectFieldDescriptor(Type=typing.Union[None, Nullable, bool]) - value: 'typing.Optional[bool]' = None + value: 'typing.Union[None, Nullable, bool]' = None @dataclass class TimeSinceReset(ClusterAttributeDescriptor): diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm index 8f515e35e876b4..780d7ea63fe937 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm @@ -3968,8 +3968,12 @@ id CHIPDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader if (*aError != CHIP_NO_ERROR) { return nil; } - NSNumber * _Nonnull value; - value = [NSNumber numberWithUnsignedChar:cppValue]; + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.Value())]; + } return value; } case Attributes::FullDuplex::Id: { @@ -3979,8 +3983,12 @@ id CHIPDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader if (*aError != CHIP_NO_ERROR) { return nil; } - NSNumber * _Nonnull value; - value = [NSNumber numberWithBool:cppValue]; + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithBool:cppValue.Value()]; + } return value; } case Attributes::PacketRxCount::Id: { @@ -4045,8 +4053,12 @@ id CHIPDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader if (*aError != CHIP_NO_ERROR) { return nil; } - NSNumber * _Nonnull value; - value = [NSNumber numberWithBool:cppValue]; + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithBool:cppValue.Value()]; + } return value; } case Attributes::TimeSinceReset::Id: { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm index 585a220b8ee1fa..d8b041e6b8e2ea 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm @@ -9235,12 +9235,14 @@ new CHIPCommandSuccessCallbackBridge( - (void)readAttributePHYRateWithCompletionHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completionHandler { - new CHIPInt8uAttributeCallbackBridge(self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { - using TypeInfo = EthernetNetworkDiagnostics::Attributes::PHYRate::TypeInfo; - auto successFn = Callback::FromCancelable(success); - auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); - }); + new CHIPNullableEthernetNetworkDiagnosticsClusterPHYRateTypeAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = EthernetNetworkDiagnostics::Attributes::PHYRate::TypeInfo; + auto successFn + = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); } - (void)subscribeAttributePHYRateWithMinInterval:(uint16_t)minInterval @@ -9248,14 +9250,17 @@ - (void)subscribeAttributePHYRateWithMinInterval:(uint16_t)minInterval subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler { - new CHIPInt8uAttributeCallbackSubscriptionBridge( + new CHIPNullableEthernetNetworkDiagnosticsClusterPHYRateTypeAttributeCallbackSubscriptionBridge( self.callbackQueue, reportHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = EthernetNetworkDiagnostics::Attributes::PHYRate::TypeInfo; - auto successFn = Callback::FromCancelable(success); + auto successFn + = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, - minInterval, maxInterval, CHIPInt8uAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + minInterval, maxInterval, + CHIPNullableEthernetNetworkDiagnosticsClusterPHYRateTypeAttributeCallbackSubscriptionBridge:: + OnSubscriptionEstablished); }, subscriptionEstablishedHandler); } @@ -9263,12 +9268,13 @@ new CHIPInt8uAttributeCallbackSubscriptionBridge( - (void)readAttributeFullDuplexWithCompletionHandler:(void (^)( NSNumber * _Nullable value, NSError * _Nullable error))completionHandler { - new CHIPBooleanAttributeCallbackBridge(self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { - using TypeInfo = EthernetNetworkDiagnostics::Attributes::FullDuplex::TypeInfo; - auto successFn = Callback::FromCancelable(success); - auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); - }); + new CHIPNullableBooleanAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = EthernetNetworkDiagnostics::Attributes::FullDuplex::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); } - (void)subscribeAttributeFullDuplexWithMinInterval:(uint16_t)minInterval @@ -9276,14 +9282,14 @@ - (void)subscribeAttributeFullDuplexWithMinInterval:(uint16_t)minInterval subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler { - new CHIPBooleanAttributeCallbackSubscriptionBridge( + new CHIPNullableBooleanAttributeCallbackSubscriptionBridge( self.callbackQueue, reportHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = EthernetNetworkDiagnostics::Attributes::FullDuplex::TypeInfo; - auto successFn = Callback::FromCancelable(success); + auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, - minInterval, maxInterval, CHIPBooleanAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + minInterval, maxInterval, CHIPNullableBooleanAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); }, subscriptionEstablishedHandler); } @@ -9434,12 +9440,13 @@ new CHIPInt64uAttributeCallbackSubscriptionBridge( - (void)readAttributeCarrierDetectWithCompletionHandler:(void (^)( NSNumber * _Nullable value, NSError * _Nullable error))completionHandler { - new CHIPBooleanAttributeCallbackBridge(self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { - using TypeInfo = EthernetNetworkDiagnostics::Attributes::CarrierDetect::TypeInfo; - auto successFn = Callback::FromCancelable(success); - auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); - }); + new CHIPNullableBooleanAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = EthernetNetworkDiagnostics::Attributes::CarrierDetect::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); } - (void)subscribeAttributeCarrierDetectWithMinInterval:(uint16_t)minInterval @@ -9448,14 +9455,14 @@ - (void)subscribeAttributeCarrierDetectWithMinInterval:(uint16_t)minInterval reportHandler: (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler { - new CHIPBooleanAttributeCallbackSubscriptionBridge( + new CHIPNullableBooleanAttributeCallbackSubscriptionBridge( self.callbackQueue, reportHandler, ^(Cancelable * success, Cancelable * failure) { using TypeInfo = EthernetNetworkDiagnostics::Attributes::CarrierDetect::TypeInfo; - auto successFn = Callback::FromCancelable(success); + auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, - minInterval, maxInterval, CHIPBooleanAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + minInterval, maxInterval, CHIPNullableBooleanAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); }, subscriptionEstablishedHandler); } diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.h index 6e12ac61c5e2f3..2d7c95e9385780 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.h @@ -465,14 +465,14 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPTestEthernetNetworkDiagnostics : CHIPEthernetNetworkDiagnostics -- (void)writeAttributePHYRateWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; -- (void)writeAttributeFullDuplexWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; +- (void)writeAttributePHYRateWithValue:(NSNumber * _Nullable)value completionHandler:(StatusCompletion)completionHandler; +- (void)writeAttributeFullDuplexWithValue:(NSNumber * _Nullable)value completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributePacketRxCountWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributePacketTxCountWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributeTxErrCountWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributeCollisionCountWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributeOverrunCountWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; -- (void)writeAttributeCarrierDetectWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; +- (void)writeAttributeCarrierDetectWithValue:(NSNumber * _Nullable)value completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributeTimeSinceResetWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributeServerGeneratedCommandListWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm index ed2ce079d8f592..6518bd384bbc00 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm @@ -5504,7 +5504,7 @@ @implementation CHIPTestEthernetNetworkDiagnostics return &_cppCluster; } -- (void)writeAttributePHYRateWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler +- (void)writeAttributePHYRateWithValue:(NSNumber * _Nullable)value completionHandler:(StatusCompletion)completionHandler { new CHIPDefaultSuccessCallbackBridge( self.callbackQueue, @@ -5515,14 +5515,19 @@ new CHIPDefaultSuccessCallbackBridge( ListFreer listFreer; using TypeInfo = EthernetNetworkDiagnostics::Attributes::PHYRate::TypeInfo; TypeInfo::Type cppValue; - cppValue = value.unsignedCharValue; + if (value == nil) { + cppValue.SetNull(); + } else { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>(value.unsignedCharValue); + } auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); }); } -- (void)writeAttributeFullDuplexWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler +- (void)writeAttributeFullDuplexWithValue:(NSNumber * _Nullable)value completionHandler:(StatusCompletion)completionHandler { new CHIPDefaultSuccessCallbackBridge( self.callbackQueue, @@ -5533,7 +5538,12 @@ new CHIPDefaultSuccessCallbackBridge( ListFreer listFreer; using TypeInfo = EthernetNetworkDiagnostics::Attributes::FullDuplex::TypeInfo; TypeInfo::Type cppValue; - cppValue = value.boolValue; + if (value == nil) { + cppValue.SetNull(); + } else { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = value.boolValue; + } auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); @@ -5630,7 +5640,7 @@ new CHIPDefaultSuccessCallbackBridge( }); } -- (void)writeAttributeCarrierDetectWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler +- (void)writeAttributeCarrierDetectWithValue:(NSNumber * _Nullable)value completionHandler:(StatusCompletion)completionHandler { new CHIPDefaultSuccessCallbackBridge( self.callbackQueue, @@ -5641,7 +5651,12 @@ new CHIPDefaultSuccessCallbackBridge( ListFreer listFreer; using TypeInfo = EthernetNetworkDiagnostics::Attributes::CarrierDetect::TypeInfo; TypeInfo::Type cppValue; - cppValue = value.boolValue; + if (value == nil) { + cppValue.SetNull(); + } else { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = value.boolValue; + } auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); diff --git a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h index 4eb1589f17ef72..fbf58e77313643 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -1709,17 +1709,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(569) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(577) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(585) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(593) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(601) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(609) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(617) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(569) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(577) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(585) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(593) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(601) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(609) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(617) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index 0a636dcf8c365e..da01c015267786 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -10996,25 +10996,29 @@ namespace Attributes { namespace PHYRate { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value) +EmberAfStatus Get(chip::EndpointId endpoint, + DataModel::Nullable & value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::EthernetNetworkDiagnostics::PHYRateType value) { - using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } @@ -11024,11 +11028,31 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, + const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + } // namespace PHYRate namespace FullDuplex { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; @@ -11036,17 +11060,20 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value) EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } @@ -11057,6 +11084,26 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) ZCL_BOOLEAN_ATTRIBUTE_TYPE); } +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, + ZCL_BOOLEAN_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + } // namespace FullDuplex namespace PacketRxCount { @@ -11221,7 +11268,7 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value) namespace CarrierDetect { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) { using Traits = NumericAttributeTraits; Traits::StorageType temp; @@ -11229,17 +11276,20 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value) EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + if (Traits::IsNullValue(temp)) { - return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); } - *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, bool value) { using Traits = NumericAttributeTraits; - if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } @@ -11250,6 +11300,26 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) ZCL_BOOLEAN_ATTRIBUTE_TYPE); } +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteServerAttribute(endpoint, Clusters::EthernetNetworkDiagnostics::Id, Id, writable, + ZCL_BOOLEAN_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + } // namespace CarrierDetect namespace TimeSinceReset { diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 8bd3040c40b70f..cca17bb395316a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -1965,13 +1965,19 @@ namespace EthernetNetworkDiagnostics { namespace Attributes { namespace PHYRate { -EmberAfStatus Get(chip::EndpointId endpoint, uint8_t * value); // enum8 -EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +EmberAfStatus Get(chip::EndpointId endpoint, + DataModel::Nullable & value); // PHYRateType +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::EthernetNetworkDiagnostics::PHYRateType value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, + const chip::app::DataModel::Nullable & value); } // namespace PHYRate namespace FullDuplex { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); } // namespace FullDuplex namespace PacketRxCount { @@ -2000,8 +2006,10 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint64_t value); } // namespace OverrunCount namespace CarrierDetect { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); } // namespace CarrierDetect namespace TimeSinceReset { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index a936ed900b8457..7af807ed1bcfcf 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -14425,9 +14425,9 @@ namespace Attributes { namespace PHYRate { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; static constexpr ClusterId GetClusterId() { return Clusters::EthernetNetworkDiagnostics::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::PHYRate::Id; } @@ -14437,9 +14437,9 @@ struct TypeInfo namespace FullDuplex { struct TypeInfo { - using Type = bool; - using DecodableType = bool; - using DecodableArgType = bool; + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; static constexpr ClusterId GetClusterId() { return Clusters::EthernetNetworkDiagnostics::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::FullDuplex::Id; } @@ -14509,9 +14509,9 @@ struct TypeInfo namespace CarrierDetect { struct TypeInfo { - using Type = bool; - using DecodableType = bool; - using DecodableArgType = bool; + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; static constexpr ClusterId GetClusterId() { return Clusters::EthernetNetworkDiagnostics::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::CarrierDetect::Id; } @@ -14599,14 +14599,14 @@ struct TypeInfo CHIP_ERROR Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path); - Attributes::PHYRate::TypeInfo::DecodableType PHYRate = static_cast(0); - Attributes::FullDuplex::TypeInfo::DecodableType fullDuplex = static_cast(0); + Attributes::PHYRate::TypeInfo::DecodableType PHYRate; + Attributes::FullDuplex::TypeInfo::DecodableType fullDuplex; Attributes::PacketRxCount::TypeInfo::DecodableType packetRxCount = static_cast(0); Attributes::PacketTxCount::TypeInfo::DecodableType packetTxCount = static_cast(0); Attributes::TxErrCount::TypeInfo::DecodableType txErrCount = static_cast(0); Attributes::CollisionCount::TypeInfo::DecodableType collisionCount = static_cast(0); Attributes::OverrunCount::TypeInfo::DecodableType overrunCount = static_cast(0); - Attributes::CarrierDetect::TypeInfo::DecodableType carrierDetect = static_cast(0); + Attributes::CarrierDetect::TypeInfo::DecodableType carrierDetect; Attributes::TimeSinceReset::TypeInfo::DecodableType timeSinceReset = static_cast(0); Attributes::ServerGeneratedCommandList::TypeInfo::DecodableType serverGeneratedCommandList; Attributes::ClientGeneratedCommandList::TypeInfo::DecodableType clientGeneratedCommandList; diff --git a/zzz_generated/bridge-app/zap-generated/endpoint_config.h b/zzz_generated/bridge-app/zap-generated/endpoint_config.h index c92ae7cfd94b63..39ede1689a175f 100644 --- a/zzz_generated/bridge-app/zap-generated/endpoint_config.h +++ b/zzz_generated/bridge-app/zap-generated/endpoint_config.h @@ -806,17 +806,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 6de350f58ba458..892ec908c3674b 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -5179,12 +5179,12 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP switch (path.mAttributeId) { case EthernetNetworkDiagnostics::Attributes::PHYRate::Id: { - uint8_t value; + chip::app::DataModel::Nullable value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("PHYRate", 1, value); } case EthernetNetworkDiagnostics::Attributes::FullDuplex::Id: { - bool value; + chip::app::DataModel::Nullable value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("FullDuplex", 1, value); } @@ -5214,7 +5214,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("OverrunCount", 1, value); } case EthernetNetworkDiagnostics::Attributes::CarrierDetect::Id: { - bool value; + chip::app::DataModel::Nullable value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("CarrierDetect", 1, value); } diff --git a/zzz_generated/door-lock-app/zap-generated/endpoint_config.h b/zzz_generated/door-lock-app/zap-generated/endpoint_config.h index 67806590292a22..944f66ef11833d 100644 --- a/zzz_generated/door-lock-app/zap-generated/endpoint_config.h +++ b/zzz_generated/door-lock-app/zap-generated/endpoint_config.h @@ -812,17 +812,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(371) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(371) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/light-switch-app/zap-generated/endpoint_config.h b/zzz_generated/light-switch-app/zap-generated/endpoint_config.h index d9094961aea125..f88f80ec7f95a2 100644 --- a/zzz_generated/light-switch-app/zap-generated/endpoint_config.h +++ b/zzz_generated/light-switch-app/zap-generated/endpoint_config.h @@ -717,17 +717,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(293) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(301) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(309) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(317) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(325) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(333) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(341) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(293) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(301) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(309) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(317) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(325) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(333) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(341) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/lighting-app/zap-generated/endpoint_config.h b/zzz_generated/lighting-app/zap-generated/endpoint_config.h index c52973b2c1ba8f..6575b5e38c7ba6 100644 --- a/zzz_generated/lighting-app/zap-generated/endpoint_config.h +++ b/zzz_generated/lighting-app/zap-generated/endpoint_config.h @@ -778,17 +778,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(311) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(319) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(327) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(335) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(343) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(351) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(359) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(311) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(319) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(327) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(335) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(343) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(351) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(359) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/lock-app/zap-generated/endpoint_config.h b/zzz_generated/lock-app/zap-generated/endpoint_config.h index bb4f1f8e0a8bf9..a36bc800742670 100644 --- a/zzz_generated/lock-app/zap-generated/endpoint_config.h +++ b/zzz_generated/lock-app/zap-generated/endpoint_config.h @@ -794,17 +794,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(371) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(371) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h b/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h index ea8f41ba4eba75..cd4f12d5d248d2 100644 --- a/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h +++ b/zzz_generated/pump-controller-app/zap-generated/endpoint_config.h @@ -750,17 +750,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h b/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h index 3c2d49030d3344..64be26465ee95e 100644 --- a/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h +++ b/zzz_generated/temperature-measurement-app/zap-generated/endpoint_config.h @@ -404,17 +404,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(110) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(118) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(126) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(134) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(142) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(150) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(158) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(110) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(118) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(126) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(134) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(142) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(150) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(158) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/thermostat/zap-generated/endpoint_config.h b/zzz_generated/thermostat/zap-generated/endpoint_config.h index e0aa6367dd4eef..6838bb0260e56c 100644 --- a/zzz_generated/thermostat/zap-generated/endpoint_config.h +++ b/zzz_generated/thermostat/zap-generated/endpoint_config.h @@ -854,17 +854,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/tv-app/zap-generated/endpoint_config.h b/zzz_generated/tv-app/zap-generated/endpoint_config.h index 76f4aec2001101..291009cc30c168 100644 --- a/zzz_generated/tv-app/zap-generated/endpoint_config.h +++ b/zzz_generated/tv-app/zap-generated/endpoint_config.h @@ -1198,17 +1198,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h index 82c8c878f2229f..89b3b75b5fb7ea 100644 --- a/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h +++ b/zzz_generated/tv-casting-app/zap-generated/endpoint_config.h @@ -1061,17 +1061,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(315) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(323) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ diff --git a/zzz_generated/window-app/zap-generated/endpoint_config.h b/zzz_generated/window-app/zap-generated/endpoint_config.h index c7fe13b587b717..08d648933e6b73 100644 --- a/zzz_generated/window-app/zap-generated/endpoint_config.h +++ b/zzz_generated/window-app/zap-generated/endpoint_config.h @@ -801,17 +801,17 @@ { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ - { 0x00000000, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ - { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ - { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* PacketRxCount */ \ - { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* PacketTxCount */ \ - { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* TxErrCount */ \ - { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* CollisionCount */ \ - { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* OverrunCount */ \ - { 0x00000007, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ - { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(371) }, /* TimeSinceReset */ \ - { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(379) }, /* FeatureMap */ \ - { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* PHYRate */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* FullDuplex */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(331) }, /* PacketRxCount */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(339) }, /* PacketTxCount */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(347) }, /* TxErrCount */ \ + { 0x00000005, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(355) }, /* CollisionCount */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(363) }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* CarrierDetect */ \ + { 0x00000008, ZAP_TYPE(INT64U), 8, 0, ZAP_LONG_DEFAULTS_INDEX(371) }, /* TimeSinceReset */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_LONG_DEFAULTS_INDEX(379) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { 0x00000000, ZAP_TYPE(INT8U), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ From 26fa3fa4fa49ff619a4d99450e1cd18a3187d201 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 7 Feb 2022 15:11:10 -0500 Subject: [PATCH 09/12] Add correct checking for whether a command is supported. (#14806) This also fixes the status reporting for unsupported endpoints and clusters. And fixes some tests to use the right endpoint, now that we are checking that sort of thing. Fixes https://github.com/project-chip/connectedhomeip/issues/7612 Fixes https://github.com/project-chip/connectedhomeip/issues/13920 Fixes https://github.com/project-chip/connectedhomeip/issues/14022 Fixes https://github.com/project-chip/connectedhomeip/issues/11578 Fixes https://github.com/project-chip/connectedhomeip/issues/11185 --- .github/.wordlist.txt | 4 + examples/bridge-app/esp32/README.md | 6 +- examples/bridge-app/esp32/main/main.cpp | 19 +- examples/bridge-app/linux/README.md | 6 +- examples/bridge-app/linux/main.cpp | 27 +- examples/tv-app/linux/AppImpl.cpp | 95 ++++++- src/app/CommandHandler.cpp | 36 +-- src/app/CommandHandler.h | 9 +- src/app/InteractionModelEngine.cpp | 2 +- src/app/InteractionModelEngine.h | 16 +- src/app/tests/TestCommandInteraction.cpp | 30 +- .../tests/integration/chip_im_initiator.cpp | 6 +- .../tests/integration/chip_im_responder.cpp | 24 +- src/app/tests/suites/TestCluster.yaml | 14 +- .../certification/Test_TC_SWDIAG_1_1.yaml | 5 +- .../certification/Test_TC_SWDIAG_2_1.yaml | 2 +- .../certification/Test_TC_SWDIAG_3_1.yaml | 8 +- .../certification/Test_TC_WIFIDIAG_1_1.yaml | 11 +- .../certification/Test_TC_WIFIDIAG_3_1.yaml | 4 +- src/app/util/af.h | 6 +- src/app/util/attribute-storage.cpp | 10 + src/app/util/attribute-storage.h | 9 +- .../util/ember-compatibility-functions.cpp | 56 +++- src/controller/tests/TestReadChunking.cpp | 4 +- .../tests/TestServerCommandDispatch.cpp | 12 +- .../tests/data_model/TestCommands.cpp | 20 +- src/controller/tests/data_model/TestRead.cpp | 20 +- src/controller/tests/data_model/TestWrite.cpp | 20 +- .../Framework/CHIPTests/CHIPClustersTests.m | 111 ++++---- .../linux-cirque/MobileDeviceTest.py | 2 +- .../chip-tool/zap-generated/test/Commands.h | 263 +++++++++++------- 31 files changed, 580 insertions(+), 277 deletions(-) diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index bfad18cce35fa0..707a0fd79c1252 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -504,6 +504,7 @@ ImplClass implementers imx imxlinux +incomingCommands indexhtml Inet InetLayer @@ -550,6 +551,7 @@ jupyterlab KA Kconfig KeypadInput +kInvalidCommandId KitProg kNodeIdNotSpecified knownissues @@ -716,6 +718,7 @@ nrfdks nrfutil nrfxlib NTAG +nullptr NUM nwk NXP @@ -763,6 +766,7 @@ otasoftwareupdaterequestor otaURL OTBR otcli +outgoingCommands PAA PacketBuffer PAI diff --git a/examples/bridge-app/esp32/README.md b/examples/bridge-app/esp32/README.md index 963ae595bece86..df50e4becfce52 100644 --- a/examples/bridge-app/esp32/README.md +++ b/examples/bridge-app/esp32/README.md @@ -58,7 +58,7 @@ defined: application's `main.cpp` for an example of this implementation. `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName)` -`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs)` +`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, incomingCommands, outgoingCommands)` `DECLARE_DYNAMIC_CLUSTER_LIST_END` - These three macros are used to declare a list of clusters for use within a @@ -66,7 +66,9 @@ defined: `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN` macro which will define the name of the allocated cluster structure. Each cluster is then added by the `DECLARE_DYNAMIC_CLUSTER` macro referencing attribute list previously - defined by the `DECLARE_DYNAMIC_ATTRIBUTE...` macros. Finally, + defined by the `DECLARE_DYNAMIC_ATTRIBUTE...` macros and the lists of + incoming/outgoing commands terminated by kInvalidCommandId (or nullptr if + there aren't any commands in the list). Finally, `DECLARE_DYNAMIC_CLUSTER_LIST_END` macro should be used to close the definition. diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index be17e3fa11466a..d12a81b2c10ed8 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -97,10 +97,23 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_LABEL_LIST_ATTRIBUTE_ID, ARRAY, kFixedLabelAttribu DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Cluster List for Bridged Light endpoint +// TODO: It's not clear whether it would be better to get the command lists from +// the ZAP config on our last fixed endpoint instead. +constexpr CommandId onOffIncomingCommands[] = { + app::Clusters::OnOff::Commands::Off::Id, + app::Clusters::OnOff::Commands::On::Id, + app::Clusters::OnOff::Commands::Toggle::Id, + app::Clusters::OnOff::Commands::OffWithEffect::Id, + app::Clusters::OnOff::Commands::OnWithRecallGlobalScene::Id, + app::Clusters::OnOff::Commands::OnWithTimedOff::Id, + kInvalidCommandId, +}; + DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) -DECLARE_DYNAMIC_CLUSTER(ZCL_ON_OFF_CLUSTER_ID, onOffAttrs), DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, bridgedDeviceBasicAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_FIXED_LABEL_CLUSTER_ID, fixedLabelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(ZCL_ON_OFF_CLUSTER_ID, onOffAttrs, onOffIncomingCommands, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, bridgedDeviceBasicAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_FIXED_LABEL_CLUSTER_ID, fixedLabelAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); diff --git a/examples/bridge-app/linux/README.md b/examples/bridge-app/linux/README.md index 9cdd2a30f8080c..5ff4087b7d89c0 100644 --- a/examples/bridge-app/linux/README.md +++ b/examples/bridge-app/linux/README.md @@ -55,7 +55,7 @@ defined: application's `main.cpp` for an example of this implementation. `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName)` -`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs)` +`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, incomingCommands, outgoingCommands)` `DECLARE_DYNAMIC_CLUSTER_LIST_END` - These three macros are used to declare a list of clusters for use within a @@ -63,7 +63,9 @@ defined: `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN` macro which will define the name of the allocated cluster structure. Each cluster is then added by the `DECLARE_DYNAMIC_CLUSTER` macro referencing attribute list previously - defined by the `DECLARE_DYNAMIC_ATTRIBUTE...` macros. Finally, + defined by the `DECLARE_DYNAMIC_ATTRIBUTE...` macros and the lists of + incoming/outgoing commands terminated by kInvalidCommandId (or nullptr if + there aren't any commands in the list). Finally, `DECLARE_DYNAMIC_CLUSTER_LIST_END` macro should be used to close the definition. diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index bf4627f8109d5a..9c98f4f7822c4a 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -117,10 +117,23 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_LABEL_LIST_ATTRIBUTE_ID, ARRAY, kFixedLabelAttribu DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Cluster List for Bridged Light endpoint +// TODO: It's not clear whether it would be better to get the command lists from +// the ZAP config on our last fixed endpoint instead. +constexpr CommandId onOffIncomingCommands[] = { + app::Clusters::OnOff::Commands::Off::Id, + app::Clusters::OnOff::Commands::On::Id, + app::Clusters::OnOff::Commands::Toggle::Id, + app::Clusters::OnOff::Commands::OffWithEffect::Id, + app::Clusters::OnOff::Commands::OnWithRecallGlobalScene::Id, + app::Clusters::OnOff::Commands::OnWithTimedOff::Id, + kInvalidCommandId, +}; + DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) -DECLARE_DYNAMIC_CLUSTER(ZCL_ON_OFF_CLUSTER_ID, onOffAttrs), DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, bridgedDeviceBasicAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_FIXED_LABEL_CLUSTER_ID, fixedLabelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(ZCL_ON_OFF_CLUSTER_ID, onOffAttrs, onOffIncomingCommands, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, bridgedDeviceBasicAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_FIXED_LABEL_CLUSTER_ID, fixedLabelAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); @@ -166,10 +179,10 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_LABEL_LIST_ATTRIBUTE_ID, ARRAY, kFixedLabelAttribu // Declare Cluster List for Bridged Switch endpoint DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedSwitchClusters) -DECLARE_DYNAMIC_CLUSTER(ZCL_SWITCH_CLUSTER_ID, switchAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, switchDescriptorAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, switchBridgedDeviceBasicAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_FIXED_LABEL_CLUSTER_ID, switchFixedLabelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(ZCL_SWITCH_CLUSTER_ID, switchAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, switchDescriptorAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID, switchBridgedDeviceBasicAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_FIXED_LABEL_CLUSTER_ID, switchFixedLabelAttrs, nullptr, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Switch endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedSwitchEndpoint, bridgedSwitchClusters); diff --git a/examples/tv-app/linux/AppImpl.cpp b/examples/tv-app/linux/AppImpl.cpp index a1af141d7ec959..9870636db1f33c 100644 --- a/examples/tv-app/linux/AppImpl.cpp +++ b/examples/tv-app/linux/AppImpl.cpp @@ -132,17 +132,94 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_CHANNEL_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttri DECLARE_DYNAMIC_ATTRIBUTE(ZCL_CHANNEL_CURRENT_CHANNEL_ATTRIBUTE_ID, STRUCT, 1, 0), /* current channel */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); +constexpr CommandId keypadInputIncomingCommands[] = { + app::Clusters::KeypadInput::Commands::SendKeyRequest::Id, + kInvalidCommandId, +}; +constexpr CommandId keypadInputOutgoingCommands[] = { + app::Clusters::KeypadInput::Commands::SendKeyResponse::Id, + kInvalidCommandId, +}; +constexpr CommandId applicationLauncherIncomingCommands[] = { + app::Clusters::ApplicationLauncher::Commands::LaunchAppRequest::Id, + app::Clusters::ApplicationLauncher::Commands::StopAppRequest::Id, + app::Clusters::ApplicationLauncher::Commands::HideAppRequest::Id, + kInvalidCommandId, +}; +constexpr CommandId applicationLauncherOutgoingCommands[] = { + app::Clusters::ApplicationLauncher::Commands::LauncherResponse::Id, + kInvalidCommandId, +}; +constexpr CommandId accountLoginIncomingCommands[] = { + app::Clusters::AccountLogin::Commands::GetSetupPINRequest::Id, + app::Clusters::AccountLogin::Commands::LoginRequest::Id, + app::Clusters::AccountLogin::Commands::LogoutRequest::Id, + kInvalidCommandId, +}; +constexpr CommandId accountLoginOutgoingCommands[] = { + app::Clusters::AccountLogin::Commands::GetSetupPINResponse::Id, + kInvalidCommandId, +}; +// TODO: Sort out when the optional commands here should be listed. +constexpr CommandId contentLauncherIncomingCommands[] = { + app::Clusters::ContentLauncher::Commands::LaunchContentRequest::Id, + app::Clusters::ContentLauncher::Commands::LaunchURLRequest::Id, + kInvalidCommandId, +}; +constexpr CommandId contentLauncherOutgoingCommands[] = { + app::Clusters::ContentLauncher::Commands::LaunchResponse::Id, + kInvalidCommandId, +}; +// TODO: Sort out when the optional commands here should be listed. +constexpr CommandId mediaPlaybackIncomingCommands[] = { + app::Clusters::MediaPlayback::Commands::PlayRequest::Id, app::Clusters::MediaPlayback::Commands::PauseRequest::Id, + app::Clusters::MediaPlayback::Commands::StopRequest::Id, app::Clusters::MediaPlayback::Commands::StartOverRequest::Id, + app::Clusters::MediaPlayback::Commands::PreviousRequest::Id, app::Clusters::MediaPlayback::Commands::NextRequest::Id, + app::Clusters::MediaPlayback::Commands::RewindRequest::Id, app::Clusters::MediaPlayback::Commands::FastForwardRequest::Id, + app::Clusters::MediaPlayback::Commands::SkipForwardRequest::Id, app::Clusters::MediaPlayback::Commands::SkipBackwardRequest::Id, + app::Clusters::MediaPlayback::Commands::SeekRequest::Id, kInvalidCommandId, +}; +constexpr CommandId mediaPlaybackOutgoingCommands[] = { + app::Clusters::MediaPlayback::Commands::PlaybackResponse::Id, + kInvalidCommandId, +}; +constexpr CommandId targetNavigatorIncomingCommands[] = { + app::Clusters::TargetNavigator::Commands::NavigateTargetRequest::Id, + kInvalidCommandId, +}; +constexpr CommandId targetNavigatorOutgoingCommands[] = { + app::Clusters::TargetNavigator::Commands::NavigateTargetResponse::Id, + kInvalidCommandId, +}; +// TODO: Sort out when the optional commands here should be listed. +constexpr CommandId channelIncomingCommands[] = { + app::Clusters::Channel::Commands::ChangeChannelRequest::Id, + app::Clusters::Channel::Commands::ChangeChannelByNumberRequest::Id, + app::Clusters::Channel::Commands::SkipChannelRequest::Id, + kInvalidCommandId, +}; +constexpr CommandId channelOutgoingCommands[] = { + app::Clusters::Channel::Commands::ChangeChannelResponse::Id, + kInvalidCommandId, +}; // Declare Cluster List for Content App endpoint DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(contentAppClusters) -DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, applicationBasicAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_KEYPAD_INPUT_CLUSTER_ID, keypadInputAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_LAUNCHER_CLUSTER_ID, applicationLauncherAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_ACCOUNT_LOGIN_CLUSTER_ID, accountLoginAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_CONTENT_LAUNCH_CLUSTER_ID, contentLauncherAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_MEDIA_PLAYBACK_CLUSTER_ID, mediaPlaybackAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_TARGET_NAVIGATOR_CLUSTER_ID, targetNavigatorAttrs), - DECLARE_DYNAMIC_CLUSTER(ZCL_CHANNEL_CLUSTER_ID, channelAttrs) DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(ZCL_DESCRIPTOR_CLUSTER_ID, descriptorAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_BASIC_CLUSTER_ID, applicationBasicAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(ZCL_KEYPAD_INPUT_CLUSTER_ID, keypadInputAttrs, keypadInputIncomingCommands, + keypadInputOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(ZCL_APPLICATION_LAUNCHER_CLUSTER_ID, applicationLauncherAttrs, applicationLauncherIncomingCommands, + applicationLauncherOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(ZCL_ACCOUNT_LOGIN_CLUSTER_ID, accountLoginAttrs, accountLoginIncomingCommands, + accountLoginOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(ZCL_CONTENT_LAUNCH_CLUSTER_ID, contentLauncherAttrs, contentLauncherIncomingCommands, + contentLauncherOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(ZCL_MEDIA_PLAYBACK_CLUSTER_ID, mediaPlaybackAttrs, mediaPlaybackIncomingCommands, + mediaPlaybackOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(ZCL_TARGET_NAVIGATOR_CLUSTER_ID, targetNavigatorAttrs, targetNavigatorIncomingCommands, + targetNavigatorOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER(ZCL_CHANNEL_CLUSTER_ID, channelAttrs, channelIncomingCommands, channelOutgoingCommands), + DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Content App endpoint DECLARE_DYNAMIC_ENDPOINT(contentAppEndpoint, contentAppClusters); diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index 476a080c1c801e..e83b45a09dda1c 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -254,7 +254,18 @@ CHIP_ERROR CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommand err = commandPath.GetEndpointId(&concretePath.mEndpointId); SuccessOrExit(err); - VerifyOrExit(mpCallback->CommandExists(concretePath), err = CHIP_ERROR_INVALID_PROFILE_ID); + using Protocols::InteractionModel::Status; + { + Status commandExists = mpCallback->CommandExists(concretePath); + if (commandExists != Status::Success) + { + ChipLogDetail(DataManagement, "No command " ChipLogFormatMEI " in Cluster " ChipLogFormatMEI " on Endpoint 0x%" PRIx16, + ChipLogValueMEI(concretePath.mCommandId), ChipLogValueMEI(concretePath.mClusterId), + concretePath.mEndpointId); + return AddStatus(concretePath, commandExists); + } + } + VerifyOrExit(mpExchangeCtx != nullptr && mpExchangeCtx->HasSessionHandle(), err = CHIP_ERROR_INCORRECT_STATE); { @@ -272,10 +283,10 @@ CHIP_ERROR CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommand { if (err != CHIP_ERROR_ACCESS_DENIED) { - return AddStatus(concretePath, Protocols::InteractionModel::Status::Failure); + return AddStatus(concretePath, Status::Failure); } // TODO: when wildcard invokes are supported, handle them to discard rather than fail with status - return AddStatus(concretePath, Protocols::InteractionModel::Status::UnsupportedAccess); + return AddStatus(concretePath, Status::UnsupportedAccess); } } @@ -308,18 +319,7 @@ CHIP_ERROR CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommand exit: if (err != CHIP_NO_ERROR) { - // The Path is the path in the request if there are any error occurred before we dispatch the command to clusters. - // Currently, it could be failed to decode Path or failed to find cluster / command on desired endpoint. - // TODO: The behavior when receiving a malformed message is not clear in the Spec. (Spec#3259) - // TODO: The error code should be updated after #7072 added error codes required by IM. - if (err == CHIP_ERROR_INVALID_PROFILE_ID) - { - ChipLogDetail(DataManagement, "No Cluster " ChipLogFormatMEI " on Endpoint 0x%" PRIx16, - ChipLogValueMEI(concretePath.mClusterId), concretePath.mEndpointId); - } - - // TODO:in particular different reasons for ServerClusterCommandExists to test false should result in different errors here - AddStatus(concretePath, Protocols::InteractionModel::Status::InvalidCommand); + return AddStatus(concretePath, Status::InvalidCommand); } // We have handled the error status above and put the error status in response, now return success status so we can process @@ -394,10 +394,10 @@ CHIP_ERROR CommandHandler::ProcessGroupCommandDataIB(CommandDataIB::Parser & aCo const ConcreteCommandPath concretePath(mapping.endpoint_id, clusterId, commandId); - if (!mpCallback->CommandExists(concretePath)) + if (mpCallback->CommandExists(concretePath) != Protocols::InteractionModel::Status::Success) { - ChipLogError(DataManagement, "No Cluster " ChipLogFormatMEI " on Endpoint 0x%" PRIx16, ChipLogValueMEI(clusterId), - mapping.endpoint_id); + ChipLogDetail(DataManagement, "No command " ChipLogFormatMEI " in Cluster " ChipLogFormatMEI " on Endpoint 0x%" PRIx16, + ChipLogValueMEI(mapping.endpoint_id), ChipLogValueMEI(clusterId), mapping.endpoint_id); continue; } diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h index 690bc6e104f74d..bf4e3d52b51780 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -74,9 +75,13 @@ class CommandHandler TLV::TLVReader & apPayload) = 0; /* - * Check to see if a command implementation exists for a specific concrete command path. + * Check to see if a command implementation exists for a specific + * concrete command path. If it does, Success will be returned. If + * not, one of UnsupportedEndpoint, UnsupportedCluster, or + * UnsupportedCommand will be returned, depending on how the command + * fails to exist. */ - virtual bool CommandExists(const ConcreteCommandPath & aCommandPath) = 0; + virtual Protocols::InteractionModel::Status CommandExists(const ConcreteCommandPath & aCommandPath) = 0; }; class Handle diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index c283a5177cffab..b08db60763aa2f 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -596,7 +596,7 @@ void InteractionModelEngine::DispatchCommand(CommandHandler & apCommandObj, cons DispatchSingleClusterCommand(aCommandPath, apPayload, &apCommandObj); } -bool InteractionModelEngine::CommandExists(const ConcreteCommandPath & aCommandPath) +Protocols::InteractionModel::Status InteractionModelEngine::CommandExists(const ConcreteCommandPath & aCommandPath) { return ServerClusterCommandExists(aCommandPath); } diff --git a/src/app/InteractionModelEngine.h b/src/app/InteractionModelEngine.h index 41aa33db976a6b..c6b916fd8ba07b 100644 --- a/src/app/InteractionModelEngine.h +++ b/src/app/InteractionModelEngine.h @@ -272,7 +272,7 @@ class InteractionModelEngine : public Messaging::ExchangeDelegate, public Comman void DispatchCommand(CommandHandler & apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & apPayload) override; - bool CommandExists(const ConcreteCommandPath & aCommandPath) override; + Protocols::InteractionModel::Status CommandExists(const ConcreteCommandPath & aCommandPath) override; bool HasActiveRead(); @@ -305,16 +305,12 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip CommandHandler * apCommandObj); /** - * Check whether the given cluster exists on the given endpoint and supports the given command. - * TODO: The implementation lives in ember-compatibility-functions.cpp, this should be replaced by IM command catalog look up - * function after we have a cluster catalog in interaction model engine. - * TODO: The endpoint id on response command (client side command) is unclear, so we don't have a ClientClusterCommandExists - * function. (Spec#3258) - * - * @retval True if the endpoint contains the server side of the given cluster and that cluster implements the given command, false - * otherwise. + * Check whether the given cluster exists on the given endpoint and supports + * the given command. If it does, Success will be returned. If it does not, + * one of UnsupportedEndpoint, UnsupportedCluster, or UnsupportedCommand + * will be returned, depending on how the command fails to exist. */ -bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath); +Protocols::InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath); /** * Fetch attribute value and version info and write to the AttributeReport provided. diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index c0a040d3968a27..cf8a78bf196919 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -45,6 +45,7 @@ #include using TestContext = chip::Test::AppContext; +using namespace chip::Protocols; namespace chip { @@ -65,11 +66,27 @@ namespace app { CommandHandler::Handle asyncCommandHandle; -bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) +InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) { - // Mock cluster catalog, only support one command on one cluster on one endpoint. - return (aCommandPath.mEndpointId == kTestEndpointId && aCommandPath.mClusterId == kTestClusterId && - aCommandPath.mCommandId != kTestNonExistCommandId); + // Mock cluster catalog, only support commands on one cluster on one endpoint. + using InteractionModel::Status; + + if (aCommandPath.mEndpointId != kTestEndpointId) + { + return Status::UnsupportedEndpoint; + } + + if (aCommandPath.mClusterId != kTestClusterId) + { + return Status::UnsupportedCluster; + } + + if (aCommandPath.mCommandId == kTestNonExistCommandId) + { + return Status::UnsupportedCommand; + } + + return Status::Success; } void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip::TLV::TLVReader & aReader, @@ -142,7 +159,10 @@ class MockCommandHandlerCallback : public CommandHandler::Callback { DispatchSingleClusterCommand(aCommandPath, apPayload, &apCommandObj); } - bool CommandExists(const ConcreteCommandPath & aCommandPath) { return ServerClusterCommandExists(aCommandPath); } + InteractionModel::Status CommandExists(const ConcreteCommandPath & aCommandPath) + { + return ServerClusterCommandExists(aCommandPath); + } int onFinalCalledTimes = 0; } mockCommandHandlerDelegate; diff --git a/src/app/tests/integration/chip_im_initiator.cpp b/src/app/tests/integration/chip_im_initiator.cpp index 472948c1c3fb3f..7f700638a37e99 100644 --- a/src/app/tests/integration/chip_im_initiator.cpp +++ b/src/app/tests/integration/chip_im_initiator.cpp @@ -632,10 +632,10 @@ void SubscribeRequestTimerHandler(chip::System::Layer * systemLayer, void * appS namespace chip { namespace app { -bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) +Protocols::InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) { - // Always return true in test. - return true; + // Always return success in test. + return Protocols::InteractionModel::Status::Success; } void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip::TLV::TLVReader & aReader, diff --git a/src/app/tests/integration/chip_im_responder.cpp b/src/app/tests/integration/chip_im_responder.cpp index a3d399e98ba8cc..c9d5e86c7b6eec 100644 --- a/src/app/tests/integration/chip_im_responder.cpp +++ b/src/app/tests/integration/chip_im_responder.cpp @@ -45,11 +45,27 @@ namespace chip { namespace app { -bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) +Protocols::InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) { // The Mock cluster catalog -- only have one command on one cluster on one endpoint. - return (aCommandPath.mEndpointId == kTestEndpointId && aCommandPath.mClusterId == kTestClusterId && - aCommandPath.mCommandId == kTestCommandId); + using Protocols::InteractionModel::Status; + + if (aCommandPath.mEndpointId != kTestEndpointId) + { + return Status::UnsupportedEndpoint; + } + + if (aCommandPath.mClusterId != kTestClusterId) + { + return Status::UnsupportedCluster; + } + + if (aCommandPath.mCommandId != kTestCommandId) + { + return Status::UnsupportedCommand; + } + + return Status::Success; } void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip::TLV::TLVReader & aReader, @@ -57,7 +73,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip { static bool statusCodeFlipper = false; - if (!ServerClusterCommandExists(aCommandPath)) + if (ServerClusterCommandExists(aCommandPath) != Protocols::InteractionModel::Status::Success) { return; } diff --git a/src/app/tests/suites/TestCluster.yaml b/src/app/tests/suites/TestCluster.yaml index 285e56fbaccdb8..545305a6afb74b 100644 --- a/src/app/tests/suites/TestCluster.yaml +++ b/src/app/tests/suites/TestCluster.yaml @@ -954,17 +954,13 @@ tests: command: "test" endpoint: 200 response: - # No such endpoint, so expect an error. - # SDK returning wrong error code here so far. - errorWrongValue: UNSUPPORTED_ENDPOINT + error: UNSUPPORTED_ENDPOINT - label: "Send Test Command to unsupported cluster" command: "test" endpoint: 0 response: - # No TestCluster on that, so expect an error. - # SDK returning wrong error code here so far. - errorWrongValue: UNSUPPORTED_CLUSTER + error: UNSUPPORTED_CLUSTER # Tests for vendor id @@ -2838,16 +2834,14 @@ tests: command: "readAttribute" attribute: "list_int8u" response: - # SDK returning wrong error code here so far. - errorWrongValue: UNSUPPORTED_ENDPOINT + error: UNSUPPORTED_ENDPOINT - label: "Read attribute from nonexistent cluster." endpoint: 0 command: "readAttribute" attribute: "list_int8u" response: - # SDK returning wrong error code here so far. - errorWrongValue: UNSUPPORTED_CLUSTER + error: UNSUPPORTED_CLUSTER # Tests for command with optional arguments - label: diff --git a/src/app/tests/suites/certification/Test_TC_SWDIAG_1_1.yaml b/src/app/tests/suites/certification/Test_TC_SWDIAG_1_1.yaml index dcbccd4cdf2ca2..ae45e8cea85052 100644 --- a/src/app/tests/suites/certification/Test_TC_SWDIAG_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_SWDIAG_1_1.yaml @@ -16,18 +16,15 @@ name: 45.1.1. [TC-SWDIAG-1.1] Attributes with server as DUT config: cluster: "Software Diagnostics" - endpoint: 1 + endpoint: 0 tests: - label: "Wait for the commissioned device to be retrieved" cluster: "DelayCommands" command: "WaitForCommissionee" - #Issue #11185 Disabled as ThreadMetrics attribute missing - #disabled due to issue #13441 - label: "Reads a list of ThreadMetrics struct non-global attribute from DUT." - disabled: true command: "readAttribute" attribute: "ThreadMetrics" PICS: A_THREADMETRICS diff --git a/src/app/tests/suites/certification/Test_TC_SWDIAG_2_1.yaml b/src/app/tests/suites/certification/Test_TC_SWDIAG_2_1.yaml index 159935ef59a7ef..70c0fa0ba2ce9a 100644 --- a/src/app/tests/suites/certification/Test_TC_SWDIAG_2_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_SWDIAG_2_1.yaml @@ -16,7 +16,7 @@ name: 45.1.3. [TC-SWDIAG-2.1] Event functionality with server as DUT config: cluster: "Software Diagnostics" - endpoint: 1 + endpoint: 0 tests: #issue #11725 Reading the List is not implemented in YAML framework diff --git a/src/app/tests/suites/certification/Test_TC_SWDIAG_3_1.yaml b/src/app/tests/suites/certification/Test_TC_SWDIAG_3_1.yaml index 5444450d919801..a7149d134902a7 100644 --- a/src/app/tests/suites/certification/Test_TC_SWDIAG_3_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_SWDIAG_3_1.yaml @@ -16,27 +16,25 @@ name: 45.1.4. [TC-SWDIAG-3.1] Command received functionality with server as DUT config: cluster: "Software Diagnostics" - endpoint: 1 + endpoint: 0 tests: - label: "Wait for the commissioned device to be retrieved" cluster: "DelayCommands" command: "WaitForCommissionee" - #issue #11578 ResetWatermarks command is Failing - label: "Sends ResetWatermarks to DUT" - disabled: true command: "ResetWatermarks" PICS: CR_RESETWATERMARKS - #Disabled due to issue #13441 - label: "Reads a list of ThreadMetrics struct attribute from DUT." disabled: true command: "readAttribute" attribute: "ThreadMetrics" PICS: A_THREADMETRICS response: - value: 0 + # TODO: Say something about the values? + value: {} - label: "Reads CurrentHeapUsed attribute value from DUT" optional: true diff --git a/src/app/tests/suites/certification/Test_TC_WIFIDIAG_1_1.yaml b/src/app/tests/suites/certification/Test_TC_WIFIDIAG_1_1.yaml index 6258d1750d4ac3..e2c0f53419a22b 100644 --- a/src/app/tests/suites/certification/Test_TC_WIFIDIAG_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_WIFIDIAG_1_1.yaml @@ -16,16 +16,14 @@ name: 54.1.1. [TC-WIFIDIAG-1.1] Attributes with server as DUT config: cluster: "WiFi Network Diagnostics" - endpoint: 1 + endpoint: 0 tests: - label: "Wait for the commissioned device to be retrieved" cluster: "DelayCommands" command: "WaitForCommissionee" - #Below steps disabled due to issue #13645 and 11670 - label: "Reads NetworkInterface structure attribute from DUT" - disabled: true cluster: "General Diagnostics" command: "readAttribute" attribute: "NetworkInterfaces" @@ -33,6 +31,9 @@ tests: constraints: type: list + # Various tests disabled for now until + # https://github.com/project-chip/connectedhomeip/pull/14755 is + # fixed and the SDK has the right types. - label: "Reads SecurityType attribute from DUT" disabled: true command: "readAttribute" @@ -185,14 +186,18 @@ tests: constraints: type: uint32 + # Disabled because this fails on Linux because we have no Wi-Fi interface. - label: "Reads CurrentMaxRate attribute from DUT" + disabled: true optional: true command: "readAttribute" attribute: "CurrentMaxRate" response: value: 0 + # Disabled because this fails on Linux because we have no Wi-Fi interface. - label: "Reads CurrentMaxRate attribute constraints" + disabled: true optional: true command: "readAttribute" attribute: "CurrentMaxRate" diff --git a/src/app/tests/suites/certification/Test_TC_WIFIDIAG_3_1.yaml b/src/app/tests/suites/certification/Test_TC_WIFIDIAG_3_1.yaml index ba69ea1d0917c7..337c939846ecf5 100644 --- a/src/app/tests/suites/certification/Test_TC_WIFIDIAG_3_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_WIFIDIAG_3_1.yaml @@ -17,7 +17,7 @@ name: config: cluster: "WiFi Network Diagnostics" - endpoint: 1 + endpoint: 0 tests: - label: "Wait for the commissioned device to be retrieved" @@ -25,6 +25,8 @@ tests: command: "WaitForCommissionee" #Below steps disabled due to issue #13645 + # Also, ResetCounts may not work on some platforms yet? + # And on Linux since we don't have actual Wi-Fi these error out. - label: "TH sends ResetCounts command to DUT" disabled: true command: "ResetCounts" diff --git a/src/app/util/af.h b/src/app/util/af.h index 60bd133994eec1..84e76f7147e713 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -286,12 +286,14 @@ extern EmberAfDefinedEndpoint emAfEndpoints[]; chip::EndpointId emberAfEndpointFromIndex(uint16_t index); /** - * Returns the index of a given endpoint + * Returns the index of a given endpoint. Will return 0xFFFF if this is not a + * valid endpoint id or if the endpoint is disabled. */ uint16_t emberAfIndexFromEndpoint(chip::EndpointId endpoint); /** - * Returns the index of a given endpoint; Does not ignore disabled endpoints + * Returns the index of a given endpoint; Does not ignore disabled endpoints. + * Will return 0xFFFF if this is not a valid endpoint id. */ uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(chip::EndpointId endpoint); diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 1b8180dc9f64c5..61fdb72285c2f3 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -662,6 +662,16 @@ EmberAfStatus emAfReadOrWriteAttribute(EmberAfAttributeSearchRecord * attRecord, return EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE; // Sorry, attribute was not found. } +const EmberAfEndpointType * emberAfFindEndpointType(chip::EndpointId endpointId) +{ + uint16_t ep = emberAfIndexFromEndpoint(endpointId); + if (ep == 0xFFFF) + { + return nullptr; + } + return emAfEndpoints[ep].endpointType; +} + const EmberAfCluster * emberAfFindClusterInType(const EmberAfEndpointType * endpointType, ClusterId clusterId, EmberAfClusterMask mask, uint8_t * index) { diff --git a/src/app/util/attribute-storage.h b/src/app/util/attribute-storage.h index 1ae15547871cb1..6a4e4d079a4ab1 100644 --- a/src/app/util/attribute-storage.h +++ b/src/app/util/attribute-storage.h @@ -78,9 +78,10 @@ #define DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName) EmberAfCluster clusterListName[] = { -#define DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs) \ +#define DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, incomingCommands, outgoingCommands) \ { \ - clusterId, clusterAttrs, sizeof(clusterAttrs) / sizeof(EmberAfAttributeMetadata), 0, ZAP_CLUSTER_MASK(SERVER), NULL \ + clusterId, clusterAttrs, sizeof(clusterAttrs) / sizeof(EmberAfAttributeMetadata), 0, ZAP_CLUSTER_MASK(SERVER), NULL, \ + incomingCommands, outgoingCommands \ } #define DECLARE_DYNAMIC_CLUSTER_LIST_END } @@ -128,6 +129,10 @@ bool emAfMatchCluster(const EmberAfCluster * cluster, EmberAfAttributeSearchReco bool emAfMatchAttribute(const EmberAfCluster * cluster, const EmberAfAttributeMetadata * am, EmberAfAttributeSearchRecord * attRecord); +// Returns endpoint type for the given endpoint id if there is an enabled +// endpoint with that endpoint id. Otherwise returns null. +const EmberAfEndpointType * emberAfFindEndpointType(chip::EndpointId endpointId); + // Check if a cluster is implemented or not. If yes, the cluster is returned. // // mask = 0 -> find either client or server diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index d8ece370e6e47b..f2b39780d5e003 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -247,11 +247,31 @@ CHIP_ERROR attributeBufferToNumericTlvData(TLV::TLVWriter & writer, bool isNulla } // anonymous namespace -bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) +Protocols::InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) { - // TODO: Currently, we are using cluster catalog from the ember library, this should be modified or replaced after several - // updates to Commands. - return emberAfContainsServer(aCommandPath.mEndpointId, aCommandPath.mClusterId); + using Protocols::InteractionModel::Status; + + const EmberAfEndpointType * type = emberAfFindEndpointType(aCommandPath.mEndpointId); + if (type == nullptr) + { + return Status::UnsupportedEndpoint; + } + + const EmberAfCluster * cluster = emberAfFindClusterInType(type, aCommandPath.mClusterId, CLUSTER_MASK_SERVER); + if (cluster == nullptr) + { + return Status::UnsupportedCluster; + } + + for (const CommandId * cmd = cluster->clientGeneratedCommandList; cmd != nullptr; cmd++) + { + if (*cmd == aCommandPath.mCommandId) + { + return Status::Success; + } + } + + return Status::UnsupportedCommand; } namespace { @@ -403,6 +423,30 @@ CHIP_ERROR ReadViaAccessInterface(FabricIndex aAccessingFabricIndex, bool aIsFab return CHIP_NO_ERROR; } +// Determine the appropriate status response for an unsupported attribute for +// the given path. Must be called when the attribute is known to be unsupported +// (i.e. we found no attribute metadata for it). +Protocols::InteractionModel::Status UnsupportedAttributeStatus(const ConcreteAttributePath & aPath) +{ + using Protocols::InteractionModel::Status; + + const EmberAfEndpointType * type = emberAfFindEndpointType(aPath.mEndpointId); + if (type == nullptr) + { + return Status::UnsupportedEndpoint; + } + + const EmberAfCluster * cluster = emberAfFindClusterInType(type, aPath.mClusterId, CLUSTER_MASK_SERVER); + if (cluster == nullptr) + { + return Status::UnsupportedCluster; + } + + // Since we know the attribute is unsupported and the endpoint/cluster are + // OK, this is the only option left. + return Status::UnsupportedAttribute; +} + } // anonymous namespace CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, bool aIsFabricFiltered, @@ -436,7 +480,7 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b if (attributeCluster == nullptr && attributeMetadata == nullptr) { - return SendFailureStatus(aPath, aAttributeReports, Protocols::InteractionModel::Status::UnsupportedAttribute, nullptr); + return SendFailureStatus(aPath, aAttributeReports, UnsupportedAttributeStatus(aPath), nullptr); } // Check access control. A failed check will disallow the operation, and may or may not generate an attribute report @@ -873,7 +917,7 @@ CHIP_ERROR WriteSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, if (attributeMetadata == nullptr) { - return apWriteHandler->AddStatus(aPath, Protocols::InteractionModel::Status::UnsupportedAttribute); + return apWriteHandler->AddStatus(aPath, UnsupportedAttributeStatus(aPath)); } if (attributeMetadata->IsReadOnly()) diff --git a/src/controller/tests/TestReadChunking.cpp b/src/controller/tests/TestReadChunking.cpp index 9304e24c8039c8..d704e16fb94f5e 100644 --- a/src/controller/tests/TestReadChunking.cpp +++ b/src/controller/tests/TestReadChunking.cpp @@ -75,7 +75,7 @@ DECLARE_DYNAMIC_ATTRIBUTE(0x00000001, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE(0x DECLARE_DYNAMIC_ATTRIBUTE(0x00000005, INT8U, 1, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters) -DECLARE_DYNAMIC_CLUSTER(TestCluster::Id, testClusterAttrs), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(TestCluster::Id, testClusterAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint, testEndpointClusters); @@ -84,7 +84,7 @@ DECLARE_DYNAMIC_ATTRIBUTE(kTestListAttribute, ARRAY, 1, 0), DECLARE_DYNAMIC_ATTR DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpoint3Clusters) -DECLARE_DYNAMIC_CLUSTER(TestCluster::Id, testClusterAttrsOnEndpoint3), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(TestCluster::Id, testClusterAttrsOnEndpoint3, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint3, testEndpoint3Clusters); diff --git a/src/controller/tests/TestServerCommandDispatch.cpp b/src/controller/tests/TestServerCommandDispatch.cpp index f094f717b65ac7..a6515ddd7f6551 100644 --- a/src/controller/tests/TestServerCommandDispatch.cpp +++ b/src/controller/tests/TestServerCommandDispatch.cpp @@ -144,7 +144,8 @@ void TestCommandInteraction::TestNoHandler(nlTestSuite * apSuite, void * apConte // not safe to do so. auto onFailureCb = [apSuite](CHIP_ERROR aError) { NL_TEST_ASSERT(apSuite, - aError.IsIMStatus() && app::StatusIB(aError).mStatus == Protocols::InteractionModel::Status::InvalidCommand); + aError.IsIMStatus() && + app::StatusIB(aError).mStatus == Protocols::InteractionModel::Status::UnsupportedEndpoint); }; responseDirective = kSendDataResponse; @@ -176,9 +177,14 @@ DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::DeviceLis DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(testClusterAttrs) DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); +constexpr CommandId testClusterCommands[] = { + TestCluster::Commands::TestSimpleArgumentRequest::Id, + kInvalidCommandId, +}; DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(testEndpointClusters) -DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::TestCluster::Id, testClusterAttrs), - DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::Descriptor::Id, descriptorAttrs), DECLARE_DYNAMIC_CLUSTER_LIST_END; +DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::TestCluster::Id, testClusterAttrs, testClusterCommands, nullptr), + DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(testEndpoint, testEndpointClusters); diff --git a/src/controller/tests/data_model/TestCommands.cpp b/src/controller/tests/data_model/TestCommands.cpp index c4bc3ba4881c87..d13f08f83faabd 100644 --- a/src/controller/tests/data_model/TestCommands.cpp +++ b/src/controller/tests/data_model/TestCommands.cpp @@ -36,12 +36,14 @@ #include #include #include +#include using TestContext = chip::Test::AppContext; using namespace chip; using namespace chip::app; using namespace chip::app::Clusters; +using namespace chip::Protocols; namespace { chip::ClusterStatus kTestSuccessClusterStatus = 1; @@ -129,10 +131,22 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip } } -bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) +InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) { - // Mock cluster catalog, only support one command on one cluster on one endpoint. - return (aCommandPath.mEndpointId == kTestEndpointId && aCommandPath.mClusterId == TestCluster::Id); + // Mock cluster catalog, only support commands on one cluster on one endpoint. + using InteractionModel::Status; + + if (aCommandPath.mEndpointId != kTestEndpointId) + { + return Status::UnsupportedEndpoint; + } + + if (aCommandPath.mClusterId != TestCluster::Id) + { + return Status::UnsupportedCluster; + } + + return Status::Success; } CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescriptor, bool aIsFabricFiltered, diff --git a/src/controller/tests/data_model/TestRead.cpp b/src/controller/tests/data_model/TestRead.cpp index 6082280c2f0106..cbf8e5ddd550ec 100644 --- a/src/controller/tests/data_model/TestRead.cpp +++ b/src/controller/tests/data_model/TestRead.cpp @@ -25,11 +25,13 @@ #include #include #include +#include using TestContext = chip::Test::AppContext; using namespace chip; using namespace chip::app::Clusters; +using namespace chip::Protocols; namespace { @@ -52,10 +54,22 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip CommandHandler * apCommandObj) {} -bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) +InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) { - // Mock cluster catalog, only support one command on one cluster on one endpoint. - return (aCommandPath.mEndpointId == kTestEndpointId && aCommandPath.mClusterId == TestCluster::Id); + // Mock cluster catalog, only support commands on one cluster on one endpoint. + using InteractionModel::Status; + + if (aCommandPath.mEndpointId != kTestEndpointId) + { + return Status::UnsupportedEndpoint; + } + + if (aCommandPath.mClusterId != TestCluster::Id) + { + return Status::UnsupportedCluster; + } + + return Status::Success; } CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescriptor, bool aIsFabricFiltered, diff --git a/src/controller/tests/data_model/TestWrite.cpp b/src/controller/tests/data_model/TestWrite.cpp index 274948956792f7..be60e8317add34 100644 --- a/src/controller/tests/data_model/TestWrite.cpp +++ b/src/controller/tests/data_model/TestWrite.cpp @@ -26,11 +26,13 @@ #include #include #include +#include using TestContext = chip::Test::AppContext; using namespace chip; using namespace chip::app::Clusters; +using namespace chip::Protocols; namespace { @@ -53,10 +55,22 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip CommandHandler * apCommandObj) {} -bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) +InteractionModel::Status ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath) { - // Mock cluster catalog, only support one command on one cluster on one endpoint. - return (aCommandPath.mEndpointId == kTestEndpointId && aCommandPath.mClusterId == TestCluster::Id); + // Mock cluster catalog, only support commands on one cluster on one endpoint. + using InteractionModel::Status; + + if (aCommandPath.mEndpointId != kTestEndpointId) + { + return Status::UnsupportedEndpoint; + } + + if (aCommandPath.mClusterId != TestCluster::Id) + { + return Status::UnsupportedCluster; + } + + return Status::Success; } CHIP_ERROR ReadSingleClusterData(const Access::SubjectDescriptor & aSubjectDescriptor, bool aIsFabricFiltered, diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index bb4439fdd94179..015bab228debb2 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -23207,53 +23207,15 @@ - (void)testSendClusterTest_TC_WIFIDIAG_1_1_000000_WaitForCommissionee } - (void)testSendClusterTest_TC_WIFIDIAG_1_1_000001_ReadAttribute { - XCTestExpectation * expectation = [self expectationWithDescription:@"Reads CurrentMaxRate attribute from DUT"]; + XCTestExpectation * expectation = [self expectationWithDescription:@"Reads NetworkInterface structure attribute from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestWiFiNetworkDiagnostics * cluster = [[CHIPTestWiFiNetworkDiagnostics alloc] initWithDevice:device - endpoint:1 - queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeCurrentMaxRateWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Reads CurrentMaxRate attribute from DUT Error: %@", err); - - if (err.code == CHIPErrorCodeUnsupportedAttribute) { - [expectation fulfill]; - return; - } - - XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); - - { - id actualValue = value; - XCTAssertEqual([actualValue unsignedLongLongValue], 0ULL); - } - - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} -- (void)testSendClusterTest_TC_WIFIDIAG_1_1_000002_ReadAttribute -{ - XCTestExpectation * expectation = [self expectationWithDescription:@"Reads CurrentMaxRate attribute constraints"]; - - CHIPDevice * device = GetConnectedDevice(); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestWiFiNetworkDiagnostics * cluster = [[CHIPTestWiFiNetworkDiagnostics alloc] initWithDevice:device - endpoint:1 - queue:queue]; + CHIPTestGeneralDiagnostics * cluster = [[CHIPTestGeneralDiagnostics alloc] initWithDevice:device endpoint:0 queue:queue]; XCTAssertNotNil(cluster); - [cluster readAttributeCurrentMaxRateWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Reads CurrentMaxRate attribute constraints Error: %@", err); - - if (err.code == CHIPErrorCodeUnsupportedAttribute) { - [expectation fulfill]; - return; - } + [cluster readAttributeNetworkInterfacesWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Reads NetworkInterface structure attribute from DUT Error: %@", err); XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); @@ -28764,7 +28726,7 @@ - (void)testSendClusterTestCluster_000144_Test [cluster testWithCompletionHandler:^(NSError * _Nullable err) { NSLog(@"Send Test Command to unsupported endpoint Error: %@", err); - XCTAssertNotEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); [expectation fulfill]; }]; @@ -28782,7 +28744,7 @@ - (void)testSendClusterTestCluster_000145_Test [cluster testWithCompletionHandler:^(NSError * _Nullable err) { NSLog(@"Send Test Command to unsupported cluster Error: %@", err); - XCTAssertNotEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER); [expectation fulfill]; }]; @@ -34622,7 +34584,7 @@ - (void)testSendClusterTestCluster_000360_ReadAttribute [cluster readAttributeListInt8uWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { NSLog(@"Read attribute from nonexistent endpoint. Error: %@", err); - XCTAssertNotEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT); [expectation fulfill]; }]; @@ -34640,7 +34602,7 @@ - (void)testSendClusterTestCluster_000361_ReadAttribute [cluster readAttributeListInt8uWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { NSLog(@"Read attribute from nonexistent cluster. Error: %@", err); - XCTAssertNotEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER); [expectation fulfill]; }]; @@ -42566,13 +42528,33 @@ - (void)testSendClusterTest_TC_SWDIAG_1_1_000000_WaitForCommissionee [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } - (void)testSendClusterTest_TC_SWDIAG_1_1_000001_ReadAttribute +{ + XCTestExpectation * expectation = + [self expectationWithDescription:@"Reads a list of ThreadMetrics struct non-global attribute from DUT."]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:0 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster readAttributeThreadMetricsWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"Reads a list of ThreadMetrics struct non-global attribute from DUT. Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_SWDIAG_1_1_000002_ReadAttribute { XCTestExpectation * expectation = [self expectationWithDescription:@"Reads CurrentHeapFree non-global attribute value from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:1 queue:queue]; + CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:0 queue:queue]; XCTAssertNotNil(cluster); [cluster readAttributeCurrentHeapFreeWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { @@ -42590,14 +42572,14 @@ - (void)testSendClusterTest_TC_SWDIAG_1_1_000001_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_SWDIAG_1_1_000002_ReadAttribute +- (void)testSendClusterTest_TC_SWDIAG_1_1_000003_ReadAttribute { XCTestExpectation * expectation = [self expectationWithDescription:@"Reads CurrentHeapUsed non-global attribute value from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:1 queue:queue]; + CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:0 queue:queue]; XCTAssertNotNil(cluster); [cluster readAttributeCurrentHeapUsedWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { @@ -42615,14 +42597,14 @@ - (void)testSendClusterTest_TC_SWDIAG_1_1_000002_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_SWDIAG_1_1_000003_ReadAttribute +- (void)testSendClusterTest_TC_SWDIAG_1_1_000004_ReadAttribute { XCTestExpectation * expectation = [self expectationWithDescription:@"Reads CurrentHeapHighWaterMark non-global attribute value from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:1 queue:queue]; + CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:0 queue:queue]; XCTAssertNotNil(cluster); [cluster readAttributeCurrentHeapHighWatermarkWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { @@ -42649,13 +42631,32 @@ - (void)testSendClusterTest_TC_SWDIAG_3_1_000000_WaitForCommissionee WaitForCommissionee(expectation, queue); [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_SWDIAG_3_1_000001_ReadAttribute +- (void)testSendClusterTest_TC_SWDIAG_3_1_000001_ResetWatermarks +{ + XCTestExpectation * expectation = [self expectationWithDescription:@"Sends ResetWatermarks to DUT"]; + + CHIPDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:0 queue:queue]; + XCTAssertNotNil(cluster); + + [cluster resetWatermarksWithCompletionHandler:^(NSError * _Nullable err) { + NSLog(@"Sends ResetWatermarks to DUT Error: %@", err); + + XCTAssertEqual([CHIPErrorTestUtils errorToZCLErrorCode:err], 0); + + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} +- (void)testSendClusterTest_TC_SWDIAG_3_1_000002_ReadAttribute { XCTestExpectation * expectation = [self expectationWithDescription:@"Reads CurrentHeapUsed attribute value from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:1 queue:queue]; + CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:0 queue:queue]; XCTAssertNotNil(cluster); [cluster readAttributeCurrentHeapUsedWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { @@ -42678,13 +42679,13 @@ - (void)testSendClusterTest_TC_SWDIAG_3_1_000001_ReadAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterTest_TC_SWDIAG_3_1_000002_ReadAttribute +- (void)testSendClusterTest_TC_SWDIAG_3_1_000003_ReadAttribute { XCTestExpectation * expectation = [self expectationWithDescription:@"Reads CurrentHeapHighWaterMark attribute value from DUT"]; CHIPDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:1 queue:queue]; + CHIPTestSoftwareDiagnostics * cluster = [[CHIPTestSoftwareDiagnostics alloc] initWithDevice:device endpoint:0 queue:queue]; XCTAssertNotNil(cluster); [cluster readAttributeCurrentHeapHighWatermarkWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { diff --git a/src/test_driver/linux-cirque/MobileDeviceTest.py b/src/test_driver/linux-cirque/MobileDeviceTest.py index ac95881b8e41cd..20fb5022a9cb98 100755 --- a/src/test_driver/linux-cirque/MobileDeviceTest.py +++ b/src/test_driver/linux-cirque/MobileDeviceTest.py @@ -118,7 +118,7 @@ def run_controller_test(self): "Toggle on/off from 0 to 1", "Received command for Endpoint=1 Cluster=0x0000_0006 Command=0x0000_0000", "Toggle on/off from 1 to 0", - "No Cluster 0x0000_0006 on Endpoint 0xe9"]), + "No command 0x0000_0001 in Cluster 0x0000_0006 on Endpoint 0xe9"]), "Datamodel test failed: cannot find matching string from device {}".format(device_id)) diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 3dce5ddec4cd69..69344067e3912f 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -40758,12 +40758,8 @@ class Test_TC_WIFIDIAG_1_1 : public TestCommand err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Reads CurrentMaxRate attribute from DUT\n"); - err = TestReadsCurrentMaxRateAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Reads CurrentMaxRate attribute constraints\n"); - err = TestReadsCurrentMaxRateAttributeConstraints_2(); + ChipLogProgress(chipTool, " ***** Test Step 1 : Reads NetworkInterface structure attribute from DUT\n"); + err = TestReadsNetworkInterfaceStructureAttributeFromDut_1(); break; } @@ -40776,7 +40772,7 @@ class Test_TC_WIFIDIAG_1_1 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; + const uint16_t mTestCount = 2; chip::Optional mCluster; chip::Optional mEndpoint; @@ -40786,19 +40782,12 @@ class Test_TC_WIFIDIAG_1_1 : public TestCommand (static_cast(context))->OnFailureResponse_1(error); } - static void OnSuccessCallback_1(void * context, uint64_t currentMaxRate) - { - (static_cast(context))->OnSuccessResponse_1(currentMaxRate); - } - - static void OnFailureCallback_2(void * context, CHIP_ERROR error) - { - (static_cast(context))->OnFailureResponse_2(error); - } - - static void OnSuccessCallback_2(void * context, uint64_t currentMaxRate) + static void OnSuccessCallback_1( + void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterfaceType::DecodableType> & networkInterfaces) { - (static_cast(context))->OnSuccessResponse_2(currentMaxRate); + (static_cast(context))->OnSuccessResponse_1(networkInterfaces); } // @@ -40811,14 +40800,14 @@ class Test_TC_WIFIDIAG_1_1 : public TestCommand return WaitForCommissionee(); } - CHIP_ERROR TestReadsCurrentMaxRateAttributeFromDut_1() + CHIP_ERROR TestReadsNetworkInterfaceStructureAttributeFromDut_1() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - chip::Controller::WiFiNetworkDiagnosticsClusterTest cluster; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::GeneralDiagnosticsClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure( - cluster.ReadAttribute( + cluster.ReadAttribute( this, OnSuccessCallback_1, OnFailureCallback_1)); return CHIP_NO_ERROR; } @@ -40826,37 +40815,14 @@ class Test_TC_WIFIDIAG_1_1 : public TestCommand void OnFailureResponse_1(CHIP_ERROR error) { chip::app::StatusIB status(error); - (status.mStatus == chip::Protocols::InteractionModel::Status::UnsupportedAttribute) ? NextTest() : ThrowFailureResponse(); - } - - void OnSuccessResponse_1(uint64_t currentMaxRate) - { - VerifyOrReturn(CheckValue("currentMaxRate", currentMaxRate, 0ULL)); - - NextTest(); - } - - CHIP_ERROR TestReadsCurrentMaxRateAttributeConstraints_2() - { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; - chip::Controller::WiFiNetworkDiagnosticsClusterTest cluster; - cluster.Associate(mDevices[kIdentityAlpha], endpoint); - - ReturnErrorOnFailure( - cluster.ReadAttribute( - this, OnSuccessCallback_2, OnFailureCallback_2)); - return CHIP_NO_ERROR; - } - - void OnFailureResponse_2(CHIP_ERROR error) - { - chip::app::StatusIB status(error); - (status.mStatus == chip::Protocols::InteractionModel::Status::UnsupportedAttribute) ? NextTest() : ThrowFailureResponse(); + ThrowFailureResponse(); } - void OnSuccessResponse_2(uint64_t currentMaxRate) + void + OnSuccessResponse_1(const chip::app::DataModel::DecodableList< + chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterfaceType::DecodableType> & networkInterfaces) { - VerifyOrReturn(CheckConstraintType("currentMaxRate", "", "uint64")); + VerifyOrReturn(CheckConstraintType("networkInterfaces", "", "list")); NextTest(); } }; @@ -56705,7 +56671,7 @@ class TestCluster : public TestCommand void OnFailureResponse_144(CHIP_ERROR error) { chip::app::StatusIB status(error); - VerifyOrReturn(CheckConstraintNotValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); NextTest(); } @@ -56733,7 +56699,7 @@ class TestCluster : public TestCommand void OnFailureResponse_145(CHIP_ERROR error) { chip::app::StatusIB status(error); - VerifyOrReturn(CheckConstraintNotValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); NextTest(); } @@ -62527,7 +62493,7 @@ class TestCluster : public TestCommand void OnFailureResponse_360(CHIP_ERROR error) { chip::app::StatusIB status(error); - VerifyOrReturn(CheckConstraintNotValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); NextTest(); } @@ -62547,7 +62513,7 @@ class TestCluster : public TestCommand void OnFailureResponse_361(CHIP_ERROR error) { chip::app::StatusIB status(error); - VerifyOrReturn(CheckConstraintNotValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); NextTest(); } @@ -73040,26 +73006,35 @@ class Test_TC_SWDIAG_1_1 : public TestCommand err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Reads CurrentHeapFree non-global attribute value from DUT\n"); - err = TestReadsCurrentHeapFreeNonGlobalAttributeValueFromDut_1(); + ChipLogProgress(chipTool, " ***** Test Step 1 : Reads a list of ThreadMetrics struct non-global attribute from DUT.\n"); + if (ShouldSkip("A_THREADMETRICS")) + { + NextTest(); + return; + } + err = TestReadsAListOfThreadMetricsStructNonGlobalAttributeFromDut_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Reads CurrentHeapUsed non-global attribute value from DUT\n"); + ChipLogProgress(chipTool, " ***** Test Step 2 : Reads CurrentHeapFree non-global attribute value from DUT\n"); + err = TestReadsCurrentHeapFreeNonGlobalAttributeValueFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Reads CurrentHeapUsed non-global attribute value from DUT\n"); if (ShouldSkip("A_CURRENTHEAPUSED")) { NextTest(); return; } - err = TestReadsCurrentHeapUsedNonGlobalAttributeValueFromDut_2(); + err = TestReadsCurrentHeapUsedNonGlobalAttributeValueFromDut_3(); break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Reads CurrentHeapHighWaterMark non-global attribute value from DUT\n"); + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Reads CurrentHeapHighWaterMark non-global attribute value from DUT\n"); if (ShouldSkip("A_CURRENTHEAPHIGHWATERMARK")) { NextTest(); return; } - err = TestReadsCurrentHeapHighWaterMarkNonGlobalAttributeValueFromDut_3(); + err = TestReadsCurrentHeapHighWaterMarkNonGlobalAttributeValueFromDut_4(); break; } @@ -73072,7 +73047,7 @@ class Test_TC_SWDIAG_1_1 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; + const uint16_t mTestCount = 5; chip::Optional mCluster; chip::Optional mEndpoint; @@ -73082,9 +73057,12 @@ class Test_TC_SWDIAG_1_1 : public TestCommand (static_cast(context))->OnFailureResponse_1(error); } - static void OnSuccessCallback_1(void * context, uint64_t currentHeapFree) + static void OnSuccessCallback_1( + void * context, + const chip::app::DataModel::DecodableList & + threadMetrics) { - (static_cast(context))->OnSuccessResponse_1(currentHeapFree); + (static_cast(context))->OnSuccessResponse_1(threadMetrics); } static void OnFailureCallback_2(void * context, CHIP_ERROR error) @@ -73092,9 +73070,9 @@ class Test_TC_SWDIAG_1_1 : public TestCommand (static_cast(context))->OnFailureResponse_2(error); } - static void OnSuccessCallback_2(void * context, uint64_t currentHeapUsed) + static void OnSuccessCallback_2(void * context, uint64_t currentHeapFree) { - (static_cast(context))->OnSuccessResponse_2(currentHeapUsed); + (static_cast(context))->OnSuccessResponse_2(currentHeapFree); } static void OnFailureCallback_3(void * context, CHIP_ERROR error) @@ -73102,9 +73080,19 @@ class Test_TC_SWDIAG_1_1 : public TestCommand (static_cast(context))->OnFailureResponse_3(error); } - static void OnSuccessCallback_3(void * context, uint64_t currentHeapHighWatermark) + static void OnSuccessCallback_3(void * context, uint64_t currentHeapUsed) + { + (static_cast(context))->OnSuccessResponse_3(currentHeapUsed); + } + + static void OnFailureCallback_4(void * context, CHIP_ERROR error) + { + (static_cast(context))->OnFailureResponse_4(error); + } + + static void OnSuccessCallback_4(void * context, uint64_t currentHeapHighWatermark) { - (static_cast(context))->OnSuccessResponse_3(currentHeapHighWatermark); + (static_cast(context))->OnSuccessResponse_4(currentHeapHighWatermark); } // @@ -73117,71 +73105,96 @@ class Test_TC_SWDIAG_1_1 : public TestCommand return WaitForCommissionee(); } - CHIP_ERROR TestReadsCurrentHeapFreeNonGlobalAttributeValueFromDut_1() + CHIP_ERROR TestReadsAListOfThreadMetricsStructNonGlobalAttributeFromDut_1() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; chip::Controller::SoftwareDiagnosticsClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); - ReturnErrorOnFailure(cluster.ReadAttribute( + ReturnErrorOnFailure(cluster.ReadAttribute( this, OnSuccessCallback_1, OnFailureCallback_1)); return CHIP_NO_ERROR; } void OnFailureResponse_1(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_1( + const chip::app::DataModel::DecodableList & + threadMetrics) + { + + NextTest(); + } + + CHIP_ERROR TestReadsCurrentHeapFreeNonGlobalAttributeValueFromDut_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + chip::Controller::SoftwareDiagnosticsClusterTest cluster; + cluster.Associate(mDevices[kIdentityAlpha], endpoint); + + ReturnErrorOnFailure(cluster.ReadAttribute( + this, OnSuccessCallback_2, OnFailureCallback_2)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_2(CHIP_ERROR error) { chip::app::StatusIB status(error); (status.mStatus == chip::Protocols::InteractionModel::Status::UnsupportedAttribute) ? NextTest() : ThrowFailureResponse(); } - void OnSuccessResponse_1(uint64_t currentHeapFree) + void OnSuccessResponse_2(uint64_t currentHeapFree) { VerifyOrReturn(CheckConstraintType("currentHeapFree", "", "uint64")); NextTest(); } - CHIP_ERROR TestReadsCurrentHeapUsedNonGlobalAttributeValueFromDut_2() + CHIP_ERROR TestReadsCurrentHeapUsedNonGlobalAttributeValueFromDut_3() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; chip::Controller::SoftwareDiagnosticsClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_2, OnFailureCallback_2)); + this, OnSuccessCallback_3, OnFailureCallback_3)); return CHIP_NO_ERROR; } - void OnFailureResponse_2(CHIP_ERROR error) + void OnFailureResponse_3(CHIP_ERROR error) { chip::app::StatusIB status(error); (status.mStatus == chip::Protocols::InteractionModel::Status::UnsupportedAttribute) ? NextTest() : ThrowFailureResponse(); } - void OnSuccessResponse_2(uint64_t currentHeapUsed) + void OnSuccessResponse_3(uint64_t currentHeapUsed) { VerifyOrReturn(CheckConstraintType("currentHeapUsed", "", "uint64")); NextTest(); } - CHIP_ERROR TestReadsCurrentHeapHighWaterMarkNonGlobalAttributeValueFromDut_3() + CHIP_ERROR TestReadsCurrentHeapHighWaterMarkNonGlobalAttributeValueFromDut_4() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; chip::Controller::SoftwareDiagnosticsClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure( cluster.ReadAttribute( - this, OnSuccessCallback_3, OnFailureCallback_3)); + this, OnSuccessCallback_4, OnFailureCallback_4)); return CHIP_NO_ERROR; } - void OnFailureResponse_3(CHIP_ERROR error) + void OnFailureResponse_4(CHIP_ERROR error) { chip::app::StatusIB status(error); (status.mStatus == chip::Protocols::InteractionModel::Status::UnsupportedAttribute) ? NextTest() : ThrowFailureResponse(); } - void OnSuccessResponse_3(uint64_t currentHeapHighWatermark) + void OnSuccessResponse_4(uint64_t currentHeapHighWatermark) { VerifyOrReturn(CheckConstraintType("currentHeapHighWatermark", "", "uint64")); NextTest(); @@ -73288,22 +73301,31 @@ class Test_TC_SWDIAG_3_1 : public TestCommand err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Reads CurrentHeapUsed attribute value from DUT\n"); - if (ShouldSkip("A_CURRENTHEAPUSED")) + ChipLogProgress(chipTool, " ***** Test Step 1 : Sends ResetWatermarks to DUT\n"); + if (ShouldSkip("CR_RESETWATERMARKS")) { NextTest(); return; } - err = TestReadsCurrentHeapUsedAttributeValueFromDut_1(); + err = TestSendsResetWatermarksToDut_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Reads CurrentHeapHighWaterMark attribute value from DUT\n"); + ChipLogProgress(chipTool, " ***** Test Step 2 : Reads CurrentHeapUsed attribute value from DUT\n"); + if (ShouldSkip("A_CURRENTHEAPUSED")) + { + NextTest(); + return; + } + err = TestReadsCurrentHeapUsedAttributeValueFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Reads CurrentHeapHighWaterMark attribute value from DUT\n"); if (ShouldSkip("A_CURRENTHEAPHIGHWATERMARK")) { NextTest(); return; } - err = TestReadsCurrentHeapHighWaterMarkAttributeValueFromDut_2(); + err = TestReadsCurrentHeapHighWaterMarkAttributeValueFromDut_3(); break; } @@ -73316,29 +73338,29 @@ class Test_TC_SWDIAG_3_1 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; + const uint16_t mTestCount = 4; chip::Optional mCluster; chip::Optional mEndpoint; - static void OnFailureCallback_1(void * context, CHIP_ERROR error) + static void OnFailureCallback_2(void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_1(error); + (static_cast(context))->OnFailureResponse_2(error); } - static void OnSuccessCallback_1(void * context, uint64_t currentHeapUsed) + static void OnSuccessCallback_2(void * context, uint64_t currentHeapUsed) { - (static_cast(context))->OnSuccessResponse_1(currentHeapUsed); + (static_cast(context))->OnSuccessResponse_2(currentHeapUsed); } - static void OnFailureCallback_2(void * context, CHIP_ERROR error) + static void OnFailureCallback_3(void * context, CHIP_ERROR error) { - (static_cast(context))->OnFailureResponse_2(error); + (static_cast(context))->OnFailureResponse_3(error); } - static void OnSuccessCallback_2(void * context, uint64_t currentHeapHighWatermark) + static void OnSuccessCallback_3(void * context, uint64_t currentHeapHighWatermark) { - (static_cast(context))->OnSuccessResponse_2(currentHeapHighWatermark); + (static_cast(context))->OnSuccessResponse_3(currentHeapHighWatermark); } // @@ -73351,49 +73373,76 @@ class Test_TC_SWDIAG_3_1 : public TestCommand return WaitForCommissionee(); } - CHIP_ERROR TestReadsCurrentHeapUsedAttributeValueFromDut_1() + CHIP_ERROR TestSendsResetWatermarksToDut_1() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; + using RequestType = chip::app::Clusters::SoftwareDiagnostics::Commands::ResetWatermarks::Type; + + RequestType request; + + auto success = [](void * context, const typename RequestType::ResponseType & data) { + (static_cast(context))->OnSuccessResponse_1(); + }; + + auto failure = [](void * context, CHIP_ERROR error) { + (static_cast(context))->OnFailureResponse_1(error); + }; + + ReturnErrorOnFailure(chip::Controller::InvokeCommand(mDevices[kIdentityAlpha], this, success, failure, endpoint, request)); + return CHIP_NO_ERROR; + } + + void OnFailureResponse_1(CHIP_ERROR error) + { + chip::app::StatusIB status(error); + ThrowFailureResponse(); + } + + void OnSuccessResponse_1() { NextTest(); } + + CHIP_ERROR TestReadsCurrentHeapUsedAttributeValueFromDut_2() + { + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; chip::Controller::SoftwareDiagnosticsClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure(cluster.ReadAttribute( - this, OnSuccessCallback_1, OnFailureCallback_1)); + this, OnSuccessCallback_2, OnFailureCallback_2)); return CHIP_NO_ERROR; } - void OnFailureResponse_1(CHIP_ERROR error) + void OnFailureResponse_2(CHIP_ERROR error) { chip::app::StatusIB status(error); (status.mStatus == chip::Protocols::InteractionModel::Status::UnsupportedAttribute) ? NextTest() : ThrowFailureResponse(); } - void OnSuccessResponse_1(uint64_t currentHeapUsed) + void OnSuccessResponse_2(uint64_t currentHeapUsed) { VerifyOrReturn(CheckValue("currentHeapUsed", currentHeapUsed, 0ULL)); NextTest(); } - CHIP_ERROR TestReadsCurrentHeapHighWaterMarkAttributeValueFromDut_2() + CHIP_ERROR TestReadsCurrentHeapHighWaterMarkAttributeValueFromDut_3() { - const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 1; + const chip::EndpointId endpoint = mEndpoint.HasValue() ? mEndpoint.Value() : 0; chip::Controller::SoftwareDiagnosticsClusterTest cluster; cluster.Associate(mDevices[kIdentityAlpha], endpoint); ReturnErrorOnFailure( cluster.ReadAttribute( - this, OnSuccessCallback_2, OnFailureCallback_2)); + this, OnSuccessCallback_3, OnFailureCallback_3)); return CHIP_NO_ERROR; } - void OnFailureResponse_2(CHIP_ERROR error) + void OnFailureResponse_3(CHIP_ERROR error) { chip::app::StatusIB status(error); (status.mStatus == chip::Protocols::InteractionModel::Status::UnsupportedAttribute) ? NextTest() : ThrowFailureResponse(); } - void OnSuccessResponse_2(uint64_t currentHeapHighWatermark) + void OnSuccessResponse_3(uint64_t currentHeapHighWatermark) { VerifyOrReturn(CheckValue("currentHeapHighWatermark", currentHeapHighWatermark, 0ULL)); From d3c24ea01f2d5c061fb3c0372380e9e7b8b1c5bb Mon Sep 17 00:00:00 2001 From: Ricardo Casallas <77841255+rcasallas-silabs@users.noreply.github.com> Date: Mon, 7 Feb 2022 15:16:27 -0500 Subject: [PATCH 10/12] Group Cryptography: Bugs fixed (#14796) * Group Cryptography: Bugs fixed * Keys stored incorrectly * LWIP decryption failure * Group Cryptography: Bugs fixed: Review comments applied. --- src/credentials/GroupDataProviderImpl.cpp | 23 +++++++++--------- src/credentials/GroupDataProviderImpl.h | 8 +++---- .../tests/TestGroupDataProvider.cpp | 20 +++++++--------- src/crypto/CHIPCryptoPAL.h | 24 +++++++++++-------- src/transport/CryptoContext.cpp | 10 ++++---- 5 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/credentials/GroupDataProviderImpl.cpp b/src/credentials/GroupDataProviderImpl.cpp index 4739ebe9e39034..06d9ad42dd0b9d 100644 --- a/src/credentials/GroupDataProviderImpl.cpp +++ b/src/credentials/GroupDataProviderImpl.cpp @@ -1606,12 +1606,10 @@ CHIP_ERROR GroupDataProviderImpl::SetKeySet(chip::FabricIndex fabric_index, cons for (size_t i = 0; i < in_keyset.num_keys_used; ++i) { ByteSpan epoch_key(in_keyset.epoch_keys[i].key, Crypto::CHIP_CRYPTO_SYMMETRIC_KEY_LENGTH_BYTES); - uint8_t key[Crypto::CHIP_CRYPTO_SYMMETRIC_KEY_LENGTH_BYTES]; - MutableByteSpan key_span(key, sizeof(key)); + MutableByteSpan key_span(keyset.operational_keys[i].value); ReturnErrorOnFailure(Crypto::DeriveGroupOperationalKey(epoch_key, key_span)); - ReturnErrorOnFailure(Crypto::DeriveGroupSessionId(ByteSpan(key, sizeof(key)), keyset.operational_keys[i].hash)); + ReturnErrorOnFailure(Crypto::DeriveGroupSessionId(key_span, keyset.operational_keys[i].hash)); } - if (found) { // Update existing keyset info, keep next @@ -1817,19 +1815,20 @@ void GroupDataProviderImpl::GroupKeyContext::Release() mProvider.mKeyContexPool.ReleaseObject(this); } -CHIP_ERROR GroupDataProviderImpl::GroupKeyContext::EncryptMessage(MutableByteSpan & plaintext, const ByteSpan & aad, - const ByteSpan & nonce, MutableByteSpan & out_mic) const +CHIP_ERROR GroupDataProviderImpl::GroupKeyContext::EncryptMessage(const ByteSpan & plaintext, const ByteSpan & aad, + const ByteSpan & nonce, MutableByteSpan & mic, + MutableByteSpan & ciphertext) const { - uint8_t * output = plaintext.data(); + uint8_t * output = ciphertext.data(); return Crypto::AES_CCM_encrypt(plaintext.data(), plaintext.size(), aad.data(), aad.size(), mKeyValue, - Crypto::kAES_CCM128_Key_Length, nonce.data(), nonce.size(), output, out_mic.data(), - out_mic.size()); + Crypto::kAES_CCM128_Key_Length, nonce.data(), nonce.size(), output, mic.data(), mic.size()); } -CHIP_ERROR GroupDataProviderImpl::GroupKeyContext::DecryptMessage(MutableByteSpan & ciphertext, const ByteSpan & aad, - const ByteSpan & nonce, const ByteSpan & mic) const +CHIP_ERROR GroupDataProviderImpl::GroupKeyContext::DecryptMessage(const ByteSpan & ciphertext, const ByteSpan & aad, + const ByteSpan & nonce, const ByteSpan & mic, + MutableByteSpan & plaintext) const { - uint8_t * output = ciphertext.data(); + uint8_t * output = plaintext.data(); return Crypto::AES_CCM_decrypt(ciphertext.data(), ciphertext.size(), aad.data(), aad.size(), mic.data(), mic.size(), mKeyValue, Crypto::kAES_CCM128_Key_Length, nonce.data(), nonce.size(), output); } diff --git a/src/credentials/GroupDataProviderImpl.h b/src/credentials/GroupDataProviderImpl.h index 90aea6fa10422c..34a9bcf64bd24b 100644 --- a/src/credentials/GroupDataProviderImpl.h +++ b/src/credentials/GroupDataProviderImpl.h @@ -158,10 +158,10 @@ class GroupDataProviderImpl : public GroupDataProvider uint16_t GetKeyHash() override { return mKeyHash; } - CHIP_ERROR EncryptMessage(MutableByteSpan & plaintext, const ByteSpan & aad, const ByteSpan & nonce, - MutableByteSpan & out_mic) const override; - CHIP_ERROR DecryptMessage(MutableByteSpan & ciphertext, const ByteSpan & aad, const ByteSpan & nonce, - const ByteSpan & mic) const override; + CHIP_ERROR EncryptMessage(const ByteSpan & plaintext, const ByteSpan & aad, const ByteSpan & nonce, MutableByteSpan & mic, + MutableByteSpan & ciphertext) const override; + CHIP_ERROR DecryptMessage(const ByteSpan & ciphertext, const ByteSpan & aad, const ByteSpan & nonce, const ByteSpan & mic, + MutableByteSpan & plaintext) const override; CHIP_ERROR EncryptPrivacy(MutableByteSpan & header, uint16_t session_id, const ByteSpan & payload, const ByteSpan & mic) const override; CHIP_ERROR DecryptPrivacy(MutableByteSpan & header, uint16_t session_id, const ByteSpan & payload, diff --git a/src/credentials/tests/TestGroupDataProvider.cpp b/src/credentials/tests/TestGroupDataProvider.cpp index 8353b6c2fb9e4a..dc33cfd2294584 100644 --- a/src/credentials/tests/TestGroupDataProvider.cpp +++ b/src/credentials/tests/TestGroupDataProvider.cpp @@ -1050,7 +1050,7 @@ void TestGroupDecryption(nlTestSuite * apSuite, void * apContext) // // Load the plaintext to encrypt - memcpy(ciphertext_buffer, kMessage, sizeof(kMessage)); + memcpy(plaintext_buffer, kMessage, sizeof(kMessage)); // Get the key context Crypto::SymmetricKeyContext * key_context = provider->GetKeyContext(kFabric2, kGroup2); @@ -1058,9 +1058,10 @@ void TestGroupDecryption(nlTestSuite * apSuite, void * apContext) uint16_t session_id = key_context->GetKeyHash(); // Encrypt the message - NL_TEST_ASSERT(apSuite, - CHIP_NO_ERROR == - key_context->EncryptMessage(ciphertext, ByteSpan(aad, sizeof(aad)), ByteSpan(nonce, sizeof(nonce)), tag)); + NL_TEST_ASSERT( + apSuite, + CHIP_NO_ERROR == + key_context->EncryptMessage(plaintext, ByteSpan(aad, sizeof(aad)), ByteSpan(nonce, sizeof(nonce)), tag, ciphertext)); // The ciphertext must be different to the original message NL_TEST_ASSERT(apSuite, memcmp(ciphertext.data(), kMessage, sizeof(kMessage))); @@ -1088,14 +1089,11 @@ void TestGroupDecryption(nlTestSuite * apSuite, void * apContext) NL_TEST_ASSERT(apSuite, expected.count(found) > 0); NL_TEST_ASSERT(apSuite, session.key != nullptr); - // Load ciphertext to decrypt - memcpy(plaintext_buffer, ciphertext_buffer, sizeof(plaintext_buffer)); - // Decrypt de ciphertext - NL_TEST_ASSERT( - apSuite, - CHIP_NO_ERROR == - session.key->DecryptMessage(plaintext, ByteSpan(aad, sizeof(aad)), ByteSpan(nonce, sizeof(nonce)), tag)); + NL_TEST_ASSERT(apSuite, + CHIP_NO_ERROR == + session.key->DecryptMessage(ciphertext, ByteSpan(aad, sizeof(aad)), ByteSpan(nonce, sizeof(nonce)), + tag, plaintext)); // The new plaintext must match the original message NL_TEST_ASSERT(apSuite, 0 == memcmp(plaintext.data(), kMessage, sizeof(kMessage))); diff --git a/src/crypto/CHIPCryptoPAL.h b/src/crypto/CHIPCryptoPAL.h index 6367ae2698dce8..f560ae676b6983 100644 --- a/src/crypto/CHIPCryptoPAL.h +++ b/src/crypto/CHIPCryptoPAL.h @@ -1356,24 +1356,28 @@ class SymmetricKeyContext virtual ~SymmetricKeyContext() = default; /** * @brief Perform the message encryption as described in 4.7.2. (Security Processing of Outgoing Messages) - * @param[in,out] plaintext Outgoing message payload. + * @param[in] plaintext Outgoing message payload. * @param[in] aad Additional data (message header contents) * @param[in] nonce Nonce (Security Flags | Message Counter | Source Node ID) - * @param[out] out_mic Outgoing Message Integrity Check + * @param[out] mic Outgoing Message Integrity Check + * @param[out] ciphertext Outgoing encrypted payload. Must be at least as big as plaintext. The same buffer may be used both + * for ciphertext, and plaintext. * @return CHIP_ERROR */ - virtual CHIP_ERROR EncryptMessage(MutableByteSpan & plaintext, const ByteSpan & aad, const ByteSpan & nonce, - MutableByteSpan & out_mic) const = 0; + virtual CHIP_ERROR EncryptMessage(const ByteSpan & plaintext, const ByteSpan & aad, const ByteSpan & nonce, + MutableByteSpan & mic, MutableByteSpan & ciphertext) const = 0; /** * @brief Perform the message decryption as described in 4.7.3.(Security Processing of Incoming Messages) - * @param[in,out] ciphertext Incoming encrypted payload - * @param[in] aad Additional data (message header contents) - * @param[in] nonce Nonce (Security Flags | Message Counter | Source Node ID) - * @param[in] mic Incoming Message Integrity Check + * @param[in] ciphertext Incoming encrypted payload + * @param[in] aad Additional data (message header contents) + * @param[in] nonce Nonce (Security Flags | Message Counter | Source Node ID) + * @param[in] mic Incoming Message Integrity Check + * @param[out] plaintext Incoming message payload. Must be at least as big as ciphertext. The same buffer may be used both + * for plaintext, and ciphertext. * @return CHIP_ERROR */ - virtual CHIP_ERROR DecryptMessage(MutableByteSpan & ciphertext, const ByteSpan & aad, const ByteSpan & nonce, - const ByteSpan & mic) const = 0; + virtual CHIP_ERROR DecryptMessage(const ByteSpan & ciphertext, const ByteSpan & aad, const ByteSpan & nonce, + const ByteSpan & mic, MutableByteSpan & plaintext) const = 0; /** * @brief Perform privacy encoding as described in 4.8.2. (Privacy Processing of Outgoing Messages) diff --git a/src/transport/CryptoContext.cpp b/src/transport/CryptoContext.cpp index fd88f1bf123c8d..3481d33de75e60 100644 --- a/src/transport/CryptoContext.cpp +++ b/src/transport/CryptoContext.cpp @@ -183,10 +183,11 @@ CHIP_ERROR CryptoContext::Encrypt(const uint8_t * input, size_t input_length, ui if (mKeyContext) { - MutableByteSpan plaintext(output, input_length); // WARNING: ASSUMES IN-PLACE ENCRYPTION + ByteSpan plaintext(input, input_length); + MutableByteSpan ciphertext(output, input_length); MutableByteSpan mic(tag, taglen); - ReturnErrorOnFailure(mKeyContext->EncryptMessage(plaintext, ByteSpan(AAD, aadLen), ByteSpan(IV), mic)); + ReturnErrorOnFailure(mKeyContext->EncryptMessage(plaintext, ByteSpan(AAD, aadLen), ByteSpan(IV), mic, ciphertext)); } else { @@ -228,10 +229,11 @@ CHIP_ERROR CryptoContext::Decrypt(const uint8_t * input, size_t input_length, ui if (nullptr != mKeyContext) { - MutableByteSpan ciphertext(output, input_length); // WARNING: ASSUMES input == output + ByteSpan ciphertext(input, input_length); + MutableByteSpan plaintext(output, input_length); ByteSpan mic(tag, taglen); - CHIP_ERROR err = mKeyContext->DecryptMessage(ciphertext, ByteSpan(AAD, aadLen), ByteSpan(IV), mic); + CHIP_ERROR err = mKeyContext->DecryptMessage(ciphertext, ByteSpan(AAD, aadLen), ByteSpan(IV), mic, plaintext); ReturnErrorOnFailure(err); } else From 566402a02b29ebebfcebcbdb279a32087ad68468 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Mon, 7 Feb 2022 12:20:23 -0800 Subject: [PATCH 11/12] Update .pullapprove.yml Move reviewers back to 2. --- .pullapprove.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pullapprove.yml b/.pullapprove.yml index 6ff715781a4716..f9da0a4be5ab3b 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -164,7 +164,7 @@ groups: requests. type: required requirements: - - len(groups.approved.include('shared-reviewers-*')) >= 3 + - len(groups.approved.include('shared-reviewers-*')) >= 2 reviews: required: 0 labels: From 6f9fa8e80a9ada4ca7de38a0931c5b383658582a Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Tue, 8 Feb 2022 04:43:11 +0800 Subject: [PATCH 12/12] [binding] Reduce binding manager size (#14303) * [binding] Reduce binding manager size The PR stores the pending notifications as a flat array of binding table indecies to recude the size of the BindingManager class. * remove test code * fix cmake build * fix review comments --- examples/all-clusters-app/mbed/CMakeLists.txt | 1 + examples/lighting-app/telink/CMakeLists.txt | 1 + src/app/chip_data_model.gni | 2 + src/app/clusters/bindings/BindingManager.cpp | 148 ++++++----------- src/app/clusters/bindings/BindingManager.h | 114 +------------ .../bindings/PendingNotificationMap.cpp | 152 ++++++++++++++++++ .../bindings/PendingNotificationMap.h | 85 ++++++++++ src/app/clusters/bindings/bindings.cpp | 33 +--- src/app/util/binding-table.h | 3 - 9 files changed, 304 insertions(+), 235 deletions(-) create mode 100644 src/app/clusters/bindings/PendingNotificationMap.cpp create mode 100644 src/app/clusters/bindings/PendingNotificationMap.h diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index cda04bca5e6733..a28dd60017e677 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -84,6 +84,7 @@ target_sources(${APP_TARGET} PRIVATE ${APP_CLUSTERS}/basic/basic.cpp ${APP_CLUSTERS}/bindings/BindingManager.cpp ${APP_CLUSTERS}/bindings/bindings.cpp + ${APP_CLUSTERS}/bindings/PendingNotificationMap.cpp ${APP_CLUSTERS}/on-off-server/on-off-server.cpp ${APP_CLUSTERS}/access-control-server/access-control-server.cpp ${APP_CLUSTERS}/account-login-server/account-login-server.cpp diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index 94e98c8be5290f..3d1e3699383a8d 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -74,6 +74,7 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/clusters/basic/basic.cpp ${CHIP_ROOT}/src/app/clusters/bindings/BindingManager.cpp ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp + ${CHIP_ROOT}/src/app/clusters/bindings/PendingNotificationMap.cpp ${CHIP_ROOT}/src/app/clusters/descriptor/descriptor.cpp ${CHIP_ROOT}/src/app/clusters/identify-server/identify-server.cpp ${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 650b375145f69d..109fa7dc85d0a0 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -148,6 +148,8 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/${cluster}.cpp", "${_app_root}/clusters/${cluster}/BindingManager.cpp", "${_app_root}/clusters/${cluster}/BindingManager.h", + "${_app_root}/clusters/${cluster}/PendingNotificationMap.cpp", + "${_app_root}/clusters/${cluster}/PendingNotificationMap.h", ] } else { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] diff --git a/src/app/clusters/bindings/BindingManager.cpp b/src/app/clusters/bindings/BindingManager.cpp index 74ff018c7a8111..d1622042bb37cc 100644 --- a/src/app/clusters/bindings/BindingManager.cpp +++ b/src/app/clusters/bindings/BindingManager.cpp @@ -49,10 +49,37 @@ BindingFabricTableDelegate gFabricTableDelegate; } // namespace +namespace { + +chip::PeerId PeerIdForNode(chip::FabricTable & fabricTable, chip::FabricIndex fabric, chip::NodeId node) +{ + chip::FabricInfo * fabricInfo = fabricTable.FindFabricWithIndex(fabric); + if (fabricInfo == nullptr) + { + return chip::PeerId(); + } + return fabricInfo->GetPeerIdForNode(node); +} + +} // namespace + namespace chip { BindingManager BindingManager::sBindingManager; +CHIP_ERROR BindingManager::UnicastBindingCreated(const EmberBindingTableEntry & bindingEntry) +{ + return EstablishConnection(bindingEntry.fabricIndex, bindingEntry.nodeId); +} + +CHIP_ERROR BindingManager::UnicastBindingRemoved(uint8_t bindingEntryId) +{ + EmberBindingTableEntry entry{}; + emberGetBinding(bindingEntryId, &entry); + mPendingNotificationMap.RemoveEntry(bindingEntryId); + return CHIP_NO_ERROR; +} + void BindingManager::SetAppServer(Server * appServer) { mAppServer = appServer; @@ -63,9 +90,8 @@ CHIP_ERROR BindingManager::EstablishConnection(FabricIndex fabric, NodeId node) { VerifyOrReturnError(mAppServer != nullptr, CHIP_ERROR_INCORRECT_STATE); - FabricInfo * fabricInfo = mAppServer->GetFabricTable().FindFabricWithIndex(fabric); - VerifyOrReturnError(fabricInfo != nullptr, CHIP_ERROR_NOT_FOUND); - PeerId peer = fabricInfo->GetPeerIdForNode(node); + PeerId peer = PeerIdForNode(mAppServer->GetFabricTable(), fabric, node); + VerifyOrReturnError(peer.GetNodeId() != kUndefinedNodeId, CHIP_ERROR_NOT_FOUND); CHIP_ERROR error = mAppServer->GetCASESessionManager()->FindOrEstablishSession(peer, &mOnConnectedCallback, &mOnConnectionFailureCallback); if (error == CHIP_ERROR_NO_MEMORY) @@ -73,11 +99,13 @@ CHIP_ERROR BindingManager::EstablishConnection(FabricIndex fabric, NodeId node) // Release the least recently used entry // TODO: Some reference counting mechanism shall be added the CASESessionManager // so that other session clients don't get accidentally closed. - PendingNotificationEntry * entry = mPendingNotificationMap.FindLRUEntry(); - if (entry != nullptr) + FabricIndex fabricToRemove; + NodeId nodeToRemove; + if (mPendingNotificationMap.FindLRUConnectPeer(&fabricToRemove, &nodeToRemove) == CHIP_NO_ERROR) { - mAppServer->GetCASESessionManager()->ReleaseSession(entry->GetPeerId()); - mPendingNotificationMap.RemoveEntry(entry); + mPendingNotificationMap.RemoveAllEntriesForNode(fabricToRemove, nodeToRemove); + PeerId lruPeer = PeerIdForNode(mAppServer->GetFabricTable(), fabricToRemove, nodeToRemove); + mAppServer->GetCASESessionManager()->ReleaseSession(lruPeer); // Now retry error = mAppServer->GetCASESessionManager()->FindOrEstablishSession(peer, &mOnConnectedCallback, &mOnConnectionFailureCallback); @@ -94,33 +122,23 @@ void BindingManager::HandleDeviceConnected(void * context, OperationalDeviceProx void BindingManager::HandleDeviceConnected(OperationalDeviceProxy * device) { - mPendingNotificationMap.ForEachActiveObject([&](PendingNotificationEntry * entry) -> Loop { - if (entry->GetPeerId() == device->GetPeerId()) - { - SyncPendingNotificationsToPeer(device, entry); - } + FabricIndex fabricToRemove = kUndefinedFabricIndex; + NodeId nodeToRemove = kUndefinedNodeId; - return Loop::Continue; - }); -} - -void BindingManager::SyncPendingNotificationsToPeer(OperationalDeviceProxy * device, PendingNotificationEntry * pendingClusters) -{ - for (const ClusterPath & path : *pendingClusters) + for (const PendingNotificationEntry & pendingNotification : mPendingNotificationMap) { - ClusterId cluster = path.cluster; - EndpointId endpoint = path.endpoint; - for (uint8_t j = 0; j < EMBER_BINDING_TABLE_SIZE; j++) + EmberBindingTableEntry entry; + emberGetBinding(pendingNotification.mBindingEntryId, &entry); + + PeerId peer = PeerIdForNode(mAppServer->GetFabricTable(), entry.fabricIndex, entry.nodeId); + if (device->GetPeerId() == peer) { - EmberBindingTableEntry entry; - if (emberGetBinding(j, &entry) == EMBER_SUCCESS && entry.type == EMBER_UNICAST_BINDING && entry.clusterId == cluster && - entry.local == endpoint && mBoundDeviceChangedHandler) - { - mBoundDeviceChangedHandler(&entry, device, path.context); - } + fabricToRemove = entry.fabricIndex; + nodeToRemove = entry.nodeId; + mBoundDeviceChangedHandler(&entry, device, pendingNotification.mContext); } } - mPendingNotificationMap.RemoveEntry(pendingClusters); + mPendingNotificationMap.RemoveAllEntriesForNode(fabricToRemove, nodeToRemove); } void BindingManager::HandleDeviceConnectionFailure(void * context, PeerId peerId, CHIP_ERROR error) @@ -138,34 +156,10 @@ void BindingManager::HandleDeviceConnectionFailure(PeerId peerId, CHIP_ERROR err void BindingManager::FabricRemoved(CompressedFabricId compressedFabricId, FabricIndex fabricIndex) { - mPendingNotificationMap.ForEachActiveObject([&](PendingNotificationEntry * entry) { - if (entry->GetFabricIndex() == fabricIndex) - { - mPendingNotificationMap.RemoveEntry(entry); - return Loop::Break; - } - return Loop::Continue; - }); + mPendingNotificationMap.RemoveAllEntriesForFabric(fabricIndex); mAppServer->GetCASESessionManager()->ReleaseSessionForFabric(compressedFabricId); } -CHIP_ERROR BindingManager::LastUnicastBindingRemoved(FabricIndex fabricIndex, NodeId node) -{ - VerifyOrReturnError(mAppServer != nullptr, CHIP_ERROR_INCORRECT_STATE); - - FabricInfo * fabricInfo = mAppServer->GetFabricTable().FindFabricWithIndex(fabricIndex); - VerifyOrReturnError(fabricInfo != nullptr, CHIP_ERROR_NOT_FOUND); - PeerId peer = fabricInfo->GetPeerIdForNode(node); - PendingNotificationEntry * entry = mPendingNotificationMap.FindEntry(fabricIndex, node); - if (entry) - { - mPendingNotificationMap.RemoveEntry(entry); - } - - mAppServer->GetCASESessionManager()->ReleaseSession(peer); - return CHIP_NO_ERROR; -} - CHIP_ERROR BindingManager::NotifyBoundClusterChanged(EndpointId endpoint, ClusterId cluster, void * context) { VerifyOrReturnError(mAppServer != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -190,9 +184,7 @@ CHIP_ERROR BindingManager::NotifyBoundClusterChanged(EndpointId endpoint, Cluste } else { - // Enqueue pending cluster and establish connection - ReturnErrorOnFailure(mPendingNotificationMap.AddPendingNotification(entry.fabricIndex, entry.nodeId, endpoint, - cluster, context)); + mPendingNotificationMap.AddPendingNotification(i, context); ReturnErrorOnFailure(EstablishConnection(entry.fabricIndex, entry.nodeId)); } } @@ -205,46 +197,4 @@ CHIP_ERROR BindingManager::NotifyBoundClusterChanged(EndpointId endpoint, Cluste return CHIP_NO_ERROR; } -BindingManager::PendingNotificationEntry * BindingManager::PendingNotificationMap::FindLRUEntry() -{ - PendingNotificationEntry * lruEntry = nullptr; - mPendingNotificationMap.ForEachActiveObject([&](PendingNotificationEntry * entry) { - if (lruEntry == nullptr || lruEntry->GetLastUpdateTime() > entry->GetLastUpdateTime()) - { - lruEntry = entry; - } - return Loop::Continue; - }); - return lruEntry; -} - -BindingManager::PendingNotificationEntry * BindingManager::PendingNotificationMap::FindEntry(FabricIndex fabricIndex, NodeId node) -{ - PendingNotificationEntry * foundEntry = nullptr; - mPendingNotificationMap.ForEachActiveObject([&](PendingNotificationEntry * entry) { - if (entry->GetFabricIndex() == fabricIndex && entry->GetNodeId() == node) - { - foundEntry = entry; - return Loop::Break; - } - return Loop::Continue; - }); - return foundEntry; -} - -CHIP_ERROR BindingManager::PendingNotificationMap::AddPendingNotification(FabricIndex fabric, NodeId node, EndpointId endpoint, - ClusterId cluster, void * context) -{ - PendingNotificationEntry * entry = FindEntry(fabric, node); - - if (entry == nullptr) - { - entry = mPendingNotificationMap.CreateObject(fabric, node); - VerifyOrReturnError(entry != nullptr, CHIP_ERROR_NO_MEMORY); - } - entry->AddPendingNotification(endpoint, cluster, context); - entry->Touch(); - return CHIP_NO_ERROR; -} - } // namespace chip diff --git a/src/app/clusters/bindings/BindingManager.h b/src/app/clusters/bindings/BindingManager.h index fd0ade9d1f5772..eb87864a127085 100644 --- a/src/app/clusters/bindings/BindingManager.h +++ b/src/app/clusters/bindings/BindingManager.h @@ -18,6 +18,7 @@ #pragma once #include +#include #include #include @@ -53,8 +54,6 @@ using BoundDeviceChangedHandler = void (*)(const EmberBindingTableEntry * bindin */ class BindingManager { - friend class PendingNotificationEntry; - public: BindingManager() : mOnConnectedCallback(HandleDeviceConnected, this), mOnConnectionFailureCallback(HandleDeviceConnectionFailure, this) @@ -68,19 +67,19 @@ class BindingManager * Notifies the BindingManager that a new unicast binding is created. * */ - CHIP_ERROR UnicastBindingCreated(FabricIndex fabric, NodeId node) { return EstablishConnection(fabric, node); } + CHIP_ERROR UnicastBindingCreated(const EmberBindingTableEntry & bindingEntry); /* - * Notifies the BindingManager that a fabric is removed from the device + * Notifies the BindingManager that a unicast binding is about to be removed from the given index. * */ - void FabricRemoved(CompressedFabricId compressedId, FabricIndex fabricIndex); + CHIP_ERROR UnicastBindingRemoved(uint8_t bindingEntryId); /* - * Notfies the BindingManager that the **last** unicast binding to a device has been removed. + * Notifies the BindingManager that a fabric is removed from the device * */ - CHIP_ERROR LastUnicastBindingRemoved(FabricIndex fabricIndex, NodeId node); + void FabricRemoved(CompressedFabricId compressedId, FabricIndex fabricIndex); /* * Notify a cluster change to **all** bound devices associated with the (endpoint, cluster) tuple. @@ -99,104 +98,6 @@ class BindingManager private: static BindingManager sBindingManager; - static constexpr uint8_t kMaxPendingNotifications = 3; - - struct ClusterPath - { - void * context; - ClusterId cluster; - EndpointId endpoint; - }; - - // A pending notification to be sent to a binding waiting for the CASE session to be established. - class PendingNotificationEntry - { - public: - PendingNotificationEntry(FabricIndex fabricIndex, NodeId node) : mNodeId(node), mFabricIndex(fabricIndex) {} - - PeerId GetPeerId() - { - PeerId peer; - if (BindingManager::GetInstance().mAppServer == nullptr) - { - return peer; - } - FabricInfo * fabric = BindingManager::GetInstance().mAppServer->GetFabricTable().FindFabricWithIndex(mFabricIndex); - if (fabric == nullptr) - { - return peer; - } - return fabric->GetPeerIdForNode(mNodeId); - } - - NodeId GetNodeId() { return mNodeId; } - - FabricIndex GetFabricIndex() { return mFabricIndex; } - - System::Clock::Timestamp GetLastUpdateTime() { return mLastUpdateTime; } - void Touch() { mLastUpdateTime = System::SystemClock().GetMonotonicTimestamp(); } - - ClusterPath * begin() { return &mPendingNotifications[0]; } - ClusterPath * end() { return &mPendingNotifications[mNumPendingNotifications]; } - - void AddPendingNotification(EndpointId endpoint, ClusterId cluster, void * context) - { - for (ClusterPath & path : *this) - { - // New notifications for the same (endpoint, cluster) shall - // simply overrride the old ones - if (path.cluster == cluster && path.endpoint == endpoint) - { - path.context = context; - return; - } - } - if (mNumPendingNotifications < kMaxPendingNotifications) - { - mPendingNotifications[mNumPendingNotifications++] = { context, cluster, endpoint }; - } - else - { - mPendingNotifications[mNextToOverride] = { context, cluster, endpoint }; - mNextToOverride++; - mNextToOverride %= kMaxPendingNotifications; - } - } - - private: - System::Clock::Timestamp mLastUpdateTime; - // TODO: Make the pending notifications list of binding table indecies and list of contexts - ClusterPath mPendingNotifications[kMaxPendingNotifications]; - - NodeId mNodeId; - uint8_t mNumPendingNotifications = 0; - uint8_t mNextToOverride = 0; - FabricIndex mFabricIndex; - }; - - // The pool for all the pending comands. - class PendingNotificationMap - { - public: - PendingNotificationEntry * FindLRUEntry(); - - PendingNotificationEntry * FindEntry(FabricIndex fabricIndex, NodeId node); - - CHIP_ERROR AddPendingNotification(FabricIndex fabricIndex, NodeId node, EndpointId endpoint, ClusterId cluster, - void * context); - - void RemoveEntry(PendingNotificationEntry * entry) { mPendingNotificationMap.ReleaseObject(entry); } - - template - Loop ForEachActiveObject(Function && function) - { - return mPendingNotificationMap.ForEachActiveObject(std::forward(function)); - } - - private: - ObjectPool mPendingNotificationMap; - }; - static void HandleDeviceConnected(void * context, OperationalDeviceProxy * device); void HandleDeviceConnected(OperationalDeviceProxy * device); @@ -205,9 +106,6 @@ class BindingManager CHIP_ERROR EstablishConnection(FabricIndex fabric, NodeId node); - // Called when CASE session is established to a peer device. Will send all the pending commands to the peer. - void SyncPendingNotificationsToPeer(OperationalDeviceProxy * device, PendingNotificationEntry * pendingClusters); - PendingNotificationMap mPendingNotificationMap; BoundDeviceChangedHandler mBoundDeviceChangedHandler; Server * mAppServer = nullptr; diff --git a/src/app/clusters/bindings/PendingNotificationMap.cpp b/src/app/clusters/bindings/PendingNotificationMap.cpp new file mode 100644 index 00000000000000..49b48eb420c565 --- /dev/null +++ b/src/app/clusters/bindings/PendingNotificationMap.cpp @@ -0,0 +1,152 @@ +/* + * + * Copyright (c) 2022 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 + +#include +#include + +namespace chip { + +CHIP_ERROR PendingNotificationMap::FindLRUConnectPeer(FabricIndex * fabric, NodeId * node) +{ + // When entries are added to PendingNotificationMap, they are appended to the end. + // To find the LRU peer, we need to find the peer whose last entry in the map is closer + // to the start of the list than the last entry of any other peer. + + // First, set up a way to easily track which entries correspond to the same peer. + uint8_t bindingWithSamePeer[EMBER_BINDING_TABLE_SIZE]; + + for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) + { + EmberBindingTableEntry entry; + emberGetBinding(i, &entry); + if (entry.type != EMBER_UNICAST_BINDING) + { + continue; + } + bool foundSamePeer = false; + for (uint8_t j = 0; j < i; j++) + { + EmberBindingTableEntry checkEntry; + emberGetBinding(j, &checkEntry); + if (checkEntry.type == EMBER_UNICAST_BINDING && checkEntry.fabricIndex == entry.fabricIndex && + checkEntry.nodeId == entry.nodeId) + { + foundSamePeer = true; + bindingWithSamePeer[i] = j; + break; + } + } + if (!foundSamePeer) + { + bindingWithSamePeer[i] = i; + } + } + + uint16_t lastAppear[EMBER_BINDING_TABLE_SIZE]; + for (uint16_t & value : lastAppear) + { + value = UINT16_MAX; + } + uint16_t appearIndex = 0; + for (PendingNotificationEntry pendingNotification : *this) + { + lastAppear[bindingWithSamePeer[pendingNotification.mBindingEntryId]] = appearIndex; + appearIndex++; + } + uint8_t lruBindingEntryIndex; + uint16_t minLastAppearValue = UINT16_MAX; + for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) + { + if (lastAppear[i] < minLastAppearValue) + { + lruBindingEntryIndex = i; + minLastAppearValue = lastAppear[i]; + } + } + if (minLastAppearValue < UINT16_MAX) + { + EmberBindingTableEntry entry; + emberGetBinding(lruBindingEntryIndex, &entry); + *fabric = entry.fabricIndex; + *node = entry.nodeId; + return CHIP_NO_ERROR; + } + return CHIP_ERROR_NOT_FOUND; +} + +void PendingNotificationMap::AddPendingNotification(uint8_t bindingEntryId, void * context) +{ + RemoveEntry(bindingEntryId); + mPendingBindingEntries[mNumEntries] = bindingEntryId; + mPendingContexts[mNumEntries] = context; + mNumEntries++; +} + +void PendingNotificationMap::RemoveEntry(uint8_t bindingEntryId) +{ + uint8_t newEntryCount = 0; + for (int i = 0; i < mNumEntries; i++) + { + if (mPendingBindingEntries[i] != bindingEntryId) + { + mPendingBindingEntries[newEntryCount] = mPendingBindingEntries[i]; + mPendingContexts[newEntryCount] = mPendingContexts[i]; + newEntryCount++; + } + } + mNumEntries = newEntryCount; +} + +void PendingNotificationMap::RemoveAllEntriesForNode(FabricIndex fabric, NodeId node) +{ + uint8_t newEntryCount = 0; + for (int i = 0; i < mNumEntries; i++) + { + EmberBindingTableEntry entry; + emberGetBinding(mPendingBindingEntries[i], &entry); + + if (entry.fabricIndex != fabric || entry.nodeId != node) + { + mPendingBindingEntries[newEntryCount] = mPendingBindingEntries[i]; + mPendingContexts[newEntryCount] = mPendingContexts[i]; + newEntryCount++; + } + } + mNumEntries = newEntryCount; +} + +void PendingNotificationMap::RemoveAllEntriesForFabric(FabricIndex fabric) +{ + uint8_t newEntryCount = 0; + for (int i = 0; i < mNumEntries; i++) + { + EmberBindingTableEntry entry; + emberGetBinding(mPendingBindingEntries[i], &entry); + + if (entry.fabricIndex != fabric) + { + mPendingBindingEntries[newEntryCount] = mPendingBindingEntries[i]; + mPendingContexts[newEntryCount] = mPendingContexts[i]; + newEntryCount++; + } + } + mNumEntries = newEntryCount; +} + +} // namespace chip diff --git a/src/app/clusters/bindings/PendingNotificationMap.h b/src/app/clusters/bindings/PendingNotificationMap.h new file mode 100644 index 00000000000000..8a9559cac9cefa --- /dev/null +++ b/src/app/clusters/bindings/PendingNotificationMap.h @@ -0,0 +1,85 @@ +/* + * + * Copyright (c) 2022 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 +#include +#include + +namespace chip { + +struct PendingNotificationEntry +{ +public: + uint8_t mBindingEntryId; + void * mContext; +}; + +// The pool for all the pending comands. +class PendingNotificationMap +{ +public: + static constexpr uint8_t kMaxPendingNotifications = EMBER_BINDING_TABLE_SIZE; + + friend class Iterator; + + class Iterator + { + public: + Iterator(PendingNotificationMap * map, int16_t index) : mMap(map), mIndex(index) {} + + PendingNotificationEntry operator*() + { + return PendingNotificationEntry{ mMap->mPendingBindingEntries[mIndex], mMap->mPendingContexts[mIndex] }; + } + + Iterator operator++() + { + mIndex++; + return *this; + } + + bool operator!=(const Iterator & rhs) { return mIndex != rhs.mIndex; } + + private: + PendingNotificationMap * mMap; + int16_t mIndex; + }; + + Iterator begin() { return Iterator(this, 0); } + + Iterator end() { return Iterator(this, mNumEntries); } + + CHIP_ERROR FindLRUConnectPeer(FabricIndex * fabric, NodeId * node); + + void AddPendingNotification(uint8_t bindingEntryId, void * context); + + void RemoveEntry(uint8_t bindingEntryId); + + void RemoveAllEntriesForNode(FabricTable * fabricTable, PeerId peer); + + void RemoveAllEntriesForNode(FabricIndex fabric, NodeId node); + + void RemoveAllEntriesForFabric(FabricIndex fabric); + +private: + uint8_t mPendingBindingEntries[kMaxPendingNotifications]; + void * mPendingContexts[kMaxPendingNotifications]; + + uint8_t mNumEntries = 0; +}; + +} // namespace chip diff --git a/src/app/clusters/bindings/bindings.cpp b/src/app/clusters/bindings/bindings.cpp index 13bfc15d7ebb8c..cfe7ea5f81e773 100644 --- a/src/app/clusters/bindings/bindings.cpp +++ b/src/app/clusters/bindings/bindings.cpp @@ -108,9 +108,10 @@ bool emberAfBindingClusterBindCallback(app::CommandHandler * commandObj, const a return true; } + emberSetBinding(bindingIndex, &bindingEntry); if (nodeId) { - CHIP_ERROR err = BindingManager::GetInstance().UnicastBindingCreated(fabricIndex, nodeId); + CHIP_ERROR err = BindingManager::GetInstance().UnicastBindingCreated(bindingEntry); if (err != CHIP_NO_ERROR) { ChipLogProgress( @@ -118,26 +119,11 @@ bool emberAfBindingClusterBindCallback(app::CommandHandler * commandObj, const a ChipLogValueX64(nodeId), err.Format()); } } - emberSetBinding(bindingIndex, &bindingEntry); + emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); return true; } -static uint8_t GetNumberOfUnicastBindingForNode(FabricIndex fabric, NodeId node) -{ - uint8_t numBinding = 0; - EmberBindingTableEntry entry; - for (uint8_t i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) - { - if (emberGetBinding(i, &entry) == EMBER_SUCCESS && entry.type == EMBER_UNICAST_BINDING && entry.fabricIndex == fabric && - entry.nodeId == node) - { - numBinding++; - } - } - return numBinding; -} - bool emberAfBindingClusterUnbindCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::Unbind::DecodableType & commandData) { @@ -173,17 +159,14 @@ bool emberAfBindingClusterUnbindCallback(app::CommandHandler * commandObj, const return true; } - emberDeleteBinding(bindingIndex); - if (nodeId != 0 && GetNumberOfUnicastBindingForNode(fabricIndex, nodeId) == 0) + CHIP_ERROR err = BindingManager::GetInstance().UnicastBindingRemoved(bindingIndex); + if (err != CHIP_NO_ERROR) { - CHIP_ERROR err = BindingManager::GetInstance().LastUnicastBindingRemoved(fabricIndex, nodeId); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Binding: Failed to disconnect device " ChipLogFormatX64 ": %s", ChipLogValueX64(nodeId), - err.AsString()); - } + ChipLogError(Zcl, "Binding: Failed to remove pending notification for unicast binding" ChipLogFormatX64 ": %s", + ChipLogValueX64(nodeId), err.AsString()); } + emberDeleteBinding(bindingIndex); emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); return true; } diff --git a/src/app/util/binding-table.h b/src/app/util/binding-table.h index 7188830b3d2803..6b0abe2f957f34 100644 --- a/src/app/util/binding-table.h +++ b/src/app/util/binding-table.h @@ -23,9 +23,6 @@ #include -// Should this be configurable by the app somehow? -#define BINDING_TABLE_SIZE 10 - EmberStatus emberGetBinding(uint8_t index, EmberBindingTableEntry * result); EmberStatus emberSetBinding(uint8_t index, EmberBindingTableEntry * result);