From 3773962d80d7c046e07e87f37ffd226d7613eb77 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 15 Feb 2023 14:55:06 -0500 Subject: [PATCH] Remove emberAfSendDefaultResponse. (#25080) * The various emberAfBasicClusterMfgSpecificPingCallback functions in examples all had the wrong signature, so wouldn't be called even if those examples enabled that non-standard command. Which the examples don't. * scenes-client.h/cpp was dead code, and not really fixable to work with Matter: the behavior expected of clients is very different from ZCL, and the code in this file would be replaced by a mix of TLV decoding of the ViewScene response and bits in CommandSender that already exist. * The declaration of emberAfGetCommandApsFrame that is being removed does not have a corresponding implementation, so it was just dead and misleading code. --- .../ameba/main/DeviceCallbacks.cpp | 6 - .../cc13x2x7_26x2x7/main/ZclCallbacks.cpp | 6 - .../esp32/main/DeviceCallbacks.cpp | 6 - .../all-clusters-app/linux/main-common.cpp | 6 - .../ameba/main/DeviceCallbacks.cpp | 6 - .../cc13x2x7_26x2x7/main/ZclCallbacks.cpp | 6 - .../esp32/main/DeviceCallbacks.cpp | 6 - .../linux/main-common.cpp | 6 - examples/chef/ameba/main/DeviceCallbacks.cpp | 6 - .../ameba/main/DeviceCallbacks.cpp | 6 - .../ameba/main/DeviceCallbacks.cpp | 6 - examples/thermostat/linux/main.cpp | 6 - examples/tv-app/linux/main.cpp | 6 - .../clusters/scenes-client/scenes-client.cpp | 141 ------------------ .../clusters/scenes-client/scenes-client.h | 30 ---- src/app/util/af.h | 18 --- .../util/ember-compatibility-functions.cpp | 15 -- src/app/util/ember-compatibility-functions.h | 1 - src/app/util/util.cpp | 17 --- 19 files changed, 300 deletions(-) delete mode 100644 src/app/clusters/scenes-client/scenes-client.cpp delete mode 100644 src/app/clusters/scenes-client/scenes-client.h diff --git a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp index fab4ba499df2ce..1a7a256bb144f4 100644 --- a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp @@ -176,9 +176,3 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI exit: return; } - -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp b/examples/all-clusters-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp index 5a78ce84982c40..ba3f7bd1c205f8 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp @@ -81,9 +81,3 @@ void emberAfOnOffClusterInitCallback(EndpointId endpoint) { // TODO: implement any additional Cluster Server init actions } - -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index 60ec91f2b38fc6..277cdb28cacbf6 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -205,12 +205,6 @@ void AppDeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpoi } } -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} - void AppDeviceCallbacksDelegate::OnIPv4ConnectivityEstablished() { wifiLED.Set(true); diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index 702c33a9e122b2..b4724ad6f7cb45 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -62,12 +62,6 @@ chip::app::Clusters::WindowCovering::WindowCoveringManager sWindowCoveringManage } // namespace -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} - void OnIdentifyStart(::Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); diff --git a/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp index e53adc0c793f25..93092cf59a7a54 100644 --- a/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp @@ -149,9 +149,3 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI exit: return; } - -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp index 5a78ce84982c40..ba3f7bd1c205f8 100644 --- a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp +++ b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp @@ -81,9 +81,3 @@ void emberAfOnOffClusterInitCallback(EndpointId endpoint) { // TODO: implement any additional Cluster Server init actions } - -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp index 0e1d50952fa906..aed35e8f3950b8 100644 --- a/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp @@ -201,12 +201,6 @@ void AppDeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpoi } } -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} - void AppDeviceCallbacksDelegate::OnIPv4ConnectivityEstablished() { wifiLED.Set(true); diff --git a/examples/all-clusters-minimal-app/linux/main-common.cpp b/examples/all-clusters-minimal-app/linux/main-common.cpp index 0b431136ed0d1d..43c98dd207f7d9 100644 --- a/examples/all-clusters-minimal-app/linux/main-common.cpp +++ b/examples/all-clusters-minimal-app/linux/main-common.cpp @@ -42,12 +42,6 @@ namespace { static LowPowerManager lowPowerManager; } // namespace -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} - void OnIdentifyStart(::Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); diff --git a/examples/chef/ameba/main/DeviceCallbacks.cpp b/examples/chef/ameba/main/DeviceCallbacks.cpp index 0ef956fe939e11..23030fead6f986 100644 --- a/examples/chef/ameba/main/DeviceCallbacks.cpp +++ b/examples/chef/ameba/main/DeviceCallbacks.cpp @@ -172,9 +172,3 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI exit: return; } - -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp b/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp index b0ffa52dbe050c..4add42b4132550 100644 --- a/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp @@ -165,9 +165,3 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI exit: return; } - -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp index 0ef956fe939e11..23030fead6f986 100644 --- a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp @@ -172,9 +172,3 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI exit: return; } - -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/examples/thermostat/linux/main.cpp b/examples/thermostat/linux/main.cpp index 1816ec7bb9be9f..16b6dadec9e175 100644 --- a/examples/thermostat/linux/main.cpp +++ b/examples/thermostat/linux/main.cpp @@ -36,12 +36,6 @@ Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0, &s } // namespace #endif -bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} - void OnIdentifyStart(Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); diff --git a/examples/tv-app/linux/main.cpp b/examples/tv-app/linux/main.cpp index eec6a8054887b8..31d15a41a8421e 100644 --- a/examples/tv-app/linux/main.cpp +++ b/examples/tv-app/linux/main.cpp @@ -50,12 +50,6 @@ using namespace chip::DeviceLayer; using namespace chip::AppPlatform; using namespace chip::app::Clusters; -bool emberAfBasicClusterMfgSpecificPingCallback(app::CommandHandler * commandObj) -{ - emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); - return true; -} - namespace { static AccountLoginManager accountLoginManager; static ApplicationBasicManager applicationBasicManager; diff --git a/src/app/clusters/scenes-client/scenes-client.cpp b/src/app/clusters/scenes-client/scenes-client.cpp deleted file mode 100644 index 899bdd148b247a..00000000000000 --- a/src/app/clusters/scenes-client/scenes-client.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/** - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "scenes-client.h" -#include -#include - -#include - -using namespace chip; -using namespace chip::app::Clusters::Scenes::Commands; - -bool emberAfScenesClusterAddSceneResponseCallback(app::CommandHandler * commandObj, uint8_t status, GroupId groupId, - uint8_t sceneId) -{ - return emberAfPluginScenesClientParseAddSceneResponse(emberAfCurrentCommand(), status, groupId, sceneId); -} - -bool emberAfScenesClusterViewSceneResponseCallback(app::CommandHandler * commandObj, uint8_t status, GroupId groupId, - uint8_t sceneId, uint16_t transitionTime, uint8_t * sceneName, - uint8_t * extensionFieldSets) -{ - return emberAfPluginScenesClientParseViewSceneResponse(emberAfCurrentCommand(), status, groupId, sceneId, transitionTime, - sceneName, extensionFieldSets); -} - -bool emberAfScenesClusterRemoveSceneResponseCallback(app::CommandHandler * commandObj, uint8_t status, GroupId groupId, - uint8_t sceneId) -{ - emberAfScenesClusterPrintln("RX: RemoveSceneResponse 0x%x, 0x%2x, 0x%x", status, groupId, sceneId); - commandObj->AddStatus(commandPath, Status::Success); - return true; -} - -bool emberAfScenesClusterRemoveAllScenesResponseCallback(app::CommandHandler * commandObj, uint8_t status, GroupId groupId) -{ - emberAfScenesClusterPrintln("RX: RemoveAllScenesResponse 0x%x, 0x%2x", status, groupId); - commandObj->AddStatus(commandPath, Status::Success); - return true; -} - -bool emberAfScenesClusterStoreSceneResponseCallback(app::CommandHandler * commandObj, uint8_t status, GroupId groupId, - uint8_t sceneId) -{ - emberAfScenesClusterPrintln("RX: StoreSceneResponse 0x%x, 0x%2x, 0x%x", status, groupId, sceneId); - commandObj->AddStatus(commandPath, Status::Success); - return true; -} - -bool emberAfScenesClusterGetSceneMembershipResponseCallback(app::CommandHandler * commandObj, uint8_t status, uint8_t capacity, - GroupId groupId, uint8_t sceneCount, uint8_t * sceneList) -{ - emberAfScenesClusterPrint("RX: GetSceneMembershipResponse 0x%x, 0x%x, 0x%2x", status, capacity, groupId); - - // Scene count and the scene list only appear in the payload if the status is - // SUCCESS. - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - uint8_t i; - emberAfScenesClusterPrint(", 0x%x,", sceneCount); - for (i = 0; i < sceneCount; i++) - { - emberAfScenesClusterPrint(" [0x%x]", sceneList[i]); - } - } - - emberAfScenesClusterPrintln("%s", ""); - commandObj->AddStatus(commandPath, Status::Success); - return true; -} - -bool emberAfPluginScenesClientParseAddSceneResponse(const EmberAfClusterCommand * cmd, uint8_t status, GroupId groupId, - uint8_t sceneId) -{ - bool enhanced = (cmd->commandId == EnhancedAddScene::Id); - emberAfScenesClusterPrintln("RX: %pAddSceneResponse 0x%x, 0x%2x, 0x%x", (enhanced ? "Enhanced" : ""), status, groupId, sceneId); - emberAfSendDefaultResponse(cmd, EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfPluginScenesClientParseViewSceneResponse(const EmberAfClusterCommand * cmd, uint8_t status, GroupId groupId, - uint8_t sceneId, uint16_t transitionTime, const uint8_t * sceneName, - const uint8_t * extensionFieldSets) -{ - bool enhanced = (cmd->commandId == EnhancedViewScene::Id); - - emberAfScenesClusterPrint("RX: %pViewSceneResponse 0x%x, 0x%2x, 0x%x", (enhanced ? "Enhanced" : ""), status, groupId, sceneId); - - // Transition time, scene name, and the extension field sets only appear in - // the payload if the status is SUCCESS. - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - uint16_t extensionFieldSetsLen = - static_cast(emberAfCurrentCommand()->bufLen - - (emberAfCurrentCommand()->payloadStartIndex + sizeof(status) + sizeof(groupId) + sizeof(sceneId) + - sizeof(transitionTime) + emberAfStringLength(sceneName) + 1)); - uint16_t extensionFieldSetsIndex = 0; - - emberAfScenesClusterPrint(", 0x%2x, \"", transitionTime); - emberAfScenesClusterPrintString(sceneName); - emberAfScenesClusterPrint("\","); - - // Each extension field set contains at least a two-byte cluster id and a - // one-byte length. - while (extensionFieldSetsIndex + 3 <= extensionFieldSetsLen) - { - ClusterId clusterId; - uint8_t length; - clusterId = emberAfGetInt16u(extensionFieldSets, extensionFieldSetsIndex, extensionFieldSetsLen); - extensionFieldSetsIndex = static_cast(extensionFieldSetsIndex + 2); - length = emberAfGetInt8u(extensionFieldSets, extensionFieldSetsIndex, extensionFieldSetsLen); - extensionFieldSetsIndex++; - emberAfScenesClusterPrint(" [0x%2x 0x%x ", clusterId, length); - if (extensionFieldSetsIndex + length <= extensionFieldSetsLen) - { - emberAfScenesClusterPrintBuffer(extensionFieldSets + extensionFieldSetsIndex, length, false); - } - emberAfScenesClusterPrint("]"); - emberAfScenesClusterFlush(); - extensionFieldSetsIndex = static_cast(extensionFieldSetsIndex + length); - } - } - - emberAfScenesClusterPrintln("%s", ""); - emberAfSendDefaultResponse(cmd, EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/src/app/clusters/scenes-client/scenes-client.h b/src/app/clusters/scenes-client/scenes-client.h deleted file mode 100644 index c5ea3b916685df..00000000000000 --- a/src/app/clusters/scenes-client/scenes-client.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include - -#include - -bool emberAfPluginScenesClientParseAddSceneResponse(const EmberAfClusterCommand * cmd, uint8_t status, chip::GroupId groupId, - uint8_t sceneId); - -bool emberAfPluginScenesClientParseViewSceneResponse(const EmberAfClusterCommand * cmd, uint8_t status, chip::GroupId groupId, - uint8_t sceneId, uint16_t transitionTime, const uint8_t * sceneName, - const uint8_t * extensionFieldSets); diff --git a/src/app/util/af.h b/src/app/util/af.h index 24b5d423e1916d..ce28d9f2246b03 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -502,24 +502,6 @@ EmberStatus emberEventControlSetDelayMS(EmberEventControl * control, uint32_t de /** @name Messaging */ // @{ -/** - * @brief Sends a default response to a cluster command. - * - * This function is used to prepare and send a default response to a cluster - * command. - * - * @param cmd The cluster command to which to respond. - * @param status Status code for the default response command. - * @return An ::EmberStatus value that indicates the success or failure of - * sending the response. - */ -EmberStatus emberAfSendDefaultResponse(const EmberAfClusterCommand * cmd, EmberAfStatus status); - -/** - * @brief Access to client API APS frame. - */ -EmberApsFrame * emberAfGetCommandApsFrame(void); - /** * @brief Set the source and destination endpoints in the client API APS frame. */ diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index ff9bff7a2ddc38..dc0f0703eb47e5 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -174,21 +174,6 @@ void SetupEmberAfCommandHandler(CommandHandler * command, const ConcreteCommandP currentCommandObject = command; } -bool IMEmberAfSendDefaultResponseWithCallback(EmberAfStatus status) -{ - if (currentCommandObject == nullptr) - { - // We have no idea what we're supposed to respond to. - return false; - } - - chip::app::ConcreteCommandPath commandPath(imCompatibilityEmberApsFrame.destinationEndpoint, - imCompatibilityEmberApsFrame.clusterId, imCompatibilityEmberAfCluster.commandId); - - CHIP_ERROR err = currentCommandObject->AddStatus(commandPath, ToInteractionModelStatus(status)); - return CHIP_NO_ERROR == err; -} - void ResetEmberAfObjects() { emAfCurrentCommand = nullptr; diff --git a/src/app/util/ember-compatibility-functions.h b/src/app/util/ember-compatibility-functions.h index 437a5c057f6c6d..493936aebae466 100644 --- a/src/app/util/ember-compatibility-functions.h +++ b/src/app/util/ember-compatibility-functions.h @@ -33,7 +33,6 @@ namespace app { namespace Compatibility { void SetupEmberAfCommandHandler(CommandHandler * command, const ConcreteCommandPath & commandPath); -bool IMEmberAfSendDefaultResponseWithCallback(EmberAfStatus status); void ResetEmberAfObjects(); } // namespace Compatibility diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index f61d492ff4a089..8156e123cf161d 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -334,23 +334,6 @@ void emAfApplyDisableDefaultResponse(uint8_t * frame_control) } } -EmberStatus emberAfSendDefaultResponse(const EmberAfClusterCommand * cmd, EmberAfStatus status) -{ - // Default Response commands are only sent in response to unicast commands. - if (cmd->type != EMBER_INCOMING_UNICAST && cmd->type != EMBER_INCOMING_UNICAST_REPLY) - { - return EMBER_SUCCESS; - } - - if (!chip::app::Compatibility::IMEmberAfSendDefaultResponseWithCallback(status)) - { - // Caller is not responding to anything! - return EMBER_ERR_FATAL; - } - - return EMBER_SUCCESS; -} - void emberAfCopyInt16u(uint8_t * data, uint16_t index, uint16_t x) { data[index] = (uint8_t)(((x)) & 0xFF);