| /** |
| * |
| * 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. |
| */ |
| // This file is generated by Simplicity Studio. Please do not edit manually. |
| // |
| // |
| |
| // This is a set of generated functions that parse the |
| // the incomming message, and call appropriate command handler. |
| |
| // #include PLATFORM_HEADER |
| #ifdef EZSP_HOST |
| // Includes needed for ember related functions for the EZSP host |
| #include "app/util/ezsp/ezsp-protocol.h" |
| #include "app/util/ezsp/ezsp-utils.h" |
| #include "app/util/ezsp/ezsp.h" |
| #include "app/util/ezsp/serial-interface.h" |
| #include "stack/include/ember-types.h" |
| #include "stack/include/error.h" |
| #else |
| // Includes needed for ember related functions for the EM250 |
| // #include "stack/include/ember.h" |
| #endif // EZSP_HOST |
| |
| #include <stdint.h> |
| |
| #include "af-structs.h" |
| #include "call-command-handler.h" |
| #include "callback.h" |
| #include "command-id.h" |
| #include "util.h" |
| |
| static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific) |
| { |
| if (wasHandled) |
| { |
| return EMBER_ZCL_STATUS_SUCCESS; |
| } |
| else if (mfgSpecific) |
| { |
| return EMBER_ZCL_STATUS_UNSUP_MANUF_CLUSTER_COMMAND; |
| } |
| else if (clusterExists) |
| { |
| return EMBER_ZCL_STATUS_UNSUP_CLUSTER_COMMAND; |
| } |
| else |
| { |
| return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER; |
| } |
| } |
| |
| // Main command parsing controller. |
| EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) |
| { |
| EmberAfStatus result = status(false, false, cmd->mfgSpecific); |
| if (cmd->direction == (uint8_t) ZCL_DIRECTION_SERVER_TO_CLIENT && |
| emberAfContainsClientWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode)) |
| { |
| switch (cmd->apsFrame->clusterId) |
| { |
| case ZCL_BASIC_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_IDENTIFY_CLUSTER_ID: |
| result = emberAfIdentifyClusterClientCommandParse(cmd); |
| break; |
| case ZCL_GROUPS_CLUSTER_ID: |
| result = emberAfGroupsClusterClientCommandParse(cmd); |
| break; |
| case ZCL_SCENES_CLUSTER_ID: |
| result = emberAfScenesClusterClientCommandParse(cmd); |
| break; |
| case ZCL_ON_OFF_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_ON_OFF_SWITCH_CONFIG_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_LEVEL_CONTROL_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_DOOR_LOCK_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_BARRIER_CONTROL_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_COLOR_CONTROL_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_TEMP_MEASUREMENT_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_IAS_ZONE_CLUSTER_ID: |
| result = emberAfIasZoneClusterClientCommandParse(cmd); |
| break; |
| default: |
| // Unrecognized cluster ID, error status will apply. |
| break; |
| } |
| } |
| else if (cmd->direction == (uint8_t) ZCL_DIRECTION_CLIENT_TO_SERVER && |
| emberAfContainsServerWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode)) |
| { |
| switch (cmd->apsFrame->clusterId) |
| { |
| case ZCL_BASIC_CLUSTER_ID: |
| result = emberAfBasicClusterServerCommandParse(cmd); |
| break; |
| case ZCL_IDENTIFY_CLUSTER_ID: |
| result = emberAfIdentifyClusterServerCommandParse(cmd); |
| break; |
| case ZCL_GROUPS_CLUSTER_ID: |
| result = emberAfGroupsClusterServerCommandParse(cmd); |
| break; |
| case ZCL_SCENES_CLUSTER_ID: |
| result = emberAfScenesClusterServerCommandParse(cmd); |
| break; |
| case ZCL_ON_OFF_CLUSTER_ID: |
| result = emberAfOnOffClusterServerCommandParse(cmd); |
| break; |
| case ZCL_ON_OFF_SWITCH_CONFIG_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_LEVEL_CONTROL_CLUSTER_ID: |
| result = emberAfLevelControlClusterServerCommandParse(cmd); |
| break; |
| case ZCL_DOOR_LOCK_CLUSTER_ID: |
| result = emberAfDoorLockClusterServerCommandParse(cmd); |
| break; |
| case ZCL_BARRIER_CONTROL_CLUSTER_ID: |
| result = emberAfBarrierControlClusterServerCommandParse(cmd); |
| break; |
| case ZCL_COLOR_CONTROL_CLUSTER_ID: |
| result = emberAfColorControlClusterServerCommandParse(cmd); |
| break; |
| case ZCL_TEMP_MEASUREMENT_CLUSTER_ID: |
| result = status(false, true, cmd->mfgSpecific); |
| break; |
| case ZCL_IAS_ZONE_CLUSTER_ID: |
| result = emberAfIasZoneClusterServerCommandParse(cmd); |
| break; |
| default: |
| // Unrecognized cluster ID, error status will apply. |
| break; |
| } |
| } |
| return result; |
| } |
| |
| // Cluster: Basic, server |
| EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfBasicClusterResetToFactoryDefaultsCallback(); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Identify, client |
| EmberAfStatus emberAfIdentifyClusterClientCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t timeout; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| timeout = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfIdentifyClusterIdentifyQueryResponseCallback(timeout); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Identify, server |
| EmberAfStatus emberAfIdentifyClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_IDENTIFY_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t identifyTime; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| identifyTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfIdentifyClusterIdentifyCallback(identifyTime); |
| break; |
| } |
| case ZCL_IDENTIFY_QUERY_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfIdentifyClusterIdentifyQueryCallback(); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Groups, client |
| EmberAfStatus emberAfGroupsClusterClientCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_ADD_GROUP_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfGroupsClusterAddGroupResponseCallback(status, groupId); |
| break; |
| } |
| case ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| uint8_t * groupName; // Ver.: always |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupName = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfGroupsClusterViewGroupResponseCallback(status, groupId, groupName); |
| break; |
| } |
| case ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t capacity; // Ver.: always |
| uint8_t groupCount; // Ver.: always |
| uint8_t * groupList; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| capacity = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupCount = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupList = cmd->buffer + payloadOffset; |
| wasHandled = emberAfGroupsClusterGetGroupMembershipResponseCallback(capacity, groupCount, groupList); |
| break; |
| } |
| case ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfGroupsClusterRemoveGroupResponseCallback(status, groupId); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Groups, server |
| EmberAfStatus emberAfGroupsClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_ADD_GROUP_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| uint8_t * groupName; // Ver.: always |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupName = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfGroupsClusterAddGroupCallback(groupId, groupName); |
| break; |
| } |
| case ZCL_VIEW_GROUP_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfGroupsClusterViewGroupCallback(groupId); |
| break; |
| } |
| case ZCL_GET_GROUP_MEMBERSHIP_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t groupCount; // Ver.: always |
| uint8_t * groupList; // Ver.: always |
| // Command is fixed length: 1 |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupCount = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupList = cmd->buffer + payloadOffset; |
| wasHandled = emberAfGroupsClusterGetGroupMembershipCallback(groupCount, groupList); |
| break; |
| } |
| case ZCL_REMOVE_GROUP_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfGroupsClusterRemoveGroupCallback(groupId); |
| break; |
| } |
| case ZCL_REMOVE_ALL_GROUPS_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfGroupsClusterRemoveAllGroupsCallback(); |
| break; |
| } |
| case ZCL_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| uint8_t * groupName; // Ver.: always |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupName = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfGroupsClusterAddGroupIfIdentifyingCallback(groupId, groupName); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Scenes, client |
| EmberAfStatus emberAfScenesClusterClientCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_ADD_SCENE_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| // Command is fixed length: 4 |
| if (cmd->bufLen < payloadOffset + 4u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterAddSceneResponseCallback(status, groupId, sceneId); |
| break; |
| } |
| case ZCL_VIEW_SCENE_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t * sceneName; // Ver.: always |
| uint8_t * extensionFieldSets; // Ver.: always |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (!(status == 0)) |
| { |
| // Argument is not always present: |
| // - it is conditionally present based on expression: status==0 |
| transitionTime = 0xFFFF; |
| } |
| else |
| { |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| } |
| if (!(status == 0)) |
| { |
| // Argument is not always present: |
| // - it is conditionally present based on expression: status==0 |
| sceneName = NULL; |
| } |
| else |
| { |
| sceneName = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += emberAfStringLength(cmd->buffer + payloadOffset) + 1u; |
| } |
| if (status == 0) |
| { |
| // Array is conditionally present based on expression: status==0 |
| extensionFieldSets = cmd->buffer + payloadOffset; |
| } |
| else |
| { |
| extensionFieldSets = NULL; |
| } |
| wasHandled = emberAfScenesClusterViewSceneResponseCallback(status, groupId, sceneId, transitionTime, sceneName, |
| extensionFieldSets); |
| break; |
| } |
| case ZCL_REMOVE_SCENE_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| // Command is fixed length: 4 |
| if (cmd->bufLen < payloadOffset + 4u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterRemoveSceneResponseCallback(status, groupId, sceneId); |
| break; |
| } |
| case ZCL_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterRemoveAllScenesResponseCallback(status, groupId); |
| break; |
| } |
| case ZCL_STORE_SCENE_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| // Command is fixed length: 4 |
| if (cmd->bufLen < payloadOffset + 4u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterStoreSceneResponseCallback(status, groupId, sceneId); |
| break; |
| } |
| case ZCL_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t status; // Ver.: always |
| uint8_t capacity; // Ver.: always |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneCount; // Ver.: always |
| uint8_t * sceneList; // Ver.: always |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| status = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| capacity = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (!(status == 0)) |
| { |
| // Argument is not always present: |
| // - it is conditionally present based on expression: status==0 |
| sceneCount = 0xFF; |
| } |
| else |
| { |
| sceneCount = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if (status == 0) |
| { |
| // Array is conditionally present based on expression: status==0 |
| sceneList = cmd->buffer + payloadOffset; |
| } |
| else |
| { |
| sceneList = NULL; |
| } |
| wasHandled = emberAfScenesClusterGetSceneMembershipResponseCallback(status, capacity, groupId, sceneCount, sceneList); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Scenes, server |
| EmberAfStatus emberAfScenesClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_ADD_SCENE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t * sceneName; // Ver.: always |
| uint8_t * extensionFieldSets; // Ver.: always |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| sceneName = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += emberAfStringLength(cmd->buffer + payloadOffset) + 1u; |
| extensionFieldSets = cmd->buffer + payloadOffset; |
| wasHandled = emberAfScenesClusterAddSceneCallback(groupId, sceneId, transitionTime, sceneName, extensionFieldSets); |
| break; |
| } |
| case ZCL_VIEW_SCENE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterViewSceneCallback(groupId, sceneId); |
| break; |
| } |
| case ZCL_REMOVE_SCENE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterRemoveSceneCallback(groupId, sceneId); |
| break; |
| } |
| case ZCL_REMOVE_ALL_SCENES_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterRemoveAllScenesCallback(groupId); |
| break; |
| } |
| case ZCL_STORE_SCENE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterStoreSceneCallback(groupId, sceneId); |
| break; |
| } |
| case ZCL_RECALL_SCENE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| uint8_t sceneId; // Ver.: always |
| uint16_t transitionTime; // Ver.: since zcl-7.0-07-5123-07 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| sceneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if ((cmd->bufLen < payloadOffset + 2u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl-7.0-07-5123-07 |
| transitionTime = 0xFFFF; |
| } |
| else |
| { |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfScenesClusterRecallSceneCallback(groupId, sceneId, transitionTime); |
| break; |
| } |
| case ZCL_GET_SCENE_MEMBERSHIP_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t groupId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| groupId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfScenesClusterGetSceneMembershipCallback(groupId); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: On/off, server |
| EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_OFF_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfOnOffClusterOffCallback(); |
| break; |
| } |
| case ZCL_ON_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfOnOffClusterOnCallback(); |
| break; |
| } |
| case ZCL_TOGGLE_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfOnOffClusterToggleCallback(); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Level Control, server |
| EmberAfStatus emberAfLevelControlClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_MOVE_TO_LEVEL_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t level; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t optionMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| level = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionMask = 0xFF; |
| } |
| else |
| { |
| optionMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionOverride = 0xFF; |
| } |
| else |
| { |
| optionOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfLevelControlClusterMoveToLevelCallback(level, transitionTime, optionMask, optionOverride); |
| break; |
| } |
| case ZCL_MOVE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t moveMode; // Ver.: always |
| uint8_t rate; // Ver.: always |
| uint8_t optionMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| moveMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| rate = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionMask = 0xFF; |
| } |
| else |
| { |
| optionMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionOverride = 0xFF; |
| } |
| else |
| { |
| optionOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfLevelControlClusterMoveCallback(moveMode, rate, optionMask, optionOverride); |
| break; |
| } |
| case ZCL_STEP_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t stepMode; // Ver.: always |
| uint8_t stepSize; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t optionMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepSize = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionMask = 0xFF; |
| } |
| else |
| { |
| optionMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionOverride = 0xFF; |
| } |
| else |
| { |
| optionOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfLevelControlClusterStepCallback(stepMode, stepSize, transitionTime, optionMask, optionOverride); |
| break; |
| } |
| case ZCL_STOP_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t optionMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionMask = 0xFF; |
| } |
| else |
| { |
| optionMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionOverride = 0xFF; |
| } |
| else |
| { |
| optionOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfLevelControlClusterStopCallback(optionMask, optionOverride); |
| break; |
| } |
| case ZCL_MOVE_TO_LEVEL_WITH_ON_OFF_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t level; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| level = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfLevelControlClusterMoveToLevelWithOnOffCallback(level, transitionTime); |
| break; |
| } |
| case ZCL_MOVE_WITH_ON_OFF_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t moveMode; // Ver.: always |
| uint8_t rate; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| moveMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| rate = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfLevelControlClusterMoveWithOnOffCallback(moveMode, rate); |
| break; |
| } |
| case ZCL_STEP_WITH_ON_OFF_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t stepMode; // Ver.: always |
| uint8_t stepSize; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| // Command is fixed length: 4 |
| if (cmd->bufLen < payloadOffset + 4u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| stepSize = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfLevelControlClusterStepWithOnOffCallback(stepMode, stepSize, transitionTime); |
| break; |
| } |
| case ZCL_STOP_WITH_ON_OFF_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfLevelControlClusterStopWithOnOffCallback(); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Door Lock, server |
| EmberAfStatus emberAfDoorLockClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_LOCK_DOOR_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t * PIN; // Ver.: since ha-1.2-05-3520-29 |
| // Command is not a fixed length |
| if ((cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: ha-1.2-05-3520-29 |
| PIN = NULL; |
| } |
| else |
| { |
| PIN = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfDoorLockClusterLockDoorCallback(PIN); |
| break; |
| } |
| case ZCL_UNLOCK_DOOR_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t * PIN; // Ver.: since ha-1.2-05-3520-29 |
| // Command is not a fixed length |
| if ((cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: ha-1.2-05-3520-29 |
| PIN = NULL; |
| } |
| else |
| { |
| PIN = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfDoorLockClusterUnlockDoorCallback(PIN); |
| break; |
| } |
| case ZCL_UNLOCK_WITH_TIMEOUT_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t timeoutInSeconds; // Ver.: always |
| uint8_t * pin; // Ver.: since ha-1.2-05-3520-29 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| timeoutInSeconds = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: ha-1.2-05-3520-29 |
| pin = NULL; |
| } |
| else |
| { |
| pin = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfDoorLockClusterUnlockWithTimeoutCallback(timeoutInSeconds, pin); |
| break; |
| } |
| case ZCL_GET_LOG_RECORD_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t logIndex; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| logIndex = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterGetLogRecordCallback(logIndex); |
| break; |
| } |
| case ZCL_SET_PIN_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t userId; // Ver.: always |
| uint8_t userStatus; // Ver.: always |
| uint8_t userType; // Ver.: always |
| uint8_t * pin; // Ver.: always |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userStatus = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userType = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| pin = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterSetPinCallback(userId, userStatus, userType, pin); |
| break; |
| } |
| case ZCL_GET_PIN_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterGetPinCallback(userId); |
| break; |
| } |
| case ZCL_CLEAR_PIN_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterClearPinCallback(userId); |
| break; |
| } |
| case ZCL_CLEAR_ALL_PINS_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfDoorLockClusterClearAllPinsCallback(); |
| break; |
| } |
| case ZCL_SET_WEEKDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| uint16_t userId; // Ver.: always |
| uint8_t daysMask; // Ver.: always |
| uint8_t startHour; // Ver.: always |
| uint8_t startMinute; // Ver.: always |
| uint8_t endHour; // Ver.: always |
| uint8_t endMinute; // Ver.: always |
| // Command is fixed length: 8 |
| if (cmd->bufLen < payloadOffset + 8u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| daysMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| startHour = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| startMinute = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| endHour = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| endMinute = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterSetWeekdayScheduleCallback(scheduleId, userId, daysMask, startHour, startMinute, |
| endHour, endMinute); |
| break; |
| } |
| case ZCL_GET_WEEKDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterGetWeekdayScheduleCallback(scheduleId, userId); |
| break; |
| } |
| case ZCL_CLEAR_WEEKDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterClearWeekdayScheduleCallback(scheduleId, userId); |
| break; |
| } |
| case ZCL_SET_YEARDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| uint16_t userId; // Ver.: always |
| uint32_t localStartTime; // Ver.: always |
| uint32_t localEndTime; // Ver.: always |
| // Command is fixed length: 11 |
| if (cmd->bufLen < payloadOffset + 11u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| localStartTime = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 4u; |
| localEndTime = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterSetYeardayScheduleCallback(scheduleId, userId, localStartTime, localEndTime); |
| break; |
| } |
| case ZCL_GET_YEARDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterGetYeardayScheduleCallback(scheduleId, userId); |
| break; |
| } |
| case ZCL_CLEAR_YEARDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterClearYeardayScheduleCallback(scheduleId, userId); |
| break; |
| } |
| case ZCL_SET_HOLIDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| uint32_t localStartTime; // Ver.: always |
| uint32_t localEndTime; // Ver.: always |
| uint8_t operatingModeDuringHoliday; // Ver.: always |
| // Command is fixed length: 10 |
| if (cmd->bufLen < payloadOffset + 10u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| localStartTime = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 4u; |
| localEndTime = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 4u; |
| operatingModeDuringHoliday = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterSetHolidayScheduleCallback(scheduleId, localStartTime, localEndTime, |
| operatingModeDuringHoliday); |
| break; |
| } |
| case ZCL_GET_HOLIDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| // Command is fixed length: 1 |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterGetHolidayScheduleCallback(scheduleId); |
| break; |
| } |
| case ZCL_CLEAR_HOLIDAY_SCHEDULE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t scheduleId; // Ver.: always |
| // Command is fixed length: 1 |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| scheduleId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterClearHolidayScheduleCallback(scheduleId); |
| break; |
| } |
| case ZCL_SET_USER_TYPE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t userId; // Ver.: always |
| uint8_t userType; // Ver.: always |
| // Command is fixed length: 3 |
| if (cmd->bufLen < payloadOffset + 3u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| userType = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterSetUserTypeCallback(userId, userType); |
| break; |
| } |
| case ZCL_GET_USER_TYPE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterGetUserTypeCallback(userId); |
| break; |
| } |
| case ZCL_SET_RFID_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t userId; // Ver.: always |
| uint8_t userStatus; // Ver.: always |
| uint8_t userType; // Ver.: always |
| uint8_t * id; // Ver.: always |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userStatus = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userType = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + emberAfStringLength(cmd->buffer + payloadOffset) + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| id = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterSetRfidCallback(userId, userStatus, userType, id); |
| break; |
| } |
| case ZCL_GET_RFID_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterGetRfidCallback(userId); |
| break; |
| } |
| case ZCL_CLEAR_RFID_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t userId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| userId = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfDoorLockClusterClearRfidCallback(userId); |
| break; |
| } |
| case ZCL_CLEAR_ALL_RFIDS_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfDoorLockClusterClearAllRfidsCallback(); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Barrier Control, server |
| EmberAfStatus emberAfBarrierControlClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_BARRIER_CONTROL_GO_TO_PERCENT_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t percentOpen; // Ver.: always |
| // Command is fixed length: 1 |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| percentOpen = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfBarrierControlClusterBarrierControlGoToPercentCallback(percentOpen); |
| break; |
| } |
| case ZCL_BARRIER_CONTROL_STOP_COMMAND_ID: { |
| // Command is fixed length: 0 |
| wasHandled = emberAfBarrierControlClusterBarrierControlStopCallback(); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: Color Control, server |
| EmberAfStatus emberAfColorControlClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_MOVE_TO_HUE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t hue; // Ver.: always |
| uint8_t direction; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| hue = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| direction = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterMoveToHueCallback(hue, direction, transitionTime, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_MOVE_HUE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t moveMode; // Ver.: always |
| uint8_t rate; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| moveMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| rate = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterMoveHueCallback(moveMode, rate, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_STEP_HUE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t stepMode; // Ver.: always |
| uint8_t stepSize; // Ver.: always |
| uint8_t transitionTime; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepSize = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = |
| emberAfColorControlClusterStepHueCallback(stepMode, stepSize, transitionTime, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_MOVE_TO_SATURATION_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t saturation; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| saturation = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = |
| emberAfColorControlClusterMoveToSaturationCallback(saturation, transitionTime, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_MOVE_SATURATION_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t moveMode; // Ver.: always |
| uint8_t rate; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| moveMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| rate = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterMoveSaturationCallback(moveMode, rate, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_STEP_SATURATION_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t stepMode; // Ver.: always |
| uint8_t stepSize; // Ver.: always |
| uint8_t transitionTime; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepSize = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = |
| emberAfColorControlClusterStepSaturationCallback(stepMode, stepSize, transitionTime, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t hue; // Ver.: always |
| uint8_t saturation; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| hue = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| saturation = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterMoveToHueAndSaturationCallback(hue, saturation, transitionTime, optionsMask, |
| optionsOverride); |
| break; |
| } |
| case ZCL_MOVE_TO_COLOR_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t colorX; // Ver.: always |
| uint16_t colorY; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| colorX = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| colorY = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = |
| emberAfColorControlClusterMoveToColorCallback(colorX, colorY, transitionTime, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_MOVE_COLOR_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| int16_t rateX; // Ver.: always |
| int16_t rateY; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| rateX = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| rateY = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterMoveColorCallback(rateX, rateY, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_STEP_COLOR_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| int16_t stepX; // Ver.: always |
| int16_t stepY; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepX = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepY = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterStepColorCallback(stepX, stepY, transitionTime, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_MOVE_TO_COLOR_TEMPERATURE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t colorTemperature; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| colorTemperature = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterMoveToColorTemperatureCallback(colorTemperature, transitionTime, optionsMask, |
| optionsOverride); |
| break; |
| } |
| case ZCL_STOP_MOVE_STEP_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterStopMoveStepCallback(optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_MOVE_COLOR_TEMPERATURE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t moveMode; // Ver.: always |
| uint16_t rate; // Ver.: always |
| uint16_t colorTemperatureMinimum; // Ver.: always |
| uint16_t colorTemperatureMaximum; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| moveMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| rate = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| colorTemperatureMinimum = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| colorTemperatureMaximum = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterMoveColorTemperatureCallback( |
| moveMode, rate, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); |
| break; |
| } |
| case ZCL_STEP_COLOR_TEMPERATURE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t stepMode; // Ver.: always |
| uint16_t stepSize; // Ver.: always |
| uint16_t transitionTime; // Ver.: always |
| uint16_t colorTemperatureMinimum; // Ver.: always |
| uint16_t colorTemperatureMaximum; // Ver.: always |
| uint8_t optionsMask; // Ver.: since zcl6-errata-14-0129-15 |
| uint8_t optionsOverride; // Ver.: since zcl6-errata-14-0129-15 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepMode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| stepSize = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| transitionTime = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| colorTemperatureMinimum = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| colorTemperatureMaximum = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsMask = 0xFF; |
| } |
| else |
| { |
| optionsMask = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: zcl6-errata-14-0129-15 |
| optionsOverride = 0xFF; |
| } |
| else |
| { |
| optionsOverride = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfColorControlClusterStepColorTemperatureCallback( |
| stepMode, stepSize, transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: IAS Zone, client |
| EmberAfStatus emberAfIasZoneClusterClientCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_ZONE_STATUS_CHANGE_NOTIFICATION_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t zoneStatus; // Ver.: always |
| uint8_t extendedStatus; // Ver.: always |
| uint8_t zoneId; // Ver.: since ha-1.2-05-3520-29 |
| uint16_t delay; // Ver.: since ha-1.2-05-3520-29 |
| // Command is not a fixed length |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| zoneStatus = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| if (cmd->bufLen < payloadOffset + 1u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| extendedStatus = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| if ((cmd->bufLen < payloadOffset + 1u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: ha-1.2-05-3520-29 |
| zoneId = 0xFF; |
| } |
| else |
| { |
| zoneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| } |
| if ((cmd->bufLen < payloadOffset + 2u)) |
| { |
| // Argument is not always present: |
| // - it is present only in versions higher than: ha-1.2-05-3520-29 |
| delay = 0xFFFF; |
| } |
| else |
| { |
| delay = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| } |
| wasHandled = emberAfIasZoneClusterZoneStatusChangeNotificationCallback(zoneStatus, extendedStatus, zoneId, delay); |
| break; |
| } |
| case ZCL_ZONE_ENROLL_REQUEST_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint16_t zoneType; // Ver.: always |
| uint16_t manufacturerCode; // Ver.: always |
| // Command is fixed length: 4 |
| if (cmd->bufLen < payloadOffset + 4u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| zoneType = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 2u; |
| manufacturerCode = emberAfGetInt16u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfIasZoneClusterZoneEnrollRequestCallback(zoneType, manufacturerCode); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |
| |
| // Cluster: IAS Zone, server |
| EmberAfStatus emberAfIasZoneClusterServerCommandParse(EmberAfClusterCommand * cmd) |
| { |
| bool wasHandled = false; |
| if (!cmd->mfgSpecific) |
| { |
| switch (cmd->commandId) |
| { |
| case ZCL_ZONE_ENROLL_RESPONSE_COMMAND_ID: { |
| uint16_t payloadOffset = cmd->payloadStartIndex; |
| uint8_t enrollResponseCode; // Ver.: always |
| uint8_t zoneId; // Ver.: always |
| // Command is fixed length: 2 |
| if (cmd->bufLen < payloadOffset + 2u) |
| { |
| return EMBER_ZCL_STATUS_MALFORMED_COMMAND; |
| } |
| enrollResponseCode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| payloadOffset += 1u; |
| zoneId = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); |
| wasHandled = emberAfIasZoneClusterZoneEnrollResponseCallback(enrollResponseCode, zoneId); |
| break; |
| } |
| default: { |
| // Unrecognized command ID, error status will apply. |
| break; |
| } |
| } |
| } |
| return status(wasHandled, true, cmd->mfgSpecific); |
| } |