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/account-login-server/account-login-server.cpp b/src/app/clusters/account-login-server/account-login-server.cpp deleted file mode 100644 index aec075453ea79b..00000000000000 --- a/src/app/clusters/account-login-server/account-login-server.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**************************************************************************** - * @file - * @brief Routines for the Application Launcher plugin, the - *server implementation of the Application Launcher cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -bool emberAfAccountLoginClusterGetSetupPINCallback(chip::app::Command * commandObj, unsigned char *) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} - -bool emberAfAccountLoginClusterLoginCallback(chip::app::Command * commandObj, unsigned char *, unsigned char *) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} diff --git a/src/app/clusters/application-launcher-server/application-launcher-server.cpp b/src/app/clusters/application-launcher-server/application-launcher-server.cpp deleted file mode 100644 index e5a1d804f7009a..00000000000000 --- a/src/app/clusters/application-launcher-server/application-launcher-server.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**************************************************************************** - * @file - * @brief Routines for the Application Launcher plugin, the - *server implementation of the Application Launcher cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -bool emberAfApplicationLauncherClusterLaunchAppCallback(chip::app::Command * commandObj, unsigned char *, unsigned char *) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} diff --git a/src/app/clusters/audio-output-server/audio-output-server.cpp b/src/app/clusters/audio-output-server/audio-output-server.cpp deleted file mode 100644 index f402937d001662..00000000000000 --- a/src/app/clusters/audio-output-server/audio-output-server.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**************************************************************************** - * @file - * @brief Routines for the Audio Output plugin, the - *server implementation of the Audio Output cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -bool emberAfAudioOutputClusterRenameOutputCallback(chip::app::Command * commandObj, unsigned char, unsigned char *) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} - -bool emberAfAudioOutputClusterSelectOutputCallback(chip::app::Command * commandObj, unsigned char) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} 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/ias-zone-client/ias-zone-client.cpp b/src/app/clusters/ias-zone-client/ias-zone-client.cpp deleted file mode 100644 index 66e065044f3d5b..00000000000000 --- a/src/app/clusters/ias-zone-client/ias-zone-client.cpp +++ /dev/null @@ -1,617 +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 * - * Client Operation: - * 1. Look for ZDO device announce notification. - * 2. Perform ZDO match descriptor on device. - * 3. If supports IAS Zone Server, Add that server - *to our known list. Write CIE Address. - * 4. Read CIE address, verify it is ours. This is - *done mostly because the test case requires it. - * 5. Read the IAS Zone Server attributes. - * Record in table. - * 6. When we get an enroll request, give them our - *(only) zone ID. - * 7. When we get a notification, read their - *attributes. - * - * Improvements that could be made: - * Add support for multiple endpoints on server. - *Most often this is a legacy security system - *retrofitted with a single ZigBee radio. Therefore - * each sensor is on a different endpoint. Right - *now our client only handles a single endpoint per - *node. - * - * Integration with Poll Control. When the device - *boots we should configure its polling to make it - *possible to read/write its attributes. - * - * Update the emberAfIasZoneClientKnownServers list - *when we know a server un-enrolls. Right now, we - *don't have any way to tell when we don't need to - *keep track of a server anymore, i.e., when it - *un-enrolls. Therefore, we could potentially keep - *adding servers to our known list, and run out of - *room to add more. Fortunately, we have two things - *working for us: - * 1. Servers will most likely stay around in a - *network. It is unlikely that an IAS Zone Client in - *production will have to handle 254 different - *servers. - * 2. If a server un-enrolls and then enrolls - *again, it will get the same Zone ID and have a spot - *in the list, since we store servers by long address. - ******************************************************************************* - ******************************************************************************/ - -#include "ias-zone-client.h" -#include "af.h" -#include - -//----------------------------------------------------------------------------- -// Globals - -IasZoneDevice emberAfIasZoneClientKnownServers[EMBER_AF_PLUGIN_IAS_ZONE_CLIENT_MAX_DEVICES]; - -typedef enum -{ - IAS_ZONE_CLIENT_STATE_NONE, - IAS_ZONE_CLIENT_STATE_DISCOVER_ENDPOINT, - IAS_ZONE_CLIENT_STATE_SET_CIE_ADDRESS, - IAS_ZONE_CLIENT_STATE_READ_CIE_ADDRESS, - IAS_ZONE_CLIENT_STATE_READ_ATTRIBUTES, -} IasZoneClientState; - -static IasZoneClientState iasZoneClientState = IAS_ZONE_CLIENT_STATE_NONE; -static uint8_t currentIndex = NO_INDEX; -static uint8_t myEndpoint = 0; - -EmberEventControl emberAfPluginIasZoneClientStateMachineEventControl; - -//----------------------------------------------------------------------------- -// Forward Declarations - -void readIasZoneServerAttributes(EmberNodeId nodeId); -static void iasClientSaveCommand(void); -static void iasClientLoadCommand(void); - -//----------------------------------------------------------------------------- -// Functions - -void emberAfIasZoneClusterClientInitCallback(EndpointId endpoint) -{ - emAfClearServers(); - myEndpoint = endpoint; - iasClientLoadCommand(); -} - -void emAfClearServers(void) -{ - MEMSET(emberAfIasZoneClientKnownServers, 0xFF, sizeof(IasZoneDevice) * EMBER_AF_PLUGIN_IAS_ZONE_CLIENT_MAX_DEVICES); -} - -static void clearState(void) -{ - currentIndex = 0; - iasZoneClientState = IAS_ZONE_CLIENT_STATE_NONE; -} - -static void setServerZoneStatus(uint8_t serverIndex, uint16_t zoneStatus) -{ - emberAfIasZoneClientKnownServers[serverIndex].zoneStatus = zoneStatus; - iasClientSaveCommand(); -} - -static void setServerIeee(uint8_t serverIndex, uint8_t * ieeeAddress) -{ - MEMCOPY(emberAfIasZoneClientKnownServers[serverIndex].ieeeAddress, ieeeAddress, EUI64_SIZE); - iasClientSaveCommand(); -} - -static void clearServerIeee(uint8_t serverIndex) -{ - MEMSET(emberAfIasZoneClientKnownServers[serverIndex].ieeeAddress, 0xFF, sizeof(IasZoneDevice)); - iasClientSaveCommand(); -} - -static void setServerNodeId(uint8_t serverIndex, EmberNodeId nodeId) -{ - emberAfIasZoneClientKnownServers[serverIndex].nodeId = nodeId; -} - -static void clearServerNodeId(uint8_t serverIndex) -{ - emberAfIasZoneClientKnownServers[serverIndex].nodeId = EMBER_NULL_NODE_ID; -} - -static void setServerZoneState(uint8_t serverIndex, uint8_t zoneState) -{ - emberAfIasZoneClientKnownServers[serverIndex].zoneState = zoneState; - iasClientSaveCommand(); -} - -static void setServerEndpoint(uint8_t serverIndex, EndpointId endpoint) -{ - emberAfIasZoneClientKnownServers[serverIndex].endpoint = endpoint; - iasClientSaveCommand(); -} - -static void setServerZoneType(uint8_t serverIndex, uint16_t zoneType) -{ - emberAfIasZoneClientKnownServers[serverIndex].zoneType = zoneType; - iasClientSaveCommand(); -} - -static void setServerZoneId(uint8_t serverIndex, uint16_t zoneId) -{ - emberAfIasZoneClientKnownServers[serverIndex].zoneId = zoneId; - iasClientSaveCommand(); -} - -static void setCurrentIndex(uint8_t serverIndex) -{ - currentIndex = serverIndex; - iasClientSaveCommand(); -} - -static void setIasZoneClientState(uint8_t clientState) -{ - iasZoneClientState = clientState; - iasClientSaveCommand(); -} - -static void iasClientSaveCommand(void) -{ -#if defined(EZSP_HOST) && !defined(EMBER_TEST) && defined(UNIX_HOST) - FILE * fp; - uint16_t i, j; - - // save zone server list - fp = fopen("iaszone.txt", "w"); - - for (i = 0; i < EMBER_AF_PLUGIN_IAS_ZONE_CLIENT_MAX_DEVICES; i++) - { - if (emberAfIasZoneClientKnownServers[i].zoneId != 0xFF) - { - fprintf(fp, "%x %x %x %x %x ", emberAfIasZoneClientKnownServers[i].zoneId, - emberAfIasZoneClientKnownServers[i].zoneStatus, emberAfIasZoneClientKnownServers[i].zoneState, - emberAfIasZoneClientKnownServers[i].endpoint, emberAfIasZoneClientKnownServers[i].zoneType); - for (j = 0; j < 8; j++) - { - fprintf(fp, "%x ", emberAfIasZoneClientKnownServers[i].ieeeAddress[j]); - } - } - } - // Write something to mark the end of the file. - fprintf(fp, "ff"); - int res = fclose(fp); - assert(res == 0); -#endif //#if defined(EZSP_HOST) && !defined(EMBER_TEST) && defined(UNIX_HOST) -} - -static void iasClientLoadCommand(void) -{ -#if defined(EZSP_HOST) && !defined(EMBER_TEST) && defined(UNIX_HOST) - FILE * fp; - uint16_t i, j; - - unsigned int data1, data2, data3, data4, data5; - - fp = fopen("iaszone.txt", "r"); - - if (!fp) - { - return; - } - - for (i = 0; i < EMBER_AF_PLUGIN_IAS_ZONE_CLIENT_MAX_DEVICES; i++) - { - if (feof(fp)) - { - break; - } - fscanf(fp, "%x ", &data1); - if (data1 == 0xff) - { - break; - } - fscanf(fp, "%x %x %x %x ", &data2, &data3, &data4, &data5); - - emberAfIasZoneClientKnownServers[i].zoneId = (uint8_t) data1; - emberAfIasZoneClientKnownServers[i].zoneStatus = (uint16_t) data2; - emberAfIasZoneClientKnownServers[i].zoneState = (uint8_t) data3; - emberAfIasZoneClientKnownServers[i].endpoint = (uint8_t) data4; - emberAfIasZoneClientKnownServers[i].zoneType = (uint16_t) data5; - - for (j = 0; j < 8; j++) - { - fscanf(fp, "%x ", &data1); - emberAfIasZoneClientKnownServers[i].ieeeAddress[j] = (uint8_t) data1; - } - } - int res = fclose(fp); - assert(res == 0); -#endif // #if defined(EZSP_HOST) && !defined(EMBER_TEST) && defined(UNIX_HOST) -} - -static uint8_t findIasZoneServerByIeee(uint8_t * ieeeAddress) -{ - uint8_t i; - for (i = 0; i < EMBER_AF_PLUGIN_IAS_ZONE_CLIENT_MAX_DEVICES; i++) - { - if (0 == memcmp(ieeeAddress, emberAfIasZoneClientKnownServers[i].ieeeAddress, EUI64_SIZE)) - { - return i; - } - } - return NO_INDEX; -} - -static uint8_t findIasZoneServerByNodeId(EmberNodeId nodeId) -{ - uint8_t i; - for (i = 0; i < EMBER_AF_PLUGIN_IAS_ZONE_CLIENT_MAX_DEVICES; i++) - { - if (nodeId == emberAfIasZoneClientKnownServers[i].nodeId) - { - return i; - } - } - - // If we didn't find the node ID in the table, see if the stack knows about - // it. - EmberEUI64 eui64; - if (emberLookupEui64ByNodeId(nodeId, eui64) == EMBER_SUCCESS) - { - i = findIasZoneServerByIeee(eui64); - if (i != NO_INDEX) - { - setServerNodeId(i, nodeId); - } - } - - return i; -} - -bool emberAfIasZoneClusterZoneStatusChangeNotificationCallback(chip::app::Command * commandObj, uint16_t zoneStatus, - uint8_t extendedStatus, uint8_t zoneId, uint16_t delay) -{ - uint8_t serverIndex = findIasZoneServerByNodeId(emberAfCurrentCommand()->source); - uint8_t status = EMBER_ZCL_STATUS_NOT_FOUND; - if (serverIndex != NO_INDEX) - { - status = EMBER_ZCL_STATUS_SUCCESS; - setServerZoneStatus(serverIndex, zoneStatus); - - emberAfIasZoneClusterPrintln("Zone %d status change, 0x%2X from 0x%2X", zoneId, zoneStatus, - emberAfCurrentCommand()->source); - - // The Test case calls for readding attributes after status change. - // that is silly for the production device. - // readIasZoneServerAttributes(emberAfCurrentCommand()->source); - } - emberAfSendDefaultResponse(emberAfCurrentCommand(), status); - return true; -} - -bool emberAfIasZoneClusterZoneEnrollRequestCallback(chip::app::Command * commandObj, uint16_t zoneType, uint16_t manufacturerCode) -{ - EmberAfIasEnrollResponseCode responseCode = EMBER_ZCL_IAS_ENROLL_RESPONSE_CODE_NO_ENROLL_PERMIT; - uint8_t zoneId = UNKNOWN_ZONE_ID; - uint8_t serverIndex = findIasZoneServerByNodeId(emberAfCurrentCommand()->source); - EmberStatus status; - - if (serverIndex != NO_INDEX) - { - responseCode = EMBER_ZCL_IAS_ENROLL_RESPONSE_CODE_SUCCESS; - zoneId = serverIndex; - setServerZoneId(serverIndex, zoneId); - } - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER), ZCL_IAS_ZONE_CLUSTER_ID, - ZCL_ZONE_ENROLL_RESPONSE_COMMAND_ID, "uu", responseCode, zoneId); - // Need to send this command with our source EUI because the server will - // check our EUI64 against his CIE Address to see if we're his CIE. - emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64; - status = emberAfSendResponse(); - emberAfCorePrintln("Sent enroll response with responseCode: 0x%X, zoneId: 0x%X, status: 0x%X", responseCode, zoneId, status); - return true; -} - -void emberAfPluginIasZoneClientStateMachineEventHandler(void) -{ - emberAfIasZoneClusterPrintln("IAS Zone Client Timeout waiting for message response."); - emberEventControlSetInactive(emberAfPluginIasZoneClientStateMachineEventControl); - clearState(); -} - -static uint8_t addServer(EmberNodeId nodeId, uint8_t * ieeeAddress) -{ - uint8_t i = findIasZoneServerByIeee(ieeeAddress); - if (i != NO_INDEX) - { - return i; - } - - for (i = 0; i < EMBER_AF_PLUGIN_IAS_ZONE_CLIENT_MAX_DEVICES; i++) - { - const uint8_t unsetEui64[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - if (0 == memcmp(emberAfIasZoneClientKnownServers[i].ieeeAddress, unsetEui64, EUI64_SIZE)) - { - setServerIeee(i, ieeeAddress); - setServerNodeId(i, nodeId); - setServerEndpoint(i, UNKNOWN_ENDPOINT); - return i; - } - } - return NO_INDEX; -} - -static void removeServer(uint8_t * ieeeAddress) -{ - uint8_t index = findIasZoneServerByIeee(ieeeAddress); - clearServerIeee(index); - clearServerNodeId(index); -} - -static EmberStatus sendCommand(EmberNodeId destAddress) -{ - emberAfSetCommandEndpoints(myEndpoint, emberAfIasZoneClientKnownServers[currentIndex].endpoint); - EmberStatus status = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, destAddress); - emberAfIasZoneClusterPrintln("Sent IAS Zone Client Command to 0x%2X (%d -> %d) status: 0x%X", destAddress, myEndpoint, - emberAfIasZoneClientKnownServers[currentIndex].endpoint, status); - if (status != EMBER_SUCCESS) - { - clearState(); - } - return status; -} - -static void setCieAddress(EmberNodeId destAddress) -{ - uint8_t writeAttributes[] = { - EMBER_LOW_BYTE(ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID), - EMBER_HIGH_BYTE(ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID), - ZCL_IEEE_ADDRESS_ATTRIBUTE_TYPE, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, // ieee (filled in later) - }; - emberAfGetEui64(&writeAttributes[3]); - emberAfFillExternalBuffer((ZCL_GLOBAL_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER), ZCL_IAS_ZONE_CLUSTER_ID, - ZCL_WRITE_ATTRIBUTES_COMMAND_ID, "b", writeAttributes, sizeof(writeAttributes)); - emberAfIasZoneClusterPrintln("Writing CIE Address to IAS Zone Server"); - if (EMBER_SUCCESS == sendCommand(destAddress)) - { - setIasZoneClientState(IAS_ZONE_CLIENT_STATE_SET_CIE_ADDRESS); - } -} - -static void iasZoneClientServiceDiscoveryCallback(const EmberAfServiceDiscoveryResult * result) -{ - if (result->status == EMBER_AF_UNICAST_SERVICE_DISCOVERY_COMPLETE_WITH_RESPONSE && - result->zdoRequestClusterId == MATCH_DESCRIPTORS_REQUEST) - { - const EmberAfEndpointList * endpointList = (const EmberAfEndpointList *) result->responseData; - if (endpointList->count > 0) - { - setServerEndpoint(currentIndex, endpointList->list[0]); - emberAfIasZoneClusterPrintln("Device 0x%2X supports IAS Zone Server", result->matchAddress); - setCieAddress(result->matchAddress); - return; - } - } - clearState(); -} - -static void checkForIasZoneServer(EmberNodeId emberNodeId, uint8_t * ieeeAddress) -{ - uint8_t endpointIndex = emberAfIndexFromEndpoint(myEndpoint); - uint8_t serverIndex = addServer(emberNodeId, ieeeAddress); - - if (serverIndex == NO_INDEX) - { - emberAfIasZoneClusterPrintln("Error: Could not add IAS Zone server."); - return; - } - - setCurrentIndex(serverIndex); - - if (emberAfIasZoneClientKnownServers[serverIndex].endpoint != UNKNOWN_ENDPOINT) - { - // If a remote endpoint that you have already seen announces itself, - // write your IEEE in them just in case they left and are rejoining. --agkeesle - // Bug: EMAPPFWKV2-1078 - setCieAddress(emberNodeId); - emberAfIasZoneClusterPrintln("Node 0x%2X already known to IAS client", emberNodeId); - return; - } - - EmberStatus status = emberAfFindDevicesByCluster(emberNodeId, ZCL_IAS_ZONE_CLUSTER_ID, - true, // server cluster? - iasZoneClientServiceDiscoveryCallback); - - if (status != EMBER_SUCCESS) - { - emberAfIasZoneClusterPrintln("Error: Failed to initiate service discovery for IAS Zone Server 0x%2X", emberNodeId); - clearState(); - } -} - -void emberAfPluginIasZoneClientZdoMessageReceivedCallback(EmberNodeId emberNodeId, EmberApsFrame * apsFrame, uint8_t * message, - uint16_t length) -{ - emberAfIasZoneClusterPrintln("Incoming ZDO, Cluster: 0x%2X", apsFrame->clusterId); - if (apsFrame->clusterId == END_DEVICE_ANNOUNCE) - { - checkForIasZoneServer(emberNodeId, &(message[3])); - } -} - -void readIasZoneServerAttributes(EmberNodeId nodeId) -{ - uint8_t iasZoneAttributeIds[] = { - EMBER_LOW_BYTE(ZCL_ZONE_STATE_ATTRIBUTE_ID), EMBER_HIGH_BYTE(ZCL_ZONE_STATE_ATTRIBUTE_ID), - - EMBER_LOW_BYTE(ZCL_ZONE_TYPE_ATTRIBUTE_ID), EMBER_HIGH_BYTE(ZCL_ZONE_TYPE_ATTRIBUTE_ID), - - EMBER_LOW_BYTE(ZCL_ZONE_STATUS_ATTRIBUTE_ID), EMBER_HIGH_BYTE(ZCL_ZONE_STATUS_ATTRIBUTE_ID), - }; - emberAfFillExternalBuffer((ZCL_GLOBAL_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER), ZCL_IAS_ZONE_CLUSTER_ID, - ZCL_READ_ATTRIBUTES_COMMAND_ID, "b", iasZoneAttributeIds, sizeof(iasZoneAttributeIds)); - if (EMBER_SUCCESS == sendCommand(nodeId)) - { - setIasZoneClientState(IAS_ZONE_CLIENT_STATE_READ_ATTRIBUTES); - } -} - -void readIasZoneServerCieAddress(EmberNodeId nodeId) -{ - uint8_t iasZoneAttributeIds[] = { - EMBER_LOW_BYTE(ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID), - EMBER_HIGH_BYTE(ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID), - }; - emberAfFillExternalBuffer((ZCL_GLOBAL_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER), ZCL_IAS_ZONE_CLUSTER_ID, - ZCL_READ_ATTRIBUTES_COMMAND_ID, "b", iasZoneAttributeIds, sizeof(iasZoneAttributeIds)); - if (EMBER_SUCCESS == sendCommand(nodeId)) - { - setIasZoneClientState(IAS_ZONE_CLIENT_STATE_READ_CIE_ADDRESS); - } -} - -void emberAfPluginIasZoneClientWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - if (clusterId == ZCL_IAS_ZONE_CLUSTER_ID && iasZoneClientState == IAS_ZONE_CLIENT_STATE_SET_CIE_ADDRESS && - buffer[0] == EMBER_ZCL_STATUS_SUCCESS) - { - readIasZoneServerCieAddress(emberAfCurrentCommand()->source); - return; - } - return; -} - -void emberAfPluginIasZoneClientReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - uint8_t zoneStatus, zoneType, zoneState; - if (clusterId == ZCL_IAS_ZONE_CLUSTER_ID && - (iasZoneClientState == IAS_ZONE_CLIENT_STATE_READ_ATTRIBUTES || - iasZoneClientState == IAS_ZONE_CLIENT_STATE_READ_CIE_ADDRESS)) - { - uint16_t i = 0; - while ((i + 3) <= bufLen) - { // 3 to insure we can read at least the attribute ID - // and the status - AttributeId attributeId = buffer[i] + (buffer[i + 1] << 8); - uint8_t status = buffer[i + 2]; - i += 3; - // emberAfIasZoneClusterPrintln("Parsing Attribute 0x%2X, Status: 0x%X", attributeId, status); - if (status == EMBER_ZCL_STATUS_SUCCESS) - { - if ((i + 1) > bufLen) - { - // Too short, dump the message. - return; - } - i++; // skip the type of the attribute. We already know what it should be. - switch (attributeId) - { - case ZCL_ZONE_STATUS_ATTRIBUTE_ID: - if ((i + 2) > bufLen) - { - // Too short, dump the message. - return; - } - zoneStatus = (buffer[i] + (buffer[i + 1] << 8)); - setServerZoneStatus(currentIndex, zoneStatus); - i += 2; - break; - case ZCL_ZONE_TYPE_ATTRIBUTE_ID: - if ((i + 2) > bufLen) - { - // Too short, dump the message. - return; - } - zoneType = (buffer[i] + (buffer[i + 1] << 8)); - setServerZoneType(currentIndex, zoneType); - i += 2; - break; - case ZCL_ZONE_STATE_ATTRIBUTE_ID: - if ((i + 1) > bufLen) - { - // Too short, dump the message - return; - } - zoneState = buffer[i]; - setServerZoneState(currentIndex, zoneState); - i++; - break; - case ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID: { - uint8_t myIeee[EUI64_SIZE]; - emberAfGetEui64(myIeee); - if ((i + 8) > bufLen) - { - // Too short, dump the message - } - else if (0 != memcmp(&(buffer[i]), myIeee, EUI64_SIZE)) - { - emberAfIasZoneClusterPrintln("CIE Address not set to mine, removing IAS zone server."); - removeServer(&(buffer[i])); - clearState(); - } - else - { - readIasZoneServerAttributes(emberAfCurrentCommand()->source); - } - return; - } - } - } - } - emberAfIasZoneClusterPrintln("Retrieved IAS Zone Server attributes from 0x%2X", emberAfCurrentCommand()->source); - clearState(); - } -} - -void emberAfPluginIasZoneClientZdoCallback(EmberNodeId emberNodeId, EmberApsFrame * apsFrame, uint8_t * message, uint16_t length) {} - -void emberAfPluginIasZoneClientWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) {} - -void emberAfPluginIasZoneClientReadAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) {} diff --git a/src/app/clusters/identify-client/identify-client.cpp b/src/app/clusters/identify-client/identify-client.cpp deleted file mode 100644 index f28b4f12b828c3..00000000000000 --- a/src/app/clusters/identify-client/identify-client.cpp +++ /dev/null @@ -1,35 +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 Identify Client plugin, the - * client implementation of the Identify cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -using namespace chip; - -bool emberAfIdentifyClusterIdentifyQueryResponseCallback(chip::app::Command * commandObj, uint16_t timeout) -{ - emberAfIdentifyClusterPrintln("RX: IdentifyQueryResponse 0x%4x", timeout); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} diff --git a/src/app/clusters/keypad-input-server/keypad-input-server.cpp b/src/app/clusters/keypad-input-server/keypad-input-server.cpp deleted file mode 100644 index 628ae1028d487a..00000000000000 --- a/src/app/clusters/keypad-input-server/keypad-input-server.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**************************************************************************** - * @file - * @brief Routines for the Keypad Input plugin, the - *server implementation of the Keypad Input cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -bool emberAfKeypadInputClusterSendKeyCallback(chip::app::Command * commandObj, unsigned char) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} diff --git a/src/app/clusters/media-input-server/media-input-server.cpp b/src/app/clusters/media-input-server/media-input-server.cpp deleted file mode 100644 index eab681a12d3d2d..00000000000000 --- a/src/app/clusters/media-input-server/media-input-server.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/** - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**************************************************************************** - * @file - * @brief Routines for the Media Input plugin, the - *server implementation of the Media Input cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -bool emberAfMediaInputClusterSelectInputCallback(chip::app::Command * commandObj, unsigned char) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} -bool emberAfMediaInputClusterHideInputStatusCallback(chip::app::Command * commandObj) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} - -bool emberAfMediaInputClusterRenameInputCallback(chip::app::Command * commandObj, unsigned char, unsigned char *) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} - -bool emberAfMediaInputClusterShowInputStatusCallback(chip::app::Command * commandObj) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} diff --git a/src/app/clusters/messaging-client/messaging-client.cpp b/src/app/clusters/messaging-client/messaging-client.cpp deleted file mode 100644 index 504b1168b76580..00000000000000 --- a/src/app/clusters/messaging-client/messaging-client.cpp +++ /dev/null @@ -1,340 +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 Messaging Client plugin, - *which implements the client side of the Messaging - *cluster. - ******************************************************************************* - ******************************************************************************/ - -#include "messaging-client.h" -#include "../../include/af.h" -#include "../../util/common.h" - -#include "app/framework/plugin/esi-management/esi-management.h" -#include - -static EmberAfPluginMessagingClientMessage messageTable[EMBER_AF_MESSAGING_CLUSTER_CLIENT_ENDPOINT_COUNT]; - -#define MESSAGE_CONTROL_INTER_PAN_TRANSMISSION_ONLY (0x2) -/** - * The callback function passed to the ESI management plugin. It handles - * ESI entry deletions. - */ -static void esiDeletionCallback(uint8_t esiIndex) -{ - uint8_t i; - for (i = 0; i < EMBER_AF_MESSAGING_CLUSTER_CLIENT_ENDPOINT_COUNT; i++) - { - messageTable[i].esiBitmask &= ~EMBER_BIT(esiIndex); - } -} - -void emberAfMessagingClusterClientInitCallback(EndpointId endpoint) -{ - emAfPluginMessagingClientClearMessage(endpoint); - // Subscribing for ESI Management plugin deletion announcements. - emberAfPluginEsiManagementSubscribeToDeletionAnnouncements(esiDeletionCallback); -} - -void emAfPluginMessagingClientClearMessage(EndpointId endpoint) -{ - uint8_t ep = emberAfFindClusterClientEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - if (ep != 0xFF) - { - messageTable[ep].valid = false; - messageTable[ep].active = false; - messageTable[ep].messageId = 0x00000000UL; - messageTable[ep].messageControl = 0x00; - messageTable[ep].startTime = 0x00000000UL; - messageTable[ep].endTime = 0x00000000UL; - messageTable[ep].durationInMinutes = 0x0000; - messageTable[ep].esiBitmask = 0; - messageTable[ep].message[0] = 0; - } -} - -void emberAfMessagingClusterClientTickCallback(EndpointId endpoint) -{ - uint8_t ep = emberAfFindClusterClientEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - - if (ep == 0xFF) - { - return; - } - - // The tick is used to deactivate messages that are active or to activate - // messages that are inactive. So, first, just flip the active state and - // notify the application of the change. - messageTable[ep].active = !messageTable[ep].active; - if (messageTable[ep].active) - { - emberAfPluginMessagingClientDisplayMessageCallback(&messageTable[ep]); - } - else - { - emberAfPluginMessagingClientCancelMessageCallback(&messageTable[ep]); - } - - // If the new state is active and the duration is not "until changed," then we - // have to schedule a tick to deactivate the message after the duration has - // elapsed. Otherwise, cancel the tick because no further processing is - // required as either the message is no longer active or it will live until - // changed. - if (messageTable[ep].active && (messageTable[ep].durationInMinutes != ZCL_MESSAGING_CLUSTER_DURATION_UNTIL_CHANGED)) - { - emberAfScheduleClientTick(endpoint, ZCL_MESSAGING_CLUSTER_ID, - ((messageTable[ep].endTime - messageTable[ep].startTime) * MILLISECOND_TICKS_PER_SECOND)); - } -} - -bool emberAfMessagingClusterDisplayMessageCallback(chip::app::Command * commandObj, uint32_t messageId, uint8_t messageControl, - uint32_t startTime, uint16_t durationInMinutes, uint8_t * msg, - uint8_t optionalExtendedMessageControl) -{ - EndpointId endpoint = emberAfCurrentEndpoint(); - uint8_t ep = emberAfFindClusterClientEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - uint32_t now = emberAfGetCurrentTime(); - uint8_t esiIndex = emberAfPluginEsiManagementUpdateEsiAndGetIndex(emberAfCurrentCommand()); - - emberAfMessagingClusterPrint("RX: DisplayMessage" - " 0x%4x, 0x%x, 0x%4x, 0x%2x, \"", - messageId, messageControl, startTime, durationInMinutes); - emberAfMessagingClusterPrintString(msg); - emberAfMessagingClusterPrintln("\""); - - if (emberAfPluginMessagingClientPreDisplayMessageCallback(messageId, messageControl, startTime, durationInMinutes, msg, - optionalExtendedMessageControl)) - { - goto kickout; - } - - if (ep == 0xFF) - { - return false; - } - - // Use of Inter-PAN transmission is deprecated. - if ((messageControl & 0x03) == MESSAGE_CONTROL_INTER_PAN_TRANSMISSION_ONLY) - { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_INVALID_FIELD); - return true; - } - - if (messageTable[ep].active) - { - // First check whether it is a duplicate message - if (messageId == messageTable[ep].messageId) - { - // Duplicate message from a different ESI, add the ESI to the bitmask - if (esiIndex < EMBER_AF_PLUGIN_ESI_MANAGEMENT_ESI_TABLE_SIZE && - (messageTable[ep].esiBitmask & EMBER_BIT(esiIndex)) == 0) - { - messageTable[ep].esiBitmask |= EMBER_BIT(esiIndex); - } - // Either way, we send back a default response. - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; - } - else - { - // If we already have another message, notify the application that it - // should no longer display it. - messageTable[ep].active = false; - emberAfPluginMessagingClientCancelMessageCallback(&messageTable[ep]); - emberAfDeactivateClientTick(emberAfCurrentEndpoint(), ZCL_MESSAGING_CLUSTER_ID); - } - } - - if (esiIndex < EMBER_AF_PLUGIN_ESI_MANAGEMENT_ESI_TABLE_SIZE) - { - messageTable[ep].esiBitmask = EMBER_BIT(esiIndex); - } - - messageTable[ep].clientEndpoint = emberAfCurrentCommand()->apsFrame->destinationEndpoint; - messageTable[ep].messageId = messageId; - messageTable[ep].messageControl = messageControl; - messageTable[ep].startTime = (startTime == ZCL_MESSAGING_CLUSTER_START_TIME_NOW ? now : startTime); - messageTable[ep].endTime = - (durationInMinutes == ZCL_MESSAGING_CLUSTER_DURATION_UNTIL_CHANGED ? ZCL_MESSAGING_CLUSTER_END_TIME_NEVER - : messageTable[ep].startTime + durationInMinutes * 60); - messageTable[ep].durationInMinutes = durationInMinutes; - emberAfCopyString(messageTable[ep].message, msg, EMBER_AF_PLUGIN_MESSAGING_CLIENT_MESSAGE_SIZE); - - if (messageTable[ep].startTime <= now) - { - if (messageTable[ep].durationInMinutes == ZCL_MESSAGING_CLUSTER_DURATION_UNTIL_CHANGED) - { - // If a message starts in the past and the duration is "until changed," it - // gets marked as active and no tick is scheduled becaues the message will - // live until we receive a new message or a cancel command. - messageTable[ep].active = true; - emberAfPluginMessagingClientDisplayMessageCallback(&messageTable[ep]); - } - else if (messageTable[ep].endTime > now) - { - // If a message starts in the past and the duration has not elapsed, it - // gets marked as active and a tick is scheduled for the time remaining in - // the duration to wake us up and mark the message as inactive. - messageTable[ep].active = true; - emberAfPluginMessagingClientDisplayMessageCallback(&messageTable[ep]); - emberAfScheduleClientTick(emberAfCurrentEndpoint(), ZCL_MESSAGING_CLUSTER_ID, - ((messageTable[ep].endTime - now) * MILLISECOND_TICKS_PER_SECOND)); - } - else - { - // Finally, if a message starts in the past and the duration has elapsed, - // it gets marked as inactive and no tick is scheduled because no further - // processing is needed. - messageTable[ep].active = false; - } - } - else - { - // If a message starts in the future, it gets marked as inactive and a tick - // is scheduled to wake us up at startTime to mark the message as active. - messageTable[ep].active = false; - emberAfScheduleClientTick(emberAfCurrentEndpoint(), ZCL_MESSAGING_CLUSTER_ID, - ((messageTable[ep].startTime - now) * MILLISECOND_TICKS_PER_SECOND)); - } - - // Once we receive a message, the data in the structure becomes valid and - // remains valid forever. When the message expires or is canceled, it gets - // marked as inactive, but stays valid. This allows the application to - // display or confirm old messages. - messageTable[ep].valid = true; - - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); -kickout: - return true; -} - -bool emberAfMessagingClusterCancelMessageCallback(chip::app::Command * commandObj, uint32_t messageId, uint8_t messageControl) -{ - EndpointId endpoint = emberAfCurrentEndpoint(); - uint8_t ep = emberAfFindClusterClientEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - EmberAfStatus status; - - if (ep == 0xFF) - { - return false; - } - - emberAfMessagingClusterPrintln("RX: CancelMessage 0x%4x, 0x%x", messageId, messageControl); - - if (messageTable[ep].active && messageTable[ep].messageId == messageId) - { - messageTable[ep].active = false; - messageTable[ep].messageControl = messageControl; - emberAfPluginMessagingClientCancelMessageCallback(&messageTable[ep]); - emberAfDeactivateClientTick(emberAfCurrentEndpoint(), ZCL_MESSAGING_CLUSTER_ID); - status = EMBER_ZCL_STATUS_SUCCESS; - } - else - { - status = EMBER_ZCL_STATUS_NOT_FOUND; - } - - emberAfSendImmediateDefaultResponse(status); - return true; -} - -void emAfPluginMessagingClientPrintInfo(EndpointId endpoint) -{ - uint8_t ep = emberAfFindClusterClientEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - - if (ep == 0xFF) - { - return; - } - - emberAfMessagingClusterPrintln("= Client Message ="); - emberAfMessagingClusterFlush(); - - emberAfMessagingClusterPrintln(" vld: %p", (messageTable[ep].valid ? "YES" : "NO")); - emberAfMessagingClusterPrintln(" act: %p", (messageTable[ep].active ? "YES" : "NO")); - emberAfMessagingClusterPrintln(" id: 0x%4x", messageTable[ep].messageId); - emberAfMessagingClusterPrintln(" mc: 0x%x", messageTable[ep].messageControl); - emberAfMessagingClusterPrintln(" st: 0x%4x", messageTable[ep].startTime); - emberAfMessagingClusterPrintln(" et: 0x%4x", messageTable[ep].endTime); - emberAfMessagingClusterPrintln("time: 0x%4x", emberAfGetCurrentTime()); - emberAfMessagingClusterPrintln(" dur: 0x%2x", messageTable[ep].durationInMinutes); - emberAfMessagingClusterFlush(); - emberAfMessagingClusterPrint(" mes: \""); - emberAfMessagingClusterPrintString(messageTable[ep].message); - emberAfMessagingClusterPrintln("\""); - emberAfMessagingClusterFlush(); -} - -EmberAfStatus emberAfPluginMessagingClientConfirmMessage(EndpointId endpoint) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_NOT_FOUND; - uint8_t ep = emberAfFindClusterClientEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - uint8_t i; - - if (ep == 0xFF) - { - return EMBER_ZCL_STATUS_FAILURE; - } - - if (messageTable[ep].valid && messageTable[ep].active) - { - for (i = 0; i < EMBER_AF_PLUGIN_ESI_MANAGEMENT_ESI_TABLE_SIZE; i++) - { - EmberAfPluginEsiManagementEsiEntry * esiEntry = emberAfPluginEsiManagementEsiLookUpByIndex(i); - EmberNodeId nodeId; - if ((messageTable[ep].esiBitmask & EMBER_BIT(i)) == 0 || esiEntry == NULL) - { - continue; - } - - nodeId = emberLookupNodeIdByEui64(esiEntry->eui64); - - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_CLIENT_TO_SERVER), ZCL_MESSAGING_CLUSTER_ID, - ZCL_MESSAGE_CONFIRMATION_COMMAND_ID, "wwus", messageTable[ep].messageId, - emberAfGetCurrentTime(), 0x00, ""); - // The source and destination are reversed for the confirmation. - emberAfSetCommandEndpoints(messageTable[ep].clientEndpoint, esiEntry->endpoint); - status = ((emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, nodeId) == EMBER_SUCCESS) ? EMBER_ZCL_STATUS_SUCCESS - : EMBER_ZCL_STATUS_FAILURE); - } - } - else - { - emberAfMessagingClusterPrintln("Err: No Valid Msg"); - } - return status; -} diff --git a/src/app/clusters/messaging-server/messaging-server.cpp b/src/app/clusters/messaging-server/messaging-server.cpp deleted file mode 100644 index e5ad2086aa59b6..00000000000000 --- a/src/app/clusters/messaging-server/messaging-server.cpp +++ /dev/null @@ -1,256 +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 Messaging Server plugin, - *which implements the server side of the Messaging - *cluster. - ******************************************************************************* - ******************************************************************************/ - -#include "messaging-server.h" -#include "../../include/af.h" -#include - -using namespace chip; - -// The internal message is stored in the same structure type that is defined -// publicly. The internal state of the message is stored in the -// messageStatusControl field -static EmberAfPluginMessagingServerMessage msgTable[EMBER_AF_MESSAGING_CLUSTER_SERVER_ENDPOINT_COUNT]; - -// These bits are used by the messageStatusControl to indicate whether or not -// a message is valid, active, or if it is a "send now" message -#define VALID EMBER_BIT(0) -#define ACTIVE EMBER_BIT(1) -#define NOW EMBER_BIT(2) - -#define messageIsValid(ep) (msgTable[ep].messageStatusControl & VALID) -#define messageIsActive(ep) (msgTable[ep].messageStatusControl & ACTIVE) -#define messageIsNow(ep) (msgTable[ep].messageStatusControl & NOW) -#define messageIsForever(ep) (msgTable[ep].durationInMinutes == ZCL_MESSAGING_CLUSTER_DURATION_UNTIL_CHANGED) -static bool messageIsCurrentOrScheduled(EndpointId endpoint) -{ - uint8_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - - if (ep == 0xFF) - { - return false; - } - - return (messageIsValid(ep) && messageIsActive(ep) && - (messageIsForever(ep) || - (emberAfGetCurrentTime() < msgTable[ep].startTime + (uint32_t) msgTable[ep].durationInMinutes * 60))); -} - -void emberAfMessagingClusterServerInitCallback(EndpointId endpoint) -{ - uint8_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - - if (ep == 0xFF) - { - return; - } - - msgTable[ep].messageStatusControl &= ~VALID; -} - -bool emberAfMessagingClusterGetLastMessageCallback(chip::app::Command * commandObj) -{ - EndpointId endpoint = emberAfCurrentEndpoint(); - EmberAfPluginMessagingServerMessage message; - emberAfMessagingClusterPrintln("RX: GetLastMessage"); - if (emberAfPluginMessagingServerGetMessage(endpoint, &message)) - { - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_MESSAGING_CLUSTER_ID, - ZCL_DISPLAY_MESSAGE_COMMAND_ID, "wuwvsu", message.messageId, message.messageControl, - message.startTime, message.durationInMinutes, message.message, message.extendedMessageControl); - emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64; - emberAfSendResponse(); - } - else - { - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_NOT_FOUND); - } - return true; -} - -#if defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_0) || defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_1B) || \ - defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_0) || defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_1) || \ - defined(EMBER_AF_HAS_SPEC_VERSIONS_SE_1_1A) -bool emberAfMessagingClusterMessageConfirmationCallback(chip::app::Command * commandObj, uint32_t messageId, - uint32_t confirmationTime) -#else -bool emberAfMessagingClusterMessageConfirmationCallback(chip::app::Command * commandObj, uint32_t messageId, - uint32_t confirmationTime, uint8_t messageConfirmationControl, - uint8_t * messageResponse) -#endif -{ - emberAfMessagingClusterPrintln("RX: MessageConfirmation 0x%4x, 0x%4x", messageId, confirmationTime); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} - -bool emberAfPluginMessagingServerGetMessage(EndpointId endpoint, EmberAfPluginMessagingServerMessage * message) -{ - uint8_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - - if (ep == 0xFF) - { - return false; - } - - MEMMOVE(message, &msgTable[ep], sizeof(EmberAfPluginMessagingServerMessage)); - - // Clear out our internal bits from the message control. - message->messageStatusControl &= ~ZCL_MESSAGING_CLUSTER_RESERVED_MASK; - - // If the message is expired or it has an absolute time, set the start time - // and duration to the original start time and duration. For "start now" - // messages that are current or scheduled, set the start time to the special - // value for "now" and set the duration to the remaining time, if it is not - // already the special value for "until changed." - if (messageIsCurrentOrScheduled(endpoint) && messageIsNow(ep)) - { - message->startTime = ZCL_MESSAGING_CLUSTER_START_TIME_NOW; - if (!messageIsForever(ep)) - { - message->durationInMinutes -= ((emberAfGetCurrentTime() - msgTable[ep].startTime) / 60); - } - } - return messageIsCurrentOrScheduled(endpoint); -} - -void emberAfPluginMessagingServerSetMessage(EndpointId endpoint, const EmberAfPluginMessagingServerMessage * message) -{ - uint8_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - - if (ep == 0xFF) - { - return; - } - - if (message == NULL) - { - msgTable[ep].messageStatusControl &= ~ACTIVE; - return; - } - - MEMMOVE(&msgTable[ep], message, sizeof(EmberAfPluginMessagingServerMessage)); - - // Rember if this is a "start now" message, but store the start time as the - // current time so the duration can be adjusted. - if (msgTable[ep].startTime == ZCL_MESSAGING_CLUSTER_START_TIME_NOW) - { - msgTable[ep].messageStatusControl |= NOW; - msgTable[ep].startTime = emberAfGetCurrentTime(); - } - else - { - msgTable[ep].messageStatusControl &= ~NOW; - } - - msgTable[ep].messageStatusControl |= (VALID | ACTIVE); -} - -void emAfPluginMessagingServerPrintInfo(EndpointId endpoint) -{ - uint8_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_MESSAGING_CLUSTER_ID); - - if (ep == 0xFF) - { - return; - } - - emberAfMessagingClusterPrintln("= Server Message ="); - emberAfMessagingClusterFlush(); - - emberAfMessagingClusterPrintln(" vld: %s", (messageIsValid(ep) ? "YES" : "NO")); - emberAfMessagingClusterPrintln(" act: %s", (messageIsCurrentOrScheduled(endpoint) ? "YES" : "NO")); - emberAfMessagingClusterPrintln(" id: 0x%4x", msgTable[ep].messageId); - emberAfMessagingClusterPrintln(" mc: 0x%x", (msgTable[ep].messageControl & ~ZCL_MESSAGING_CLUSTER_RESERVED_MASK)); - emberAfMessagingClusterPrintln(" st: 0x%4x", msgTable[ep].startTime); - emberAfMessagingClusterPrintln(" now: %s", (messageIsNow(ep) ? "YES" : "NO")); - emberAfMessagingClusterPrintln("time: 0x%4x", emberAfGetCurrentTime()); - emberAfMessagingClusterPrintln(" dur: 0x%2x", msgTable[ep].durationInMinutes); - emberAfMessagingClusterFlush(); - emberAfMessagingClusterPrint(" mes: \""); - emberAfMessagingClusterPrintString(msgTable[ep].message); - emberAfMessagingClusterPrintln("\""); - emberAfMessagingClusterFlush(); -} - -void emberAfPluginMessagingServerDisplayMessage(EmberNodeId nodeId, uint8_t srcEndpoint, uint8_t dstEndpoint) -{ - EmberStatus status; - EmberAfPluginMessagingServerMessage message; - if (!emberAfPluginMessagingServerGetMessage(srcEndpoint, &message)) - { - emberAfMessagingClusterPrintln("invalid msg"); - return; - } - - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_MESSAGING_CLUSTER_ID, - ZCL_DISPLAY_MESSAGE_COMMAND_ID, "wuwvsu", message.messageId, message.messageControl, - message.startTime, message.durationInMinutes, message.message, message.extendedMessageControl); - emberAfSetCommandEndpoints(srcEndpoint, dstEndpoint); - emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64; - status = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, nodeId); - if (status != EMBER_SUCCESS) - { - emberAfMessagingClusterPrintln("Error in display %x", status); - } -} - -void emberAfPluginMessagingServerCancelMessage(EmberNodeId nodeId, uint8_t srcEndpoint, uint8_t dstEndpoint) -{ - EmberStatus status; - EmberAfPluginMessagingServerMessage message; - - // Nullify the current message before sending the cancellation. - emberAfPluginMessagingServerSetMessage(srcEndpoint, NULL); - - // Then send the response - emberAfPluginMessagingServerGetMessage(srcEndpoint, &message); - - emberAfFillExternalBuffer((ZCL_CLUSTER_SPECIFIC_COMMAND | ZCL_FRAME_CONTROL_SERVER_TO_CLIENT), ZCL_MESSAGING_CLUSTER_ID, - ZCL_CANCEL_MESSAGE_COMMAND_ID, "wu", message.messageId, message.messageControl); - emberAfSetCommandEndpoints(srcEndpoint, dstEndpoint); - emberAfGetCommandApsFrame()->options |= EMBER_APS_OPTION_SOURCE_EUI64; - status = emberAfSendCommandUnicast(EMBER_OUTGOING_DIRECT, nodeId); - if (status != EMBER_SUCCESS) - { - emberAfMessagingClusterPrintln("Error in cancel %x", status); - } -} 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/target-navigator-server/target-navigator-server.cpp b/src/app/clusters/target-navigator-server/target-navigator-server.cpp deleted file mode 100644 index dbc5f23b2ab8df..00000000000000 --- a/src/app/clusters/target-navigator-server/target-navigator-server.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/** - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**************************************************************************** - * @file - * @brief Routines for the Target Navigator plugin, the - *server implementation of the Target Navigator cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -bool emberAfTargetNavigatorClusterNavigateTargetCallback(chip::app::Command * commandObj, unsigned char, unsigned char *) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} 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/clusters/tv-channel-server/tv-channel-server.cpp b/src/app/clusters/tv-channel-server/tv-channel-server.cpp deleted file mode 100644 index 664d5ad275c6e2..00000000000000 --- a/src/app/clusters/tv-channel-server/tv-channel-server.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/** - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Copyright (c) 2021 Silicon Labs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/**************************************************************************** - * @file - * @brief Routines for the TV Channel plugin, the - *server implementation of the TV Channel cluster. - ******************************************************************************* - ******************************************************************************/ - -#include -#include - -bool emberAfTvChannelClusterChangeChannelCallback(chip::app::Command * commandObj, unsigned char *) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} - -bool emberAfTvChannelClusterChangeChannelByNumberCallback(chip::app::Command * commandObj, unsigned short, unsigned short) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} -bool emberAfTvChannelClusterSkipChannelCallback(chip::app::Command * commandObj, unsigned short) -{ - EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS; - emberAfSendImmediateDefaultResponse(status); - return true; -} diff --git a/src/app/clusters/zll-scenes-client/zll-scenes-client.c b/src/app/clusters/zll-scenes-client/zll-scenes-client.c deleted file mode 100644 index 06d56c68747423..00000000000000 --- a/src/app/clusters/zll-scenes-client/zll-scenes-client.c +++ /dev/null @@ -1,79 +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 ZLL Scenes Client plugin. - ******************************************************************************* - * # License - * Copyright 2018 Silicon Laboratories Inc. - * www.silabs.com - ******************************************************************************* - * - * The licensor of this software is Silicon - * Laboratories Inc. Your use of this software is - * governed by the terms of Silicon Labs Master - * Software License Agreement (MSLA) available at - * www.silabs.com/about-us/legal/master-software-license-agreement. - * This software is distributed to you in Source Code - * format and is governed by the sections of the MSLA - * applicable to Source Code. - * - ******************************************************************************/ - -#include "../../include/af.h" -#include "../scenes-client/scenes-client.h" -#include - -bool emberAfScenesClusterEnhancedAddSceneResponseCallback(chip::app::Command * commandObj, uint8_t status, uint16_t groupId, - uint8_t sceneId) -{ - return emberAfPluginScenesClientParseAddSceneResponse(emberAfCurrentCommand(), status, groupId, sceneId); -} - -bool emberAfScenesClusterEnhancedViewSceneResponseCallback(chip::app::Command * commandObj, uint8_t status, uint16_t groupId, - uint8_t sceneId, uint16_t transitionTime, uint8_t * sceneName, - uint8_t * extensionFieldSets) -{ - return emberAfPluginScenesClientParseViewSceneResponse(emberAfCurrentCommand(), status, groupId, sceneId, transitionTime, - sceneName, extensionFieldSets); -} - -bool emberAfScenesClusterCopySceneResponseCallback(chip::app::Command * commandObj, uint8_t status, uint16_t groupIdFrom, - uint8_t sceneIdFrom) -{ - emberAfScenesClusterPrintln("RX: CopySceneResponse 0x%x, 0x%2x, 0x%x", status, groupIdFrom, sceneIdFrom); - emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_SUCCESS); - return true; -} 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") {