diff --git a/examples/all-clusters-app/all-clusters-common/BUILD.gn b/examples/all-clusters-app/all-clusters-common/BUILD.gn index 41fb5bcbd1aedc..d6bbe53239f2d0 100644 --- a/examples/all-clusters-app/all-clusters-common/BUILD.gn +++ b/examples/all-clusters-app/all-clusters-common/BUILD.gn @@ -17,35 +17,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("all-clusters-common") { - cluster_sources = [ - "account-login-server", - "application-launcher-server", - "audio-output-server", - "barrier-control-server", - "basic", - "bindings", - "color-control-server", - "content-launch-server", - "descriptor", - "door-lock-server", - "general-commissioning-server", - "groups-server", - "ias-zone-server", - "identify", - "keypad-input-server", - "level-control", - "low-power-server", - "media-input-server", - "media-playback-server", - "network-commissioning", - "on-off-server", - "operational-credentials", - "ota-server", - "scenes", - "target-navigator-server", - "temperature-measurement-server", - "tv-channel-server", - ] + zap_file = "all-clusters-app.zap" zap_pregenerated_dir = "gen" } diff --git a/examples/bridge-app/bridge-common/BUILD.gn b/examples/bridge-app/bridge-common/BUILD.gn index 4c19d980516fe9..46b94ab8d49c7c 100644 --- a/examples/bridge-app/bridge-common/BUILD.gn +++ b/examples/bridge-app/bridge-common/BUILD.gn @@ -17,13 +17,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("bridge-common") { - cluster_sources = [ - "basic", - "bindings", - "level-control", - "network-commissioning", - "on-off-server", - ] + zap_file = "bridge-app.zap" zap_pregenerated_dir = "gen" } diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 5c736cb3a47922..8bd2c3ec412f36 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -21,10 +21,7 @@ import("${chip_root}/src/app/chip_data_model.gni") assert(chip_build_tools) chip_data_model("data_model") { - cluster_sources = [ - "media-playback-client", - "thermostat-client", - ] + zap_file = "chip-tool.zap" zap_pregenerated_dir = "gen" diff --git a/examples/lighting-app/lighting-common/BUILD.gn b/examples/lighting-app/lighting-common/BUILD.gn index 65a6ca4734e9d3..c44f5b9875e332 100644 --- a/examples/lighting-app/lighting-common/BUILD.gn +++ b/examples/lighting-app/lighting-common/BUILD.gn @@ -28,13 +28,7 @@ if (chip_enable_pw_rpc) { } chip_data_model("lighting-common") { - cluster_sources = [ - "basic", - "bindings", - "level-control", - "network-commissioning", - "on-off-server", - ] + zap_file = "lighting-app.zap" zap_pregenerated_dir = "gen" } diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn index 76bb3397d4ffca..a0eb36cdd585e0 100644 --- a/examples/lock-app/lock-common/BUILD.gn +++ b/examples/lock-app/lock-common/BUILD.gn @@ -17,12 +17,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("lock-common") { - cluster_sources = [ - "basic", - "bindings", - "network-commissioning", - "on-off-server", - ] + zap_file = "lock-app.zap" zap_pregenerated_dir = "gen" } diff --git a/examples/tv-app/tv-common/BUILD.gn b/examples/tv-app/tv-common/BUILD.gn index e209ff1f447f7a..bbba32d4081987 100644 --- a/examples/tv-app/tv-common/BUILD.gn +++ b/examples/tv-app/tv-common/BUILD.gn @@ -17,29 +17,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("tv-common") { - cluster_sources = [ - "barrier-control-server", - "basic", - "bindings", - "color-control-server", - "content-launch-server", - "door-lock-client", - "door-lock-server", - "general-commissioning-server", - "groups-client", - "groups-server", - "ias-zone-server", - "identify", - "identify-client", - "level-control", - "low-power-server", - "media-playback-server", - "network-commissioning", - "on-off-server", - "scenes", - "scenes-client", - "temperature-measurement-server", - ] + zap_file = "tv-app.zap" zap_pregenerated_dir = "gen" } diff --git a/examples/window-app/common/BUILD.gn b/examples/window-app/common/BUILD.gn index cae03951f43359..4052665e0f2b77 100644 --- a/examples/window-app/common/BUILD.gn +++ b/examples/window-app/common/BUILD.gn @@ -17,10 +17,7 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/app/chip_data_model.gni") chip_data_model("window-common") { - cluster_sources = [ - "bindings", - "network-commissioning", - ] + zap_file = "window-app.zap" zap_pregenerated_dir = "gen" } diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 0ffe6deb6dd6c1..010fed4ce83bfe 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -18,14 +18,24 @@ import("${chip_root}/src/lib/core/core.gni") _app_root = get_path_info(".", "abspath") +_zap_cluster_list_script = get_path_info("zap_cluster_list.py", "abspath") + # Defines a source_set for CHIP data model. # # Arguments: # zap_pregenerated_dir # Path to the ZAP "gen" dir. # +# zap_file +# Path to the ZAP input file. +# # cluster_sources -# Names of the clusters to compile. +# Names of the clusters directories to compile. +# Deprecated, specify zap_file instead. +# +# remove_cluster_sources +# Names of the cluster directories to remove. +# TODO - Remove this option once everything compiles. # # use_default_client_callbacks # Include CHIPClientCallbacks.cpp. @@ -53,6 +63,8 @@ template("chip_data_model") { [ "zap_pregenerated_dir", "cluster_sources", + "remove_cluster_sources", + "zap_file", "use_default_client_callbacks", ]) @@ -75,7 +87,6 @@ template("chip_data_model") { "${_app_root}/clusters/messaging-server/messaging-server.h", "${_app_root}/clusters/network-commissioning/network-commissioning.h", "${_app_root}/clusters/on-off-server/on-off-server.h", - "${_app_root}/clusters/scenes-client/scenes-client.h", "${_app_root}/clusters/scenes/scenes-tokens.h", "${_app_root}/clusters/scenes/scenes.h", "${_app_root}/clusters/temperature-measurement-server/temperature-measurement-server.h", @@ -102,22 +113,36 @@ template("chip_data_model") { ] if (defined(invoker.cluster_sources)) { - foreach(cluster, invoker.cluster_sources) { - if (cluster == "door-lock-server") { - sources += [ - "${_app_root}/clusters/${cluster}/door-lock-server-core.cpp", - "${_app_root}/clusters/${cluster}/door-lock-server-logging.cpp", - "${_app_root}/clusters/${cluster}/door-lock-server-schedule.cpp", - "${_app_root}/clusters/${cluster}/door-lock-server-user.cpp", - ] - } else if (cluster == "network-commissioning") { - sources += [ - "${_app_root}/clusters/${cluster}/${cluster}-ember.cpp", - "${_app_root}/clusters/${cluster}/${cluster}.cpp", - ] - } else { - sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] - } + _cluster_sources = invoker.cluster_sources + } else if (defined(invoker.zap_file)) { + _zap_path = rebase_path(invoker.zap_file, root_build_dir) + _script_args = [ "--zap_file=" + _zap_path ] + + _cluster_sources = exec_script(_zap_cluster_list_script, + _script_args, + "list lines", + [ invoker.zap_file ]) + } + + if (defined(invoker.remove_cluster_sources)) { + _cluster_sources -= invoker.remove_cluster_sources + } + + foreach(cluster, _cluster_sources) { + if (cluster == "door-lock-server") { + sources += [ + "${_app_root}/clusters/${cluster}/door-lock-server-core.cpp", + "${_app_root}/clusters/${cluster}/door-lock-server-logging.cpp", + "${_app_root}/clusters/${cluster}/door-lock-server-schedule.cpp", + "${_app_root}/clusters/${cluster}/door-lock-server-user.cpp", + ] + } else if (cluster == "network-commissioning") { + sources += [ + "${_app_root}/clusters/${cluster}/${cluster}-ember.cpp", + "${_app_root}/clusters/${cluster}/${cluster}.cpp", + ] + } else { + sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] } } diff --git a/src/app/clusters/door-lock-client/door-lock-client.cpp b/src/app/clusters/door-lock-client/door-lock-client.cpp deleted file mode 100644 index 90f6e52736d70b..00000000000000 --- a/src/app/clusters/door-lock-client/door-lock-client.cpp +++ /dev/null @@ -1,42 +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. - */ - -/**************************************************************************** - * @file - * @brief Routines for the Door Lock Client plugin, the - * client implementation of the Door Lock cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -using namespace chip; - -bool emberAfDoorLockClusterLockDoorResponseCallback(chip::app::Command * commandObj, uint8_t status) -{ - emberAfDoorLockClusterPrintln("RX: LockDoorResponse 0x%x", status); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfDoorLockClusterUnlockDoorResponseCallback(chip::app::Command * commandObj, uint8_t status) -{ - emberAfDoorLockClusterPrintln("RX: UnlockDoorResponse 0x%x", status); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/src/app/clusters/groups-client/groups-client.cpp b/src/app/clusters/groups-client/groups-client.cpp deleted file mode 100644 index 0a4ed5588f7ab7..00000000000000 --- a/src/app/clusters/groups-client/groups-client.cpp +++ /dev/null @@ -1,89 +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 Routines for the Groups Client plugin, the - *client implementation of the Groups cluster. - ******************************************************************************* - ******************************************************************************/ - -// ******************************************************************* -// * groups-client.c -// * -// * -// * Copyright 2010 by Ember Corporation. All rights reserved. *80* -// ******************************************************************* - -#include -#include - -using namespace chip; - -bool emberAfGroupsClusterAddGroupResponseCallback(chip::app::Command * commandObj, uint8_t status, GroupId groupId) -{ - emberAfGroupsClusterPrintln("RX: AddGroupResponse 0x%x, 0x%2x", status, groupId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfGroupsClusterViewGroupResponseCallback(chip::app::Command * commandObj, uint8_t status, GroupId groupId, - uint8_t * groupName) -{ - emberAfGroupsClusterPrint("RX: ViewGroupResponse 0x%x, 0x%2x, \"", status, groupId); - emberAfGroupsClusterPrintString(groupName); - emberAfGroupsClusterPrintln("\""); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfGroupsClusterGetGroupMembershipResponseCallback(chip::app::Command * commandObj, uint8_t capacity, uint8_t groupCount, - uint8_t * groupList) -{ - uint8_t i; - emberAfGroupsClusterPrint("RX: GetGroupMembershipResponse 0x%x, 0x%x,", capacity, groupCount); - for (i = 0; i < groupCount; i++) - { - emberAfGroupsClusterPrint(" [0x%2x]", emberAfGetInt16u(groupList + (i << 1), 0, 2)); - } - emberAfGroupsClusterPrintln(""); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfGroupsClusterRemoveGroupResponseCallback(chip::app::Command * commandObj, uint8_t status, GroupId groupId) -{ - emberAfGroupsClusterPrintln("RX: RemoveGroupResponse 0x%x, 0x%2x", status, groupId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/src/app/clusters/scenes-client/scenes-client.cpp b/src/app/clusters/scenes-client/scenes-client.cpp deleted file mode 100644 index 697150a27c8b99..00000000000000 --- a/src/app/clusters/scenes-client/scenes-client.cpp +++ /dev/null @@ -1,162 +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 Routines for the Scenes Client plugin, which - *implements the client side of the Scenes cluster. - ******************************************************************************* - ******************************************************************************/ - -#include "scenes-client.h" -#include -#include - -#include "gen/command-id.h" - -using namespace chip; - -bool emberAfScenesClusterAddSceneResponseCallback(chip::app::Command * commandObj, uint8_t status, GroupId groupId, uint8_t sceneId) -{ - return emberAfPluginScenesClientParseAddSceneResponse(emberAfCurrentCommand(), status, groupId, sceneId); -} - -bool emberAfScenesClusterViewSceneResponseCallback(chip::app::Command * commandObj, uint8_t status, GroupId groupId, - uint8_t sceneId, uint16_t transitionTime, uint8_t * sceneName, - uint8_t * extensionFieldSets) -{ - return emberAfPluginScenesClientParseViewSceneResponse(emberAfCurrentCommand(), status, groupId, sceneId, transitionTime, - sceneName, extensionFieldSets); -} - -bool emberAfScenesClusterRemoveSceneResponseCallback(chip::app::Command * commandObj, uint8_t status, GroupId groupId, - uint8_t sceneId) -{ - emberAfScenesClusterPrintln("RX: RemoveSceneResponse 0x%x, 0x%2x, 0x%x", status, groupId, sceneId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfScenesClusterRemoveAllScenesResponseCallback(chip::app::Command * commandObj, uint8_t status, GroupId groupId) -{ - emberAfScenesClusterPrintln("RX: RemoveAllScenesResponse 0x%x, 0x%2x", status, groupId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfScenesClusterStoreSceneResponseCallback(chip::app::Command * commandObj, uint8_t status, GroupId groupId, - uint8_t sceneId) -{ - emberAfScenesClusterPrintln("RX: StoreSceneResponse 0x%x, 0x%2x, 0x%x", status, groupId, sceneId); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfScenesClusterGetSceneMembershipResponseCallback(chip::app::Command * commandObj, uint8_t status, uint8_t capacity, - GroupId groupId, uint8_t sceneCount, uint8_t * sceneList) -{ - emberAfScenesClusterPrint("RX: GetSceneMembershipResponse 0x%x, 0x%x, 0x%2x", status, capacity, groupId); - - // Scene count and the scene list only appear in the payload if the status is - // SUCCESS. - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - uint8_t i; - emberAfScenesClusterPrint(", 0x%x,", sceneCount); - for (i = 0; i < sceneCount; i++) - { - emberAfScenesClusterPrint(" [0x%x]", sceneList[i]); - } - } - - emberAfScenesClusterPrintln(""); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfPluginScenesClientParseAddSceneResponse(const EmberAfClusterCommand * cmd, uint8_t status, GroupId groupId, - uint8_t sceneId) -{ - bool enhanced = (cmd->commandId == ZCL_ENHANCED_ADD_SCENE_COMMAND_ID); - emberAfScenesClusterPrintln("RX: %pAddSceneResponse 0x%x, 0x%2x, 0x%x", (enhanced ? "Enhanced" : ""), status, groupId, sceneId); - emberAfSendDefaultResponse(cmd, EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfPluginScenesClientParseViewSceneResponse(const EmberAfClusterCommand * cmd, uint8_t status, GroupId groupId, - uint8_t sceneId, uint16_t transitionTime, const uint8_t * sceneName, - const uint8_t * extensionFieldSets) -{ - bool enhanced = (cmd->commandId == ZCL_ENHANCED_VIEW_SCENE_COMMAND_ID); - - emberAfScenesClusterPrint("RX: %pViewSceneResponse 0x%x, 0x%2x, 0x%x", (enhanced ? "Enhanced" : ""), status, groupId, sceneId); - - // Transition time, scene name, and the extension field sets only appear in - // the payload if the status is SUCCESS. - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - uint16_t extensionFieldSetsLen = - static_cast(emberAfCurrentCommand()->bufLen - - (emberAfCurrentCommand()->payloadStartIndex + sizeof(status) + sizeof(groupId) + sizeof(sceneId) + - sizeof(transitionTime) + emberAfStringLength(sceneName) + 1)); - uint16_t extensionFieldSetsIndex = 0; - - emberAfScenesClusterPrint(", 0x%2x, \"", transitionTime); - emberAfScenesClusterPrintString(sceneName); - emberAfScenesClusterPrint("\","); - - // Each extension field set contains at least a two-byte cluster id and a - // one-byte length. - while (extensionFieldSetsIndex + 3 <= extensionFieldSetsLen) - { - ClusterId clusterId; - uint8_t length; - clusterId = emberAfGetInt16u(extensionFieldSets, extensionFieldSetsIndex, extensionFieldSetsLen); - extensionFieldSetsIndex = static_cast(extensionFieldSetsIndex + 2); - length = emberAfGetInt8u(extensionFieldSets, extensionFieldSetsIndex, extensionFieldSetsLen); - extensionFieldSetsIndex++; - emberAfScenesClusterPrint(" [0x%2x 0x%x ", clusterId, length); - if (extensionFieldSetsIndex + length <= extensionFieldSetsLen) - { - emberAfScenesClusterPrintBuffer(extensionFieldSets + extensionFieldSetsIndex, length, false); - } - emberAfScenesClusterPrint("]"); - emberAfScenesClusterFlush(); - extensionFieldSetsIndex = static_cast(extensionFieldSetsIndex + length); - } - } - - emberAfScenesClusterPrintln(""); - emberAfSendDefaultResponse(cmd, EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/src/app/clusters/scenes-client/scenes-client.h b/src/app/clusters/scenes-client/scenes-client.h deleted file mode 100644 index 784efcd1f04eb8..00000000000000 --- a/src/app/clusters/scenes-client/scenes-client.h +++ /dev/null @@ -1,52 +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 Definitions for the Scenes Client plugin. - ******************************************************************************* - ******************************************************************************/ - -#pragma once - -#include -#include - -#include "af-types.h" - -bool emberAfPluginScenesClientParseAddSceneResponse(const EmberAfClusterCommand * cmd, uint8_t status, chip::GroupId groupId, - uint8_t sceneId); - -bool emberAfPluginScenesClientParseViewSceneResponse(const EmberAfClusterCommand * cmd, uint8_t status, chip::GroupId groupId, - uint8_t sceneId, uint16_t transitionTime, const uint8_t * sceneName, - const uint8_t * extensionFieldSets); diff --git a/src/app/clusters/thermostat-server/thermostat.cpp b/src/app/clusters/thermostat-server/thermostat.cpp deleted file mode 100644 index daf1c146214921..00000000000000 --- a/src/app/clusters/thermostat-server/thermostat.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/** - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include -#include - -#include "gen/attribute-id.h" -#include "gen/attribute-type.h" -#include "gen/cluster-id.h" -#include "gen/enums.h" - -using namespace chip; - -void emberAfThermostatClusterServerInitCallback(void) -{ - // TODO - // Get from the "real thermostat" - // current mode - // current occupied heating setpoint - // current unoccupied heating setpoint - // current occupied cooling setpoint - // current unoccupied cooling setpoint - // and update the zcl cluster values - // This should be a callback defined function - // with weak binding so that real thermostat - // can get the values. - // or should this just be the responsibility of the thermostat application? -} - -bool emberAfThermostatClusterClearWeeklyScheduleCallback() -{ - // TODO - return false; -} -bool emberAfThermostatClusterGetRelayStatusLogCallback() -{ - // TODO - return false; -} - -bool emberAfThermostatClusterGetWeeklyScheduleCallback(uint8_t daysToReturn, uint8_t modeToReturn) -{ - // TODO - return false; -} - -bool emberAfThermostatClusterSetWeeklyScheduleCallback(uint8_t numberOfTransitionsForSequence, uint8_t daysOfWeekForSequence, - uint8_t modeForSequence, uint8_t * payload) -{ - // TODO - return false; -} - -bool emberAfThermostatClusterSetpointRaiseLowerCallback(uint8_t mode, int8_t amount) -{ - bool result = false; - EndpointId endpoint = 1; // Hard code to 1 for now/ - int32_t HeatingSetpoint = 2000, CoolingSetpoint = 2600; // Set to defaults to be safe - EmberAfStatus status; - switch (mode) - { - case EMBER_ZCL_SETPOINT_ADJUST_MODE_HEAT_AND_COOL_SETPOINTS: { - // In auto mode we will need to change both the heating and cooling setpoints - status = emberAfReadAttribute(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, ZCL_OCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &CoolingSetpoint, sizeof(CoolingSetpoint), NULL); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - status = emberAfReadAttribute(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &HeatingSetpoint, sizeof(HeatingSetpoint), NULL); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - HeatingSetpoint += (amount * 10); - CoolingSetpoint += (amount * 10); - // TODO should check against maximum/minimum and absolute max and min values - status = emberAfWriteAttribute(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &HeatingSetpoint, ZCL_INT16U_ATTRIBUTE_TYPE); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - status = emberAfWriteAttribute(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, ZCL_OCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &CoolingSetpoint, ZCL_INT16U_ATTRIBUTE_TYPE); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - result = true; - } - else - { - // Todo roll back the setpoints - } - } - else - { - // Todo roll back the setpoints - } - } - } - break; - } - - case EMBER_ZCL_SETPOINT_ADJUST_MODE_COOL_SETPOINT: { - // In cooling mode we will need to change only the cooling setpoint - status = emberAfReadAttribute(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, ZCL_OCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &CoolingSetpoint, sizeof(CoolingSetpoint), NULL); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - CoolingSetpoint += (amount * 10); - // TODO should check against maximum/minimum and absolute max and min values - status = emberAfWriteAttribute(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, ZCL_OCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &CoolingSetpoint, ZCL_INT16U_ATTRIBUTE_TYPE); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - result = true; - } - else - { - // Todo roll back the setpoints - } - } - break; - } - - case EMBER_ZCL_SETPOINT_ADJUST_MODE_HEAT_SETPOINT: { - // In cooling mode we will need to change only the cooling setpoint - status = emberAfReadAttribute(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &HeatingSetpoint, sizeof(CoolingSetpoint), NULL); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - HeatingSetpoint += (amount * 10); - // TODO should check against maximum/minimum and absolute max and min values - status = emberAfWriteAttribute(endpoint, ZCL_THERMOSTAT_CLUSTER_ID, ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID, - CLUSTER_MASK_SERVER, (uint8_t *) &HeatingSetpoint, ZCL_INT16U_ATTRIBUTE_TYPE); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - result = true; - } - else - { - // Todo roll back the setpoints - } - } - break; - } - - default: - // Nothing to do here - break; - } - emberAfSendImmediateDefaultResponse(status); - return result; -} diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py new file mode 100755 index 00000000000000..b69a5dc945eb89 --- /dev/null +++ b/src/app/zap_cluster_list.py @@ -0,0 +1,155 @@ +#!/usr/bin/env python3 +"""Parses a ZAP input file and outputs directories to compile.""" + +import argparse +import pathlib +import json +import typing +import sys + +# List of directories in src/app/clusters to build for server clusters. +SERVER_CLUSTERS: typing.Dict[str, typing.List[str]] = { + 'ALARM_CLUSTER': [], + 'APPLICATION_BASIC_CLUSTER': [], + 'BARRIER_CONTROL_CLUSTER': ['barrier-control-server'], + 'BASIC_CLUSTER': ['basic'], + 'BINDING_CLUSTER': ['bindings'], + 'COLOR_CONTROL_CLUSTER': ['color-control-server'], + 'COMMISSIONING_CLUSTER': [], + 'CONTENT_LAUNCH_CLUSTER': ['content-launch-server'], + 'DESCRIPTOR_CLUSTER': ['descriptor'], + 'DEVICE_TEMP_CLUSTER': [], + 'DOOR_LOCK_CLUSTER': ['door-lock-server'], + 'GENERAL_COMMISSIONING_CLUSTER': ['general-commissioning-server'], + 'GROUPS_CLUSTER': ['groups-server'], + 'GROUP_KEY_MANAGEMENT_CLUSTER': [], + 'IAS_ZONE_CLUSTER': ['ias-zone-server'], + 'IDENTIFY_CLUSTER': ['identify'], + 'LEVEL_CONTROL_CLUSTER': ['level-control'], + 'LOW_POWER_CLUSTER': ['low-power-server'], + 'MEDIA_PLAYBACK_CLUSTER': ['media-playback-server'], + 'NETWORK_COMMISSIONING_CLUSTER': ['network-commissioning'], + 'OCCUPANCY_SENSING_CLUSTER': [], + 'ON_OFF_CLUSTER': ['on-off-server'], + 'OPERATIONAL_CREDENTIALS_CLUSTER': ['operational-credentials'], + 'OTA_BOOTLOAD_CLUSTER': [], + 'OTA_SERVER_CLUSTER': ['ota-server'], + 'OTA_CLIENT_CLUSTER': [], + 'POWER_CONFIG_CLUSTER': [], + 'SCENES_CLUSTER': ['scenes'], + 'TEMP_MEASUREMENT_CLUSTER': ['temperature-measurement-server'], + 'THERMOSTAT_CLUSTER': [], + 'WINDOW_COVERING_CLUSTER': [], + 'ZLL_COMMISSIONING_CLUSTER': [] +} + +# List of directories in src/app/clusters to build for client clusters. +CLIENT_CLUSTERS: typing.Dict[str, typing.List[str]] = { + 'ALARM_CLUSTER': [], + 'APPLICATION_BASIC_CLUSTER': [], + 'BARRIER_CONTROL_CLUSTER': [], + 'BASIC_CLUSTER': [], + 'BINDING_CLUSTER': [], + 'COLOR_CONTROL_CLUSTER': [], + 'COMMISSIONING_CLUSTER': [], + 'CONTENT_LAUNCH_CLUSTER': [], + 'DEVICE_TEMP_CLUSTER': [], + 'DESCRIPTOR_CLUSTER': [], + 'DOOR_LOCK_CLUSTER': [], + 'GENERAL_COMMISSIONING_CLUSTER': [], + 'GROUPS_CLUSTER': [], + 'GROUP_KEY_MANAGEMENT_CLUSTER': [], + 'IAS_ZONE_CLUSTER': ['ias-zone-client'], + 'IDENTIFY_CLUSTER': [], + 'LEVEL_CONTROL_CLUSTER': [], + 'LOW_POWER_CLUSTER': [], + 'MEDIA_PLAYBACK_CLUSTER': ['media-playback-client'], + 'NETWORK_COMMISSIONING_CLUSTER': [], + 'OCCUPANCY_SENSING_CLUSTER': [], + 'ON_OFF_CLUSTER': [], + 'OPERATIONAL_CREDENTIALS_CLUSTER': ['operational-credentials'], + 'OTA_BOOTLOAD_CLUSTER': [], + 'OTA_SERVER_CLUSTER': ['ota-server'], + 'OTA_CLIENT_CLUSTER': [], + 'POWER_CONFIG_CLUSTER': [], + 'SCENES_CLUSTER': [], + 'TEMP_MEASUREMENT_CLUSTER': [], + 'THERMOSTAT_CLUSTER': ['thermostat-client'], + 'WINDOW_COVERING_CLUSTER': [], + 'ZLL_COMMISSIONING_CLUSTER': [] +} + + +def get_cluster_sources(clusters: typing.Set[str], + source_map: typing.Dict[str, + typing.List[str]], side: str): + """Returns a list of cluster source directories for the given clusters. + + Returns: + The set of source directories to build. + """ + + cluster_sources: typing.Set[str] = set() + + for cluster in clusters: + if not cluster in source_map: + raise ValueError("Unhandled %s cluster: %s" % (side, cluster)) + + cluster_sources.update(source_map[cluster]) + + return cluster_sources + + +def dump_zapfile_clusters(zap_file_path: pathlib.Path): + """Prints all of the source directories to build for a given ZAP file. + + Arguments: + zap_file_path - Path to the ZAP input file. + """ + + client_clusters: typing.Set[str] = set() + server_clusters: typing.Set[str] = set() + + with open(zap_file_path, "r") as zap_file: + zap_json = json.loads(zap_file.read()) + + for endpoint_type in zap_json.get('endpointTypes'): + for cluster in endpoint_type.get('clusters'): + side: str = cluster.get('side') + if side == 'client': + clusters_set = client_clusters + elif side == 'server': + clusters_set = server_clusters + else: + raise ValueError("Invalid side for cluster: %s" % side) + + if cluster.get('enabled') == 1: + clusters_set.add(cluster.get('define')) + + cluster_sources: typing.Set[str] = set() + + cluster_sources.update( + get_cluster_sources(server_clusters, SERVER_CLUSTERS, 'server')) + + cluster_sources.update( + get_cluster_sources(client_clusters, CLIENT_CLUSTERS, 'client')) + + for cluster in sorted(cluster_sources): + print(cluster) + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument('--zap_file', + help='Path to .zap file', + type=pathlib.Path) + + args = parser.parse_args() + + dump_zapfile_clusters(args.zap_file) + + sys.exit(0) + + +if __name__ == '__main__': + main() diff --git a/src/darwin/Framework/CHIP/BUILD.gn b/src/darwin/Framework/CHIP/BUILD.gn index ec820f84366b9b..b3de6d3d94063b 100644 --- a/src/darwin/Framework/CHIP/BUILD.gn +++ b/src/darwin/Framework/CHIP/BUILD.gn @@ -65,16 +65,13 @@ static_library("framework") { } chip_data_model("darwin_data_model") { - cluster_sources = [ - "media-playback-client", - "network-commissioning", - ] + zap_file = "chip-tool.zap" zap_pregenerated_dir = "gen" - public_configs = [ ":darwin_config" ] - use_default_client_callbacks = true + + public_configs = [ ":darwin_config" ] } group("CHIP") {