diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 9c66167340e9de..1eef3f9ec918c8 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -11616,7 +11616,7 @@ "outgoing": 1 }, { - "name": "MediaSkipSeek", + "name": "MediaSeek", "code": 10, "mfgCode": null, "source": "client", @@ -11731,11 +11731,11 @@ "outgoing": 0 }, { - "name": "MediaSkipSeekResponse", - "code": 10, + "name": "MediaSeekResponse", + "code": 11, "mfgCode": null, "source": "server", - "incoming": 1, + "incoming": 0, "outgoing": 0 } ], @@ -12399,7 +12399,7 @@ "reportableChange": 0 }, { - "name": "application satus", + "name": "application status", "code": 7, "mfgCode": null, "side": "server", @@ -16316,4 +16316,4 @@ } ], "log": [] -} +} \ No newline at end of file diff --git a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h index 74329f223db2cd..38e48f3c90c18b 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h @@ -2235,7 +2235,7 @@ { 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* product id */ \ { 0x0005, ZAP_TYPE(CHAR_STRING), 32, 0, ZAP_LONG_DEFAULTS_INDEX(7804) }, /* application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* catalog vendor id */ \ - { 0x0007, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* application satus */ \ + { 0x0007, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* application status */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ /* Endpoint: 1, Cluster: Account Login (server) */ \ @@ -2825,8 +2825,8 @@ { 0x0506, 0x08, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipForwardResponse */ \ { 0x0506, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSkipBackward */ \ { 0x0506, 0x09, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipBackwardResponse */ \ - { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSkipSeek */ \ - { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipSeekResponse */ \ + { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSeek */ \ + { 0x0506, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSeekResponse */ \ \ /* Endpoint: 1, Cluster: Media Input (server) */ \ { 0x0507, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SelectInput */ \ diff --git a/examples/all-clusters-app/esp32/main/main.cpp b/examples/all-clusters-app/esp32/main/main.cpp index ec91e67794a2c8..6de0390eaa204b 100644 --- a/examples/all-clusters-app/esp32/main/main.cpp +++ b/examples/all-clusters-app/esp32/main/main.cpp @@ -766,3 +766,8 @@ extern "C" void app_main() vTaskDelay(50 / portTICK_PERIOD_MS); } } + +bool lowPowerClusterSleep() +{ + return true; +} diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index b9fdd4d48d4869..8f9b36a9d9964a 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -16,7 +16,10 @@ import("//build_overrides/build.gni") import("//build_overrides/chip.gni") executable("chip-all-clusters-app") { - sources = [ "main.cpp" ] + sources = [ + "include/tv-callbacks.cpp", + "main.cpp", + ] deps = [ "${chip_root}/examples/all-clusters-app/all-clusters-common", diff --git a/examples/all-clusters-app/linux/include/tv-callbacks.cpp b/examples/all-clusters-app/linux/include/tv-callbacks.cpp new file mode 100644 index 00000000000000..79a6ee8413daac --- /dev/null +++ b/examples/all-clusters-app/linux/include/tv-callbacks.cpp @@ -0,0 +1,28 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/**************************************************************************** + * @file + * @brief Routines for TV stubs + *server stub implementation of TV cluster code. + ******************************************************************************* + ******************************************************************************/ + +bool lowPowerClusterSleep() +{ + return true; +} diff --git a/examples/chip-tool/commands/clusters/Commands.h b/examples/chip-tool/commands/clusters/Commands.h index d95f83e4e87274..c6076b8fdefa67 100644 --- a/examples/chip-tool/commands/clusters/Commands.h +++ b/examples/chip-tool/commands/clusters/Commands.h @@ -463,25 +463,25 @@ static void OnMediaPlaybackClusterMediaRewindResponse(void * context, uint8_t me command->SetCommandExitStatus(CHIP_NO_ERROR); } -static void OnMediaPlaybackClusterMediaSkipBackwardResponse(void * context, uint8_t mediaPlaybackStatus) +static void OnMediaPlaybackClusterMediaSeekResponse(void * context, uint8_t mediaPlaybackStatus) { - ChipLogProgress(chipTool, "MediaPlaybackClusterMediaSkipBackwardResponse"); + ChipLogProgress(chipTool, "MediaPlaybackClusterMediaSeekResponse"); ModelCommand * command = reinterpret_cast(context); command->SetCommandExitStatus(CHIP_NO_ERROR); } -static void OnMediaPlaybackClusterMediaSkipForwardResponse(void * context, uint8_t mediaPlaybackStatus) +static void OnMediaPlaybackClusterMediaSkipBackwardResponse(void * context, uint8_t mediaPlaybackStatus) { - ChipLogProgress(chipTool, "MediaPlaybackClusterMediaSkipForwardResponse"); + ChipLogProgress(chipTool, "MediaPlaybackClusterMediaSkipBackwardResponse"); ModelCommand * command = reinterpret_cast(context); command->SetCommandExitStatus(CHIP_NO_ERROR); } -static void OnMediaPlaybackClusterMediaSkipSeekResponse(void * context, uint8_t mediaPlaybackStatus) +static void OnMediaPlaybackClusterMediaSkipForwardResponse(void * context, uint8_t mediaPlaybackStatus) { - ChipLogProgress(chipTool, "MediaPlaybackClusterMediaSkipSeekResponse"); + ChipLogProgress(chipTool, "MediaPlaybackClusterMediaSkipForwardResponse"); ModelCommand * command = reinterpret_cast(context); command->SetCommandExitStatus(CHIP_NO_ERROR); @@ -1348,7 +1348,7 @@ class ReadAccountLoginClusterRevision : public ModelCommand | * ProductId | 0x0003 | | * ApplicationId | 0x0005 | | * CatalogVendorId | 0x0006 | -| * ApplicationSatus | 0x0007 | +| * ApplicationStatus | 0x0007 | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ @@ -1621,18 +1621,18 @@ class ReadApplicationBasicCatalogVendorId : public ModelCommand }; /* - * Attribute ApplicationSatus + * Attribute ApplicationStatus */ -class ReadApplicationBasicApplicationSatus : public ModelCommand +class ReadApplicationBasicApplicationStatus : public ModelCommand { public: - ReadApplicationBasicApplicationSatus() : ModelCommand("read") + ReadApplicationBasicApplicationStatus() : ModelCommand("read") { - AddArgument("attr-name", "application-satus"); + AddArgument("attr-name", "application-status"); ModelCommand::AddArguments(); } - ~ReadApplicationBasicApplicationSatus() + ~ReadApplicationBasicApplicationStatus() { delete onSuccessCallback; delete onFailureCallback; @@ -1644,7 +1644,7 @@ class ReadApplicationBasicApplicationSatus : public ModelCommand chip::Controller::ApplicationBasicCluster cluster; cluster.Associate(device, endpointId); - return cluster.ReadAttributeApplicationSatus(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + return cluster.ReadAttributeApplicationStatus(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); } private: @@ -11979,9 +11979,9 @@ class ReadMediaInputClusterRevision : public ModelCommand | * MediaPlay | 0x00 | | * MediaPrevious | 0x04 | | * MediaRewind | 0x06 | +| * MediaSeek | 0x0A | | * MediaSkipBackward | 0x09 | | * MediaSkipForward | 0x08 | -| * MediaSkipSeek | 0x0A | | * MediaStartOver | 0x03 | | * MediaStop | 0x02 | |------------------------------------------------------------------------------| @@ -12168,17 +12168,17 @@ class MediaPlaybackMediaRewind : public ModelCommand }; /* - * Command MediaSkipBackward + * Command MediaSeek */ -class MediaPlaybackMediaSkipBackward : public ModelCommand +class MediaPlaybackMediaSeek : public ModelCommand { public: - MediaPlaybackMediaSkipBackward() : ModelCommand("media-skip-backward") + MediaPlaybackMediaSeek() : ModelCommand("media-seek") { - AddArgument("DeltaPositionMilliseconds", 0, UINT64_MAX, &mDeltaPositionMilliseconds); + AddArgument("Position", 0, UINT64_MAX, &mPosition); ModelCommand::AddArguments(); } - ~MediaPlaybackMediaSkipBackward() + ~MediaPlaybackMediaSeek() { delete onSuccessCallback; delete onFailureCallback; @@ -12186,34 +12186,33 @@ class MediaPlaybackMediaSkipBackward : public ModelCommand CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0506) command (0x09) on endpoint %" PRIu8, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0506) command (0x0A) on endpoint %" PRIu8, endpointId); chip::Controller::MediaPlaybackCluster cluster; cluster.Associate(device, endpointId); - return cluster.MediaSkipBackward(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mDeltaPositionMilliseconds); + return cluster.MediaSeek(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mPosition); } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback( - OnMediaPlaybackClusterMediaSkipBackwardResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnMediaPlaybackClusterMediaSeekResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); - uint64_t mDeltaPositionMilliseconds; + uint64_t mPosition; }; /* - * Command MediaSkipForward + * Command MediaSkipBackward */ -class MediaPlaybackMediaSkipForward : public ModelCommand +class MediaPlaybackMediaSkipBackward : public ModelCommand { public: - MediaPlaybackMediaSkipForward() : ModelCommand("media-skip-forward") + MediaPlaybackMediaSkipBackward() : ModelCommand("media-skip-backward") { AddArgument("DeltaPositionMilliseconds", 0, UINT64_MAX, &mDeltaPositionMilliseconds); ModelCommand::AddArguments(); } - ~MediaPlaybackMediaSkipForward() + ~MediaPlaybackMediaSkipBackward() { delete onSuccessCallback; delete onFailureCallback; @@ -12221,34 +12220,34 @@ class MediaPlaybackMediaSkipForward : public ModelCommand CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0506) command (0x08) on endpoint %" PRIu8, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0506) command (0x09) on endpoint %" PRIu8, endpointId); chip::Controller::MediaPlaybackCluster cluster; cluster.Associate(device, endpointId); - return cluster.MediaSkipForward(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mDeltaPositionMilliseconds); + return cluster.MediaSkipBackward(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mDeltaPositionMilliseconds); } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback( - OnMediaPlaybackClusterMediaSkipForwardResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback( + OnMediaPlaybackClusterMediaSkipBackwardResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); uint64_t mDeltaPositionMilliseconds; }; /* - * Command MediaSkipSeek + * Command MediaSkipForward */ -class MediaPlaybackMediaSkipSeek : public ModelCommand +class MediaPlaybackMediaSkipForward : public ModelCommand { public: - MediaPlaybackMediaSkipSeek() : ModelCommand("media-skip-seek") + MediaPlaybackMediaSkipForward() : ModelCommand("media-skip-forward") { - AddArgument("Position", 0, UINT64_MAX, &mPosition); + AddArgument("DeltaPositionMilliseconds", 0, UINT64_MAX, &mDeltaPositionMilliseconds); ModelCommand::AddArguments(); } - ~MediaPlaybackMediaSkipSeek() + ~MediaPlaybackMediaSkipForward() { delete onSuccessCallback; delete onFailureCallback; @@ -12256,20 +12255,20 @@ class MediaPlaybackMediaSkipSeek : public ModelCommand CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0506) command (0x0A) on endpoint %" PRIu8, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0506) command (0x08) on endpoint %" PRIu8, endpointId); chip::Controller::MediaPlaybackCluster cluster; cluster.Associate(device, endpointId); - return cluster.MediaSkipSeek(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mPosition); + return cluster.MediaSkipForward(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mDeltaPositionMilliseconds); } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnMediaPlaybackClusterMediaSkipSeekResponse, - this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback( + OnMediaPlaybackClusterMediaSkipForwardResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); - uint64_t mPosition; + uint64_t mDeltaPositionMilliseconds; }; /* @@ -22380,11 +22379,11 @@ void registerClusterApplicationBasic(Commands & commands) const char * clusterName = "ApplicationBasic"; commands_list clusterCommands = { - make_unique(), make_unique(), - make_unique(), make_unique(), - make_unique(), make_unique(), - make_unique(), make_unique(), - make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), }; commands.Register(clusterName, clusterCommands); @@ -22862,8 +22861,8 @@ void registerClusterMediaPlayback(Commands & commands) make_unique(), make_unique(), make_unique(), make_unique(), make_unique(), make_unique(), - make_unique(), make_unique(), - make_unique(), make_unique(), + make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), make_unique(), }; diff --git a/examples/chip-tool/commands/tests/Commands.h b/examples/chip-tool/commands/tests/Commands.h index d1dfacb3b37b98..ac3344fd18b9e1 100644 --- a/examples/chip-tool/commands/tests/Commands.h +++ b/examples/chip-tool/commands/tests/Commands.h @@ -21,6 +21,3241 @@ #include "TestCommand.h" +class TV_TargetNavigatorCluster : public TestCommand +{ +public: + TV_TargetNavigatorCluster() : TestCommand("TV_TargetNavigatorCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_TargetNavigatorCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterTargetNavigatorCommandReadAttribute_0(); + break; + case 1: + err = TestSendClusterTargetNavigatorCommandNavigateTarget_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_TargetNavigatorCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + // + // Tests methods + // + + // Test Read attribute Target Navigator list + typedef void (*SuccessCallback_0)(void * context, uint16_t count, _NavigateTargetTargetInfo * targetNavigatorList); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterTargetNavigatorCommandReadAttribute_0() + { + ChipLogProgress(chipTool, "Target Navigator - Read attribute Target Navigator list: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterTargetNavigatorCommandReadAttribute_0_FailureResponse, this); + mOnSuccessCallback_0 = new chip::Callback::Callback( + OnTestSendClusterTargetNavigatorCommandReadAttribute_0_SuccessResponse, this); + + chip::Controller::TargetNavigatorCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeTargetNavigatorList(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterTargetNavigatorCommandReadAttribute_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Target Navigator - Read attribute Target Navigator list: Failure Response"); + + TV_TargetNavigatorCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void + OnTestSendClusterTargetNavigatorCommandReadAttribute_0_SuccessResponse(void * context, uint16_t count, + _NavigateTargetTargetInfo * targetNavigatorList) + { + ChipLogProgress(chipTool, "Target Navigator - Read attribute Target Navigator list: Success Response"); + + TV_TargetNavigatorCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (count != 2) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "[object Object],[object Object]"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Navigate Target Command + typedef void (*SuccessCallback_1)(void * context, uint8_t status, chip::ByteSpan data); + chip::Callback::Callback * mOnSuccessCallback_1 = nullptr; + chip::Callback::Callback * mOnFailureCallback_1 = nullptr; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterTargetNavigatorCommandNavigateTarget_1() + { + ChipLogProgress(chipTool, "Target Navigator - Navigate Target Command: Sending command..."); + + mOnFailureCallback_1 = new chip::Callback::Callback( + OnTestSendClusterTargetNavigatorCommandNavigateTarget_1_FailureResponse, this); + mOnSuccessCallback_1 = new chip::Callback::Callback( + OnTestSendClusterTargetNavigatorCommandNavigateTarget_1_SuccessResponse, this); + + chip::Controller::TargetNavigatorCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint8_t targetArgument = 1; + chip::ByteSpan dataArgument = chip::ByteSpan(chip::Uint8::from_const_char("1"), strlen("1")); + err = cluster.NavigateTarget(mOnSuccessCallback_1->Cancel(), mOnFailureCallback_1->Cancel(), targetArgument, dataArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_1; + delete mOnSuccessCallback_1; + } + + return err; + } + + static void OnTestSendClusterTargetNavigatorCommandNavigateTarget_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Target Navigator - Navigate Target Command: Failure Response"); + + TV_TargetNavigatorCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterTargetNavigatorCommandNavigateTarget_1_SuccessResponse(void * context, uint8_t status, + chip::ByteSpan data) + { + ChipLogProgress(chipTool, "Target Navigator - Navigate Target Command: Success Response"); + + TV_TargetNavigatorCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_AudioOutputCluster : public TestCommand +{ +public: + TV_AudioOutputCluster() : TestCommand("TV_AudioOutputCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_AudioOutputCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterAudioOutputCommandReadAttribute_0(); + break; + case 1: + err = TestSendClusterAudioOutputCommandSelectOutput_1(); + break; + case 2: + err = TestSendClusterAudioOutputCommandRenameOutput_2(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_AudioOutputCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + // + // Tests methods + // + + // Test Read attribute Audio Output list + typedef void (*SuccessCallback_0)(void * context, uint16_t count, _AudioOutputInfo * audioOutputList); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterAudioOutputCommandReadAttribute_0() + { + ChipLogProgress(chipTool, "Audio Output - Read attribute Audio Output list: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterAudioOutputCommandReadAttribute_0_FailureResponse, this); + mOnSuccessCallback_0 = new chip::Callback::Callback( + OnTestSendClusterAudioOutputCommandReadAttribute_0_SuccessResponse, this); + + chip::Controller::AudioOutputCluster cluster; + cluster.Associate(mDevice, 2); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeAudioOutputList(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterAudioOutputCommandReadAttribute_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Audio Output - Read attribute Audio Output list: Failure Response"); + + TV_AudioOutputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterAudioOutputCommandReadAttribute_0_SuccessResponse(void * context, uint16_t count, + _AudioOutputInfo * audioOutputList) + { + ChipLogProgress(chipTool, "Audio Output - Read attribute Audio Output list: Success Response"); + + TV_AudioOutputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (count != 3) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "[object Object],[object Object],[object Object]"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Select Output Command + typedef void (*SuccessCallback_1)(void * context); + chip::Callback::Callback * mOnSuccessCallback_1 = nullptr; + chip::Callback::Callback * mOnFailureCallback_1 = nullptr; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterAudioOutputCommandSelectOutput_1() + { + ChipLogProgress(chipTool, "Audio Output - Select Output Command: Sending command..."); + + mOnFailureCallback_1 = new chip::Callback::Callback( + OnTestSendClusterAudioOutputCommandSelectOutput_1_FailureResponse, this); + mOnSuccessCallback_1 = new chip::Callback::Callback( + OnTestSendClusterAudioOutputCommandSelectOutput_1_SuccessResponse, this); + + chip::Controller::AudioOutputCluster cluster; + cluster.Associate(mDevice, 2); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint8_t indexArgument = 1; + err = cluster.SelectOutput(mOnSuccessCallback_1->Cancel(), mOnFailureCallback_1->Cancel(), indexArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_1; + delete mOnSuccessCallback_1; + } + + return err; + } + + static void OnTestSendClusterAudioOutputCommandSelectOutput_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Audio Output - Select Output Command: Failure Response"); + + TV_AudioOutputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterAudioOutputCommandSelectOutput_1_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Audio Output - Select Output Command: Success Response"); + + TV_AudioOutputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Rename Output Command + typedef void (*SuccessCallback_2)(void * context); + chip::Callback::Callback * mOnSuccessCallback_2 = nullptr; + chip::Callback::Callback * mOnFailureCallback_2 = nullptr; + bool mIsFailureExpected_2 = 0; + + CHIP_ERROR TestSendClusterAudioOutputCommandRenameOutput_2() + { + ChipLogProgress(chipTool, "Audio Output - Rename Output Command: Sending command..."); + + mOnFailureCallback_2 = new chip::Callback::Callback( + OnTestSendClusterAudioOutputCommandRenameOutput_2_FailureResponse, this); + mOnSuccessCallback_2 = new chip::Callback::Callback( + OnTestSendClusterAudioOutputCommandRenameOutput_2_SuccessResponse, this); + + chip::Controller::AudioOutputCluster cluster; + cluster.Associate(mDevice, 2); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint8_t indexArgument = 1; + chip::ByteSpan nameArgument = chip::ByteSpan(chip::Uint8::from_const_char("exampleName"), strlen("exampleName")); + err = cluster.RenameOutput(mOnSuccessCallback_2->Cancel(), mOnFailureCallback_2->Cancel(), indexArgument, nameArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_2; + delete mOnSuccessCallback_2; + } + + return err; + } + + static void OnTestSendClusterAudioOutputCommandRenameOutput_2_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Audio Output - Rename Output Command: Failure Response"); + + TV_AudioOutputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterAudioOutputCommandRenameOutput_2_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Audio Output - Rename Output Command: Success Response"); + + TV_AudioOutputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_ApplicationLauncherCluster : public TestCommand +{ +public: + TV_ApplicationLauncherCluster() : TestCommand("TV_ApplicationLauncherCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_ApplicationLauncherCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterApplicationLauncherCommandReadAttribute_0(); + break; + case 1: + err = TestSendClusterApplicationLauncherCommandLaunchApp_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_ApplicationLauncherCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + // + // Tests methods + // + + // Test Read attribute Application Launcher list + typedef void (*SuccessCallback_0)(void * context, uint16_t count, uint16_t * applicationLauncherList); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterApplicationLauncherCommandReadAttribute_0() + { + ChipLogProgress(chipTool, "Application Launcher - Read attribute Application Launcher list: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterApplicationLauncherCommandReadAttribute_0_FailureResponse, this); + mOnSuccessCallback_0 = new chip::Callback::Callback( + OnTestSendClusterApplicationLauncherCommandReadAttribute_0_SuccessResponse, this); + + chip::Controller::ApplicationLauncherCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeApplicationLauncherList(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterApplicationLauncherCommandReadAttribute_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Launcher - Read attribute Application Launcher list: Failure Response"); + + TV_ApplicationLauncherCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationLauncherCommandReadAttribute_0_SuccessResponse(void * context, uint16_t count, + uint16_t * applicationLauncherList) + { + ChipLogProgress(chipTool, "Application Launcher - Read attribute Application Launcher list: Success Response"); + + TV_ApplicationLauncherCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (count != 2) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "123,456"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Launch App Command + typedef void (*SuccessCallback_1)(void * context, uint8_t status, chip::ByteSpan data); + chip::Callback::Callback * mOnSuccessCallback_1 = nullptr; + chip::Callback::Callback * mOnFailureCallback_1 = nullptr; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterApplicationLauncherCommandLaunchApp_1() + { + ChipLogProgress(chipTool, "Application Launcher - Launch App Command: Sending command..."); + + mOnFailureCallback_1 = new chip::Callback::Callback( + OnTestSendClusterApplicationLauncherCommandLaunchApp_1_FailureResponse, this); + mOnSuccessCallback_1 = new chip::Callback::Callback( + OnTestSendClusterApplicationLauncherCommandLaunchApp_1_SuccessResponse, this); + + chip::Controller::ApplicationLauncherCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + chip::ByteSpan dataArgument = chip::ByteSpan(chip::Uint8::from_const_char("exampleData"), strlen("exampleData")); + uint16_t catalogVendorIdArgument = 1U; + chip::ByteSpan applicationIdArgument = chip::ByteSpan(chip::Uint8::from_const_char("appId"), strlen("appId")); + err = cluster.LaunchApp(mOnSuccessCallback_1->Cancel(), mOnFailureCallback_1->Cancel(), dataArgument, + catalogVendorIdArgument, applicationIdArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_1; + delete mOnSuccessCallback_1; + } + + return err; + } + + static void OnTestSendClusterApplicationLauncherCommandLaunchApp_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Launcher - Launch App Command: Failure Response"); + + TV_ApplicationLauncherCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationLauncherCommandLaunchApp_1_SuccessResponse(void * context, uint8_t status, + chip::ByteSpan data) + { + ChipLogProgress(chipTool, "Application Launcher - Launch App Command: Success Response"); + + TV_ApplicationLauncherCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_KeypadInputCluster : public TestCommand +{ +public: + TV_KeypadInputCluster() : TestCommand("TV_KeypadInputCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_KeypadInputCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterKeypadInputCommandSendKey_0(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_KeypadInputCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 1; + + // + // Tests methods + // + + // Test Send Key Command + typedef void (*SuccessCallback_0)(void * context, uint8_t status); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterKeypadInputCommandSendKey_0() + { + ChipLogProgress(chipTool, "Keypad Input - Send Key Command: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterKeypadInputCommandSendKey_0_FailureResponse, this); + mOnSuccessCallback_0 = + new chip::Callback::Callback(OnTestSendClusterKeypadInputCommandSendKey_0_SuccessResponse, this); + + chip::Controller::KeypadInputCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint8_t keyCodeArgument = 3; + err = cluster.SendKey(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel(), keyCodeArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterKeypadInputCommandSendKey_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Keypad Input - Send Key Command: Failure Response"); + + TV_KeypadInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterKeypadInputCommandSendKey_0_SuccessResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Keypad Input - Send Key Command: Success Response"); + + TV_KeypadInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_AccountLoginCluster : public TestCommand +{ +public: + TV_AccountLoginCluster() : TestCommand("TV_AccountLoginCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_AccountLoginCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterAccountLoginCommandGetSetupPIN_0(); + break; + case 1: + err = TestSendClusterAccountLoginCommandLogin_1(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_AccountLoginCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + // + // Tests methods + // + + // Test Get Setup PIN Command + typedef void (*SuccessCallback_0)(void * context, chip::ByteSpan setupPIN); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterAccountLoginCommandGetSetupPIN_0() + { + ChipLogProgress(chipTool, "Account Login - Get Setup PIN Command: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterAccountLoginCommandGetSetupPIN_0_FailureResponse, this); + mOnSuccessCallback_0 = new chip::Callback::Callback( + OnTestSendClusterAccountLoginCommandGetSetupPIN_0_SuccessResponse, this); + + chip::Controller::AccountLoginCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + chip::ByteSpan tempAccountIdentifierArgument = chip::ByteSpan(chip::Uint8::from_const_char("asdf"), strlen("asdf")); + err = cluster.GetSetupPIN(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel(), tempAccountIdentifierArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterAccountLoginCommandGetSetupPIN_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Account Login - Get Setup PIN Command: Failure Response"); + + TV_AccountLoginCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterAccountLoginCommandGetSetupPIN_0_SuccessResponse(void * context, chip::ByteSpan setupPIN) + { + ChipLogProgress(chipTool, "Account Login - Get Setup PIN Command: Success Response"); + + TV_AccountLoginCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Login Command + typedef void (*SuccessCallback_1)(void * context); + chip::Callback::Callback * mOnSuccessCallback_1 = nullptr; + chip::Callback::Callback * mOnFailureCallback_1 = nullptr; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterAccountLoginCommandLogin_1() + { + ChipLogProgress(chipTool, "Account Login - Login Command: Sending command..."); + + mOnFailureCallback_1 = + new chip::Callback::Callback(OnTestSendClusterAccountLoginCommandLogin_1_FailureResponse, this); + mOnSuccessCallback_1 = + new chip::Callback::Callback(OnTestSendClusterAccountLoginCommandLogin_1_SuccessResponse, this); + + chip::Controller::AccountLoginCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + chip::ByteSpan tempAccountIdentifierArgument = chip::ByteSpan(chip::Uint8::from_const_char("asdf"), strlen("asdf")); + chip::ByteSpan setupPINArgument = chip::ByteSpan(chip::Uint8::from_const_char("tempPin123"), strlen("tempPin123")); + err = cluster.Login(mOnSuccessCallback_1->Cancel(), mOnFailureCallback_1->Cancel(), tempAccountIdentifierArgument, + setupPINArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_1; + delete mOnSuccessCallback_1; + } + + return err; + } + + static void OnTestSendClusterAccountLoginCommandLogin_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Account Login - Login Command: Failure Response"); + + TV_AccountLoginCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterAccountLoginCommandLogin_1_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Account Login - Login Command: Success Response"); + + TV_AccountLoginCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_ApplicationBasicCluster : public TestCommand +{ +public: + TV_ApplicationBasicCluster() : TestCommand("TV_ApplicationBasicCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_ApplicationBasicCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterApplicationBasicCommandChangeStatus_0(); + break; + case 1: + err = TestSendClusterApplicationBasicCommandReadAttribute_1(); + break; + case 2: + err = TestSendClusterApplicationBasicCommandReadAttribute_2(); + break; + case 3: + err = TestSendClusterApplicationBasicCommandReadAttribute_3(); + break; + case 4: + err = TestSendClusterApplicationBasicCommandReadAttribute_4(); + break; + case 5: + err = TestSendClusterApplicationBasicCommandReadAttribute_5(); + break; + case 6: + err = TestSendClusterApplicationBasicCommandReadAttribute_6(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_ApplicationBasicCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 7; + + // + // Tests methods + // + + // Test Change Status Command + typedef void (*SuccessCallback_0)(void * context); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterApplicationBasicCommandChangeStatus_0() + { + ChipLogProgress(chipTool, "Application Basic - Change Status Command: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandChangeStatus_0_FailureResponse, this); + mOnSuccessCallback_0 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandChangeStatus_0_SuccessResponse, this); + + chip::Controller::ApplicationBasicCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint8_t statusArgument = 1; + err = cluster.ChangeStatus(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel(), statusArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterApplicationBasicCommandChangeStatus_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Basic - Change Status Command: Failure Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationBasicCommandChangeStatus_0_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Application Basic - Change Status Command: Success Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Read attribute vendor name + typedef void (*SuccessCallback_1)(void * context, chip::ByteSpan vendorName); + chip::Callback::Callback * mOnSuccessCallback_1 = nullptr; + chip::Callback::Callback * mOnFailureCallback_1 = nullptr; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterApplicationBasicCommandReadAttribute_1() + { + ChipLogProgress(chipTool, "Application Basic - Read attribute vendor name: Sending command..."); + + mOnFailureCallback_1 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_1_FailureResponse, this); + mOnSuccessCallback_1 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_1_SuccessResponse, this); + + chip::Controller::ApplicationBasicCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeVendorName(mOnSuccessCallback_1->Cancel(), mOnFailureCallback_1->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_1; + delete mOnSuccessCallback_1; + } + + return err; + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute vendor name: Failure Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_1_SuccessResponse(void * context, chip::ByteSpan vendorName) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute vendor name: Success Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Read attribute vendor id + typedef void (*SuccessCallback_2)(void * context, uint16_t vendorId); + chip::Callback::Callback * mOnSuccessCallback_2 = nullptr; + chip::Callback::Callback * mOnFailureCallback_2 = nullptr; + bool mIsFailureExpected_2 = 0; + + CHIP_ERROR TestSendClusterApplicationBasicCommandReadAttribute_2() + { + ChipLogProgress(chipTool, "Application Basic - Read attribute vendor id: Sending command..."); + + mOnFailureCallback_2 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_2_FailureResponse, this); + mOnSuccessCallback_2 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_2_SuccessResponse, this); + + chip::Controller::ApplicationBasicCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeVendorId(mOnSuccessCallback_2->Cancel(), mOnFailureCallback_2->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_2; + delete mOnSuccessCallback_2; + } + + return err; + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_2_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute vendor id: Failure Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_2_SuccessResponse(void * context, uint16_t vendorId) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute vendor id: Success Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (vendorId != 1U) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "1"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Read attribute name + typedef void (*SuccessCallback_3)(void * context, chip::ByteSpan applicationName); + chip::Callback::Callback * mOnSuccessCallback_3 = nullptr; + chip::Callback::Callback * mOnFailureCallback_3 = nullptr; + bool mIsFailureExpected_3 = 0; + + CHIP_ERROR TestSendClusterApplicationBasicCommandReadAttribute_3() + { + ChipLogProgress(chipTool, "Application Basic - Read attribute name: Sending command..."); + + mOnFailureCallback_3 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_3_FailureResponse, this); + mOnSuccessCallback_3 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_3_SuccessResponse, this); + + chip::Controller::ApplicationBasicCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeApplicationName(mOnSuccessCallback_3->Cancel(), mOnFailureCallback_3->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_3; + delete mOnSuccessCallback_3; + } + + return err; + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_3_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute name: Failure Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_3; + delete runner->mOnSuccessCallback_3; + + if (runner->mIsFailureExpected_3 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_3_SuccessResponse(void * context, + chip::ByteSpan applicationName) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute name: Success Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_3; + delete runner->mOnSuccessCallback_3; + + if (runner->mIsFailureExpected_3 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Read attribute product id + typedef void (*SuccessCallback_4)(void * context, uint16_t productId); + chip::Callback::Callback * mOnSuccessCallback_4 = nullptr; + chip::Callback::Callback * mOnFailureCallback_4 = nullptr; + bool mIsFailureExpected_4 = 0; + + CHIP_ERROR TestSendClusterApplicationBasicCommandReadAttribute_4() + { + ChipLogProgress(chipTool, "Application Basic - Read attribute product id: Sending command..."); + + mOnFailureCallback_4 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_4_FailureResponse, this); + mOnSuccessCallback_4 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_4_SuccessResponse, this); + + chip::Controller::ApplicationBasicCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeProductId(mOnSuccessCallback_4->Cancel(), mOnFailureCallback_4->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_4; + delete mOnSuccessCallback_4; + } + + return err; + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_4_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute product id: Failure Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_4; + delete runner->mOnSuccessCallback_4; + + if (runner->mIsFailureExpected_4 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_4_SuccessResponse(void * context, uint16_t productId) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute product id: Success Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_4; + delete runner->mOnSuccessCallback_4; + + if (runner->mIsFailureExpected_4 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (productId != 1U) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "1"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Read attribute id + typedef void (*SuccessCallback_5)(void * context, chip::ByteSpan applicationId); + chip::Callback::Callback * mOnSuccessCallback_5 = nullptr; + chip::Callback::Callback * mOnFailureCallback_5 = nullptr; + bool mIsFailureExpected_5 = 0; + + CHIP_ERROR TestSendClusterApplicationBasicCommandReadAttribute_5() + { + ChipLogProgress(chipTool, "Application Basic - Read attribute id: Sending command..."); + + mOnFailureCallback_5 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_5_FailureResponse, this); + mOnSuccessCallback_5 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_5_SuccessResponse, this); + + chip::Controller::ApplicationBasicCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeApplicationId(mOnSuccessCallback_5->Cancel(), mOnFailureCallback_5->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_5; + delete mOnSuccessCallback_5; + } + + return err; + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_5_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute id: Failure Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_5; + delete runner->mOnSuccessCallback_5; + + if (runner->mIsFailureExpected_5 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_5_SuccessResponse(void * context, + chip::ByteSpan applicationId) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute id: Success Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_5; + delete runner->mOnSuccessCallback_5; + + if (runner->mIsFailureExpected_5 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Read attribute catalog vendor id + typedef void (*SuccessCallback_6)(void * context, uint16_t catalogVendorId); + chip::Callback::Callback * mOnSuccessCallback_6 = nullptr; + chip::Callback::Callback * mOnFailureCallback_6 = nullptr; + bool mIsFailureExpected_6 = 0; + + CHIP_ERROR TestSendClusterApplicationBasicCommandReadAttribute_6() + { + ChipLogProgress(chipTool, "Application Basic - Read attribute catalog vendor id: Sending command..."); + + mOnFailureCallback_6 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_6_FailureResponse, this); + mOnSuccessCallback_6 = new chip::Callback::Callback( + OnTestSendClusterApplicationBasicCommandReadAttribute_6_SuccessResponse, this); + + chip::Controller::ApplicationBasicCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeCatalogVendorId(mOnSuccessCallback_6->Cancel(), mOnFailureCallback_6->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_6; + delete mOnSuccessCallback_6; + } + + return err; + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_6_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute catalog vendor id: Failure Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_6; + delete runner->mOnSuccessCallback_6; + + if (runner->mIsFailureExpected_6 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterApplicationBasicCommandReadAttribute_6_SuccessResponse(void * context, uint16_t catalogVendorId) + { + ChipLogProgress(chipTool, "Application Basic - Read attribute catalog vendor id: Success Response"); + + TV_ApplicationBasicCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_6; + delete runner->mOnSuccessCallback_6; + + if (runner->mIsFailureExpected_6 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (catalogVendorId != 1U) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "1"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_MediaPlaybackCluster : public TestCommand +{ +public: + TV_MediaPlaybackCluster() : TestCommand("TV_MediaPlaybackCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_MediaPlaybackCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterMediaPlaybackCommandMediaPlay_0(); + break; + case 1: + err = TestSendClusterMediaPlaybackCommandMediaPause_1(); + break; + case 2: + err = TestSendClusterMediaPlaybackCommandMediaStop_2(); + break; + case 3: + err = TestSendClusterMediaPlaybackCommandMediaStartOver_3(); + break; + case 4: + err = TestSendClusterMediaPlaybackCommandMediaPrevious_4(); + break; + case 5: + err = TestSendClusterMediaPlaybackCommandMediaNext_5(); + break; + case 6: + err = TestSendClusterMediaPlaybackCommandMediaRewind_6(); + break; + case 7: + err = TestSendClusterMediaPlaybackCommandMediaFastForward_7(); + break; + case 8: + err = TestSendClusterMediaPlaybackCommandMediaSkipForward_8(); + break; + case 9: + err = TestSendClusterMediaPlaybackCommandMediaSkipBackward_9(); + break; + case 10: + err = TestSendClusterMediaPlaybackCommandMediaSeek_10(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_MediaPlaybackCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + // + // Tests methods + // + + // Test Media Playback Play Command + typedef void (*SuccessCallback_0)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaPlay_0() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Play Command: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaPlay_0_FailureResponse, this); + mOnSuccessCallback_0 = + new chip::Callback::Callback(OnTestSendClusterMediaPlaybackCommandMediaPlay_0_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.MediaPlay(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaPlay_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Play Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaPlay_0_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Play Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Pause Command + typedef void (*SuccessCallback_1)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_1 = nullptr; + chip::Callback::Callback * mOnFailureCallback_1 = nullptr; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaPause_1() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Pause Command: Sending command..."); + + mOnFailureCallback_1 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaPause_1_FailureResponse, this); + mOnSuccessCallback_1 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaPause_1_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.MediaPause(mOnSuccessCallback_1->Cancel(), mOnFailureCallback_1->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_1; + delete mOnSuccessCallback_1; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaPause_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Pause Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaPause_1_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Pause Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Stop Command + typedef void (*SuccessCallback_2)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_2 = nullptr; + chip::Callback::Callback * mOnFailureCallback_2 = nullptr; + bool mIsFailureExpected_2 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaStop_2() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Stop Command: Sending command..."); + + mOnFailureCallback_2 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaStop_2_FailureResponse, this); + mOnSuccessCallback_2 = + new chip::Callback::Callback(OnTestSendClusterMediaPlaybackCommandMediaStop_2_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.MediaStop(mOnSuccessCallback_2->Cancel(), mOnFailureCallback_2->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_2; + delete mOnSuccessCallback_2; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaStop_2_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Stop Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaStop_2_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Stop Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Start Over Command + typedef void (*SuccessCallback_3)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_3 = nullptr; + chip::Callback::Callback * mOnFailureCallback_3 = nullptr; + bool mIsFailureExpected_3 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaStartOver_3() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Start Over Command: Sending command..."); + + mOnFailureCallback_3 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaStartOver_3_FailureResponse, this); + mOnSuccessCallback_3 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaStartOver_3_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.MediaStartOver(mOnSuccessCallback_3->Cancel(), mOnFailureCallback_3->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_3; + delete mOnSuccessCallback_3; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaStartOver_3_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Start Over Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_3; + delete runner->mOnSuccessCallback_3; + + if (runner->mIsFailureExpected_3 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaStartOver_3_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Start Over Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_3; + delete runner->mOnSuccessCallback_3; + + if (runner->mIsFailureExpected_3 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Previous Command + typedef void (*SuccessCallback_4)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_4 = nullptr; + chip::Callback::Callback * mOnFailureCallback_4 = nullptr; + bool mIsFailureExpected_4 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaPrevious_4() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Previous Command: Sending command..."); + + mOnFailureCallback_4 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaPrevious_4_FailureResponse, this); + mOnSuccessCallback_4 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaPrevious_4_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.MediaPrevious(mOnSuccessCallback_4->Cancel(), mOnFailureCallback_4->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_4; + delete mOnSuccessCallback_4; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaPrevious_4_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Previous Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_4; + delete runner->mOnSuccessCallback_4; + + if (runner->mIsFailureExpected_4 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaPrevious_4_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Previous Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_4; + delete runner->mOnSuccessCallback_4; + + if (runner->mIsFailureExpected_4 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Next Command + typedef void (*SuccessCallback_5)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_5 = nullptr; + chip::Callback::Callback * mOnFailureCallback_5 = nullptr; + bool mIsFailureExpected_5 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaNext_5() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Next Command: Sending command..."); + + mOnFailureCallback_5 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaNext_5_FailureResponse, this); + mOnSuccessCallback_5 = + new chip::Callback::Callback(OnTestSendClusterMediaPlaybackCommandMediaNext_5_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.MediaNext(mOnSuccessCallback_5->Cancel(), mOnFailureCallback_5->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_5; + delete mOnSuccessCallback_5; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaNext_5_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Next Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_5; + delete runner->mOnSuccessCallback_5; + + if (runner->mIsFailureExpected_5 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaNext_5_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Next Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_5; + delete runner->mOnSuccessCallback_5; + + if (runner->mIsFailureExpected_5 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Rewind Command + typedef void (*SuccessCallback_6)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_6 = nullptr; + chip::Callback::Callback * mOnFailureCallback_6 = nullptr; + bool mIsFailureExpected_6 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaRewind_6() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Rewind Command: Sending command..."); + + mOnFailureCallback_6 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaRewind_6_FailureResponse, this); + mOnSuccessCallback_6 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaRewind_6_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.MediaRewind(mOnSuccessCallback_6->Cancel(), mOnFailureCallback_6->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_6; + delete mOnSuccessCallback_6; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaRewind_6_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Rewind Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_6; + delete runner->mOnSuccessCallback_6; + + if (runner->mIsFailureExpected_6 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaRewind_6_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Rewind Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_6; + delete runner->mOnSuccessCallback_6; + + if (runner->mIsFailureExpected_6 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Fast Forward Command + typedef void (*SuccessCallback_7)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_7 = nullptr; + chip::Callback::Callback * mOnFailureCallback_7 = nullptr; + bool mIsFailureExpected_7 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaFastForward_7() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Fast Forward Command: Sending command..."); + + mOnFailureCallback_7 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaFastForward_7_FailureResponse, this); + mOnSuccessCallback_7 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaFastForward_7_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.MediaFastForward(mOnSuccessCallback_7->Cancel(), mOnFailureCallback_7->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_7; + delete mOnSuccessCallback_7; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaFastForward_7_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Fast Forward Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_7; + delete runner->mOnSuccessCallback_7; + + if (runner->mIsFailureExpected_7 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaFastForward_7_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Fast Forward Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_7; + delete runner->mOnSuccessCallback_7; + + if (runner->mIsFailureExpected_7 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Skip Forward Command + typedef void (*SuccessCallback_8)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_8 = nullptr; + chip::Callback::Callback * mOnFailureCallback_8 = nullptr; + bool mIsFailureExpected_8 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaSkipForward_8() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Skip Forward Command: Sending command..."); + + mOnFailureCallback_8 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaSkipForward_8_FailureResponse, this); + mOnSuccessCallback_8 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaSkipForward_8_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint64_t deltaPositionMillisecondsArgument = 100ULL; + err = cluster.MediaSkipForward(mOnSuccessCallback_8->Cancel(), mOnFailureCallback_8->Cancel(), + deltaPositionMillisecondsArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_8; + delete mOnSuccessCallback_8; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaSkipForward_8_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Skip Forward Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_8; + delete runner->mOnSuccessCallback_8; + + if (runner->mIsFailureExpected_8 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaSkipForward_8_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Skip Forward Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_8; + delete runner->mOnSuccessCallback_8; + + if (runner->mIsFailureExpected_8 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Skip Backward Command + typedef void (*SuccessCallback_9)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_9 = nullptr; + chip::Callback::Callback * mOnFailureCallback_9 = nullptr; + bool mIsFailureExpected_9 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaSkipBackward_9() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Skip Backward Command: Sending command..."); + + mOnFailureCallback_9 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaSkipBackward_9_FailureResponse, this); + mOnSuccessCallback_9 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaSkipBackward_9_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint64_t deltaPositionMillisecondsArgument = 100ULL; + err = cluster.MediaSkipBackward(mOnSuccessCallback_9->Cancel(), mOnFailureCallback_9->Cancel(), + deltaPositionMillisecondsArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_9; + delete mOnSuccessCallback_9; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaSkipBackward_9_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Skip Backward Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_9; + delete runner->mOnSuccessCallback_9; + + if (runner->mIsFailureExpected_9 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaSkipBackward_9_SuccessResponse(void * context, + uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Skip Backward Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_9; + delete runner->mOnSuccessCallback_9; + + if (runner->mIsFailureExpected_9 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Media Playback Seek Command + typedef void (*SuccessCallback_10)(void * context, uint8_t mediaPlaybackStatus); + chip::Callback::Callback * mOnSuccessCallback_10 = nullptr; + chip::Callback::Callback * mOnFailureCallback_10 = nullptr; + bool mIsFailureExpected_10 = 0; + + CHIP_ERROR TestSendClusterMediaPlaybackCommandMediaSeek_10() + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Seek Command: Sending command..."); + + mOnFailureCallback_10 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaSeek_10_FailureResponse, this); + mOnSuccessCallback_10 = new chip::Callback::Callback( + OnTestSendClusterMediaPlaybackCommandMediaSeek_10_SuccessResponse, this); + + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(mDevice, 3); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint64_t positionArgument = 100ULL; + err = cluster.MediaSeek(mOnSuccessCallback_10->Cancel(), mOnFailureCallback_10->Cancel(), positionArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_10; + delete mOnSuccessCallback_10; + } + + return err; + } + + static void OnTestSendClusterMediaPlaybackCommandMediaSeek_10_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Seek Command: Failure Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_10; + delete runner->mOnSuccessCallback_10; + + if (runner->mIsFailureExpected_10 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaPlaybackCommandMediaSeek_10_SuccessResponse(void * context, uint8_t mediaPlaybackStatus) + { + ChipLogProgress(chipTool, "Media Playback - Media Playback Seek Command: Success Response"); + + TV_MediaPlaybackCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_10; + delete runner->mOnSuccessCallback_10; + + if (runner->mIsFailureExpected_10 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (mediaPlaybackStatus != 0) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "0"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_TvChannelCluster : public TestCommand +{ +public: + TV_TvChannelCluster() : TestCommand("TV_TvChannelCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_TvChannelCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterTvChannelCommandReadAttribute_0(); + break; + case 1: + err = TestSendClusterTvChannelCommandChangeChannelByNumber_1(); + break; + case 2: + err = TestSendClusterTvChannelCommandSkipChannel_2(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_TvChannelCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + // + // Tests methods + // + + // Test Read attribute TV Channel list + typedef void (*SuccessCallback_0)(void * context, uint16_t count, _TvChannelInfo * tvChannelList); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterTvChannelCommandReadAttribute_0() + { + ChipLogProgress(chipTool, "TV Channel - Read attribute TV Channel list: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterTvChannelCommandReadAttribute_0_FailureResponse, this); + mOnSuccessCallback_0 = + new chip::Callback::Callback(OnTestSendClusterTvChannelCommandReadAttribute_0_SuccessResponse, this); + + chip::Controller::TvChannelCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeTvChannelList(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterTvChannelCommandReadAttribute_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "TV Channel - Read attribute TV Channel list: Failure Response"); + + TV_TvChannelCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterTvChannelCommandReadAttribute_0_SuccessResponse(void * context, uint16_t count, + _TvChannelInfo * tvChannelList) + { + ChipLogProgress(chipTool, "TV Channel - Read attribute TV Channel list: Success Response"); + + TV_TvChannelCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (count != 2) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "[object Object],[object Object]"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Change Channel By Number Command + typedef void (*SuccessCallback_1)(void * context); + chip::Callback::Callback * mOnSuccessCallback_1 = nullptr; + chip::Callback::Callback * mOnFailureCallback_1 = nullptr; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterTvChannelCommandChangeChannelByNumber_1() + { + ChipLogProgress(chipTool, "TV Channel - Change Channel By Number Command: Sending command..."); + + mOnFailureCallback_1 = new chip::Callback::Callback( + OnTestSendClusterTvChannelCommandChangeChannelByNumber_1_FailureResponse, this); + mOnSuccessCallback_1 = new chip::Callback::Callback( + OnTestSendClusterTvChannelCommandChangeChannelByNumber_1_SuccessResponse, this); + + chip::Controller::TvChannelCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint16_t majorNumberArgument = 1U; + uint16_t minorNumberArgument = 2U; + err = cluster.ChangeChannelByNumber(mOnSuccessCallback_1->Cancel(), mOnFailureCallback_1->Cancel(), majorNumberArgument, + minorNumberArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_1; + delete mOnSuccessCallback_1; + } + + return err; + } + + static void OnTestSendClusterTvChannelCommandChangeChannelByNumber_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "TV Channel - Change Channel By Number Command: Failure Response"); + + TV_TvChannelCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterTvChannelCommandChangeChannelByNumber_1_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "TV Channel - Change Channel By Number Command: Success Response"); + + TV_TvChannelCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Skip Channel Command + typedef void (*SuccessCallback_2)(void * context); + chip::Callback::Callback * mOnSuccessCallback_2 = nullptr; + chip::Callback::Callback * mOnFailureCallback_2 = nullptr; + bool mIsFailureExpected_2 = 0; + + CHIP_ERROR TestSendClusterTvChannelCommandSkipChannel_2() + { + ChipLogProgress(chipTool, "TV Channel - Skip Channel Command: Sending command..."); + + mOnFailureCallback_2 = new chip::Callback::Callback( + OnTestSendClusterTvChannelCommandSkipChannel_2_FailureResponse, this); + mOnSuccessCallback_2 = + new chip::Callback::Callback(OnTestSendClusterTvChannelCommandSkipChannel_2_SuccessResponse, this); + + chip::Controller::TvChannelCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint16_t countArgument = 1U; + err = cluster.SkipChannel(mOnSuccessCallback_2->Cancel(), mOnFailureCallback_2->Cancel(), countArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_2; + delete mOnSuccessCallback_2; + } + + return err; + } + + static void OnTestSendClusterTvChannelCommandSkipChannel_2_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "TV Channel - Skip Channel Command: Failure Response"); + + TV_TvChannelCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterTvChannelCommandSkipChannel_2_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "TV Channel - Skip Channel Command: Success Response"); + + TV_TvChannelCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_LowPowerCluster : public TestCommand +{ +public: + TV_LowPowerCluster() : TestCommand("TV_LowPowerCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_LowPowerCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterLowPowerCommandSleep_0(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_LowPowerCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 1; + + // + // Tests methods + // + + // Test Sleep Input Status Command + typedef void (*SuccessCallback_0)(void * context); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterLowPowerCommandSleep_0() + { + ChipLogProgress(chipTool, "Low Power - Sleep Input Status Command: Sending command..."); + + mOnFailureCallback_0 = + new chip::Callback::Callback(OnTestSendClusterLowPowerCommandSleep_0_FailureResponse, this); + mOnSuccessCallback_0 = + new chip::Callback::Callback(OnTestSendClusterLowPowerCommandSleep_0_SuccessResponse, this); + + chip::Controller::LowPowerCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.Sleep(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterLowPowerCommandSleep_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Low Power - Sleep Input Status Command: Failure Response"); + + TV_LowPowerCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterLowPowerCommandSleep_0_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Low Power - Sleep Input Status Command: Success Response"); + + TV_LowPowerCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + +class TV_MediaInputCluster : public TestCommand +{ +public: + TV_MediaInputCluster() : TestCommand("TV_MediaInputCluster"), mTestIndex(0) {} + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "TV_MediaInputCluster: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterMediaInputCommandReadAttribute_0(); + break; + case 1: + err = TestSendClusterMediaInputCommandSelectInput_1(); + break; + case 2: + err = TestSendClusterMediaInputCommandHideInputStatus_2(); + break; + case 3: + err = TestSendClusterMediaInputCommandShowInputStatus_3(); + break; + case 4: + err = TestSendClusterMediaInputCommandRenameInput_4(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "TV_MediaInputCluster: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + // + // Tests methods + // + + // Test Read attribute media input list + typedef void (*SuccessCallback_0)(void * context, uint16_t count, _MediaInputInfo * mediaInputList); + chip::Callback::Callback * mOnSuccessCallback_0 = nullptr; + chip::Callback::Callback * mOnFailureCallback_0 = nullptr; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterMediaInputCommandReadAttribute_0() + { + ChipLogProgress(chipTool, "Media Input - Read attribute media input list: Sending command..."); + + mOnFailureCallback_0 = new chip::Callback::Callback( + OnTestSendClusterMediaInputCommandReadAttribute_0_FailureResponse, this); + mOnSuccessCallback_0 = new chip::Callback::Callback( + OnTestSendClusterMediaInputCommandReadAttribute_0_SuccessResponse, this); + + chip::Controller::MediaInputCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ReadAttributeMediaInputList(mOnSuccessCallback_0->Cancel(), mOnFailureCallback_0->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_0; + delete mOnSuccessCallback_0; + } + + return err; + } + + static void OnTestSendClusterMediaInputCommandReadAttribute_0_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Input - Read attribute media input list: Failure Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaInputCommandReadAttribute_0_SuccessResponse(void * context, uint16_t count, + _MediaInputInfo * mediaInputList) + { + ChipLogProgress(chipTool, "Media Input - Read attribute media input list: Success Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_0; + delete runner->mOnSuccessCallback_0; + + if (runner->mIsFailureExpected_0 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + if (count != 2) + { + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "[object Object],[object Object]"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Select Input Command + typedef void (*SuccessCallback_1)(void * context); + chip::Callback::Callback * mOnSuccessCallback_1 = nullptr; + chip::Callback::Callback * mOnFailureCallback_1 = nullptr; + bool mIsFailureExpected_1 = 0; + + CHIP_ERROR TestSendClusterMediaInputCommandSelectInput_1() + { + ChipLogProgress(chipTool, "Media Input - Select Input Command: Sending command..."); + + mOnFailureCallback_1 = new chip::Callback::Callback( + OnTestSendClusterMediaInputCommandSelectInput_1_FailureResponse, this); + mOnSuccessCallback_1 = + new chip::Callback::Callback(OnTestSendClusterMediaInputCommandSelectInput_1_SuccessResponse, this); + + chip::Controller::MediaInputCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint8_t indexArgument = 1; + err = cluster.SelectInput(mOnSuccessCallback_1->Cancel(), mOnFailureCallback_1->Cancel(), indexArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_1; + delete mOnSuccessCallback_1; + } + + return err; + } + + static void OnTestSendClusterMediaInputCommandSelectInput_1_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Input - Select Input Command: Failure Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaInputCommandSelectInput_1_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Media Input - Select Input Command: Success Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_1; + delete runner->mOnSuccessCallback_1; + + if (runner->mIsFailureExpected_1 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Hide Input Status Command + typedef void (*SuccessCallback_2)(void * context); + chip::Callback::Callback * mOnSuccessCallback_2 = nullptr; + chip::Callback::Callback * mOnFailureCallback_2 = nullptr; + bool mIsFailureExpected_2 = 0; + + CHIP_ERROR TestSendClusterMediaInputCommandHideInputStatus_2() + { + ChipLogProgress(chipTool, "Media Input - Hide Input Status Command: Sending command..."); + + mOnFailureCallback_2 = new chip::Callback::Callback( + OnTestSendClusterMediaInputCommandHideInputStatus_2_FailureResponse, this); + mOnSuccessCallback_2 = new chip::Callback::Callback( + OnTestSendClusterMediaInputCommandHideInputStatus_2_SuccessResponse, this); + + chip::Controller::MediaInputCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.HideInputStatus(mOnSuccessCallback_2->Cancel(), mOnFailureCallback_2->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_2; + delete mOnSuccessCallback_2; + } + + return err; + } + + static void OnTestSendClusterMediaInputCommandHideInputStatus_2_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Input - Hide Input Status Command: Failure Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaInputCommandHideInputStatus_2_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Media Input - Hide Input Status Command: Success Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_2; + delete runner->mOnSuccessCallback_2; + + if (runner->mIsFailureExpected_2 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Show Input Status Command + typedef void (*SuccessCallback_3)(void * context); + chip::Callback::Callback * mOnSuccessCallback_3 = nullptr; + chip::Callback::Callback * mOnFailureCallback_3 = nullptr; + bool mIsFailureExpected_3 = 0; + + CHIP_ERROR TestSendClusterMediaInputCommandShowInputStatus_3() + { + ChipLogProgress(chipTool, "Media Input - Show Input Status Command: Sending command..."); + + mOnFailureCallback_3 = new chip::Callback::Callback( + OnTestSendClusterMediaInputCommandShowInputStatus_3_FailureResponse, this); + mOnSuccessCallback_3 = new chip::Callback::Callback( + OnTestSendClusterMediaInputCommandShowInputStatus_3_SuccessResponse, this); + + chip::Controller::MediaInputCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + err = cluster.ShowInputStatus(mOnSuccessCallback_3->Cancel(), mOnFailureCallback_3->Cancel()); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_3; + delete mOnSuccessCallback_3; + } + + return err; + } + + static void OnTestSendClusterMediaInputCommandShowInputStatus_3_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Input - Show Input Status Command: Failure Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_3; + delete runner->mOnSuccessCallback_3; + + if (runner->mIsFailureExpected_3 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaInputCommandShowInputStatus_3_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Media Input - Show Input Status Command: Success Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_3; + delete runner->mOnSuccessCallback_3; + + if (runner->mIsFailureExpected_3 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + // Test Rename Input Command + typedef void (*SuccessCallback_4)(void * context); + chip::Callback::Callback * mOnSuccessCallback_4 = nullptr; + chip::Callback::Callback * mOnFailureCallback_4 = nullptr; + bool mIsFailureExpected_4 = 0; + + CHIP_ERROR TestSendClusterMediaInputCommandRenameInput_4() + { + ChipLogProgress(chipTool, "Media Input - Rename Input Command: Sending command..."); + + mOnFailureCallback_4 = new chip::Callback::Callback( + OnTestSendClusterMediaInputCommandRenameInput_4_FailureResponse, this); + mOnSuccessCallback_4 = + new chip::Callback::Callback(OnTestSendClusterMediaInputCommandRenameInput_4_SuccessResponse, this); + + chip::Controller::MediaInputCluster cluster; + cluster.Associate(mDevice, 1); + + CHIP_ERROR err = CHIP_NO_ERROR; + + uint8_t indexArgument = 1; + chip::ByteSpan nameArgument = chip::ByteSpan(chip::Uint8::from_const_char("newName"), strlen("newName")); + err = cluster.RenameInput(mOnSuccessCallback_4->Cancel(), mOnFailureCallback_4->Cancel(), indexArgument, nameArgument); + + if (CHIP_NO_ERROR != err) + { + delete mOnFailureCallback_4; + delete mOnSuccessCallback_4; + } + + return err; + } + + static void OnTestSendClusterMediaInputCommandRenameInput_4_FailureResponse(void * context, uint8_t status) + { + ChipLogProgress(chipTool, "Media Input - Rename Input Command: Failure Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_4; + delete runner->mOnSuccessCallback_4; + + if (runner->mIsFailureExpected_4 == false) + { + ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } + + static void OnTestSendClusterMediaInputCommandRenameInput_4_SuccessResponse(void * context) + { + ChipLogProgress(chipTool, "Media Input - Rename Input Command: Success Response"); + + TV_MediaInputCluster * runner = reinterpret_cast(context); + + delete runner->mOnFailureCallback_4; + delete runner->mOnSuccessCallback_4; + + if (runner->mIsFailureExpected_4 == true) + { + ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); + return; + } + + runner->NextTest(); + } +}; + class TestCluster : public TestCommand { public: @@ -11831,8 +15066,22 @@ void registerCommandsTests(Commands & commands) const char * clusterName = "Tests"; commands_list clusterCommands = { - make_unique(), make_unique(), make_unique(), - make_unique(), make_unique(), make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), }; commands.Register(clusterName, clusterCommands); diff --git a/examples/chip-tool/templates/tests-commands.zapt b/examples/chip-tool/templates/tests-commands.zapt index be551aad14839d..1d6a546504d3a0 100644 --- a/examples/chip-tool/templates/tests-commands.zapt +++ b/examples/chip-tool/templates/tests-commands.zapt @@ -4,13 +4,23 @@ #include "TestCommand.h" -{{>test_cluster tests="TestCluster, Test_TC_OO_1_1, Test_TC_OO_2_1, Test_TC_OO_2_2, Test_TC_DM_1_1, Test_TC_DM_3_1"}} +{{>test_cluster tests="TV_TargetNavigatorCluster, TV_AudioOutputCluster, TV_ApplicationLauncherCluster, TV_KeypadInputCluster, TV_AccountLoginCluster, TV_ApplicationBasicCluster, TV_MediaPlaybackCluster, TV_TvChannelCluster, TV_LowPowerCluster, TV_MediaInputCluster, TestCluster, Test_TC_OO_1_1, Test_TC_OO_2_1, Test_TC_OO_2_2, Test_TC_DM_1_1, Test_TC_DM_3_1"}} void registerCommandsTests(Commands & commands) { const char * clusterName = "Tests"; commands_list clusterCommands = { + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), diff --git a/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp b/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp index c82d70c8b6fa4a..8993d81a622cad 100644 --- a/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp +++ b/examples/tv-app/linux/include/account-login/AccountLoginManager.cpp @@ -29,10 +29,13 @@ using namespace std; bool AccountLoginManager::isUserLoggedIn(string requestTempAccountIdentifier, string requestSetupPin) { + // TODO: Fix hardcoding length of strings + requestTempAccountIdentifier = requestTempAccountIdentifier.substr(0, 4); + requestSetupPin = requestSetupPin.substr(0, 10); for (auto it = accounts.cbegin(); it != accounts.cend(); ++it) { - emberAfAccountLoginClusterPrintln("temporary account id: %s", it->first); - emberAfAccountLoginClusterPrintln("setup pin %s", it->second); + ChipLogProgress(Zcl, "temporary account id: %s", it->first.c_str()); + ChipLogProgress(Zcl, "setup pin %s", it->second.c_str()); } if (accounts.find(requestTempAccountIdentifier) != accounts.end()) @@ -55,43 +58,25 @@ bool AccountLoginManager::isUserLoggedIn(string requestTempAccountIdentifier, st void AccountLoginManager::setTempAccountIdentifierForPin(string tempAccountIdentifier, string setupPin) { - accounts[tempAccountIdentifier] = setupPin; + // TODO: Fix hardcoding length of strings + string tempId = tempAccountIdentifier.substr(0, 4); + accounts[tempId] = setupPin; } string AccountLoginManager::proxySetupPinRequest(string requestTempAccountIdentifier, chip::EndpointId endpoint) { // TODO: Insert your code here to send temp account identifier request - return "HtempPin123"; + return "tempPin123"; } -bool emberAfAccountLoginClusterGetSetupPINCallback(chip::app::Command * command, unsigned char * tempAccountIdentifier) +bool accountLoginClusterIsUserLoggedIn(std::string requestTempAccountIdentifier, std::string requestSetupPin) { - string tempAccountIdentifierString(reinterpret_cast(tempAccountIdentifier)); - - string responseSetupPin = AccountLoginManager().proxySetupPinRequest(tempAccountIdentifierString, emberAfCurrentEndpoint()); - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_ACCOUNT_LOGIN_CLUSTER_ID, - ZCL_GET_SETUP_PIN_RESPONSE_COMMAND_ID, "s", &responseSetupPin); - - EmberStatus status = emberAfSendResponse(); - if (status != EMBER_SUCCESS) - { - ChipLogError(Zcl, "Failed to send %s. Error:%s", "GetSetupPIN", chip::ErrorStr(EMBER_ZCL_STATUS_NOT_AUTHORIZED)); - } - AccountLoginManager().GetInstance().setTempAccountIdentifierForPin(tempAccountIdentifierString, responseSetupPin); - return true; + return AccountLoginManager().GetInstance().isUserLoggedIn(requestTempAccountIdentifier, requestSetupPin); } -bool emberAfAccountLoginClusterLoginCallback(chip::app::Command * command, unsigned char * tempAccountIdentifier, - unsigned char * tempSetupPin) +std::string accountLoginClusterGetSetupPin(std::string requestTempAccountIdentifier, chip::EndpointId endpoint) { - string tempAccountIdentifierString(reinterpret_cast(tempAccountIdentifier)); - string tempSetupPinString(reinterpret_cast(tempSetupPin)); - bool isUserLoggedIn = AccountLoginManager().GetInstance().isUserLoggedIn(tempAccountIdentifierString, tempSetupPinString); - EmberAfStatus status = isUserLoggedIn ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_NOT_AUTHORIZED; - if (!isUserLoggedIn) - { - ChipLogError(Zcl, "User is not authorized. Error:%s", chip::ErrorStr(EMBER_ZCL_STATUS_NOT_AUTHORIZED)); - } - emberAfSendImmediateDefaultResponse(status); - return true; + string responseSetupPin = AccountLoginManager().proxySetupPinRequest(requestTempAccountIdentifier, endpoint); + AccountLoginManager().GetInstance().setTempAccountIdentifierForPin(requestTempAccountIdentifier, responseSetupPin); + return responseSetupPin; } diff --git a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp b/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp index bd4b598e34dafe..9edee7c04019ce 100644 --- a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp +++ b/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp @@ -146,18 +146,9 @@ Application ApplicationBasicManager::getApplicationForEndpoint(chip::EndpointId return app; } -bool ApplicationBasicManager::proxyChangeApplicationStatusRequest(EmberAfApplicationBasicStatus status, chip::EndpointId endpoint) +bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, chip::EndpointId endpoint) { // TODO: Insert code here ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", status, endpoint); return true; } - -bool emberAfApplicationBasicClusterChangeStatusCallback(chip::app::Command * commandObj, uint8_t newApplicationStatus) -{ - bool success = ApplicationBasicManager().proxyChangeApplicationStatusRequest( - static_cast(newApplicationStatus), emberAfCurrentEndpoint()); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); - return true; -} diff --git a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.h b/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.h index 61131fa70492fe..177cde404928c9 100644 --- a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.h +++ b/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.h @@ -30,7 +30,6 @@ class ApplicationBasicManager public: CHIP_ERROR Init(); void store(chip::EndpointId endpoint, Application * application); - bool proxyChangeApplicationStatusRequest(EmberAfApplicationBasicStatus status, chip::EndpointId endpoint); Application getApplicationForEndpoint(chip::EndpointId endpoint); static ApplicationBasicManager & GetInstance() diff --git a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp b/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp index 9a4977b5a8f99d..056669bbd73226 100644 --- a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp +++ b/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.cpp @@ -17,12 +17,7 @@ */ #include "ApplicationLauncherManager.h" - -#include -#include -#include -#include - +#include #include #include @@ -45,56 +40,16 @@ vector ApplicationLauncherManager::proxyGetApplicationList() return applications; } -ApplicationLaunchResponse ApplicationLauncherManager::proxyApplicationLaunchRequest(EmberAfApplicationLauncherApp application, - string data) +ApplicationLauncherResponse applicationLauncherClusterLaunchApp(EmberAfApplicationLauncherApp application, std::string data) { // TODO: Insert your code - ApplicationLaunchResponse response; - response.data = "data"; - response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS; + ApplicationLauncherResponse response; + const char * testData = "data"; + response.data = (uint8_t *) testData; + response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS; // TODO: Update once storing a structure attribute is supported // emberAfWriteServerAttribute(endpoint, ZCL_APPLICATION_LAUNCH_CLUSTER_ID, ZCL_APPLICATION_LAUNCHER_CURRENT_APP_APPLICATION_ID, // (uint8_t *) &application, ZCL_STRUCT_ATTRIBUTE_TYPE); return response; } - -static void sendResponse(const char * responseName, ApplicationLaunchResponse response) -{ - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), - ZCL_APPLICATION_LAUNCHER_CLUSTER_ID, ZCL_LAUNCH_APP_RESPONSE_COMMAND_ID, "us", response.status, - &response.data); - - EmberStatus status = emberAfSendResponse(); - if (status != EMBER_SUCCESS) - { - ChipLogError(Zcl, "Failed to send %s. Error:%s", responseName, chip::ErrorStr(status)); - } -} - -EmberAfApplicationLauncherApp getApplicationFromCommand(EmberAfClusterCommand * cmd, unsigned char * reqestData, - uint8_t * requestApplication) -{ - string reqestDataString(reinterpret_cast(reqestData)); - - uint16_t extensionFieldSetsLen = - static_cast(cmd->bufLen - (cmd->payloadStartIndex + emberAfStringLength((uint8_t *) reqestData) + 1)); - uint16_t catalogVendorId = emberAfGetInt16u(requestApplication, 0, extensionFieldSetsLen); - uint8_t * applicationId = emberAfGetString(requestApplication, 0, extensionFieldSetsLen); - - EmberAfApplicationLauncherApp application = {}; - application.applicationId = applicationId; - application.catalogVendorId = catalogVendorId; - return application; -} - -bool emberAfApplicationLauncherClusterLaunchAppCallback(unsigned char * reqestData, uint8_t * requestApplication) -{ - EmberAfApplicationLauncherApp application = getApplicationFromCommand(emberAfCurrentCommand(), reqestData, requestApplication); - string reqestDataString(reinterpret_cast(reqestData)); - - ApplicationLaunchResponse response = ApplicationLauncherManager().proxyApplicationLaunchRequest(application, reqestDataString); - - sendResponse("LaunchAppResponse", response); - return true; -} diff --git a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h b/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h index 44eb238c0f2eaa..ebaf0950abbfaa 100644 --- a/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h +++ b/examples/tv-app/linux/include/application-launcher/ApplicationLauncherManager.h @@ -24,16 +24,9 @@ #include #include -struct ApplicationLaunchResponse -{ - EmberAfApplicationLauncherStatus status; - std::string data; -}; - class ApplicationLauncherManager { public: CHIP_ERROR Init(); - ApplicationLaunchResponse proxyApplicationLaunchRequest(EmberAfApplicationLauncherApp application, std::string data); std::vector proxyGetApplicationList(); }; diff --git a/examples/tv-app/linux/include/audio-output/AudioOutputManager.cpp b/examples/tv-app/linux/include/audio-output/AudioOutputManager.cpp index 377853248fd0d3..0c0331dedd5c6d 100644 --- a/examples/tv-app/linux/include/audio-output/AudioOutputManager.cpp +++ b/examples/tv-app/linux/include/audio-output/AudioOutputManager.cpp @@ -18,11 +18,6 @@ #include "AudioOutputManager.h" -#include -#include -#include -#include -#include #include #include #include @@ -63,29 +58,13 @@ vector AudioOutputManager::proxyGetListOfAudioOutputInfo return audioOutputInfos; } -bool AudioOutputManager::proxySelectOutputRequest(uint8_t index) +bool audioOutputClusterSelectOutput(uint8_t index) { // TODO: Insert code here return true; } -bool AudioOutputManager::proxyRenameOutputRequest(uint8_t index, uint8_t * name) +bool audioOutputClusterRenameOutput(uint8_t index, uint8_t * name) { // TODO: Insert code here return true; } - -bool emberAfAudioOutputClusterRenameOutputCallback(chip::app::Command * command, unsigned char index, uint8_t * name) -{ - bool success = AudioOutputManager().proxyRenameOutputRequest(index, name); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); - return true; -} - -bool emberAfAudioOutputClusterSelectOutputCallback(chip::app::Command * command, unsigned char index) -{ - bool success = AudioOutputManager().proxySelectOutputRequest(index); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); - return true; -} diff --git a/examples/tv-app/linux/include/audio-output/AudioOutputManager.h b/examples/tv-app/linux/include/audio-output/AudioOutputManager.h index 00119e0b90e0bd..2b7f03c62f38e8 100644 --- a/examples/tv-app/linux/include/audio-output/AudioOutputManager.h +++ b/examples/tv-app/linux/include/audio-output/AudioOutputManager.h @@ -26,7 +26,5 @@ class AudioOutputManager { public: CHIP_ERROR Init(); - bool proxySelectOutputRequest(uint8_t index); - bool proxyRenameOutputRequest(uint8_t index, uint8_t * name); std::vector proxyGetListOfAudioOutputInfo(); }; diff --git a/examples/tv-app/linux/include/endpoint-configuration/chip_tv_config.ini b/examples/tv-app/linux/include/endpoint-configuration/chip_tv_config.ini index 6339c17baae38f..7cca7457aa40f6 100644 --- a/examples/tv-app/linux/include/endpoint-configuration/chip_tv_config.ini +++ b/examples/tv-app/linux/include/endpoint-configuration/chip_tv_config.ini @@ -1,11 +1,11 @@ -[endpoint0] +[endpoint1] type=videoPlayer macAddress=00:00:00:00:00 -[endpoint1] +[endpoint2] type=speaker -[endpoint2] +[endpoint3] type=app vendorName=exampleVendorName1 vendorId=1 @@ -14,7 +14,7 @@ productId=1 id=1 catalogVendorId=1 -[endpoint3] +[endpoint4] type=app vendorName=exampleVendorName2 vendorId=2 @@ -23,7 +23,7 @@ productId=2 id=2 catalogVendorId=2 -[endpoint4] +[endpoint5] type=app vendorName=exampleVendorName3 vendorId=3 @@ -32,7 +32,7 @@ productId=3 id= 3 catalogVendorId=3 -[endpoint5] +[endpoint6] type=app vendorName=exampleVendorName4 vendorId=4 diff --git a/examples/tv-app/linux/include/keypad-input/KeypadInputManager.cpp b/examples/tv-app/linux/include/keypad-input/KeypadInputManager.cpp index aadfdb9eabacf6..58a39ab91bb6b4 100644 --- a/examples/tv-app/linux/include/keypad-input/KeypadInputManager.cpp +++ b/examples/tv-app/linux/include/keypad-input/KeypadInputManager.cpp @@ -18,10 +18,6 @@ #include "KeypadInputManager.h" -#include -#include -#include -#include #include #include @@ -45,28 +41,8 @@ CHIP_ERROR KeypadInputManager::Init() return err; } -EmberAfKeypadInputStatus KeypadInputManager::proxyKeypadInputRequest(EmberAfKeypadInputCecKeyCode keyCode) +EmberAfKeypadInputStatus keypadInputClusterSendKey(EmberAfKeypadInputCecKeyCode keyCode) { // TODO: Insert code here return EMBER_ZCL_KEYPAD_INPUT_STATUS_SUCCESS; } - -static void sendResponse(const char * responseName, EmberAfKeypadInputStatus keypadInputStatus) -{ - static_assert(std::is_same, uint8_t>::value, "Wrong enum size"); - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_KEYPAD_INPUT_CLUSTER_ID, - ZCL_SEND_KEY_RESPONSE_COMMAND_ID, "u", keypadInputStatus); - - EmberStatus status = emberAfSendResponse(); - if (status != EMBER_SUCCESS) - { - ChipLogError(Zcl, "Failed to send %s. Error:%s", responseName, chip::ErrorStr(EMBER_ZCL_STATUS_NOT_AUTHORIZED)); - } -} - -bool emberAfKeypadInputClusterSendKeyCallback(EmberAfKeypadInputCecKeyCode keyCode) -{ - EmberAfKeypadInputStatus status = KeypadInputManager().proxyKeypadInputRequest(keyCode); - sendResponse("KeypadInputResponse", status); - return true; -} diff --git a/examples/tv-app/linux/include/keypad-input/KeypadInputManager.h b/examples/tv-app/linux/include/keypad-input/KeypadInputManager.h index ad63185ccc1460..235d2e5ccb61e4 100644 --- a/examples/tv-app/linux/include/keypad-input/KeypadInputManager.h +++ b/examples/tv-app/linux/include/keypad-input/KeypadInputManager.h @@ -27,5 +27,4 @@ class KeypadInputManager { public: CHIP_ERROR Init(); - EmberAfKeypadInputStatus proxyKeypadInputRequest(EmberAfKeypadInputCecKeyCode keyCode); }; diff --git a/examples/tv-app/linux/include/low-power/LowPowerManager.cpp b/examples/tv-app/linux/include/low-power/LowPowerManager.cpp index 4262efabe89dac..97016d4b01a74f 100644 --- a/examples/tv-app/linux/include/low-power/LowPowerManager.cpp +++ b/examples/tv-app/linux/include/low-power/LowPowerManager.cpp @@ -18,23 +18,8 @@ #include "LowPowerManager.h" -#include - -#include -#include -#include -#include - -bool LowPowerManager::proxySleepRequest() +bool lowPowerClusterSleep() { // TODO: Insert code here return true; } - -bool emberAfLowPowerClusterSleepCallback() -{ - bool success = LowPowerManager().proxySleepRequest(); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); - return true; -} diff --git a/examples/tv-app/linux/include/low-power/LowPowerManager.h b/examples/tv-app/linux/include/low-power/LowPowerManager.h index 56bc3c7532730c..bfc50cb491a120 100644 --- a/examples/tv-app/linux/include/low-power/LowPowerManager.h +++ b/examples/tv-app/linux/include/low-power/LowPowerManager.h @@ -23,5 +23,4 @@ class LowPowerManager { public: - bool proxySleepRequest(); }; diff --git a/examples/tv-app/linux/include/media-input/MediaInputManager.cpp b/examples/tv-app/linux/include/media-input/MediaInputManager.cpp index 3ff43bcc68ae75..610defa80816a0 100644 --- a/examples/tv-app/linux/include/media-input/MediaInputManager.cpp +++ b/examples/tv-app/linux/include/media-input/MediaInputManager.cpp @@ -16,10 +16,7 @@ */ #include "MediaInputManager.h" -#include -#include -#include -#include + #include #include #include @@ -38,30 +35,6 @@ CHIP_ERROR MediaInputManager::Init() return err; } -bool MediaInputManager::proxySelectInputRequest(uint8_t input) -{ - // TODO: Insert code here - return true; -} - -bool MediaInputManager::proxyShowInputStatusRequest() -{ - // TODO: Insert code here - return true; -} - -bool MediaInputManager::proxyHideInputStatusRequest() -{ - // TODO: Insert code here - return true; -} - -bool MediaInputManager::proxyRenameInputRequest(uint8_t input, std::string name) -{ - // TODO: Insert code here - return true; -} - std::vector MediaInputManager::proxyGetInputList() { // TODO: Insert code here @@ -83,50 +56,23 @@ std::vector MediaInputManager::proxyGetInputList() return mediaInputList; } -static void storeCurrentInput(chip::EndpointId endpoint, uint8_t currentInput) +bool mediaInputClusterSelectInput(uint8_t input) { - EmberAfStatus status = - emberAfWriteServerAttribute(endpoint, ZCL_MEDIA_INPUT_CLUSTER_ID, ZCL_MEDIA_INPUT_CURRENT_INPUT_ATTRIBUTE_ID, - (uint8_t *) ¤tInput, ZCL_INT8U_ATTRIBUTE_TYPE); - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - ChipLogError(Zcl, "Failed to store media playback attribute."); - } -} - -bool emberAfMediaInputClusterSelectInputCallback(uint8_t input) -{ - bool success = MediaInputManager().proxySelectInputRequest(input); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - if (success) - { - storeCurrentInput(emberAfCurrentEndpoint(), input); - } - emberAfSendImmediateDefaultResponse(status); + // TODO: Insert code here return true; } - -bool emberAfMediaInputClusterShowInputStatusCallback() +bool mediaInputClusterShowInputStatus() { - bool success = MediaInputManager().proxyShowInputStatusRequest(); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); + // TODO: Insert code here return true; } - -bool emberAfMediaInputClusterHideInputStatusCallback() +bool mediaInputClusterHideInputStatus() { - bool success = MediaInputManager().proxyHideInputStatusRequest(); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); + // TODO: Insert code here return true; } - -bool emberAfMediaInputClusterRenameInputCallback(uint8_t input, char * name) +bool mediaInputClusterRenameInput(uint8_t input, std::string name) { - std::string nameString(name); - bool success = MediaInputManager().proxyRenameInputRequest(input, nameString); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); + // TODO: Insert code here return true; } diff --git a/examples/tv-app/linux/include/media-input/MediaInputManager.h b/examples/tv-app/linux/include/media-input/MediaInputManager.h index 58eb516fa87a44..e802479440eb2d 100644 --- a/examples/tv-app/linux/include/media-input/MediaInputManager.h +++ b/examples/tv-app/linux/include/media-input/MediaInputManager.h @@ -29,8 +29,4 @@ class MediaInputManager public: CHIP_ERROR Init(); std::vector proxyGetInputList(); - bool proxySelectInputRequest(uint8_t input); - bool proxyShowInputStatusRequest(); - bool proxyHideInputStatusRequest(); - bool proxyRenameInputRequest(uint8_t input, std::string name); }; diff --git a/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp b/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp index f50efd601806b4..3146f0c3d79036 100644 --- a/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp +++ b/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.cpp @@ -17,10 +17,6 @@ #include "MediaPlaybackManager.h" #include -#include -#include -#include -#include #include #include @@ -42,81 +38,32 @@ CHIP_ERROR MediaPlaybackManager::Init() return err; } -static void writePlaybackState(chip::EndpointId endpoint, uint8_t playbackState) -{ - EmberAfStatus status = - emberAfWriteServerAttribute(endpoint, ZCL_MEDIA_PLAYBACK_CLUSTER_ID, ZCL_MEDIA_PLAYBACK_STATE_ATTRIBUTE_ID, - (uint8_t *) &playbackState, ZCL_INT8U_ATTRIBUTE_TYPE); - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - ChipLogError(Zcl, "Failed to store media playback attribute."); - } -} - -static uint8_t readPlaybackStatus(chip::EndpointId endpoint) -{ - uint8_t playbackState; - EmberAfStatus status = - emberAfReadServerAttribute(endpoint, ZCL_MEDIA_PLAYBACK_CLUSTER_ID, ZCL_MEDIA_PLAYBACK_STATE_ATTRIBUTE_ID, - (uint8_t *) &playbackState, sizeof(uint8_t)); - if (status != EMBER_ZCL_STATUS_SUCCESS) - { - ChipLogError(Zcl, "Failed to read media playback attribute."); - } - - return playbackState; -} - -void MediaPlaybackManager::storeNewPlaybackState(chip::EndpointId endpoint, uint8_t newPlaybackState) -{ - oldPlaybackState = readPlaybackStatus(endpoint); - - if (oldPlaybackState == newPlaybackState) - { - return; - } - else - { - writePlaybackState(endpoint, newPlaybackState); - } -} - -static void sendResponse(const char * responseName, chip::CommandId commandId, EmberAfMediaPlaybackStatus mediaPlaybackStatus) -{ - static_assert(std::is_same, uint8_t>::value, "Wrong enum size"); - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_MEDIA_PLAYBACK_CLUSTER_ID, - commandId, "u", mediaPlaybackStatus); - - EmberStatus status = emberAfSendResponse(); - if (status != EMBER_SUCCESS) - { - ChipLogError(Zcl, "Failed to send %s. Error:%s", responseName, chip::ErrorStr(status)); - } -} - -EmberAfMediaPlaybackStatus MediaPlaybackManager::proxyMediaPlaybackRequest(MediaPlaybackRequest mediaPlaybackRequest) +EmberAfMediaPlaybackStatus MediaPlaybackManager::proxyMediaPlaybackRequest(MediaPlaybackRequest mediaPlaybackRequest, + uint64_t deltaPositionMilliseconds) { switch (mediaPlaybackRequest) { - case Play: + case MEDIA_PLAYBACK_REQUEST_PLAY: // TODO: Insert code here - case Pause: + case MEDIA_PLAYBACK_REQUEST_PAUSE: // TODO: Insert code here - case Stop: + case MEDIA_PLAYBACK_REQUEST_STOP: // TODO: Insert code here - case StartOver: + case MEDIA_PLAYBACK_REQUEST_START_OVER: // TODO: Insert code here - case Previous: + case MEDIA_PLAYBACK_REQUEST_PREVIOUS: // TODO: Insert code here - case Next: + case MEDIA_PLAYBACK_REQUEST_NEXT: // TODO: Insert code here - case Rewind: + case MEDIA_PLAYBACK_REQUEST_REWIND: // TODO: Insert code here - case FastForward: + case MEDIA_PLAYBACK_REQUEST_FAST_FORWARD: // TODO: Insert code here - case SkipForward: + case MEDIA_PLAYBACK_REQUEST_SKIP_FORWARD: // TODO: Insert code here - case Seek: + case MEDIA_PLAYBACK_REQUEST_SKIP_BACKWARD: + // TODO: Insert code here + case MEDIA_PLAYBACK_REQUEST_SEEK: return EMBER_ZCL_MEDIA_PLAYBACK_STATUS_SUCCESS; break; default: { @@ -125,81 +72,8 @@ EmberAfMediaPlaybackStatus MediaPlaybackManager::proxyMediaPlaybackRequest(Media } } -bool emberAfMediaPlaybackClusterMediaPlayCallback(chip::app::Command *) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::Play); - MediaPlaybackManager().storeNewPlaybackState(emberAfCurrentEndpoint(), EMBER_ZCL_MEDIA_PLAYBACK_STATE_PLAYING); - sendResponse("MediaPlayResponse", ZCL_MEDIA_PLAY_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaPauseCallback(chip::app::Command *) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::Pause); - MediaPlaybackManager().storeNewPlaybackState(emberAfCurrentEndpoint(), EMBER_ZCL_MEDIA_PLAYBACK_STATE_PAUSED); - sendResponse("MediaPauseResponse", ZCL_MEDIA_PAUSE_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaStopCallback(chip::app::Command *) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::Stop); - MediaPlaybackManager().storeNewPlaybackState(emberAfCurrentEndpoint(), EMBER_ZCL_MEDIA_PLAYBACK_STATE_NOT_PLAYING); - sendResponse("MediaStopResponse", ZCL_MEDIA_STOP_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaFastForwardCallback(chip::app::Command *) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::FastForward); - sendResponse("MediaFastForward", ZCL_MEDIA_FAST_FORWARD_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaPreviousCallback(chip::app::Command *) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::Previous); - sendResponse("MediaPrevious", ZCL_MEDIA_PREVIOUS_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaRewindCallback(chip::app::Command *) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::Rewind); - sendResponse("MediaRewind", ZCL_MEDIA_REWIND_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaSkipBackwardCallback(chip::app::Command *, uint64_t deltaPositionMilliseconds) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::SkipBackward); - sendResponse("MediaSkipBackward", ZCL_MEDIA_SKIP_BACKWARD_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaSkipForwardCallback(chip::app::Command *, uint64_t deltaPositionMilliseconds) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::SkipForward); - sendResponse("MediaSkipForward", ZCL_MEDIA_SKIP_FORWARD_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaSkipSeekCallback(chip::app::Command *, uint64_t positionMilliseconds) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::Seek); - sendResponse("MediaSeek", ZCL_MEDIA_SKIP_FORWARD_RESPONSE_COMMAND_ID, status); - return true; -} - -bool emberAfMediaPlaybackClusterMediaNextCallback(chip::app::Command *) -{ - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::Next); - sendResponse("MediaNext", ZCL_MEDIA_NEXT_RESPONSE_COMMAND_ID, status); - return true; -} -bool emberAfMediaPlaybackClusterMediaStartOverCallback(chip::app::Command *) +EmberAfMediaPlaybackStatus mediaPlaybackClusterSendMediaPlaybackRequest(MediaPlaybackRequest mediaPlaybackRequest, + uint64_t deltaPositionMilliseconds) { - EmberAfMediaPlaybackStatus status = MediaPlaybackManager().proxyMediaPlaybackRequest(MediaPlaybackRequest::StartOver); - sendResponse("MediaStartOver", ZCL_MEDIA_START_OVER_RESPONSE_COMMAND_ID, status); - return true; + return MediaPlaybackManager().proxyMediaPlaybackRequest(mediaPlaybackRequest, deltaPositionMilliseconds); } diff --git a/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.h b/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.h index 5d9d4b3209472d..75b1ae1a177685 100644 --- a/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.h +++ b/examples/tv-app/linux/include/media-playback/MediaPlaybackManager.h @@ -18,32 +18,19 @@ #pragma once +#include #include #include #include -enum MediaPlaybackRequest -{ - Play, - Pause, - Stop, - StartOver, - Previous, - Next, - Rewind, - FastForward, - SkipForward, - SkipBackward, - Seek -}; - class MediaPlaybackManager { public: CHIP_ERROR Init(); void storeNewPlaybackState(chip::EndpointId endpoint, uint8_t newPlaybackState); - EmberAfMediaPlaybackStatus proxyMediaPlaybackRequest(MediaPlaybackRequest mediaPlaybackRequest); + EmberAfMediaPlaybackStatus proxyMediaPlaybackRequest(MediaPlaybackRequest mediaPlaybackRequest, + uint64_t deltaPositionMilliseconds); private: uint8_t oldPlaybackState; diff --git a/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp b/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp index 616da6a67d95d7..2e69bbcbb9efdc 100644 --- a/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp +++ b/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.cpp @@ -16,11 +16,7 @@ */ #include "TargetNavigatorManager.h" - -#include -#include -#include -#include +#include #include #include #include @@ -58,31 +54,12 @@ std::vector TargetNavigatorManager::proxyGetTar return targets; } -TargetNavigatorLaunchResponse TargetNavigatorManager::proxyNavigateTargetRequest(uint8_t target, std::string data) +TargetNavigatorResponse targetNavigatorClusterNavigateTarget(uint8_t target, std::string data) { // TODO: Insert code here - TargetNavigatorLaunchResponse response; - response.data = "data response"; - response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS; + TargetNavigatorResponse response; + const char * testData = "data response"; + response.data = (uint8_t *) testData; + response.status = EMBER_ZCL_APPLICATION_LAUNCHER_STATUS_SUCCESS; return response; } - -static void sendResponse(const char * responseName, TargetNavigatorLaunchResponse response) -{ - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_TARGET_NAVIGATOR_CLUSTER_ID, - ZCL_NAVIGATE_TARGET_RESPONSE_COMMAND_ID, "us", response.status, &response.data); - - EmberStatus status = emberAfSendResponse(); - if (status != EMBER_SUCCESS) - { - ChipLogError(Zcl, "Failed to send %s. Error:%s", responseName, chip::ErrorStr(status)); - } -} - -bool emberAfTargetNavigatorClusterNavigateTargetCallback(unsigned char target, unsigned char * data) -{ - std::string dataString(reinterpret_cast(data)); - TargetNavigatorLaunchResponse response = TargetNavigatorManager().proxyNavigateTargetRequest(target, dataString); - sendResponse("NavigateTargetResponse", response); - return true; -} diff --git a/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.h b/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.h index 9cac6cdde5fb29..575f1ca7ffadef 100644 --- a/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.h +++ b/examples/tv-app/linux/include/target-navigator/TargetNavigatorManager.h @@ -23,16 +23,9 @@ #include #include -struct TargetNavigatorLaunchResponse -{ - EmberAfApplicationLauncherStatus status; - std::string data; -}; - class TargetNavigatorManager { public: CHIP_ERROR Init(); - TargetNavigatorLaunchResponse proxyNavigateTargetRequest(uint8_t target, std::string data); std::vector proxyGetTargetInfoList(); }; diff --git a/examples/tv-app/linux/include/tv-channel/TvChannelManager.cpp b/examples/tv-app/linux/include/tv-channel/TvChannelManager.cpp index 2fbbebd2b8e2fa..a9012e7fd58e47 100644 --- a/examples/tv-app/linux/include/tv-channel/TvChannelManager.cpp +++ b/examples/tv-app/linux/include/tv-channel/TvChannelManager.cpp @@ -16,12 +16,6 @@ */ #include "TvChannelManager.h" - -#include -#include -#include -#include -#include #include #include #include @@ -47,24 +41,6 @@ CHIP_ERROR TvChannelManager::Init() return err; } -EmberAfTvChannelInfo TvChannelManager::proxyChangeChannelRequest(std::string match) -{ - // TODO: Insert code here - EmberAfTvChannelInfo channel = {}; - return channel; -} - -bool TvChannelManager::proxyChangeChannelByNumberRequest(uint16_t majorNumer, uint16_t minorNumber) -{ - // TODO: Insert code here - return true; -} -bool TvChannelManager::proxySkipChannelRequest(uint16_t count) -{ - // TODO: Insert code here - return true; -} - std::vector TvChannelManager::proxyGetTvChannelList() { // TODO: Insert code here @@ -88,38 +64,19 @@ std::vector TvChannelManager::proxyGetTvChannelList() return tvChannels; } -static void sendResponse(const char * responseName, EmberAfTvChannelInfo channelInfo) -{ - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_TV_CHANNEL_CLUSTER_ID, - ZCL_CHANGE_CHANNEL_RESPONSE_COMMAND_ID, "uusss", channelInfo.majorNumber, channelInfo.minorNumber, - channelInfo.affiliateCallSign, channelInfo.callSign, channelInfo.name); - - EmberStatus status = emberAfSendResponse(); - if (status != EMBER_SUCCESS) - { - emberAfMediaPlaybackClusterPrintln("Failed to send %s: 0x%X", responseName, status); - } -} - -bool emberAfTvChannelClusterChangeChannelCallback(char * match) +EmberAfTvChannelInfo tvChannelClusterChangeChannel(std::string match) { - EmberAfTvChannelInfo channelInfo = TvChannelManager().proxyChangeChannelRequest(match); - sendResponse("ChangeChannel", channelInfo); - return true; + // TODO: Insert code here + EmberAfTvChannelInfo channel = {}; + return channel; } - -bool emberAfTvChannelClusterChangeChannelByNumberCallback(unsigned short majorNumber, unsigned short minorNumber) +bool tvChannelClusterChangeChannelByNumber(uint16_t majorNumber, uint16_t minorNumber) { - bool success = TvChannelManager().proxyChangeChannelByNumberRequest(majorNumber, minorNumber); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); + // TODO: Insert code here return true; } - -bool emberAfTvChannelClusterSkipChannelCallback(unsigned short count) +bool tvChannelClusterSkipChannel(uint16_t count) { - bool success = TvChannelManager().proxySkipChannelRequest(count); - EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; - emberAfSendImmediateDefaultResponse(status); + // TODO: Insert code here return true; } diff --git a/examples/tv-app/linux/include/tv-channel/TvChannelManager.h b/examples/tv-app/linux/include/tv-channel/TvChannelManager.h index a2d0c6674f0340..5f4a8abe262c22 100644 --- a/examples/tv-app/linux/include/tv-channel/TvChannelManager.h +++ b/examples/tv-app/linux/include/tv-channel/TvChannelManager.h @@ -27,8 +27,5 @@ class TvChannelManager { public: CHIP_ERROR Init(); - EmberAfTvChannelInfo proxyChangeChannelRequest(std::string match); - bool proxyChangeChannelByNumberRequest(uint16_t majorNumer, uint16_t minorNumber); - bool proxySkipChannelRequest(uint16_t count); std::vector proxyGetTvChannelList(); }; diff --git a/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp b/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp index 9a7677f0c79fc2..30634007af3a40 100644 --- a/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp +++ b/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp @@ -38,6 +38,182 @@ namespace app { namespace clusters { +namespace AccountLogin { + +void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::AccountLogin::Commands::Ids::GetSetupPIN: { + expectArgumentCount = 1; + const uint8_t * tempAccountIdentifier; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(tempAccountIdentifier); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = + emberAfAccountLoginClusterGetSetupPINCallback(apCommandObj, const_cast(tempAccountIdentifier)); + } + break; + } + case Clusters::AccountLogin::Commands::Ids::Login: { + expectArgumentCount = 2; + const uint8_t * tempAccountIdentifier; + const uint8_t * setupPIN; + bool argExists[2]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 2) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(tempAccountIdentifier); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(setupPIN); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfAccountLoginClusterLoginCallback(apCommandObj, const_cast(tempAccountIdentifier), + const_cast(setupPIN)); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::AccountLogin::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::AccountLogin::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::AccountLogin::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + } +} + +} // namespace AccountLogin + namespace ApplicationBasic { void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) @@ -146,6 +322,125 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } // namespace ApplicationBasic +namespace ApplicationLauncher { + +void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::ApplicationLauncher::Commands::Ids::LaunchApp: { + expectArgumentCount = 3; + const uint8_t * data; + uint16_t catalogVendorId; + const uint8_t * applicationId; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(data); + break; + case 1: + TLVUnpackError = aDataTlv.Get(catalogVendorId); + break; + case 2: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(applicationId); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfApplicationLauncherClusterLaunchAppCallback( + apCommandObj, const_cast(data), catalogVendorId, const_cast(applicationId)); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::ApplicationLauncher::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::ApplicationLauncher::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::ApplicationLauncher::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + } +} + +} // namespace ApplicationLauncher + namespace AudioOutput { void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) @@ -968,7 +1263,126 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 4) + if (currentDecodeTagId < 4) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(location); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(countryCode); + break; + case 2: + TLVUnpackError = aDataTlv.Get(breadcrumb); + break; + case 3: + TLVUnpackError = aDataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback( + apCommandObj, location, const_cast(countryCode), breadcrumb, timeoutMs); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::GeneralCommissioning::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::GeneralCommissioning::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::GeneralCommissioning::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + } +} + +} // namespace GeneralCommissioning + +namespace KeypadInput { + +void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::KeypadInput::Commands::Ids::SendKey: { + expectArgumentCount = 1; + uint8_t keyCode; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -985,17 +1399,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(location); - break; - case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(countryCode); - break; - case 2: - TLVUnpackError = aDataTlv.Get(breadcrumb); - break; - case 3: - TLVUnpackError = aDataTlv.Get(timeoutMs); + TLVUnpackError = aDataTlv.Get(keyCode); break; default: // Unsupported tag, ignore it. @@ -1014,11 +1418,10 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback( - apCommandObj, location, const_cast(countryCode), breadcrumb, timeoutMs); + wasHandled = emberAfKeypadInputClusterSendKeyCallback(apCommandObj, keyCode); } break; } @@ -1026,12 +1429,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En // Unrecognized command ID, error status will apply. chip::app::CommandPathParams returnStatusParam = { aEndpointId, 0, // GroupId - Clusters::GeneralCommissioning::Id, aCommandId, + Clusters::KeypadInput::Id, aCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::GeneralCommissioning::Id); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::KeypadInput::Id); return; } } @@ -1041,7 +1444,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En { chip::app::CommandPathParams returnStatusParam = { aEndpointId, 0, // GroupId - Clusters::GeneralCommissioning::Id, aCommandId, + Clusters::KeypadInput::Id, aCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); @@ -1052,7 +1455,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } } -} // namespace GeneralCommissioning +} // namespace KeypadInput namespace LevelControl { @@ -1584,6 +1987,245 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } // namespace LevelControl +namespace LowPower { + +void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::LowPower::Commands::Ids::Sleep: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfLowPowerClusterSleepCallback(apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::LowPower::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::LowPower::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::LowPower::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + } +} + +} // namespace LowPower + +namespace MediaInput { + +void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::MediaInput::Commands::Ids::HideInputStatus: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfMediaInputClusterHideInputStatusCallback(apCommandObj); + break; + } + case Clusters::MediaInput::Commands::Ids::RenameInput: { + expectArgumentCount = 2; + uint8_t index; + const uint8_t * name; + bool argExists[2]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 2) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(index); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(name); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfMediaInputClusterRenameInputCallback(apCommandObj, index, const_cast(name)); + } + break; + } + case Clusters::MediaInput::Commands::Ids::SelectInput: { + expectArgumentCount = 1; + uint8_t index; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(index); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfMediaInputClusterSelectInputCallback(apCommandObj, index); + } + break; + } + case Clusters::MediaInput::Commands::Ids::ShowInputStatus: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfMediaInputClusterShowInputStatusCallback(apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::MediaInput::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::MediaInput::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::MediaInput::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + } +} + +} // namespace MediaInput + namespace MediaPlayback { void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) @@ -1637,9 +2279,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En wasHandled = emberAfMediaPlaybackClusterMediaRewindCallback(apCommandObj); break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSkipBackward: { + case Clusters::MediaPlayback::Commands::Ids::MediaSeek: { expectArgumentCount = 1; - uint64_t deltaPositionMilliseconds; + uint64_t position; bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -1670,7 +2312,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(deltaPositionMilliseconds); + TLVUnpackError = aDataTlv.Get(position); break; default: // Unsupported tag, ignore it. @@ -1692,11 +2334,11 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSkipBackwardCallback(apCommandObj, deltaPositionMilliseconds); + wasHandled = emberAfMediaPlaybackClusterMediaSeekCallback(apCommandObj, position); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSkipForward: { + case Clusters::MediaPlayback::Commands::Ids::MediaSkipBackward: { expectArgumentCount = 1; uint64_t deltaPositionMilliseconds; bool argExists[1]; @@ -1751,13 +2393,13 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSkipForwardCallback(apCommandObj, deltaPositionMilliseconds); + wasHandled = emberAfMediaPlaybackClusterMediaSkipBackwardCallback(apCommandObj, deltaPositionMilliseconds); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSkipSeek: { + case Clusters::MediaPlayback::Commands::Ids::MediaSkipForward: { expectArgumentCount = 1; - uint64_t position; + uint64_t deltaPositionMilliseconds; bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -1788,7 +2430,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(position); + TLVUnpackError = aDataTlv.Get(deltaPositionMilliseconds); break; default: // Unsupported tag, ignore it. @@ -1810,7 +2452,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSkipSeekCallback(apCommandObj, position); + wasHandled = emberAfMediaPlaybackClusterMediaSkipForwardCallback(apCommandObj, deltaPositionMilliseconds); } break; } @@ -2932,7 +3574,279 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 4) + if (currentDecodeTagId < 4) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + NOCArray = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + IPKValue = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 2: + TLVUnpackError = aDataTlv.Get(CaseAdminNode); + break; + case 3: + TLVUnpackError = aDataTlv.Get(AdminVendorId); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterAddOpCertCallback(apCommandObj, NOCArray, IPKValue, CaseAdminNode, + AdminVendorId); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::AddTrustedRootCertificate: { + expectArgumentCount = 1; + chip::ByteSpan RootCertificate; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + RootCertificate = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(apCommandObj, RootCertificate); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::OpCSRRequest: { + expectArgumentCount = 1; + chip::ByteSpan CSRNonce; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + CSRNonce = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterOpCSRRequestCallback(apCommandObj, CSRNonce); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::RemoveAllFabrics: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(apCommandObj); + break; + } + case Clusters::OperationalCredentials::Commands::Ids::RemoveFabric: { + expectArgumentCount = 3; + chip::FabricId FabricId; + chip::NodeId NodeId; + uint16_t VendorId; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(FabricId); + break; + case 1: + TLVUnpackError = aDataTlv.Get(NodeId); + break; + case 2: + TLVUnpackError = aDataTlv.Get(VendorId); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(apCommandObj, FabricId, NodeId, VendorId); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::RemoveTrustedRootCertificate: { + expectArgumentCount = 1; + chip::ByteSpan TrustedRootIdentifier; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -2949,23 +3863,11 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - NOCArray = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 1: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - IPKValue = chip::ByteSpan(data, aDataTlv.GetLength()); + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + TrustedRootIdentifier = chip::ByteSpan(data, aDataTlv.GetLength()); } break; - case 2: - TLVUnpackError = aDataTlv.Get(CaseAdminNode); - break; - case 3: - TLVUnpackError = aDataTlv.Get(AdminVendorId); - break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -2983,17 +3885,17 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterAddOpCertCallback(apCommandObj, NOCArray, IPKValue, CaseAdminNode, - AdminVendorId); + wasHandled = + emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(apCommandObj, TrustedRootIdentifier); } break; } - case Clusters::OperationalCredentials::Commands::Ids::AddTrustedRootCertificate: { + case Clusters::OperationalCredentials::Commands::Ids::SetFabric: { expectArgumentCount = 1; - chip::ByteSpan RootCertificate; + uint16_t VendorId; bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3023,12 +3925,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - RootCertificate = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(VendorId); + break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -3049,13 +3948,13 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(apCommandObj, RootCertificate); + wasHandled = emberAfOperationalCredentialsClusterSetFabricCallback(apCommandObj, VendorId); } break; } - case Clusters::OperationalCredentials::Commands::Ids::OpCSRRequest: { + case Clusters::OperationalCredentials::Commands::Ids::UpdateFabricLabel: { expectArgumentCount = 1; - chip::ByteSpan CSRNonce; + const uint8_t * Label; bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3085,12 +3984,10 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - CSRNonce = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(Label); + break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -3111,22 +4008,64 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterOpCSRRequestCallback(apCommandObj, CSRNonce); + wasHandled = + emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(apCommandObj, const_cast(Label)); } break; } - case Clusters::OperationalCredentials::Commands::Ids::RemoveAllFabrics: { - - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(apCommandObj); - break; + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OperationalCredentials::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OperationalCredentials::Id); + return; } - case Clusters::OperationalCredentials::Commands::Ids::RemoveFabric: { - expectArgumentCount = 3; - chip::FabricId FabricId; - chip::NodeId NodeId; - uint16_t VendorId; - bool argExists[3]; + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OperationalCredentials::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + } +} + +} // namespace OperationalCredentials + +namespace TvChannel { + +void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::TvChannel::Commands::Ids::ChangeChannel: { + expectArgumentCount = 1; + const uint8_t * match; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3139,7 +4078,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3156,13 +4095,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(FabricId); - break; - case 1: - TLVUnpackError = aDataTlv.Get(NodeId); - break; - case 2: - TLVUnpackError = aDataTlv.Get(VendorId); + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(match); break; default: // Unsupported tag, ignore it. @@ -3181,17 +4115,18 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(apCommandObj, FabricId, NodeId, VendorId); + wasHandled = emberAfTvChannelClusterChangeChannelCallback(apCommandObj, const_cast(match)); } break; } - case Clusters::OperationalCredentials::Commands::Ids::RemoveTrustedRootCertificate: { - expectArgumentCount = 1; - chip::ByteSpan TrustedRootIdentifier; - bool argExists[1]; + case Clusters::TvChannel::Commands::Ids::ChangeChannelByNumber: { + expectArgumentCount = 2; + uint16_t majorNumber; + uint16_t minorNumber; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -3204,7 +4139,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -3220,12 +4155,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - TrustedRootIdentifier = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(majorNumber); + break; + case 1: + TLVUnpackError = aDataTlv.Get(minorNumber); + break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -3243,17 +4178,16 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(apCommandObj, TrustedRootIdentifier); + wasHandled = emberAfTvChannelClusterChangeChannelByNumberCallback(apCommandObj, majorNumber, minorNumber); } break; } - case Clusters::OperationalCredentials::Commands::Ids::SetFabric: { + case Clusters::TvChannel::Commands::Ids::SkipChannel: { expectArgumentCount = 1; - uint16_t VendorId; + uint16_t Count; bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3284,7 +4218,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(VendorId); + TLVUnpackError = aDataTlv.Get(Count); break; default: // Unsupported tag, ignore it. @@ -3306,14 +4240,64 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterSetFabricCallback(apCommandObj, VendorId); + wasHandled = emberAfTvChannelClusterSkipChannelCallback(apCommandObj, Count); } break; } - case Clusters::OperationalCredentials::Commands::Ids::UpdateFabricLabel: { - expectArgumentCount = 1; - const uint8_t * Label; - bool argExists[1]; + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::TvChannel::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::TvChannel::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::TvChannel::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + } +} + +} // namespace TvChannel + +namespace TargetNavigator { + +void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::TargetNavigator::Commands::Ids::NavigateTarget: { + expectArgumentCount = 2; + uint8_t target; + const uint8_t * data; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -3326,7 +4310,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -3343,8 +4327,11 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: + TLVUnpackError = aDataTlv.Get(target); + break; + case 1: // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(Label); + TLVUnpackError = aDataTlv.GetDataPtr(data); break; default: // Unsupported tag, ignore it. @@ -3363,11 +4350,10 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(apCommandObj, const_cast(Label)); + wasHandled = emberAfTargetNavigatorClusterNavigateTargetCallback(apCommandObj, target, const_cast(data)); } break; } @@ -3375,12 +4361,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En // Unrecognized command ID, error status will apply. chip::app::CommandPathParams returnStatusParam = { aEndpointId, 0, // GroupId - Clusters::OperationalCredentials::Id, aCommandId, + Clusters::TargetNavigator::Id, aCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OperationalCredentials::Id); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::TargetNavigator::Id); return; } } @@ -3390,7 +4376,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En { chip::app::CommandPathParams returnStatusParam = { aEndpointId, 0, // GroupId - Clusters::OperationalCredentials::Id, aCommandId, + Clusters::TargetNavigator::Id, aCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); @@ -3401,7 +4387,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } } -} // namespace OperationalCredentials +} // namespace TargetNavigator } // namespace clusters @@ -3415,9 +4401,15 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { + case Clusters::AccountLogin::Id: + clusters::AccountLogin::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case Clusters::ApplicationBasic::Id: clusters::ApplicationBasic::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case Clusters::ApplicationLauncher::Id: + clusters::ApplicationLauncher::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case Clusters::AudioOutput::Id: clusters::AudioOutput::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; @@ -3436,9 +4428,18 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC case Clusters::GeneralCommissioning::Id: clusters::GeneralCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case Clusters::KeypadInput::Id: + clusters::KeypadInput::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case Clusters::LevelControl::Id: clusters::LevelControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case Clusters::LowPower::Id: + clusters::LowPower::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::MediaInput::Id: + clusters::MediaInput::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case Clusters::MediaPlayback::Id: clusters::MediaPlayback::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; @@ -3454,6 +4455,12 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC case Clusters::OperationalCredentials::Id: clusters::OperationalCredentials::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case Clusters::TvChannel::Id: + clusters::TvChannel::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::TargetNavigator::Id: + clusters::TargetNavigator::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; default: // Unrecognized cluster ID, error status will apply. chip::app::CommandPathParams returnStatusParam = { aEndPointId, diff --git a/examples/tv-app/tv-common/gen/callback.h b/examples/tv-app/tv-common/gen/callback.h index 782de2beb4b590..092843d68b81eb 100644 --- a/examples/tv-app/tv-common/gen/callback.h +++ b/examples/tv-app/tv-common/gen/callback.h @@ -2311,12 +2311,31 @@ void emberAfWiFiNetworkDiagnosticsClusterServerTickCallback(chip::EndpointId end // Cluster Commands Callback +/** + * @brief Account Login Cluster GetSetupPIN Command callback + */ + +bool emberAfAccountLoginClusterGetSetupPINCallback(chip::app::Command * commandObj, uint8_t * tempAccountIdentifier); + +/** + * @brief Account Login Cluster Login Command callback + */ + +bool emberAfAccountLoginClusterLoginCallback(chip::app::Command * commandObj, uint8_t * tempAccountIdentifier, uint8_t * setupPIN); + /** * @brief Application Basic Cluster ChangeStatus Command callback */ bool emberAfApplicationBasicClusterChangeStatusCallback(chip::app::Command * commandObj, uint8_t status); +/** + * @brief Application Launcher Cluster LaunchApp Command callback + */ + +bool emberAfApplicationLauncherClusterLaunchAppCallback(chip::app::Command * commandObj, uint8_t * data, uint16_t catalogVendorId, + uint8_t * applicationId); + /** * @brief Audio Output Cluster RenameOutput Command callback */ @@ -2388,6 +2407,12 @@ bool emberAfGeneralCommissioningClusterCommissioningCompleteCallback(chip::app:: bool emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(chip::app::Command * commandObj, uint8_t location, uint8_t * countryCode, uint64_t breadcrumb, uint32_t timeoutMs); +/** + * @brief Keypad Input Cluster SendKey Command callback + */ + +bool emberAfKeypadInputClusterSendKeyCallback(chip::app::Command * commandObj, uint8_t keyCode); + /** * @brief Level Control Cluster Move Command callback */ @@ -2441,6 +2466,36 @@ bool emberAfLevelControlClusterStopCallback(chip::app::Command * commandObj, uin bool emberAfLevelControlClusterStopWithOnOffCallback(chip::app::Command * commandObj); +/** + * @brief Low Power Cluster Sleep Command callback + */ + +bool emberAfLowPowerClusterSleepCallback(chip::app::Command * commandObj); + +/** + * @brief Media Input Cluster HideInputStatus Command callback + */ + +bool emberAfMediaInputClusterHideInputStatusCallback(chip::app::Command * commandObj); + +/** + * @brief Media Input Cluster RenameInput Command callback + */ + +bool emberAfMediaInputClusterRenameInputCallback(chip::app::Command * commandObj, uint8_t index, uint8_t * name); + +/** + * @brief Media Input Cluster SelectInput Command callback + */ + +bool emberAfMediaInputClusterSelectInputCallback(chip::app::Command * commandObj, uint8_t index); + +/** + * @brief Media Input Cluster ShowInputStatus Command callback + */ + +bool emberAfMediaInputClusterShowInputStatusCallback(chip::app::Command * commandObj); + /** * @brief Media Playback Cluster MediaFastForward Command callback */ @@ -2478,22 +2533,22 @@ bool emberAfMediaPlaybackClusterMediaPreviousCallback(chip::app::Command * comma bool emberAfMediaPlaybackClusterMediaRewindCallback(chip::app::Command * commandObj); /** - * @brief Media Playback Cluster MediaSkipBackward Command callback + * @brief Media Playback Cluster MediaSeek Command callback */ -bool emberAfMediaPlaybackClusterMediaSkipBackwardCallback(chip::app::Command * commandObj, uint64_t deltaPositionMilliseconds); +bool emberAfMediaPlaybackClusterMediaSeekCallback(chip::app::Command * commandObj, uint64_t position); /** - * @brief Media Playback Cluster MediaSkipForward Command callback + * @brief Media Playback Cluster MediaSkipBackward Command callback */ -bool emberAfMediaPlaybackClusterMediaSkipForwardCallback(chip::app::Command * commandObj, uint64_t deltaPositionMilliseconds); +bool emberAfMediaPlaybackClusterMediaSkipBackwardCallback(chip::app::Command * commandObj, uint64_t deltaPositionMilliseconds); /** - * @brief Media Playback Cluster MediaSkipSeek Command callback + * @brief Media Playback Cluster MediaSkipForward Command callback */ -bool emberAfMediaPlaybackClusterMediaSkipSeekCallback(chip::app::Command * commandObj, uint64_t position); +bool emberAfMediaPlaybackClusterMediaSkipForwardCallback(chip::app::Command * commandObj, uint64_t deltaPositionMilliseconds); /** * @brief Media Playback Cluster MediaStartOver Command callback @@ -2666,6 +2721,31 @@ bool emberAfOperationalCredentialsClusterSetFabricCallback(chip::app::Command * bool emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(chip::app::Command * commandObj, uint8_t * Label); +/** + * @brief TV Channel Cluster ChangeChannel Command callback + */ + +bool emberAfTvChannelClusterChangeChannelCallback(chip::app::Command * commandObj, uint8_t * match); + +/** + * @brief TV Channel Cluster ChangeChannelByNumber Command callback + */ + +bool emberAfTvChannelClusterChangeChannelByNumberCallback(chip::app::Command * commandObj, uint16_t majorNumber, + uint16_t minorNumber); + +/** + * @brief TV Channel Cluster SkipChannel Command callback + */ + +bool emberAfTvChannelClusterSkipChannelCallback(chip::app::Command * commandObj, uint16_t Count); + +/** + * @brief Target Navigator Cluster NavigateTarget Command callback + */ + +bool emberAfTargetNavigatorClusterNavigateTargetCallback(chip::app::Command * commandObj, uint8_t target, uint8_t * data); + // // Non-Cluster Related Callbacks // diff --git a/examples/tv-app/tv-common/gen/endpoint_config.h b/examples/tv-app/tv-common/gen/endpoint_config.h index b485e3e990ce76..e12fcc97e816ee 100644 --- a/examples/tv-app/tv-common/gen/endpoint_config.h +++ b/examples/tv-app/tv-common/gen/endpoint_config.h @@ -1620,7 +1620,7 @@ { 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* product id */ \ { 0x0005, ZAP_TYPE(CHAR_STRING), 32, 0, ZAP_LONG_DEFAULTS_INDEX(5952) }, /* application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* catalog vendor id */ \ - { 0x0007, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* application satus */ \ + { 0x0007, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* application status */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ /* Endpoint: 3, Cluster: Account Login (server) */ \ @@ -1638,7 +1638,7 @@ { 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* product id */ \ { 0x0005, ZAP_TYPE(CHAR_STRING), 32, 0, ZAP_LONG_DEFAULTS_INDEX(6556) }, /* application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* catalog vendor id */ \ - { 0x0007, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* application satus */ \ + { 0x0007, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* application status */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ /* Endpoint: 5, Cluster: Application Basic (server) */ \ @@ -1648,7 +1648,7 @@ { 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* product id */ \ { 0x0005, ZAP_TYPE(CHAR_STRING), 32, 0, ZAP_LONG_DEFAULTS_INDEX(6652) }, /* application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* catalog vendor id */ \ - { 0x0007, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* application satus */ \ + { 0x0007, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* application status */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ } @@ -1847,7 +1847,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (117) +#define EMBER_AF_GENERATED_COMMAND_COUNT (116) #define GENERATED_COMMANDS \ { \ \ @@ -1996,8 +1996,7 @@ { 0x0506, 0x08, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipForwardResponse */ \ { 0x0506, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSkipBackward */ \ { 0x0506, 0x09, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipBackwardResponse */ \ - { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSkipSeek */ \ - { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipSeekResponse */ \ + { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSeek */ \ \ /* Endpoint: 3, Cluster: Content Launcher (server) */ \ { 0x050A, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* LaunchContent */ \ diff --git a/examples/tv-app/tv-common/tv-app.zap b/examples/tv-app/tv-common/tv-app.zap index e522289402a90c..01b30d6c9afbe7 100644 --- a/examples/tv-app/tv-common/tv-app.zap +++ b/examples/tv-app/tv-common/tv-app.zap @@ -1619,16 +1619,9 @@ "source": "client", "incoming": 1, "outgoing": 0 - }, - { - "name": "RetrieveLogsResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 } - ] + ], + "attributes": [] }, { "name": "General Diagnostics", @@ -6028,7 +6021,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -6036,7 +6029,7 @@ "code": 1, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -6044,7 +6037,7 @@ "code": 2, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], @@ -6159,7 +6152,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], @@ -6244,7 +6237,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -6252,7 +6245,7 @@ "code": 1, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -6260,7 +6253,7 @@ "code": 2, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -6268,7 +6261,7 @@ "code": 3, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], @@ -6344,7 +6337,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], @@ -6405,7 +6398,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], @@ -6591,7 +6584,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], @@ -7091,7 +7084,7 @@ "outgoing": 1 }, { - "name": "MediaSkipSeek", + "name": "MediaSeek", "code": 10, "mfgCode": null, "source": "client", @@ -7204,14 +7197,6 @@ "source": "server", "incoming": 1, "outgoing": 0 - }, - { - "name": "MediaSkipSeekResponse", - "code": 10, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 0 } ], "attributes": [ @@ -7603,7 +7588,7 @@ "reportableChange": 0 }, { - "name": "application satus", + "name": "application status", "code": 7, "mfgCode": null, "side": "server", @@ -7647,7 +7632,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -7655,7 +7640,7 @@ "code": 1, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], @@ -7962,7 +7947,7 @@ "reportableChange": 0 }, { - "name": "application satus", + "name": "application status", "code": 7, "mfgCode": null, "side": "server", @@ -8127,7 +8112,7 @@ "reportableChange": 0 }, { - "name": "application satus", + "name": "application status", "code": 7, "mfgCode": null, "side": "server", @@ -8218,4 +8203,4 @@ } ], "log": [] -} +} \ No newline at end of file diff --git a/scripts/tests/test_suites.sh b/scripts/tests/test_suites.sh index 0aa875e183dcee..bcf045b75dba90 100755 --- a/scripts/tests/test_suites.sh +++ b/scripts/tests/test_suites.sh @@ -18,10 +18,31 @@ set -e -declare -a test_array="($(find src/app/tests/suites -type f -name "*.yaml" -exec basename {} .yaml \;))" declare -i iterations=20 declare -i background_pid=0 +# read shell arguments +# - a for application +# - i for number of iterations you want to have +while getopts a:i: flag; do + case "$flag" in + a) application=$OPTARG ;; + i) iterations=$OPTARG ;; + esac +done + +echo "Running tests for application: $application, with iterations set to: $iterations" + +if [[ $application == "tv" ]]; then + declare -a test_array="($(find src/app/tests/suites -type f -name "TV_*.yaml" -exec basename {} .yaml \;))" + cp examples/tv-app/linux/include/endpoint-configuration/chip_tv_config.ini /tmp/chip_tv_config.ini +# in case there's no application argument +# always default to all-cluters app +else + application="all-clusters" + declare -a test_array="($(find src/app/tests/suites -type f -name "Test*.yaml" -exec basename {} .yaml \;))" +fi + cleanup() { if [[ $background_pid != 0 ]]; then # In case we died on a failure before we cleaned up our background task. @@ -30,12 +51,9 @@ cleanup() { } trap cleanup EXIT -if [[ -n $1 ]]; then - iterations=$1 - if [[ $iterations == 0 ]]; then - echo "Invalid iteration count: '$1'" - exit 1 - fi +if [[ $iterations == 0 ]]; then + echo "Invalid iteration count: '$1'" + exit 1 fi echo "Found tests:" @@ -55,7 +73,7 @@ for j in "${iter_array[@]}"; do echo " * Starting cluster server" rm -rf /tmp/chip_tool_config.ini # This part is a little complicated. We want to - # 1) Start chip-all-clusters-app in the background + # 1) Start chip-app in the background # 2) Pipe its output through tee so we can wait until it's ready for a # PASE handshake. # 3) Save its pid off so we can kill it. @@ -72,14 +90,14 @@ for j in "${iter_array[@]}"; do # Clear out our temp files so we don't accidentally do a stale # read from them before we write to them. - rm -rf /tmp/all-clusters-log - touch /tmp/all-clusters-log + rm -rf /tmp/"$application"-log + touch /tmp/"$application"-log rm -rf /tmp/pid ( - stdbuf -o0 out/debug/standalone/chip-all-clusters-app & + stdbuf -o0 out/debug/standalone/chip-"$application"-app & echo $! >&3 - ) 3>/tmp/pid | tee /tmp/all-clusters-log & - while ! grep -q "Server Listening" /tmp/all-clusters-log; do + ) 3>/tmp/pid | tee /tmp/"$application"-log & + while ! grep -q "Server Listening" /tmp/"$application"-log; do : done # Now read $background_pid from /tmp/pid; presumably it's diff --git a/src/app/clusters/account-login-server/account-login-server.cpp b/src/app/clusters/account-login-server/account-login-server.cpp index aec075453ea79b..4df1fbe994f2cc 100644 --- a/src/app/clusters/account-login-server/account-login-server.cpp +++ b/src/app/clusters/account-login-server/account-login-server.cpp @@ -14,23 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /**************************************************************************** * @file * @brief Routines for the Application Launcher plugin, the @@ -39,18 +22,52 @@ ******************************************************************************/ #include +#include +#include #include +#include -bool emberAfAccountLoginClusterGetSetupPINCallback(chip::app::Command * commandObj, unsigned char *) +bool accountLoginClusterIsUserLoggedIn(std::string requestTempAccountIdentifier, std::string requestSetupPin); +std::string accountLoginClusterGetSetupPin(std::string requestTempAccountIdentifier, chip::EndpointId endpoint); + +void sendResponse(chip::app::Command * command, const char * responseSetupPin) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + CHIP_ERROR err = CHIP_NO_ERROR; + chip::app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_ACCOUNT_LOGIN_CLUSTER_ID, + ZCL_GET_SETUP_PIN_RESPONSE_COMMAND_ID, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + chip::TLV::TLVWriter * writer = nullptr; + SuccessOrExit(err = command->PrepareCommand(cmdParams)); + VerifyOrExit((writer = command->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + SuccessOrExit(err = writer->PutString(chip::TLV::ContextTag(0), responseSetupPin)); + SuccessOrExit(err = command->FinishCommand()); +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Failed to encode GetSetupPIN command. Error:%s", chip::ErrorStr(err)); + } +} + +bool emberAfAccountLoginClusterGetSetupPINCallback(chip::app::Command * command, uint8_t * tempAccountIdentifier) +{ + // TODO: char is not null terminated, verify this code once #7963 gets merged. + std::string tempAccountIdentifierString(reinterpret_cast(tempAccountIdentifier)); + std::string responseSetupPin = accountLoginClusterGetSetupPin(tempAccountIdentifierString, emberAfCurrentEndpoint()); + sendResponse(command, responseSetupPin.c_str()); return true; } -bool emberAfAccountLoginClusterLoginCallback(chip::app::Command * commandObj, unsigned char *, unsigned char *) +bool emberAfAccountLoginClusterLoginCallback(chip::app::Command * command, uint8_t * tempAccountIdentifier, uint8_t * tempSetupPin) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + // TODO: char is not null terminated, verify this code once #7963 gets merged. + std::string tempAccountIdentifierString(reinterpret_cast(tempAccountIdentifier)); + std::string tempSetupPinString(reinterpret_cast(tempSetupPin)); + bool isLoggedIn = accountLoginClusterIsUserLoggedIn(tempAccountIdentifierString, tempSetupPinString); + EmberAfStatus status = isLoggedIn ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_NOT_AUTHORIZED; + if (!isLoggedIn) + { + ChipLogError(Zcl, "User is not authorized."); + } emberAfSendImmediateDefaultResponse(status); return true; } diff --git a/src/app/clusters/application-basic-server/application-basic-server.cpp b/src/app/clusters/application-basic-server/application-basic-server.cpp new file mode 100644 index 00000000000000..069f839bcf98f8 --- /dev/null +++ b/src/app/clusters/application-basic-server/application-basic-server.cpp @@ -0,0 +1,39 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/**************************************************************************** + * @file + * @brief Routines for the Application Launcher plugin, the + *server implementation of the Application Launcher cluster. + ******************************************************************************* + ******************************************************************************/ + +#include +#include +#include +#include + +bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, chip::EndpointId endpoint); + +bool emberAfApplicationBasicClusterChangeStatusCallback(chip::app::Command * commandObj, uint8_t newApplicationStatus) +{ + bool success = applicationBasicClusterChangeApplicationStatus(static_cast(newApplicationStatus), + emberAfCurrentEndpoint()); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; + emberAfSendImmediateDefaultResponse(status); + return true; +} diff --git a/src/app/clusters/application-launcher-server/application-launcher-server.cpp b/src/app/clusters/application-launcher-server/application-launcher-server.cpp index e5a1d804f7009a..a21f1bcb8aa873 100644 --- a/src/app/clusters/application-launcher-server/application-launcher-server.cpp +++ b/src/app/clusters/application-launcher-server/application-launcher-server.cpp @@ -15,22 +15,6 @@ * limitations under the License. */ -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /**************************************************************************** * @file * @brief Routines for the Application Launcher plugin, the @@ -39,11 +23,56 @@ ******************************************************************************/ #include +#include +#include +#include +#include +#include #include -bool emberAfApplicationLauncherClusterLaunchAppCallback(chip::app::Command * commandObj, unsigned char *, unsigned char *) +ApplicationLauncherResponse applicationLauncherClusterLaunchApp(EmberAfApplicationLauncherApp application, std::string data); + +bool emberAfApplicationLauncherClusterLaunchAppCallback(chip::app::Command * commandObj, uint8_t *, uint8_t *) { EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; emberAfSendImmediateDefaultResponse(status); return true; } + +void sendResponse(chip::app::Command * command, ApplicationLauncherResponse response) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + chip::app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_APPLICATION_LAUNCHER_CLUSTER_ID, + ZCL_LAUNCH_APP_RESPONSE_COMMAND_ID, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + chip::TLV::TLVWriter * writer = nullptr; + SuccessOrExit(err = command->PrepareCommand(cmdParams)); + VerifyOrExit((writer = command->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + SuccessOrExit(err = writer->Put(chip::TLV::ContextTag(0), response.status)); + SuccessOrExit(err = writer->PutString(chip::TLV::ContextTag(1), reinterpret_cast(response.data))); + SuccessOrExit(err = command->FinishCommand()); +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Failed to send LaunchAppResponse. Error:%s", chip::ErrorStr(err)); + } +} + +EmberAfApplicationLauncherApp getApplicationFromCommand(uint16_t catalogVendorId, uint8_t * applicationId) +{ + EmberAfApplicationLauncherApp application = {}; + application.applicationId = applicationId; + application.catalogVendorId = catalogVendorId; + return application; +} + +bool emberAfApplicationLauncherClusterLaunchAppCallback(chip::app::Command * command, uint8_t * requestData, + uint16_t requestApplicationCatalogVendorId, uint8_t * requestApplicationId) +{ + EmberAfApplicationLauncherApp application = getApplicationFromCommand(requestApplicationCatalogVendorId, requestApplicationId); + // TODO: Char is not null terminated, verify this code once #7963 gets merged. + std::string reqestDataString(reinterpret_cast(requestData)); + ApplicationLauncherResponse response = applicationLauncherClusterLaunchApp(application, reqestDataString); + sendResponse(command, response); + return true; +} diff --git a/src/app/clusters/application-launcher-server/application-launcher-server.h b/src/app/clusters/application-launcher-server/application-launcher-server.h new file mode 100644 index 00000000000000..5c71e3d93fc82a --- /dev/null +++ b/src/app/clusters/application-launcher-server/application-launcher-server.h @@ -0,0 +1,27 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**************************************************************************** + * @file + * @brief Routines for the Application Launcher plugin, the + *server implementation of the Application Launcher cluster. + ******************************************************************************* + ******************************************************************************/ +struct ApplicationLauncherResponse +{ + uint8_t status; + uint8_t * data; +}; diff --git a/src/app/clusters/audio-output-server/audio-output-server.cpp b/src/app/clusters/audio-output-server/audio-output-server.cpp index f402937d001662..969b41fffed6a0 100644 --- a/src/app/clusters/audio-output-server/audio-output-server.cpp +++ b/src/app/clusters/audio-output-server/audio-output-server.cpp @@ -15,22 +15,6 @@ * limitations under the License. */ -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /**************************************************************************** * @file * @brief Routines for the Audio Output plugin, the @@ -41,16 +25,21 @@ #include #include -bool emberAfAudioOutputClusterRenameOutputCallback(chip::app::Command * commandObj, unsigned char, unsigned char *) +bool audioOutputClusterSelectOutput(uint8_t index); +bool audioOutputClusterRenameOutput(uint8_t index, uint8_t * name); + +bool emberAfAudioOutputClusterRenameOutputCallback(chip::app::Command * command, uint8_t index, uint8_t * name) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + bool success = audioOutputClusterRenameOutput(index, name); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; } -bool emberAfAudioOutputClusterSelectOutputCallback(chip::app::Command * commandObj, unsigned char) +bool emberAfAudioOutputClusterSelectOutputCallback(chip::app::Command * command, uint8_t index) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + bool success = audioOutputClusterSelectOutput(index); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; } diff --git a/src/app/clusters/keypad-input-server/keypad-input-server.cpp b/src/app/clusters/keypad-input-server/keypad-input-server.cpp index 628ae1028d487a..1fca897e19851f 100644 --- a/src/app/clusters/keypad-input-server/keypad-input-server.cpp +++ b/src/app/clusters/keypad-input-server/keypad-input-server.cpp @@ -14,23 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /**************************************************************************** * @file * @brief Routines for the Keypad Input plugin, the @@ -39,11 +22,36 @@ ******************************************************************************/ #include +#include +#include +#include #include -bool emberAfKeypadInputClusterSendKeyCallback(chip::app::Command * commandObj, unsigned char) +EmberAfKeypadInputStatus keypadInputClusterSendKey(EmberAfKeypadInputCecKeyCode keyCode); + +static void sendResponse(chip::app::Command * command, EmberAfKeypadInputStatus keypadInputStatus) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + chip::app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_KEYPAD_INPUT_CLUSTER_ID, + ZCL_SEND_KEY_RESPONSE_COMMAND_ID, (chip::app::CommandPathFlags::kEndpointIdValid) }; + chip::TLV::TLVWriter * writer = nullptr; + + VerifyOrExit(command != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + SuccessOrExit(err = command->PrepareCommand(cmdParams)); + VerifyOrExit((writer = command->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + SuccessOrExit(err = writer->Put(chip::TLV::ContextTag(0), keypadInputStatus)); + SuccessOrExit(err = command->FinishCommand()); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Failed to encode KeypadInputResponse command. Error:%s", chip::ErrorStr(err)); + } +} + +bool emberAfKeypadInputClusterSendKeyCallback(chip::app::Command * command, uint8_t keyCode) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfKeypadInputStatus status = keypadInputClusterSendKey(static_cast(keyCode)); + sendResponse(command, status); return true; } diff --git a/src/app/clusters/low-power-server/low-power-server.cpp b/src/app/clusters/low-power-server/low-power-server.cpp index 71342477c76146..aaf56bfefc8ea0 100644 --- a/src/app/clusters/low-power-server/low-power-server.cpp +++ b/src/app/clusters/low-power-server/low-power-server.cpp @@ -15,22 +15,6 @@ * limitations under the License. */ -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /**************************************************************************** * @file * @brief Routines for the Low Power plugin, the @@ -41,9 +25,12 @@ #include #include -bool emberAfLowPowerClusterSleepCallback(chip::app::Command * commandObj) +bool lowPowerClusterSleep(); + +bool emberAfLowPowerClusterSleepCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + bool success = lowPowerClusterSleep(); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; } diff --git a/src/app/clusters/media-input-server/media-input-server.cpp b/src/app/clusters/media-input-server/media-input-server.cpp index eab681a12d3d2d..eccf01dcd1ed3e 100644 --- a/src/app/clusters/media-input-server/media-input-server.cpp +++ b/src/app/clusters/media-input-server/media-input-server.cpp @@ -14,23 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /**************************************************************************** * @file * @brief Routines for the Media Input plugin, the @@ -39,31 +22,62 @@ ******************************************************************************/ #include +#include +#include +#include +#include #include +#include -bool emberAfMediaInputClusterSelectInputCallback(chip::app::Command * commandObj, unsigned char) +bool mediaInputClusterSelectInput(uint8_t input); +bool mediaInputClusterShowInputStatus(); +bool mediaInputClusterHideInputStatus(); +bool mediaInputClusterRenameInput(uint8_t input, std::string name); + +static void storeCurrentInput(chip::EndpointId endpoint, uint8_t currentInput) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + EmberAfStatus status = emberAfWriteServerAttribute( + endpoint, ZCL_MEDIA_INPUT_CLUSTER_ID, ZCL_MEDIA_INPUT_CURRENT_INPUT_ATTRIBUTE_ID, ¤tInput, ZCL_INT8U_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(Zcl, "Failed to store media playback attribute."); + } +} + +bool emberAfMediaInputClusterSelectInputCallback(chip::app::Command * command, uint8_t input) +{ + bool success = mediaInputClusterSelectInput(input); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; + if (success) + { + storeCurrentInput(emberAfCurrentEndpoint(), input); + } emberAfSendImmediateDefaultResponse(status); return true; } -bool emberAfMediaInputClusterHideInputStatusCallback(chip::app::Command * commandObj) + +bool emberAfMediaInputClusterShowInputStatusCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + bool success = mediaInputClusterShowInputStatus(); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; } -bool emberAfMediaInputClusterRenameInputCallback(chip::app::Command * commandObj, unsigned char, unsigned char *) +bool emberAfMediaInputClusterHideInputStatusCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + bool success = mediaInputClusterHideInputStatus(); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; } -bool emberAfMediaInputClusterShowInputStatusCallback(chip::app::Command * commandObj) +bool emberAfMediaInputClusterRenameInputCallback(chip::app::Command * command, uint8_t input, uint8_t * name) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + // TODO: char is not null terminated, verify this code once #7963 gets merged. + std::string nameString(reinterpret_cast(name)); + bool success = mediaInputClusterRenameInput(input, nameString); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; } diff --git a/src/app/clusters/media-playback-server/media-playback-server.cpp b/src/app/clusters/media-playback-server/media-playback-server.cpp index 9119960f83d54a..d86f48c9f4672f 100644 --- a/src/app/clusters/media-playback-server/media-playback-server.cpp +++ b/src/app/clusters/media-playback-server/media-playback-server.cpp @@ -15,22 +15,6 @@ * limitations under the License. */ -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /**************************************************************************** * @file * @brief Routines for the Media Playback plugin, the @@ -39,74 +23,153 @@ ******************************************************************************/ #include +#include +#include +#include +#include +#include +#include #include -bool emberAfMediaPlaybackClusterFastForwardRequestCallback(chip::app::Command * commandObj) +EmberAfMediaPlaybackStatus mediaPlaybackClusterSendMediaPlaybackRequest(MediaPlaybackRequest mediaPlaybackRequest, + uint64_t deltaPositionMilliseconds); + +static void writePlaybackState(chip::EndpointId endpoint, uint8_t playbackState) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfStatus status = emberAfWriteServerAttribute( + endpoint, ZCL_MEDIA_PLAYBACK_CLUSTER_ID, ZCL_MEDIA_PLAYBACK_STATE_ATTRIBUTE_ID, &playbackState, ZCL_INT8U_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(Zcl, "Failed to store media playback attribute."); + } +} + +static uint8_t readPlaybackStatus(chip::EndpointId endpoint) +{ + uint8_t playbackState; + EmberAfStatus status = emberAfReadServerAttribute(endpoint, ZCL_MEDIA_PLAYBACK_CLUSTER_ID, + ZCL_MEDIA_PLAYBACK_STATE_ATTRIBUTE_ID, &playbackState, sizeof(uint8_t)); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(Zcl, "Failed to read media playback attribute."); + } + + return playbackState; +} + +void storeNewPlaybackState(chip::EndpointId endpoint, uint8_t newPlaybackState) +{ + uint8_t mediaPlaybackClusterPlaybackState = readPlaybackStatus(endpoint); + + if (mediaPlaybackClusterPlaybackState == newPlaybackState) + { + return; + } + else + { + writePlaybackState(endpoint, newPlaybackState); + } +} + +static void sendResponse(chip::app::Command * command, const char * responseName, chip::CommandId commandId, + EmberAfMediaPlaybackStatus mediaPlaybackStatus) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + chip::app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_MEDIA_PLAYBACK_CLUSTER_ID, commandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + chip::TLV::TLVWriter * writer = nullptr; + + VerifyOrExit(command != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + SuccessOrExit(err = command->PrepareCommand(cmdParams)); + VerifyOrExit((writer = command->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + SuccessOrExit(err = writer->Put(chip::TLV::ContextTag(0), mediaPlaybackStatus)); + SuccessOrExit(err = command->FinishCommand()); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Failed to send %s. Error:%s", responseName, chip::ErrorStr(err)); + } +} + +bool emberAfMediaPlaybackClusterMediaPlayCallback(chip::app::Command * command) +{ + EmberAfMediaPlaybackStatus status = mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_PLAY, 0); + storeNewPlaybackState(emberAfCurrentEndpoint(), EMBER_ZCL_MEDIA_PLAYBACK_STATE_PLAYING); + sendResponse(command, "MediaPlayResponse", ZCL_MEDIA_PLAY_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterNextRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaPauseCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_PAUSE, 0); + storeNewPlaybackState(emberAfCurrentEndpoint(), EMBER_ZCL_MEDIA_PLAYBACK_STATE_PAUSED); + sendResponse(command, "MediaPauseResponse", ZCL_MEDIA_PAUSE_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterPauseRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaStopCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_STOP, 0); + storeNewPlaybackState(emberAfCurrentEndpoint(), EMBER_ZCL_MEDIA_PLAYBACK_STATE_NOT_PLAYING); + sendResponse(command, "MediaStopResponse", ZCL_MEDIA_STOP_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterPlayRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaFastForwardCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_FAST_FORWARD, 0); + sendResponse(command, "MediaFastForward", ZCL_MEDIA_FAST_FORWARD_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterPreviousRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaPreviousCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_PREVIOUS, 0); + sendResponse(command, "MediaPrevious", ZCL_MEDIA_PREVIOUS_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterRewindRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaRewindCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_REWIND, 0); + sendResponse(command, "MediaRewind", ZCL_MEDIA_REWIND_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterStopRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaSkipBackwardCallback(chip::app::Command * command, uint64_t deltaPositionMilliseconds) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = + mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_SKIP_BACKWARD, deltaPositionMilliseconds); + sendResponse(command, "MediaSkipBackward", ZCL_MEDIA_SKIP_BACKWARD_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterSkipBackwardRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaSkipForwardCallback(chip::app::Command * command, uint64_t deltaPositionMilliseconds) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = + mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_SKIP_FORWARD, deltaPositionMilliseconds); + sendResponse(command, "MediaSkipForward", ZCL_MEDIA_SKIP_FORWARD_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterStartOverRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaSeekCallback(chip::app::Command * command, uint64_t positionMilliseconds) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = + mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_SEEK, positionMilliseconds); + sendResponse(command, "MediaSeek", ZCL_MEDIA_SEEK_RESPONSE_COMMAND_ID, status); return true; } -bool emberAfMediaPlaybackClusterSkipForwardRequestCallback(chip::app::Command * commandObj) +bool emberAfMediaPlaybackClusterMediaNextCallback(chip::app::Command * command) +{ + EmberAfMediaPlaybackStatus status = mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_NEXT, 0); + sendResponse(command, "MediaNext", ZCL_MEDIA_NEXT_RESPONSE_COMMAND_ID, status); + return true; +} +bool emberAfMediaPlaybackClusterMediaStartOverCallback(chip::app::Command * command) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + EmberAfMediaPlaybackStatus status = mediaPlaybackClusterSendMediaPlaybackRequest(MEDIA_PLAYBACK_REQUEST_START_OVER, 0); + sendResponse(command, "MediaStartOver", ZCL_MEDIA_START_OVER_RESPONSE_COMMAND_ID, status); return true; } diff --git a/src/app/clusters/media-playback-server/media-playback-server.h b/src/app/clusters/media-playback-server/media-playback-server.h new file mode 100644 index 00000000000000..2850f97851b1a7 --- /dev/null +++ b/src/app/clusters/media-playback-server/media-playback-server.h @@ -0,0 +1,40 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/**************************************************************************** + * @file + * @brief Routines for the Media Playback plugin, the + *server implementation of the Media Playback cluster. + ******************************************************************************* + ******************************************************************************/ + +#include + +enum MediaPlaybackRequest : uint8_t +{ + MEDIA_PLAYBACK_REQUEST_PLAY = 0, + MEDIA_PLAYBACK_REQUEST_PAUSE = 1, + MEDIA_PLAYBACK_REQUEST_STOP = 2, + MEDIA_PLAYBACK_REQUEST_START_OVER = 3, + MEDIA_PLAYBACK_REQUEST_PREVIOUS = 4, + MEDIA_PLAYBACK_REQUEST_NEXT = 5, + MEDIA_PLAYBACK_REQUEST_REWIND = 6, + MEDIA_PLAYBACK_REQUEST_FAST_FORWARD = 7, + MEDIA_PLAYBACK_REQUEST_SKIP_FORWARD = 8, + MEDIA_PLAYBACK_REQUEST_SKIP_BACKWARD = 9, + MEDIA_PLAYBACK_REQUEST_SEEK = 10, +}; diff --git a/src/app/clusters/target-navigator-server/target-navigator-server.cpp b/src/app/clusters/target-navigator-server/target-navigator-server.cpp index dbc5f23b2ab8df..6bb7b2e50c0939 100644 --- a/src/app/clusters/target-navigator-server/target-navigator-server.cpp +++ b/src/app/clusters/target-navigator-server/target-navigator-server.cpp @@ -15,22 +15,6 @@ * limitations under the License. */ -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ /**************************************************************************** * @file * @brief Routines for the Target Navigator plugin, the @@ -39,11 +23,39 @@ ******************************************************************************/ #include +#include +#include +#include +#include +#include #include -bool emberAfTargetNavigatorClusterNavigateTargetCallback(chip::app::Command * commandObj, unsigned char, unsigned char *) +TargetNavigatorResponse targetNavigatorClusterNavigateTarget(uint8_t target, std::string data); + +void sendResponse(chip::app::Command * command, TargetNavigatorResponse response) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + chip::app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_TARGET_NAVIGATOR_CLUSTER_ID, + ZCL_NAVIGATE_TARGET_RESPONSE_COMMAND_ID, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + chip::TLV::TLVWriter * writer = nullptr; + SuccessOrExit(err = command->PrepareCommand(cmdParams)); + VerifyOrExit((writer = command->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + SuccessOrExit(err = writer->Put(chip::TLV::ContextTag(0), response.status)); + SuccessOrExit(err = writer->PutString(chip::TLV::ContextTag(1), reinterpret_cast(response.data))); + SuccessOrExit(err = command->FinishCommand()); +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Failed to send NavigateTargetResponse. Error:%s", chip::ErrorStr(err)); + } +} + +bool emberAfTargetNavigatorClusterNavigateTargetCallback(chip::app::Command * command, uint8_t target, uint8_t * data) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + // TODO: char is not null terminated, verify this code once #7963 gets merged. + std::string dataString(reinterpret_cast(data)); + TargetNavigatorResponse response = targetNavigatorClusterNavigateTarget(target, dataString); + sendResponse(command, response); return true; } diff --git a/src/app/clusters/target-navigator-server/target-navigator-server.h b/src/app/clusters/target-navigator-server/target-navigator-server.h new file mode 100644 index 00000000000000..9cfb1f06dd6fc7 --- /dev/null +++ b/src/app/clusters/target-navigator-server/target-navigator-server.h @@ -0,0 +1,28 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/**************************************************************************** + * @file + * @brief Routines for the Target Navigator plugin, the + *server implementation of the Target Navigator cluster. + ******************************************************************************* + ******************************************************************************/ + +struct TargetNavigatorResponse +{ + uint8_t status; + uint8_t * data; +}; diff --git a/src/app/clusters/tv-channel-server/tv-channel-server.cpp b/src/app/clusters/tv-channel-server/tv-channel-server.cpp index 664d5ad275c6e2..10db39de675120 100644 --- a/src/app/clusters/tv-channel-server/tv-channel-server.cpp +++ b/src/app/clusters/tv-channel-server/tv-channel-server.cpp @@ -39,24 +39,59 @@ ******************************************************************************/ #include +#include +#include +#include #include -bool emberAfTvChannelClusterChangeChannelCallback(chip::app::Command * commandObj, unsigned char *) +EmberAfTvChannelInfo tvChannelClusterChangeChannel(std::string match); +bool tvChannelClusterChangeChannelByNumber(uint16_t majorNumer, uint16_t minorNumber); +bool tvChannelClusterSkipChannel(uint16_t count); + +void sendResponse(chip::app::Command * command, EmberAfTvChannelInfo channelInfo) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); + CHIP_ERROR err = CHIP_NO_ERROR; + chip::app::CommandPathParams cmdParams = { emberAfCurrentEndpoint(), /* group id */ 0, ZCL_TV_CHANNEL_CLUSTER_ID, + ZCL_CHANGE_CHANNEL_RESPONSE_COMMAND_ID, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + chip::TLV::TLVWriter * writer = nullptr; + SuccessOrExit(err = command->PrepareCommand(cmdParams)); + VerifyOrExit((writer = command->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); + // TODO: Enable this once struct as param is supported + // SuccessOrExit(err = writer->Put(chip::TLV::ContextTag(0), channelInfo)); + // EmberAfTvChannelErrorType. errorType + // SuccessOrExit(err = writer->Put(chip::TLV::ContextTag(1), errorType)); + SuccessOrExit(err = command->FinishCommand()); +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Failed to send ChangeChannel. Error:%s", chip::ErrorStr(err)); + } +} + +bool emberAfTvChannelClusterChangeChannelCallback(chip::app::Command * command, uint8_t * match) +{ + // TODO: char is not null terminated, verify this code once #7963 gets merged. + std::string matchString(reinterpret_cast(match)); + // TODO: Enable this once struct as param is supported + // EmberAfTvChannelInfo channelInfo = tvChannelClusterChangeChannel(matchString); + // sendResponse(command, channelInfo); + emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); return true; } -bool emberAfTvChannelClusterChangeChannelByNumberCallback(chip::app::Command * commandObj, unsigned short, unsigned short) +bool emberAfTvChannelClusterChangeChannelByNumberCallback(chip::app::Command * command, uint16_t majorNumber, uint16_t minorNumber) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + bool success = tvChannelClusterChangeChannelByNumber(majorNumber, minorNumber); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; } -bool emberAfTvChannelClusterSkipChannelCallback(chip::app::Command * commandObj, unsigned short) + +bool emberAfTvChannelClusterSkipChannelCallback(chip::app::Command * command, uint16_t count) { - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; + bool success = tvChannelClusterSkipChannel(count); + EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; } diff --git a/src/app/common/gen/client-command-macro.h b/src/app/common/gen/client-command-macro.h index 4d470f3d54a6c8..bdaac8f9afe84a 100644 --- a/src/app/common/gen/client-command-macro.h +++ b/src/app/common/gen/client-command-macro.h @@ -4316,26 +4316,26 @@ \ ZCL_MEDIA_SKIP_BACKWARD_RESPONSE_COMMAND_ID, "u", mediaPlaybackStatus); -/** @brief Command description for MediaSkipSeek +/** @brief Command description for MediaSeek * - * Command: MediaSkipSeek + * Command: MediaSeek * @param position INT64U */ #define emberAfFillCommandMedia \ - PlaybackClusterMediaSkipSeek(position) emberAfFillExternalBuffer(mask, \ + PlaybackClusterMediaSeek(position) emberAfFillExternalBuffer(mask, \ \ - ZCL_MEDIA_SKIP_SEEK_COMMAND_ID, "u", position); + ZCL_MEDIA_SEEK_COMMAND_ID, "u", position); -/** @brief Command description for MediaSkipSeekResponse +/** @brief Command description for MediaSeekResponse * - * Command: MediaSkipSeekResponse + * Command: MediaSeekResponse * @param mediaPlaybackStatus MediaPlaybackStatus */ #define emberAfFillCommandMedia \ - PlaybackClusterMediaSkipSeekResponse(mediaPlaybackStatus) \ + PlaybackClusterMediaSeekResponse(mediaPlaybackStatus) \ emberAfFillExternalBuffer(mask, \ \ - ZCL_MEDIA_SKIP_SEEK_RESPONSE_COMMAND_ID, "u", mediaPlaybackStatus); + ZCL_MEDIA_SEEK_RESPONSE_COMMAND_ID, "u", mediaPlaybackStatus); /** @brief Command description for SelectInput * @@ -4531,14 +4531,12 @@ /** @brief Command description for LaunchApp * * Command: LaunchApp - * @param application ApplicationLauncherApp [] - * @param applicationLen int + * @param catalogVendorId INT16U */ #define emberAfFillCommandApplication \ - LauncherClusterLaunchApp(application, applicationLen) \ - emberAfFillExternalBuffer(mask, \ + LauncherClusterLaunchApp(catalogVendorId) emberAfFillExternalBuffer(mask, \ \ - ZCL_LAUNCH_APP_COMMAND_ID, "b", application, applicationLen); + ZCL_LAUNCH_APP_COMMAND_ID, "u", catalogVendorId); /** @brief Command description for LaunchAppResponse * @@ -4550,6 +4548,16 @@ \ ZCL_LAUNCH_APP_RESPONSE_COMMAND_ID, "u", data); +/** @brief Command description for LaunchApp + * + * Command: LaunchApp + * @param applicationId CHAR_STRING + */ +#define emberAfFillCommandApplication \ + LauncherClusterLaunchApp(applicationId) emberAfFillExternalBuffer(mask, \ + \ + ZCL_LAUNCH_APP_COMMAND_ID, "u", applicationId); + /** @brief Command description for ChangeStatus * * Command: ChangeStatus diff --git a/src/app/common/gen/command-id.h b/src/app/common/gen/command-id.h index 5de8fa92c056c3..764e29ea5d75f8 100644 --- a/src/app/common/gen/command-id.h +++ b/src/app/common/gen/command-id.h @@ -399,8 +399,8 @@ #define ZCL_MEDIA_SKIP_FORWARD_RESPONSE_COMMAND_ID (0x08) #define ZCL_MEDIA_SKIP_BACKWARD_COMMAND_ID (0x09) #define ZCL_MEDIA_SKIP_BACKWARD_RESPONSE_COMMAND_ID (0x09) -#define ZCL_MEDIA_SKIP_SEEK_COMMAND_ID (0x0A) -#define ZCL_MEDIA_SKIP_SEEK_RESPONSE_COMMAND_ID (0x0A) +#define ZCL_MEDIA_SEEK_COMMAND_ID (0x0A) +#define ZCL_MEDIA_SEEK_RESPONSE_COMMAND_ID (0x0B) // Commands for cluster: Media Input #define ZCL_SELECT_INPUT_COMMAND_ID (0x00) diff --git a/src/app/common/gen/ids/Attributes.h b/src/app/common/gen/ids/Attributes.h index af543b5843d8e7..5128e72197590c 100644 --- a/src/app/common/gen/ids/Attributes.h +++ b/src/app/common/gen/ids/Attributes.h @@ -1318,13 +1318,13 @@ static constexpr AttributeId ApplicationId = 0x0002; namespace ApplicationBasic { namespace Attributes { namespace Ids { -static constexpr AttributeId VendorName = 0x0000; -static constexpr AttributeId VendorId = 0x0001; -static constexpr AttributeId ApplicationName = 0x0002; -static constexpr AttributeId ProductId = 0x0003; -static constexpr AttributeId ApplicationId = 0x0005; -static constexpr AttributeId CatalogVendorId = 0x0006; -static constexpr AttributeId ApplicationSatus = 0x0007; +static constexpr AttributeId VendorName = 0x0000; +static constexpr AttributeId VendorId = 0x0001; +static constexpr AttributeId ApplicationName = 0x0002; +static constexpr AttributeId ProductId = 0x0003; +static constexpr AttributeId ApplicationId = 0x0005; +static constexpr AttributeId CatalogVendorId = 0x0006; +static constexpr AttributeId ApplicationStatus = 0x0007; } // namespace Ids } // namespace Attributes } // namespace ApplicationBasic diff --git a/src/app/common/gen/ids/Commands.h b/src/app/common/gen/ids/Commands.h index 358ab71870c228..f5156f22826dd8 100644 --- a/src/app/common/gen/ids/Commands.h +++ b/src/app/common/gen/ids/Commands.h @@ -566,8 +566,8 @@ static constexpr CommandId MediaSkipForward = 0x08; static constexpr CommandId MediaSkipForwardResponse = 0x08; static constexpr CommandId MediaSkipBackward = 0x09; static constexpr CommandId MediaSkipBackwardResponse = 0x09; -static constexpr CommandId MediaSkipSeek = 0x0A; -static constexpr CommandId MediaSkipSeekResponse = 0x0A; +static constexpr CommandId MediaSeek = 0x0A; +static constexpr CommandId MediaSeekResponse = 0x0B; } // namespace Ids } // namespace Commands } // namespace MediaPlayback diff --git a/src/app/tests/suites/TV_AccountLoginCluster.yaml b/src/app/tests/suites/TV_AccountLoginCluster.yaml new file mode 100644 index 00000000000000..a713295169922b --- /dev/null +++ b/src/app/tests/suites/TV_AccountLoginCluster.yaml @@ -0,0 +1,41 @@ +# 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. + +name: Account Login Cluster Tests + +config: + cluster: "Account Login" + endpoint: 3 + +tests: + - label: "Get Setup PIN Command" + command: "GetSetupPIN" + arguments: + values: + - name: "tempAccountIdentifier" + value: "asdf" + + # TODO: Enable these once they are able to work + # response: + # values: + # - name: "setupPIN" + # value: "tempPin123" + - label: "Login Command" + command: "Login" + arguments: + values: + - name: "tempAccountIdentifier" + value: "asdf" + - name: "setupPIN" + value: "tempPin123" diff --git a/src/app/tests/suites/TV_ApplicationBasicCluster.yaml b/src/app/tests/suites/TV_ApplicationBasicCluster.yaml new file mode 100644 index 00000000000000..12eecf629fb38a --- /dev/null +++ b/src/app/tests/suites/TV_ApplicationBasicCluster.yaml @@ -0,0 +1,66 @@ +# 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. + +name: Application Basic Cluster Tests + +config: + cluster: "Application Basic" + endpoint: 3 + +tests: + - label: "Change Status Command" + command: "ChangeStatus" + arguments: + values: + - name: "status" + value: 1 + + - label: "Read attribute vendor name" + command: "readAttribute" + attribute: "vendor name" + + # TODO: Support chars validation + # response: + # value: "exampleVendorName1" + - label: "Read attribute vendor id" + command: "readAttribute" + attribute: "vendor id" + response: + value: 1 + + - label: "Read attribute name" + command: "readAttribute" + attribute: "application name" + + # TODO: Support chars validation + # response: + # value: "exampleName1" + - label: "Read attribute product id" + command: "readAttribute" + attribute: "product id" + response: + value: 1 + + - label: "Read attribute id" + command: "readAttribute" + attribute: "application id" + + # TODO: Support chars validation + # response: + # value: "appId" + - label: "Read attribute catalog vendor id" + command: "readAttribute" + attribute: "catalog vendor id" + response: + value: 1 diff --git a/src/app/tests/suites/TV_ApplicationLauncherCluster.yaml b/src/app/tests/suites/TV_ApplicationLauncherCluster.yaml new file mode 100644 index 00000000000000..545623bd82dfa8 --- /dev/null +++ b/src/app/tests/suites/TV_ApplicationLauncherCluster.yaml @@ -0,0 +1,37 @@ +# 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. + +name: Application Launcher Cluster Tests + +config: + cluster: "Application Launcher" + endpoint: 1 + +tests: + - label: "Read attribute Application Launcher list" + command: "readAttribute" + attribute: "Application Launcher List" + response: + value: [123, 456] + + - label: "Launch App Command" + command: "LaunchApp" + arguments: + values: + - name: "data" + value: "exampleData" + - name: "catalogVendorId" + value: 1 + - name: "applicationId" + value: "appId" diff --git a/src/app/tests/suites/TV_AudioOutputCluster.yaml b/src/app/tests/suites/TV_AudioOutputCluster.yaml new file mode 100644 index 00000000000000..f6116a67fa399f --- /dev/null +++ b/src/app/tests/suites/TV_AudioOutputCluster.yaml @@ -0,0 +1,47 @@ +# 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. + +name: Audio Output Cluster Tests + +config: + cluster: "Audio Output" + endpoint: 2 + +tests: + - label: "Read attribute Audio Output list" + command: "readAttribute" + attribute: "Audio Output List" + response: + value: + [ + { index: 1, outputType: 0, name: 12 }, + { index: 2, outputType: 0, name: 12 }, + { index: 3, outputType: 0, name: 12 }, + ] + + - label: "Select Output Command" + command: "SelectOutput" + arguments: + values: + - name: "index" + value: 1 + + - label: "Rename Output Command" + command: "RenameOutput" + arguments: + values: + - name: "index" + value: 1 + - name: "name" + value: "exampleName" diff --git a/src/app/tests/suites/TV_KeypadInputCluster.yaml b/src/app/tests/suites/TV_KeypadInputCluster.yaml new file mode 100644 index 00000000000000..bddf3002db8819 --- /dev/null +++ b/src/app/tests/suites/TV_KeypadInputCluster.yaml @@ -0,0 +1,27 @@ +# 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. + +name: Keypad Input Cluster Tests + +config: + cluster: "Keypad Input" + endpoint: 1 + +tests: + - label: "Send Key Command" + command: "SendKey" + arguments: + values: + - name: "keyCode" + value: 3 diff --git a/src/app/tests/suites/TV_LowPowerCluster.yaml b/src/app/tests/suites/TV_LowPowerCluster.yaml new file mode 100644 index 00000000000000..a100c7293cfea4 --- /dev/null +++ b/src/app/tests/suites/TV_LowPowerCluster.yaml @@ -0,0 +1,23 @@ +# 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. + +name: Low Power Cluster Tests + +config: + cluster: "Low Power" + endpoint: 1 + +tests: + - label: "Sleep Input Status Command" + command: "Sleep" diff --git a/src/app/tests/suites/TV_MediaInputCluster.yaml b/src/app/tests/suites/TV_MediaInputCluster.yaml new file mode 100644 index 00000000000000..8f26fb10311501 --- /dev/null +++ b/src/app/tests/suites/TV_MediaInputCluster.yaml @@ -0,0 +1,52 @@ +# 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. + +name: Media Input Cluster Tests + +config: + cluster: "Media Input" + endpoint: 1 + +tests: + - label: "Read attribute media input list" + command: "readAttribute" + attribute: "media input list" + response: + value: + [ + { index: 1, inputType: 4, name: 12, description: 19 }, + { index: 2, inputType: 4, name: 12, description: 19 }, + ] + + - label: "Select Input Command" + command: "SelectInput" + arguments: + values: + - name: "index" + value: 1 + + - label: "Hide Input Status Command" + command: "HideInputStatus" + + - label: "Show Input Status Command" + command: "ShowInputStatus" + + - label: "Rename Input Command" + command: "RenameInput" + arguments: + values: + - name: "index" + value: 1 + - name: "name" + value: "newName" diff --git a/src/app/tests/suites/TV_MediaPlaybackCluster.yaml b/src/app/tests/suites/TV_MediaPlaybackCluster.yaml new file mode 100644 index 00000000000000..6607a3f21abea5 --- /dev/null +++ b/src/app/tests/suites/TV_MediaPlaybackCluster.yaml @@ -0,0 +1,109 @@ +# 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. + +name: Media Playback Cluster Tests + +config: + cluster: "Media Playback" + endpoint: 3 + +tests: + - label: "Media Playback Play Command" + command: "MediaPlay" + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Pause Command" + command: "MediaPause" + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Stop Command" + command: "MediaStop" + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Start Over Command" + command: "MediaStartOver" + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Previous Command" + command: "MediaPrevious" + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Next Command" + command: "MediaNext" + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Rewind Command" + command: "MediaRewind" + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Fast Forward Command" + command: "MediaFastForward" + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Skip Forward Command" + command: "MediaSkipForward" + arguments: + values: + - name: "deltaPositionMilliseconds" + value: 100 + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Skip Backward Command" + command: "MediaSkipBackward" + arguments: + values: + - name: "deltaPositionMilliseconds" + value: 100 + response: + values: + - name: "mediaPlaybackStatus" + value: 0 + + - label: "Media Playback Seek Command" + command: "MediaSeek" + arguments: + values: + - name: "position" + value: 100 + response: + values: + - name: "mediaPlaybackStatus" + value: 0 diff --git a/src/app/tests/suites/TV_TargetNavigatorCluster.yaml b/src/app/tests/suites/TV_TargetNavigatorCluster.yaml new file mode 100644 index 00000000000000..807f3e8010270d --- /dev/null +++ b/src/app/tests/suites/TV_TargetNavigatorCluster.yaml @@ -0,0 +1,35 @@ +# 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. + +name: Target Navigator Cluster Tests + +config: + cluster: "Target Navigator" + endpoint: 1 + +tests: + - label: "Read attribute Target Navigator list" + command: "readAttribute" + attribute: "Target Navigator List" + response: + value: [{ identifier: 1, name: 12 }, { identifier: 2, name: 12 }] + + - label: "Navigate Target Command" + command: "NavigateTarget" + arguments: + values: + - name: "target" + value: 1 + - name: "data" + value: 1 diff --git a/src/app/tests/suites/TV_TvChannelCluster.yaml b/src/app/tests/suites/TV_TvChannelCluster.yaml new file mode 100644 index 00000000000000..31d92d203696c0 --- /dev/null +++ b/src/app/tests/suites/TV_TvChannelCluster.yaml @@ -0,0 +1,65 @@ +# 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. + +name: TV Channel Cluster Tests + +config: + cluster: "TV Channel" + endpoint: 1 + +tests: + - label: "Read attribute TV Channel list" + command: "readAttribute" + attribute: "TV Channel list" + response: + value: + [ + { + majorNumber: 1, + minorNumber: 2, + name: 12, + callSign: 13, + affiliateCallSign: 13, + }, + { + majorNumber: 2, + minorNumber: 3, + name: 12, + callSign: 13, + affiliateCallSign: 13, + }, + ] + # TODO: Enable the test once struct response is supported + # - label: "Change Channel Command" + # command: "ChangeChannel" + # arguments: + # values: + # - name: "match" + # value: "CNN" + + - label: "Change Channel By Number Command" + command: "ChangeChannelByNumber" + arguments: + values: + - name: "majorNumber" + value: 1 + - name: "minorNumber" + value: 2 + + - label: "Skip Channel Command" + command: "SkipChannel" + arguments: + values: + - name: "count" + value: 1 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 44fd13b3e20a0b..abc8951e75baa4 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 @@ -30,7 +30,7 @@ limitations under the License. product id application id catalog vendor id - application satus + application status Upon receipt, this SHALL change the running status of the application. 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 2a12dfe6e001ca..462bddb35e47a3 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 @@ -26,14 +26,16 @@ limitations under the License. This cluster provides an interface for launching content on a media player device such as a TV or Speaker. application launcher list - + catalog vendor id application id 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. - + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/media-playback-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/media-playback-cluster.xml index bdb3b2400e64ff..69431a2aad3cad 100644 --- a/src/app/zap-templates/zcl/data-model/chip/media-playback-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/media-playback-cluster.xml @@ -79,7 +79,7 @@ limitations under the License. - + Upon receipt, this SHALL Skip backward in the media by the given number of seconds, using the data as follows: @@ -134,7 +134,7 @@ limitations under the License. - + Upon receipt, this SHALL change the playback position in the media to the given position using data as follows: diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index d11456c6d4f934..0d0b34eaaf9574 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -10,10 +10,10 @@ # List of directories in src/app/clusters to build for server clusters. SERVER_CLUSTERS: typing.Dict[str, typing.List[str]] = { 'ALARM_CLUSTER': [], - 'APPLICATION_BASIC_CLUSTER': [], - 'ACCOUNT_LOGIN_CLUSTER': [], + 'APPLICATION_BASIC_CLUSTER': ['application-basic-server'], + 'ACCOUNT_LOGIN_CLUSTER': ['account-login-server'], 'APPLICATION_LAUNCHER_CLUSTER': ['application-launcher-server'], - 'AUDIO_OUTPUT_CLUSTER': [], + 'AUDIO_OUTPUT_CLUSTER': ['audio-output-server'], 'BARRIER_CONTROL_CLUSTER': ['barrier-control-server'], 'BASIC_CLUSTER': ['basic'], 'BINARY_INPUT_BASIC_CLUSTER': ['binary-input-server'], @@ -35,7 +35,7 @@ 'GROUP_KEY_MANAGEMENT_CLUSTER': [], 'IAS_ZONE_CLUSTER': ['ias-zone-server'], 'IDENTIFY_CLUSTER': ['identify'], - 'KEYPAD_INPUT_CLUSTER': ['keypad-input-server'], + 'KEYPAD_INPUT_CLUSTER': [ 'keypad-input-server'], 'LEVEL_CONTROL_CLUSTER': ['level-control'], 'LOW_POWER_CLUSTER': ['low-power-server'], 'MEDIA_INPUT_CLUSTER': ['media-input-server'], diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 33ef9372d93fad..86c88cc7b83f6e 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -7464,7 +7464,7 @@ "outgoing": 1 }, { - "name": "MediaSkipSeek", + "name": "MediaSeek", "code": 10, "mfgCode": null, "source": "client", @@ -7579,8 +7579,8 @@ "outgoing": 0 }, { - "name": "MediaSkipSeekResponse", - "code": 10, + "name": "MediaSeekResponse", + "code": 11, "mfgCode": null, "source": "server", "incoming": 1, @@ -8256,7 +8256,7 @@ "reportableChange": 0 }, { - "name": "application satus", + "name": "application status", "code": 7, "mfgCode": null, "side": "server", @@ -9157,4 +9157,4 @@ } ], "log": [] -} +} \ No newline at end of file diff --git a/src/controller/data_model/gen/CHIPClientCallbacks.cpp b/src/controller/data_model/gen/CHIPClientCallbacks.cpp index f141142e5bf7ac..f7bef97ef6e019 100644 --- a/src/controller/data_model/gen/CHIPClientCallbacks.cpp +++ b/src/controller/data_model/gen/CHIPClientCallbacks.cpp @@ -2470,6 +2470,19 @@ bool emberAfMediaPlaybackClusterMediaRewindResponseCallback(chip::app::Command * return true; } +bool emberAfMediaPlaybackClusterMediaSeekResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus) +{ + ChipLogProgress(Zcl, "MediaSeekResponse:"); + ChipLogProgress(Zcl, " mediaPlaybackStatus: %" PRIu8 "", mediaPlaybackStatus); + + GET_CLUSTER_RESPONSE_CALLBACKS("MediaPlaybackClusterMediaSeekResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, mediaPlaybackStatus); + return true; +} + bool emberAfMediaPlaybackClusterMediaSkipBackwardResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus) { ChipLogProgress(Zcl, "MediaSkipBackwardResponse:"); @@ -2496,19 +2509,6 @@ bool emberAfMediaPlaybackClusterMediaSkipForwardResponseCallback(chip::app::Comm return true; } -bool emberAfMediaPlaybackClusterMediaSkipSeekResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus) -{ - ChipLogProgress(Zcl, "MediaSkipSeekResponse:"); - ChipLogProgress(Zcl, " mediaPlaybackStatus: %" PRIu8 "", mediaPlaybackStatus); - - GET_CLUSTER_RESPONSE_CALLBACKS("MediaPlaybackClusterMediaSkipSeekResponseCallback"); - - Callback::Callback * cb = - Callback::Callback::FromCancelable(onSuccessCallback); - cb->mCall(cb->mContext, mediaPlaybackStatus); - return true; -} - bool emberAfMediaPlaybackClusterMediaStartOverResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus) { ChipLogProgress(Zcl, "MediaStartOverResponse:"); diff --git a/src/controller/data_model/gen/CHIPClientCallbacks.h b/src/controller/data_model/gen/CHIPClientCallbacks.h index f6736eba27e35c..2146f9207f3320 100644 --- a/src/controller/data_model/gen/CHIPClientCallbacks.h +++ b/src/controller/data_model/gen/CHIPClientCallbacks.h @@ -137,9 +137,9 @@ typedef void (*MediaPlaybackClusterMediaPauseResponseCallback)(void * context, u typedef void (*MediaPlaybackClusterMediaPlayResponseCallback)(void * context, uint8_t mediaPlaybackStatus); typedef void (*MediaPlaybackClusterMediaPreviousResponseCallback)(void * context, uint8_t mediaPlaybackStatus); typedef void (*MediaPlaybackClusterMediaRewindResponseCallback)(void * context, uint8_t mediaPlaybackStatus); +typedef void (*MediaPlaybackClusterMediaSeekResponseCallback)(void * context, uint8_t mediaPlaybackStatus); typedef void (*MediaPlaybackClusterMediaSkipBackwardResponseCallback)(void * context, uint8_t mediaPlaybackStatus); typedef void (*MediaPlaybackClusterMediaSkipForwardResponseCallback)(void * context, uint8_t mediaPlaybackStatus); -typedef void (*MediaPlaybackClusterMediaSkipSeekResponseCallback)(void * context, uint8_t mediaPlaybackStatus); typedef void (*MediaPlaybackClusterMediaStartOverResponseCallback)(void * context, uint8_t mediaPlaybackStatus); typedef void (*MediaPlaybackClusterMediaStopResponseCallback)(void * context, uint8_t mediaPlaybackStatus); typedef void (*NetworkCommissioningClusterAddThreadNetworkResponseCallback)(void * context, uint8_t errorCode, uint8_t * debugText); diff --git a/src/controller/data_model/gen/CHIPClusters.cpp b/src/controller/data_model/gen/CHIPClusters.cpp index edf4d4e578de71..806d31e96285da 100644 --- a/src/controller/data_model/gen/CHIPClusters.cpp +++ b/src/controller/data_model/gen/CHIPClusters.cpp @@ -258,8 +258,8 @@ CHIP_ERROR ApplicationBasicCluster::ReadAttributeCatalogVendorId(Callback::Cance BasicAttributeFilter); } -CHIP_ERROR ApplicationBasicCluster::ReadAttributeApplicationSatus(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) +CHIP_ERROR ApplicationBasicCluster::ReadAttributeApplicationStatus(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) { chip::app::AttributePathParams attributePath; attributePath.mEndpointId = mEndpoint; @@ -6123,8 +6123,8 @@ CHIP_ERROR MediaPlaybackCluster::MediaRewind(Callback::Cancelable * onSuccessCal return err; } -CHIP_ERROR MediaPlaybackCluster::MediaSkipBackward(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds) +CHIP_ERROR MediaPlaybackCluster::MediaSeek(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + uint64_t position) { CHIP_ERROR err = CHIP_NO_ERROR; app::CommandSender * sender = nullptr; @@ -6137,7 +6137,7 @@ CHIP_ERROR MediaPlaybackCluster::MediaSkipBackward(Callback::Cancelable * onSucc VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSkipBackwardCommandId, + app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSeekCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender)); @@ -6145,8 +6145,8 @@ CHIP_ERROR MediaPlaybackCluster::MediaSkipBackward(Callback::Cancelable * onSucc SuccessOrExit(err = sender->PrepareCommand(cmdParams)); VerifyOrExit((writer = sender->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // deltaPositionMilliseconds: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), deltaPositionMilliseconds)); + // position: int64u + SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), position)); SuccessOrExit(err = sender->FinishCommand()); @@ -6164,8 +6164,8 @@ CHIP_ERROR MediaPlaybackCluster::MediaSkipBackward(Callback::Cancelable * onSucc return err; } -CHIP_ERROR MediaPlaybackCluster::MediaSkipForward(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds) +CHIP_ERROR MediaPlaybackCluster::MediaSkipBackward(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds) { CHIP_ERROR err = CHIP_NO_ERROR; app::CommandSender * sender = nullptr; @@ -6178,7 +6178,7 @@ CHIP_ERROR MediaPlaybackCluster::MediaSkipForward(Callback::Cancelable * onSucce VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSkipForwardCommandId, + app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSkipBackwardCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender)); @@ -6205,8 +6205,8 @@ CHIP_ERROR MediaPlaybackCluster::MediaSkipForward(Callback::Cancelable * onSucce return err; } -CHIP_ERROR MediaPlaybackCluster::MediaSkipSeek(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint64_t position) +CHIP_ERROR MediaPlaybackCluster::MediaSkipForward(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds) { CHIP_ERROR err = CHIP_NO_ERROR; app::CommandSender * sender = nullptr; @@ -6219,7 +6219,7 @@ CHIP_ERROR MediaPlaybackCluster::MediaSkipSeek(Callback::Cancelable * onSuccessC VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSkipSeekCommandId, + app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMediaSkipForwardCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender)); @@ -6227,8 +6227,8 @@ CHIP_ERROR MediaPlaybackCluster::MediaSkipSeek(Callback::Cancelable * onSuccessC SuccessOrExit(err = sender->PrepareCommand(cmdParams)); VerifyOrExit((writer = sender->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // position: int64u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), position)); + // deltaPositionMilliseconds: int64u + SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), deltaPositionMilliseconds)); SuccessOrExit(err = sender->FinishCommand()); diff --git a/src/controller/data_model/gen/CHIPClusters.h b/src/controller/data_model/gen/CHIPClusters.h index 9915ac64d1a3f7..1f58a61b350b7b 100644 --- a/src/controller/data_model/gen/CHIPClusters.h +++ b/src/controller/data_model/gen/CHIPClusters.h @@ -113,7 +113,7 @@ class DLL_EXPORT ApplicationBasicCluster : public ClusterBase CHIP_ERROR ReadAttributeProductId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeApplicationId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeCatalogVendorId(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeApplicationSatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeApplicationStatus(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); private: @@ -892,11 +892,11 @@ class DLL_EXPORT MediaPlaybackCluster : public ClusterBase CHIP_ERROR MediaPlay(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR MediaPrevious(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR MediaRewind(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR MediaSeek(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint64_t position); CHIP_ERROR MediaSkipBackward(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds); CHIP_ERROR MediaSkipForward(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint64_t deltaPositionMilliseconds); - CHIP_ERROR MediaSkipSeek(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint64_t position); CHIP_ERROR MediaStartOver(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR MediaStop(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); @@ -911,9 +911,9 @@ class DLL_EXPORT MediaPlaybackCluster : public ClusterBase static constexpr CommandId kMediaPlayCommandId = 0x00; static constexpr CommandId kMediaPreviousCommandId = 0x04; static constexpr CommandId kMediaRewindCommandId = 0x06; + static constexpr CommandId kMediaSeekCommandId = 0x0A; static constexpr CommandId kMediaSkipBackwardCommandId = 0x09; static constexpr CommandId kMediaSkipForwardCommandId = 0x08; - static constexpr CommandId kMediaSkipSeekCommandId = 0x0A; static constexpr CommandId kMediaStartOverCommandId = 0x03; static constexpr CommandId kMediaStopCommandId = 0x02; }; diff --git a/src/controller/data_model/gen/IMClusterCommandHandler.cpp b/src/controller/data_model/gen/IMClusterCommandHandler.cpp index 9017384223f213..2e696574fcc7fb 100644 --- a/src/controller/data_model/gen/IMClusterCommandHandler.cpp +++ b/src/controller/data_model/gen/IMClusterCommandHandler.cpp @@ -3110,7 +3110,7 @@ void DispatchClientCommand(app::Command * apCommandObj, CommandId aCommandId, En } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSkipBackwardResponse: { + case Clusters::MediaPlayback::Commands::Ids::MediaSeekResponse: { expectArgumentCount = 1; uint8_t mediaPlaybackStatus; bool argExists[1]; @@ -3165,11 +3165,11 @@ void DispatchClientCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSkipBackwardResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfMediaPlaybackClusterMediaSeekResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSkipForwardResponse: { + case Clusters::MediaPlayback::Commands::Ids::MediaSkipBackwardResponse: { expectArgumentCount = 1; uint8_t mediaPlaybackStatus; bool argExists[1]; @@ -3224,11 +3224,11 @@ void DispatchClientCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSkipForwardResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfMediaPlaybackClusterMediaSkipBackwardResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSkipSeekResponse: { + case Clusters::MediaPlayback::Commands::Ids::MediaSkipForwardResponse: { expectArgumentCount = 1; uint8_t mediaPlaybackStatus; bool argExists[1]; @@ -3283,7 +3283,7 @@ void DispatchClientCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSkipSeekResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfMediaPlaybackClusterMediaSkipForwardResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } diff --git a/src/controller/data_model/gen/callback.h b/src/controller/data_model/gen/callback.h index cde7d97fb4de4b..fbe53f3ed539e6 100644 --- a/src/controller/data_model/gen/callback.h +++ b/src/controller/data_model/gen/callback.h @@ -3985,22 +3985,22 @@ bool emberAfMediaPlaybackClusterMediaPreviousResponseCallback(chip::app::Command bool emberAfMediaPlaybackClusterMediaRewindResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus); /** - * @brief Media Playback Cluster MediaSkipBackwardResponse Command callback + * @brief Media Playback Cluster MediaSeekResponse Command callback */ -bool emberAfMediaPlaybackClusterMediaSkipBackwardResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus); +bool emberAfMediaPlaybackClusterMediaSeekResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus); /** - * @brief Media Playback Cluster MediaSkipForwardResponse Command callback + * @brief Media Playback Cluster MediaSkipBackwardResponse Command callback */ -bool emberAfMediaPlaybackClusterMediaSkipForwardResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus); +bool emberAfMediaPlaybackClusterMediaSkipBackwardResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus); /** - * @brief Media Playback Cluster MediaSkipSeekResponse Command callback + * @brief Media Playback Cluster MediaSkipForwardResponse Command callback */ -bool emberAfMediaPlaybackClusterMediaSkipSeekResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus); +bool emberAfMediaPlaybackClusterMediaSkipForwardResponseCallback(chip::app::Command * commandObj, uint8_t mediaPlaybackStatus); /** * @brief Media Playback Cluster MediaStartOverResponse Command callback diff --git a/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h b/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h index 7c9cdabd82ff7f..48899292648be7 100644 --- a/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h +++ b/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h @@ -114,7 +114,7 @@ chip::System::PacketBufferHandle encodeAccountLoginClusterReadClusterRevisionAtt | * ProductId | 0x0003 | | * ApplicationId | 0x0005 | | * CatalogVendorId | 0x0006 | -| * ApplicationSatus | 0x0007 | +| * ApplicationStatus | 0x0007 | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ @@ -169,10 +169,10 @@ chip::System::PacketBufferHandle encodeApplicationBasicClusterReadCatalogVendorI /** * @brief - * Encode a Application Basic server read command for the application satus attribute into buffer including the APS frame + * Encode a Application Basic server read command for the application status attribute into buffer including the APS frame */ -chip::System::PacketBufferHandle encodeApplicationBasicClusterReadApplicationSatusAttribute(uint8_t seqNum, - chip::EndpointId destinationEndpoint); +chip::System::PacketBufferHandle encodeApplicationBasicClusterReadApplicationStatusAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); /** * @brief @@ -2088,9 +2088,9 @@ chip::System::PacketBufferHandle encodeMediaInputClusterReadClusterRevisionAttri | * MediaPlay | 0x00 | | * MediaPrevious | 0x04 | | * MediaRewind | 0x06 | +| * MediaSeek | 0x0A | | * MediaSkipBackward | 0x09 | | * MediaSkipForward | 0x08 | -| * MediaSkipSeek | 0x0A | | * MediaStartOver | 0x03 | | * MediaStop | 0x02 | |------------------------------------------------------------------------------| diff --git a/src/controller/data_model/gen/encoder.cpp b/src/controller/data_model/gen/encoder.cpp index 8fbea087925aff..744cca1f112b69 100644 --- a/src/controller/data_model/gen/encoder.cpp +++ b/src/controller/data_model/gen/encoder.cpp @@ -165,7 +165,7 @@ PacketBufferHandle encodeAccountLoginClusterReadClusterRevisionAttribute(uint8_t | * ProductId | 0x0003 | | * ApplicationId | 0x0005 | | * CatalogVendorId | 0x0006 | -| * ApplicationSatus | 0x0007 | +| * ApplicationStatus | 0x0007 | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ @@ -255,15 +255,15 @@ PacketBufferHandle encodeApplicationBasicClusterReadCatalogVendorIdAttribute(uin } /* - * Attribute ApplicationSatus + * Attribute ApplicationStatus */ -PacketBufferHandle encodeApplicationBasicClusterReadApplicationSatusAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +PacketBufferHandle encodeApplicationBasicClusterReadApplicationStatusAttribute(uint8_t seqNum, EndpointId destinationEndpoint) { - COMMAND_HEADER("ReadApplicationBasicApplicationSatus", ApplicationBasic::Id); + COMMAND_HEADER("ReadApplicationBasicApplicationStatus", ApplicationBasic::Id); buf.Put8(kFrameControlGlobalCommand) .Put8(seqNum) .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ApplicationBasic::Attributes::Ids::ApplicationSatus); + .Put32(ApplicationBasic::Attributes::Ids::ApplicationStatus); COMMAND_FOOTER(); } @@ -3341,9 +3341,9 @@ PacketBufferHandle encodeMediaInputClusterReadClusterRevisionAttribute(uint8_t s | * MediaPlay | 0x00 | | * MediaPrevious | 0x04 | | * MediaRewind | 0x06 | +| * MediaSeek | 0x0A | | * MediaSkipBackward | 0x09 | | * MediaSkipForward | 0x08 | -| * MediaSkipSeek | 0x0A | | * MediaStartOver | 0x03 | | * MediaStop | 0x02 | |------------------------------------------------------------------------------| diff --git a/src/controller/data_model/gen/endpoint_config.h b/src/controller/data_model/gen/endpoint_config.h index 1e279851b76503..bed56ac8b08c83 100644 --- a/src/controller/data_model/gen/endpoint_config.h +++ b/src/controller/data_model/gen/endpoint_config.h @@ -660,8 +660,8 @@ { 0x0506, 0x08, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipForwardResponse */ \ { 0x0506, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSkipBackward */ \ { 0x0506, 0x09, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipBackwardResponse */ \ - { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSkipSeek */ \ - { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSkipSeekResponse */ \ + { 0x0506, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MediaSeek */ \ + { 0x0506, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* MediaSeekResponse */ \ \ /* Endpoint: 1, Cluster: Media Input (client) */ \ { 0x0507, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SelectInput */ \ diff --git a/src/controller/java/gen/CHIPClusters-JNI.cpp b/src/controller/java/gen/CHIPClusters-JNI.cpp index 27456848d8aa30..ec592a00b4fc4b 100644 --- a/src/controller/java/gen/CHIPClusters-JNI.cpp +++ b/src/controller/java/gen/CHIPClusters-JNI.cpp @@ -3137,12 +3137,11 @@ class CHIPMediaPlaybackClusterMediaRewindResponseCallback jobject javaCallbackRef; }; -class CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback - : public Callback::Callback +class CHIPMediaPlaybackClusterMediaSeekResponseCallback : public Callback::Callback { public: - CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) + CHIPMediaPlaybackClusterMediaSeekResponseCallback(jobject javaCallback) : + Callback::Callback(CallbackFn, this) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); if (env == nullptr) @@ -3157,7 +3156,7 @@ class CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback ChipLogError(Zcl, "Could not create global reference for Java callback"); } } - ~CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback() + ~CHIPMediaPlaybackClusterMediaSeekResponseCallback() { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); if (env == nullptr) @@ -3175,11 +3174,11 @@ class CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); jobject javaCallbackRef; jmethodID javaMethod; - CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback * cppCallback = nullptr; + CHIPMediaPlaybackClusterMediaSeekResponseCallback * cppCallback = nullptr; VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); - cppCallback = reinterpret_cast(context); + cppCallback = reinterpret_cast(context); VerifyOrExit(cppCallback != nullptr, err = CHIP_JNI_ERROR_NULL_OBJECT); javaCallbackRef = cppCallback->javaCallbackRef; @@ -3206,12 +3205,12 @@ class CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback jobject javaCallbackRef; }; -class CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback - : public Callback::Callback +class CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback + : public Callback::Callback { public: - CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) + CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback(jobject javaCallback) : + Callback::Callback(CallbackFn, this) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); if (env == nullptr) @@ -3226,7 +3225,7 @@ class CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback ChipLogError(Zcl, "Could not create global reference for Java callback"); } } - ~CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback() + ~CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback() { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); if (env == nullptr) @@ -3244,11 +3243,11 @@ class CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); jobject javaCallbackRef; jmethodID javaMethod; - CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback * cppCallback = nullptr; + CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback * cppCallback = nullptr; VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); - cppCallback = reinterpret_cast(context); + cppCallback = reinterpret_cast(context); VerifyOrExit(cppCallback != nullptr, err = CHIP_JNI_ERROR_NULL_OBJECT); javaCallbackRef = cppCallback->javaCallbackRef; @@ -3275,12 +3274,12 @@ class CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback jobject javaCallbackRef; }; -class CHIPMediaPlaybackClusterMediaSkipSeekResponseCallback - : public Callback::Callback +class CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback + : public Callback::Callback { public: - CHIPMediaPlaybackClusterMediaSkipSeekResponseCallback(jobject javaCallback) : - Callback::Callback(CallbackFn, this) + CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback(jobject javaCallback) : + Callback::Callback(CallbackFn, this) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); if (env == nullptr) @@ -3295,7 +3294,7 @@ class CHIPMediaPlaybackClusterMediaSkipSeekResponseCallback ChipLogError(Zcl, "Could not create global reference for Java callback"); } } - ~CHIPMediaPlaybackClusterMediaSkipSeekResponseCallback() + ~CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback() { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); if (env == nullptr) @@ -3313,11 +3312,11 @@ class CHIPMediaPlaybackClusterMediaSkipSeekResponseCallback JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); jobject javaCallbackRef; jmethodID javaMethod; - CHIPMediaPlaybackClusterMediaSkipSeekResponseCallback * cppCallback = nullptr; + CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback * cppCallback = nullptr; VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); - cppCallback = reinterpret_cast(context); + cppCallback = reinterpret_cast(context); VerifyOrExit(cppCallback != nullptr, err = CHIP_JNI_ERROR_NULL_OBJECT); javaCallbackRef = cppCallback->javaCallbackRef; @@ -9228,25 +9227,24 @@ JNI_METHOD(void, MediaPlaybackCluster, mediaRewind)(JNIEnv * env, jobject self, env->CallVoidMethod(callback, method, exception); } } -JNI_METHOD(void, MediaPlaybackCluster, mediaSkipBackward) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jlong deltaPositionMilliseconds) +JNI_METHOD(void, MediaPlaybackCluster, mediaSeek)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jlong position) { StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); CHIP_ERROR err = CHIP_NO_ERROR; MediaPlaybackCluster * cppCluster; - CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback * onSuccess; + CHIPMediaPlaybackClusterMediaSeekResponseCallback * onSuccess; CHIPDefaultFailureCallback * onFailure; cppCluster = reinterpret_cast(clusterPtr); VerifyOrExit(cppCluster != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - onSuccess = new CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback(callback); + onSuccess = new CHIPMediaPlaybackClusterMediaSeekResponseCallback(callback); VerifyOrExit(onSuccess != nullptr, err = CHIP_ERROR_INCORRECT_STATE); onFailure = new CHIPDefaultFailureCallback(callback); VerifyOrExit(onFailure != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - err = cppCluster->MediaSkipBackward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds); + err = cppCluster->MediaSeek(onSuccess->Cancel(), onFailure->Cancel(), position); SuccessOrExit(err); exit: @@ -9274,25 +9272,25 @@ JNI_METHOD(void, MediaPlaybackCluster, mediaSkipBackward) env->CallVoidMethod(callback, method, exception); } } -JNI_METHOD(void, MediaPlaybackCluster, mediaSkipForward) +JNI_METHOD(void, MediaPlaybackCluster, mediaSkipBackward) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jlong deltaPositionMilliseconds) { StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); CHIP_ERROR err = CHIP_NO_ERROR; MediaPlaybackCluster * cppCluster; - CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback * onSuccess; + CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback * onSuccess; CHIPDefaultFailureCallback * onFailure; cppCluster = reinterpret_cast(clusterPtr); VerifyOrExit(cppCluster != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - onSuccess = new CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback(callback); + onSuccess = new CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallback(callback); VerifyOrExit(onSuccess != nullptr, err = CHIP_ERROR_INCORRECT_STATE); onFailure = new CHIPDefaultFailureCallback(callback); VerifyOrExit(onFailure != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - err = cppCluster->MediaSkipForward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds); + err = cppCluster->MediaSkipBackward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds); SuccessOrExit(err); exit: @@ -9320,25 +9318,25 @@ JNI_METHOD(void, MediaPlaybackCluster, mediaSkipForward) env->CallVoidMethod(callback, method, exception); } } -JNI_METHOD(void, MediaPlaybackCluster, mediaSkipSeek) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jlong position) +JNI_METHOD(void, MediaPlaybackCluster, mediaSkipForward) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jlong deltaPositionMilliseconds) { StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); CHIP_ERROR err = CHIP_NO_ERROR; MediaPlaybackCluster * cppCluster; - CHIPMediaPlaybackClusterMediaSkipSeekResponseCallback * onSuccess; + CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback * onSuccess; CHIPDefaultFailureCallback * onFailure; cppCluster = reinterpret_cast(clusterPtr); VerifyOrExit(cppCluster != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - onSuccess = new CHIPMediaPlaybackClusterMediaSkipSeekResponseCallback(callback); + onSuccess = new CHIPMediaPlaybackClusterMediaSkipForwardResponseCallback(callback); VerifyOrExit(onSuccess != nullptr, err = CHIP_ERROR_INCORRECT_STATE); onFailure = new CHIPDefaultFailureCallback(callback); VerifyOrExit(onFailure != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - err = cppCluster->MediaSkipSeek(onSuccess->Cancel(), onFailure->Cancel(), position); + err = cppCluster->MediaSkipForward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds); SuccessOrExit(err); exit: diff --git a/src/controller/java/gen/ChipClusters.java b/src/controller/java/gen/ChipClusters.java index 96e1723ca466f5..fd573f3c4bb71b 100644 --- a/src/controller/java/gen/ChipClusters.java +++ b/src/controller/java/gen/ChipClusters.java @@ -1459,6 +1459,10 @@ public void mediaRewind(MediaRewindResponseCallback callback) { mediaRewind(chipClusterPtr, callback); } + public void mediaSeek(MediaSeekResponseCallback callback, long position) { + mediaSeek(chipClusterPtr, callback, position); + } + public void mediaSkipBackward( MediaSkipBackwardResponseCallback callback, long deltaPositionMilliseconds) { mediaSkipBackward(chipClusterPtr, callback, deltaPositionMilliseconds); @@ -1469,10 +1473,6 @@ public void mediaSkipForward( mediaSkipForward(chipClusterPtr, callback, deltaPositionMilliseconds); } - public void mediaSkipSeek(MediaSkipSeekResponseCallback callback, long position) { - mediaSkipSeek(chipClusterPtr, callback, position); - } - public void mediaStartOver(MediaStartOverResponseCallback callback) { mediaStartOver(chipClusterPtr, callback); } @@ -1494,6 +1494,9 @@ private native void mediaFastForward( private native void mediaRewind(long chipClusterPtr, MediaRewindResponseCallback callback); + private native void mediaSeek( + long chipClusterPtr, MediaSeekResponseCallback callback, long position); + private native void mediaSkipBackward( long chipClusterPtr, MediaSkipBackwardResponseCallback callback, @@ -1504,9 +1507,6 @@ private native void mediaSkipForward( MediaSkipForwardResponseCallback callback, long deltaPositionMilliseconds); - private native void mediaSkipSeek( - long chipClusterPtr, MediaSkipSeekResponseCallback callback, long position); - private native void mediaStartOver( long chipClusterPtr, MediaStartOverResponseCallback callback); @@ -1548,19 +1548,19 @@ public interface MediaRewindResponseCallback { void onError(Exception error); } - public interface MediaSkipBackwardResponseCallback { + public interface MediaSeekResponseCallback { void onSuccess(int mediaPlaybackStatus); void onError(Exception error); } - public interface MediaSkipForwardResponseCallback { + public interface MediaSkipBackwardResponseCallback { void onSuccess(int mediaPlaybackStatus); void onError(Exception error); } - public interface MediaSkipSeekResponseCallback { + public interface MediaSkipForwardResponseCallback { void onSuccess(int mediaPlaybackStatus); void onError(Exception error); diff --git a/src/controller/python/chip/clusters/CHIPClusters.cpp b/src/controller/python/chip/clusters/CHIPClusters.cpp index 6061073508e780..1a970de024d9c8 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.cpp +++ b/src/controller/python/chip/clusters/CHIPClusters.cpp @@ -432,13 +432,13 @@ CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_CatalogVendorId(chip::Control return cluster.ReadAttributeCatalogVendorId(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); } -CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_ApplicationSatus(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, chip::GroupId /* ZCLgroupId */) +CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_ApplicationStatus(chip::Controller::Device * device, + chip::EndpointId ZCLendpointId, chip::GroupId /* ZCLgroupId */) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::ApplicationBasicCluster cluster; cluster.Associate(device, ZCLendpointId); - return cluster.ReadAttributeApplicationSatus(gInt8uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); + return cluster.ReadAttributeApplicationStatus(gInt8uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel()); } CHIP_ERROR chip_ime_ReadAttribute_ApplicationBasic_ClusterRevision(chip::Controller::Device * device, @@ -2924,6 +2924,14 @@ CHIP_ERROR chip_ime_AppendCommand_MediaPlayback_MediaRewind(chip::Controller::De cluster.Associate(device, ZCLendpointId); return cluster.MediaRewind(nullptr, nullptr); } +CHIP_ERROR chip_ime_AppendCommand_MediaPlayback_MediaSeek(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, + chip::GroupId, uint64_t position) +{ + VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + chip::Controller::MediaPlaybackCluster cluster; + cluster.Associate(device, ZCLendpointId); + return cluster.MediaSeek(nullptr, nullptr, position); +} CHIP_ERROR chip_ime_AppendCommand_MediaPlayback_MediaSkipBackward(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId, uint64_t deltaPositionMilliseconds) { @@ -2940,14 +2948,6 @@ CHIP_ERROR chip_ime_AppendCommand_MediaPlayback_MediaSkipForward(chip::Controlle cluster.Associate(device, ZCLendpointId); return cluster.MediaSkipForward(nullptr, nullptr, deltaPositionMilliseconds); } -CHIP_ERROR chip_ime_AppendCommand_MediaPlayback_MediaSkipSeek(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, - chip::GroupId, uint64_t position) -{ - VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - chip::Controller::MediaPlaybackCluster cluster; - cluster.Associate(device, ZCLendpointId); - return cluster.MediaSkipSeek(nullptr, nullptr, position); -} CHIP_ERROR chip_ime_AppendCommand_MediaPlayback_MediaStartOver(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId) { diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 82ad2f08492748..babaf37fa4878e 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -437,15 +437,15 @@ def ListClusterCommands(self): }, "MediaRewind": { }, + "MediaSeek": { + "position": "int", + }, "MediaSkipBackward": { "deltaPositionMilliseconds": "int", }, "MediaSkipForward": { "deltaPositionMilliseconds": "int", }, - "MediaSkipSeek": { - "position": "int", - }, "MediaStartOver": { }, "MediaStop": { @@ -718,7 +718,7 @@ def ListClusterAttributes(self): "attributeId": 0x0006, "type": "int", }, - "ApplicationSatus": { + "ApplicationStatus": { "attributeId": 0x0007, "type": "int", }, @@ -2549,6 +2549,10 @@ def ClusterMediaPlayback_CommandMediaRewind(self, device: ctypes.c_void_p, ZCLen return self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaRewind( device, ZCLendpoint, ZCLgroupid ) + def ClusterMediaPlayback_CommandMediaSeek(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, position: int): + return self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSeek( + device, ZCLendpoint, ZCLgroupid, position + ) def ClusterMediaPlayback_CommandMediaSkipBackward(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, deltaPositionMilliseconds: int): return self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipBackward( device, ZCLendpoint, ZCLgroupid, deltaPositionMilliseconds @@ -2557,10 +2561,6 @@ def ClusterMediaPlayback_CommandMediaSkipForward(self, device: ctypes.c_void_p, return self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipForward( device, ZCLendpoint, ZCLgroupid, deltaPositionMilliseconds ) - def ClusterMediaPlayback_CommandMediaSkipSeek(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, position: int): - return self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipSeek( - device, ZCLendpoint, ZCLgroupid, position - ) def ClusterMediaPlayback_CommandMediaStartOver(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaStartOver( device, ZCLendpoint, ZCLgroupid @@ -2799,8 +2799,8 @@ def ClusterApplicationBasic_ReadAttributeApplicationId(self, device: ctypes.c_vo return self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationId(device, ZCLendpoint, ZCLgroupid) def ClusterApplicationBasic_ReadAttributeCatalogVendorId(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_CatalogVendorId(device, ZCLendpoint, ZCLgroupid) - def ClusterApplicationBasic_ReadAttributeApplicationSatus(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationSatus(device, ZCLendpoint, ZCLgroupid) + def ClusterApplicationBasic_ReadAttributeApplicationStatus(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): + return self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationStatus(device, ZCLendpoint, ZCLgroupid) def ClusterApplicationBasic_ReadAttributeClusterRevision(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ClusterRevision(device, ZCLendpoint, ZCLgroupid) def ClusterApplicationLauncher_ReadAttributeApplicationLauncherList(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): @@ -3630,9 +3630,9 @@ def InitLib(self, chipLib): # Cluster ApplicationBasic ReadAttribute CatalogVendorId self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_CatalogVendorId.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_CatalogVendorId.restype = ctypes.c_uint32 - # Cluster ApplicationBasic ReadAttribute ApplicationSatus - self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationSatus.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationSatus.restype = ctypes.c_uint32 + # Cluster ApplicationBasic ReadAttribute ApplicationStatus + self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationStatus.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] + self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ApplicationStatus.restype = ctypes.c_uint32 # Cluster ApplicationBasic ReadAttribute ClusterRevision self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_ReadAttribute_ApplicationBasic_ClusterRevision.restype = ctypes.c_uint32 @@ -4454,15 +4454,15 @@ def InitLib(self, chipLib): # Cluster MediaPlayback Command MediaRewind self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaRewind.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaRewind.restype = ctypes.c_uint32 + # Cluster MediaPlayback Command MediaSeek + self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSeek.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint64] + self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSeek.restype = ctypes.c_uint32 # Cluster MediaPlayback Command MediaSkipBackward self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipBackward.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint64] self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipBackward.restype = ctypes.c_uint32 # Cluster MediaPlayback Command MediaSkipForward self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipForward.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint64] self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipForward.restype = ctypes.c_uint32 - # Cluster MediaPlayback Command MediaSkipSeek - self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipSeek.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint64] - self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaSkipSeek.restype = ctypes.c_uint32 # Cluster MediaPlayback Command MediaStartOver self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaStartOver.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_AppendCommand_MediaPlayback_MediaStartOver.restype = ctypes.c_uint32 diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h index f30ba7a1a511c5..e74e9ab2539740 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h @@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)readAttributeProductIdWithResponseHandler:(ResponseHandler)responseHandler; - (void)readAttributeApplicationIdWithResponseHandler:(ResponseHandler)responseHandler; - (void)readAttributeCatalogVendorIdWithResponseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeApplicationSatusWithResponseHandler:(ResponseHandler)responseHandler; +- (void)readAttributeApplicationStatusWithResponseHandler:(ResponseHandler)responseHandler; - (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler; @end @@ -743,9 +743,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)mediaPlay:(ResponseHandler)responseHandler; - (void)mediaPrevious:(ResponseHandler)responseHandler; - (void)mediaRewind:(ResponseHandler)responseHandler; +- (void)mediaSeek:(uint64_t)position responseHandler:(ResponseHandler)responseHandler; - (void)mediaSkipBackward:(uint64_t)deltaPositionMilliseconds responseHandler:(ResponseHandler)responseHandler; - (void)mediaSkipForward:(uint64_t)deltaPositionMilliseconds responseHandler:(ResponseHandler)responseHandler; -- (void)mediaSkipSeek:(uint64_t)position responseHandler:(ResponseHandler)responseHandler; - (void)mediaStartOver:(ResponseHandler)responseHandler; - (void)mediaStop:(ResponseHandler)responseHandler; diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index 227f21df0b2307..96d1823b7f924f 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -1753,22 +1753,22 @@ static void CallbackFn(void * context, uint8_t mediaPlaybackStatus) dispatch_queue_t mQueue; }; -class CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge - : public Callback::Callback { +class CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge + : public Callback::Callback { public: - CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) , mHandler(handler) , mQueue(queue) { } - ~CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge() {}; + ~CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge() {}; static void CallbackFn(void * context, uint8_t mediaPlaybackStatus) { - CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge * callback - = reinterpret_cast(context); + CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge * callback + = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ callback->mHandler(nil, @ { @@ -1785,22 +1785,22 @@ static void CallbackFn(void * context, uint8_t mediaPlaybackStatus) dispatch_queue_t mQueue; }; -class CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge - : public Callback::Callback { +class CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge + : public Callback::Callback { public: - CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) , mHandler(handler) , mQueue(queue) { } - ~CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge() {}; + ~CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge() {}; static void CallbackFn(void * context, uint8_t mediaPlaybackStatus) { - CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge * callback - = reinterpret_cast(context); + CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge * callback + = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ callback->mHandler(nil, @ { @@ -1817,22 +1817,22 @@ static void CallbackFn(void * context, uint8_t mediaPlaybackStatus) dispatch_queue_t mQueue; }; -class CHIPMediaPlaybackClusterMediaSkipSeekResponseCallbackBridge - : public Callback::Callback { +class CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge + : public Callback::Callback { public: - CHIPMediaPlaybackClusterMediaSkipSeekResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) , mHandler(handler) , mQueue(queue) { } - ~CHIPMediaPlaybackClusterMediaSkipSeekResponseCallbackBridge() {}; + ~CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge() {}; static void CallbackFn(void * context, uint8_t mediaPlaybackStatus) { - CHIPMediaPlaybackClusterMediaSkipSeekResponseCallbackBridge * callback - = reinterpret_cast(context); + CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge * callback + = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ callback->mHandler(nil, @ { @@ -3935,7 +3935,7 @@ - (void)readAttributeCatalogVendorIdWithResponseHandler:(ResponseHandler)respons } } -- (void)readAttributeApplicationSatusWithResponseHandler:(ResponseHandler)responseHandler +- (void)readAttributeApplicationStatusWithResponseHandler:(ResponseHandler)responseHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]); if (!onSuccess) { @@ -3952,7 +3952,7 @@ - (void)readAttributeApplicationSatusWithResponseHandler:(ResponseHandler)respon __block CHIP_ERROR err; dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel()); + err = self.cppCluster.ReadAttributeApplicationStatus(onSuccess->Cancel(), onFailure->Cancel()); }); if (err != CHIP_NO_ERROR) { @@ -11849,10 +11849,10 @@ - (void)mediaRewind:(ResponseHandler)responseHandler responseHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)mediaSkipBackward:(uint64_t)deltaPositionMilliseconds responseHandler:(ResponseHandler)responseHandler +- (void)mediaSeek:(uint64_t)position responseHandler:(ResponseHandler)responseHandler { - CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge * onSuccess - = new CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge(responseHandler, [self callbackQueue]); + CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge * onSuccess + = new CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge(responseHandler, [self callbackQueue]); if (!onSuccess) { responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -11867,7 +11867,7 @@ - (void)mediaSkipBackward:(uint64_t)deltaPositionMilliseconds responseHandler:(R __block CHIP_ERROR err; dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.MediaSkipBackward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds); + err = self.cppCluster.MediaSeek(onSuccess->Cancel(), onFailure->Cancel(), position); }); if (err != CHIP_NO_ERROR) { @@ -11876,10 +11876,10 @@ - (void)mediaSkipBackward:(uint64_t)deltaPositionMilliseconds responseHandler:(R responseHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)mediaSkipForward:(uint64_t)deltaPositionMilliseconds responseHandler:(ResponseHandler)responseHandler +- (void)mediaSkipBackward:(uint64_t)deltaPositionMilliseconds responseHandler:(ResponseHandler)responseHandler { - CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge * onSuccess - = new CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge(responseHandler, [self callbackQueue]); + CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge * onSuccess + = new CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge(responseHandler, [self callbackQueue]); if (!onSuccess) { responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -11894,7 +11894,7 @@ - (void)mediaSkipForward:(uint64_t)deltaPositionMilliseconds responseHandler:(Re __block CHIP_ERROR err; dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.MediaSkipForward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds); + err = self.cppCluster.MediaSkipBackward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds); }); if (err != CHIP_NO_ERROR) { @@ -11903,10 +11903,10 @@ - (void)mediaSkipForward:(uint64_t)deltaPositionMilliseconds responseHandler:(Re responseHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)mediaSkipSeek:(uint64_t)position responseHandler:(ResponseHandler)responseHandler +- (void)mediaSkipForward:(uint64_t)deltaPositionMilliseconds responseHandler:(ResponseHandler)responseHandler { - CHIPMediaPlaybackClusterMediaSkipSeekResponseCallbackBridge * onSuccess - = new CHIPMediaPlaybackClusterMediaSkipSeekResponseCallbackBridge(responseHandler, [self callbackQueue]); + CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge * onSuccess + = new CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge(responseHandler, [self callbackQueue]); if (!onSuccess) { responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -11921,7 +11921,7 @@ - (void)mediaSkipSeek:(uint64_t)position responseHandler:(ResponseHandler)respon __block CHIP_ERROR err; dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.MediaSkipSeek(onSuccess->Cancel(), onFailure->Cancel(), position); + err = self.cppCluster.MediaSkipForward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds); }); if (err != CHIP_NO_ERROR) { diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 10348d2f72c20d..1ba4acf294b9eb 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -3072,18 +3072,18 @@ - (void)testSendClusterApplicationBasicReadAttributeCatalogVendorIdWithResponseH [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterApplicationBasicReadAttributeApplicationSatusWithResponseHandler +- (void)testSendClusterApplicationBasicReadAttributeApplicationStatusWithResponseHandler { XCTestExpectation * expectation = - [self expectationWithDescription:@"ApplicationBasicReadAttributeApplicationSatusWithResponseHandler"]; + [self expectationWithDescription:@"ApplicationBasicReadAttributeApplicationStatusWithResponseHandler"]; CHIPDevice * device = GetPairedDevice(kDeviceId); dispatch_queue_t queue = dispatch_get_main_queue(); CHIPApplicationBasic * cluster = [[CHIPApplicationBasic alloc] initWithDevice:device endpoint:1 queue:queue]; XCTAssertNotNil(cluster); - [cluster readAttributeApplicationSatusWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ApplicationBasic ApplicationSatus Error: %@", err); + [cluster readAttributeApplicationStatusWithResponseHandler:^(NSError * err, NSDictionary * values) { + NSLog(@"ApplicationBasic ApplicationStatus Error: %@", err); XCTAssertEqual(err.code, 0); [expectation fulfill]; }];