diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index 809b98c0b5e5d5..ca364740a9e9f2 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -81,8 +81,6 @@ target_sources(${APP_TARGET} PRIVATE ${APP_UTIL}/ember-print.cpp ${APP_UTIL}/ember-compatibility-functions.cpp ${APP_UTIL}/message.cpp - ${APP_UTIL}/process-cluster-message.cpp - ${APP_UTIL}/process-global-message.cpp ${APP_UTIL}/util.cpp ${APP_UTIL}/error-mapping.cpp diff --git a/examples/lighting-app/mbed/CMakeLists.txt b/examples/lighting-app/mbed/CMakeLists.txt index 5c90f5e4a644a3..f623512804b86a 100644 --- a/examples/lighting-app/mbed/CMakeLists.txt +++ b/examples/lighting-app/mbed/CMakeLists.txt @@ -65,8 +65,6 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/src/app/util/ember-print.cpp ${CHIP_ROOT}/src/app/util/error-mapping.cpp ${CHIP_ROOT}/src/app/util/message.cpp - ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp - ${CHIP_ROOT}/src/app/util/process-global-message.cpp ${CHIP_ROOT}/src/app/util/util.cpp ${CHIP_ROOT}/src/app/server/EchoHandler.cpp ${CHIP_ROOT}/src/app/server/Dnssd.cpp diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index 0dfdd67b0cf741..2261a2e2823421 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -65,8 +65,6 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/util/ember-print.cpp ${CHIP_ROOT}/src/app/util/error-mapping.cpp ${CHIP_ROOT}/src/app/util/message.cpp - ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp - ${CHIP_ROOT}/src/app/util/process-global-message.cpp ${CHIP_ROOT}/src/app/util/util.cpp ${CHIP_ROOT}/src/app/server/EchoHandler.cpp ${CHIP_ROOT}/src/app/server/Dnssd.cpp diff --git a/examples/lock-app/mbed/CMakeLists.txt b/examples/lock-app/mbed/CMakeLists.txt index a6821cdf28e0d0..49fa9d1c366efe 100644 --- a/examples/lock-app/mbed/CMakeLists.txt +++ b/examples/lock-app/mbed/CMakeLists.txt @@ -64,8 +64,6 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/src/app/util/ember-print.cpp ${CHIP_ROOT}/src/app/util/error-mapping.cpp ${CHIP_ROOT}/src/app/util/message.cpp - ${CHIP_ROOT}/src/app/util/process-cluster-message.cpp - ${CHIP_ROOT}/src/app/util/process-global-message.cpp ${CHIP_ROOT}/src/app/util/util.cpp ${CHIP_ROOT}/src/app/server/EchoHandler.cpp ${CHIP_ROOT}/src/app/server/Dnssd.cpp diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 4cdbe5d86e1dd3..c9a80289364a46 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -138,7 +138,6 @@ static_library("app") { "TimedRequest.h", "WriteClient.cpp", "WriteHandler.cpp", - "decoder.cpp", "encoder-common.cpp", "reporting/Engine.cpp", "reporting/Engine.h", diff --git a/src/app/chip-zcl-zpro-codec.h b/src/app/chip-zcl-zpro-codec.h index 2e09b80816dbee..9c25a339aff810 100644 --- a/src/app/chip-zcl-zpro-codec.h +++ b/src/app/chip-zcl-zpro-codec.h @@ -42,23 +42,6 @@ typedef struct uint8_t radius; } EmberApsFrame; -/** @brief Extracts an aps frame from buffer into outApsFrame - * @param buffer Buffer to read from - * @param buf_length Length of buffer - * @param outApsFrame Pointer to EmberApsFrame struct to read into - * @return returns the number of bytes that were consumed to read out the EmberApsFrame. 0 means an error was encountered - */ -uint16_t extractApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * outApsFrame); - -/** @brief Populates msg with address of the zcl message within buffer. - * @return Returns the length of msg buffer. Returns 0 on error e.g. if buffer is too short. - */ -uint16_t extractMessage(uint8_t * buffer, uint16_t buffer_length, uint8_t ** msg); - -/** @brief Prints an aps frame struct - */ -void printApsFrame(EmberApsFrame * frame); - /** * @brief Encode an APS frame into the given buffer. Returns the number of * bytes of buffer used by the encoding or 0 if the given buffer is not big diff --git a/src/app/chip_data_model.cmake b/src/app/chip_data_model.cmake index 663c27c142e6e1..9c6a71f6f5c716 100644 --- a/src/app/chip_data_model.cmake +++ b/src/app/chip_data_model.cmake @@ -93,8 +93,6 @@ function(chip_configure_data_model APP_TARGET) ${CHIP_APP_BASE_DIR}/util/ember-print.cpp ${CHIP_APP_BASE_DIR}/util/error-mapping.cpp ${CHIP_APP_BASE_DIR}/util/message.cpp - ${CHIP_APP_BASE_DIR}/util/process-cluster-message.cpp - ${CHIP_APP_BASE_DIR}/util/process-global-message.cpp ${CHIP_APP_BASE_DIR}/util/util.cpp ) endfunction() diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index c8134caba0f0f0..3ea9d09b684dfc 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -110,8 +110,6 @@ template("chip_data_model") { "${_app_root}/util/ember-print.cpp", "${_app_root}/util/error-mapping.cpp", "${_app_root}/util/message.cpp", - "${_app_root}/util/process-cluster-message.cpp", - "${_app_root}/util/process-global-message.cpp", "${_app_root}/util/util.cpp", "${chip_root}/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp", ] diff --git a/src/app/decoder.cpp b/src/app/decoder.cpp deleted file mode 100644 index 86de3ccd05a1d5..00000000000000 --- a/src/app/decoder.cpp +++ /dev/null @@ -1,85 +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. - */ - -// bool emberAfProcessMessage(EmberApsFrame *apsFrame, -// EmberIncomingMessageType type, -// uint8_t *message, -// uint16_t msgLen, -// EmberNodeId source, -// InterPanHeader *interPanHeader) - -#include "chip-zcl-zpro-codec.h" - -#include -#include -#include -#include -#include -#include - -uint16_t extractApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * outApsFrame) -{ - if (buffer == nullptr || buf_length == 0 || outApsFrame == nullptr) - { - ChipLogError(Zcl, "Error extracting APS frame. invalid inputs"); - return 0; - } - - chip::DataModelReader reader(buffer, buf_length); - - // Skip first byte, because that's the always-0 frame control. - uint8_t ignored; - const CHIP_ERROR err = reader.ReadOctet(&ignored) - .ReadClusterId(&outApsFrame->clusterId) - .ReadEndpointId(&outApsFrame->sourceEndpoint) - .ReadEndpointId(&outApsFrame->destinationEndpoint) - .Read16(&outApsFrame->options) - .ReadGroupId(&outApsFrame->groupId) - .ReadOctet(&outApsFrame->sequence) - .ReadOctet(&outApsFrame->radius) - .StatusCode(); - - return err == CHIP_NO_ERROR ? static_cast(reader.OctetsRead()) : 0; -} - -void printApsFrame(EmberApsFrame * frame) -{ - ChipLogProgress(Zcl, - "\n clusterID " ChipLogFormatMEI - ", sourceEndpoint %d, destinationEndPoint %d, options %d, groupID %d, " - "sequence %d, radius %d\n", - frame, ChipLogValueMEI(frame->clusterId), frame->sourceEndpoint, frame->destinationEndpoint, frame->options, - frame->groupId, frame->sequence, frame->radius); -} - -uint16_t extractMessage(uint8_t * buffer, uint16_t buffer_length, uint8_t ** msg) -{ - // The message starts after the EmberApsFrame. - uint16_t result = 0; - EmberApsFrame frame; - uint16_t apsFrameSize = extractApsFrame(buffer, buffer_length, &frame); - if (msg && apsFrameSize > 0) - { - *msg = buffer + apsFrameSize; - result = static_cast(buffer_length - apsFrameSize); - } - else if (msg) - { - *msg = nullptr; - } - return result; -} diff --git a/src/app/util/process-cluster-message.cpp b/src/app/util/process-cluster-message.cpp deleted file mode 100644 index 4032ec233681be..00000000000000 --- a/src/app/util/process-cluster-message.cpp +++ /dev/null @@ -1,102 +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. - */ - -/** - * - * Copyright (c) 2020 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 This file contains a function that processes - *cluster-specific ZCL message. - ******************************************************************************* - ******************************************************************************/ - -// this file contains all the common includes for clusters in the zcl-util -#include "app/util/common.h" - -// for pulling in defines dealing with EITHER server or client -#include - -#include - -// the EM260 host needs to include the config file -#ifdef EZSP_HOST -#include -#endif - -//------------------------------------------------------------------------------ - -bool emAfProcessClusterSpecificCommand(EmberAfClusterCommand * cmd) -{ - // if we are disabled then we can only respond to read or write commands - // or identify cluster (see device enabled attr of basic cluster) - if (!emberAfIsDeviceEnabled(cmd->apsFrame->destinationEndpoint) && cmd->apsFrame->clusterId != ZCL_IDENTIFY_CLUSTER_ID) - { - emberAfCorePrintln("%pd, dropping ep 0x%x clus " ChipLogFormatMEI " cmd " ChipLogFormatMEI, "disable", - cmd->apsFrame->destinationEndpoint, ChipLogValueMEI(cmd->apsFrame->clusterId), - ChipLogValueMEI(cmd->commandId)); - emberAfSendDefaultResponse(cmd, EMBER_ZCL_STATUS_FAILURE); - return true; - } - -#ifdef ZCL_USING_KEY_ESTABLISHMENT_CLUSTER_CLIENT - if (cmd->apsFrame->clusterId == ZCL_KEY_ESTABLISHMENT_CLUSTER_ID && cmd->direction == ZCL_DIRECTION_SERVER_TO_CLIENT && - emberAfKeyEstablishmentClusterClientCommandReceivedCallback(cmd)) - { - return true; - } -#endif -#ifdef ZCL_USING_KEY_ESTABLISHMENT_CLUSTER_SERVER - if (cmd->apsFrame->clusterId == ZCL_KEY_ESTABLISHMENT_CLUSTER_ID && cmd->direction == ZCL_DIRECTION_CLIENT_TO_SERVER && - emberAfKeyEstablishmentClusterServerCommandReceivedCallback(cmd)) - { - return true; - } -#endif - -#ifdef ZCL_USING_OTA_BOOTLOAD_CLUSTER_CLIENT - if (cmd->apsFrame->clusterId == ZCL_OTA_BOOTLOAD_CLUSTER_ID && cmd->direction == ZCL_DIRECTION_SERVER_TO_CLIENT && - emberAfOtaRequestorIncomingMessageRawCallback(cmd)) - { - return true; - } -#endif -#ifdef ZCL_USING_OTA_BOOTLOAD_CLUSTER_SERVER - if (cmd->apsFrame->clusterId == ZCL_OTA_BOOTLOAD_CLUSTER_ID && cmd->direction == ZCL_DIRECTION_CLIENT_TO_SERVER && - emberAfOtaProviderIncomingMessageRawCallback(cmd)) - { - return true; - } -#endif - - // All cluster messages (commands) will go through the IM now, return false to indicate an error. - return false; -} diff --git a/src/app/util/process-global-message.cpp b/src/app/util/process-global-message.cpp deleted file mode 100644 index 140d53c87200bb..00000000000000 --- a/src/app/util/process-global-message.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. - */ - -/** - * - * Copyright (c) 2020 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 This file contains function that processes - *global ZCL message. - ******************************************************************************* - ******************************************************************************/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef EMBER_AF_PLUGIN_COMMS_HUB_FUNCTION_SUB_GHZ -#include "app/framework/plugin/comms-hub-function-sub-ghz/comms-hub-function-sub-ghz.h" -#endif - -#include - -using namespace chip; - -bool emAfProcessGlobalCommand(EmberAfClusterCommand * cmd) -{ - uint8_t frameControl; - // This is a little clumsy but easier to read and port - // from earlier implementation. - ClusterId clusterId = cmd->apsFrame->clusterId; - CommandId zclCmd = cmd->commandId; - uint8_t * message = cmd->buffer; - uint16_t msgLen = cmd->bufLen; - uint16_t msgIndex = cmd->payloadStartIndex; - uint8_t clientServerMask = (cmd->direction == ZCL_DIRECTION_CLIENT_TO_SERVER ? CLUSTER_MASK_SERVER : CLUSTER_MASK_CLIENT); - - // If we are disabled then we can only respond to read or write commands - // or identify cluster (see device enabled attr of basic cluster) - // Since read and write is handled by interaction model, we only need to handle identify command. - if (!emberAfIsDeviceEnabled(cmd->apsFrame->destinationEndpoint) && - /* zclCmd != ZCL_READ_ATTRIBUTES_COMMAND_ID && - zclCmd != ZCL_WRITE_ATTRIBUTES_COMMAND_ID && zclCmd != ZCL_WRITE_ATTRIBUTES_UNDIVIDED_COMMAND_ID && - zclCmd != ZCL_WRITE_ATTRIBUTES_NO_RESPONSE_COMMAND_ID && */ - clusterId != ZCL_IDENTIFY_CLUSTER_ID) - { - emberAfCorePrintln("disabled"); - emberAfDebugPrintln("%pd, dropping global cmd:" ChipLogFormatMEI, "disable", ChipLogValueMEI(zclCmd)); - emberAfSendDefaultResponse(cmd, EMBER_ZCL_STATUS_FAILURE); - return true; - } - - // If a manufacturer-specific command arrives using our special internal "not - // manufacturer specific" code, we need to reject it outright without letting - // it pass through to the rest of the code. The internal read and write APIs - // would interpret it as a standard attribute or cluster and return incorrect - // results. - if (cmd->mfgSpecific && cmd->mfgCode == EMBER_AF_NULL_MANUFACTURER_CODE) - { - goto kickout; - } - - // Clear out the response buffer by setting its length to zero - appResponseLength = 0; - - // Make the ZCL header for the response - // note: cmd byte is set below - frameControl = static_cast(ZCL_GLOBAL_COMMAND | - (cmd->direction == ZCL_DIRECTION_CLIENT_TO_SERVER - ? ZCL_FRAME_CONTROL_SERVER_TO_CLIENT | EMBER_AF_DEFAULT_RESPONSE_POLICY_RESPONSES - : ZCL_FRAME_CONTROL_CLIENT_TO_SERVER | EMBER_AF_DEFAULT_RESPONSE_POLICY_RESPONSES)); - if (cmd->mfgSpecific) - { - frameControl |= ZCL_MANUFACTURER_SPECIFIC_MASK; - } - emberAfPutInt8uInResp(frameControl); - if (cmd->mfgSpecific) - { - emberAfPutInt16uInResp(cmd->mfgCode); - } - emberAfPutInt8uInResp(cmd->seqNum); - - switch (zclCmd) - { - // [command id:4] [status:1] - case ZCL_DEFAULT_RESPONSE_COMMAND_ID: { - EmberAfStatus status; - CommandId commandId; - commandId = emberAfGetInt32u(message, msgIndex, msgLen); - status = (EmberAfStatus) emberAfGetInt8u(message, msgIndex + 4, msgLen); - - emberAfClusterDefaultResponseWithMfgCodeCallback(cmd->apsFrame->destinationEndpoint, clusterId, commandId, status, - clientServerMask, cmd->mfgCode); - emberAfDefaultResponseCallback(clusterId, commandId, status); - return true; - } - - default: - // MISRA requires default case. - break; - } - -kickout: - emberAfSendDefaultResponse( - cmd, (cmd->mfgSpecific ? EMBER_ZCL_STATUS_UNSUP_MANUF_GENERAL_COMMAND : EMBER_ZCL_STATUS_UNSUP_GENERAL_COMMAND)); - return true; -} diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index c304e440be67b8..06add3f7ee01d4 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -91,12 +91,9 @@ const EmberAfClusterName zclClusterNames[] = { { ZCL_NULL_CLUSTER_ID, EMBER_AF_NULL_MANUFACTURER_CODE, NULL }, // terminator }; -static const EmberAfClusterCommand staticCmd = {}; -EmberAfClusterCommand curCmd; // A pointer to the current command being processed -// This struct is allocated on the stack inside -// emberAfProcessMessage. The pointer below is set -// to NULL when the function exits. +// This struct is allocated inside ember-compatibility-functions.cpp. +// The pointer below is set to NULL when not processing a command. EmberAfClusterCommand * emAfCurrentCommand; // A pointer to the global exchange manager @@ -109,10 +106,6 @@ uint8_t emberAfIncomingZclSequenceNumber = 0xFF; // not responses. uint8_t emberAfSequenceNumber = 0xFF; -// A bool value so we know when the device is performing -// key establishment. -bool emAfDeviceIsPerformingKeyEstablishment = false; - static uint8_t /*enum EmberAfRetryOverride*/ emberAfApsRetryOverride = EMBER_AF_RETRY_OVERRIDE_NONE; static uint8_t /*enum EmberAfDisableDefaultResponse*/ emAfDisableDefaultResponse = EMBER_AF_DISABLE_DEFAULT_RESPONSE_NONE; static uint8_t /*enum EmberAfDisableDefaultResponse*/ emAfSavedDisableDefaultResponseVale = EMBER_AF_DISABLE_DEFAULT_RESPONSE_NONE; @@ -399,184 +392,6 @@ uint16_t emberAfGetMfgCodeFromCurrentCommand(void) } } -static void printIncomingZclMessage(const EmberAfClusterCommand * cmd) -{ -#if defined(EMBER_AF_PRINT_ENABLE) && defined(EMBER_AF_PRINT_APP) - if (emberAfPrintReceivedMessages) - { - // emberAfAppPrint("\r\nT%4x:", emberAfGetCurrentTime()); - emberAfAppPrint("RX len %d, ep %x, clus " ChipLogFormatMEI " ", cmd->bufLen, cmd->apsFrame->destinationEndpoint, - ChipLogValueMEI(cmd->apsFrame->clusterId)); - emberAfAppDebugExec(emberAfDecodeAndPrintClusterWithMfgCode(cmd->apsFrame->clusterId, cmd->mfgCode)); - if (cmd->mfgSpecific) - { - emberAfAppPrint(" mfgId %2x", cmd->mfgCode); - } - emberAfAppPrint(" FC %x seq %x cmd " ChipLogFormatMEI " payload[", - cmd->buffer[0], // frame control - cmd->seqNum, ChipLogValueMEI(cmd->commandId)); - emberAfAppFlush(); - emberAfAppPrintBuffer(cmd->buffer + cmd->payloadStartIndex, // message - static_cast(cmd->bufLen - cmd->payloadStartIndex), // length - true); // spaces? - emberAfAppFlush(); - emberAfAppPrintln("]"); - } -#endif -} - -static bool dispatchZclMessage(EmberAfClusterCommand * cmd) -{ - uint16_t index = emberAfIndexFromEndpoint(cmd->apsFrame->destinationEndpoint); - - if (index == 0xFFFF) - { - emberAfDebugPrint("Drop cluster " ChipLogFormatMEI " command " ChipLogFormatMEI, ChipLogValueMEI(cmd->apsFrame->clusterId), - ChipLogValueMEI(cmd->commandId)); - emberAfDebugPrint(" due to invalid endpoint: "); - emberAfDebugPrintln("0x%x", cmd->apsFrame->destinationEndpoint); - return false; - } - else if (emberAfNetworkIndexFromEndpointIndex(index) != cmd->networkIndex) - { - emberAfDebugPrint("Drop cluster " ChipLogFormatMEI " command " ChipLogFormatMEI, ChipLogValueMEI(cmd->apsFrame->clusterId), - ChipLogValueMEI(cmd->commandId)); - emberAfDebugPrint(" for endpoint 0x%x due to wrong %s: ", cmd->apsFrame->destinationEndpoint, "network"); - emberAfDebugPrintln("%d", cmd->networkIndex); - return false; - } -#ifdef EMBER_AF_PLUGIN_GROUPS_SERVER - else if ((cmd->type == EMBER_INCOMING_MULTICAST || cmd->type == EMBER_INCOMING_MULTICAST_LOOPBACK) && - !emberAfGroupsClusterEndpointInGroupCallback(cmd->source->GetSessionHandle()->AsSecureSession()->GetFabricIndex(), - cmd->apsFrame->destinationEndpoint, cmd->apsFrame->groupId)) - { - emberAfDebugPrint("Drop cluster " ChipLogFormatMEI " command " ChipLogFormatMEI, ChipLogValueMEI(cmd->apsFrame->clusterId), - ChipLogValueMEI(cmd->commandId)); - emberAfDebugPrint(" for endpoint 0x%x due to wrong %s: ", cmd->apsFrame->destinationEndpoint, "group"); - emberAfDebugPrintln("0x%02x", cmd->apsFrame->groupId); - return false; - } -#endif // EMBER_AF_PLUGIN_GROUPS_SERVER - else - { - return (cmd->clusterSpecific ? emAfProcessClusterSpecificCommand(cmd) : emAfProcessGlobalCommand(cmd)); - } -} - -bool emberAfProcessMessageIntoZclCmd(EmberApsFrame * apsFrame, EmberIncomingMessageType type, uint8_t * message, - uint16_t messageLength, Messaging::ExchangeContext * exchange, InterPanHeader * interPanHeader, - EmberAfClusterCommand * returnCmd) -{ - uint8_t minLength = - (message[0] & ZCL_MANUFACTURER_SPECIFIC_MASK ? EMBER_AF_ZCL_MANUFACTURER_SPECIFIC_OVERHEAD : EMBER_AF_ZCL_OVERHEAD); - - if (messageLength < minLength) - { - emberAfAppPrintln("%pRX pkt too short: %d < %d", "ERROR: ", messageLength, minLength); - return false; - } - - // Populate the cluster command struct for processing. - returnCmd->apsFrame = apsFrame; - returnCmd->type = type; - returnCmd->source = exchange; - returnCmd->buffer = message; - returnCmd->bufLen = messageLength; - returnCmd->clusterSpecific = (message[0] & ZCL_CLUSTER_SPECIFIC_COMMAND); - returnCmd->mfgSpecific = (message[0] & ZCL_MANUFACTURER_SPECIFIC_MASK); - returnCmd->direction = - ((message[0] & ZCL_FRAME_CONTROL_DIRECTION_MASK) ? ZCL_DIRECTION_SERVER_TO_CLIENT : ZCL_DIRECTION_CLIENT_TO_SERVER); - returnCmd->payloadStartIndex = 1; - if (returnCmd->mfgSpecific) - { - returnCmd->mfgCode = emberAfGetInt16u(message, returnCmd->payloadStartIndex, messageLength); - returnCmd->payloadStartIndex = static_cast(returnCmd->payloadStartIndex + 2); - } - else - { - returnCmd->mfgCode = EMBER_AF_NULL_MANUFACTURER_CODE; - } - returnCmd->seqNum = message[returnCmd->payloadStartIndex++]; - returnCmd->commandId = emberAfGetInt32u(message, returnCmd->payloadStartIndex, returnCmd->bufLen); - returnCmd->payloadStartIndex = static_cast(returnCmd->payloadStartIndex + 4); - if (returnCmd->payloadStartIndex > returnCmd->bufLen) - { - emberAfAppPrintln("%pRX pkt malformed: %d < %d", "ERROR: ", returnCmd->bufLen, returnCmd->payloadStartIndex); - return false; - } - returnCmd->interPanHeader = interPanHeader; - // returnCmd->networkIndex = emberGetCurrentNetwork(); - return true; -} - -// a single call to process global and cluster-specific messages and callbacks. -bool emberAfProcessMessage(EmberApsFrame * apsFrame, EmberIncomingMessageType type, uint8_t * message, uint16_t msgLen, - Messaging::ExchangeContext * exchange, InterPanHeader * interPanHeader) -{ - bool msgHandled = false; - // reset/reinitialize curCmd - curCmd = staticCmd; - if (!emberAfProcessMessageIntoZclCmd(apsFrame, type, message, msgLen, exchange, interPanHeader, &curCmd)) - { - goto kickout; - } - - emAfCurrentCommand = &curCmd; - - // All of these should be covered by the EmberAfClusterCommand but are - // still here until all the code is moved over to use the cmd. -WEH - emberAfIncomingZclSequenceNumber = curCmd.seqNum; - - printIncomingZclMessage(&curCmd); - prepareForResponse(&curCmd); - - if (interPanHeader != NULL && !(interPanHeader->options & EMBER_AF_INTERPAN_OPTION_MAC_HAS_LONG_ADDRESS)) - { - // For safety, dump all interpan messages that don't have a long - // source in the MAC layer. In theory they should not get past - // the MAC filters but this is insures they will not get processed. - goto kickout; - } - - if (curCmd.apsFrame->destinationEndpoint == EMBER_BROADCAST_ENDPOINT) - { - uint8_t i; - for (i = 0; i < emberAfEndpointCount(); i++) - { - EndpointId endpoint = emberAfEndpointFromIndex(i); - if (!emberAfEndpointIndexIsEnabled(i) || - !emberAfContainsClusterWithMfgCode(endpoint, curCmd.apsFrame->clusterId, curCmd.mfgCode)) - { - continue; - } - // Since the APS frame is cleared after each sending, - // we must reinitialize it. It is cleared to prevent - // data from leaking out and being sent inadvertently. - prepareForResponse(&curCmd); - - // Change the destination endpoint of the incoming command and the source - // source endpoint of the response so they both reflect the endpoint the - // message is actually being passed to in this iteration of the loop. - curCmd.apsFrame->destinationEndpoint = endpoint; - emberAfResponseApsFrame.sourceEndpoint = endpoint; - if (dispatchZclMessage(&curCmd)) - { - msgHandled = true; - } - } - } - else - { - msgHandled = dispatchZclMessage(&curCmd); - } - -kickout: - emberAfClearResponseData(); - memset(&interpanResponseHeader, 0, sizeof(EmberAfInterpanHeader)); - emAfCurrentCommand = NULL; - return msgHandled; -} - uint8_t emberAfNextSequence(void) { return ((++emberAfSequenceNumber) & EMBER_AF_ZCL_SEQUENCE_MASK); diff --git a/src/app/util/util.h b/src/app/util/util.h index 5145a6de0c04a2..84def0875d2335 100644 --- a/src/app/util/util.h +++ b/src/app/util/util.h @@ -151,13 +151,6 @@ void emberAfStackDown(void); void emberAfDecodeAndPrintCluster(chip::ClusterId cluster); void emberAfDecodeAndPrintClusterWithMfgCode(chip::ClusterId cluster, uint16_t mfgCode); -bool emberAfProcessMessage(EmberApsFrame * apsFrame, EmberIncomingMessageType type, uint8_t * message, uint16_t msgLen, - chip::Messaging::ExchangeContext * source, InterPanHeader * interPanHeader); - -bool emberAfProcessMessageIntoZclCmd(EmberApsFrame * apsFrame, EmberIncomingMessageType type, uint8_t * message, - uint16_t messageLength, chip::Messaging::ExchangeContext * source, - InterPanHeader * interPanHeader, EmberAfClusterCommand * returnCmd); - /** * Retrieves the difference between the two passed values. * This function assumes that the two values have the same endianness. @@ -212,9 +205,6 @@ void emberAfSetNoReplyForNextMessage(bool set); #define isThisDataTypeSentLittleEndianOTA(dataType) (!(emberAfIsThisDataTypeAStringType(dataType))) -bool emAfProcessGlobalCommand(EmberAfClusterCommand * cmd); -bool emAfProcessClusterSpecificCommand(EmberAfClusterCommand * cmd); - extern uint8_t emberAfResponseType; uint16_t emberAfStrnlen(const uint8_t * string, uint16_t maxLength); diff --git a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj index 00dd58da64c5ac..ad51c7f8c0ef25 100644 --- a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj @@ -14,7 +14,6 @@ 1E85730E265519AE0050A4D9 /* CHIPClusters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E857309265519AE0050A4D9 /* CHIPClusters.cpp */; }; 1E857310265519AE0050A4D9 /* IMClusterCommandHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85730B265519AE0050A4D9 /* IMClusterCommandHandler.cpp */; }; 1E85732226551A490050A4D9 /* binding-table.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731226551A490050A4D9 /* binding-table.cpp */; }; - 1E85732326551A490050A4D9 /* process-global-message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731326551A490050A4D9 /* process-global-message.cpp */; }; 1E85732526551A490050A4D9 /* message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731526551A490050A4D9 /* message.cpp */; }; 1E85732626551A490050A4D9 /* attribute-storage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731626551A490050A4D9 /* attribute-storage.cpp */; }; 1E85732726551A490050A4D9 /* client-api.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731726551A490050A4D9 /* client-api.cpp */; }; @@ -26,7 +25,6 @@ 1E85732D26551A490050A4D9 /* util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731D26551A490050A4D9 /* util.cpp */; }; 1E85732E26551A490050A4D9 /* ember-print.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731E26551A490050A4D9 /* ember-print.cpp */; }; 1E85732F26551A490050A4D9 /* attribute-size-util.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85731F26551A490050A4D9 /* attribute-size-util.cpp */; }; - 1E85733026551A490050A4D9 /* process-cluster-message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85732026551A490050A4D9 /* process-cluster-message.cpp */; }; 1E85733126551A490050A4D9 /* chip-message-send.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E85732126551A490050A4D9 /* chip-message-send.cpp */; }; 1EB41B7B263C4CC60048E4C1 /* CHIPClustersTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1EB41B7A263C4CC60048E4C1 /* CHIPClustersTests.m */; }; 1EC3238D271999E2002A8BF0 /* cluster-objects.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1EC3238C271999E2002A8BF0 /* cluster-objects.cpp */; }; @@ -105,7 +103,6 @@ 1E857309265519AE0050A4D9 /* CHIPClusters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CHIPClusters.cpp; path = "../../../../zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp"; sourceTree = ""; }; 1E85730B265519AE0050A4D9 /* IMClusterCommandHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IMClusterCommandHandler.cpp; path = "../../../../zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp"; sourceTree = ""; }; 1E85731226551A490050A4D9 /* binding-table.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "binding-table.cpp"; path = "../../../app/util/binding-table.cpp"; sourceTree = ""; }; - 1E85731326551A490050A4D9 /* process-global-message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "process-global-message.cpp"; path = "../../../app/util/process-global-message.cpp"; sourceTree = ""; }; 1E85731526551A490050A4D9 /* message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = message.cpp; path = ../../../app/util/message.cpp; sourceTree = ""; }; 1E85731626551A490050A4D9 /* attribute-storage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "attribute-storage.cpp"; path = "../../../app/util/attribute-storage.cpp"; sourceTree = ""; }; 1E85731726551A490050A4D9 /* client-api.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "client-api.cpp"; path = "../../../app/util/client-api.cpp"; sourceTree = ""; }; @@ -117,7 +114,6 @@ 1E85731D26551A490050A4D9 /* util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = util.cpp; path = ../../../app/util/util.cpp; sourceTree = ""; }; 1E85731E26551A490050A4D9 /* ember-print.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ember-print.cpp"; path = "../../../app/util/ember-print.cpp"; sourceTree = ""; }; 1E85731F26551A490050A4D9 /* attribute-size-util.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "attribute-size-util.cpp"; path = "../../../app/util/attribute-size-util.cpp"; sourceTree = ""; }; - 1E85732026551A490050A4D9 /* process-cluster-message.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "process-cluster-message.cpp"; path = "../../../app/util/process-cluster-message.cpp"; sourceTree = ""; }; 1E85732126551A490050A4D9 /* chip-message-send.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "chip-message-send.cpp"; path = "../../../app/util/chip-message-send.cpp"; sourceTree = ""; }; 1EB41B7A263C4CC60048E4C1 /* CHIPClustersTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CHIPClustersTests.m; sourceTree = ""; }; 1EC3238C271999E2002A8BF0 /* cluster-objects.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "cluster-objects.cpp"; path = "../../../../zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp"; sourceTree = ""; }; @@ -220,8 +216,6 @@ 1E85731A26551A490050A4D9 /* ember-compatibility-functions.cpp */, 1E85731E26551A490050A4D9 /* ember-print.cpp */, 1E85731526551A490050A4D9 /* message.cpp */, - 1E85732026551A490050A4D9 /* process-cluster-message.cpp */, - 1E85731326551A490050A4D9 /* process-global-message.cpp */, 1E85731D26551A490050A4D9 /* util.cpp */, ); name = CHIPApp; @@ -503,7 +497,6 @@ 998F287126D56940001846C6 /* CHIPP256KeypairBridge.mm in Sources */, 1E85730E265519AE0050A4D9 /* CHIPClusters.cpp in Sources */, 1E16A90226B98AB700683C53 /* CHIPTestClustersObjc.mm in Sources */, - 1E85732326551A490050A4D9 /* process-global-message.cpp in Sources */, 51B22C2A2740CB47008D5055 /* CHIPCommandPayloadsObjc.mm in Sources */, 1E85732E26551A490050A4D9 /* ember-print.cpp in Sources */, 2C5EEEF7268A85C400CAE3D3 /* CHIPDeviceConnectionBridge.mm in Sources */, @@ -517,7 +510,6 @@ 2F79A67726CE6672006377B0 /* im-client-callbacks.cpp in Sources */, 1E85732226551A490050A4D9 /* binding-table.cpp in Sources */, 1ED276E226C5812A00547A89 /* CHIPCluster.mm in Sources */, - 1E85733026551A490050A4D9 /* process-cluster-message.cpp in Sources */, 1E85732526551A490050A4D9 /* message.cpp in Sources */, B2E0D7B3245B0B5C003C5B48 /* CHIPError.mm in Sources */, 1E85732726551A490050A4D9 /* client-api.cpp in Sources */,