From 12768005e51f66e3262db20029b9b53b15bc8c97 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Wed, 8 Nov 2023 15:17:58 -0500 Subject: [PATCH] Match `Keypad Input Cluster` to spec (#30316) * xml rename KeypadInputStatusEnum to StatusEnum * zap regen * Rename remaining status usages * Minor change to kick CI * Add compat * Fix typo --- .../all-clusters-minimal-app.matter | 4 +- ...ootnode_basicvideoplayer_0ff86e943b.matter | 4 +- .../placeholder/linux/apps/app1/config.matter | 6 +-- .../placeholder/linux/apps/app2/config.matter | 6 +-- .../android/java/KeypadInputManager.cpp | 4 +- .../keypad-input/KeypadInputManager.cpp | 42 +++++++++---------- examples/tv-app/tv-common/tv-app.matter | 4 +- .../tv-casting-common/tv-casting-app.matter | 4 +- src/app/CompatEnumNames.h | 5 +++ .../data-model/chip/keypad-input-cluster.xml | 4 +- .../data-model/chip/media-input-cluster.xml | 1 + .../data_model/controller-clusters.matter | 4 +- .../python/chip/clusters/Objects.py | 6 +-- .../CHIP/zap-generated/MTRBaseClusters.h | 8 ++-- .../integration-tests/tv-app/test_app.py | 4 +- .../zap-generated/cluster-enums-check.h | 4 +- .../app-common/zap-generated/cluster-enums.h | 4 +- .../zap-generated/cluster-objects.h | 4 +- 18 files changed, 62 insertions(+), 56 deletions(-) diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index e5dcdd9ef793af..bbcaf521b97840 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -3429,7 +3429,7 @@ server cluster KeypadInput = 1289 { kData = 118; } - enum KeypadInputStatusEnum : enum8 { + enum StatusEnum : enum8 { kSuccess = 0; kUnsupportedKey = 1; kInvalidKeyInCurrentState = 2; @@ -3453,7 +3453,7 @@ server cluster KeypadInput = 1289 { } response struct SendKeyResponse = 1 { - KeypadInputStatusEnum status = 0; + StatusEnum status = 0; } command SendKey(SendKeyRequest): SendKeyResponse = 0; diff --git a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter index 1ccb6c4c41c848..d964a8f5a7a3bf 100644 --- a/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter +++ b/examples/chef/devices/rootnode_basicvideoplayer_0ff86e943b.matter @@ -1400,7 +1400,7 @@ server cluster KeypadInput = 1289 { kData = 118; } - enum KeypadInputStatusEnum : enum8 { + enum StatusEnum : enum8 { kSuccess = 0; kUnsupportedKey = 1; kInvalidKeyInCurrentState = 2; @@ -1424,7 +1424,7 @@ server cluster KeypadInput = 1289 { } response struct SendKeyResponse = 1 { - KeypadInputStatusEnum status = 0; + StatusEnum status = 0; } command SendKey(SendKeyRequest): SendKeyResponse = 0; diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 32b499ac96d58b..334225aad8fe75 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -5875,7 +5875,7 @@ client cluster KeypadInput = 1289 { kData = 118; } - enum KeypadInputStatusEnum : enum8 { + enum StatusEnum : enum8 { kSuccess = 0; kUnsupportedKey = 1; kInvalidKeyInCurrentState = 2; @@ -5899,7 +5899,7 @@ client cluster KeypadInput = 1289 { } response struct SendKeyResponse = 1 { - KeypadInputStatusEnum status = 0; + StatusEnum status = 0; } /** Upon receipt, this SHALL process a keycode as input to the media device. */ @@ -5997,7 +5997,7 @@ server cluster KeypadInput = 1289 { kData = 118; } - enum KeypadInputStatusEnum : enum8 { + enum StatusEnum : enum8 { kSuccess = 0; kUnsupportedKey = 1; kInvalidKeyInCurrentState = 2; diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index ef0aa162fd9c1a..45c2602cbc005e 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -5834,7 +5834,7 @@ client cluster KeypadInput = 1289 { kData = 118; } - enum KeypadInputStatusEnum : enum8 { + enum StatusEnum : enum8 { kSuccess = 0; kUnsupportedKey = 1; kInvalidKeyInCurrentState = 2; @@ -5858,7 +5858,7 @@ client cluster KeypadInput = 1289 { } response struct SendKeyResponse = 1 { - KeypadInputStatusEnum status = 0; + StatusEnum status = 0; } /** Upon receipt, this SHALL process a keycode as input to the media device. */ @@ -5956,7 +5956,7 @@ server cluster KeypadInput = 1289 { kData = 118; } - enum KeypadInputStatusEnum : enum8 { + enum StatusEnum : enum8 { kSuccess = 0; kUnsupportedKey = 1; kInvalidKeyInCurrentState = 2; diff --git a/examples/tv-app/android/java/KeypadInputManager.cpp b/examples/tv-app/android/java/KeypadInputManager.cpp index ceea8305b585c6..a25a3bdbbc7975 100644 --- a/examples/tv-app/android/java/KeypadInputManager.cpp +++ b/examples/tv-app/android/java/KeypadInputManager.cpp @@ -61,11 +61,11 @@ void KeypadInputManager::HandleSendKey(CommandResponseHelper(ret); + response.status = static_cast(ret); } helper.Success(response); } diff --git a/examples/tv-app/tv-common/clusters/keypad-input/KeypadInputManager.cpp b/examples/tv-app/tv-common/clusters/keypad-input/KeypadInputManager.cpp index 5548174821a45d..17c372accea7a9 100644 --- a/examples/tv-app/tv-common/clusters/keypad-input/KeypadInputManager.cpp +++ b/examples/tv-app/tv-common/clusters/keypad-input/KeypadInputManager.cpp @@ -31,67 +31,67 @@ void KeypadInputManager::HandleSendKey(CommandResponseHelper This command SHALL be generated in response to a SendKey Request command. - + - + diff --git a/src/app/zap-templates/zcl/data-model/chip/media-input-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/media-input-cluster.xml index 495160b10b473c..d6b6b1782769fd 100644 --- a/src/app/zap-templates/zcl/data-model/chip/media-input-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/media-input-cluster.xml @@ -25,6 +25,7 @@ limitations under the License. true This cluster provides an interface for controlling the Input Selector on a media device such as a TV. + InputList CurrentInput diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index fdf693d73ae72b..69770135cadd9e 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -6237,7 +6237,7 @@ client cluster KeypadInput = 1289 { kData = 118; } - enum KeypadInputStatusEnum : enum8 { + enum StatusEnum : enum8 { kSuccess = 0; kUnsupportedKey = 1; kInvalidKeyInCurrentState = 2; @@ -6261,7 +6261,7 @@ client cluster KeypadInput = 1289 { } response struct SendKeyResponse = 1 { - KeypadInputStatusEnum status = 0; + StatusEnum status = 0; } /** Upon receipt, this SHALL process a keycode as input to the media device. */ diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index e933de1f6a9fe1..fa74f18f61a1ff 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -34618,7 +34618,7 @@ class CecKeyCode(MatterIntEnum): # enum value. This specific should never be transmitted. kUnknownEnumValue = 14, - class KeypadInputStatusEnum(MatterIntEnum): + class StatusEnum(MatterIntEnum): kSuccess = 0x00 kUnsupportedKey = 0x01 kInvalidKeyInCurrentState = 0x02 @@ -34662,10 +34662,10 @@ class SendKeyResponse(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="status", Tag=0, Type=KeypadInput.Enums.KeypadInputStatusEnum), + ClusterObjectFieldDescriptor(Label="status", Tag=0, Type=KeypadInput.Enums.StatusEnum), ]) - status: 'KeypadInput.Enums.KeypadInputStatusEnum' = 0 + status: 'KeypadInput.Enums.StatusEnum' = 0 class Attributes: @dataclass diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index 37e38c896308c5..2a45f40a80bd7a 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -16512,10 +16512,10 @@ typedef NS_ENUM(uint8_t, MTRKeypadInputCecKeyCode) { } MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); typedef NS_ENUM(uint8_t, MTRKeypadInputStatus) { - MTRKeypadInputStatusSuccess MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, - MTRKeypadInputStatusUnsupportedKey MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, - MTRKeypadInputStatusInvalidKeyInCurrentState MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x02, -} MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); + MTRKeypadInputStatusSuccess MTR_PROVISIONALLY_AVAILABLE = 0x00, + MTRKeypadInputStatusUnsupportedKey MTR_PROVISIONALLY_AVAILABLE = 0x01, + MTRKeypadInputStatusInvalidKeyInCurrentState MTR_PROVISIONALLY_AVAILABLE = 0x02, +} MTR_PROVISIONALLY_AVAILABLE; typedef NS_OPTIONS(uint32_t, MTRKeypadInputFeature) { MTRKeypadInputFeatureNavigationKeyCodes MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x1, diff --git a/src/test_driver/openiotsdk/integration-tests/tv-app/test_app.py b/src/test_driver/openiotsdk/integration-tests/tv-app/test_app.py index 5315700fafbd75..0ad77468e7fc14 100644 --- a/src/test_driver/openiotsdk/integration-tests/tv-app/test_app.py +++ b/src/test_driver/openiotsdk/integration-tests/tv-app/test_app.py @@ -408,13 +408,13 @@ def test_tv_ctrl(device, controller): err, res = send_zcl_command(devCtrl, "KeypadInput", "SendKey", nodeId, endpoint, dict(keyCode=keyCode), requestTimeoutMs=1000) assert err == 0 - assert res.status == KeypadInput.Enums.KeypadInputStatusEnum.kSuccess + assert res.status == KeypadInput.Enums.StatusEnum.kSuccess err, res = send_zcl_command(devCtrl, "KeypadInput", "SendKey", nodeId, endpoint, dict(keyCode=TV_CTRL_TEST_KEY_PAD_UNSUPPORTED_KEY), requestTimeoutMs=1000) assert err == 0 - assert res.status == KeypadInput.Enums.KeypadInputStatusEnum.kUnsupportedKey + assert res.status == KeypadInput.Enums.StatusEnum.kUnsupportedKey # TargetNavigator err, res = read_zcl_attribute(devCtrl, "TargetNavigator", "TargetList", nodeId, endpoint) diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index fd2191e88db3d7..82b98beb17baa7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -2799,9 +2799,9 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(KeypadInput::CecKeyCode return static_cast(14); } } -static auto __attribute__((unused)) EnsureKnownEnumValue(KeypadInput::KeypadInputStatusEnum val) +static auto __attribute__((unused)) EnsureKnownEnumValue(KeypadInput::StatusEnum val) { - using EnumType = KeypadInput::KeypadInputStatusEnum; + using EnumType = KeypadInput::StatusEnum; switch (val) { case EnumType::kSuccess: diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index 558ae6a14a86ae..af1f7f02e0b934 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -3972,8 +3972,8 @@ enum class CecKeyCode : uint8_t kUnknownEnumValue = 14, }; -// Enum for KeypadInputStatusEnum -enum class KeypadInputStatusEnum : uint8_t +// Enum for StatusEnum +enum class StatusEnum : uint8_t { kSuccess = 0x00, kUnsupportedKey = 0x01, 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 3d888cc28d954d..04b06178dcec5f 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 @@ -29836,7 +29836,7 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::SendKeyResponse::Id; } static constexpr ClusterId GetClusterId() { return Clusters::KeypadInput::Id; } - KeypadInputStatusEnum status = static_cast(0); + StatusEnum status = static_cast(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -29851,7 +29851,7 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::SendKeyResponse::Id; } static constexpr ClusterId GetClusterId() { return Clusters::KeypadInput::Id; } - KeypadInputStatusEnum status = static_cast(0); + StatusEnum status = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace SendKeyResponse