From: saerome kim Date: Mon, 27 Feb 2017 01:01:13 +0000 (+0900) Subject: Fixed ACR issues X-Git-Tag: submit/tizen/20170512.045637~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=484e99115f3b89337d61e8f743da354f268ba115;p=platform%2Fcore%2Fapi%2Fzigbee.git Fixed ACR issues - Fixed an issue where some enummerations and structures do not have comments - Added zigbee_doc.h - Version tags has been changed from 3.0 to 4.0 - Modified to meet Tizen API guideline - Modified to use '_' in filename - @brief section is changed to start with verb Change-Id: I1964b7f40a1172b595c1af06ed94a9461b147e54 Signed-off-by: saerome kim --- diff --git a/common/h b/common/h new file mode 100644 index 0000000..e69de29 diff --git a/common/zb-common.h b/common/zb-common.h index 54cc3df..08de6e3 100644 --- a/common/zb-common.h +++ b/common/zb-common.h @@ -16,9 +16,9 @@ #ifndef __TIZEN_NETWORK_ZIGBEE_INTERNAL_COMMON_H__ #define __TIZEN_NETWORK_ZIGBEE_INTERNAL_COMMON_H__ -#include -#include -#include +#include +#include +#include #ifndef ZIGBEE_DBUS_INTERFACE #define ZIGBEE_DBUS_INTERFACE "org.tizen.zigbee" @@ -61,20 +61,6 @@ #define MAX_DEVICE_LIST 32 /**< maximum end-devices in device list */ -/** - * @brief Use this value as the return value to stop foreach function. - * - * @since_tizen 3.0 - */ -#define ZIGBEE_FUNC_STOP false - -/** - * @brief Use this value as the return value to continue foreach function. - * - * @since_tizen 3.0 - */ -#define ZIGBEE_FUNC_CONTINUE true - #define NOT_USED(var) ((var) = (var)) /*--------------------------------------------------------------------------------------- @@ -83,10 +69,10 @@ /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.39 Fields of the Simple Descriptor + * @brief Fields of the Simple Descriptor * @details Device descriptions contained in node. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_zdo_simple_desc_s { unsigned char ep; /**< Endpoint ID */ @@ -101,10 +87,10 @@ struct zb_zdo_simple_desc_s { /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.34 Fields of the Node Power Descriptor . + * @brief Fields of the Node Power Descriptor . * @details Node power characteristics. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_zdo_node_power_descriptor_s { unsigned char current_power_mode; /**< Current Power Mode */ @@ -115,9 +101,9 @@ struct zb_zdo_node_power_descriptor_s { /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief structure for end-device information. + * @brief Structure for end-device information. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_end_device_info_s { nwk_addr addr16; /**< 16bit network address */ @@ -132,10 +118,10 @@ struct zb_end_device_info_s { /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.29 Fields of the Node Descriptor + * @brief Fields of the Node Descriptor * @details Type and capabilities of the node. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_zdo_node_descriptor_s { unsigned char logical_type; /**< Logical Role */ @@ -154,9 +140,9 @@ struct zb_zdo_node_descriptor_s { /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.125 NetworkList Record Format. + * @brief NetworkList Record Format. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_zdo_network_list_record_s { ieee_addr extended_pan_id; /**< Extended PAN ID */ @@ -175,9 +161,9 @@ struct zb_zdo_network_list_record_s { /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.127 NeighborTableList Record Format. + * @brief NeighborTableList Record Format. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_zdo_neighbor_table_desc_s { ieee_addr extended_pan_id; /**< Extended PAN ID */ @@ -194,9 +180,9 @@ struct zb_zdo_neighbor_table_desc_s { /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.129 RoutingTableList Record Format. + * @brief RoutingTableList Record Format. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_zdo_routing_table_s { nwk_addr dst_addr; /**< Network Address */ @@ -210,9 +196,9 @@ struct zb_zdo_routing_table_s { /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.131 BindingTableList Record Format. + * @brief BindingTableList Record Format. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_zdo_binding_table_s { ieee_addr src_addr64; /**< IEEE address */ @@ -227,9 +213,9 @@ struct zb_zdo_binding_table_s { /** * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.136 DiscoveryCacheList Record Format. + * @brief DiscoveryCacheList Record Format. * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_zdo_discovery_cache_s { ieee_addr addr64; /**< IEEE Address */ @@ -244,7 +230,7 @@ struct zb_zdo_discovery_cache_s { /** * @brief Format of Attribute Value Field for string * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct attribute_str_s { unsigned char n; /**< number of elements */ @@ -254,7 +240,7 @@ struct attribute_str_s { /** * @brief Format of Attribute Value Field for wide-string * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct attribute_wstr_s { unsigned short n; /**< number of elements */ @@ -262,9 +248,9 @@ struct attribute_wstr_s { }; /** - * @brief Figure 2.8 Format of Attribute Value Field for an array, Set or Bag + * @brief Figure 2.8 Format of Attribute Value Field for an array, Set or Bag in Zigbee Cluster Libarry * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct attribute_array_s { unsigned char t; /**< element type */ @@ -275,7 +261,7 @@ struct attribute_array_s { /** * @brief Attribute value sequence * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct attribute_element_value { unsigned char t; /**< element type */ @@ -283,9 +269,9 @@ struct attribute_element_value { }; /** - * @brief Figure 2.9 Format of the Attribute Value Field for a Structure + * @brief Format of the Attribute Value Field for a Structure * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct attribute_struct_s { unsigned short n; /**< number of elements */ @@ -295,7 +281,7 @@ struct attribute_struct_s { /** * @brief value format for the cluster attribute data * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zb_value_s { unsigned char type; /**< value type */ @@ -306,9 +292,9 @@ struct zb_value_s { }; /** - * @brief Figure 2.7 Format of the Read Attribute Status Record Field + * @brief Format of the Read Attribute Status Record Field * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct read_attribute_status_record_s { unsigned short id; /**< attribute identifier */ @@ -328,7 +314,7 @@ struct read_attribute_status_record_s { /** * @brief write attributes data structure * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct write_attribute_record_s { unsigned short id; /**< attribute identifier */ @@ -339,7 +325,7 @@ struct write_attribute_record_s { /** * @brief For write attribute response command * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct write_attribute_status_record_s { unsigned char status; /**< attribute status */ @@ -349,7 +335,7 @@ struct write_attribute_status_record_s { /** * @brief reporting configuration record structure * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct reporting_configuration_record_s { unsigned char dir; /*(< direction */ @@ -363,9 +349,9 @@ struct reporting_configuration_record_s { /** - * @brief Figure 2.18 Format of the Attribute Status Record Field + * @brief Format of the Attribute Status Record Field * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct reporting_configuration_response_record_s { unsigned char status; /**< status */ @@ -376,7 +362,7 @@ struct reporting_configuration_response_record_s { /** * @brief Read reporting configuration record * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct read_reporting_configuration_record_s { unsigned char dir; /**< direction */ @@ -384,9 +370,9 @@ struct read_reporting_configuration_record_s { }; /** - * @brief Figure 2.24 Format of the Attribute Report Fields + * @brief Format of the Attribute Report Fields * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct attribute_report_s { unsigned short id; /**< attribute identifier */ @@ -395,9 +381,9 @@ struct attribute_report_s { }; /** - * @brief Figure 2.28 Format of the Attribute Report Fields + * @brief Format of the Attribute Report Fields * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct discover_attribute_info_record_s { unsigned short id; /**< attribute identifier */ @@ -405,9 +391,9 @@ struct discover_attribute_info_record_s { }; /** - * @brief Figure 12.5 Format of the Extended Attribute Information Fields + * @brief Format of the Extended Attribute Information Fields * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct extended_attribute_infomation_s { unsigned short id; /**< attribute identifier */ @@ -418,12 +404,12 @@ struct extended_attribute_infomation_s { /** * @brief Events * - * @since_tizen 3.0 + * @since_tizen 4.0 */ struct zbl_event_s { - unsigned char *data; - unsigned char len; + unsigned char *data; /**< Event data buffer */ + unsigned char len; /**< Event */ }; #endif /* __TIZTN_NETWORK_ZIGBEE_INTERNAL_COMMON_H__ */ diff --git a/common/zb-utils.c b/common/zb-utils.c index 9e56ae5..aea0bd1 100644 --- a/common/zb-utils.c +++ b/common/zb-utils.c @@ -16,7 +16,7 @@ #include #include -#include +#include #include "zb-log.h" diff --git a/doc/ha/generic_devices/zb-ha-on-off-switch.h b/doc/ha/generic_devices/zb-ha-on-off-switch.h deleted file mode 100644 index f9d1339..0000000 --- a/doc/ha/generic_devices/zb-ha-on-off-switch.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_HA_OCCUPANCY_SENSOR_H__ -#define __TIZEN_NETWORK_ZIGBEE_HA_OCCUPANCY_SENSOR_H__ - -#include -#include - -/* Table 7.1 Clusters Common to All Devices - * +---------------------------------------------------------------------------+ - * | Server Side | Client Side (see 7.1.4)| - * +---------------------------------------------------------------------------+ - * | Mandatory | - * +---------------------------------------------------------------------------+ - * | Basic | None | - * | Identify | | - * +---------------------------------------------------------------------------+ - * | Optional | - * +---------------------------------------------------------------------------+ - * | Clusters with reporting capability | Clusters with reporting capability | - * | Power Configuration | Time | - * | Device Temperature Configuration | OTA Bootload | - * | Alarms | | - * | Electrical Measurement | | - * | Poll Control | | - * | Partition | Partition | - * | Manufacturer-specific | Manufacturer-specific | - * +---------------------------------------------------------------------------+ - */ - -/* Table 7.55 Example Features and Functions Supported by the On/Off Switch Device - * +----------------------------------------------------------------+----------+ - * | Device Type/Feature or Function |Mandatory/| - * | |Optional | - * +----------------------------------------------------------------+----------+ - * | Join (end devices and routers only) | M | - * | Form Network (Coordinator only) | M | - * | Allow Others to Join Network (routers and Coordinators only) | M | - * | Restore to Factory Fresh Settings | M | - * | Enable Identify Mode | O | - * | Group Nodes (send out an Add Group If Identify) | O | - * | Create Scene (Store Scene) | O | - * | Service discovery (Match Descriptor Request) | O | - * | ZDP Bind Response | M | - * | ZDP Unbind Response | M | - * | End Device Annce/Device Annce | M | - * | Service Discovery Response (Match Descriptor Response) | M | - * | EZ-Mode Commissioning | M | - * +----------------------------------------------------------------+----------+ - */ - -/* Table 7.5 Clusters Supported by the On/Off Switch Device - * +---------------------------------------------------------------------------+ - * | Server Side | Client Side (see 7.1.4)| - * +---------------------------------------------------------------------------+ - * | Mandatory | - * +---------------------------------------------------------------------------+ - * | None | On/Off (suject to binding) | - * | | Identify | - * +---------------------------------------------------------------------------+ - * | Optional | - * +---------------------------------------------------------------------------+ - * | | Scenes | - * | | Groups | - * | On/Off Switch Configuration | | - * +---------------------------------------------------------------------------+ - */ - -/*-------------------------------------------------------------------------------------- - * Basic Cluster (0x0000 - IN) - *--------------------------------------------------------------------------------------*/ - -// Case 1. Add macros to guide how to use ZCL cluster functions. -#define zb_ha_get_on_off_switch_zcl_version(node_id, dest_ep, cb, user_data) \ - zb_zcl_basic_get_zcl_version(unsigned short node_id, unsigned char dest_ep, zb_zcl_8u_cb cb, void *user_data); -#define zb_ha_get_on_off_switch_application_version(node_id, dest_ep, cb, user_data) \ - zb_zcl_basic_get_application_version(unsigned short node_id, unsigned char dest_ep, zb_zcl_8u_cb cb, void *user_data); -#define zb_ha_get_on_off_switch_stack_version(node_id, dest_ep, cb, user_data) \ - zb_zcl_basic_get_stack_version(unsigned short node_id, unsigned char dest_ep, zb_zcl_8u_cb cb, void *user_data); -#define zb_ha_get_on_off_switch_hw_version(node_id, dest_ep, cb, user_data) \ - zb_zcl_basic_get_hw_version(unsigned short node_id, unsigned char dest_ep, zb_zcl_8u_cb cb, void *user_data); -#define zb_ha_get_on_off_switch_manufacturer_name(node_id, dest_ep, cb, user_data) \ - zb_zcl_basic_get_manufacturer_name(unsigned short node_id, unsigned char dest_ep, zb_zcl_string_cb cb, void *user_data); -#define zb_ha_get_on_off_switch_model_identifier(node_id, dest_ep, cb, user_data) \ - zb_zcl_basic_get_model_identifier(unsigned short node_id, unsigned char dest_ep, zb_zcl_string_cb cb, void *user_data); -#define zb_ha_get_on_off_switch_date_cod(node_id, dest_ep, cb, user_data) \ - zb_zcl_basic_get_date_code(unsigned short node_id, unsigned char dest_ep, zb_zcl_string_cb cb, void *user_data); -#define zb_ha_get_on_off_switch_power_source(node_id, dest_ep, cb, user_data) \ - zb_zcl_basic_get_power_source(unsigned short node_id, unsigned char dest_ep, zb_zcl_8u_cb cb, void *user_data); - -// Case 2. Just add comments & examples how to use general ZCL APIs -/* Example : -#include -. -. -static void get_my_zcl_version_cb(unsigned short node_id, unsigned char src_ep, unsigned char ver, void *user_data) -{ - printf("Device ZCL version is %d\n", ver); -} - -static void get_my_manufacturer_name_cb(unsigned short node_id, unsigned char src_ep, const char *name, void *user_data) -{ - char *buf = name; - printf("Device Manufacturer Name is %s\n", buf); -} - -static void _get_basic_cluster_handler(unsigned short nodeid, unsigned char ep, int attribute_id) { - . - . - switch(attribute_id) { - case ZB_ZCL_VERSION_ATTRIBUTE_ID: - zb_zcl_basic_get_zcl_version(nodeid, ep, get_my_zcl_version_cb, NULL); - break; - - case ZB_ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID: - zb_zcl_basic_get_manufacturer_name(nodeid, ep, get_my_manufacturer_name_cb, NULL); - break; - . - . - } - . - . - . -} -*/ - -/*-------------------------------------------------------------------------------------- - * Power Configuration Cluster (0x0001 - IN) - *--------------------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------------------- - * Device Temperature Cluster (0x0002 - IN) - *--------------------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------------------- - * Identify Cluster (0x0003 - IN) - *--------------------------------------------------------------------------------------*/ - -// Case 1. Add macros to guide how to use ZCL cluster functions. -#define zb_ha_on_off_switch_set_identify(node_id, dest_ep, identify_time) \ - zb_zcl_identify_identify_query( (node_id), (dest_ep), (identif_time)) - -#define zb_ha_on_off_switch_get_identify_query(node_id, dest_ep, cb, user_data) \ - zb_zcl_identify_identify_query( (node_id), (dest_ep), (cb), (user_data) ) - -// Case 2. Just add comments & examples how to use general ZCL APIs - -/*-------------------------------------------------------------------------------------- - * Alarm Cluster (0x0009 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-alarm-cluster.h - -/*-------------------------------------------------------------------------------------- - * Electrical Measurement Cluster (0x0B04 - IN) - *--------------------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------------------- - * Diagnostic Cluster (0x0B05 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-diagnostic-cluster.h - -/*-------------------------------------------------------------------------------------- - * Poll-Control Cluster (0x0020 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-poll-control-cluster.h - -/*-------------------------------------------------------------------------------------- - * Partition Cluster (0x0016 - IN) - *--------------------------------------------------------------------------------------*/ - -// To-Do : docs-10-5685-00-zarc-public-telecom-services-specification.pdf - -/*-------------------------------------------------------------------------------------- - * OTA Bootloader Cluster (0x0016 - OUT) - *--------------------------------------------------------------------------------------*/ - -// To-Do : docs-09-5264-23-00zi-zigbee-ota-upgrade-cluster-specification.pdf - -/*-------------------------------------------------------------------------------------- - * On/Off Cluster (0x0006 - OUT) - *--------------------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------------------- - * On/Off Configuration Cluster (0x0007 - IN) - *--------------------------------------------------------------------------------------*/ - -// Case 1. Add macros to guide how to use ZCL cluster functions. - -/* Attributes */ -#define zb_ha_get_on_off_switch_type(node_id, dest_ep, cb, user_data) \ - zb_zcl_get_on_off_switch_type( (node_id), (dest_ep), (cb), (user_data) ) -#define zb_ha_get_on_off_switch_action(node_id, dest_ep, cb, user_data) \ - zb_zcl_get_on_off_switch_action( (node_id), (dest_ep), (cb), (user_data) ) -#define zb_ha_set_on_off_switch_action(node_id, dest_ep, switch_action) \ - zb_zcl_set_on_off_switch_action( (node_id), (dest_ep), (switch_action) ) - -/* Commands - * ZB_ZCL_OFF_COMMAND_ID = 0x00, // Ver.: always - * ZB_ZCL_ON_COMMAND_ID = 0x01, // Ver.: always - * ZB_ZCL_TOGGLE_COMMAND_ID = 0x02, // Ver.: always - */ -#define zb_ha_cmd_on_off(node_id, dest_ep, cmd_id) \ - zb_zcl_cmd_on_off_cluster( (node_id), (dest_ep), (cmdid) ) - -// Case 2. Just add comments & examples how to use general ZCL APIs - -/* Example. -#include -. -. -. -void bulb_off(void) -{ - zb_zcl_cmd_on_off(0x1df4, 1, ZB_ZCL_OFF_COMMAND_ID); -} - -void bulb_on(void) -{ - zb_zcl_cmd_on_off(0x1df4, 1, ZB_ZCL_ON_COMMAND_ID); -} - -void bulb_toggle(void) -{ - zb_zcl_cmd_on_off(0x1df4, 1, ZB_ZCL_TOGGLE_COMMAND_ID); -} -*/ - -#endif /* __TIZEN_NETWORK_ZIGBEE_HA_OCCUPANCY_SENSOR_H__ */ diff --git a/doc/ha/lighting_devices/zb-ha-on-off-light.h b/doc/ha/lighting_devices/zb-ha-on-off-light.h deleted file mode 100644 index 1ae878a..0000000 --- a/doc/ha/lighting_devices/zb-ha-on-off-light.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - #ifndef __TIZEN_NETWORK_ZIGBEE_HA_COMBINED_INTERFACE_H__ - #define __TIZEN_NETWORK_ZIGBEE_HA_COMBINED_INTERFACE_H__ - -#include -#include - -/* Table 7.1 Clusters Common to All Devices - * +---------------------------------------------------------------------------+ - * | Server Side | Client Side (see 7.1.4)| - * +---------------------------------------------------------------------------+ - * | Mandatory | - * +---------------------------------------------------------------------------+ - * | Basic | None | - * | Identify | | - * +---------------------------------------------------------------------------+ - * | Optional | - * +---------------------------------------------------------------------------+ - * | Clusters with reporting capability | Clusters with reporting capability | - * | Power Configuration | Time | - * | Device Temperature Configuration | OTA Bootload | - * | Alarms | | - * | Electrical Measurement | | - * | Poll Control | | - * | Partition | Partition | - * | Manufacturer-specific | Manufacturer-specific | - * +---------------------------------------------------------------------------+ - */ - -/* Table 7.41 Example Features and Functions Supported by the On/Off Light Device - * +----------------------------------------------------------------+----------+ - * | Device Type/Feature or Function |Mandatory/| - * | |Optional | - * +----------------------------------------------------------------+----------+ - * | Join (end devices and routers only) | M | - * | Form Network (Coordinator only) | M | - * | Allow Others to Join Network (routers and Coordinators only) | M | - * | Restore to Factory Fresh Settings | M | - * | Enable Identify Mode | O | - * | Group Nodes (send out an Add Group If Identify) | M | - * | Create Scene (Store Scene) | O | - * | Service discovery (Match Descriptor Request) | M | - * | ZDP Bind Response | M | - * | ZDP Unbind Response | M | - * | End Device Annce/Device Annce | M | - * | Service Discovery Response (Match Descriptor Response) | M | - * | EZ-Mode Commissioning | M | - * +----------------------------------------------------------------+----------+ - */ - -/* Table 7.40 Clusters Supported by the On/Off Light Device - * +---------------------------------------------------------------------------+ - * | Server Side | Client Side (see 7.1.4)| - * +---------------------------------------------------------------------------+ - * | Mandatory | - * +---------------------------------------------------------------------------+ - * | On/Off | None | - * | Scenes | | - * | Groups | | - * +---------------------------------------------------------------------------+ - * | Optional | - * +---------------------------------------------------------------------------+ - * | None | Occupancy Sensing | - * +---------------------------------------------------------------------------+ - */ - -/*-------------------------------------------------------------------------------------- - * Basic Cluster (0x0000 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail zb-zcl-basic-cluster.h - -/*-------------------------------------------------------------------------------------- - * Power Configuration Cluster (0x0001 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-power-configuration-cluster.h - -/*-------------------------------------------------------------------------------------- - * Device Temperature Cluster (0x0002 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-device-temperature-cluster.h - -/*-------------------------------------------------------------------------------------- - * Identify Cluster (0x0003 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-identify-cluster.h - -/*-------------------------------------------------------------------------------------- - * Alarm Cluster (0x0009 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-alarm-cluster.h - -/*-------------------------------------------------------------------------------------- - * Electrical Measurement Cluster (0x0B04 - IN) - *--------------------------------------------------------------------------------------*/ - -/*-------------------------------------------------------------------------------------- - * Diagnostic Cluster (0x0B05 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-diagnostic-cluster.h - -/*-------------------------------------------------------------------------------------- - * Poll-Control Cluster (0x0020 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-poll-control-cluster.h - -/*-------------------------------------------------------------------------------------- - * Partition Cluster (0x0016 - IN) - *--------------------------------------------------------------------------------------*/ - -// To-Do : docs-10-5685-00-zarc-public-telecom-services-specification.pdf - -/*-------------------------------------------------------------------------------------- - * OTA Bootloader Cluster (0x0016 - OUT) - *--------------------------------------------------------------------------------------*/ - -// To-Do : docs-09-5264-23-00zi-zigbee-ota-upgrade-cluster-specification.pdf - -/*-------------------------------------------------------------------------------------- - * On/Off Cluster (0x0006 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-on-off-cluster.h - -/*-------------------------------------------------------------------------------------- - * Groups Cluster (0x0004 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-group-cluster.h - -/*-------------------------------------------------------------------------------------- - * Scenes Cluster (0x0005 - IN) - *--------------------------------------------------------------------------------------*/ - -// See detail : zb-zcl-scene-cluster.h - -#endif /* __TIZEN_NETWORK_ZIGBEE_HA_COMBINED_INTERFACE_H__ */ diff --git a/doc/zigbee_doc.h b/doc/zigbee_doc.h new file mode 100644 index 0000000..929ead2 --- /dev/null +++ b/doc/zigbee_doc.h @@ -0,0 +1,414 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_DOC_H__ +#define __TIZEN_NETWORK_ZIGBEE_DOC_H__ + +/** + * @ingroup CAPI_NETWORK_FRAMEWORK + * @defgroup CAPI_NETWORK_ZIGBEE_MODULE ZigBee + * + * @brief The Zigbee API provides functions for IoT connectivity. + * + * @section CAPI_NETWORK_ZIGBEE_MODULE_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_MODULE_OVERVIEW Overview + * ZigBee is the wireless language that everyday devices use to connect to one another. + * ZigBee devices can transmit data over long distances by passing data through a mesh network + * of intermediate devices to reach more distant ones. + * ZigBee is typically used in low data rate applications that require long battery life and secure networking. \n\n + * ZigBee has a defined rate of 250 kbit/s, best suited for intermittent data transmissions + * from a sensor or input device. \n See http://www.zigbee.org for more information. + * + * @subsection CAPI_NETWORK_ZIGBEE_MODULE_CREATE_NETWORK Create Network + * To run the Zigbee coordinator, first create an instance through the zb_create function. + * After that, register an event_handler for event reception using zb_set_event_cb function. + * Once the event_handler is registered, enable the zigbee-service by enabling the zigbee-daemon + * by calling the zb_enable function. + * Finally, we call the zb_form_network function to form the Zigbee network. \n + * + * Example : + * @code +#include +... +static void zigbee_event_cb(nwk_addr addr16, ieee_addr addr64, zb_event_e e, zb_event_data_s ev) +{ + unsigned char status, count, ep, command_id; + unsigned short cluster_id; + + printf("Event received = %s [0x%02X]", zb_event_str[e], e); + + switch (e) { + case ZB_ZDP_JOIN_EVENT: + { + count = ev.data.join->count; + printf(" %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X joined", + addr64[0], addr64[1], addr64[2], addr64[3], + addr64[4], addr64[5], addr64[6], addr64[7]); + printf("end-point count=%d", count); + break; + } + ... +} +... +static void zigbee_enable_cb(unsigned char status, void *user_data) +{ + printf(" Enable result received = 0x%02X\n", status); +} +... +static void zigbee_form_network_done_cb(nwk_addr panid, void *user_data) +{ + nwk_addr nodeid; + nwk_addr panid; + unsigned char channel; + unsigned char tx_power; + + ret = zb_get_network_info(handle, co_addr64, &nodeid, &panid, &channel, &tx_power); + printf("zb_get_network_info ret=[0x%02X]\n", (int)ret); + printf(" IEEE ADDR : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", + co_addr64[0], co_addr64[1], co_addr64[2], + co_addr64[3], co_addr64[4], co_addr64[5], + co_addr64[6], co_addr64[7]); + printf(" nodeID [0x%02X]\n", nodeid); + printf(" PanID [0x%02X]\n", panid); + printf(" Channel [%d] Tx Power [%d]\n", channel, tx_power); +} +... +zigbee_h handle = NULL; +... +static void _init_zigbee_service(...) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_create(&handle); + if (ZIGBEE_ERROR_NONE != ret) { + printf("zb_create ret=[0x%x]\n", (int)handle); + return; + } + + ret = zb_set_event_cb(handle, zigbee_event_cb); + if (ZIGBEE_ERROR_NONE != ret) { + printf("zb_set_event_cb(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + printf(" - zb_set_event_cb() ret: [0x%X]", ret); + + ret = zb_enable(handle, zigbee_enable_cb); + if (ZIGBEE_ERROR_NONE != ret) { + printf("zb_enable ret=[0x%x]\n", ret); + return; + } + + ret = zb_form_network(handle, zigbee_form_network_done_cb, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + printf(" - zb_form_network ret=[0x%x]\n", ret); + return; + } + ... +} + * @endcode + * + * @subsection CAPI_NETWORK_ZIGBEE_MODULE_ALLOW_DEVICES_TO_JOIN_NETWORK Allow devices to Join the Network + * Once the zigbee network is formed, it allows the end-device to join the network by + * calling zb_permit_join function. + * + * Example : + * @code +#include +... +static int _permit_join(zigbee_h handle) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char timeout = 90; + + ret = zb_permit_join(handle, timeout); + if (ZIGBEE_ERROR_NONE != ret) { + printf("zb_permit_join(0x%X) - FAILED!!!", ret); + return ret; + } + + printf(" - zb_permit_join() ret: [0x%X]", ret); + + return ret; +} + * @endcode + * + * @subsection CAPI_NETWORK_ZIGBEE_MODULE_DEVICES_JOINED Devices Joined + * When end-device joins the network, ZB_ZDP_JOIN_EVENT is received in the event handler + * registered through the set_event_cb function. + * When the end-device is joined, the zb_get_all_device_list function can be used to obtain + * information about the end-device or router device that is joined. + * If necessary, you can control the device by remembering the network address and + * end-point information of the joined device. + * + * Example : + * @code +#include +... +static void zigbee_event_cb(nwk_addr addr16, ieee_addr addr64, zb_event_e e, zb_event_data_s ev) +{ + unsigned char status, count, ep, command_id; + unsigned short cluster_id; + + printf("Event received = %s [0x%02X]", zb_event_str[e], e); + + switch (e) { + case ZB_ZDP_ENABLE_EVENT: + { + status = ev.data.enable->status; + printf(" service enabled = %d", status); + break; + } + case ZB_ZDP_FORM_NETWORK_DONE: + { + printf(" form network done"); + break; + } + case ZB_ZDP_JOIN_EVENT: + { + count = ev.data.join->count; + printf(" %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X joined", + addr64[0], addr64[1], addr64[2], addr64[3], + addr64[4], addr64[5], addr64[6], addr64[7]); + printf("end-point count=%d", count); + break; + } + ... +} +... +nwk_addr g_power_outlet_addr; +unsigend char g_power_outlet_ep; +... +nwk_addr g_open_close_sensor_addr; +unsigend char g_open_close_sensor_ep; +... +static int _get_end_device_list(zigbee_h handle) +{ + int ret = ZIGBEE_ERROR_NONE; + int i, j; + int count; + nwk_addr addr16; + ieee_addr addr64; + unsigned char num_of_ep; + unsigned char ep_list[10]; + zb_end_device_info_h *list = NULL; + + ret = zb_get_all_device_list(handle, &count, &list); + for (i = 0; i < count && list; i++) { + zb_get_network_address(list[i], &addr16); + zb_get_ieee_address((list)[i], addr64); + + if (!strncmp((char *)power_outlet_addr64, (char *)addr64, sizeof(addr64))) { + g_power_outlet_addr = addr16; + printf(Power Outlet Find!!"); + } + else if (!strncmp((char *)open_close_addr64, (char *)addr64, sizeof(addr64))) { + g_open_close_sensor_addr = addr16; + printf("Open/Close Sensor Find!!"); + } + printf("network address = 0x%02X", addr16); + printf(" ieee address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + addr64[0], addr64[1], addr64[2], addr64[3], + addr64[4], addr64[5], addr64[6], addr64[7]); + + zb_get_num_of_ep((list)[i], &num_of_ep); + printf("number of end-points = 0x%04X", num_of_ep); + + memset(ep_list, 0, sizeof(ep_list)); + zb_get_ep_list((list)[i], ep_list); + + for (j = 0; j < num_of_ep; j++) { + if (!strncmp((char *)power_outlet_addr64, (char *)addr64, sizeof(addr64))) { + g_power_outlet_ep = ep_list[j]; + } + else if (!strncmp((char *)open_close_addr64, (char *)addr64, sizeof(addr64))) { + g_open_close_sensor_ep = ep_list[j]; + } + printf("%02x ", ep_list[j]); + } + printf("\n"); + } + zb_device_list_free(list); + + printf(" - zb_get_all_device_list() ret: [0x%X]", ret); + + return ret; +} + * @endcode + * + * @subsection CAPI_NETWORK_ZIGBEE_MODULE_CONTROL_DEVICES Control the Devices + * A joined end-device can be controlled using an API that handles cluster-specific + * commands supported by end-device. + * + * Example : + * @code +#include + * @subsection CAPI_NETWORK_ZIGBEE_MODULE_CONTROL_DEVICE_ATTRIBUTES Control Attributes + * + * Example : + * @code +#include +static int _run_on(zigbee_h handle) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_onoff_control(handle, g_power_outlet_addr, g_power_outlet_ep, ZB_ZCL_ON); + if (ZIGBEE_ERROR_NONE != ret) { + printf("zb_zcl_onoff_control(0x%X) - FAILED!!!", ret); + return ret; + } + + printf(" - zb_zcl_onoff_control() ret: [0x%X]", ret); + + return ret; +} + +static int _run_off(zigbee_h handle) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_onoff_control(handle, g_power_outlet_addr, g_power_outlet_ep, ZB_ZCL_OFF); + if (ZIGBEE_ERROR_NONE != ret) { + printf("zb_zcl_onoff_control(0x%X) - FAILED!!!", ret); + return ret; + } + + printf(" - zb_zcl_onoff_control() ret: [0x%X]", ret); + + return ret; +} + * @endcode + * + * @subsection CAPI_NETWORK_ZIGBEE_MODULE_RECEIVING_EVENT_FROM_DEVICES Receiving Events From the Devices + * If an IAS zone sensor such as an open / close sensor is joined to the network, + * the following attribute changed notification event can be received when an open / close event occurs. + * + * Example : + * @code +#include +static void zigbee_event_cb(nwk_addr addr16, ieee_addr addr64, zb_event_e e, zb_event_data_s ev) +{ + unsigned char status, count, ep, command_id; + unsigned short cluster_id; + + printf("Event received = %s [0x%02X]", zb_event_str[e], e); + + switch (e) { + ... + case ZB_ZCL_IAS_ZONE_STATUS_CHANGE_NOTIFICATION_EVENT: + { + unsigned short zone_status; + + zone_status = ev.data.ias_noti->zone_status; + ep = ev.data.ias_noti->src_ep; + printf(" addr16 = 0x%04X", addr16); + printf(" endpoint = 0x%02X", ep); + printf(" zone_status = 0x%04X", zone_status); + break; + } + case ZB_ZCL_IAS_ZONE_STATUS_CHANGE_EXTENDED_NOTIFICATION_EVENT: + { + unsigned short zone_status, zone_id, delay; + unsigned char extended_status; + + ep = ev.data.ias_extended_noti->src_ep; + zone_status = ev.data.ias_extended_noti->zone_status; + extended_status = ev.data.ias_extended_noti->extended_status; + zone_id = ev.data.ias_extended_noti->zone_id; + delay = ev.data.ias_extended_noti->delay; + + printf(" addr16 = 0x%04X", addr16); + printf(" endpoint = 0x%02X", ep); + printf(" zone_status = 0x%04X", zone_status); + printf(" extended_status = 0x%02X", extended_status); + printf(" zone_id = 0x%04X", zone_id); + printf(" delay = 0x%04X", delay); + + // Closed or not alarmed + if (0x01 == (zone_status & 0x01)) + zb_zcl_onoff_control(handle, g_power_outlet_addr, g_power_outlet_ep, ZB_ZCL_OFF); + // Opened or alarmed + else if (0x00 == (zone_status & 0x01)) + zb_zcl_onoff_control(handle, g_power_outlet_addr, g_power_outlet_ep, ZB_ZCL_ON); + break; + } + ... +} + * + * @endcode + * + * @subsection CAPI_NETWORK_ZIGBEE_MODULE_LEAVING_DEVICES_FROM_NETWORK Leaving the devices From the Network + * + * Example : + * @code +#include +... +static int _run_leave_device(zigbee_h handle, bool remove_children, bool rejoin) +{ + int ret = ZIGBEE_ERROR_NONE; + bool remove_children = true; + bool rejoin = false; + unsigned char var = 0; + + ret = zb_leave_device(handle, dest_addr64, remove_children, rejoin); + if (ret != ZIGBEE_ERROR_NONE) { + printf("zb_leave_device(0x%X) - FAILED!!!", ret); + return ret; + } + + printf(" - zb_leave_device() ret: [0x%X]", ret); + + return ret; +} + * + * @endcode + * + * @subsection CAPI_NETWORK_ZIGBEE_MODULE_LEAVING_DEVICES_DISABLE_NETWORK Disable Network + * When all is done, disable the network and destroy the handle that was used. + * + * Example : + * @code +#include +... +static int _run_disable(zigbee_h handle) +{ + // De-register event callback + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_disable(handle); + if (ZIGBEE_ERROR_NONE != ret) { + printf("zb_disable(0x%X) - FAILED!!!", ret); + return ret; + } + + printf(" - zb_disable() ret: [0x%X]", ret); + + if (NULL == handle) { + printf("Already destroyed or not created."); + return ret; + } + + zb_destroy(handle); + handle = NULL; + + return ret; +} + * @endcode + */ + +#endif __TIZEN_NETWORK_ZIGBEE_DOC_H__ + diff --git a/include/zb-custom.h b/include/zb-custom.h deleted file mode 100644 index 4c55064..0000000 --- a/include/zb-custom.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_CUSTOM_H__ -#define __TIZEN_NETWORK_ZIGBEE_CUSTOM_H__ - -/** - * @file zb-custom.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE ZigBee Custom Commands - * - * @brief zigbee provides API for custom command. - * - * @section CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE_HEADER Header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE_OVERVIEW Overview - * This API set consists of ZigBee custom command API - * - * @{ - */ - -/** - * @brief The response of custom command function - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] src_ep source end-point (ex. 1) - * @param[out] dst_ep destination end-point (ex. 1) - * @param[out] cluster_id ZCL cluster id - * @param[out] profile_id Profile id - * @param[out] payload_len Length of payload - * @param[out] payload Payload data - * @param[out] user_data User data - * - * @see zb_aps_send() - */ -typedef void (*zb_aps_send_rsp)( - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned short cluster_id, - unsigned short profile_id, - unsigned short payload_len, - unsigned char *payload, - void *user_data); - -/** - * @brief The response of custom command function - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] src_ep source end-point (ex. 1) - * @param[out] dst_ep destination end-point (ex. 1) - * @param[out] cluster_id ZCL cluster id - * @param[out] profile_id Profile id - * @param[out] payload_len Length of payload - * @param[out] payload Payload data - * @param[out] user_data User data - * - * @see zb_zcl_send() - */ -typedef void (*zb_zcl_send_rsp)( - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned short cluster_id, - unsigned short profile_id, - unsigned short payload_len, - unsigned char *payload, - void *user_data); - -/** - * @brief The response of custom command function - * - * @since_tizen 3.0 - * - * @param[out] length The length of data - * @param[out] data Received data - * @param[out] user_data User data - * - * @see zb_send_to_local() - */ -typedef void (*zb_send_to_local_rsp)( - unsigned short length, - unsigned char *data, - void *user_data); - -/** - * @brief Send custom data - * - * @since_tizen 3.0 - * - * @param[in] handle Handle of node descriptor - * @param[in] addr16 Network address - * @param[in] aps_frame_ctl APS Frame control bits. \n - * - Delivery Mode : \n - * #ZB_APS_DELIVERY_UNICAST \n - * #ZB_APS_DELIVERY_INDIRECT \n - * #ZB_APS_DELIVERY_BROADCAST \n - * #ZB_APS_DELIVERY_MULTICAST \n - * - ACK Request : \n - * #ZB_APS_NO_ACK_REQUEST \n - * #ZB_APS_ACK_REQUEST - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] cluster_id ZCL cluster id - * @param[in] profile_id Profile id - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE - * @param[in] mfg_code Manufacturer Code - * @param[in] cmd_id Command ID - * @param[in] payload_len Length of payload - * @param[in] payload Payload data - * @param[in] cb Callback function to get response. - * @param[in] user_data User data to be received from callback function. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_aps_send_rsp() - */ -int zb_aps_send( - zigbee_h handle, - nwk_addr addr16, - unsigned char aps_frame_ctl, - unsigned char src_ep, - unsigned char dst_ep, - unsigned short cluster_id, - unsigned short profile_id, - unsigned char zcl_frame_ctl, - unsigned short mfg_code, - unsigned char cmd_id, - unsigned short payload_len, - unsigned char *payload, - zb_aps_send_rsp cb, - void *user_data); - -/** - * @brief Send custom data - * - * @since_tizen 3.0 - * - * @param[in] handle Handle of node descriptor - * @param[in] addr16 Network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] cluster_id ZCL cluster id - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE - * @param[in] cmd APL Command - * @param[in] payload_len Length of payload - * @param[in] payload Payload data - * @param[in] cb Callback function to get response. - * @param[in] user_data User data to be received from callback function. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_send_rsp() - */ -int zb_zcl_send( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned short cluster_id, - unsigned char zcl_frame_ctl, - unsigned char cmd, - unsigned short payload_len, - unsigned char *payload, - zb_zcl_send_rsp cb, - void *user_data); - -/** - * @brief Send custom data - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] length The length of data - * @param[in] data Data to send - * @param[in] cb Callback function to get response. - * @param[in] user_data User data to be received from callback function. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_send_to_local_rsp() - */ -int zb_send_to_local( - zigbee_h handle, - unsigned short length, - unsigned char *data, - zb_send_to_local_rsp cb, - void *user_data); - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_CUSTOM_H__ */ diff --git a/include/zb-error.h b/include/zb-error.h deleted file mode 100644 index 3566a46..0000000 --- a/include/zb-error.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - -#ifndef __CAPI_NETWORK_ZIGBEE_ERROR_H__ -#define __CAPI_NETWORK_ZIGBEE_ERROR_H__ - -#include - -#ifndef TIZEN_ERROR_ZIGBEE -#define TIZEN_ERROR_ZIGBEE 0x02000000 -#endif - -/** - * @file zb-error.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_MODULE - * @brief Enumeration for zigbee CAPI error code. - * @since_tizen 3.0 - * - * @{ - */ -typedef enum { - ZIGBEE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - ZIGBEE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_ZIGBEE | 0x01, /**< parameter error */ - ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE = TIZEN_ERROR_ZIGBEE | 0x03, /**< out of range error */ - ZIGBEE_ERROR_INVALID_ENDPOINT = TIZEN_ERROR_ZIGBEE | 0x04, /**< endpoint 0 is reserved for ZDP */ - ZIGBEE_ERROR_INVALID_ADDRESS = TIZEN_ERROR_ZIGBEE | 0x05, /**< wrong address */ - ZIGBEE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_ZIGBEE | 0x6, /**< out of memory */ - ZIGBEE_ERROR_INVALID_DATA = TIZEN_ERROR_ZIGBEE | 0x7, /**< Invalid data available */ - ZIGBEE_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< DBus error */ - ZIGBEE_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */ - ZIGBEE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< not supported */ -} zb_error_e; - -/** - * @} - */ - -#endif /* __CAPI_NETWORK_ZIGBEE_ERROR_H__ */ diff --git a/include/zb-ha.h b/include/zb-ha.h deleted file mode 100644 index 741511b..0000000 --- a/include/zb-ha.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_HA_H__ -#define __TIZEN_NETWORK_ZIGBEE_HA_H__ - -/** - * @brief Zigbee profile id - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_PROFILE_HOME_AUTOMATION = 0x0104, -} zb_profile_id_e; - -/** - * @brief Devices specified the HA profile - * - * @since_tizen 3.0 - */ -typedef enum { - /* General devices */ - ZB_HA_ON_OFF_SWITCH = 0x0000, - ZB_HA_LEVEL_CONTROL_SWITCH = 0x0001, - ZB_HA_ON_OFF_OUTPUT = 0x0002, - ZB_HA_LEVEL_CONTROLLABLE_OUTPUT = 0x0003, - ZB_HA_SCENE_SELECOTOR = 0x0004, - ZB_HA_CONFIGURATION_TOOL = 0x0005, - ZB_HA_REMOTE_CONTROL = 0x0006, - ZB_HA_COMBINED_INTERFACE = 0x0007, - ZB_HA_RANGE_EXTENDER = 0x0008, - ZB_HA_MAINS_POWER_OUTLET = 0x0009, - ZB_HA_DOOR_LOCK = 0x000A, - ZB_HA_DOOR_LOCK_CONTROLLER = 0x000B, - ZB_HA_SIMPLE_SENSOR = 0x000C, - ZB_HA_CONSUMPTION_AWARENESS_DEVICE = 0x000D, - ZB_HA_HOME_GATEWAY = 0x0050, - ZB_HA_SMART_PLUG = 0x0051, - ZB_HA_WHITE_GOODS = 0x0052, - ZB_HA_METER_INTERFACE = 0x0053, - /* Lighting devices */ - ZB_HA_ON_OFF_LIGHT = 0x0100, - ZB_HA_DIMMABLE_LIGHT = 0x0101, - ZB_HA_COLOR_DIMMABLE_LIGHT = 0x0102, - ZB_HA_ON_OFF_LIGHT_SWITCH = 0x0103, - ZB_HA_DIMMER_SWITCH = 0x0104, - ZB_HA_COLOR_DIMMER_SWITCH = 0x0105, - ZB_HA_LIGHT_SENSOR = 0x0106, - ZB_HA_OCUPANCY_SENSOR = 0x0107, - /* Closures devices */ - ZB_HA_SHADE = 0x0200, - ZB_HA_SHADE_CONTROLLER = 0x0201, - ZB_HA_WINDOW_COVERING_DEVICE = 0x0202, - ZB_HA_WINDOW_COVERING_CONTROLLER = 0x0203, - /* HVAC devices */ - ZB_HA_HEATING_COLLING_UNIT = 0x0300, - ZB_HA_THERMOSTAT = 0x0301, - ZB_HA_TEMPERATURE_SENSOR = 0x0302, - ZB_HA_PUMP = 0x0303, - ZB_HA_PUMP_CONTROLLER = 0x0304, - ZB_HA_PRESSURE_SENSOR = 0x0305, - ZB_HA_FLOW_SENSOR = 0x0306, - ZB_HA_MINI_SPLIT_AC = 0x0307, - /* Intruder Alarms system */ - ZB_HA_ISA_CONTROL_AND_INDICATING_EQUIPMENT = 0x0400, - ZB_HA_ISA_ANCILLARY_CONTROL_EQUIPMENT = 0x0401, - ZB_HA_ISA_ZONE = 0x0402, - ZB_HA_ISA_WARNIGN_DEVICE = 0x0403, -} ha_device_id_e; - - -#endif /* __TIZEN_NETWORK_ZIGBEE_HA_H__ */ diff --git a/include/zb-type.h b/include/zb-type.h deleted file mode 100644 index 52ef0f6..0000000 --- a/include/zb-type.h +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - -#ifndef __CAPI_NETWORK_ZIGBEE_CONSTANT_H__ -#define __CAPI_NETWORK_ZIGBEE_CONSTANT_H__ - -#include - -/** - * @file zb-type.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_COMMON_MODULE Common - * - * @brief zigbee common types provides the set of definitions to use zigbee service - * - * @section CAPI_NETWORK_ZIGBEE_COMMON_MODULE_HEADER header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_COMMON_MODULE_HEADER_OVERVIEW overview - * This API set consists of data structures and types - * - * @{ - */ - -/** - * @brief Data type abbreviation : 8 bit value - * - * @since_tizen 3.0 - */ -typedef unsigned char v1; -/** - * @brief Data type abbreviation : 16 bit value - * - * @since_tizen 3.0 - */ -typedef unsigned char v2[2]; -/** - * @brief Data type abbreviation : 24 bit value - * - * @since_tizen 3.0 - */ -typedef unsigned char v3[3]; -/** - * @brief Data type abbreviation : 32 bit value - * - * @since_tizen 3.0 - */ -typedef unsigned char v4[4]; -/** - * @brief Data type abbreviation : 40 bit value - * - * @since_tizen 3.0 - */ -typedef unsigned char v5[5]; -/** - * @brief Data type abbreviation : 48 bit value - * - * @since_tizen 3.0 - */ -typedef unsigned char v6[6]; -/** - * @brief Data type abbreviation : 56 bit value - * - * @since_tizen 3.0 - */ -typedef unsigned char v7[7]; -/** - * @brief Data type abbreviation : 64 bit value - * - * @since_tizen 3.0 - */ -typedef unsigned char v8[8]; - -/** - * @brief Data type abbreviation : IEEE Address - * - * @since_tizen 3.0 - */ -typedef unsigned char ieee_addr[8]; -/** - * @brief Data type abbreviation : Network Address - * - * @since_tizen 3.0 - */ -typedef unsigned short nwk_addr; - -/** - * @brief Data type abbreviation : 128 bit security key - * - * @since_tizen 3.0 - */ -typedef unsigned char aes128_key[16]; - -/** -* @brief The handle of zigbee -* @details a zigbee_h is an opaque data structure.\n -* zigbee_h is a data type of zigbee's response which consists of result, handler and etc. -* -* @since_tizen 3.0 -*/ -typedef struct zbl_zigbee_s* zigbee_h; - -/** - * @brief Events for zb_event_cb - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_ENABLE_EVENT = 0x00, /**< This event is received after enabling zigbee system service */ - ZB_ZDP_FORM_NETWORK_DONE = 0x01, /**< This event comes from coming network operation completed */ - ZB_ZDP_JOIN_EVENT = 0x02, /**< This event takes place when new device joined */ - ZB_ZDP_REJOIN_EVENT = 0x03, /**< This event takes place when existing device or devices which is(are) received 'leave_network' command is re-joined */ - ZB_ZDP_CHILD_LEFT = 0x04, /**< This event takes place when a child device leave current network explicitly */ - ZB_ZDP_LEAVE_DONE_EVENT = 0x05, /**< This event will take place after dismiss current network */ - ZB_ZDP_UPDATED_NETWORK_NOTIFICATION_EVENT = 0x06, /**< A device updated its network information */ - ZB_ZDP_BIND_RSP_EVENT = 0x07, /**< Binding end-points result */ - ZB_ZDP_UNBIND_RSP_EVENT = 0x08, /**< Unbinding end-points result */ - ZB_ZCL_GLOBAL_DEFAULT_RSP_EVENT = 0x10, /**< This event is used when global default response */ - ZB_ZCL_GLOBAL_ATTRIBUTE_REPORT_EVENT = 0x11, /**< This event is took place when report attribute command received */ - ZB_ZCL_ALARM_EVENT = 0x20, /**< Events related to alarm cluster */ - ZB_ZCL_IAS_ZONE_ENROLL_REQUEST_EVENT = 0x21, /**< A Device which supports IAS zone cluster want to register its ability */ - ZB_ZCL_IAS_ZONE_STATUS_CHANGE_NOTIFICATION_EVENT = 0x22, /**< A Device which supports IAS zone cluster notifies its status change */ - ZB_ZCL_IAS_ZONE_STATUS_CHANGE_EXTENDED_NOTIFICATION_EVENT = 0x23, /**< A Device which supports IAS zone cluster notifies its status change */ - ZB_ZCL_LEVEL_CONTROL_CURRENT_LEVEL_ATTRIBUTE_REPORT_EVENT = 0x30, /**< (Confusint) This event will be received after level control cluster attribute changed */ - ZB_ZCL_COLOR_CONTROL_CURRENT_X_ATTRIBUTE_REPORT_EVENT = 0x31, /**< This event will be received after color control cluster X attribute changed */ - ZB_ZCL_COLOR_CONTROL_CURRENT_Y_ATTRIBUTE_REPORT_EVENT = 0x32, /**< This event will be received after color control cluster Y attribute changed */ - ZB_ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_REPORT_EVENT = 0x33, /**< This event will be received after color control cluster hue attribute changed */ - ZB_ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_REPORT_EVENT = 0x34, /**< This event will be received after color control cluster saturation attribute changed */ - ZB_ZCL_COLOR_CONTROL_CURRENT_TEMPERATURE_ATTRIBUTE_REPORT_EVENT = 0x35, /**< This event will be received after color control cluster temperature attribute changed */ - ZB_ZCL_DOOR_LOCK_OPERATIONAL_NOTIFICATION_EVENT = 0x40, /**< This event is received when door-lock operation has been finished */ - ZB_ZCL_DOOR_LOCK_PROGRAMING_NOTIFICATION_EVENT = 0x41, /**< This event is received when door-lock programming has been changed */ - ZB_ZCL_SIMPLE_METERING_REMOVE_MIRROR_EVENT = 0x51, /**< This event is used to request the ESP to remove its mirror of Metering */ - ZB_ZCL_SIMPLE_METERING_REQUEST_MIRROR_EVENT = 0x52, /**< This event is used to request the ESP to mirror Metering Device data */ -} zb_event_e; - -/** - * @brief The structure type for the ZB_ZDP_ENABLE_EVENT callback data. - * @details The result of enabling zigbee system service. - * - * @since_tizen 3.0 - */ -typedef struct { - unsigned char status; /**< Status of enabling zigbee system service */ -} zb_event_enable_s; - -/** - * @brief The structure type for the ZB_ZDP_FORM_NETWORK_DONE callback data. - * @details This event comes from coming network operation completed. - * - * @since_tizen 3.0 - */ -typedef struct { - nwk_addr pan_id; /**< Pan ID */ -} zb_event_form_network_s; - -/** - * @brief The structure type for the ZB_ZDP_JOIN_EVENT callback data. - * @details This event takes place when new device joined. - * - * @since_tizen 3.0 - */ -typedef struct { - unsigned char count; /**< Number of endpoint list */ - unsigned char ep[10]; /**< Endpoint list */ -} zb_event_join_s; - -/** - * @brief The structure type for the ZB_ZDP_CHILD_LEFT callback data. - * @details This event takes place when a child device leave current network explicitly. - * - * @since_tizen 3.0 - */ -typedef struct { - unsigned char status; /**< Left status of child device */ -} zb_event_child_left_s; - -/** - * @brief The structure type for the ZB_ZCL_GLOBAL_DEFAULT_RSP_EVENT callback data. - * @details This event is used when global default response. - * - * @since_tizen 3.0 - */ -typedef struct { - unsigned char ep; - unsigned short cluster_id; - unsigned char command_id; - unsigned char status; -} zb_event_global_default_rsp_s; - -/** - * @brief The structure type for the ZB_ZCL_GLOBAL_ATTRIBUTE_REPORT_EVENT callback data. - * @details This event is took place when report attribute command received. - * - * @since_tizen 3.0 - */ -typedef struct { - void* records; /**< Array of attribute report record */ - unsigned char count; /**< count of records */ -} zb_event_global_attr_report_s; - -/** - * @brief The structure type for the ZB_ZCL_ALARM_EVENT callback data. - * @details This event is related to alarm cluster. - * - * @since_tizen 3.0 - */ -typedef struct { - unsigned short count; /**< Alarm count */ -} zb_event_alarm_s; - -/** - * @brief The structure type for the ZB_ZCL_IAS_ZONE_ENROLL_REQUEST_EVENT callback data. - * @details A Device which supports IAS zone cluster want to register its ability. - * - * @since_tizen 3.0 - */ -typedef struct { - unsigned char src_ep; /**< Source endpoint */ - unsigned short zone_type; /**< Zone type 0x0000 : Standard CIE / Alarm1 - System Alarm, Alarm2 - N/A\n - * 0x000d : Motion Sensor / Alarm1 - Intrusion indication, Alarm2 - Presence indication\n - * 0x0015 : Contact switch / Alarm1 - 1st portal Open-Close, Alarm2 - 2nd portal Open-Close\n - * 0x0028 : Fire sensor / Alarm1 - Fire indication, Alarm2 - N/A\n - * 0x002a : Water sensor / Alarm1 - Water overflow indication, Alarm2 - N/A\n - * 0x002b : Gas Sensor / Alarm1 - CO indication, Alarm2 - Cooking indication\n - * 0x002c : Personal emergency Sensor / Alarm1 - Fall / Concussion, Alarm2 - Emergency button\n - * 0x002d : Vibration or Movement Sensor / Alarm1 - Movement indication, Alarm2 - Vibration\n - * 0x010f : Remote control / Alarm1 - Panic, Alarm2 - Emergency\n - * 0x0115 : Key fob / Alarm1 - Panic, Alarm2 - Emergency\n - * 0x021d : Keypad / Alarm1 - Panic, Alarm2 - Emergency\n - * 0x0225 : Standard Warning Device (see. EN 50131 European Standards Series for Intruder Alarm Systems) - * / Alarm1 - N/A, Alarm2 -N/A\n - * 0x8000~0xfffe : Reserved for manufacturer specific types / Alarm1 - N/A, Alarm2 - N/A\n - * 0xffff : Invalid Zone Type / Alarm1 - N/A, Alarm2 - N/A\n */ - unsigned char mfg_code; /**< Manufacturer Code */ -} zb_event_ias_enroll_request_s; - -/** - * @brief The structure type for the ZB_ZCL_IAS_ZONE_STATUS_CHANGE_NOTIFICATION_EVENT callback data. - * @details A Device which supports IAS zone cluster notifies its status change. - * - * @since_tizen 3.0 - */ -typedef struct { - unsigned char src_ep; /**< Source endpoint */ - unsigned short zone_status; /**< zone_status Bit 0 : Alarm1 : 1 - opened or alarmed / 0 - closed or not alarmed\n - * Bit 1 : Alarm2 : 1 - opened or alarmed / 0 - closed or not alarmed\n - * Bit 2 : Temper : 1 - Tempered / 0 - Not tempered\n - * Bit 3 : Battery : 1 - Low batter / 0 - Battery OK\n - * Bit 4 : Supervision report : 1 - Report / 0 - Does not report\n - * Note 1: This bit indicates whether the Zone issues periodic Zone Status Change\n - * Notification commands. The CIE device may use these periodic reports as an\n - * indication that a zone is operational. Zones that do not implement the periodic\n - * reporting are required to set this bit to zero (the CIE will know not to interpret the\n - * lack of reports as a problem).\n - * Bit 5 : Restore reports : 1 - Reports restore / 0 - Does not report restore\n - * Note 2: This bit indicates whether or not a Zone Status Change Notification\n - * command will be sent to indicate that an alarm is no longer present. Some Zones\n - * do not have the ability to detect that alarm condition is no longer present, they\n - * only can tell that an alarm has occurred. These Zones must set the "Restore" bit to\n - * zero, indicating to the CIE not to look for alarm-restore notifications.\n - * Bit 6 : Trouble : 1 - Trouble/Failure / 0 - OK\n - * Bit 7 : AC(mains) : 1 - ACMains fault / 0 - AC/Mains OK\n */ -} zb_event_ias_noti_s; - -/** - * @brief The structure type for the ZB_ZCL_IAS_ZONE_STATUS_CHANGE_EXTENDED_NOTIFICATION_EVENT callback data. - * @details A Device which supports IAS zone cluster notifies its status change. - * - * @since_tizen 3.0 - */ -typedef struct { - unsigned char src_ep; /**< Source endpoint */ - unsigned char extended_status; /**< Extended status */ - unsigned short zone_status; /**< Zone status */ - unsigned short delay; /**< Delay */ - unsigned char zone_id; /**< Zone ID */ -} zb_event_ias_extended_noti_s; - -/** - * @brief The structure type for response data of zb_event_cb. - * @details This function can receive events from the devices in the network. - * ex) join, re-join, leave and attribute change report - * - * @since_tizen 3.0 - */ -typedef struct { - union { - zb_event_enable_s *enable; /**< The result of enabling zigbee system service. */ - zb_event_form_network_s *form_network; /**< This event comes from coming network operation completed. */ - zb_event_join_s *join; /**< This event takes place when new device joined. */ - zb_event_child_left_s *child_left; /**< This event takes place when a child device leave current network explicitly. */ - zb_event_global_default_rsp_s *global_default_rsp; /**< This event is used when global default response. */ - zb_event_global_attr_report_s *global_attr_report; /**< This event is took place when report attribute command received. */ - zb_event_alarm_s *alarm; /**< This event is related to alarm cluster. */ - zb_event_ias_enroll_request_s *ias_enroll_request; /**< A Device which supports IAS zone cluster want to register its ability. */ - zb_event_ias_noti_s *ias_noti; /**< A Device which supports IAS zone cluster notifies its status change. */ - zb_event_ias_extended_noti_s *ias_extended_noti; /**< A Device which supports IAS zone cluster notifies its status change. */ - } data; -} zb_event_data_s; - -/** - * @brief APS Delivery Mode - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_APS_DELIVERY_UNICAST = 0, /**< Unicast delivery */ - ZB_APS_DELIVERY_INDIRECT = 1, /**< Indirect delivery */ - ZB_APS_DELIVERY_BROADCAST = 2, /**< Broadcast delivery */ - ZB_APS_DELIVERY_MULTICAST = 3 /**< Multicast delivery */ -} zb_aps_delivery_mode; - -/** - * @brief APS ACK Request - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_APS_NO_ACK_REQUEST = (0 << 6), /**< Not request ACK */ - ZB_APS_ACK_REQUEST = (1 << 6), /**< Request ACK */ -} zb_aps_ack_request; - -/** - * @brief Frame type at ZCL Header - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_FC_GLOBALLY_USED = (0 << 0), /**< profile widely used */ - ZB_APS_FC_CLUSTER_SPECIFIC = (1 << 0), /**< cluster specific */ -} zb_zcl_fc_type_e; - -/** - * @brief Manufacturer specific or not at ZCL Header - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_FC_NOT_MANUFACTURER = (0 << 2), /**< manufacturer code not present */ - ZB_ZCL_FC_MANUFACTURER = (1 << 2), /**< manufacturer code present */ -} zb_zcl_fc_manufacturer_present_e; - -/** - * @brief Request or Response at ZCL Header - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_CLIENT_TO_SERVER = (0 << 3), /**< request */ - ZB_ZCL_SERVER_TO_CLIENT = (1 << 3), /**< response */ -} zb_zcl_fc_direction_e; - -/** - * @brief Disable default response or not at ZCL Header - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_LEAVE_WELL_ALONE = (0 << 4), /**< enable default response */ - ZB_ZCL_DISABLE_DEFAULT_RESPONSE = (1 << 4), /**< disable default response */ -} zb_zcl_fc_disable_default_response_e; - -/** - * @brief default ZCL frame control at APS Header - * - * @since_tizen 3.0 - */ -#define ZB_ZCL_FC_DEFAULT 0x00 /**< Generally used / Not manufacture / Request / with Default Response */ - -/** - * @brief Broadcast address to all router device - * - * @since_tizen 3.0 - */ -#define ZB_BROADCAST_ADDRESS 0xFFFC /**< Broadcast to all routers. */ - -/** - * @brief Broadcast address to devices which support 'rx_on_idle' feature - * - * @since_tizen 3.0 - */ -#define ZB_RX_ON_WHEN_IDLE_BROADCAST_ADDRESS 0xFFFD /**< Broadcast to all non-sleepy devices. */ - -/** - * @brief Broadcast address to all devices - * - * @since_tizen 3.0 - */ -#define ZB_SLEEPY_BROADCAST_ADDRESS 0xFFFF /**< Broadcast to all devices, including sleepy end devices. */ - -/** - * @} - */ - -#endif /* __CAPI_NETWORK_ZIGBEE_CONSTANT_H__ */ diff --git a/include/zb-zcl.h b/include/zb-zcl.h deleted file mode 100644 index 4a055cf..0000000 --- a/include/zb-zcl.h +++ /dev/null @@ -1,2671 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_H__ - -/** - * @file zb-zcl.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE Zigbee Cluster Library - * - * @brief zigbee provides API for ZCL access. - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_MODULE_HEADER Header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_MODULE_OVERVIEW Overview - * This API set consists of ZCL access API - * - * @{ - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/** - * @brief Return readabble Zigbee Cluster Library status code for human - * @details Return Zigbee Cluster Library status code - * - * @since_tizen 3.0 - * - * @param[in] id ZigBee Cluster Library Status code - * - * @return pointer of status code string - * - */ -const char* zb_get_zcl_error_message(int id); - -/** - * @brief Return readable cluster name for human - * @details Return Zigbee Cluster name and ID - * - * @since_tizen 3.0 - * - * @param[in] id ZigBee Cluster ID - * - * @return pointer of cluster name string - * - */ -const char* zb_get_cluster_name(int id); - -/** - * @brief Return measuring unit of attribute type - * @details this help to know measuring unit of attribute type - * - * @since_tizen 3.0 - * - * @param[in] type attribute type - * - * @return #zb_zcl_data_category_e - * @retval #DATA_TYPE_NONE Data type none - * @retval #DATA_TYPE_DISCRETE Discrete data type - * @retval #DATA_TYPE_ANALOG Analog data type - * - */ -int zb_get_analog_or_discret(unsigned char type); - -/** - * @brief Return attribute size - * @details Return size of attribute data - * - * @since_tizen 3.0 - * - * @param[in] type attribute type - * - * @return size of attribute data type - * - */ -int zb_get_data_size(unsigned char type); - -/** - * @brief create simple value data - * @details The simple value data shall contain the data type of the attribute value - * according to the data type in (see Table 2.16). - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple data value - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_destroy_value() - */ -int zb_create_value( - zb_value_h *handle); - -/** - * @brief destroy simple value data - * @details Remove allocated memory for simple value data - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple data value - * - * @return None - * - * @see zb_create_value() - */ -void zb_destroy_value( - zb_value_h handle); - -/** - * @brief set value from zb_value_h - * @details get data from zb_value_h, expected value type as follows : \n - * val : 16 byte buffer \n - * ieee_addr addr64 : 64-bit IEEE address \n - * aes128_key key16 : 128-bit key \n - * str : for 1 byte string \n - * -> 1st byte is string length, the other are string data.) \n - * wstr : for 2 byte string \n - * -> 1st 2 byte are string length, the other are string data.) \n - * - * @since_tizen 3.0 - * - * @param[in] handle handle of value structure - * @param[in] type data type : \n - * @param[in] value read buffer - * @param[in] count number of read buffer - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_NO_DATA No data available - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - */ -int zb_set_value(zb_value_h handle, unsigned char type, unsigned char *value, int count); - -/** - * @brief get value from zb_value_h - * @details get data from zb_value_h, expected value type as follows : \n - * val : 16 byte buffer \n - * struct attribute_str_s *str : for 1 byte string \n - * -> 1st byte is string length, the other are string data.) \n - * struct attribute_wstr_s *wstr : for 2 byte string \n - * -> 1st 2 byte are string length, the other are string data.) \n - * - * @since_tizen 3.0 - * - * @param[in] handle handle of value structure - * @param[out] type data type - * @param[out] value read buffer - * @param[out] count number of read buffer - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_NO_DATA No data available - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - */ -int zb_get_value(zb_value_h handle, unsigned char *type, unsigned char **value, int *count); - -/** - * @brief create read attribute status record - * @details This allocates heap for read attribute status record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_destroy_read_attr_status_record() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - */ -int zb_create_read_attr_status_record(read_attr_status_record_h *handle); - -/** - * @brief destroy read attribute status record - * @details This destroys read attribute status record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_attr_status_record() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - */ -void zb_destroy_read_attr_status_record(read_attr_status_record_h handle); - -/** - * @brief get identifier from read attribute status record - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that has been read (or of which an element has been read). - * \n\n This field shall contain the same value that was included in the corresponding a - * ttribute identifier field of the original read attributes or read attributes structured - * command. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[out] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_attr_status_record() - * @see zb_destroy_read_attr_status_record() - * @see zb_set_id_to_read_attr_status_record() - * @see zb_set_status_to_read_attr_status_record() - * @see zb_set_type_to_read_attr_status_record() - * @see zb_set_value_to_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - */ -int zb_get_id_from_read_attr_status_record( - read_attr_status_record_h handle, - unsigned short* id); - -/** - * @brief set identifier to read attribute status record - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that has been read (or of which an element has been read). - * \n\n This field shall contain the same value that was included in the corresponding a - * ttribute identifier field of the original read attributes or read attributes structured - * command. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[in] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_attr_status_record() - * @see zb_destroy_read_attr_status_record() - * @see zb_set_status_to_read_attr_status_record() - * @see zb_set_type_to_read_attr_status_record() - * @see zb_set_value_to_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - */ -int zb_set_id_to_read_attr_status_record( - read_attr_status_record_h handle, - unsigned short id); - -/** - * @brief get identifier from read attribute status record - * @details The status field is 8 bits in length and specifies the status of the read - * operation on this attribute. \n\n This field shall be set to SUCCESS, if the operation - * was successful, or an error code, as specified in zb_zcl_status_e if the operation was - * not successful. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[out] status error code @see #zb_zcl_status_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_attr_status_record() - * @see zb_destroy_read_attr_status_record() - * @see zb_set_id_to_read_attr_status_record() - * @see zb_set_status_to_read_attr_status_record() - * @see zb_set_type_to_read_attr_status_record() - * @see zb_set_value_to_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - */ -int zb_get_status_from_read_attr_status_record( - read_attr_status_record_h handle, - unsigned char* status); - -/** - * @brief set identifier to read attribute status record - * @details The status field is 8 bits in length and specifies the status of the read - * operation on this attribute. \n\n This field shall be set to SUCCESS, if the operation - * was successful, or an error code, as specified in zb_zcl_status_e if the operation was - * not successful. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[in] status error code @see #zb_zcl_status_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_attr_status_record() - * @see zb_destroy_read_attr_status_record() - * @see zb_set_id_to_read_attr_status_record() - * @see zb_set_type_to_read_attr_status_record() - * @see zb_set_value_to_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - */ -int zb_set_status_to_read_attr_status_record( - read_attr_status_record_h handle, - unsigned char status); - - -/** - * @brief get identifier from read attribute status record - * @details The attribute data type field shall contain the data type of the attribute - * in the same read attributes status record (see Table 2.16). \n\n This field shall only - * be included in zb_zcl_data_type_e if the associated status field contains a value of - * SUCCESS. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[out] type data type in @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_attr_status_record() - * @see zb_destroy_read_attr_status_record() - * @see zb_set_id_to_read_attr_status_record() - * @see zb_set_status_to_read_attr_status_record() - * @see zb_set_type_to_read_attr_status_record() - * @see zb_set_value_to_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - */ -int zb_get_type_from_read_attr_status_record( - read_attr_status_record_h handle, - unsigned char *type); - -/** - * @brief set identifier to read attribute status record - * @details The attribute data type field shall contain the data type of the attribute - * in the same read attributes status record (see Table 2.16). \n\n This field shall only - * be included in zb_zcl_data_type_e if the associated status field contains a value of - * SUCCESS. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[in] type data type in @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_attr_status_record() - * @see zb_destroy_read_attr_status_record() - * @see zb_set_id_to_read_attr_status_record() - * @see zb_set_status_to_read_attr_status_record() - * @see zb_set_value_to_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - */ -int zb_set_type_to_read_attr_status_record( - read_attr_status_record_h handle, - unsigned char type); - -/** - * @brief get data value from read attribute status record - * @details The attribute value field is variable in length and shall contain the current - * value of this attribute. \n\n This field shall only be included if the associated - * status field contains a value of SUCCESS. \n\n - * For an attribute or element of simple type, this - * field has the format shown in the Table of Data Types (Table 2.16). - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[in] type data type in #zb_zcl_data_type_e - * @param[out] value data value pointer - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NO_DATA No data available - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_create_read_attr_status_record() - * @see zb_destroy_read_attr_status_record() - * @see zb_set_id_to_read_attr_status_record() - * @see zb_set_status_to_read_attr_status_record() - * @see zb_set_type_to_read_attr_status_record() - * @see zb_set_value_to_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - */ -int zb_get_value_from_read_attr_status_record( - read_attr_status_record_h handle, - unsigned char type, - zb_value_h value); - -/** - * @brief set data value to read attribute status record - * @details The attribute value field is variable in length and shall contain the current - * value of this attribute. \n\n This field shall only be included if the associated - * status field contains a value of SUCCESS. \n\n - * For an attribute or element of simple type, this - * field has the format shown in the Table of Data Types (Table 2.16). - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[in] type data type in #zb_zcl_data_type_e - * @param[in] value data value pointer - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NO_DATA No data available - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_create_read_attr_status_record() - * @see zb_destroy_read_attr_status_record() - * @see zb_set_id_to_read_attr_status_record() - * @see zb_set_status_to_read_attr_status_record() - * @see zb_set_type_to_read_attr_status_record() - * @see zb_zcl_global_read_attr_rsp() - * @see zb_get_id_from_read_attr_status_record() - * @see zb_get_status_from_read_attr_status_record() - * @see zb_get_type_from_read_attr_status_record() - * @see zb_get_value_from_read_attr_status_record() - */ -int zb_set_value_to_read_attr_status_record( - read_attr_status_record_h handle, - unsigned char type, - zb_value_h value); - -/** - * @brief create discover attribute infomation record - * @details This allocates heap for discover attribute infomation record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of discover attribute infomation record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_destroy_discover_attr_info() - * @see zb_get_id_from_discover_attr_info() - * @see zb_get_type_from_discover_attr_info() - * @see zb_zcl_global_discover_attr_rsp() - */ -int zb_create_discover_attr_info(discover_attr_info_record_h *handle); - -/** - * @brief destroy discover attribute infomation record - * @details This destroys discover attribute infomation record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of discover attribute infomation record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_discover_attr_info() - * @see zb_get_id_from_discover_attr_info() - * @see zb_get_type_from_discover_attr_info() - * @see zb_zcl_global_discover_attr_rsp() - */ -void zb_destroy_discover_attr_info(discover_attr_info_record_h handle); - -/** - * @brief get identifier from discover attribute info - * @details The attribute identifier field shall contain the identifier of a discovered - * attribute. \n\n Attributes shall be included in ascending order, starting with the - * lowest attribute identifier that is greater than or equal to the start attribute - * identifier field of the received discover attributes command. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[out] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_discover_attr_info() - * @see zb_destroy_discover_attr_info() - * @see zb_get_type_from_discover_attr_info() - * @see zb_zcl_global_discover_attr_rsp() - */ -int zb_get_id_from_discover_attr_info( - discover_attr_info_record_h handle, - unsigned short *id); - -/** - * @brief set identifier to discover attribute info - * @details The attribute identifier field shall contain the identifier of a discovered - * attribute. \n\n Attributes shall be included in ascending order, starting with the - * lowest attribute identifier that is greater than or equal to the start attribute - * identifier field of the received discover attributes command. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[in] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_discover_attr_info() - * @see zb_destroy_discover_attr_info() - * @see zb_get_type_from_discover_attr_info() - * @see zb_zcl_global_discover_attr_rsp() - */ -int zb_set_id_to_discover_attr_info( - discover_attr_info_record_h handle, - unsigned short id); - -/** - * @brief get data type from discover attribute info - * @details The attribute data type field shall contain the data type of the attribute in - * the same attribute report field (see Table 2.16) - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[out] type attribute data type @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_discover_attr_info() - * @see zb_destroy_discover_attr_info() - * @see zb_get_id_from_discover_attr_info() - * @see zb_zcl_global_discover_attr_rsp() - */ -int zb_get_type_from_discover_attr_info( - discover_attr_info_record_h handle, - unsigned char *type); - -/** - * @brief set data type to discover attribute info - * @details The attribute data type field shall contain the data type of the attribute in - * the same attribute report field (see Table 2.16) - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[in] type attribute data type @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_discover_attr_info() - * @see zb_destroy_discover_attr_info() - * @see zb_get_id_from_discover_attr_info() - * @see zb_zcl_global_discover_attr_rsp() - */ -int zb_set_type_to_discover_attr_info( - discover_attr_info_record_h handle, - unsigned char type); - -/** - * @brief create write attribute record - * @details Allocate memory for write attribute record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_zcl_global_write_attr() - * @see zb_zcl_global_write_attr_undivided() - * @see zb_zcl_global_write_attr_no_rep() - * @see zb_destroy_write_attr_record() - * @see zb_set_id_to_write_attr_record() - * @see zb_set_type_to_write_attr_record() - * @see zb_set_buf_to_write_attr_record() - * @see zb_set_value_to_write_attr_record() - */ -int zb_create_write_attr_record( - write_attr_record_h *handle); - -/** - * @brief destroy write attribute record - * @details Remove allocated memory for write attribute record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute record - * - * @return None - * - * @see zb_zcl_global_write_attr() - * @see zb_zcl_global_write_attr_undivided() - * @see zb_zcl_global_write_attr_no_rep() - * @see zb_create_write_attr_record() - * @see zb_set_id_to_write_attr_record() - * @see zb_set_type_to_write_attr_record() - * @see zb_set_buf_to_write_attr_record() - * @see zb_set_value_to_write_attr_record() - */ -void zb_destroy_write_attr_record( - write_attr_record_h handle); - -/** - * @brief set attribute identifier write attribute record - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that is to be written. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute record - * @param[in] id attribute identifier - * - * @return None - * - * @see zb_zcl_global_write_attr() - * @see zb_zcl_global_write_attr_undivided() - * @see zb_zcl_global_write_attr_no_rep() - * @see zb_create_write_attr_record() - * @see zb_destroy_write_attr_record() - * @see zb_set_type_to_write_attr_record() - * @see zb_set_buf_to_write_attr_record() - * @see zb_set_value_to_write_attr_record() - */ -int zb_set_id_to_write_attr_record( - write_attr_record_h handle, - unsigned short id); - -/** - * @brief set attribute data type write attribute record - * @details The attribute data type field shall contain the data type of the attribute - * that is to be written. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute record - * @param[in] type attribute data type - * - * @return None - * - * @see zb_zcl_global_write_attr() - * @see zb_zcl_global_write_attr_undivided() - * @see zb_zcl_global_write_attr_no_rep() - * @see zb_create_write_attr_record() - * @see zb_destroy_write_attr_record() - * @see zb_set_id_to_write_attr_record() - * @see zb_set_buf_to_write_attr_record() - * @see zb_set_value_to_write_attr_record() - */ -int zb_set_type_to_write_attr_record( - write_attr_record_h handle, - unsigned char type); - -/** - * @brief set attribute data write attribute record - * @details The attribute data type field shall contain the data type of the attribute - * that is to be written. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute record - * @param[in] type attribute type - * @param[in] value attribute data - * @param[in] count length of attribute data - * - * @return None - * - * @see zb_zcl_global_write_attr() - * @see zb_zcl_global_write_attr_undivided() - * @see zb_zcl_global_write_attr_no_rep() - * @see zb_create_write_attr_record() - * @see zb_destroy_write_attr_record() - * @see zb_set_id_to_write_attr_record() - * @see zb_set_type_to_write_attr_record() - * @see zb_set_buf_to_write_attr_record() - * @see zb_set_value_to_write_attr_record() - */ -int zb_set_buf_to_write_attr_record( - write_attr_record_h handle, - unsigned char type, - unsigned char *value, - int count); - -/** - * @brief set data value to write attribute status record - * @details The attribute data type field shall contain the data type of the attribute in - * the same attribute report field (see Table 2.16) - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] value attribute data value - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_write_attr() - * @see zb_zcl_global_write_attr_undivided() - * @see zb_zcl_global_write_attr_no_rep() - * @see zb_create_write_attr_record() - * @see zb_destroy_write_attr_record() - * @see zb_set_id_to_write_attr_record() - * @see zb_set_type_to_write_attr_record() - * @see zb_set_buf_to_write_attr_record() - */ -int zb_set_value_to_write_attr_record( - write_attr_record_h handle, - zb_value_h value); - -/** - * @brief create write attribute status record - * @details This allocates heap for write attribute status record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_write_attr_rsp() - * @see zb_destroy_write_attr_status() - * @see zb_get_status_from_write_attr_status() - * @see zb_get_id_from_write_attr_status() - */ -int zb_create_write_attr_status(write_attr_status_record_h *handle); - -/** - * @brief destroy write attribute status record - * @details This destroys write attribute status record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_write_attr_rsp() - * @see zb_create_write_attr_status() - * @see zb_get_id_from_discover_attr_info() - * @see zb_get_type_from_discover_attr_info() - - */ -void zb_destroy_write_attr_status(write_attr_status_record_h handle); - -/** - * @brief get status from write attribute status record - * @details The status field is 8 bits in length and specifies the status of the read - * operation on this attribute. \n\n This field shall be set to SUCCESS, if the operation - * was successful, or an error code, as specifed in zb_zcl_status_e if the operation was - * not successful. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[out] status error code @see #zb_zcl_status_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_write_attr_rsp() - * @see zb_get_id_from_write_attr_status() - */ -int zb_get_status_from_write_attr_status( - write_attr_status_record_h handle, - unsigned char *status); - -/** - * @brief set status to write attribute status record - * @details The status field is 8 bits in length and specifies the status of the read - * operation on this attribute. \n\n This field shall be set to SUCCESS, if the operation - * was successful, or an error code, as specifed in zb_zcl_status_e if the operation was - * not successful. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read attribute status record - * @param[in] status error code @see #zb_zcl_status_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_write_attr_rsp() - * @see zb_get_status_from_write_attr_status() - * @see zb_get_id_from_write_attr_status() - * @see zb_set_id_to_write_attr_status() - */ -int zb_set_status_to_write_attr_status( - write_attr_status_record_h handle, - unsigned char status); - -/** - * @brief get identifier from write attribute status record - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that has been write (or of which an element has been write). - * \n\n This field shall contain the same value that was included in the corresponding a - * ttribute identifier field of the original write attributes or write attributes - * structured command. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_write_attr_rsp() - * @see zb_get_status_from_write_attr_status() - * @see zb_set_status_to_write_attr_status() - * @see zb_set_id_to_write_attr_status() - */ -int zb_get_id_from_write_attr_status( - write_attr_status_record_h handle, - unsigned short *id); - -/** - * @brief set identifier to write attribute status record - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that has been write (or of which an element has been write). - * \n\n This field shall contain the same value that was included in the corresponding a - * ttribute identifier field of the original write attributes or write attributes - * structured command. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_write_attr_rsp() - * @see zb_get_status_from_write_attr_status() - * @see zb_set_status_to_write_attr_status() - * @see zb_get_id_from_write_attr_status() - */ -int zb_set_id_to_write_attr_status( - write_attr_status_record_h handle, - unsigned short id); - -/** - * @brief create reporting configuration record - * @details Allocate memory for reporting configuration record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of reporting configuration record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_create_report_config_record( - report_config_record_h *handle); - -/** - * @brief destroy reporting configuration record - * @details This destroys reporting configuration record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of reporting configuration record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -void zb_destroy_report_config_record( - report_config_record_h handle); - -/** - * @brief get direction from reporting configuration record - * @details The direction field specifies whether values of the attribute are be reported, - * or whether reports of the attribute are to be received. \n\n - * If this value is set to 0x00, then the attribute data type field, the minimum - * reporting interval field, the maximum reporting interval field and the reportable - * change field are included in the payload, and the timeout period field is omitted. - * The record is sent to a cluster server (or client) to configure how it sends reports to - * a client (or server) of the same cluster. \n\n - * If this value is set to 0x01, then the timeout period field is included in the payload, - * and the attribute data type field, the minimum reporting interval field, the - * maximum reporting interval field and the reportable change field are omitted. The - * record is sent to a cluster client (or server) to configure how it should expect - * reports from a server (or client) of the same cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] dir 00 : The receiver of the Configure Reporting command shall configure - * reporting to send to each destination as resolved by - * the bindings for the cluster hosting the attributes to be reported.\n - * 01 : This indicates to the receiver of the Configure Reporting - * command that the sender has configured its reporting - * mechanism to transmit reports and that, based on the current - * state of the sender's bindings, the sender will send reports to the - * receiver.\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_dir_from_report_config_record( - report_config_record_h handle, - unsigned char *dir); - -/** - * @brief set direction to reporting configuration record - * @details The direction field specifies whether values of the attribute are be reported, - * or whether reports of the attribute are to be received. \n\n - * If this value is set to 0x00, then the attribute data type field, the minimum - * reporting interval field, the maximum reporting interval field and the reportable - * change field are included in the payload, and the timeout period field is omitted. - * The record is sent to a cluster server (or client) to configure how it sends reports to - * a client (or server) of the same cluster. \n\n - * If this value is set to 0x01, then the timeout period field is included in the payload, - * and the attribute data type field, the minimum reporting interval field, the - * maximum reporting interval field and the reportable change field are omitted. The - * record is sent to a cluster client (or server) to configure how it should expect - * reports from a server (or client) of the same cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] dir 00 : The receiver of the Configure Reporting command shall configure - * reporting to send to each destination as resolved by - * the bindings for the cluster hosting the attributes to be reported.\n - * 01 : This indicates to the receiver of the Configure Reporting - * command that the sender has configured its reporting - * mechanism to transmit reports and that, based on the current - * state of the sender's bindings, the sender will send reports to the - * receiver.\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_set_dir_to_report_config_record( - report_config_record_h handle, - unsigned char dir); - -/** - * @brief get attribute identifier from reporting configuration record - * @details If the direction field is 0x00, this field contains the identifier of the - * attribute that is to be reported. \n\n If instead the direction field is 0x01, - * the device shall expect reports of values of this attribute. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_id_from_report_config_record( - report_config_record_h handle, - unsigned short *id); - -/** - * @brief set attribute identifier to reporting configuration record - * @details If the direction field is 0x00, this field contains the identifier of the - * attribute that is to be reported. \n\n If instead the direction field is 0x01, - * the device shall expect reports of values of this attribute. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_set_id_to_report_config_record( - report_config_record_h handle, - unsigned short id); - -/** - * @brief get attribute data type from reporting configuration record - * @details The Attribute data type field contains the data type of the attribute that is - * to be reported. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] type attribute data type @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_type_from_report_config_record( - report_config_record_h handle, - unsigned char *type); - -/** - * @brief set attribute data type to reporting configuration record - * @details The Attribute data type field contains the data type of the attribute that is - * to be reported. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] type attribute data type @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_set_type_to_report_config_record( - report_config_record_h handle, - unsigned char type); - -/** - * @brief get minimum interval from reporting configuration record - * @details The minimum reporting interval field is 16 bits in length and shall contain - * the minimum interval, in seconds, between issuing reports of the specified attribute. - * \n\n - * If this value is set to 0x0000, then there is no minimum limit, unless one is - * imposed by the specification of the cluster using this reporting mechanism or by - * the applicable profile. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] min_i minimum interval time - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_min_i_from_report_config_record( - report_config_record_h handle, - unsigned short *min_i); - -/** - * @brief set minimum interval to reporting configuration record - * @details The minimum reporting interval field is 16 bits in length and shall contain - * the minimum interval, in seconds, between issuing reports of the specified attribute. - * \n\n - * If this value is set to 0x0000, then there is no minimum limit, unless one is - * imposed by the specification of the cluster using this reporting mechanism or by - * the applicable profile. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] min_i minimum interval time - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_set_min_i_to_report_config_record( - report_config_record_h handle, - unsigned short min_i); - -/** - * @brief get maximum interval from reporting configuration record - * @details The maximum reporting interval field is 16 bits in length and shall contain - * the maximum interval, in seconds, between issuing reports of the specified attribute. - * \n\n - * If this value is set to 0xffff, then the device shall not issue reports for the - * specified attribute, and the configuration information for that attribute need not be - * maintained. \n\n (Note: in an implementation using dynamic memory allocation, the - * memory space for that information may then be reclaimed). - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] max_i maximum interval time - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_max_i_from_report_config_record( - report_config_record_h handle, - unsigned short *max_i); - -/** - * @brief set maximum interval to reporting configuration record - * @details The maximum reporting interval field is 16 bits in length and shall contain - * the maximum interval, in seconds, between issuing reports of the specified attribute. - * \n\n - * If this value is set to 0xffff, then the device shall not issue reports for the - * specified attribute, and the configuration information for that attribute need not be - * maintained. \n\n (Note: in an implementation using dynamic memory allocation, the - * memory space for that information may then be reclaimed). - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] max_i maximum interval time - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_set_max_i_to_report_config_record( - report_config_record_h handle, - unsigned short max_i); - -/** - * @brief get timeout from reporting configuration record - * @details The timeout period field is 16 bits in length and shall contain the maximum - * expected time, in seconds, between received reports for the attribute specified in - * the attribute identifier field. If more time than this elapses between reports, this - * may be an indication that there is a problem with reporting. \n\n - * If this value is set to 0x0000, reports of the attribute are not subject to timeout. - * Note that, for a server/client connection to work properly using automatic - * reporting, the timeout value set for attribute reports to be received by the client (or - * server) cluster must be set somewhat higher than the maximum reporting interval - * set for the attribute on the server (or client) cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] timeout timeout - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_timeout_from_report_config_record( - report_config_record_h handle, - unsigned short *timeout); - -/** - * @brief set timeout to reporting configuration record - * @details The timeout period field is 16 bits in length and shall contain the maximum - * expected time, in seconds, between received reports for the attribute specified in - * the attribute identifier field. If more time than this elapses between reports, this - * may be an indication that there is a problem with reporting. \n\n - * If this value is set to 0x0000, reports of the attribute are not subject to timeout. - * Note that, for a server/client connection to work properly using automatic - * reporting, the timeout value set for attribute reports to be received by the client (or - * server) cluster must be set somewhat higher than the maximum reporting interval - * set for the attribute on the server (or client) cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] timeout timeout - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_set_timeout_to_report_config_record( - report_config_record_h handle, - unsigned short timeout); - -/** - * @brief get change from reporting configuration record - * @details The reportable change field shall contain the minimum change to the attribute - * that will result in a report being issued. This field is of variable length. \n\n - * For attributes with 'analog' data type (see Table 2.16) the field has the same data - * type as the attribute. \n\n The sign (if any) of the reportable change field is ignored. - * \n - * For attributes of 'discrete' data type (see Table 2.16) this field is omitted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] value data (only analog data type is allowed) - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_change_from_report_config_record1( - report_config_record_h handle, - zb_value_h value); - -/** - * @brief set change to reporting configuration record - * @details The reportable change field shall contain the minimum change to the attribute - * that will result in a report being issued. This field is of variable length. \n\n - * For attributes with 'analog' data type (see Table 2.16) the field has the same data - * type as the attribute. \n\n The sign (if any) of the reportable change field is ignored. - * \n - * For attributes of 'discrete' data type (see Table 2.16) this field is omitted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] value data (only analog data type is allowed) - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_set_change_to_report_config_record1( - report_config_record_h handle, - zb_value_h value); - -/** - * @brief get change from reporting configuration record - * @details The reportable change field shall contain the minimum change to the attribute - * that will result in a report being issued. This field is of variable length. \n\n - * For attributes with 'analog' data type (see Table 2.16) the field has the same data - * type as the attribute. \n\n The sign (if any) of the reportable change field is ignored. - * \n - * For attributes of 'discrete' data type (see Table 2.16) this field is omitted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] type attribute type - * @param[out] value attribute data which is allocated in library (only analog data type is allowed) - * @param[out] size attribute data size - * - * @remark value : generated from library you MUST free it - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_change_from_report_config_record2( - report_config_record_h handle, - unsigned char *type, - unsigned char **value, - int *size); - -/** - * @brief set change to reporting configuration record - * @details The reportable change field shall contain the minimum change to the attribute - * that will result in a report being issued. This field is of variable length. \n\n - * For attributes with 'analog' data type (see Table 2.16) the field has the same data - * type as the attribute. \n\n The sign (if any) of the reportable change field is ignored. - * \n - * For attributes of 'discrete' data type (see Table 2.16) this field is omitted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] type attribute type - * @param[in] value attribute data (only analog data type is allowed) - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_set_change_to_report_config_record2( - report_config_record_h handle, - unsigned char type, - unsigned char *value); - -/** - * @brief get change from reporting configuration record - * @details The reportable change field shall contain the minimum change to the attribute - * that will result in a report being issued. This field is of variable length. \n\n - * For attributes with 'analog' data type (see Table 2.16) the field has the same data - * type as the attribute. \n\n The sign (if any) of the reportable change field is ignored. - * \n - * For attributes of 'discrete' data type (see Table 2.16) this field is omitted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] type attribute type - * @param[out] value attribute data (only analog data type is allowed) - * @param[out] size attribute data size - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_change_from_report_config_record2( - report_config_record_h handle, - unsigned char *type, - unsigned char **value, - int *size); - -/** - * @brief get change from reporting configuration record - * @details The reportable change field shall contain the minimum change to the attribute - * that will result in a report being issued. This field is of variable length. \n\n - * For attributes with 'analog' data type (see Table 2.16) the field has the same data - * type as the attribute. \n\n The sign (if any) of the reportable change field is ignored. - * \n - * For attributes of 'discrete' data type (see Table 2.16) this field is omitted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] type attribute type - * @param[out] value attribute data (only analog data type is allowed) - * @param[out] size attribute data size - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_read_report_config_rsp() - * @see zb_create_report_config_record() - * @see zb_destroy_report_config_record() - * @see zb_get_id_from_report_config_record() - * @see zb_set_id_to_report_config_record() - * @see zb_get_dir_from_report_config_record() - * @see zb_set_dir_to_report_config_record() - * @see zb_get_type_from_report_config_record() - * @see zb_set_type_to_report_config_record() - * @see zb_get_min_i_from_report_config_record() - * @see zb_set_min_i_to_report_config_record() - * @see zb_get_max_i_from_report_config_record() - * @see zb_set_max_i_to_report_config_record() - * @see zb_get_change_from_report_config_record1() - * @see zb_set_change_to_report_config_record1() - * @see zb_get_change_from_report_config_record2() - * @see zb_set_change_to_report_config_record2() - * @see zb_get_change_from_report_config_record3() - * @see zb_get_timeout_from_report_config_record() - * @see zb_set_timeout_to_report_config_record() - */ -int zb_get_change_from_report_config_record3( - report_config_record_h handle, - unsigned char *type, - unsigned char *value, - int *size); - -/** - * @brief create read reporting configuration record - * @details Allocate memory for read reporting configuration record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of read configuration record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_create_read_report_config_record() - * @see zb_destroy_read_report_config_record() - * @see zb_get_id_from_read_report_config_record() - * @see zb_set_id_to_read_report_config_record() - * @see zb_get_dir_from_read_report_config_record() - * @see zb_set_dir_to_read_report_config_record() - */ -int zb_create_read_report_config_record( - read_report_config_record_h *handle); - -/** - * @brief destroy read reporting configuration record - * @details Remove allocated memory for read reporting configuration record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute record - * - * @return None - * - * @see zb_create_read_report_config_record() - * @see zb_destroy_read_report_config_record() - * @see zb_get_id_from_read_report_config_record() - * @see zb_set_id_to_read_report_config_record() - * @see zb_get_dir_from_read_report_config_record() - * @see zb_set_dir_to_read_report_config_record() - */ -void zb_destroy_read_report_config_record( - read_report_config_record_h handle); - -/** - * @brief get direction from read reporting configuration record - * @details The direction field specifies whether values of the attribute are reported - * (0x00), or whether reports of the attribute are received (0x01). \n\n - * All other values of this field are reserved. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] dir direction - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_report_config_record() - * @see zb_destroy_read_report_config_record() - * @see zb_get_id_from_read_report_config_record() - * @see zb_set_id_to_read_report_config_record() - * @see zb_get_dir_from_read_report_config_record() - * @see zb_set_dir_to_read_report_config_record() - */ -int zb_get_dir_from_read_report_config_record( - read_report_config_record_h handle, - unsigned char *dir); - -/** - * @brief set direction to read reporting configuration record - * @details The direction field specifies whether values of the attribute are reported - * (0x00), or whether reports of the attribute are received (0x01). \n\n - * All other values of this field are reserved. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] dir direction - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_report_config_record() - * @see zb_destroy_read_report_config_record() - * @see zb_get_id_from_read_report_config_record() - * @see zb_set_id_to_read_report_config_record() - * @see zb_get_dir_from_read_report_config_record() - * @see zb_set_dir_to_read_report_config_record() - */ -int zb_set_dir_to_read_report_config_record( - read_report_config_record_h handle, - unsigned char dir); - -/** - * @brief get attribute idenitifier from read reporting configuration record - * @details The attribute identifier field shall contain the identifier of the attribute - * whose reporting configuration details are to be read. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_report_config_record() - * @see zb_destroy_read_report_config_record() - * @see zb_get_id_from_read_report_config_record() - * @see zb_set_id_to_read_report_config_record() - * @see zb_get_dir_from_read_report_config_record() - * @see zb_set_dir_to_read_report_config_record() - */ -int zb_get_id_from_read_report_config_record( - read_report_config_record_h handle, - unsigned short *id); - -/** - * @brief get attribute idenitifier from read reporting configuration record - * @details The attribute identifier field shall contain the identifier of the attribute - * whose reporting configuration details are to be read. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_create_read_report_config_record() - * @see zb_destroy_read_report_config_record() - * @see zb_get_id_from_read_report_config_record() - * @see zb_set_id_to_read_report_config_record() - * @see zb_get_dir_from_read_report_config_record() - * @see zb_set_dir_to_read_report_config_record() - */ -int zb_set_id_to_read_report_config_record( - read_report_config_record_h handle, - unsigned short id); - -/** - * @brief create reporting configuration response record - * @details Allocate memory for reporting configuration response record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of reporting configuration response record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_zcl_global_config_report_rsp() - * @see zb_create_report_config_response_record() - * @see zb_destroy_report_config_response_record() - * @see zb_get_status_from_report_config_response_record() - * @see zb_set_status_to_report_config_response_record() - * @see zb_get_dir_from_report_config_response_record() - * @see zb_set_dir_to_report_config_response_record() - * @see zb_get_id_from_report_config_response_record() - * @see zb_set_id_to_report_config_response_record() - */ -int zb_create_report_config_response_record( - report_config_response_record_h *handle); - -/** - * @brief destroy reporting configuration response record - * @details This destroys reporting configuration response record - * - * @since_tizen 3.0 - * - * @param[in] handle handle of reporting configuration response record - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_config_report_rsp() - * @see zb_create_report_config_response_record() - * @see zb_destroy_report_config_response_record() - * @see zb_get_status_from_report_config_response_record() - * @see zb_set_status_to_report_config_response_record() - * @see zb_get_dir_from_report_config_response_record() - * @see zb_set_dir_to_report_config_response_record() - * @see zb_get_id_from_report_config_response_record() - * @see zb_set_id_to_report_config_response_record() - */ -void zb_destroy_report_config_response_record( - report_config_response_record_h handle); - -/** - * @brief get status from reporting configuration response record - * @details If the attribute is not implemented on the sender or receiver of the command, - * whichever is relevant (depending on direction), this field shall be set to - * UNSUPPORTED_ATTRIBUTE. \n If the attribute is supported, but is not capable of - * being reported, this field shall be set to UNREPORTABLE_ATTRIBUTE. \n - * Otherwise, this field shall be set to SUCCESS. \n - * If the status field is not set to SUCCESS, all fields except the direction and - * attribute identifier fields shall be omitted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] status status @see #zb_zcl_status_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_config_report_rsp() - * @see zb_create_report_config_response_record() - * @see zb_destroy_report_config_response_record() - * @see zb_get_status_from_report_config_response_record() - * @see zb_set_status_to_report_config_response_record() - * @see zb_get_dir_from_report_config_response_record() - * @see zb_set_dir_to_report_config_response_record() - * @see zb_get_id_from_report_config_response_record() - * @see zb_set_id_to_report_config_response_record() - */ -int zb_get_status_from_report_config_response_record( - report_config_response_record_h handle, - unsigned char *status); - -/** - * @brief set status to reporting configuration response record - * @details If the attribute is not implemented on the sender or receiver of the command, - * whichever is relevant (depending on direction), this field shall be set to - * UNSUPPORTED_ATTRIBUTE. \n If the attribute is supported, but is not capable of - * being reported, this field shall be set to UNREPORTABLE_ATTRIBUTE. \n - * Otherwise, this field shall be set to SUCCESS. \n - * If the status field is not set to SUCCESS, all fields except the direction and - * attribute identifier fields shall be omitted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] status status @see #zb_zcl_status_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_config_report_rsp() - * @see zb_create_report_config_response_record() - * @see zb_destroy_report_config_response_record() - * @see zb_get_status_from_report_config_response_record() - * @see zb_set_status_to_report_config_response_record() - * @see zb_get_dir_from_report_config_response_record() - * @see zb_set_dir_to_report_config_response_record() - * @see zb_get_id_from_report_config_response_record() - * @see zb_set_id_to_report_config_response_record() - */ -int zb_set_status_to_report_config_response_record( - report_config_response_record_h handle, - unsigned char status); - -/** - * @brief get direction from reporting configuration response record - * @details The direction field specifies whether values of the attribute are reported - * (0x00), or whether reports of the attribute are received (0x01). \n\n - * If this value is set to 0x00, then the attribute data type field, the minimum - * reporting interval field, the maximum reporting interval field and the reportable - * change field are included in the payload, and the timeout period field is omitted. If - * this value is set to 0x01, then the timeout period field is included in the payload, - * and the attribute data type field, the minimum reporting interval field, the - * maximum reporting interval field and the reportable change field are omitted. \n\n - * All other values of this field are reserved. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] dir direction 00 : Client-to-Server \n - * 01 : server-to-Client \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_config_report_rsp() - * @see zb_create_report_config_response_record() - * @see zb_destroy_report_config_response_record() - * @see zb_get_status_from_report_config_response_record() - * @see zb_set_status_to_report_config_response_record() - * @see zb_get_dir_from_report_config_response_record() - * @see zb_set_dir_to_report_config_response_record() - * @see zb_get_id_from_report_config_response_record() - * @see zb_set_id_to_report_config_response_record() - */ -int zb_get_dir_from_report_config_response_record( - report_config_response_record_h handle, - unsigned char *dir); - -/** - * @brief set direction to reporting configuration response record - * @details The direction field specifies whether values of the attribute are reported - * (0x00), or whether reports of the attribute are received (0x01). \n\n - * If this value is set to 0x00, then the attribute data type field, the minimum - * reporting interval field, the maximum reporting interval field and the reportable - * change field are included in the payload, and the timeout period field is omitted. If - * this value is set to 0x01, then the timeout period field is included in the payload, - * and the attribute data type field, the minimum reporting interval field, the - * maximum reporting interval field and the reportable change field are omitted. \n\n - * All other values of this field are reserved. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] dir direction 00 : Client-to-Server \n - * 01 : server-to-Client \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_config_report_rsp() - * @see zb_create_report_config_response_record() - * @see zb_destroy_report_config_response_record() - * @see zb_get_status_from_report_config_response_record() - * @see zb_set_status_to_report_config_response_record() - * @see zb_get_dir_from_report_config_response_record() - * @see zb_set_dir_to_report_config_response_record() - * @see zb_get_id_from_report_config_response_record() - * @see zb_set_id_to_report_config_response_record() - */ -int zb_set_dir_to_report_config_response_record( - report_config_response_record_h handle, - unsigned char dir); - -/** - * @brief get attribute identifier from reporting configuration response record - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that the reporting configuration details apply to. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_config_report_rsp() - * @see zb_create_report_config_response_record() - * @see zb_destroy_report_config_response_record() - * @see zb_get_status_from_report_config_response_record() - * @see zb_set_status_to_report_config_response_record() - * @see zb_get_dir_from_report_config_response_record() - * @see zb_set_dir_to_report_config_response_record() - * @see zb_get_id_from_report_config_response_record() - * @see zb_set_id_to_report_config_response_record() - */ -int zb_get_id_from_report_config_response_record( - report_config_response_record_h handle, - unsigned short *id); - -/** - * @brief set attribute identifier to reporting configuration response record - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that the reporting configuration details apply to. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_config_report_rsp() - * @see zb_create_report_config_response_record() - * @see zb_destroy_report_config_response_record() - * @see zb_get_status_from_report_config_response_record() - * @see zb_set_status_to_report_config_response_record() - * @see zb_get_dir_from_report_config_response_record() - * @see zb_set_dir_to_report_config_response_record() - * @see zb_get_id_from_report_config_response_record() - * @see zb_set_id_to_report_config_response_record() - */ -int zb_set_id_to_report_config_response_record( - report_config_response_record_h handle, - unsigned short id); - -/** - * @brief create reporting attribute - * @details Allocate memory for reporting attribute - * - * @since_tizen 3.0 - * - * @param[in] handle handle of reporting attribute - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_event_get_attr_report() - * @see zb_create_attr_report() - * @see zb_destroy_attr_report() - * @see zb_get_id_from_attr_report() - * @see zb_set_id_to_attr_report() - * @see zb_get_type_from_attr_report() - * @see zb_set_type_to_attr_report() - * @see zb_get_value_from_attr_report() - * @see zb_set_value_to_attr_report() - */ -int zb_create_attr_report( - attr_report_h *handle); - -/** - * @brief destroy reporting attribute - * @details This destroys reporting attribute - * - * @since_tizen 3.0 - * - * @param[in] handle handle of reporting attribute - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_event_get_attr_report() - * @see zb_create_attr_report() - * @see zb_destroy_attr_report() - * @see zb_get_id_from_attr_report() - * @see zb_set_id_to_attr_report() - * @see zb_get_type_from_attr_report() - * @see zb_set_type_to_attr_report() - * @see zb_get_value_from_attr_report() - * @see zb_set_value_to_attr_report() - */ -void zb_destroy_attr_report( - attr_report_h handle); - -/** - * @brief get attribute identifier from reporting attribute - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that the reporting configuration details apply to. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_event_get_attr_report() - * @see zb_create_attr_report() - * @see zb_destroy_attr_report() - * @see zb_get_id_from_attr_report() - * @see zb_set_id_to_attr_report() - * @see zb_get_type_from_attr_report() - * @see zb_set_type_to_attr_report() - * @see zb_get_value_from_attr_report() - * @see zb_set_value_to_attr_report() - */ -int zb_get_id_from_attr_report( - attr_report_h handle, - unsigned short *id); - -/** - * @brief set attribute identifier to reporting attribute - * @details The attribute identifier field is 16 bits in length and shall contain the - * identifier of the attribute that the reporting configuration details apply to. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_event_get_attr_report() - * @see zb_create_attr_report() - * @see zb_destroy_attr_report() - * @see zb_get_id_from_attr_report() - * @see zb_set_id_to_attr_report() - * @see zb_get_type_from_attr_report() - * @see zb_set_type_to_attr_report() - * @see zb_get_value_from_attr_report() - * @see zb_set_value_to_attr_report() - */ -int zb_set_id_to_attr_report( - attr_report_h handle, - unsigned short id); - -/** - * @brief get attribute type from reporting attribute - * @details The attribute data type field contains the data type of the attribute that is - * being reported. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] type attribute data type @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_event_get_attr_report() - * @see zb_create_attr_report() - * @see zb_destroy_attr_report() - * @see zb_get_id_from_attr_report() - * @see zb_set_id_to_attr_report() - * @see zb_get_type_from_attr_report() - * @see zb_set_type_to_attr_report() - * @see zb_get_value_from_attr_report() - * @see zb_set_value_to_attr_report() - */ -int zb_get_type_from_attr_report( - attr_report_h handle, - unsigned char *type); - -/** - * @brief set attribute type to reporting attribute - * @details The attribute data type field contains the data type of the attribute that is - * being reported. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] type attribute data type @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_event_get_attr_report() - * @see zb_create_attr_report() - * @see zb_destroy_attr_report() - * @see zb_get_id_from_attr_report() - * @see zb_set_id_to_attr_report() - * @see zb_get_type_from_attr_report() - * @see zb_set_type_to_attr_report() - * @see zb_get_value_from_attr_report() - * @see zb_set_value_to_attr_report() - */ -int zb_set_type_to_attr_report( - attr_report_h handle, - unsigned char type); - -/** - * @brief get attribute data from reporting attribute - * @details The attribute data field is variable in length and shall contain the actual - * value of the attribute being reported. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] value attribute value - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_NO_DATA No data available - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_event_get_attr_report() - * @see zb_create_attr_report() - * @see zb_destroy_attr_report() - * @see zb_get_id_from_attr_report() - * @see zb_set_id_to_attr_report() - * @see zb_get_type_from_attr_report() - * @see zb_set_type_to_attr_report() - * @see zb_get_value_from_attr_report() - * @see zb_set_value_to_attr_report() - */ -int zb_get_value_from_attr_report( - attr_report_h handle, - zb_value_h value); - -/** - * @brief set attribute data to reporting attribute - * @details The attribute data field is variable in length and shall contain the actual - * value of the attribute being reported. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] value attribute value - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_NO_DATA No data available - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_event_get_attr_report() - * @see zb_create_attr_report() - * @see zb_destroy_attr_report() - * @see zb_get_id_from_attr_report() - * @see zb_set_id_to_attr_report() - * @see zb_get_type_from_attr_report() - * @see zb_set_type_to_attr_report() - * @see zb_get_value_from_attr_report() - * @see zb_set_value_to_attr_report() - */ -int zb_set_value_to_attr_report( - attr_report_h handle, - zb_value_h value); - -/** - * @brief create extended attribute information - * @details Allocate memory for extended attribute information - * - * @since_tizen 3.0 - * - * @param[in] handle handle of extended attribute information - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_zcl_global_discover_attr_extended_rsp() - * @see zb_create_extended_attr_report() - * @see zb_destroy_extended_attr_report() - * @see zb_get_id_from_extended_attr_info() - * @see zb_set_id_to_extended_attr_info() - * @see zb_get_type_from_extended_attr_info() - * @see zb_set_type_to_extended_attr_info() - * @see zb_get_acl_from_extended_attr_info() - * @see zb_set_acl_to_extended_attr_info() - */ -int zb_create_extended_attr_info( - extended_attr_info_h *handle); - -/** - * @brief destroy extended attribute information - * @details This destroys extended attribute information - * - * @since_tizen 3.0 - * - * @param[in] handle handle of extended attribute information - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_discover_attr_extended_rsp() - * @see zb_create_extended_attr_report() - * @see zb_destroy_extended_attr_report() - * @see zb_get_id_from_extended_attr_info() - * @see zb_set_id_to_extended_attr_info() - * @see zb_get_type_from_extended_attr_info() - * @see zb_set_type_to_extended_attr_info() - * @see zb_get_acl_from_extended_attr_info() - * @see zb_set_acl_to_extended_attr_info() - */ -void zb_destroy_extended_attr_info( - extended_attr_info_h handle); - -/** - * @brief get attribute identifier from extended attribute information - * @details The attribute identifier field shall contain the identifier of a discovered - * attribute. \n - * Attributes shall be included in ascending order, starting with the lowest attribute - * identifier that is greater than or equal to the start attribute identifier field of the - * received discover attributes command. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_discover_attr_extended_rsp() - * @see zb_create_extended_attr_report() - * @see zb_destroy_extended_attr_report() - * @see zb_get_id_from_extended_attr_info() - * @see zb_set_id_to_extended_attr_info() - * @see zb_get_type_from_extended_attr_info() - * @see zb_set_type_to_extended_attr_info() - * @see zb_get_acl_from_extended_attr_info() - * @see zb_set_acl_to_extended_attr_info() - */ -int zb_get_id_from_extended_attr_info( - extended_attr_info_h handle, - unsigned short *id); - -/** - * @brief set attribute identifier to extended attribute information - * @details The attribute identifier field shall contain the identifier of a discovered - * attribute. \n - * Attributes shall be included in ascending order, starting with the lowest attribute - * identifier that is greater than or equal to the start attribute identifier field of the - * received discover attributes command. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] id attribute identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_discover_attr_extended_rsp() - * @see zb_create_extended_attr_report() - * @see zb_destroy_extended_attr_report() - * @see zb_get_id_from_extended_attr_info() - * @see zb_set_id_to_extended_attr_info() - * @see zb_get_type_from_extended_attr_info() - * @see zb_set_type_to_extended_attr_info() - * @see zb_get_acl_from_extended_attr_info() - * @see zb_set_acl_to_extended_attr_info() - */ -int zb_set_id_to_extended_attr_info( - extended_attr_info_h handle, - unsigned short id); - -/** - * @brief get attribute identifier type from extended attribute information - * @details The attribute data type field shall contain the data type of the attribute in - * the same attribute report field - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] type attribute data type @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_discover_attr_extended_rsp() - * @see zb_create_extended_attr_report() - * @see zb_destroy_extended_attr_report() - * @see zb_get_id_from_extended_attr_info() - * @see zb_set_id_to_extended_attr_info() - * @see zb_get_type_from_extended_attr_info() - * @see zb_set_type_to_extended_attr_info() - * @see zb_get_acl_from_extended_attr_info() - * @see zb_set_acl_to_extended_attr_info() - */ -int zb_get_type_from_extended_attr_info( - extended_attr_info_h handle, - unsigned char *type); - -/** - * @brief set attribute identifier type to extended attribute information - * @details The attribute data type field shall contain the data type of the attribute in - * the same attribute report field - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] type attribute data type @see #zb_zcl_data_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_discover_attr_extended_rsp() - * @see zb_create_extended_attr_report() - * @see zb_destroy_extended_attr_report() - * @see zb_get_id_from_extended_attr_info() - * @see zb_set_id_to_extended_attr_info() - * @see zb_get_type_from_extended_attr_info() - * @see zb_set_type_to_extended_attr_info() - * @see zb_get_acl_from_extended_attr_info() - * @see zb_set_acl_to_extended_attr_info() - */ -int zb_set_type_to_extended_attr_info( - extended_attr_info_h handle, - unsigned char type); - -/** - * @brief get access control field from extended attribute information - * @details The attribute access control field shall indicate whether the attribute is - * readable, writable, and/or reportable. This is an 8-bit bitmask field. \n - * The bits are in little endian order (bit 0 is listed first). - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[out] acl ZB_ZCL_WRITABLE : Bit-0., Writable \n - * ZB_ZCL_REPORTABLE Bit-1 : Reportable \n See #zb_zcl_acl_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_discover_attr_extended_rsp() - * @see zb_create_extended_attr_report() - * @see zb_destroy_extended_attr_report() - * @see zb_get_id_from_extended_attr_info() - * @see zb_set_id_to_extended_attr_info() - * @see zb_get_type_from_extended_attr_info() - * @see zb_set_type_to_extended_attr_info() - * @see zb_get_acl_from_extended_attr_info() - * @see zb_set_acl_to_extended_attr_info() - */ -int zb_get_acl_from_extended_attr_info( - extended_attr_info_h handle, - unsigned char *acl); - -/** - * @brief set attribute access control field to extended attribute information - * @details The attribute access control field shall indicate whether the attribute is - * readable, writable, and/or reportable. This is an 8-bit bitmask field. \n - * The bits are in little endian order (bit 0 is listed first). - * - * @since_tizen 3.0 - * - * @param[in] handle handle of write attribute status record - * @param[in] acl ZB_ZCL_WRITABLE : Bit-0., Writable \n - * ZB_ZCL_REPORTABLE Bit-1 : Reportable \n See #zb_zcl_acl_type_e - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zcl_global_discover_attr_extended_rsp() - * @see zb_create_extended_attr_report() - * @see zb_destroy_extended_attr_report() - * @see zb_get_id_from_extended_attr_info() - * @see zb_set_id_to_extended_attr_info() - * @see zb_get_type_from_extended_attr_info() - * @see zb_set_type_to_extended_attr_info() - * @see zb_get_acl_from_extended_attr_info() - * @see zb_set_acl_to_extended_attr_info() - */ -int zb_set_acl_to_extended_attr_info( - extended_attr_info_h handle, - unsigned char acl); - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_H__ */ diff --git a/include/zb-zdo.h b/include/zb-zdo.h deleted file mode 100644 index f4b054a..0000000 --- a/include/zb-zdo.h +++ /dev/null @@ -1,2216 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZDO_H__ - -/** - * @file zb-zdo.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE Zigbee Device Object - * - * @brief zigbee provides API for ZDO access. - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_MODULE_HEADER Header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_MODULE_OVERVIEW Overview - * This API set consists of ZDO access API - * - * @{ - */ - -#include -#include -#include -#include -#include -#include - -/** - * @brief Return readabble ZDO error code - * @details Return ZDO error code string - * - * @since_tizen 3.0 - * - * @param[in] id ZDO id - * - * @return pointer of error message id string - * - */ -const char* zb_zdo_get_error_message(int id); - -/** - * @brief Return readabble Zigbee profile id - * @details Return Zigbee profile id - * - * @since_tizen 3.0 - * - * @param[in] profile_id ZigBee profile id - * - * @return pointer of profile id string - * - */ -const char* zb_get_profile_id_string(int profile_id); - -/** - * @brief Return readabble Zigbee device id - * @details Return Zigbee device id - * - * @since_tizen 3.0 - * - * @param[in] device_id ZigBee device id - * - * @return pointer of device id string - * - */ -const char* zb_get_device_id_string(int device_id); - -/** - * @brief Create simple descriptor - * @details Create simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[out] handle handle of simple descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_simple_desc_copy() - * @see zb_simple_desc_destroy() - */ -int zb_simple_desc_create( - zb_zdo_simple_desc_h *handle); - -/** - * @brief copy simple descriptor - * @details copy simple descriptor handle to another - * - * @since_tizen 3.0 - * - * @param[in] src handle of source simple descriptor - * @param[out] dst handle of destination simple descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_copy() - * @see zb_simple_desc_destroy() - */ -int zb_simple_desc_copy( - zb_zdo_simple_desc_h src, - zb_zdo_simple_desc_h dst); - -/** - * @brief destroy simple descriptor handle - * @details destroy simple descriptor allocated memory - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_copy() - * @see zb_simple_desc_destroy() - */ -int zb_simple_desc_destroy( - zb_zdo_simple_desc_h handle); - -/** - * @brief get active endpoint number from simple descriptor handle - * @details get active endpoint number from simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[out] ep endpoint number - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_set_ep() - */ -int zb_simple_desc_get_ep( - zb_zdo_simple_desc_h handle, - unsigned char *ep); - -/** - * @brief set active endpoint number to simple descriptor handle - * @details set active endpoint number to simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[in] ep endpoint number - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_get_ep() - */ -int zb_simple_desc_set_ep( - zb_zdo_simple_desc_h handle, - unsigned char ep); - -/** - * @brief get profile id from simple descriptor handle - * @details get profile id from simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[out] profile_id profile id - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_set_profile_id() - */ -int zb_simple_desc_get_profile_id( - zb_zdo_simple_desc_h handle, - unsigned short *profile_id); - -/** - * @brief set profile id to simple descriptor handle - * @details set profile id to simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[in] profile_id profile id - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_get_device_id() - */ -int zb_simple_desc_set_profile_id( - zb_zdo_simple_desc_h handle, - unsigned short profile_id); - -/** - * @brief set device id from simple descriptor handle - * @details set device id from simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[out] device_id 16-bit device identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_set_device_id() - */ -int zb_simple_desc_get_device_id( - zb_zdo_simple_desc_h handle, - unsigned short *device_id); - -/** - * @brief set device id to simple descriptor handle - * @details set device id to simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[in] device_id 16-bit device identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_get_device_ver() - */ -int zb_simple_desc_set_device_id( - zb_zdo_simple_desc_h handle, - unsigned short device_id); - -/** - * @brief get device version from simple descriptor handle - * @details get device version from simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[out] device_ver device version - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_set_device_ver() - */ -int zb_simple_desc_get_device_ver( - zb_zdo_simple_desc_h handle, - unsigned short *device_ver); - -/** - * @brief set device version to simple descriptor handle - * @details set device version to simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[in] device_ver device version - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_set_device_ver() - */ -int zb_simple_desc_set_device_ver( - zb_zdo_simple_desc_h handle, - unsigned short device_ver); - -/** - * @brief get number of input clusters from simple descriptor handle - * @details get number of input clusters from simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[out] num_of_in_clusters number of input clusters - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_set_num_of_in_clusters() - */ -int zb_simple_desc_get_num_of_in_clusters( - zb_zdo_simple_desc_h handle, - unsigned char *num_of_in_clusters); - -/** - * @brief get number of input clusters to simple descriptor handle - * @details get number of input clusters to simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[in] num_of_in_clusters number of input clusters - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_get_num_of_in_clusters() - */ -int zb_simple_desc_set_num_of_in_clusters( - zb_zdo_simple_desc_h handle, - unsigned char num_of_in_clusters); - -/** - * @brief get number of output clusters from simple descriptor handle - * @details get number of output clusters from simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[out] num_of_out_clusters number of output clusters - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_set_num_of_out_clusters() - */ -int zb_simple_desc_get_num_of_out_clusters( - zb_zdo_simple_desc_h handle, - unsigned char *num_of_out_clusters); - -/** - * @brief set number of output clusters to simple descriptor handle - * @details set number of output clusters to simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[in] num_of_out_clusters number of output clusters - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_get_num_of_out_clusters() - */ -int zb_simple_desc_set_num_of_out_clusters( - zb_zdo_simple_desc_h handle, - unsigned char num_of_out_clusters); - -/** - * @brief get input cluster list from simple descriptor handle - * @details get input cluster list from simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[out] in_clusters input clusters - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_set_in_clusters() - */ -int zb_simple_desc_get_in_clusters( - zb_zdo_simple_desc_h handle, - unsigned short **in_clusters); - -/** - * @brief set input cluster list to simple descriptor handle - * @details set input cluster list to simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[in] in_clusters input clusters - * @param[in] num number of input clusters - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_get_in_clusters() - */ -int zb_simple_desc_set_in_clusters( - zb_zdo_simple_desc_h handle, - unsigned short *in_clusters, - int num); - -/** - * @brief get output cluster list from simple descriptor handle - * @details get output cluster list from simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[out] out_clusters output clusters - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_get_in_clusters() - */ -int zb_simple_desc_get_out_clusters( - zb_zdo_simple_desc_h handle, - unsigned short **out_clusters); - -/** - * @brief set output cluster list to simple descriptor handle - * @details set output cluster list to simple descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of simple descriptor - * @param[in] out_clusters output clusters - * @param[in] num number of output clusters - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_simple_desc_get_in_clusters() - */ -int zb_simple_desc_set_out_clusters( - zb_zdo_simple_desc_h handle, - unsigned short *out_clusters, - int num); - -/** - * @brief Create node power descriptor - * @details Create node power descriptor handle - * - * @since_tizen 3.0 - * - * @param[out] handle handle of node power descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_node_power_desc_copy() - * @see zb_node_power_desc_destroy() - */ -int zb_node_power_desc_create( - zb_zdo_node_power_descriptor_h *handle); - -/** - * @brief copy node power descriptor - * @details copy node power descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] src handle of source node power descriptor - * @param[out] dst handle of destination node power descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_power_desc_create() - * @see zb_node_power_desc_destroy() - */ -int zb_node_power_desc_copy( - zb_zdo_node_power_descriptor_h src, - zb_zdo_node_power_descriptor_h dst); - -/** - * @brief destroy node power descriptor - * @details destroy node power descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_power_desc_copy() - * @see zb_node_power_desc_destroy() - */ -int zb_node_power_desc_destroy( - zb_zdo_node_power_descriptor_h handle); - -/** - * @brief get current power mode from node power descriptor - * @details The current power mode field of the node power descriptor is four bits in length - * and specifies the current sleep/power-saving mode of the node. \n\n The current power - * mode field shall be set to one of the non-reserved values - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * @param[out] current_power_mode 0b0000 : Receiver synchronized with the receiver on when - * idle sub-field of the node descriptor \n - * 0b0001 : Receiver comes on periodically as defined by the - * node power descriptor \n - * 0b0010 : Receiver comes on when stimulated, e.g. by a - * user pressing a button - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_power_desc_set_current_power_mode() - */ -int zb_node_power_desc_get_current_power_mode( - zb_zdo_node_power_descriptor_h handle, - unsigned char* current_power_mode); - -/** - * @brief set current power mode from node power descriptor - * @details The current power mode field of the node power descriptor is four bits in length - * and specifies the current sleep/power-saving mode of the node. \n\n The current power - * mode field shall be set to one of the non-reserved values - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * @param[in] current_power_mode 0b0000 : Receiver synchronized with the receiver on when - * idle sub-field of the node descriptor \n - * 0b0001 : Receiver comes on periodically as defined by the - * node power descriptor \n - * 0b0010 : Receiver comes on when stimulated, e.g. by a - * user pressing a button - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_power_desc_get_current_power_mode() - */ -int zb_node_power_desc_set_current_power_mode( - zb_zdo_node_power_descriptor_h handle, - unsigned char current_power_mode); - -/** - * @brief get available power mode from node power descriptor - * @details The available power sources field of the node power descriptor is four bits in - * length and specifies the power sources available on this node. \n\n For each power - * source supported on this node, the corresponding bit of the available power sources - * field, shall be set to 1. All other bits shall be set to 0. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * @param[out] available_power_sources 0b0001 : Constant (mains) power \n - * 0b0010 : Rechargeable battery \n - * 0b0100 : Disposable battery \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_power_desc_set_available_power_sources() - */ -int zb_node_power_desc_get_available_power_sources( - zb_zdo_node_power_descriptor_h handle, - unsigned char* available_power_sources); - -/** - * @brief set available power mode from node power descriptor - * @details The available power sources field of the node power descriptor is four bits in - * length and specifies the power sources available on this node. \n\n For each power - * source supported on this node, the corresponding bit of the available power sources - * field, shall be set to 1. All other bits shall be set to 0. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * @param[in] available_power_sources 0b0001 : Constant (mains) power \n - * 0b0010 : Rechargeable battery \n - * 0b0100 : Disposable battery \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_power_desc_get_available_power_sources() - */ -int zb_node_power_desc_set_available_power_sources( - zb_zdo_node_power_descriptor_h handle, - unsigned char available_power_sources); - -/** - * @brief get current power source from node power descriptor - * @details The current power source field of the node power descriptor is four bits in - * length and specifies the current power source being utilized by the node. \n]n - * For the current power source selected, the corresponding bit of the current power \n\n - * source field, shall be set to 1. All other bits shall be set to 0. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * @param[in] current_power_source 0b0001 : Constant (mains) power \n - * 0b0010 : Rechargeable battery \n - * 0b0100 : Disposable battery \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_power_desc_set_current_power_source() - */ -int zb_node_power_desc_get_current_power_source( - zb_zdo_node_power_descriptor_h handle, - unsigned char* current_power_source); - -/** - * @brief set available power mode from node power descriptor - * @details The current power source field of the node power descriptor is four bits in - * length and specifies the current power source being utilized by the node. \n]n - * For the current power source selected, the corresponding bit of the current power \n\n - * source field, shall be set to 1. All other bits shall be set to 0. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * @param[in] current_power_source 0b0001 : Constant (mains) power \n - * 0b0010 : Rechargeable battery \n - * 0b0100 : Disposable battery \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_power_desc_get_current_power_source() - */ -int zb_node_power_desc_set_current_power_source( - zb_zdo_node_power_descriptor_h handle, - unsigned char current_power_source); - -/** - * @brief get current power source level from node power descriptor - * @details The current power source level field of the node power descriptor is four bits - * in length and specifies the level of charge of the power source. \n\n The current power - * source level field shall be set to one of the non-reserved values - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * @param[in] current_power_source_level 0b0000 : Citical \n - * 0b0100 : 33% \n - * 0b1000 : 66% \n - * 0b1100 : 100% \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_power_desc_set_current_power_source_level() - */ -int zb_node_power_desc_get_current_power_source_level( - zb_zdo_node_power_descriptor_h handle, - unsigned char* current_power_source_level); - -/** - * @brief set current power source level from node power descriptor - * @details The current power source level field of the node power descriptor is four bits - * in length and specifies the level of charge of the power source. \n\n The current power - * source level field shall be set to one of the non-reserved values - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node power descriptor - * @param[in] current_power_source_level 0b0000 : Critical \n - * 0b0100 : 33% \n - * 0b1000 : 66% \n - * 0b1100 : 100% \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_power_desc_get_current_power_source_level() - */ -int zb_node_power_desc_set_current_power_source_level( - zb_zdo_node_power_descriptor_h handle, - unsigned char current_power_source_level); - -/** - * @brief Create node descriptor - * @details Create node descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * - * @see zb_node_desc_copy() - * @see zb_node_desc_destroy() - */ -int zb_node_desc_create( - zb_zdo_node_descriptor_h *handle); - -/** - * @brief copy node descriptor - * @details copy node descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] src handle of source node descriptor - * @param[in] dst handle of destination node descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_create() - * @see zb_node_desc_destroy() - */ -int zb_node_desc_copy( - zb_zdo_node_descriptor_h src, - zb_zdo_node_descriptor_h dst); - -/** - * @brief destroy node descriptor - * @details destroy node descriptor handle - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_create() - * @see zb_node_desc_copy() - */ -int zb_node_desc_destroy( - zb_zdo_node_descriptor_h handle); - -/** - * @brief get logical type from node descriptor - * @details The logical type field of the node descriptor is three bits in length and - * specifies the device type of the ZigBee node. \n\n The logical type field shall be set - * to one of the non-reserved values. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] logical_type 0b000 : ZigBee coordinator \n - * 0b001 : Zigbee router \n - * 0b010 : Zigee end device \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_logical_type() - */ -int zb_node_desc_get_logical_type( - zb_zdo_node_descriptor_h handle, - unsigned char* logical_type); - -/** - * @brief set logical type from to descriptor - * @details The logical type field of the node descriptor is three bits in length and - * specifies the device type of the ZigBee node. \n\n The logical type field shall be set - * to one of the non-reserved values. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] logical_type 0b000 : ZigBee coordinator \n - * 0b001 : ZigBee router \n - * 0b010 : ZigBee end device \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_logical_type() - */ -int zb_node_desc_set_logical_type( - zb_zdo_node_descriptor_h handle, - unsigned char logical_type); - -/** - * @brief get complex descriptor available from node descriptor - * @details The complex descriptor available field of the node descriptor is one bit in - * length and specifies whether a complex descriptor is available on this device. \n\n - * If this field is set to 1, a complex descriptor is available. \n\n - * If this field is set to 0, a complex descriptor is not available. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] complex_desciptor_available 1 : a complex descriptor is available \n - * 0 : a complex descriptor is not available \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_complex_descriptor_available() - */ -int zb_node_desc_get_complex_desciptor_available( - zb_zdo_node_descriptor_h handle, - unsigned char* complex_desciptor_available); - -/** - * @brief set complex descriptor available to node descriptor - * @details The complex descriptor available field of the node descriptor is one bit in - * length and specifies whether a complex descriptor is available on this device. \n\n - * If this field is set to 1, a complex descriptor is available. \n\n - * If this field is set to 0, a complex descriptor is not available. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] complex_desciptor_available 1 : a complex descriptor is available \n - * 0 : a complex descriptor is not available \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_complex_desciptor_available() - */ -int zb_node_desc_set_complex_descriptor_available( - zb_zdo_node_descriptor_h handle, - unsigned char complex_desciptor_available); - -/** - * @brief get user descriptor available from node descriptor - * @details The user descriptor available field of the node descriptor is one bit in - * length and specifies whether a user descriptor is available on this device. \n\n - * If this field is set to 1, a user descriptor is available. - * If this field is set to 0, a user descriptor is not available. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] user_descriptor_available 1 : a user descriptor is available \n - * 0 : a user descriptor is not available \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_user_descriptor_available() - */ -int zb_node_desc_get_user_descriptor_available( - zb_zdo_node_descriptor_h handle, - unsigned char* user_descriptor_available); - -/** - * @brief set user descriptor available to node descriptor - * @details The user descriptor available field of the node descriptor is one bit in - * length and specifies whether a user descriptor is available on this device. \n\n - * If this field is set to 1, a user descriptor is available. - * If this field is set to 0, a user descriptor is not available. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] user_descriptor_available 1 : a user descriptor is available \n - * 0 : a user descriptor is not available \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_user_descriptor_available() - */ -int zb_node_desc_set_user_descriptor_available( - zb_zdo_node_descriptor_h handle, - unsigned char user_descriptor_available); - -/** - * @brief get APS flags available from node descriptor - * @details The APS flags field of the node descriptor is three bits in length and - * specifies the application support sub-layer capabilities of the node. \n\n - * This field is currently not supported and shall be set to zero. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] aps_flags 0 : APS flags \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_aps_flags() - */ -int zb_node_desc_get_aps_flags( - zb_zdo_node_descriptor_h handle, - unsigned char* aps_flags); -/** - * @brief set APS flags available to node descriptor - * @details The APS flags field of the node descriptor is three bits in length and - * specifies the application support sub-layer capabilities of the node. \n\n - * This field is currently not supported and shall be set to zero. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] aps_flags 0 : APS flags \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_aps_flags() - */ -int zb_node_desc_set_aps_flags( - zb_zdo_node_descriptor_h handle, - unsigned char aps_flags); - -/** - * @brief get frequency band from node descriptor - * @details The frequency band field of the node descriptor is five bits in length and - * specifies the frequency bands that are supported by the underlying IEEE 802.15.4 radio - * utilized by the node. \n\n For each frequency band supported by the underlying IEEE - * 802.15.4 radio, the corresponding bit of the frequency band field. \n\n - * shall be set to 1. All other bits shall be set to 0. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] frequency_band 0b00001 : 868-868,6MHz \n - * 0b00010 : Reserved \n - * 0b00100 : 902-928MHz \n - * 0b01000 : 2400-2483.5MHz - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_frequency_band() - */ -int zb_node_desc_get_frequency_band( - zb_zdo_node_descriptor_h handle, - unsigned char* frequency_band); - -/** - * @brief set frequency band to node descriptor - * @details The frequency band field of the node descriptor is five bits in length and - * specifies the frequency bands that are supported by the underlying IEEE 802.15.4 radio - * utilized by the node. \n\n For each frequency band supported by the underlying IEEE - * 802.15.4 radio, the corresponding bit of the frequency band field. \n\n - * shall be set to 1. All other bits shall be set to 0. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] frequency_band 0b00001 : 868-868,6MHz \n - * 0b00010 : Reserved \n - * 0b00100 : 902-928MHz \n - * 0b01000 : 2400-2483.5MHz - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_frequency_band() - */ -int zb_node_desc_set_frequency_band( - zb_zdo_node_descriptor_h handle, - unsigned char frequency_band); - -/** - * @brief get MAC capability from node descriptor - * @details The MAC capability flags field is eight bits in length and specifies the node - * capabilities, as required by the IEEE 802.15.4-2003 MAC sub-layer. \n\n The - * MAC capability flags field shall be formatted as illustrated in below table. \n\n - * - * The alternate PAN coordinator sub-field is one bit in length and shall be set to 1 if - * this node is capable of becoming a PAN coordinator. Otherwise, the alternative - * PAN coordinator sub-field shall be set to 0. \n\n - * - * The device type sub-field is one bit in length and shall be set to 1 if this node is a - * full function device (FFD). Otherwise, the device type sub-field shall be set to 0, - * indicating a reduced function device (RFD). \n\n - * - * The power source sub-field is one bit in length and shall be set to 1 if the current - * power source is mains power. Otherwise, the power source sub-field shall be set to - * 0. This information is derived from the node current power source field of the - * node power descriptor.\n\n - * - * The receiver on when idle sub-field is one bit in length and shall be set to 1 if the - * device does not disable its receiver to conserve power during idle periods. - * Otherwise, the receiver on when idle sub-field shall be set to 0 \n\n - * - * The security capability sub-field is one bit in length and shall be set to 1 if the - * device is capable of sending and receiving frames secured using the security suite - * specified in [B1]. Otherwise, the security capability sub-field shall be set to 0. - * The allocate address sub-field is one bit in length and shall be set to 0 or 1. \n\n - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] mac_capability_flags Bit 0 : Alternative PAN coordinator \n - * Bit 1 : Device Type \n - * Bit 2 : Power source \n - * Bit 3 : Receiver on when idle \n - * Bit 4-5 : Reserved \n - * Bit 6 : Security capability \n - * Bit 7 : Allocated address \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_mac_capability_flags() - */ -int zb_node_desc_get_mac_capability_flags( - zb_zdo_node_descriptor_h handle, - unsigned char* mac_capability_flags); - -/** - * @brief set MAC capability to node descriptor - * @details The MAC capability flags field is eight bits in length and specifies the node - * capabilities, as required by the IEEE 802.15.4-2003 MAC sub-layer. \n\n The - * MAC capability flags field shall be formatted as illustrated in below table.\n\n - * - * The alternate PAN coordinator sub-field is one bit in length and shall be set to 1 if - * this node is capable of becoming a PAN coordinator. Otherwise, the alternative - * PAN coordinator sub-field shall be set to 0. \n\n - * - * The device type sub-field is one bit in length and shall be set to 1 if this node is a - * full function device (FFD). Otherwise, the device type sub-field shall be set to 0, - * indicating a reduced function device (RFD). \n\n - * - * The power source sub-field is one bit in length and shall be set to 1 if the current - * power source is mains power. Otherwise, the power source sub-field shall be set to - * 0. This information is derived from the node current power source field of the - * node power descriptor.\n\n - * - * The receiver on when idle sub-field is one bit in length and shall be set to 1 if the - * device does not disable its receiver to conserve power during idle periods. - * Otherwise, the receiver on when idle sub-field shall be set to 0 \n\n - * - * The security capability sub-field is one bit in length and shall be set to 1 if the - * device is capable of sending and receiving frames secured using the security suite - * specified in [B1]. Otherwise, the security capability sub-field shall be set to 0. - * The allocate address sub-field is one bit in length and shall be set to 0 or 1. \n\n - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] mac_capability_flags Bit 0 : Alternative PAN coordinator \n - * Bit 1 : Device Type \n - * Bit 2 : Power source \n - * Bit 3 : Receiver on when idle \n - * Bit 4-5 : Reserved \n - * Bit 6 : Security capability \n - * Bit 7 : Allocated address \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_get_mac_capability_flags() - */ -int zb_node_desc_set_mac_capability_flags( - zb_zdo_node_descriptor_h handle, - unsigned char mac_capability_flags); - -/** - * @brief get manufacturer code from node descriptor - * @details The manufacturer code field of the node descriptor is sixteen bits in length - * and specifies a manufacturer code that is allocated by the ZigBee Alliance, relating - * the manufacturer to the device. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] manufacturer_code manufacturer code - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_manufacturer_code() - */ -int zb_node_desc_get_manufacturer_code( - zb_zdo_node_descriptor_h handle, - unsigned short* manufacturer_code); - -/** - * @brief set manufacturer code to node descriptor - * @details The manufacturer code field of the node descriptor is sixteen bits in length - * and specifies a manufacturer code that is allocated by the ZigBee Alliance, relating - * the manufacturer to the device. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] manufacturer_code manufacturer code - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_get_frequency_band() - */ -int zb_node_desc_set_manufacturer_code( - zb_zdo_node_descriptor_h handle, - unsigned short manufacturer_code); - -/** - * @brief get maximum buffer size from node descriptor - * @details The maximum buffer size field of the node descriptor is eight bits in length, - * with a valid range of 0x00-0x7f. \n\n This field specifies the maximum size, in octets, - * of the network sub-layer data unit (NSDU) for this node. This is the maximum size of - * data or commands passed to or from the application by the application support - * sub-layer, before any fragmentation or re-assembly. \n\n - * This field can be used as a high-level indication for network management. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] maximum_buffer_size 0x00~0x7f - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_maximum_buffer_size() - */ -int zb_node_desc_get_maximum_buffer_size( - zb_zdo_node_descriptor_h handle, - unsigned char* maximum_buffer_size); - -/** - * @brief set maximum buffer size to node descriptor - * @details The maximum buffer size field of the node descriptor is eight bits in length, - * with a valid range of 0x00-0x7f. \n\n This field specifies the maximum size, in octets, - * of the network sub-layer data unit (NSDU) for this node. This is the maximum size of - * data or commands passed to or from the application by the application support - * sub-layer, before any fragmentation or re-assembly. \n\n - * This field can be used as a high-level indication for network management. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] maximum_buffer_size 0x00~0x7f - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_maximum_buffer_size() - */ -int zb_node_desc_set_maximum_buffer_size( - zb_zdo_node_descriptor_h handle, - unsigned char maximum_buffer_size); - -/** - * @brief get maximum incoming transfer size from node descriptor - * @details The maximum transfer size field of the node descriptor is sixteen bits in - * length, with a valid range of 0x0000-0x7fff. \n\n This field specifies the maximum - * size, in octets, of the application sub-layer data unit (ASDU) that can be transferred - * to this node in one single message transfer. \n\n This value can exceed the value of - * the node maximum buffer size field through the use of fragmentation. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] maximum_incoming_transfer_size 0x0000~0x7fff - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_maximum_buffer_size() - */ -int zb_node_desc_get_maximum_incoming_transfer_size( - zb_zdo_node_descriptor_h handle, - unsigned short* maximum_incoming_transfer_size); - -/** - * @brief set maximum incoming transfer size to node descriptor - * @details The maximum transfer size field of the node descriptor is sixteen bits in - * length, with a valid range of 0x0000-0x7fff. \n\n This field specifies the maximum - * size, in octets, of the application sub-layer data unit (ASDU) that can be transferred - * to this node in one single message transfer. \n\n This value can exceed the value of - * the node maximum buffer size field through the use of fragmentation. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] maximum_incoming_transfer_size 0x0000~0x7fff - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_maximum_buffer_size() - */ -int zb_node_desc_set_maximum_incoming_transfer_size( - zb_zdo_node_descriptor_h handle, - unsigned short maximum_incoming_transfer_size); - -/** - * @brief get server mask from node descriptor - * @details The server mask field of the node descriptor is sixteen bits in length, - * with bit settings signifying the system server capabilities of this node. \n\n - * It is used to facilitate discovery of particular system servers by other nodes on the - * system. \n\n The bit settings are defined in below table. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] server_mask Bit 0 : Primary Trust Center \n - * Bit 1 : Backup Trust Center \n - * Bit 2 : Primary Binding Table Cache \n - * Bit 3 : Backup Binding Table Cache \n - * Bit 4 : Primary Discovery Cache \n - * Bit 5 : Backup Discovery Cache \n - * Bit 6 : Network Manager \n - * Bit 7~15 : Reserved - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_server_mask() - */ -int zb_node_desc_get_server_mask( - zb_zdo_node_descriptor_h handle, - unsigned short* server_mask); - -/** - * @brief set server mask to node descriptor - * @details The server mask field of the node descriptor is sixteen bits in length, - * with bit settings signifying the system server capabilities of this node. \n\n - * It is used to facilitate discovery of particular system servers by other nodes on the - * system. \n\n The bit settings are defined in below table. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] server_mask Bit 0 : Primary Trust Center \n - * Bit 1 : Backup Trust Center \n - * Bit 2 : Primary Binding Table Cache \n - * Bit 3 : Backup Binding Table Cache \n - * Bit 4 : Primary Discovery Cache \n - * Bit 5 : Backup Discovery Cache \n - * Bit 6 : Network Manager \n - * Bit 7~15 : Reserved - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_server_mask() - */ -int zb_node_desc_set_server_mask( - zb_zdo_node_descriptor_h handle, - unsigned short server_mask); - -/** - * @brief get maximum outgoing transfer size from node descriptor - * @details The maximum transfer size field of the node descriptor is sixteen bits in, - * length with a valid range of 0x0000-0x7fff. \n\n This field specifies the maximum size, - * in octets, of the application sub-layer data unit (ASDU) that can be transferred from - * this node in one single message transfer. \n\n This value can exceed the value of the - * node maximum buffer size field through the use of fragmentation. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] maximum_outgoing_transfer_size 0x0000~0x7ffff - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_server_mask() - */ -int zb_node_desc_get_maximum_outgoing_transfer_size( - zb_zdo_node_descriptor_h handle, - unsigned short* maximum_outgoing_transfer_size); - -/** - * @brief set maximum outgoing transfer size to node descriptor - * @details The maximum transfer size field of the node descriptor is sixteen bits in, - * length with a valid range of 0x0000-0x7fff. \n\n This field specifies the maximum size, - * in octets, of the application sub-layer data unit (ASDU) that can be transferred from - * this node in one single message transfer. \n\n This value can exceed the value of the - * node maximum buffer size field through the use of fragmentation. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] maximum_outgoing_transfer_size 0x0000~0x7ffff - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_set_server_mask() - */ -int zb_node_desc_set_maximum_outgoing_transfer_size( - zb_zdo_node_descriptor_h handle, - unsigned short maximum_outgoing_transfer_size); - -/** - * @brief get descriptor capability from node descriptor - * @details The descriptor capability field of the node descriptor is eight bits in length - * , with bit settings signifying the descriptor capabilities of this node. \n\n - * It is used to facilitate discovery of particular features of the descriptor fields by - * other nodes on the system. The bit settings are defined in Table. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] descriptor_capability_field Bit 0 : Extended Active Endpoint List Available \n - * Bit 1 : Extended Simple Descriptor List Available \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_node_desc_set_descriptor_capability_field() - */ -int zb_node_desc_get_descriptor_capability_field( - zb_zdo_node_descriptor_h handle, - unsigned short* descriptor_capability_field); - -/** - * @brief set descriptor capability to node descriptor - * @details The descriptor capability field of the node descriptor is eight bits in length - * , with bit settings signifying the descriptor capabilities of this node. \n\n - * It is used to facilitate discovery of particular features of the descriptor fields by - * other nodes on the system. The bit settings are defined in Table. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[in] descriptor_capability_field Bit 0 : Extended Active Endpoint List Available \n - * Bit 1 : Extended Simple Descriptor List Available \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * - * @see zb_node_desc_get_descriptor_capability_field() - */ -int zb_node_desc_set_descriptor_capability_field( - zb_zdo_node_descriptor_h handle, - unsigned short descriptor_capability_field); - -/** - * @brief get extended pan id from network list record - * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee - * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n - * Therefore this function can help parsing parameter in network_list_record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] extended_pan_id The 64-bit extended PAN identifier of the discovered - * network. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_nwk_disc_rsp() - */ -int zb_network_list_record_get_extended_pan_id( - zb_zdo_network_list_record_h handle, - ieee_addr extended_pan_id); - -/** - * @brief get logical channel number from network list record - * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee - * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has multiple network_list_record. - * \n\n Therefore this function can help parsing parameter in network_list_record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] logical_channel The current logical channel occupied by the network. \n - * Selected from the available logical channels supported by - * the PHY. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_nwk_disc_rsp() - */ -int zb_network_list_record_get_logical_channel( - zb_zdo_network_list_record_h handle, - unsigned char* logical_channel); - -/** - * @brief get ZigBee version from network list record - * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee - * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n - * Therefore this function can help parsing parameter in network_list_record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] zigbee_version 0x0~0xf : The version of the ZigBee protocol in use - * in the discovered network. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_nwk_disc_rsp() - */ -int zb_network_list_record_get_zigbee_version( - zb_zdo_network_list_record_h handle, - unsigned char* zigbee_version); - -/** - * @brief get stack profile from network list record - * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee - * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n - * Therefore this function can help parsing parameter in network_list_record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] stack_profile 0x0~0xf : A ZigBee stack profile identifier indicating - * the stack profile in use in the discovered network. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_nwk_disc_rsp() - */ -int zb_network_list_record_get_stack_profile( - zb_zdo_network_list_record_h handle, - unsigned char* stack_profile); - -/** - * @brief get beacon order from network list record - * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee - * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n - * Therefore this function can help parsing parameter in network_list_record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] beacon_order 0x0~0xf : This specifies how often the MAC sub-layer - * beacon is to be transmitted by a given device on the network. \n\n For a discussion of - * MAC sub-layer beacon order - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_nwk_disc_rsp() - */ -int zb_network_list_record_get_beacon_order( - zb_zdo_network_list_record_h handle, - unsigned char* beacon_order); - -/** - * @brief get superframe order from network list record - * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee - * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n - * Therefore this function can help parsing parameter in network_list_record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] superframe_order 0x0~0xf : For beacon-oriented networks, i.e., beacon - * order < 15, this specifies the length of the active period of the superframe. \n\n - * For a discussion of MAC sub-layer superframe order. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_nwk_disc_rsp() - */ -int zb_network_list_record_get_superframe_order( - zb_zdo_network_list_record_h handle, - unsigned char* superframe_order); - -/** - * @brief get permit joining from network list record - * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee - * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n - * Therefore this function can help parsing parameter in network_list_record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] permit_joining 0 or 1 : A value of TRUE indicates that at least one - * ZigBee router on the network currently permits joining, i.e., its NWK has been - * issued an NLME-PERMIT-JOINING primitive and the time limit, if given, has - * not yet expired. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_nwk_disc_rsp() - */ -int zb_network_list_record_get_permit_joining( - zb_zdo_network_list_record_h handle, - unsigned char* permit_joining); - -/** - * @brief get destination address from routing table record - * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp - * command (ClusterID=0x8032) ), it has a routing table record. \n\n - * Therefore this function can help parsing parameter in routing table records. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] dst_addr The destination address for the binding entry - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_rtg_rsp() - * @see zb_routing_table_get_dst_addr() - * @see zb_routing_table_get_dst_status() - * @see zb_routing_table_get_memory_constrained() - * @see zb_routing_table_get_many_to_one() - * @see zb_routing_table_get_route_record_required() - * @see zb_routing_table_get_next_hop_addr() - */ -int zb_routing_table_get_dst_addr(zb_zdo_routing_table_h handle, - nwk_addr* dst_addr); - -/** - * @brief get status bits (3bit) from routing table record - * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp - * command (ClusterID=0x8032) ), it has a routing table record. \n\n - * Therefore this function can help parsing parameter in routing table records. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] status 0x0=ACTIVE. \n - * 0x1=DISCOVERY_UNDERWAY. \n - * 0x2=DISCOVERY_FAILED. \n - * 0x3=INACTIVE. \n - * 0x4=VALIDATION_UNDERWAY \n - * 0x5-0x7=RESERVED. \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_rtg_rsp() - * @see zb_routing_table_get_dst_addr() - * @see zb_routing_table_get_dst_status() - * @see zb_routing_table_get_memory_constrained() - * @see zb_routing_table_get_many_to_one() - * @see zb_routing_table_get_route_record_required() - * @see zb_routing_table_get_next_hop_addr() - */ -int zb_routing_table_get_dst_status(zb_zdo_routing_table_h handle, - unsigned char* status); - -/** - * @brief get memory constrained (1bit) from routing table record - * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp - * command (ClusterID=0x8032) ), it has a routing table record. \n\n - * Therefore this function can help parsing parameter in routing table records. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] memory_constrained A flag indicating whether the device is a memory - * constrained concentrator. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_rtg_rsp() - * @see zb_routing_table_get_dst_addr() - * @see zb_routing_table_get_dst_status() - * @see zb_routing_table_get_memory_constrained() - * @see zb_routing_table_get_many_to_one() - * @see zb_routing_table_get_route_record_required() - * @see zb_routing_table_get_next_hop_addr() - */ -int zb_routing_table_get_memory_constrained( - zb_zdo_routing_table_h handle, unsigned char* memory_constrained); - -/** - * @brief get many-to-one (1bit) from routing table record - * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp - * command (ClusterID=0x8032) ), it has a routing table record. \n\n - * Therefore this function can help parsing parameter in routing table records. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] many_to_one A flag indicating that the destination is a concentrator that - * issued a many-to-one request. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_rtg_rsp() - * @see zb_routing_table_get_dst_addr() - * @see zb_routing_table_get_dst_status() - * @see zb_routing_table_get_memory_constrained() - * @see zb_routing_table_get_many_to_one() - * @see zb_routing_table_get_route_record_required() - * @see zb_routing_table_get_next_hop_addr() - */ -int zb_routing_table_get_many_to_one(zb_zdo_routing_table_h handle, - unsigned char* many_to_one); - -/** - * @brief get routing record required (1bit) from routing table record - * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp - * command (ClusterID=0x8032) ), it has a routing table record. \n\n - * Therefore this function can help parsing parameter in routing table records. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] route_record_required A flag indicating that a route record command frame - * should be sent to the destination prior to the next - * data packet. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_rtg_rsp() - * @see zb_routing_table_get_dst_addr() - * @see zb_routing_table_get_dst_status() - * @see zb_routing_table_get_memory_constrained() - * @see zb_routing_table_get_many_to_one() - * @see zb_routing_table_get_route_record_required() - * @see zb_routing_table_get_next_hop_addr() - */ -int zb_routing_table_get_route_record_required( - zb_zdo_routing_table_h handle, unsigned char* route_record_required); - -/** - * @brief get next hop address from routing table record - * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp - * command (ClusterID=0x8032) ), it has a routing table record. \n\n - * Therefore this function can help parsing parameter in routing table records. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] next_hop_addr Next-hop address. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_rtg_rsp() - * @see zb_routing_table_get_dst_addr() - * @see zb_routing_table_get_dst_status() - * @see zb_routing_table_get_memory_constrained() - * @see zb_routing_table_get_many_to_one() - * @see zb_routing_table_get_route_record_required() - * @see zb_routing_table_get_next_hop_addr() - */ -int zb_routing_table_get_next_hop_addr( - zb_zdo_routing_table_h handle, nwk_addr* next_hop_addr); - -/** - * @brief get extended pan id from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] extended_pan_id The 64-bit extended PAN id of the neighboring device - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_extended_pan_id( - zb_zdo_neighbor_table_desc_h handle, - ieee_addr extended_pan_id); - -/** - * @brief get IEEE address from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] addr64 64-bit IEEE address that is unique to every device. \n - * If this value is unknown at the time of the request, this field shall be set to - * 0xffffffffffffffff. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_ieee_addr( - zb_zdo_neighbor_table_desc_h handle, - ieee_addr addr64); - -/** - * @brief get network address from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] addr16 16-bit network address that is unique to every device. \n - * If this value is unknown at the time of the request, this field shall be set to - * 0xffffffffffffffff. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_nwk_addr( - zb_zdo_neighbor_table_desc_h handle, - nwk_addr* addr16); - -/** - * @brief get device type from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] device_type The type of the neighbor device: \n - * 0x0 = ZigBee coordinator \n - * 0x1 = ZigBee router \n - * 0x2 = ZigBee end device \n - * 0x3 = Unknown \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_device_type( - zb_zdo_neighbor_table_desc_h handle, - unsigned char* device_type); - -/** - * @brief get RxOnWhenIdle value from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] rx_on_when_idle Indicates if neighbor's receiver is - * enabled during idle portions of the \n - * CAP: \n - * 0x0 = Receiver is off \n - * 0x1 = Receiver is on \n - * 0x2 = unknown - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_rx_on_when_idle( - zb_zdo_neighbor_table_desc_h handle, - unsigned char* rx_on_when_idle); - -/** - * @brief get Relationship value from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] releationship The relationship between the - * neighbor and the current device: \n - * 0x0 = neighbor is the parent \n - * 0x1 = neighbor is a child \n - * 0x2 = neighbor is a sibling \n - * 0x3 = None of the above \n - * 0x4 = previous child - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_relationship( - zb_zdo_neighbor_table_desc_h handle, - unsigned char* releationship); - -/** - * @brief get Permit joining value from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] permit_joining An indication of whether the - * neighbor device is accepting join requests: \n - * 0x0 = neighbor is not accepting join requests \n - * 0x1 = neighbor is accepting join requests \n - * 0x2 = unknown - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_permit_joining( - zb_zdo_neighbor_table_desc_h handle, - unsigned char* permit_joining); - -/** - * @brief get Depth value from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] depth The 0x00~nwkcMaxDepth (See. Zigbee Spec.) \n - * tree depth of the neighbor device. \n - * A value of 0x00 indicates that the device is the ZigBee - * coordinator for the network. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_depth( - zb_zdo_neighbor_table_desc_h handle, - unsigned char* depth); - -/** - * @brief get LQI(Link-Quality Indicator) value from neighbor table list record - * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee - * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n - * Therefore this function can help parsing parameter in neigbor_table_list. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] lqi The estimated link quality for RF transmissions from this device. \n - * See ZigBee specification for discussion of how this is calculated. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_lqi_rsp() - * @see zb_neighbor_table_desc_get_extended_pan_id() - * @see zb_neighbor_table_desc_get_ieee_addr() - * @see zb_neighbor_table_desc_get_nwk_addr() - * @see zb_neighbor_table_desc_get_device_type() - * @see zb_neighbor_table_desc_get_rx_on_when_idle() - * @see zb_neighbor_table_desc_get_relationship() - * @see zb_neighbor_table_desc_get_permit_joining - * @see zb_neighbor_table_desc_get_depth() - * @see zb_neighbor_table_desc_get_lqi() - */ -int zb_neighbor_table_desc_get_lqi( - zb_zdo_neighbor_table_desc_h handle, - unsigned char* lqi); - -/** - * @brief get source MAC address from binding table record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in binding_table structure. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] src_addr The source IEEE address for the binding entry. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_bind_rsp() - */ -int zb_binding_table_get_src_addr( - zb_zdo_binding_table_h handle, - ieee_addr src_addr); - -/** - * @brief get SrcEndpoint from binding table record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in binding_table structure. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] src_ep The source endpoint for the binding entry. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_bind_rsp() - */ -int zb_binding_table_get_src_ep( - zb_zdo_binding_table_h handle, - unsigned char *src_ep); - -/** - * @brief get ClusterId from binding table record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in binding_table structure. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] cluster_id The identifier of the cluster on the source device that is bound - * to the destination device. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_bind_rsp() - */ -int zb_binding_table_get_cluster_id( - zb_zdo_binding_table_h handle, - unsigned short *cluster_id); - -/** - * @brief get DstAddrMode from binding table record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in binding_table structure. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] dst_addr_mode The addressing mode for the destination address. \n\n - * This field can take one of the non-reserved values - * from the following list: \n\n - * 0x00 = reserved \n - * 0x01 = 16-bit group address for DstAddr and DstEndpoint not - * present \n - * 0x02 = reserved \n - * 0x03 = 64-bit extended address for DstAddr and DstEndp present \n - * 0x04 ? 0xff = reserved \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_bind_rsp() - */ -int zb_binding_table_get_dst_addr_mode( - zb_zdo_binding_table_h handle, - unsigned char *dst_addr_mode); - -/** - * @brief get DstAddr from binding table record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in binding_table structure. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] addr16 The destination address for the binding entry. \n - * As specified by the DstAddrMode field. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NO_DATA No network address - * - * @see zb_zdo_mgmt_bind_rsp() - */ -int zb_binding_table_get_dst_addr16( - zb_zdo_binding_table_h handle, - nwk_addr *addr16); - -/** - * @brief get DstAddr from binding table record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in binding_table structure. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] addr64 The destination address for the binding entry. \n - * As specified by the DstAddrMode field. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_NO_DATA No IEEE address - * - * @see zb_zdo_mgmt_bind_rsp() - */ -int zb_binding_table_get_dst_addr64( - zb_zdo_binding_table_h handle, - ieee_addr addr64); - -/** - * @brief get DstEndPoint from binding table record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in binding_table structure. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] dst_ep 0x01~0xff : This field shall be present only if the DstAddrMode - * field has a value of 0x03 and, if present, shall be the destination - * endpoint for the binding entry. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_bind_rsp() - */ -int zb_binding_table_get_dst_ep( - zb_zdo_binding_table_h handle, - unsigned char *dst_ep); - -/** - * @brief get ExtendedAddress from discovery cache record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Cache_rsp (ClusterID = 0x8037) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in discovery cache list record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] addr64 64-bit IEEE Address of the cached device. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_cache_rsp() - */ -int zb_discovery_cache_get_ieee_addr( - zb_zdo_discovery_cache_h handle, - ieee_addr addr64); - -/** - * @brief get NetworkAddress from discovery cache record - * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee - * called Mgmt_Cache_rsp (ClusterID = 0x8037) ), it has multiple binding table. \n\n - * Therefore this function can help parsing parameter in discovery cache list record. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of node descriptor - * @param[out] addr16 16-bit network Address of the cached device. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * - * @see zb_zdo_mgmt_cache_rsp() - */ -int zb_discovery_cache_get_nwk_addr( - zb_zdo_discovery_cache_h handle, - nwk_addr *addr16); - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_H__ */ diff --git a/include/zb_custom.h b/include/zb_custom.h new file mode 100644 index 0000000..df0ff47 --- /dev/null +++ b/include/zb_custom.h @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_CUSTOM_H__ +#define __TIZEN_NETWORK_ZIGBEE_CUSTOM_H__ + +/** + * @file zb_custom.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE ZigBee Custom Commands + * + * @brief Zigbee provides API for custom command. + * + * @section CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_CUSTOM_MODULE_OVERVIEW Overview + * This API set consists of ZigBee custom command API + * + * @{ + */ + +/** + * @brief Called after custom APS send command + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] src_ep source end-point (ex. 1) + * @param[out] dst_ep destination end-point (ex. 1) + * @param[out] cluster_id ZCL cluster id + * @param[out] profile_id Profile id + * @param[out] payload_len Length of payload + * @param[out] payload Payload data + * @param[out] user_data User data + * + * @see zb_aps_send() + */ +typedef void (*zb_aps_send_rsp)( + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned short cluster_id, + unsigned short profile_id, + unsigned short payload_len, + unsigned char *payload, + void *user_data); + +/** + * @brief Called after custom ZCL send command + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] src_ep source end-point (ex. 1) + * @param[out] dst_ep destination end-point (ex. 1) + * @param[out] cluster_id ZCL cluster id + * @param[out] profile_id Profile id + * @param[out] payload_len Length of payload + * @param[out] payload Payload data + * @param[out] user_data User data + * + * @see zb_zcl_send() + */ +typedef void (*zb_zcl_send_rsp)( + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned short cluster_id, + unsigned short profile_id, + unsigned short payload_len, + unsigned char *payload, + void *user_data); + +/** + * @brief Called after custom local send command + * + * @since_tizen 4.0 + * + * @param[out] length The length of data + * @param[out] data Received data + * @param[out] user_data User data + * + * @see zb_send_to_local() + */ +typedef void (*zb_send_to_local_rsp)( + unsigned short length, + unsigned char *data, + void *user_data); + +/** + * @brief Sends custom APS data + * + * @since_tizen 4.0 + * + * @param[in] handle Handle of node descriptor + * @param[in] addr16 Network address + * @param[in] aps_frame_ctl APS Frame control bits. \n + * - Delivery Mode : \n + * #ZB_APS_DELIVERY_UNICAST \n + * #ZB_APS_DELIVERY_INDIRECT \n + * #ZB_APS_DELIVERY_BROADCAST \n + * #ZB_APS_DELIVERY_MULTICAST \n + * - ACK Request : \n + * #ZB_APS_NO_ACK_REQUEST \n + * #ZB_APS_ACK_REQUEST + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] cluster_id ZCL cluster id + * @param[in] profile_id Profile id + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE + * @param[in] mfg_code Manufacturer Code + * @param[in] cmd_id Command ID + * @param[in] payload_len Length of payload + * @param[in] payload Payload data + * @param[in] cb Callback function to get response. + * @param[in] user_data User data to be received from callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_aps_send_rsp() + */ +int zb_aps_send( + zigbee_h handle, + nwk_addr addr16, + unsigned char aps_frame_ctl, + unsigned char src_ep, + unsigned char dst_ep, + unsigned short cluster_id, + unsigned short profile_id, + unsigned char zcl_frame_ctl, + unsigned short mfg_code, + unsigned char cmd_id, + unsigned short payload_len, + unsigned char *payload, + zb_aps_send_rsp cb, + void *user_data); + +/** + * @brief Sends custom ZCL data + * + * @since_tizen 4.0 + * + * @param[in] handle Handle of node descriptor + * @param[in] addr16 Network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] cluster_id ZCL cluster id + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE + * @param[in] cmd APL Command + * @param[in] payload_len Length of payload + * @param[in] payload Payload data + * @param[in] cb Callback function to get response. + * @param[in] user_data User data to be received from callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_send_rsp() + */ +int zb_zcl_send( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned short cluster_id, + unsigned char zcl_frame_ctl, + unsigned char cmd, + unsigned short payload_len, + unsigned char *payload, + zb_zcl_send_rsp cb, + void *user_data); + +/** + * @brief Transmits data that needs to be processed locally. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] length The length of data + * @param[in] data Data to send + * @param[in] cb Callback function to get response. + * @param[in] user_data User data to be received from callback function. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_send_to_local_rsp() + */ +int zb_send_to_local( + zigbee_h handle, + unsigned short length, + unsigned char *data, + zb_send_to_local_rsp cb, + void *user_data); + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_CUSTOM_H__ */ diff --git a/include/zb_error.h b/include/zb_error.h new file mode 100644 index 0000000..05c756a --- /dev/null +++ b/include/zb_error.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __CAPI_NETWORK_ZIGBEE_ERROR_H__ +#define __CAPI_NETWORK_ZIGBEE_ERROR_H__ + +#include + +#ifndef TIZEN_ERROR_ZIGBEE +#define TIZEN_ERROR_ZIGBEE 0x02000000 +#endif + +/** + * @file zb_error.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_MODULE + * @brief Enumeration for zigbee CAPI error code. + * @since_tizen 4.0 + * + * @{ + */ +typedef enum { + ZIGBEE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + ZIGBEE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< parameter error */ + ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE = TIZEN_ERROR_RESULT_OUT_OF_RANGE, /**< out of range error */ + ZIGBEE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< out of memory */ + ZIGBEE_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< DBus error */ + ZIGBEE_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */ + ZIGBEE_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< not supported */ + ZIGBEE_ERROR_INVALID_ENDPOINT = TIZEN_ERROR_ZIGBEE | 0x01, /**< endpoint 0 is reserved for ZDP */ + ZIGBEE_ERROR_INVALID_ADDRESS = TIZEN_ERROR_ZIGBEE | 0x02, /**< wrong address */ +} zb_error_e; + +/** + * @} + */ + +#endif /* __CAPI_NETWORK_ZIGBEE_ERROR_H__ */ diff --git a/include/zb_ha.h b/include/zb_ha.h new file mode 100644 index 0000000..9a4924e --- /dev/null +++ b/include/zb_ha.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_HA_H__ +#define __TIZEN_NETWORK_ZIGBEE_HA_H__ + +/** + * @brief Zigbee profile id + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_PROFILE_HOME_AUTOMATION = 0x0104, /**< Zigbee Home Automation profile */ +} zb_profile_id_e; + +/** + * @brief Devices specified the HA profile + * + * @since_tizen 4.0 + */ +typedef enum { + /* General devices */ + ZB_HA_ON_OFF_SWITCH = 0x0000, /**< On/off switch device */ + ZB_HA_LEVEL_CONTROL_SWITCH = 0x0001, /**< Level control device */ + ZB_HA_ON_OFF_OUTPUT = 0x0002, /**< On/off output device */ + ZB_HA_LEVEL_CONTROLLABLE_OUTPUT = 0x0003, /**< Controllable output device */ + ZB_HA_SCENE_SELECOTOR = 0x0004, /**< Scene selector device */ + ZB_HA_CONFIGURATION_TOOL = 0x0005, /**< Configuration tool device */ + ZB_HA_REMOTE_CONTROL = 0x0006, /**< Remote control device */ + ZB_HA_COMBINED_INTERFACE = 0x0007, /**< Combined interface device */ + ZB_HA_RANGE_EXTENDER = 0x0008, /**< Range exntender device */ + ZB_HA_MAINS_POWER_OUTLET = 0x0009, /**< Main power outlet device */ + ZB_HA_DOOR_LOCK = 0x000A, /**< Door lock device */ + ZB_HA_DOOR_LOCK_CONTROLLER = 0x000B, /**< Door lock controller device */ + ZB_HA_SIMPLE_SENSOR = 0x000C, /**< Simple sensor device */ + ZB_HA_CONSUMPTION_AWARENESS_DEVICE = 0x000D, /**< Comsumption awareness device */ + ZB_HA_HOME_GATEWAY = 0x0050, /**< Home gateway device */ + ZB_HA_SMART_PLUG = 0x0051, /**< Smart plug device */ + ZB_HA_WHITE_GOODS = 0x0052, /**< White goods device */ + ZB_HA_METER_INTERFACE = 0x0053, /**< Meter interface device */ + /* Lighting devices */ + ZB_HA_ON_OFF_LIGHT = 0x0100, /**< On/off light device */ + ZB_HA_DIMMABLE_LIGHT = 0x0101, /**< Dimmable light device */ + ZB_HA_COLOR_DIMMABLE_LIGHT = 0x0102, /**< Color dimmable light device */ + ZB_HA_ON_OFF_LIGHT_SWITCH = 0x0103, /**< On/off light device */ + ZB_HA_DIMMER_SWITCH = 0x0104, /**< Dimmer switch device */ + ZB_HA_COLOR_DIMMER_SWITCH = 0x0105, /**< Color dimmer switch device */ + ZB_HA_LIGHT_SENSOR = 0x0106, /**< Light sensor device */ + ZB_HA_OCUPANCY_SENSOR = 0x0107, /**< Ocupancy sensor device */ + /* Closures devices */ + ZB_HA_SHADE = 0x0200, /**< shade device */ + ZB_HA_SHADE_CONTROLLER = 0x0201, /**< Shade controller device */ + ZB_HA_WINDOW_COVERING_DEVICE = 0x0202, /**< Window covering device */ + ZB_HA_WINDOW_COVERING_CONTROLLER = 0x0203, /**< Window covering controller device */ + /* HVAC devices */ + ZB_HA_HEATING_COOLLING_UNIT = 0x0300, /**< Heating coolling device */ + ZB_HA_THERMOSTAT = 0x0301, /**< Thermostat device */ + ZB_HA_TEMPERATURE_SENSOR = 0x0302, /**< Temperature sensor device */ + ZB_HA_PUMP = 0x0303, /**< Pump device */ + ZB_HA_PUMP_CONTROLLER = 0x0304, /**< Pump controller device */ + ZB_HA_PRESSURE_SENSOR = 0x0305, /**< Pressure sensor device */ + ZB_HA_FLOW_SENSOR = 0x0306, /**< Flow sensor device */ + ZB_HA_MINI_SPLIT_AC = 0x0307, /**< Mini split device */ + /* Intruder Alarms system */ + ZB_HA_ISA_CONTROL_AND_INDICATING_EQUIPMENT = 0x0400, /**< ISA control and indicatiing equipment device */ + ZB_HA_ISA_ANCILLARY_CONTROL_EQUIPMENT = 0x0401, /**< ISA ancillary controll device */ + ZB_HA_ISA_ZONE = 0x0402, /**< ISA zone device */ + ZB_HA_ISA_WARNIGN_DEVICE = 0x0403, /**< ISA warning device */ +} ha_device_id_e; + + +#endif /* __TIZEN_NETWORK_ZIGBEE_HA_H__ */ diff --git a/include/zb_type.h b/include/zb_type.h new file mode 100644 index 0000000..c474843 --- /dev/null +++ b/include/zb_type.h @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ + +#ifndef __CAPI_NETWORK_ZIGBEE_CONSTANT_H__ +#define __CAPI_NETWORK_ZIGBEE_CONSTANT_H__ + +#include + +/** + * @file zb_type.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_COMMON_MODULE Common + * + * @brief zigbee common types provides the set of definitions to use zigbee service + * + * @section CAPI_NETWORK_ZIGBEE_COMMON_MODULE_HEADER header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_COMMON_MODULE_HEADER_OVERVIEW overview + * This API set consists of data structures and types + * + * @{ + */ + +/** + * @brief The data type abbreviation : IEEE Address + * + * @since_tizen 4.0 + */ +typedef unsigned char ieee_addr[8]; +/** + * @brief The data type abbreviation : Network Address + * + * @since_tizen 4.0 + */ +typedef unsigned short nwk_addr; + +/** + * @brief The data type abbreviation : 128 bit security key + * + * @since_tizen 4.0 + */ +typedef unsigned char aes128_key[16]; + +/** +* @brief The handle of zigbee +* @details a zigbee_h is an opaque data structure.\n +* zigbee_h is a data type of zigbee's response which consists of result, handler and etc. +* +* @since_tizen 4.0 +*/ +typedef struct zbl_zigbee_s* zigbee_h; + +/** + * @brief The events for zb_event_cb + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_ENABLE_EVENT = 0x00, /**< This event is received after enabling zigbee system service */ + ZB_ZDP_FORM_NETWORK_DONE = 0x01, /**< This event comes from coming network operation completed */ + ZB_ZDP_JOIN_EVENT = 0x02, /**< This event takes place when new device joined */ + ZB_ZDP_REJOIN_EVENT = 0x03, /**< This event takes place when existing device or devices which is(are) received 'leave_network' command is re-joined */ + ZB_ZDP_CHILD_LEFT = 0x04, /**< This event takes place when a child device leave current network explicitly */ + ZB_ZDP_LEAVE_DONE_EVENT = 0x05, /**< This event will take place after dismiss current network */ + ZB_ZDP_UPDATED_NETWORK_NOTIFICATION_EVENT = 0x06, /**< A device updated its network information */ + ZB_ZDP_BIND_RSP_EVENT = 0x07, /**< Binding end-points result */ + ZB_ZDP_UNBIND_RSP_EVENT = 0x08, /**< Unbinding end-points result */ + ZB_ZCL_GLOBAL_DEFAULT_RSP_EVENT = 0x10, /**< This event is used when global default response */ + ZB_ZCL_GLOBAL_ATTRIBUTE_REPORT_EVENT = 0x11, /**< This event is took place when report attribute command received */ + ZB_ZCL_ALARM_EVENT = 0x20, /**< Events related to alarm cluster */ + ZB_ZCL_IAS_ZONE_ENROLL_REQUEST_EVENT = 0x21, /**< A Device which supports IAS zone cluster want to register its ability */ + ZB_ZCL_IAS_ZONE_STATUS_CHANGE_NOTIFICATION_EVENT = 0x22, /**< A Device which supports IAS zone cluster notifies its status change */ + ZB_ZCL_IAS_ZONE_STATUS_CHANGE_EXTENDED_NOTIFICATION_EVENT = 0x23, /**< A Device which supports IAS zone cluster notifies its status change */ + ZB_ZCL_LEVEL_CONTROL_CURRENT_LEVEL_ATTRIBUTE_REPORT_EVENT = 0x30, /**< (Confusint) This event will be received after level control cluster attribute changed */ + ZB_ZCL_COLOR_CONTROL_CURRENT_X_ATTRIBUTE_REPORT_EVENT = 0x31, /**< This event will be received after color control cluster X attribute changed */ + ZB_ZCL_COLOR_CONTROL_CURRENT_Y_ATTRIBUTE_REPORT_EVENT = 0x32, /**< This event will be received after color control cluster Y attribute changed */ + ZB_ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_REPORT_EVENT = 0x33, /**< This event will be received after color control cluster hue attribute changed */ + ZB_ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_REPORT_EVENT = 0x34, /**< This event will be received after color control cluster saturation attribute changed */ + ZB_ZCL_COLOR_CONTROL_CURRENT_TEMPERATURE_ATTRIBUTE_REPORT_EVENT = 0x35, /**< This event will be received after color control cluster temperature attribute changed */ + ZB_ZCL_DOOR_LOCK_OPERATIONAL_NOTIFICATION_EVENT = 0x40, /**< This event is received when door-lock operation has been finished */ + ZB_ZCL_DOOR_LOCK_PROGRAMING_NOTIFICATION_EVENT = 0x41, /**< This event is received when door-lock programming has been changed */ + ZB_ZCL_SIMPLE_METERING_REMOVE_MIRROR_EVENT = 0x51, /**< This event is used to request the ESP to remove its mirror of Metering */ + ZB_ZCL_SIMPLE_METERING_REQUEST_MIRROR_EVENT = 0x52, /**< This event is used to request the ESP to mirror Metering Device data */ +} zb_event_e; + +/** + * @brief The structure type for the ZB_ZDP_ENABLE_EVENT callback data. + * @details The result of enabling zigbee system service. + * + * @since_tizen 4.0 + */ +typedef struct { + unsigned char status; /**< Status of enabling zigbee system service */ +} zb_event_enable_s; + +/** + * @brief The structure type for the ZB_ZDP_FORM_NETWORK_DONE callback data. + * @details This event comes from coming network operation completed. + * + * @since_tizen 4.0 + */ +typedef struct { + nwk_addr pan_id; /**< Pan ID */ +} zb_event_form_network_s; + +/** + * @brief The structure type for the ZB_ZDP_JOIN_EVENT callback data. + * @details This event takes place when new device joined. + * + * @since_tizen 4.0 + */ +typedef struct { + unsigned char count; /**< Number of endpoint list */ + unsigned char ep[10]; /**< Endpoint list */ +} zb_event_join_s; + +/** + * @brief The structure type for the ZB_ZDP_CHILD_LEFT callback data. + * @details This event takes place when a child device leave current network explicitly. + * + * @since_tizen 4.0 + */ +typedef struct { + unsigned char status; /**< Left status of child device */ +} zb_event_child_left_s; + +/** + * @brief The structure type for the ZB_ZCL_GLOBAL_DEFAULT_RSP_EVENT callback data. + * @details This event is used when global default response. + * + * @since_tizen 4.0 + */ +typedef struct { + unsigned char ep; /**< End-point */ + unsigned short cluster_id; /**< Cluster id */ + unsigned char command_id; /**< Command id */ + unsigned char status; /**< Status */ +} zb_event_global_default_rsp_s; + +/** + * @brief The structure type for the ZB_ZCL_GLOBAL_ATTRIBUTE_REPORT_EVENT callback data. + * @details This event is took place when report attribute command received. + * + * @since_tizen 4.0 + */ +typedef struct { + void* records; /**< Array of attribute report record */ + unsigned char count; /**< count of records */ +} zb_event_global_attr_report_s; + +/** + * @brief The structure type for the ZB_ZCL_ALARM_EVENT callback data. + * @details This event is related to alarm cluster. + * + * @since_tizen 4.0 + */ +typedef struct { + unsigned short count; /**< Alarm count */ +} zb_event_alarm_s; + +/** + * @brief The structure type for the ZB_ZCL_IAS_ZONE_ENROLL_REQUEST_EVENT callback data. + * @details A Device which supports IAS zone cluster want to register its ability. + * + * @since_tizen 4.0 + */ +typedef struct { + unsigned char src_ep; /**< Source endpoint */ + unsigned short zone_type; /**< Zone type 0x0000 : Standard CIE / Alarm1 - System Alarm, Alarm2 - N/A\n + * 0x000d : Motion Sensor / Alarm1 - Intrusion indication, Alarm2 - Presence indication\n + * 0x0015 : Contact switch / Alarm1 - 1st portal Open-Close, Alarm2 - 2nd portal Open-Close\n + * 0x0028 : Fire sensor / Alarm1 - Fire indication, Alarm2 - N/A\n + * 0x002a : Water sensor / Alarm1 - Water overflow indication, Alarm2 - N/A\n + * 0x002b : Gas Sensor / Alarm1 - CO indication, Alarm2 - Cooking indication\n + * 0x002c : Personal emergency Sensor / Alarm1 - Fall / Concussion, Alarm2 - Emergency button\n + * 0x002d : Vibration or Movement Sensor / Alarm1 - Movement indication, Alarm2 - Vibration\n + * 0x010f : Remote control / Alarm1 - Panic, Alarm2 - Emergency\n + * 0x0115 : Key fob / Alarm1 - Panic, Alarm2 - Emergency\n + * 0x021d : Keypad / Alarm1 - Panic, Alarm2 - Emergency\n + * 0x0225 : Standard Warning Device (see. EN 50131 European Standards Series for Intruder Alarm Systems) + * / Alarm1 - N/A, Alarm2 -N/A\n + * 0x8000~0xfffe : Reserved for manufacturer specific types / Alarm1 - N/A, Alarm2 - N/A\n + * 0xffff : Invalid Zone Type / Alarm1 - N/A, Alarm2 - N/A\n */ + unsigned char mfg_code; /**< Manufacturer Code */ +} zb_event_ias_enroll_request_s; + +/** + * @brief The structure type for the ZB_ZCL_IAS_ZONE_STATUS_CHANGE_NOTIFICATION_EVENT callback data. + * @details A Device which supports IAS zone cluster notifies its status change. + * + * @since_tizen 4.0 + */ +typedef struct { + unsigned char src_ep; /**< Source endpoint */ + unsigned short zone_status; /**< zone_status Bit 0 : Alarm1 : 1 - opened or alarmed / 0 - closed or not alarmed\n + * Bit 1 : Alarm2 : 1 - opened or alarmed / 0 - closed or not alarmed\n + * Bit 2 : Temper : 1 - Tempered / 0 - Not tempered\n + * Bit 3 : Battery : 1 - Low batter / 0 - Battery OK\n + * Bit 4 : Supervision report : 1 - Report / 0 - Does not report\n + * Note 1: This bit indicates whether the Zone issues periodic Zone Status Change\n + * Notification commands. The CIE device may use these periodic reports as an\n + * indication that a zone is operational. Zones that do not implement the periodic\n + * reporting are required to set this bit to zero (the CIE will know not to interpret the\n + * lack of reports as a problem).\n + * Bit 5 : Restore reports : 1 - Reports restore / 0 - Does not report restore\n + * Note 2: This bit indicates whether or not a Zone Status Change Notification\n + * command will be sent to indicate that an alarm is no longer present. Some Zones\n + * do not have the ability to detect that alarm condition is no longer present, they\n + * only can tell that an alarm has occurred. These Zones must set the "Restore" bit to\n + * zero, indicating to the CIE not to look for alarm-restore notifications.\n + * Bit 6 : Trouble : 1 - Trouble/Failure / 0 - OK\n + * Bit 7 : AC(mains) : 1 - ACMains fault / 0 - AC/Mains OK\n */ +} zb_event_ias_noti_s; + +/** + * @brief The structure type for the ZB_ZCL_IAS_ZONE_STATUS_CHANGE_EXTENDED_NOTIFICATION_EVENT callback data. + * @details A Device which supports IAS zone cluster notifies its status change. + * + * @since_tizen 4.0 + */ +typedef struct { + unsigned char src_ep; /**< Source endpoint */ + unsigned char extended_status; /**< Extended status */ + unsigned short zone_status; /**< Zone status */ + unsigned short delay; /**< Delay */ + unsigned char zone_id; /**< Zone ID */ +} zb_event_ias_extended_noti_s; + +/** + * @brief The structure type for response data of zb_event_cb. + * @details This function can receive events from the devices in the network. + * ex) join, re-join, leave and attribute change report + * + * @since_tizen 4.0 + */ +typedef struct { + union { + zb_event_enable_s *enable; /**< The result of enabling zigbee system service. */ + zb_event_form_network_s *form_network; /**< This event comes from coming network operation completed. */ + zb_event_join_s *join; /**< This event takes place when new device joined. */ + zb_event_child_left_s *child_left; /**< This event takes place when a child device leave current network explicitly. */ + zb_event_global_default_rsp_s *global_default_rsp; /**< This event is used when global default response. */ + zb_event_global_attr_report_s *global_attr_report; /**< This event is took place when report attribute command received. */ + zb_event_alarm_s *alarm; /**< This event is related to alarm cluster. */ + zb_event_ias_enroll_request_s *ias_enroll_request; /**< A Device which supports IAS zone cluster want to register its ability. */ + zb_event_ias_noti_s *ias_noti; /**< A Device which supports IAS zone cluster notifies its status change. */ + zb_event_ias_extended_noti_s *ias_extended_noti; /**< A Device which supports IAS zone cluster notifies its status change. */ + } data; +} zb_event_data_s; + +/** + * @brief APS Delivery Mode + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_APS_DELIVERY_UNICAST = 0, /**< Unicast delivery */ + ZB_APS_DELIVERY_INDIRECT = 1, /**< Indirect delivery */ + ZB_APS_DELIVERY_BROADCAST = 2, /**< Broadcast delivery */ + ZB_APS_DELIVERY_MULTICAST = 3 /**< Multicast delivery */ +} zb_aps_delivery_mode; + +/** + * @brief APS ACK Request + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_APS_NO_ACK_REQUEST = (0 << 6), /**< Not request ACK */ + ZB_APS_ACK_REQUEST = (1 << 6), /**< Request ACK */ +} zb_aps_ack_request; + +/** + * @brief Frame type at ZCL Header + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_FC_GLOBALLY_USED = (0 << 0), /**< profile widely used */ + ZB_APS_FC_CLUSTER_SPECIFIC = (1 << 0), /**< cluster specific */ +} zb_zcl_fc_type_e; + +/** + * @brief Manufacturer specific or not at ZCL Header + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_FC_NOT_MANUFACTURER = (0 << 2), /**< manufacturer code not present */ + ZB_ZCL_FC_MANUFACTURER = (1 << 2), /**< manufacturer code present */ +} zb_zcl_fc_manufacturer_present_e; + +/** + * @brief Request or Response at ZCL Header + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_CLIENT_TO_SERVER = (0 << 3), /**< request */ + ZB_ZCL_SERVER_TO_CLIENT = (1 << 3), /**< response */ +} zb_zcl_fc_direction_e; + +/** + * @brief Disable default response or not at ZCL Header + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_LEAVE_WELL_ALONE = (0 << 4), /**< enable default response */ + ZB_ZCL_DISABLE_DEFAULT_RESPONSE = (1 << 4), /**< disable default response */ +} zb_zcl_fc_disable_default_response_e; + +/** + * @brief Default ZCL frame control at APS Header + * + * @since_tizen 4.0 + */ +#define ZB_ZCL_FC_DEFAULT 0x00 /**< Generally used / Not manufacture / Request / with Default Response */ + +/** + * @brief Broadcast address to all router device + * + * @since_tizen 4.0 + */ +#define ZB_BROADCAST_ADDRESS 0xFFFC /**< Broadcast to all routers. */ + +/** + * @brief Broadcast address to devices which support 'rx_on_idle' feature + * + * @since_tizen 4.0 + */ +#define ZB_RX_ON_WHEN_IDLE_BROADCAST_ADDRESS 0xFFFD /**< Broadcast to all non-sleepy devices. */ + +/** + * @brief Broadcast address to all devices + * + * @since_tizen 4.0 + */ +#define ZB_SLEEPY_BROADCAST_ADDRESS 0xFFFF /**< Broadcast to all devices, including sleepy end devices. */ + +/** + * @brief Uses this value as the return value to stop foreach function. + * + * @since_tizen 4.0 + */ +#define ZIGBEE_FUNC_STOP false + +/** + * @brief Uses this value as the return value to continue foreach function. + * + * @since_tizen 4.0 + */ +#define ZIGBEE_FUNC_CONTINUE true + +/** + * @} + */ + +#endif /* __CAPI_NETWORK_ZIGBEE_CONSTANT_H__ */ diff --git a/include/zb_zcl.h b/include/zb_zcl.h new file mode 100644 index 0000000..c661ff1 --- /dev/null +++ b/include/zb_zcl.h @@ -0,0 +1,2676 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_H__ + +/** + * @file zb_zcl.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE Zigbee Cluster Library + * + * @brief Zigbee provides API for ZCL access. + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_MODULE_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_MODULE_OVERVIEW Overview + * This API set consists of ZCL access API + * + * @{ + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * @brief Returns readabble Zigbee Cluster Library status code for human + * @details Returns Zigbee Cluster Library status code + * + * @since_tizen 4.0 + * + * @param[in] id ZigBee Cluster Library Status code + * + * @return pointer of status code string + * + */ +const char* zb_get_zcl_error_message(int id); + +/** + * @brief Returns readable cluster name for human + * @details Returns Zigbee Cluster name and ID + * + * @since_tizen 4.0 + * + * @param[in] id ZigBee Cluster ID + * + * @return pointer of cluster name string + * + */ +const char* zb_get_cluster_name(int id); + +/** + * @brief Returns measuring unit of attribute type + * @details this help to know measuring unit of attribute type + * + * @since_tizen 4.0 + * + * @param[in] type attribute type + * + * @return #zb_zcl_data_category_e + * @retval #DATA_TYPE_NONE Data type none + * @retval #DATA_TYPE_DISCRETE Discrete data type + * @retval #DATA_TYPE_ANALOG Analog data type + * + */ +int zb_get_analog_or_discret(unsigned char type); + +/** + * @brief Returns attribute size + * @details Returns size of attribute data + * + * @since_tizen 4.0 + * + * @param[in] type attribute type + * + * @return size of attribute data type + * + */ +int zb_get_data_size(unsigned char type); + +/** + * @brief Creates simple value data + * @details The simple value data shall contain the data type of the attribute value + * according to the data type in #zb_zcl_data_type_e. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple data value + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_destroy_value() + */ +int zb_create_value( + zb_value_h *handle); + +/** + * @brief Destroys simple value data + * @details Remove allocated memory for simple value data + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple data value + * + * @return None + * + * @see zb_create_value() + */ +void zb_destroy_value( + zb_value_h handle); + +/** + * @brief Sets value from zb_value_h + * @details get data from zb_value_h, expected value type as follows : \n + * val : 16 byte buffer \n + * ieee_addr addr64 : 64-bit IEEE address \n + * aes128_key key16 : 128-bit key \n + * str : for 1 byte string \n + * -> 1st byte is string length, the other are string data.) \n + * wstr : for 2 byte string \n + * -> 1st 2 byte are string length, the other are string data.) \n + * + * @since_tizen 4.0 + * + * @param[in] handle handle of value structure + * @param[in] type data type : \n + * @param[in] value read buffer + * @param[in] count number of read buffer + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_NO_DATA No data available + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + */ +int zb_set_value(zb_value_h handle, unsigned char type, unsigned char *value, int count); + +/** + * @brief Gets value from zb_value_h + * @details get data from zb_value_h, expected value type as follows : \n + * val : 16 byte buffer \n + * struct attribute_str_s *str : for 1 byte string \n + * -> 1st byte is string length, the other are string data.) \n + * struct attribute_wstr_s *wstr : for 2 byte string \n + * -> 1st 2 byte are string length, the other are string data.) \n + * + * @since_tizen 4.0 + * + * @param[in] handle handle of value structure + * @param[out] type data type + * @param[out] value read buffer + * @param[out] count number of read buffer + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_NO_DATA No data available + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + */ +int zb_get_value(zb_value_h handle, unsigned char *type, unsigned char **value, int *count); + +/** + * @brief Creates read attribute status record + * @details This allocates heap for read attribute status record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_destroy_read_attr_status_record() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + */ +int zb_create_read_attr_status_record(read_attr_status_record_h *handle); + +/** + * @brief Destroys read attribute status record + * @details This destroys read attribute status record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_attr_status_record() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + */ +void zb_destroy_read_attr_status_record(read_attr_status_record_h handle); + +/** + * @brief Gets identifier from read attribute status record + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that has been read (or of which an element has been read). + * \n\n This field shall contain the same value that was included in the corresponding a + * ttribute identifier field of the original read attributes or read attributes structured + * command. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[out] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_attr_status_record() + * @see zb_destroy_read_attr_status_record() + * @see zb_set_id_to_read_attr_status_record() + * @see zb_set_status_to_read_attr_status_record() + * @see zb_set_type_to_read_attr_status_record() + * @see zb_set_value_to_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + */ +int zb_get_id_from_read_attr_status_record( + read_attr_status_record_h handle, + unsigned short* id); + +/** + * @brief Sets identifier to read attribute status record + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that has been read (or of which an element has been read). + * \n\n This field shall contain the same value that was included in the corresponding a + * ttribute identifier field of the original read attributes or read attributes structured + * command. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[in] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_attr_status_record() + * @see zb_destroy_read_attr_status_record() + * @see zb_set_status_to_read_attr_status_record() + * @see zb_set_type_to_read_attr_status_record() + * @see zb_set_value_to_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + */ +int zb_set_id_to_read_attr_status_record( + read_attr_status_record_h handle, + unsigned short id); + +/** + * @brief Gets identifier from read attribute status record + * @details The status field is 8 bits in length and specifies the status of the read + * operation on this attribute. \n\n This field shall be set to SUCCESS, if the operation + * was successful, or an error code, as specified in zb_zcl_status_e if the operation was + * not successful. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[out] status error code @see #zb_zcl_status_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_attr_status_record() + * @see zb_destroy_read_attr_status_record() + * @see zb_set_id_to_read_attr_status_record() + * @see zb_set_status_to_read_attr_status_record() + * @see zb_set_type_to_read_attr_status_record() + * @see zb_set_value_to_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + */ +int zb_get_status_from_read_attr_status_record( + read_attr_status_record_h handle, + unsigned char* status); + +/** + * @brief Sets identifier to read attribute status record + * @details The status field is 8 bits in length and specifies the status of the read + * operation on this attribute. \n\n This field shall be set to SUCCESS, if the operation + * was successful, or an error code, as specified in zb_zcl_status_e if the operation was + * not successful. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[in] status error code @see #zb_zcl_status_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_attr_status_record() + * @see zb_destroy_read_attr_status_record() + * @see zb_set_id_to_read_attr_status_record() + * @see zb_set_type_to_read_attr_status_record() + * @see zb_set_value_to_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + */ +int zb_set_status_to_read_attr_status_record( + read_attr_status_record_h handle, + unsigned char status); + + +/** + * @brief Gets identifier from read attribute status record + * @details The attribute data type field shall contain the data type of the attribute + * in the same read attributes status record (see #zb_zcl_data_type_e). \n\n This field shall only + * be included in zb_zcl_data_type_e if the associated status field contains a value of + * SUCCESS. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[out] type data type in @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_attr_status_record() + * @see zb_destroy_read_attr_status_record() + * @see zb_set_id_to_read_attr_status_record() + * @see zb_set_status_to_read_attr_status_record() + * @see zb_set_type_to_read_attr_status_record() + * @see zb_set_value_to_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + */ +int zb_get_type_from_read_attr_status_record( + read_attr_status_record_h handle, + unsigned char *type); + +/** + * @brief Sets identifier to read attribute status record + * @details The attribute data type field shall contain the data type of the attribute + * in the same read attributes status record (see #zb_zcl_data_type_e). + * \n\n This field shall only be included in zb_zcl_data_type_e if the associated status + * field contains a value of SUCCESS. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[in] type data type in @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_attr_status_record() + * @see zb_destroy_read_attr_status_record() + * @see zb_set_id_to_read_attr_status_record() + * @see zb_set_status_to_read_attr_status_record() + * @see zb_set_value_to_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + */ +int zb_set_type_to_read_attr_status_record( + read_attr_status_record_h handle, + unsigned char type); + +/** + * @brief Gets data value from read attribute status record + * @details The attribute value field is variable in length and shall contain the current + * value of this attribute. \n\n This field shall only be included if the associated + * status field contains a value of SUCCESS. \n\n + * For an attribute or element of simple type, this + * field has the format shown in the Table of Data Types (see #zb_zcl_data_type_e). + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[in] type data type in #zb_zcl_data_type_e + * @param[out] value data value pointer + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NO_DATA No data available + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_create_read_attr_status_record() + * @see zb_destroy_read_attr_status_record() + * @see zb_set_id_to_read_attr_status_record() + * @see zb_set_status_to_read_attr_status_record() + * @see zb_set_type_to_read_attr_status_record() + * @see zb_set_value_to_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + */ +int zb_get_value_from_read_attr_status_record( + read_attr_status_record_h handle, + unsigned char type, + zb_value_h value); + +/** + * @brief Sets data value to read attribute status record + * @details The attribute value field is variable in length and shall contain the current + * value of this attribute. \n\n This field shall only be included if the associated + * status field contains a value of SUCCESS. \n\n + * For an attribute or element of simple type, this + * field has the format shown in the Table of Data Types (see #zb_zcl_data_type_e). + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[in] type data type in #zb_zcl_data_type_e + * @param[in] value data value pointer + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NO_DATA No data available + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_create_read_attr_status_record() + * @see zb_destroy_read_attr_status_record() + * @see zb_set_id_to_read_attr_status_record() + * @see zb_set_status_to_read_attr_status_record() + * @see zb_set_type_to_read_attr_status_record() + * @see zb_zcl_global_read_attr_rsp() + * @see zb_get_id_from_read_attr_status_record() + * @see zb_get_status_from_read_attr_status_record() + * @see zb_get_type_from_read_attr_status_record() + * @see zb_get_value_from_read_attr_status_record() + */ +int zb_set_value_to_read_attr_status_record( + read_attr_status_record_h handle, + unsigned char type, + zb_value_h value); + +/** + * @brief Creates discover attribute infomation record + * @details This allocates heap for discover attribute infomation record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of discover attribute infomation record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_destroy_discover_attr_info() + * @see zb_get_id_from_discover_attr_info() + * @see zb_get_type_from_discover_attr_info() + * @see zb_zcl_global_discover_attr_rsp() + */ +int zb_create_discover_attr_info(discover_attr_info_record_h *handle); + +/** + * @brief Destroys discover attribute infomation record + * @details This destroys discover attribute infomation record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of discover attribute infomation record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_discover_attr_info() + * @see zb_get_id_from_discover_attr_info() + * @see zb_get_type_from_discover_attr_info() + * @see zb_zcl_global_discover_attr_rsp() + */ +void zb_destroy_discover_attr_info(discover_attr_info_record_h handle); + +/** + * @brief Gets identifier from discover attribute info + * @details The attribute identifier field shall contain the identifier of a discovered + * attribute. \n\n Attributes shall be included in ascending order, starting with the + * lowest attribute identifier that is greater than or equal to the start attribute + * identifier field of the received discover attributes command. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[out] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_discover_attr_info() + * @see zb_destroy_discover_attr_info() + * @see zb_get_type_from_discover_attr_info() + * @see zb_zcl_global_discover_attr_rsp() + */ +int zb_get_id_from_discover_attr_info( + discover_attr_info_record_h handle, + unsigned short *id); + +/** + * @brief Sets identifier to discover attribute info + * @details The attribute identifier field shall contain the identifier of a discovered + * attribute. \n\n Attributes shall be included in ascending order, starting with the + * lowest attribute identifier that is greater than or equal to the start attribute + * identifier field of the received discover attributes command. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[in] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_discover_attr_info() + * @see zb_destroy_discover_attr_info() + * @see zb_get_type_from_discover_attr_info() + * @see zb_zcl_global_discover_attr_rsp() + */ +int zb_set_id_to_discover_attr_info( + discover_attr_info_record_h handle, + unsigned short id); + +/** + * @brief Gets data type from discover attribute info + * @details The attribute data type field shall contain the data type of the attribute in + * the same attribute report field (see #zb_zcl_data_type_e) + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[out] type attribute data type @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_discover_attr_info() + * @see zb_destroy_discover_attr_info() + * @see zb_get_id_from_discover_attr_info() + * @see zb_zcl_global_discover_attr_rsp() + */ +int zb_get_type_from_discover_attr_info( + discover_attr_info_record_h handle, + unsigned char *type); + +/** + * @brief Sets data type to discover attribute info + * @details The attribute data type field shall contain the data type of the attribute in + * the same attribute report field (see #zb_zcl_data_type_e) + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[in] type attribute data type @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_discover_attr_info() + * @see zb_destroy_discover_attr_info() + * @see zb_get_id_from_discover_attr_info() + * @see zb_zcl_global_discover_attr_rsp() + */ +int zb_set_type_to_discover_attr_info( + discover_attr_info_record_h handle, + unsigned char type); + +/** + * @brief Creates write attribute record + * @details Allocate memory for write attribute record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_zcl_global_write_attr() + * @see zb_zcl_global_write_attr_undivided() + * @see zb_zcl_global_write_attr_no_rep() + * @see zb_destroy_write_attr_record() + * @see zb_set_id_to_write_attr_record() + * @see zb_set_type_to_write_attr_record() + * @see zb_set_buf_to_write_attr_record() + * @see zb_set_value_to_write_attr_record() + */ +int zb_create_write_attr_record( + write_attr_record_h *handle); + +/** + * @brief Destroys write attribute record + * @details Remove allocated memory for write attribute record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute record + * + * @return None + * + * @see zb_zcl_global_write_attr() + * @see zb_zcl_global_write_attr_undivided() + * @see zb_zcl_global_write_attr_no_rep() + * @see zb_create_write_attr_record() + * @see zb_set_id_to_write_attr_record() + * @see zb_set_type_to_write_attr_record() + * @see zb_set_buf_to_write_attr_record() + * @see zb_set_value_to_write_attr_record() + */ +void zb_destroy_write_attr_record( + write_attr_record_h handle); + +/** + * @brief Sets attribute identifier write attribute record + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that is to be written. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute record + * @param[in] id attribute identifier + * + * @return None + * + * @see zb_zcl_global_write_attr() + * @see zb_zcl_global_write_attr_undivided() + * @see zb_zcl_global_write_attr_no_rep() + * @see zb_create_write_attr_record() + * @see zb_destroy_write_attr_record() + * @see zb_set_type_to_write_attr_record() + * @see zb_set_buf_to_write_attr_record() + * @see zb_set_value_to_write_attr_record() + */ +int zb_set_id_to_write_attr_record( + write_attr_record_h handle, + unsigned short id); + +/** + * @brief Sets attribute data type write attribute record + * @details The attribute data type field shall contain the data type of the attribute + * that is to be written. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute record + * @param[in] type attribute data type + * + * @return None + * + * @see zb_zcl_global_write_attr() + * @see zb_zcl_global_write_attr_undivided() + * @see zb_zcl_global_write_attr_no_rep() + * @see zb_create_write_attr_record() + * @see zb_destroy_write_attr_record() + * @see zb_set_id_to_write_attr_record() + * @see zb_set_buf_to_write_attr_record() + * @see zb_set_value_to_write_attr_record() + */ +int zb_set_type_to_write_attr_record( + write_attr_record_h handle, + unsigned char type); + +/** + * @brief Sets attribute data write attribute record + * @details The attribute data type field shall contain the data type of the attribute + * that is to be written. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute record + * @param[in] type attribute type + * @param[in] value attribute data + * @param[in] count length of attribute data + * + * @return None + * + * @see zb_zcl_global_write_attr() + * @see zb_zcl_global_write_attr_undivided() + * @see zb_zcl_global_write_attr_no_rep() + * @see zb_create_write_attr_record() + * @see zb_destroy_write_attr_record() + * @see zb_set_id_to_write_attr_record() + * @see zb_set_type_to_write_attr_record() + * @see zb_set_buf_to_write_attr_record() + * @see zb_set_value_to_write_attr_record() + */ +int zb_set_buf_to_write_attr_record( + write_attr_record_h handle, + unsigned char type, + unsigned char *value, + int count); + +/** + * @brief Sets data value to write attribute status record + * @details The attribute data type field shall contain the data type of the attribute in + * the same attribute report field (see #zb_zcl_data_type_e) + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] value attribute data value + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_write_attr() + * @see zb_zcl_global_write_attr_undivided() + * @see zb_zcl_global_write_attr_no_rep() + * @see zb_create_write_attr_record() + * @see zb_destroy_write_attr_record() + * @see zb_set_id_to_write_attr_record() + * @see zb_set_type_to_write_attr_record() + * @see zb_set_buf_to_write_attr_record() + */ +int zb_set_value_to_write_attr_record( + write_attr_record_h handle, + zb_value_h value); + +/** + * @brief Creates write attribute status record + * @details This allocates heap for write attribute status record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_write_attr_rsp() + * @see zb_destroy_write_attr_status() + * @see zb_get_status_from_write_attr_status() + * @see zb_get_id_from_write_attr_status() + */ +int zb_create_write_attr_status(write_attr_status_record_h *handle); + +/** + * @brief Destroys write attribute status record + * @details This destroys write attribute status record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_write_attr_rsp() + * @see zb_create_write_attr_status() + * @see zb_get_id_from_discover_attr_info() + * @see zb_get_type_from_discover_attr_info() + + */ +void zb_destroy_write_attr_status(write_attr_status_record_h handle); + +/** + * @brief Gets status from write attribute status record + * @details The status field is 8 bits in length and specifies the status of the read + * operation on this attribute. \n\n This field shall be set to SUCCESS, if the operation + * was successful, or an error code, as specifed in zb_zcl_status_e if the operation was + * not successful. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[out] status error code @see #zb_zcl_status_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_write_attr_rsp() + * @see zb_get_id_from_write_attr_status() + */ +int zb_get_status_from_write_attr_status( + write_attr_status_record_h handle, + unsigned char *status); + +/** + * @brief Sets status to write attribute status record + * @details The status field is 8 bits in length and specifies the status of the read + * operation on this attribute. \n\n This field shall be set to SUCCESS, if the operation + * was successful, or an error code, as specifed in zb_zcl_status_e if the operation was + * not successful. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read attribute status record + * @param[in] status error code @see #zb_zcl_status_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_write_attr_rsp() + * @see zb_get_status_from_write_attr_status() + * @see zb_get_id_from_write_attr_status() + * @see zb_set_id_to_write_attr_status() + */ +int zb_set_status_to_write_attr_status( + write_attr_status_record_h handle, + unsigned char status); + +/** + * @brief Gets identifier from write attribute status record + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that has been write (or of which an element has been write). + * \n\n This field shall contain the same value that was included in the corresponding a + * ttribute identifier field of the original write attributes or write attributes + * structured command. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_write_attr_rsp() + * @see zb_get_status_from_write_attr_status() + * @see zb_set_status_to_write_attr_status() + * @see zb_set_id_to_write_attr_status() + */ +int zb_get_id_from_write_attr_status( + write_attr_status_record_h handle, + unsigned short *id); + +/** + * @brief Sets identifier to write attribute status record + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that has been write (or of which an element has been write). + * \n\n This field shall contain the same value that was included in the corresponding a + * ttribute identifier field of the original write attributes or write attributes + * structured command. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_write_attr_rsp() + * @see zb_get_status_from_write_attr_status() + * @see zb_set_status_to_write_attr_status() + * @see zb_get_id_from_write_attr_status() + */ +int zb_set_id_to_write_attr_status( + write_attr_status_record_h handle, + unsigned short id); + +/** + * @brief Creates reporting configuration record + * @details Allocate memory for reporting configuration record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of reporting configuration record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_create_report_config_record( + report_config_record_h *handle); + +/** + * @brief Destroys reporting configuration record + * @details This destroys reporting configuration record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of reporting configuration record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +void zb_destroy_report_config_record( + report_config_record_h handle); + +/** + * @brief Gets direction from reporting configuration record + * @details The direction field specifies whether values of the attribute are be reported, + * or whether reports of the attribute are to be received. \n\n + * If this value is set to 0x00, then the attribute data type field, the minimum + * reporting interval field, the maximum reporting interval field and the reportable + * change field are included in the payload, and the timeout period field is omitted. + * The record is sent to a cluster server (or client) to configure how it sends reports to + * a client (or server) of the same cluster. \n\n + * If this value is set to 0x01, then the timeout period field is included in the payload, + * and the attribute data type field, the minimum reporting interval field, the + * maximum reporting interval field and the reportable change field are omitted. The + * record is sent to a cluster client (or server) to configure how it should expect + * reports from a server (or client) of the same cluster. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] dir 00 : The receiver of the Configure Reporting command shall configure + * reporting to send to each destination as resolved by + * the bindings for the cluster hosting the attributes to be reported.\n + * 01 : This indicates to the receiver of the Configure Reporting + * command that the sender has configured its reporting + * mechanism to transmit reports and that, based on the current + * state of the sender's bindings, the sender will send reports to the + * receiver.\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_dir_from_report_config_record( + report_config_record_h handle, + unsigned char *dir); + +/** + * @brief Sets direction to reporting configuration record + * @details The direction field specifies whether values of the attribute are be reported, + * or whether reports of the attribute are to be received. \n\n + * If this value is set to 0x00, then the attribute data type field, the minimum + * reporting interval field, the maximum reporting interval field and the reportable + * change field are included in the payload, and the timeout period field is omitted. + * The record is sent to a cluster server (or client) to configure how it sends reports to + * a client (or server) of the same cluster. \n\n + * If this value is set to 0x01, then the timeout period field is included in the payload, + * and the attribute data type field, the minimum reporting interval field, the + * maximum reporting interval field and the reportable change field are omitted. The + * record is sent to a cluster client (or server) to configure how it should expect + * reports from a server (or client) of the same cluster. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] dir 00 : The receiver of the Configure Reporting command shall configure + * reporting to send to each destination as resolved by + * the bindings for the cluster hosting the attributes to be reported.\n + * 01 : This indicates to the receiver of the Configure Reporting + * command that the sender has configured its reporting + * mechanism to transmit reports and that, based on the current + * state of the sender's bindings, the sender will send reports to the + * receiver.\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_set_dir_to_report_config_record( + report_config_record_h handle, + unsigned char dir); + +/** + * @brief Gets attribute identifier from reporting configuration record + * @details If the direction field is 0x00, this field contains the identifier of the + * attribute that is to be reported. \n\n If instead the direction field is 0x01, + * the device shall expect reports of values of this attribute. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_id_from_report_config_record( + report_config_record_h handle, + unsigned short *id); + +/** + * @brief Sets attribute identifier to reporting configuration record + * @details If the direction field is 0x00, this field contains the identifier of the + * attribute that is to be reported. \n\n If instead the direction field is 0x01, + * the device shall expect reports of values of this attribute. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_set_id_to_report_config_record( + report_config_record_h handle, + unsigned short id); + +/** + * @brief Gets attribute data type from reporting configuration record + * @details The Attribute data type field contains the data type of the attribute that is + * to be reported. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] type attribute data type @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_type_from_report_config_record( + report_config_record_h handle, + unsigned char *type); + +/** + * @brief Sets attribute data type to reporting configuration record + * @details The Attribute data type field contains the data type of the attribute that is + * to be reported. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] type attribute data type @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_set_type_to_report_config_record( + report_config_record_h handle, + unsigned char type); + +/** + * @brief Gets minimum interval from reporting configuration record + * @details The minimum reporting interval field is 16 bits in length and shall contain + * the minimum interval, in seconds, between issuing reports of the specified attribute. + * \n\n + * If this value is set to 0x0000, then there is no minimum limit, unless one is + * imposed by the specification of the cluster using this reporting mechanism or by + * the applicable profile. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] min_i minimum interval time + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_min_i_from_report_config_record( + report_config_record_h handle, + unsigned short *min_i); + +/** + * @brief Sets minimum interval to reporting configuration record + * @details The minimum reporting interval field is 16 bits in length and shall contain + * the minimum interval, in seconds, between issuing reports of the specified attribute. + * \n\n + * If this value is set to 0x0000, then there is no minimum limit, unless one is + * imposed by the specification of the cluster using this reporting mechanism or by + * the applicable profile. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] min_i minimum interval time + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_set_min_i_to_report_config_record( + report_config_record_h handle, + unsigned short min_i); + +/** + * @brief Gets maximum interval from reporting configuration record + * @details The maximum reporting interval field is 16 bits in length and shall contain + * the maximum interval, in seconds, between issuing reports of the specified attribute. + * \n\n + * If this value is set to 0xffff, then the device shall not issue reports for the + * specified attribute, and the configuration information for that attribute need not be + * maintained. \n\n (Note: in an implementation using dynamic memory allocation, the + * memory space for that information may then be reclaimed). + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] max_i maximum interval time + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_max_i_from_report_config_record( + report_config_record_h handle, + unsigned short *max_i); + +/** + * @brief Sets maximum interval to reporting configuration record + * @details The maximum reporting interval field is 16 bits in length and shall contain + * the maximum interval, in seconds, between issuing reports of the specified attribute. + * \n\n + * If this value is set to 0xffff, then the device shall not issue reports for the + * specified attribute, and the configuration information for that attribute need not be + * maintained. \n\n (Note: in an implementation using dynamic memory allocation, the + * memory space for that information may then be reclaimed). + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] max_i maximum interval time + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_set_max_i_to_report_config_record( + report_config_record_h handle, + unsigned short max_i); + +/** + * @brief Gets timeout from reporting configuration record + * @details The timeout period field is 16 bits in length and shall contain the maximum + * expected time, in seconds, between received reports for the attribute specified in + * the attribute identifier field. If more time than this elapses between reports, this + * may be an indication that there is a problem with reporting. \n\n + * If this value is set to 0x0000, reports of the attribute are not subject to timeout. + * Note that, for a server/client connection to work properly using automatic + * reporting, the timeout value set for attribute reports to be received by the client (or + * server) cluster must be set somewhat higher than the maximum reporting interval + * set for the attribute on the server (or client) cluster. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] timeout timeout + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_timeout_from_report_config_record( + report_config_record_h handle, + unsigned short *timeout); + +/** + * @brief Sets timeout to reporting configuration record + * @details The timeout period field is 16 bits in length and shall contain the maximum + * expected time, in seconds, between received reports for the attribute specified in + * the attribute identifier field. If more time than this elapses between reports, this + * may be an indication that there is a problem with reporting. \n\n + * If this value is set to 0x0000, reports of the attribute are not subject to timeout. + * Note that, for a server/client connection to work properly using automatic + * reporting, the timeout value set for attribute reports to be received by the client (or + * server) cluster must be set somewhat higher than the maximum reporting interval + * set for the attribute on the server (or client) cluster. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] timeout timeout + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_set_timeout_to_report_config_record( + report_config_record_h handle, + unsigned short timeout); + +/** + * @brief Gets change from reporting configuration record + * @details The reportable change field shall contain the minimum change to the attribute + * that will result in a report being issued. This field is of variable length. \n\n + * For attributes with 'analog' data type (see #zb_zcl_data_type_e) + * the field has the same data type as the attribute. \n\n + * The sign (if any) of the reportable change field is ignored.\n + * For attributes of 'discrete' data type (see #zb_zcl_data_type_e) + * this field is omitted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] value data (only analog data type is allowed) + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_change_from_report_config_record1( + report_config_record_h handle, + zb_value_h value); + +/** + * @brief Sets change to reporting configuration record + * @details The reportable change field shall contain the minimum change to the attribute + * that will result in a report being issued. This field is of variable length. \n\n + * For attributes with 'analog' data type (see #zb_zcl_data_type_e) + * the field has the same data type as the attribute. \n\n + * The sign (if any) of the reportable change field is ignored. \n + * For attributes of 'discrete' data type (see #zb_zcl_data_type_e) + * this field is omitted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] value data (only analog data type is allowed) + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_set_change_to_report_config_record1( + report_config_record_h handle, + zb_value_h value); + +/** + * @brief Gets change from reporting configuration record + * @details The reportable change field shall contain the minimum change to the attribute + * that will result in a report being issued. This field is of variable length. \n\n + * For attributes with 'analog' data type (see #zb_zcl_data_type_e) + * the field has the same data type as the attribute. \n\n The sign (if any) of the + * reportable change field is ignored. \n + * For attributes of 'discrete' data type (see #zb_zcl_data_type_e) + * this field is omitted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] type attribute type + * @param[out] value attribute data which is allocated in library (only analog data type is allowed) + * @param[out] size attribute data size + * + * @remark value : generated from library you MUST free it + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_change_from_report_config_record2( + report_config_record_h handle, + unsigned char *type, + unsigned char **value, + int *size); + +/** + * @brief Sets change to reporting configuration record + * @details The reportable change field shall contain the minimum change to the attribute + * that will result in a report being issued. This field is of variable length. \n\n + * For attributes with 'analog' data type (see #zb_zcl_data_type_e) + * the field has the same data type as the attribute. \n\n + * The sign (if any) of the reportable change field is ignored. \n + * For attributes of 'discrete' data type (see #zb_zcl_data_type_e) + * this field is omitted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] type attribute type + * @param[in] value attribute data (only analog data type is allowed) + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_set_change_to_report_config_record2( + report_config_record_h handle, + unsigned char type, + unsigned char *value); + +/** + * @brief Gets change from reporting configuration record + * @details The reportable change field shall contain the minimum change to the attribute + * that will result in a report being issued. This field is of variable length. \n\n + * For attributes with 'analog' data type (see #zb_zcl_data_type_e) + * the field has the same data type as the attribute. \n\n + * The sign (if any) of the reportable change field is ignored.\n + * For attributes of 'discrete' data type (see #zb_zcl_data_type_e) + * this field is omitted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] type attribute type + * @param[out] value attribute data (only analog data type is allowed) + * @param[out] size attribute data size + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_change_from_report_config_record2( + report_config_record_h handle, + unsigned char *type, + unsigned char **value, + int *size); + +/** + * @brief Gets change from reporting configuration record + * @details The reportable change field shall contain the minimum change to the attribute + * that will result in a report being issued. This field is of variable length. \n\n + * For attributes with 'analog' data type (see #zb_zcl_data_type_e) + * the field has the same data type as the attribute. \n\n + * The sign (if any) of the reportable change field is ignored. \n + * For attributes of 'discrete' data type (see #zb_zcl_data_type_e) + * this field is omitted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] type attribute type + * @param[out] value attribute data (only analog data type is allowed) + * @param[out] size attribute data size + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_read_report_config_rsp() + * @see zb_create_report_config_record() + * @see zb_destroy_report_config_record() + * @see zb_get_id_from_report_config_record() + * @see zb_set_id_to_report_config_record() + * @see zb_get_dir_from_report_config_record() + * @see zb_set_dir_to_report_config_record() + * @see zb_get_type_from_report_config_record() + * @see zb_set_type_to_report_config_record() + * @see zb_get_min_i_from_report_config_record() + * @see zb_set_min_i_to_report_config_record() + * @see zb_get_max_i_from_report_config_record() + * @see zb_set_max_i_to_report_config_record() + * @see zb_get_change_from_report_config_record1() + * @see zb_set_change_to_report_config_record1() + * @see zb_get_change_from_report_config_record2() + * @see zb_set_change_to_report_config_record2() + * @see zb_get_change_from_report_config_record3() + * @see zb_get_timeout_from_report_config_record() + * @see zb_set_timeout_to_report_config_record() + */ +int zb_get_change_from_report_config_record3( + report_config_record_h handle, + unsigned char *type, + unsigned char *value, + int *size); + +/** + * @brief Creates read reporting configuration record + * @details Allocate memory for read reporting configuration record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of read configuration record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_create_read_report_config_record() + * @see zb_destroy_read_report_config_record() + * @see zb_get_id_from_read_report_config_record() + * @see zb_set_id_to_read_report_config_record() + * @see zb_get_dir_from_read_report_config_record() + * @see zb_set_dir_to_read_report_config_record() + */ +int zb_create_read_report_config_record( + read_report_config_record_h *handle); + +/** + * @brief Destroys read reporting configuration record + * @details Remove allocated memory for read reporting configuration record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute record + * + * @return None + * + * @see zb_create_read_report_config_record() + * @see zb_destroy_read_report_config_record() + * @see zb_get_id_from_read_report_config_record() + * @see zb_set_id_to_read_report_config_record() + * @see zb_get_dir_from_read_report_config_record() + * @see zb_set_dir_to_read_report_config_record() + */ +void zb_destroy_read_report_config_record( + read_report_config_record_h handle); + +/** + * @brief Gets direction from read reporting configuration record + * @details The direction field specifies whether values of the attribute are reported + * (0x00), or whether reports of the attribute are received (0x01). \n\n + * All other values of this field are reserved. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] dir direction + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_report_config_record() + * @see zb_destroy_read_report_config_record() + * @see zb_get_id_from_read_report_config_record() + * @see zb_set_id_to_read_report_config_record() + * @see zb_get_dir_from_read_report_config_record() + * @see zb_set_dir_to_read_report_config_record() + */ +int zb_get_dir_from_read_report_config_record( + read_report_config_record_h handle, + unsigned char *dir); + +/** + * @brief Sets direction to read reporting configuration record + * @details The direction field specifies whether values of the attribute are reported + * (0x00), or whether reports of the attribute are received (0x01). \n\n + * All other values of this field are reserved. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] dir direction + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_report_config_record() + * @see zb_destroy_read_report_config_record() + * @see zb_get_id_from_read_report_config_record() + * @see zb_set_id_to_read_report_config_record() + * @see zb_get_dir_from_read_report_config_record() + * @see zb_set_dir_to_read_report_config_record() + */ +int zb_set_dir_to_read_report_config_record( + read_report_config_record_h handle, + unsigned char dir); + +/** + * @brief Gets attribute idenitifier from read reporting configuration record + * @details The attribute identifier field shall contain the identifier of the attribute + * whose reporting configuration details are to be read. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_report_config_record() + * @see zb_destroy_read_report_config_record() + * @see zb_get_id_from_read_report_config_record() + * @see zb_set_id_to_read_report_config_record() + * @see zb_get_dir_from_read_report_config_record() + * @see zb_set_dir_to_read_report_config_record() + */ +int zb_get_id_from_read_report_config_record( + read_report_config_record_h handle, + unsigned short *id); + +/** + * @brief Gets attribute idenitifier from read reporting configuration record + * @details The attribute identifier field shall contain the identifier of the attribute + * whose reporting configuration details are to be read. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_create_read_report_config_record() + * @see zb_destroy_read_report_config_record() + * @see zb_get_id_from_read_report_config_record() + * @see zb_set_id_to_read_report_config_record() + * @see zb_get_dir_from_read_report_config_record() + * @see zb_set_dir_to_read_report_config_record() + */ +int zb_set_id_to_read_report_config_record( + read_report_config_record_h handle, + unsigned short id); + +/** + * @brief Creates reporting configuration response record + * @details Allocate memory for reporting configuration response record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of reporting configuration response record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_zcl_global_config_report_rsp() + * @see zb_create_report_config_response_record() + * @see zb_destroy_report_config_response_record() + * @see zb_get_status_from_report_config_response_record() + * @see zb_set_status_to_report_config_response_record() + * @see zb_get_dir_from_report_config_response_record() + * @see zb_set_dir_to_report_config_response_record() + * @see zb_get_id_from_report_config_response_record() + * @see zb_set_id_to_report_config_response_record() + */ +int zb_create_report_config_response_record( + report_config_response_record_h *handle); + +/** + * @brief Destroys reporting configuration response record + * @details This destroys reporting configuration response record + * + * @since_tizen 4.0 + * + * @param[in] handle handle of reporting configuration response record + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_config_report_rsp() + * @see zb_create_report_config_response_record() + * @see zb_destroy_report_config_response_record() + * @see zb_get_status_from_report_config_response_record() + * @see zb_set_status_to_report_config_response_record() + * @see zb_get_dir_from_report_config_response_record() + * @see zb_set_dir_to_report_config_response_record() + * @see zb_get_id_from_report_config_response_record() + * @see zb_set_id_to_report_config_response_record() + */ +void zb_destroy_report_config_response_record( + report_config_response_record_h handle); + +/** + * @brief Gets status from reporting configuration response record + * @details If the attribute is not implemented on the sender or receiver of the command, + * whichever is relevant (depending on direction), this field shall be set to + * UNSUPPORTED_ATTRIBUTE. \n If the attribute is supported, but is not capable of + * being reported, this field shall be set to UNREPORTABLE_ATTRIBUTE. \n + * Otherwise, this field shall be set to SUCCESS. \n + * If the status field is not set to SUCCESS, all fields except the direction and + * attribute identifier fields shall be omitted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] status status @see #zb_zcl_status_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_config_report_rsp() + * @see zb_create_report_config_response_record() + * @see zb_destroy_report_config_response_record() + * @see zb_get_status_from_report_config_response_record() + * @see zb_set_status_to_report_config_response_record() + * @see zb_get_dir_from_report_config_response_record() + * @see zb_set_dir_to_report_config_response_record() + * @see zb_get_id_from_report_config_response_record() + * @see zb_set_id_to_report_config_response_record() + */ +int zb_get_status_from_report_config_response_record( + report_config_response_record_h handle, + unsigned char *status); + +/** + * @brief Sets status to reporting configuration response record + * @details If the attribute is not implemented on the sender or receiver of the command, + * whichever is relevant (depending on direction), this field shall be set to + * UNSUPPORTED_ATTRIBUTE. \n If the attribute is supported, but is not capable of + * being reported, this field shall be set to UNREPORTABLE_ATTRIBUTE. \n + * Otherwise, this field shall be set to SUCCESS. \n + * If the status field is not set to SUCCESS, all fields except the direction and + * attribute identifier fields shall be omitted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] status status @see #zb_zcl_status_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_config_report_rsp() + * @see zb_create_report_config_response_record() + * @see zb_destroy_report_config_response_record() + * @see zb_get_status_from_report_config_response_record() + * @see zb_set_status_to_report_config_response_record() + * @see zb_get_dir_from_report_config_response_record() + * @see zb_set_dir_to_report_config_response_record() + * @see zb_get_id_from_report_config_response_record() + * @see zb_set_id_to_report_config_response_record() + */ +int zb_set_status_to_report_config_response_record( + report_config_response_record_h handle, + unsigned char status); + +/** + * @brief Gets direction from reporting configuration response record + * @details The direction field specifies whether values of the attribute are reported + * (0x00), or whether reports of the attribute are received (0x01). \n\n + * If this value is set to 0x00, then the attribute data type field, the minimum + * reporting interval field, the maximum reporting interval field and the reportable + * change field are included in the payload, and the timeout period field is omitted. If + * this value is set to 0x01, then the timeout period field is included in the payload, + * and the attribute data type field, the minimum reporting interval field, the + * maximum reporting interval field and the reportable change field are omitted. \n\n + * All other values of this field are reserved. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] dir direction 00 : Client-to-Server \n + * 01 : server-to-Client \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_config_report_rsp() + * @see zb_create_report_config_response_record() + * @see zb_destroy_report_config_response_record() + * @see zb_get_status_from_report_config_response_record() + * @see zb_set_status_to_report_config_response_record() + * @see zb_get_dir_from_report_config_response_record() + * @see zb_set_dir_to_report_config_response_record() + * @see zb_get_id_from_report_config_response_record() + * @see zb_set_id_to_report_config_response_record() + */ +int zb_get_dir_from_report_config_response_record( + report_config_response_record_h handle, + unsigned char *dir); + +/** + * @brief Sets direction to reporting configuration response record + * @details The direction field specifies whether values of the attribute are reported + * (0x00), or whether reports of the attribute are received (0x01). \n\n + * If this value is set to 0x00, then the attribute data type field, the minimum + * reporting interval field, the maximum reporting interval field and the reportable + * change field are included in the payload, and the timeout period field is omitted. If + * this value is set to 0x01, then the timeout period field is included in the payload, + * and the attribute data type field, the minimum reporting interval field, the + * maximum reporting interval field and the reportable change field are omitted. \n\n + * All other values of this field are reserved. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] dir direction 00 : Client-to-Server \n + * 01 : server-to-Client \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_config_report_rsp() + * @see zb_create_report_config_response_record() + * @see zb_destroy_report_config_response_record() + * @see zb_get_status_from_report_config_response_record() + * @see zb_set_status_to_report_config_response_record() + * @see zb_get_dir_from_report_config_response_record() + * @see zb_set_dir_to_report_config_response_record() + * @see zb_get_id_from_report_config_response_record() + * @see zb_set_id_to_report_config_response_record() + */ +int zb_set_dir_to_report_config_response_record( + report_config_response_record_h handle, + unsigned char dir); + +/** + * @brief Gets attribute identifier from reporting configuration response record + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that the reporting configuration details apply to. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_config_report_rsp() + * @see zb_create_report_config_response_record() + * @see zb_destroy_report_config_response_record() + * @see zb_get_status_from_report_config_response_record() + * @see zb_set_status_to_report_config_response_record() + * @see zb_get_dir_from_report_config_response_record() + * @see zb_set_dir_to_report_config_response_record() + * @see zb_get_id_from_report_config_response_record() + * @see zb_set_id_to_report_config_response_record() + */ +int zb_get_id_from_report_config_response_record( + report_config_response_record_h handle, + unsigned short *id); + +/** + * @brief Sets attribute identifier to reporting configuration response record + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that the reporting configuration details apply to. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_config_report_rsp() + * @see zb_create_report_config_response_record() + * @see zb_destroy_report_config_response_record() + * @see zb_get_status_from_report_config_response_record() + * @see zb_set_status_to_report_config_response_record() + * @see zb_get_dir_from_report_config_response_record() + * @see zb_set_dir_to_report_config_response_record() + * @see zb_get_id_from_report_config_response_record() + * @see zb_set_id_to_report_config_response_record() + */ +int zb_set_id_to_report_config_response_record( + report_config_response_record_h handle, + unsigned short id); + +/** + * @brief Creates reporting attribute + * @details Allocate memory for reporting attribute + * + * @since_tizen 4.0 + * + * @param[in] handle handle of reporting attribute + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_event_get_attr_report() + * @see zb_create_attr_report() + * @see zb_destroy_attr_report() + * @see zb_get_id_from_attr_report() + * @see zb_set_id_to_attr_report() + * @see zb_get_type_from_attr_report() + * @see zb_set_type_to_attr_report() + * @see zb_get_value_from_attr_report() + * @see zb_set_value_to_attr_report() + */ +int zb_create_attr_report( + attr_report_h *handle); + +/** + * @brief Destroys reporting attribute + * @details This destroys reporting attribute + * + * @since_tizen 4.0 + * + * @param[in] handle handle of reporting attribute + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_event_get_attr_report() + * @see zb_create_attr_report() + * @see zb_destroy_attr_report() + * @see zb_get_id_from_attr_report() + * @see zb_set_id_to_attr_report() + * @see zb_get_type_from_attr_report() + * @see zb_set_type_to_attr_report() + * @see zb_get_value_from_attr_report() + * @see zb_set_value_to_attr_report() + */ +void zb_destroy_attr_report( + attr_report_h handle); + +/** + * @brief Gets attribute identifier from reporting attribute + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that the reporting configuration details apply to. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_event_get_attr_report() + * @see zb_create_attr_report() + * @see zb_destroy_attr_report() + * @see zb_get_id_from_attr_report() + * @see zb_set_id_to_attr_report() + * @see zb_get_type_from_attr_report() + * @see zb_set_type_to_attr_report() + * @see zb_get_value_from_attr_report() + * @see zb_set_value_to_attr_report() + */ +int zb_get_id_from_attr_report( + attr_report_h handle, + unsigned short *id); + +/** + * @brief Sets attribute identifier to reporting attribute + * @details The attribute identifier field is 16 bits in length and shall contain the + * identifier of the attribute that the reporting configuration details apply to. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_event_get_attr_report() + * @see zb_create_attr_report() + * @see zb_destroy_attr_report() + * @see zb_get_id_from_attr_report() + * @see zb_set_id_to_attr_report() + * @see zb_get_type_from_attr_report() + * @see zb_set_type_to_attr_report() + * @see zb_get_value_from_attr_report() + * @see zb_set_value_to_attr_report() + */ +int zb_set_id_to_attr_report( + attr_report_h handle, + unsigned short id); + +/** + * @brief Gets attribute type from reporting attribute + * @details The attribute data type field contains the data type of the attribute that is + * being reported. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] type attribute data type @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_event_get_attr_report() + * @see zb_create_attr_report() + * @see zb_destroy_attr_report() + * @see zb_get_id_from_attr_report() + * @see zb_set_id_to_attr_report() + * @see zb_get_type_from_attr_report() + * @see zb_set_type_to_attr_report() + * @see zb_get_value_from_attr_report() + * @see zb_set_value_to_attr_report() + */ +int zb_get_type_from_attr_report( + attr_report_h handle, + unsigned char *type); + +/** + * @brief Sets attribute type to reporting attribute + * @details The attribute data type field contains the data type of the attribute that is + * being reported. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] type attribute data type @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_event_get_attr_report() + * @see zb_create_attr_report() + * @see zb_destroy_attr_report() + * @see zb_get_id_from_attr_report() + * @see zb_set_id_to_attr_report() + * @see zb_get_type_from_attr_report() + * @see zb_set_type_to_attr_report() + * @see zb_get_value_from_attr_report() + * @see zb_set_value_to_attr_report() + */ +int zb_set_type_to_attr_report( + attr_report_h handle, + unsigned char type); + +/** + * @brief Gets attribute data from reporting attribute + * @details The attribute data field is variable in length and shall contain the actual + * value of the attribute being reported. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] value attribute value + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_NO_DATA No data available + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_event_get_attr_report() + * @see zb_create_attr_report() + * @see zb_destroy_attr_report() + * @see zb_get_id_from_attr_report() + * @see zb_set_id_to_attr_report() + * @see zb_get_type_from_attr_report() + * @see zb_set_type_to_attr_report() + * @see zb_get_value_from_attr_report() + * @see zb_set_value_to_attr_report() + */ +int zb_get_value_from_attr_report( + attr_report_h handle, + zb_value_h value); + +/** + * @brief Sets attribute data to reporting attribute + * @details The attribute data field is variable in length and shall contain the actual + * value of the attribute being reported. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] value attribute value + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_NO_DATA No data available + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_event_get_attr_report() + * @see zb_create_attr_report() + * @see zb_destroy_attr_report() + * @see zb_get_id_from_attr_report() + * @see zb_set_id_to_attr_report() + * @see zb_get_type_from_attr_report() + * @see zb_set_type_to_attr_report() + * @see zb_get_value_from_attr_report() + * @see zb_set_value_to_attr_report() + */ +int zb_set_value_to_attr_report( + attr_report_h handle, + zb_value_h value); + +/** + * @brief Creates extended attribute information + * @details Allocate memory for extended attribute information + * + * @since_tizen 4.0 + * + * @param[in] handle handle of extended attribute information + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_zcl_global_discover_attr_extended_rsp() + * @see zb_create_extended_attr_report() + * @see zb_destroy_extended_attr_report() + * @see zb_get_id_from_extended_attr_info() + * @see zb_set_id_to_extended_attr_info() + * @see zb_get_type_from_extended_attr_info() + * @see zb_set_type_to_extended_attr_info() + * @see zb_get_acl_from_extended_attr_info() + * @see zb_set_acl_to_extended_attr_info() + */ +int zb_create_extended_attr_info( + extended_attr_info_h *handle); + +/** + * @brief Destroys extended attribute information + * @details This destroys extended attribute information + * + * @since_tizen 4.0 + * + * @param[in] handle handle of extended attribute information + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_discover_attr_extended_rsp() + * @see zb_create_extended_attr_report() + * @see zb_destroy_extended_attr_report() + * @see zb_get_id_from_extended_attr_info() + * @see zb_set_id_to_extended_attr_info() + * @see zb_get_type_from_extended_attr_info() + * @see zb_set_type_to_extended_attr_info() + * @see zb_get_acl_from_extended_attr_info() + * @see zb_set_acl_to_extended_attr_info() + */ +void zb_destroy_extended_attr_info( + extended_attr_info_h handle); + +/** + * @brief Gets attribute identifier from extended attribute information + * @details The attribute identifier field shall contain the identifier of a discovered + * attribute. \n + * Attributes shall be included in ascending order, starting with the lowest attribute + * identifier that is greater than or equal to the start attribute identifier field of the + * received discover attributes command. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_discover_attr_extended_rsp() + * @see zb_create_extended_attr_report() + * @see zb_destroy_extended_attr_report() + * @see zb_get_id_from_extended_attr_info() + * @see zb_set_id_to_extended_attr_info() + * @see zb_get_type_from_extended_attr_info() + * @see zb_set_type_to_extended_attr_info() + * @see zb_get_acl_from_extended_attr_info() + * @see zb_set_acl_to_extended_attr_info() + */ +int zb_get_id_from_extended_attr_info( + extended_attr_info_h handle, + unsigned short *id); + +/** + * @brief Sets attribute identifier to extended attribute information + * @details The attribute identifier field shall contain the identifier of a discovered + * attribute. \n + * Attributes shall be included in ascending order, starting with the lowest attribute + * identifier that is greater than or equal to the start attribute identifier field of the + * received discover attributes command. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] id attribute identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_discover_attr_extended_rsp() + * @see zb_create_extended_attr_report() + * @see zb_destroy_extended_attr_report() + * @see zb_get_id_from_extended_attr_info() + * @see zb_set_id_to_extended_attr_info() + * @see zb_get_type_from_extended_attr_info() + * @see zb_set_type_to_extended_attr_info() + * @see zb_get_acl_from_extended_attr_info() + * @see zb_set_acl_to_extended_attr_info() + */ +int zb_set_id_to_extended_attr_info( + extended_attr_info_h handle, + unsigned short id); + +/** + * @brief Gets attribute identifier type from extended attribute information + * @details The attribute data type field shall contain the data type of the attribute in + * the same attribute report field + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] type attribute data type @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_discover_attr_extended_rsp() + * @see zb_create_extended_attr_report() + * @see zb_destroy_extended_attr_report() + * @see zb_get_id_from_extended_attr_info() + * @see zb_set_id_to_extended_attr_info() + * @see zb_get_type_from_extended_attr_info() + * @see zb_set_type_to_extended_attr_info() + * @see zb_get_acl_from_extended_attr_info() + * @see zb_set_acl_to_extended_attr_info() + */ +int zb_get_type_from_extended_attr_info( + extended_attr_info_h handle, + unsigned char *type); + +/** + * @brief Sets attribute identifier type to extended attribute information + * @details The attribute data type field shall contain the data type of the attribute in + * the same attribute report field + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] type attribute data type @see #zb_zcl_data_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_discover_attr_extended_rsp() + * @see zb_create_extended_attr_report() + * @see zb_destroy_extended_attr_report() + * @see zb_get_id_from_extended_attr_info() + * @see zb_set_id_to_extended_attr_info() + * @see zb_get_type_from_extended_attr_info() + * @see zb_set_type_to_extended_attr_info() + * @see zb_get_acl_from_extended_attr_info() + * @see zb_set_acl_to_extended_attr_info() + */ +int zb_set_type_to_extended_attr_info( + extended_attr_info_h handle, + unsigned char type); + +/** + * @brief Gets access control field from extended attribute information + * @details The attribute access control field shall indicate whether the attribute is + * readable, writable, and/or reportable. This is an 8-bit bitmask field. \n + * The bits are in little endian order (bit 0 is listed first). + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[out] acl ZB_ZCL_WRITABLE : Bit-0., Writable \n + * ZB_ZCL_REPORTABLE Bit-1 : Reportable \n See #zb_zcl_acl_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_discover_attr_extended_rsp() + * @see zb_create_extended_attr_report() + * @see zb_destroy_extended_attr_report() + * @see zb_get_id_from_extended_attr_info() + * @see zb_set_id_to_extended_attr_info() + * @see zb_get_type_from_extended_attr_info() + * @see zb_set_type_to_extended_attr_info() + * @see zb_get_acl_from_extended_attr_info() + * @see zb_set_acl_to_extended_attr_info() + */ +int zb_get_acl_from_extended_attr_info( + extended_attr_info_h handle, + unsigned char *acl); + +/** + * @brief Sets attribute access control field to extended attribute information + * @details The attribute access control field shall indicate whether the attribute is + * readable, writable, and/or reportable. This is an 8-bit bitmask field. \n + * The bits are in little endian order (bit 0 is listed first). + * + * @since_tizen 4.0 + * + * @param[in] handle handle of write attribute status record + * @param[in] acl ZB_ZCL_WRITABLE : Bit-0., Writable \n + * ZB_ZCL_REPORTABLE Bit-1 : Reportable \n See #zb_zcl_acl_type_e + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zcl_global_discover_attr_extended_rsp() + * @see zb_create_extended_attr_report() + * @see zb_destroy_extended_attr_report() + * @see zb_get_id_from_extended_attr_info() + * @see zb_set_id_to_extended_attr_info() + * @see zb_get_type_from_extended_attr_info() + * @see zb_set_type_to_extended_attr_info() + * @see zb_get_acl_from_extended_attr_info() + * @see zb_set_acl_to_extended_attr_info() + */ +int zb_set_acl_to_extended_attr_info( + extended_attr_info_h handle, + unsigned char acl); + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_H__ */ diff --git a/include/zb_zdo.h b/include/zb_zdo.h new file mode 100644 index 0000000..74963d3 --- /dev/null +++ b/include/zb_zdo.h @@ -0,0 +1,2216 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZDO_H__ + +/** + * @file zb_zdo.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE Zigbee Device Object + * + * @brief zigbee provides API for ZDO access. + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_MODULE_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_MODULE_OVERVIEW Overview + * This API set consists of ZDO access API + * + * @{ + */ + +#include +#include +#include +#include +#include +#include + +/** + * @brief Return readabble ZDO error code + * @details Return ZDO error code string + * + * @since_tizen 4.0 + * + * @param[in] id ZDO id + * + * @return pointer of error message id string + * + */ +const char* zb_zdo_get_error_message(int id); + +/** + * @brief Return readabble Zigbee profile id + * @details Return Zigbee profile id + * + * @since_tizen 4.0 + * + * @param[in] profile_id ZigBee profile id + * + * @return pointer of profile id string + * + */ +const char* zb_get_profile_id_string(int profile_id); + +/** + * @brief Return readabble Zigbee device id + * @details Return Zigbee device id + * + * @since_tizen 4.0 + * + * @param[in] device_id ZigBee device id + * + * @return pointer of device id string + * + */ +const char* zb_get_device_id_string(int device_id); + +/** + * @brief Create simple descriptor + * @details Create simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[out] handle handle of simple descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_simple_desc_copy() + * @see zb_simple_desc_destroy() + */ +int zb_simple_desc_create( + zb_zdo_simple_desc_h *handle); + +/** + * @brief copy simple descriptor + * @details copy simple descriptor handle to another + * + * @since_tizen 4.0 + * + * @param[in] src handle of source simple descriptor + * @param[out] dst handle of destination simple descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_copy() + * @see zb_simple_desc_destroy() + */ +int zb_simple_desc_copy( + zb_zdo_simple_desc_h src, + zb_zdo_simple_desc_h dst); + +/** + * @brief destroy simple descriptor handle + * @details destroy simple descriptor allocated memory + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_copy() + * @see zb_simple_desc_destroy() + */ +int zb_simple_desc_destroy( + zb_zdo_simple_desc_h handle); + +/** + * @brief get active endpoint number from simple descriptor handle + * @details get active endpoint number from simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[out] ep endpoint number + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_set_ep() + */ +int zb_simple_desc_get_ep( + zb_zdo_simple_desc_h handle, + unsigned char *ep); + +/** + * @brief set active endpoint number to simple descriptor handle + * @details set active endpoint number to simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[in] ep endpoint number + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_get_ep() + */ +int zb_simple_desc_set_ep( + zb_zdo_simple_desc_h handle, + unsigned char ep); + +/** + * @brief get profile id from simple descriptor handle + * @details get profile id from simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[out] profile_id profile id + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_set_profile_id() + */ +int zb_simple_desc_get_profile_id( + zb_zdo_simple_desc_h handle, + unsigned short *profile_id); + +/** + * @brief set profile id to simple descriptor handle + * @details set profile id to simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[in] profile_id profile id + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_get_device_id() + */ +int zb_simple_desc_set_profile_id( + zb_zdo_simple_desc_h handle, + unsigned short profile_id); + +/** + * @brief set device id from simple descriptor handle + * @details set device id from simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[out] device_id 16-bit device identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_set_device_id() + */ +int zb_simple_desc_get_device_id( + zb_zdo_simple_desc_h handle, + unsigned short *device_id); + +/** + * @brief set device id to simple descriptor handle + * @details set device id to simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[in] device_id 16-bit device identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_get_device_ver() + */ +int zb_simple_desc_set_device_id( + zb_zdo_simple_desc_h handle, + unsigned short device_id); + +/** + * @brief get device version from simple descriptor handle + * @details get device version from simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[out] device_ver device version + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_set_device_ver() + */ +int zb_simple_desc_get_device_ver( + zb_zdo_simple_desc_h handle, + unsigned short *device_ver); + +/** + * @brief set device version to simple descriptor handle + * @details set device version to simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[in] device_ver device version + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_set_device_ver() + */ +int zb_simple_desc_set_device_ver( + zb_zdo_simple_desc_h handle, + unsigned short device_ver); + +/** + * @brief get number of input clusters from simple descriptor handle + * @details get number of input clusters from simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[out] num_of_in_clusters number of input clusters + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_set_num_of_in_clusters() + */ +int zb_simple_desc_get_num_of_in_clusters( + zb_zdo_simple_desc_h handle, + unsigned char *num_of_in_clusters); + +/** + * @brief get number of input clusters to simple descriptor handle + * @details get number of input clusters to simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[in] num_of_in_clusters number of input clusters + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_get_num_of_in_clusters() + */ +int zb_simple_desc_set_num_of_in_clusters( + zb_zdo_simple_desc_h handle, + unsigned char num_of_in_clusters); + +/** + * @brief get number of output clusters from simple descriptor handle + * @details get number of output clusters from simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[out] num_of_out_clusters number of output clusters + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_set_num_of_out_clusters() + */ +int zb_simple_desc_get_num_of_out_clusters( + zb_zdo_simple_desc_h handle, + unsigned char *num_of_out_clusters); + +/** + * @brief set number of output clusters to simple descriptor handle + * @details set number of output clusters to simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[in] num_of_out_clusters number of output clusters + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_get_num_of_out_clusters() + */ +int zb_simple_desc_set_num_of_out_clusters( + zb_zdo_simple_desc_h handle, + unsigned char num_of_out_clusters); + +/** + * @brief get input cluster list from simple descriptor handle + * @details get input cluster list from simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[out] in_clusters input clusters + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_set_in_clusters() + */ +int zb_simple_desc_get_in_clusters( + zb_zdo_simple_desc_h handle, + unsigned short **in_clusters); + +/** + * @brief set input cluster list to simple descriptor handle + * @details set input cluster list to simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[in] in_clusters input clusters + * @param[in] num number of input clusters + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_get_in_clusters() + */ +int zb_simple_desc_set_in_clusters( + zb_zdo_simple_desc_h handle, + unsigned short *in_clusters, + int num); + +/** + * @brief get output cluster list from simple descriptor handle + * @details get output cluster list from simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[out] out_clusters output clusters + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_get_in_clusters() + */ +int zb_simple_desc_get_out_clusters( + zb_zdo_simple_desc_h handle, + unsigned short **out_clusters); + +/** + * @brief set output cluster list to simple descriptor handle + * @details set output cluster list to simple descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of simple descriptor + * @param[in] out_clusters output clusters + * @param[in] num number of output clusters + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_simple_desc_get_in_clusters() + */ +int zb_simple_desc_set_out_clusters( + zb_zdo_simple_desc_h handle, + unsigned short *out_clusters, + int num); + +/** + * @brief Create node power descriptor + * @details Create node power descriptor handle + * + * @since_tizen 4.0 + * + * @param[out] handle handle of node power descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_node_power_desc_copy() + * @see zb_node_power_desc_destroy() + */ +int zb_node_power_desc_create( + zb_zdo_node_power_descriptor_h *handle); + +/** + * @brief copy node power descriptor + * @details copy node power descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] src handle of source node power descriptor + * @param[out] dst handle of destination node power descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_power_desc_create() + * @see zb_node_power_desc_destroy() + */ +int zb_node_power_desc_copy( + zb_zdo_node_power_descriptor_h src, + zb_zdo_node_power_descriptor_h dst); + +/** + * @brief destroy node power descriptor + * @details destroy node power descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_power_desc_copy() + * @see zb_node_power_desc_destroy() + */ +int zb_node_power_desc_destroy( + zb_zdo_node_power_descriptor_h handle); + +/** + * @brief get current power mode from node power descriptor + * @details The current power mode field of the node power descriptor is four bits in length + * and specifies the current sleep/power-saving mode of the node. \n\n The current power + * mode field shall be set to one of the non-reserved values + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * @param[out] current_power_mode 0b0000 : Receiver synchronized with the receiver on when + * idle sub-field of the node descriptor \n + * 0b0001 : Receiver comes on periodically as defined by the + * node power descriptor \n + * 0b0010 : Receiver comes on when stimulated, e.g. by a + * user pressing a button + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_power_desc_set_current_power_mode() + */ +int zb_node_power_desc_get_current_power_mode( + zb_zdo_node_power_descriptor_h handle, + unsigned char* current_power_mode); + +/** + * @brief set current power mode from node power descriptor + * @details The current power mode field of the node power descriptor is four bits in length + * and specifies the current sleep/power-saving mode of the node. \n\n The current power + * mode field shall be set to one of the non-reserved values + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * @param[in] current_power_mode 0b0000 : Receiver synchronized with the receiver on when + * idle sub-field of the node descriptor \n + * 0b0001 : Receiver comes on periodically as defined by the + * node power descriptor \n + * 0b0010 : Receiver comes on when stimulated, e.g. by a + * user pressing a button + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_power_desc_get_current_power_mode() + */ +int zb_node_power_desc_set_current_power_mode( + zb_zdo_node_power_descriptor_h handle, + unsigned char current_power_mode); + +/** + * @brief get available power mode from node power descriptor + * @details The available power sources field of the node power descriptor is four bits in + * length and specifies the power sources available on this node. \n\n For each power + * source supported on this node, the corresponding bit of the available power sources + * field, shall be set to 1. All other bits shall be set to 0. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * @param[out] available_power_sources 0b0001 : Constant (mains) power \n + * 0b0010 : Rechargeable battery \n + * 0b0100 : Disposable battery \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_power_desc_set_available_power_sources() + */ +int zb_node_power_desc_get_available_power_sources( + zb_zdo_node_power_descriptor_h handle, + unsigned char* available_power_sources); + +/** + * @brief set available power mode from node power descriptor + * @details The available power sources field of the node power descriptor is four bits in + * length and specifies the power sources available on this node. \n\n For each power + * source supported on this node, the corresponding bit of the available power sources + * field, shall be set to 1. All other bits shall be set to 0. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * @param[in] available_power_sources 0b0001 : Constant (mains) power \n + * 0b0010 : Rechargeable battery \n + * 0b0100 : Disposable battery \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_power_desc_get_available_power_sources() + */ +int zb_node_power_desc_set_available_power_sources( + zb_zdo_node_power_descriptor_h handle, + unsigned char available_power_sources); + +/** + * @brief get current power source from node power descriptor + * @details The current power source field of the node power descriptor is four bits in + * length and specifies the current power source being utilized by the node. \n]n + * For the current power source selected, the corresponding bit of the current power \n\n + * source field, shall be set to 1. All other bits shall be set to 0. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * @param[in] current_power_source 0b0001 : Constant (mains) power \n + * 0b0010 : Rechargeable battery \n + * 0b0100 : Disposable battery \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_power_desc_set_current_power_source() + */ +int zb_node_power_desc_get_current_power_source( + zb_zdo_node_power_descriptor_h handle, + unsigned char* current_power_source); + +/** + * @brief set available power mode from node power descriptor + * @details The current power source field of the node power descriptor is four bits in + * length and specifies the current power source being utilized by the node. \n]n + * For the current power source selected, the corresponding bit of the current power \n\n + * source field, shall be set to 1. All other bits shall be set to 0. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * @param[in] current_power_source 0b0001 : Constant (mains) power \n + * 0b0010 : Rechargeable battery \n + * 0b0100 : Disposable battery \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_power_desc_get_current_power_source() + */ +int zb_node_power_desc_set_current_power_source( + zb_zdo_node_power_descriptor_h handle, + unsigned char current_power_source); + +/** + * @brief get current power source level from node power descriptor + * @details The current power source level field of the node power descriptor is four bits + * in length and specifies the level of charge of the power source. \n\n The current power + * source level field shall be set to one of the non-reserved values + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * @param[in] current_power_source_level 0b0000 : Citical \n + * 0b0100 : 33% \n + * 0b1000 : 66% \n + * 0b1100 : 100% \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_power_desc_set_current_power_source_level() + */ +int zb_node_power_desc_get_current_power_source_level( + zb_zdo_node_power_descriptor_h handle, + unsigned char* current_power_source_level); + +/** + * @brief set current power source level from node power descriptor + * @details The current power source level field of the node power descriptor is four bits + * in length and specifies the level of charge of the power source. \n\n The current power + * source level field shall be set to one of the non-reserved values + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node power descriptor + * @param[in] current_power_source_level 0b0000 : Critical \n + * 0b0100 : 33% \n + * 0b1000 : 66% \n + * 0b1100 : 100% \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_power_desc_get_current_power_source_level() + */ +int zb_node_power_desc_set_current_power_source_level( + zb_zdo_node_power_descriptor_h handle, + unsigned char current_power_source_level); + +/** + * @brief Create node descriptor + * @details Create node descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * + * @see zb_node_desc_copy() + * @see zb_node_desc_destroy() + */ +int zb_node_desc_create( + zb_zdo_node_descriptor_h *handle); + +/** + * @brief copy node descriptor + * @details copy node descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] src handle of source node descriptor + * @param[in] dst handle of destination node descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_create() + * @see zb_node_desc_destroy() + */ +int zb_node_desc_copy( + zb_zdo_node_descriptor_h src, + zb_zdo_node_descriptor_h dst); + +/** + * @brief destroy node descriptor + * @details destroy node descriptor handle + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_create() + * @see zb_node_desc_copy() + */ +int zb_node_desc_destroy( + zb_zdo_node_descriptor_h handle); + +/** + * @brief get logical type from node descriptor + * @details The logical type field of the node descriptor is three bits in length and + * specifies the device type of the ZigBee node. \n\n The logical type field shall be set + * to one of the non-reserved values. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] logical_type 0b000 : ZigBee coordinator \n + * 0b001 : Zigbee router \n + * 0b010 : Zigee end device \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_logical_type() + */ +int zb_node_desc_get_logical_type( + zb_zdo_node_descriptor_h handle, + unsigned char* logical_type); + +/** + * @brief set logical type from to descriptor + * @details The logical type field of the node descriptor is three bits in length and + * specifies the device type of the ZigBee node. \n\n The logical type field shall be set + * to one of the non-reserved values. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] logical_type 0b000 : ZigBee coordinator \n + * 0b001 : ZigBee router \n + * 0b010 : ZigBee end device \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_logical_type() + */ +int zb_node_desc_set_logical_type( + zb_zdo_node_descriptor_h handle, + unsigned char logical_type); + +/** + * @brief get complex descriptor available from node descriptor + * @details The complex descriptor available field of the node descriptor is one bit in + * length and specifies whether a complex descriptor is available on this device. \n\n + * If this field is set to 1, a complex descriptor is available. \n\n + * If this field is set to 0, a complex descriptor is not available. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] complex_desciptor_available 1 : a complex descriptor is available \n + * 0 : a complex descriptor is not available \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_complex_descriptor_available() + */ +int zb_node_desc_get_complex_desciptor_available( + zb_zdo_node_descriptor_h handle, + unsigned char* complex_desciptor_available); + +/** + * @brief set complex descriptor available to node descriptor + * @details The complex descriptor available field of the node descriptor is one bit in + * length and specifies whether a complex descriptor is available on this device. \n\n + * If this field is set to 1, a complex descriptor is available. \n\n + * If this field is set to 0, a complex descriptor is not available. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] complex_desciptor_available 1 : a complex descriptor is available \n + * 0 : a complex descriptor is not available \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_complex_desciptor_available() + */ +int zb_node_desc_set_complex_descriptor_available( + zb_zdo_node_descriptor_h handle, + unsigned char complex_desciptor_available); + +/** + * @brief get user descriptor available from node descriptor + * @details The user descriptor available field of the node descriptor is one bit in + * length and specifies whether a user descriptor is available on this device. \n\n + * If this field is set to 1, a user descriptor is available. + * If this field is set to 0, a user descriptor is not available. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] user_descriptor_available 1 : a user descriptor is available \n + * 0 : a user descriptor is not available \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_user_descriptor_available() + */ +int zb_node_desc_get_user_descriptor_available( + zb_zdo_node_descriptor_h handle, + unsigned char* user_descriptor_available); + +/** + * @brief set user descriptor available to node descriptor + * @details The user descriptor available field of the node descriptor is one bit in + * length and specifies whether a user descriptor is available on this device. \n\n + * If this field is set to 1, a user descriptor is available. + * If this field is set to 0, a user descriptor is not available. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] user_descriptor_available 1 : a user descriptor is available \n + * 0 : a user descriptor is not available \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_user_descriptor_available() + */ +int zb_node_desc_set_user_descriptor_available( + zb_zdo_node_descriptor_h handle, + unsigned char user_descriptor_available); + +/** + * @brief get APS flags available from node descriptor + * @details The APS flags field of the node descriptor is three bits in length and + * specifies the application support sub-layer capabilities of the node. \n\n + * This field is currently not supported and shall be set to zero. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] aps_flags 0 : APS flags \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_aps_flags() + */ +int zb_node_desc_get_aps_flags( + zb_zdo_node_descriptor_h handle, + unsigned char* aps_flags); +/** + * @brief set APS flags available to node descriptor + * @details The APS flags field of the node descriptor is three bits in length and + * specifies the application support sub-layer capabilities of the node. \n\n + * This field is currently not supported and shall be set to zero. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] aps_flags 0 : APS flags \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_aps_flags() + */ +int zb_node_desc_set_aps_flags( + zb_zdo_node_descriptor_h handle, + unsigned char aps_flags); + +/** + * @brief get frequency band from node descriptor + * @details The frequency band field of the node descriptor is five bits in length and + * specifies the frequency bands that are supported by the underlying IEEE 802.15.4 radio + * utilized by the node. \n\n For each frequency band supported by the underlying IEEE + * 802.15.4 radio, the corresponding bit of the frequency band field. \n\n + * shall be set to 1. All other bits shall be set to 0. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] frequency_band 0b00001 : 868-868,6MHz \n + * 0b00010 : Reserved \n + * 0b00100 : 902-928MHz \n + * 0b01000 : 2400-2483.5MHz + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_frequency_band() + */ +int zb_node_desc_get_frequency_band( + zb_zdo_node_descriptor_h handle, + unsigned char* frequency_band); + +/** + * @brief set frequency band to node descriptor + * @details The frequency band field of the node descriptor is five bits in length and + * specifies the frequency bands that are supported by the underlying IEEE 802.15.4 radio + * utilized by the node. \n\n For each frequency band supported by the underlying IEEE + * 802.15.4 radio, the corresponding bit of the frequency band field. \n\n + * shall be set to 1. All other bits shall be set to 0. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] frequency_band 0b00001 : 868-868,6MHz \n + * 0b00010 : Reserved \n + * 0b00100 : 902-928MHz \n + * 0b01000 : 2400-2483.5MHz + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_frequency_band() + */ +int zb_node_desc_set_frequency_band( + zb_zdo_node_descriptor_h handle, + unsigned char frequency_band); + +/** + * @brief get MAC capability from node descriptor + * @details The MAC capability flags field is eight bits in length and specifies the node + * capabilities, as required by the IEEE 802.15.4-2003 MAC sub-layer. \n\n The + * MAC capability flags field shall be formatted as illustrated in below table. \n\n + * + * The alternate PAN coordinator sub-field is one bit in length and shall be set to 1 if + * this node is capable of becoming a PAN coordinator. Otherwise, the alternative + * PAN coordinator sub-field shall be set to 0. \n\n + * + * The device type sub-field is one bit in length and shall be set to 1 if this node is a + * full function device (FFD). Otherwise, the device type sub-field shall be set to 0, + * indicating a reduced function device (RFD). \n\n + * + * The power source sub-field is one bit in length and shall be set to 1 if the current + * power source is mains power. Otherwise, the power source sub-field shall be set to + * 0. This information is derived from the node current power source field of the + * node power descriptor.\n\n + * + * The receiver on when idle sub-field is one bit in length and shall be set to 1 if the + * device does not disable its receiver to conserve power during idle periods. + * Otherwise, the receiver on when idle sub-field shall be set to 0 \n\n + * + * The security capability sub-field is one bit in length and shall be set to 1 if the + * device is capable of sending and receiving frames secured using the security suite + * specified in [B1]. Otherwise, the security capability sub-field shall be set to 0. + * The allocate address sub-field is one bit in length and shall be set to 0 or 1. \n\n + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] mac_capability_flags Bit 0 : Alternative PAN coordinator \n + * Bit 1 : Device Type \n + * Bit 2 : Power source \n + * Bit 3 : Receiver on when idle \n + * Bit 4-5 : Reserved \n + * Bit 6 : Security capability \n + * Bit 7 : Allocated address \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_mac_capability_flags() + */ +int zb_node_desc_get_mac_capability_flags( + zb_zdo_node_descriptor_h handle, + unsigned char* mac_capability_flags); + +/** + * @brief set MAC capability to node descriptor + * @details The MAC capability flags field is eight bits in length and specifies the node + * capabilities, as required by the IEEE 802.15.4-2003 MAC sub-layer. \n\n The + * MAC capability flags field shall be formatted as illustrated in below table.\n\n + * + * The alternate PAN coordinator sub-field is one bit in length and shall be set to 1 if + * this node is capable of becoming a PAN coordinator. Otherwise, the alternative + * PAN coordinator sub-field shall be set to 0. \n\n + * + * The device type sub-field is one bit in length and shall be set to 1 if this node is a + * full function device (FFD). Otherwise, the device type sub-field shall be set to 0, + * indicating a reduced function device (RFD). \n\n + * + * The power source sub-field is one bit in length and shall be set to 1 if the current + * power source is mains power. Otherwise, the power source sub-field shall be set to + * 0. This information is derived from the node current power source field of the + * node power descriptor.\n\n + * + * The receiver on when idle sub-field is one bit in length and shall be set to 1 if the + * device does not disable its receiver to conserve power during idle periods. + * Otherwise, the receiver on when idle sub-field shall be set to 0 \n\n + * + * The security capability sub-field is one bit in length and shall be set to 1 if the + * device is capable of sending and receiving frames secured using the security suite + * specified in [B1]. Otherwise, the security capability sub-field shall be set to 0. + * The allocate address sub-field is one bit in length and shall be set to 0 or 1. \n\n + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] mac_capability_flags Bit 0 : Alternative PAN coordinator \n + * Bit 1 : Device Type \n + * Bit 2 : Power source \n + * Bit 3 : Receiver on when idle \n + * Bit 4-5 : Reserved \n + * Bit 6 : Security capability \n + * Bit 7 : Allocated address \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_get_mac_capability_flags() + */ +int zb_node_desc_set_mac_capability_flags( + zb_zdo_node_descriptor_h handle, + unsigned char mac_capability_flags); + +/** + * @brief get manufacturer code from node descriptor + * @details The manufacturer code field of the node descriptor is sixteen bits in length + * and specifies a manufacturer code that is allocated by the ZigBee Alliance, relating + * the manufacturer to the device. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] manufacturer_code manufacturer code + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_manufacturer_code() + */ +int zb_node_desc_get_manufacturer_code( + zb_zdo_node_descriptor_h handle, + unsigned short* manufacturer_code); + +/** + * @brief set manufacturer code to node descriptor + * @details The manufacturer code field of the node descriptor is sixteen bits in length + * and specifies a manufacturer code that is allocated by the ZigBee Alliance, relating + * the manufacturer to the device. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] manufacturer_code manufacturer code + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_get_frequency_band() + */ +int zb_node_desc_set_manufacturer_code( + zb_zdo_node_descriptor_h handle, + unsigned short manufacturer_code); + +/** + * @brief get maximum buffer size from node descriptor + * @details The maximum buffer size field of the node descriptor is eight bits in length, + * with a valid range of 0x00-0x7f. \n\n This field specifies the maximum size, in octets, + * of the network sub-layer data unit (NSDU) for this node. This is the maximum size of + * data or commands passed to or from the application by the application support + * sub-layer, before any fragmentation or re-assembly. \n\n + * This field can be used as a high-level indication for network management. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] maximum_buffer_size 0x00~0x7f + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_maximum_buffer_size() + */ +int zb_node_desc_get_maximum_buffer_size( + zb_zdo_node_descriptor_h handle, + unsigned char* maximum_buffer_size); + +/** + * @brief set maximum buffer size to node descriptor + * @details The maximum buffer size field of the node descriptor is eight bits in length, + * with a valid range of 0x00-0x7f. \n\n This field specifies the maximum size, in octets, + * of the network sub-layer data unit (NSDU) for this node. This is the maximum size of + * data or commands passed to or from the application by the application support + * sub-layer, before any fragmentation or re-assembly. \n\n + * This field can be used as a high-level indication for network management. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] maximum_buffer_size 0x00~0x7f + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_maximum_buffer_size() + */ +int zb_node_desc_set_maximum_buffer_size( + zb_zdo_node_descriptor_h handle, + unsigned char maximum_buffer_size); + +/** + * @brief get maximum incoming transfer size from node descriptor + * @details The maximum transfer size field of the node descriptor is sixteen bits in + * length, with a valid range of 0x0000-0x7fff. \n\n This field specifies the maximum + * size, in octets, of the application sub-layer data unit (ASDU) that can be transferred + * to this node in one single message transfer. \n\n This value can exceed the value of + * the node maximum buffer size field through the use of fragmentation. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] maximum_incoming_transfer_size 0x0000~0x7fff + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_maximum_buffer_size() + */ +int zb_node_desc_get_maximum_incoming_transfer_size( + zb_zdo_node_descriptor_h handle, + unsigned short* maximum_incoming_transfer_size); + +/** + * @brief set maximum incoming transfer size to node descriptor + * @details The maximum transfer size field of the node descriptor is sixteen bits in + * length, with a valid range of 0x0000-0x7fff. \n\n This field specifies the maximum + * size, in octets, of the application sub-layer data unit (ASDU) that can be transferred + * to this node in one single message transfer. \n\n This value can exceed the value of + * the node maximum buffer size field through the use of fragmentation. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] maximum_incoming_transfer_size 0x0000~0x7fff + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_maximum_buffer_size() + */ +int zb_node_desc_set_maximum_incoming_transfer_size( + zb_zdo_node_descriptor_h handle, + unsigned short maximum_incoming_transfer_size); + +/** + * @brief get server mask from node descriptor + * @details The server mask field of the node descriptor is sixteen bits in length, + * with bit settings signifying the system server capabilities of this node. \n\n + * It is used to facilitate discovery of particular system servers by other nodes on the + * system. \n\n The bit settings are defined in below table. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] server_mask Bit 0 : Primary Trust Center \n + * Bit 1 : Backup Trust Center \n + * Bit 2 : Primary Binding Table Cache \n + * Bit 3 : Backup Binding Table Cache \n + * Bit 4 : Primary Discovery Cache \n + * Bit 5 : Backup Discovery Cache \n + * Bit 6 : Network Manager \n + * Bit 7~15 : Reserved + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_server_mask() + */ +int zb_node_desc_get_server_mask( + zb_zdo_node_descriptor_h handle, + unsigned short* server_mask); + +/** + * @brief set server mask to node descriptor + * @details The server mask field of the node descriptor is sixteen bits in length, + * with bit settings signifying the system server capabilities of this node. \n\n + * It is used to facilitate discovery of particular system servers by other nodes on the + * system. \n\n The bit settings are defined in below table. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] server_mask Bit 0 : Primary Trust Center \n + * Bit 1 : Backup Trust Center \n + * Bit 2 : Primary Binding Table Cache \n + * Bit 3 : Backup Binding Table Cache \n + * Bit 4 : Primary Discovery Cache \n + * Bit 5 : Backup Discovery Cache \n + * Bit 6 : Network Manager \n + * Bit 7~15 : Reserved + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_server_mask() + */ +int zb_node_desc_set_server_mask( + zb_zdo_node_descriptor_h handle, + unsigned short server_mask); + +/** + * @brief get maximum outgoing transfer size from node descriptor + * @details The maximum transfer size field of the node descriptor is sixteen bits in, + * length with a valid range of 0x0000-0x7fff. \n\n This field specifies the maximum size, + * in octets, of the application sub-layer data unit (ASDU) that can be transferred from + * this node in one single message transfer. \n\n This value can exceed the value of the + * node maximum buffer size field through the use of fragmentation. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] maximum_outgoing_transfer_size 0x0000~0x7ffff + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_server_mask() + */ +int zb_node_desc_get_maximum_outgoing_transfer_size( + zb_zdo_node_descriptor_h handle, + unsigned short* maximum_outgoing_transfer_size); + +/** + * @brief set maximum outgoing transfer size to node descriptor + * @details The maximum transfer size field of the node descriptor is sixteen bits in, + * length with a valid range of 0x0000-0x7fff. \n\n This field specifies the maximum size, + * in octets, of the application sub-layer data unit (ASDU) that can be transferred from + * this node in one single message transfer. \n\n This value can exceed the value of the + * node maximum buffer size field through the use of fragmentation. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] maximum_outgoing_transfer_size 0x0000~0x7ffff + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_set_server_mask() + */ +int zb_node_desc_set_maximum_outgoing_transfer_size( + zb_zdo_node_descriptor_h handle, + unsigned short maximum_outgoing_transfer_size); + +/** + * @brief get descriptor capability from node descriptor + * @details The descriptor capability field of the node descriptor is eight bits in length + * , with bit settings signifying the descriptor capabilities of this node. \n\n + * It is used to facilitate discovery of particular features of the descriptor fields by + * other nodes on the system. The bit settings are defined in Table. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] descriptor_capability_field Bit 0 : Extended Active Endpoint List Available \n + * Bit 1 : Extended Simple Descriptor List Available \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_node_desc_set_descriptor_capability_field() + */ +int zb_node_desc_get_descriptor_capability_field( + zb_zdo_node_descriptor_h handle, + unsigned short* descriptor_capability_field); + +/** + * @brief set descriptor capability to node descriptor + * @details The descriptor capability field of the node descriptor is eight bits in length + * , with bit settings signifying the descriptor capabilities of this node. \n\n + * It is used to facilitate discovery of particular features of the descriptor fields by + * other nodes on the system. The bit settings are defined in Table. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[in] descriptor_capability_field Bit 0 : Extended Active Endpoint List Available \n + * Bit 1 : Extended Simple Descriptor List Available \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * + * @see zb_node_desc_get_descriptor_capability_field() + */ +int zb_node_desc_set_descriptor_capability_field( + zb_zdo_node_descriptor_h handle, + unsigned short descriptor_capability_field); + +/** + * @brief get extended pan id from network list record + * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee + * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n + * Therefore this function can help parsing parameter in network_list_record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] extended_pan_id The 64-bit extended PAN identifier of the discovered + * network. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_nwk_disc_rsp() + */ +int zb_network_list_record_get_extended_pan_id( + zb_zdo_network_list_record_h handle, + ieee_addr extended_pan_id); + +/** + * @brief get logical channel number from network list record + * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee + * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has multiple network_list_record. + * \n\n Therefore this function can help parsing parameter in network_list_record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] logical_channel The current logical channel occupied by the network. \n + * Selected from the available logical channels supported by + * the PHY. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_nwk_disc_rsp() + */ +int zb_network_list_record_get_logical_channel( + zb_zdo_network_list_record_h handle, + unsigned char* logical_channel); + +/** + * @brief get ZigBee version from network list record + * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee + * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n + * Therefore this function can help parsing parameter in network_list_record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] zigbee_version 0x0~0xf : The version of the ZigBee protocol in use + * in the discovered network. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_nwk_disc_rsp() + */ +int zb_network_list_record_get_zigbee_version( + zb_zdo_network_list_record_h handle, + unsigned char* zigbee_version); + +/** + * @brief get stack profile from network list record + * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee + * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n + * Therefore this function can help parsing parameter in network_list_record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] stack_profile 0x0~0xf : A ZigBee stack profile identifier indicating + * the stack profile in use in the discovered network. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_nwk_disc_rsp() + */ +int zb_network_list_record_get_stack_profile( + zb_zdo_network_list_record_h handle, + unsigned char* stack_profile); + +/** + * @brief get beacon order from network list record + * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee + * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n + * Therefore this function can help parsing parameter in network_list_record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] beacon_order 0x0~0xf : This specifies how often the MAC sub-layer + * beacon is to be transmitted by a given device on the network. \n\n For a discussion of + * MAC sub-layer beacon order + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_nwk_disc_rsp() + */ +int zb_network_list_record_get_beacon_order( + zb_zdo_network_list_record_h handle, + unsigned char* beacon_order); + +/** + * @brief get superframe order from network list record + * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee + * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n + * Therefore this function can help parsing parameter in network_list_record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] superframe_order 0x0~0xf : For beacon-oriented networks, i.e., beacon + * order < 15, this specifies the length of the active period of the superframe. \n\n + * For a discussion of MAC sub-layer superframe order. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_nwk_disc_rsp() + */ +int zb_network_list_record_get_superframe_order( + zb_zdo_network_list_record_h handle, + unsigned char* superframe_order); + +/** + * @brief get permit joining from network list record + * @details When received zb_zdo_mgmt_nwk_disc_rsp callback (originally, ZigBee + * called Mgmt_NWK_Disc_rsp (ClusterID = 0x8030) ), it has a network_list_record. \n\n + * Therefore this function can help parsing parameter in network_list_record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] permit_joining 0 or 1 : A value of TRUE indicates that at least one + * ZigBee router on the network currently permits joining, i.e., its NWK has been + * issued an NLME-PERMIT-JOINING primitive and the time limit, if given, has + * not yet expired. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_nwk_disc_rsp() + */ +int zb_network_list_record_get_permit_joining( + zb_zdo_network_list_record_h handle, + unsigned char* permit_joining); + +/** + * @brief get destination address from routing table record + * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp + * command (ClusterID=0x8032) ), it has a routing table record. \n\n + * Therefore this function can help parsing parameter in routing table records. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] dst_addr The destination address for the binding entry + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_rtg_rsp() + * @see zb_routing_table_get_dst_addr() + * @see zb_routing_table_get_dst_status() + * @see zb_routing_table_get_memory_constrained() + * @see zb_routing_table_get_many_to_one() + * @see zb_routing_table_get_route_record_required() + * @see zb_routing_table_get_next_hop_addr() + */ +int zb_routing_table_get_dst_addr(zb_zdo_routing_table_h handle, + nwk_addr* dst_addr); + +/** + * @brief get status bits (3bit) from routing table record + * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp + * command (ClusterID=0x8032) ), it has a routing table record. \n\n + * Therefore this function can help parsing parameter in routing table records. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] status 0x0=ACTIVE. \n + * 0x1=DISCOVERY_UNDERWAY. \n + * 0x2=DISCOVERY_FAILED. \n + * 0x3=INACTIVE. \n + * 0x4=VALIDATION_UNDERWAY \n + * 0x5-0x7=RESERVED. \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_rtg_rsp() + * @see zb_routing_table_get_dst_addr() + * @see zb_routing_table_get_dst_status() + * @see zb_routing_table_get_memory_constrained() + * @see zb_routing_table_get_many_to_one() + * @see zb_routing_table_get_route_record_required() + * @see zb_routing_table_get_next_hop_addr() + */ +int zb_routing_table_get_dst_status(zb_zdo_routing_table_h handle, + unsigned char* status); + +/** + * @brief get memory constrained (1bit) from routing table record + * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp + * command (ClusterID=0x8032) ), it has a routing table record. \n\n + * Therefore this function can help parsing parameter in routing table records. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] memory_constrained A flag indicating whether the device is a memory + * constrained concentrator. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_rtg_rsp() + * @see zb_routing_table_get_dst_addr() + * @see zb_routing_table_get_dst_status() + * @see zb_routing_table_get_memory_constrained() + * @see zb_routing_table_get_many_to_one() + * @see zb_routing_table_get_route_record_required() + * @see zb_routing_table_get_next_hop_addr() + */ +int zb_routing_table_get_memory_constrained( + zb_zdo_routing_table_h handle, unsigned char* memory_constrained); + +/** + * @brief get many-to-one (1bit) from routing table record + * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp + * command (ClusterID=0x8032) ), it has a routing table record. \n\n + * Therefore this function can help parsing parameter in routing table records. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] many_to_one A flag indicating that the destination is a concentrator that + * issued a many-to-one request. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_rtg_rsp() + * @see zb_routing_table_get_dst_addr() + * @see zb_routing_table_get_dst_status() + * @see zb_routing_table_get_memory_constrained() + * @see zb_routing_table_get_many_to_one() + * @see zb_routing_table_get_route_record_required() + * @see zb_routing_table_get_next_hop_addr() + */ +int zb_routing_table_get_many_to_one(zb_zdo_routing_table_h handle, + unsigned char* many_to_one); + +/** + * @brief get routing record required (1bit) from routing table record + * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp + * command (ClusterID=0x8032) ), it has a routing table record. \n\n + * Therefore this function can help parsing parameter in routing table records. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] route_record_required A flag indicating that a route record command frame + * should be sent to the destination prior to the next + * data packet. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_rtg_rsp() + * @see zb_routing_table_get_dst_addr() + * @see zb_routing_table_get_dst_status() + * @see zb_routing_table_get_memory_constrained() + * @see zb_routing_table_get_many_to_one() + * @see zb_routing_table_get_route_record_required() + * @see zb_routing_table_get_next_hop_addr() + */ +int zb_routing_table_get_route_record_required( + zb_zdo_routing_table_h handle, unsigned char* route_record_required); + +/** + * @brief get next hop address from routing table record + * @details When received zb_zdo_mgmt_rtg_rsp callback (originally, The Mgmt_Rtg_rsp + * command (ClusterID=0x8032) ), it has a routing table record. \n\n + * Therefore this function can help parsing parameter in routing table records. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] next_hop_addr Next-hop address. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_rtg_rsp() + * @see zb_routing_table_get_dst_addr() + * @see zb_routing_table_get_dst_status() + * @see zb_routing_table_get_memory_constrained() + * @see zb_routing_table_get_many_to_one() + * @see zb_routing_table_get_route_record_required() + * @see zb_routing_table_get_next_hop_addr() + */ +int zb_routing_table_get_next_hop_addr( + zb_zdo_routing_table_h handle, nwk_addr* next_hop_addr); + +/** + * @brief get extended pan id from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] extended_pan_id The 64-bit extended PAN id of the neighboring device + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_extended_pan_id( + zb_zdo_neighbor_table_desc_h handle, + ieee_addr extended_pan_id); + +/** + * @brief get IEEE address from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] addr64 64-bit IEEE address that is unique to every device. \n + * If this value is unknown at the time of the request, this field shall be set to + * 0xffffffffffffffff. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_ieee_addr( + zb_zdo_neighbor_table_desc_h handle, + ieee_addr addr64); + +/** + * @brief get network address from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] addr16 16-bit network address that is unique to every device. \n + * If this value is unknown at the time of the request, this field shall be set to + * 0xffffffffffffffff. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_nwk_addr( + zb_zdo_neighbor_table_desc_h handle, + nwk_addr* addr16); + +/** + * @brief get device type from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] device_type The type of the neighbor device: \n + * 0x0 = ZigBee coordinator \n + * 0x1 = ZigBee router \n + * 0x2 = ZigBee end device \n + * 0x3 = Unknown \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_device_type( + zb_zdo_neighbor_table_desc_h handle, + unsigned char* device_type); + +/** + * @brief get RxOnWhenIdle value from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] rx_on_when_idle Indicates if neighbor's receiver is + * enabled during idle portions of the \n + * CAP: \n + * 0x0 = Receiver is off \n + * 0x1 = Receiver is on \n + * 0x2 = unknown + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_rx_on_when_idle( + zb_zdo_neighbor_table_desc_h handle, + unsigned char* rx_on_when_idle); + +/** + * @brief get Relationship value from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] releationship The relationship between the + * neighbor and the current device: \n + * 0x0 = neighbor is the parent \n + * 0x1 = neighbor is a child \n + * 0x2 = neighbor is a sibling \n + * 0x3 = None of the above \n + * 0x4 = previous child + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_relationship( + zb_zdo_neighbor_table_desc_h handle, + unsigned char* releationship); + +/** + * @brief get Permit joining value from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] permit_joining An indication of whether the + * neighbor device is accepting join requests: \n + * 0x0 = neighbor is not accepting join requests \n + * 0x1 = neighbor is accepting join requests \n + * 0x2 = unknown + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_permit_joining( + zb_zdo_neighbor_table_desc_h handle, + unsigned char* permit_joining); + +/** + * @brief get Depth value from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] depth The 0x00~nwkcMaxDepth (See. Zigbee Spec.) \n + * tree depth of the neighbor device. \n + * A value of 0x00 indicates that the device is the ZigBee + * coordinator for the network. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_depth( + zb_zdo_neighbor_table_desc_h handle, + unsigned char* depth); + +/** + * @brief get LQI(Link-Quality Indicator) value from neighbor table list record + * @details When received zb_zdo_mgmt_lqi_rsp callback (originally, ZigBee + * called Mgmt_Lqi_rsp (ClusterID = 0x8031) ), it has multiple neigbor_table_list. \n\n + * Therefore this function can help parsing parameter in neigbor_table_list. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] lqi The estimated link quality for RF transmissions from this device. \n + * See ZigBee specification for discussion of how this is calculated. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_lqi_rsp() + * @see zb_neighbor_table_desc_get_extended_pan_id() + * @see zb_neighbor_table_desc_get_ieee_addr() + * @see zb_neighbor_table_desc_get_nwk_addr() + * @see zb_neighbor_table_desc_get_device_type() + * @see zb_neighbor_table_desc_get_rx_on_when_idle() + * @see zb_neighbor_table_desc_get_relationship() + * @see zb_neighbor_table_desc_get_permit_joining + * @see zb_neighbor_table_desc_get_depth() + * @see zb_neighbor_table_desc_get_lqi() + */ +int zb_neighbor_table_desc_get_lqi( + zb_zdo_neighbor_table_desc_h handle, + unsigned char* lqi); + +/** + * @brief get source MAC address from binding table record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in binding_table structure. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] src_addr The source IEEE address for the binding entry. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_bind_rsp() + */ +int zb_binding_table_get_src_addr( + zb_zdo_binding_table_h handle, + ieee_addr src_addr); + +/** + * @brief get SrcEndpoint from binding table record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in binding_table structure. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] src_ep The source endpoint for the binding entry. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_bind_rsp() + */ +int zb_binding_table_get_src_ep( + zb_zdo_binding_table_h handle, + unsigned char *src_ep); + +/** + * @brief get ClusterId from binding table record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in binding_table structure. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] cluster_id The identifier of the cluster on the source device that is bound + * to the destination device. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_bind_rsp() + */ +int zb_binding_table_get_cluster_id( + zb_zdo_binding_table_h handle, + unsigned short *cluster_id); + +/** + * @brief get DstAddrMode from binding table record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in binding_table structure. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] dst_addr_mode The addressing mode for the destination address. \n\n + * This field can take one of the non-reserved values + * from the following list: \n\n + * 0x00 = reserved \n + * 0x01 = 16-bit group address for DstAddr and DstEndpoint not + * present \n + * 0x02 = reserved \n + * 0x03 = 64-bit extended address for DstAddr and DstEndp present \n + * 0x04 ? 0xff = reserved \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_bind_rsp() + */ +int zb_binding_table_get_dst_addr_mode( + zb_zdo_binding_table_h handle, + unsigned char *dst_addr_mode); + +/** + * @brief get DstAddr from binding table record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in binding_table structure. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] addr16 The destination address for the binding entry. \n + * As specified by the DstAddrMode field. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NO_DATA No network address + * + * @see zb_zdo_mgmt_bind_rsp() + */ +int zb_binding_table_get_dst_addr16( + zb_zdo_binding_table_h handle, + nwk_addr *addr16); + +/** + * @brief get DstAddr from binding table record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in binding_table structure. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] addr64 The destination address for the binding entry. \n + * As specified by the DstAddrMode field. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_NO_DATA No IEEE address + * + * @see zb_zdo_mgmt_bind_rsp() + */ +int zb_binding_table_get_dst_addr64( + zb_zdo_binding_table_h handle, + ieee_addr addr64); + +/** + * @brief get DstEndPoint from binding table record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Bind_rsp (ClusterID = 0x8033) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in binding_table structure. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] dst_ep 0x01~0xff : This field shall be present only if the DstAddrMode + * field has a value of 0x03 and, if present, shall be the destination + * endpoint for the binding entry. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_bind_rsp() + */ +int zb_binding_table_get_dst_ep( + zb_zdo_binding_table_h handle, + unsigned char *dst_ep); + +/** + * @brief get ExtendedAddress from discovery cache record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Cache_rsp (ClusterID = 0x8037) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in discovery cache list record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] addr64 64-bit IEEE Address of the cached device. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_cache_rsp() + */ +int zb_discovery_cache_get_ieee_addr( + zb_zdo_discovery_cache_h handle, + ieee_addr addr64); + +/** + * @brief get NetworkAddress from discovery cache record + * @details When received zb_zdo_mgmt_bind_rsp callback (originally, ZigBee + * called Mgmt_Cache_rsp (ClusterID = 0x8037) ), it has multiple binding table. \n\n + * Therefore this function can help parsing parameter in discovery cache list record. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of node descriptor + * @param[out] addr16 16-bit network Address of the cached device. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see zb_zdo_mgmt_cache_rsp() + */ +int zb_discovery_cache_get_nwk_addr( + zb_zdo_discovery_cache_h handle, + nwk_addr *addr16); + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_H__ */ diff --git a/include/zcl/zb-zcl-alarm-cluster.h b/include/zcl/zb-zcl-alarm-cluster.h deleted file mode 100644 index 431f65a..0000000 --- a/include/zcl/zb-zcl-alarm-cluster.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-alarm-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_MODULE Alarm Cluster - * - * @brief zigbee alarm cluster commands - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 3.57 Generated Command IDs for the Alarms Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Alarm | M | - * | 0x01 | Get alarm response | O | - * +--------------------------------+--------------------------------------+------------+ - */ - -#if 0 /* This will be handled by event-handler */ -/** - * @brief Command description for alarm notification - * @details The alarm command signals an alarm situation on the sending device. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Destination endpoint - * @param[out] status Status code \n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_NOT_FOUND - * @param[out] alarm_code Alarm code (8bit enumeration) - * @ Identifying code for the cause of the alarm, - * @ as given in the specification of the cluster - * @ whose attribute generated this alarm. - * @param[out] cluster_id Custer identifier - */ -typedef void (*zb_zcl_alarm_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char alarm_code, - unsigned short cluster_id); -#endif - -/** - * @brief Command description for get alarm response - * @details The get alarm response command returns the results of a request to retrieve - * information from the alarm log, along with a time stamp indicating when the - * alarm situation was detected. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Destination endpoint - * @param[out] status Status code \n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_NOT_FOUND - * @param[out] alarm_code Alarm code (8bit enumeration) - * @ Identifying code for the cause of the alarm, - * @ as given in the specification of the cluster - * @ whose attribute generated this alarm. - * @param[out] cluster_id Custer identifier - * @param[out] time_stamp Unsigned 32bit time stamp - * @param[out] user_data User data - * - * @see zb_zcl_alarm_get_alarm() - */ -typedef void (*zb_zcl_alarm_get_alarm_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned char alarm_code, - unsigned short cluster_id, - unsigned int time_stamp, - void *user_data); - -/* Table 3.56 Received Command IDs for the Alarms Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Reset Alarm | M | - * | 0x01 | Reset all alarms | M | - * | 0x02 | Get Alarm | O | - * | 0x03 | Reset alarm log | O | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for reset alarm - * @details This command resets a specific alarm. This is needed for some alarms that do - * not reset automatically. If the alarm condition being reset was in fact still active - * then a new notification will be generated and, where implemented, a new record added - * to the alarm log. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Destination endpoint - * @param[in] alarm_code Alarm code (8bit enumeration) - * @ Identifying code for the cause of the alarm, - * @ as given in the specification of the cluster - * @ whose attribute generated this alarm. - * @param[in] cluster_id Custer identifier - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - */ -int zb_zcl_alarm_reset_alarm( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char alarm_code, - unsigned short cluster_id); - -/** - * @brief Command description for reset all alarm - * @details This command resets all alarms. Any alarm conditions that were in fact still - * active will cause a new notification to be generated and, where implemented, a new - * record added to the alarm log. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Destination endpoint - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - */ -int zb_zcl_alarm_reset_all_alarm( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep); - -/** - * @brief Command description for get alarm - * @details This command causes the alarm with the earliest timestamp in the alarm table - * to be reported in a get alarm response command 3.11.2.5.2. This command enables - * the reading of logged alarm conditions from the alarm table. Once an alarm - * condition has been reported the corresponding entry in the table is removed. - * This command does not have a payload. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Destination endpoint - * @param[in] cb Response callback function pointer - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_alarm_get_alarm_rsp() - */ -int zb_zcl_alarm_get_alarm( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - zb_zcl_alarm_get_alarm_rsp cb, - void *user_data); - -/** - * @brief Command description for reset all alarm log - * @details This command causes the alarm table to be cleared, and does not have a payload. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Destination endpoint - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - */ -int zb_zcl_alarm_reset_all_alarm_log( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-attribute-ids.h b/include/zcl/zb-zcl-attribute-ids.h deleted file mode 100644 index 92ef295..0000000 --- a/include/zcl/zb-zcl-attribute-ids.h +++ /dev/null @@ -1,1057 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDS_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDS_H__ - -/** - * @file zb-zcl-attribute-ids.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDENTIFIER_MODULE Cluster Attribute Identifier - * - * @brief zigbee cluster attribute type - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDENTIFIER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/** - * @brief Attribute types for cluster: Basic - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_VERSION_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_APPLICATION_VERSION_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_STACK_VERSION_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_HW_VERSION_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_DATE_CODE_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_POWER_SOURCE_ATTRIBUTE_ID = 0x0007, /**< Ver.: always */ - ZB_ZCL_APPLICATION_PROFILE_VERSION_ATTRIBUTE_ID = 0x0008, /**< Ver.: always */ - ZB_ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_DEVICE_ENABLED_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_ALARM_MASK_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ - ZB_ZCL_SW_BUILD_ID_ATTRIBUTE_ID = 0x4000, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_basic_server_attributes_e; - -/** - * @brief Attribute types for cluster: Power Configuration - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_MAINS_VOLTAGE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_MAINS_FREQUENCY_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_MAINS_ALARM_MASK_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_MAINS_VOLTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_MAINS_VOLTAGE_MAX_THRESHOLD_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_MAINS_VOLTAGE_DWELL_TRIP_POINT_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_BATTERY_VOLTAGE_ATTRIBUTE_ID = 0x0020, /**< Ver.: always */ - ZB_ZCL_BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE_ID = 0x0021, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_MANUFACTURER_ATTRIBUTE_ID = 0x0030, /**< Ver.: always */ - ZB_ZCL_BATTERY_SIZE_ATTRIBUTE_ID = 0x0031, /**< Ver.: always */ - ZB_ZCL_BATTERY_AHR_RATING_ATTRIBUTE_ID = 0x0032, /**< Ver.: always */ - ZB_ZCL_BATTERY_QUANTITY_ATTRIBUTE_ID = 0x0033, /**< Ver.: always */ - ZB_ZCL_BATTERY_RATED_VOLTAGE_ATTRIBUTE_ID = 0x0034, /**< Ver.: always */ - ZB_ZCL_BATTERY_ALARM_MASK_ATTRIBUTE_ID = 0x0035, /**< Ver.: always */ - ZB_ZCL_BATTERY_VOLTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x0036, /**< Ver.: always */ - ZB_ZCL_BATTERY_VOLTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x0037, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_VOLTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x0038, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_VOLTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x0039, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_PERCENTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x003A, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_PERCENTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x003B, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_PERCENTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x003C, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_PERCENTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x003D, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_ALARM_STATE_ATTRIBUTE_ID = 0x003E, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_VOLTAGE_ATTRIBUTE_ID = 0x0040, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_PERCENTAGE_REMAINING_ATTRIBUTE_ID = 0x0041, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_MANUFACTURER_ATTRIBUTE_ID = 0x0050, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_SIZE_ATTRIBUTE_ID = 0x0051, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_AHR_RATING_ATTRIBUTE_ID = 0x0052, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_QUANTITY_ATTRIBUTE_ID = 0x0053, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_RATED_VOLTAGE_ATTRIBUTE_ID = 0x0054, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_ALARM_MASK_ATTRIBUTE_ID = 0x0055, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_VOLTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x0056, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_VOLTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x0057, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_VOLTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x0058, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_VOLTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x0059, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_PERCENTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x005A, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_PERCENTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x005B, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_PERCENTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x005C, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_PERCENTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x005D, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_2_ALARM_STATE_ATTRIBUTE_ID = 0x005E, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_VOLTAGE_ATTRIBUTE_ID = 0x0060, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_PERCENTAGE_REMAINING_ATTRIBUTE_ID = 0x0061, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_MANUFACTURER_ATTRIBUTE_ID = 0x0070, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_SIZE_ATTRIBUTE_ID = 0x0071, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_AHR_RATING_ATTRIBUTE_ID = 0x0072, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_QUANTITY_ATTRIBUTE_ID = 0x0073, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_RATED_VOLTAGE_ATTRIBUTE_ID = 0x0074, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_ALARM_MASK_ATTRIBUTE_ID = 0x0075, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_VOLTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x0076, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_VOLTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x0077, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_VOLTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x0078, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_VOLTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x0079, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_PERCENTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x007A, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_PERCENTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x007B, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_PERCENTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x007C, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_PERCENTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x007D, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_BATTERY_3_ALARM_STATE_ATTRIBUTE_ID = 0x007E, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_power_configuration_server_attributes_e; - -/** - * @brief Attribute types for cluster: Device Temperature Configuration - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_CURRENT_TEMPERATURE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_MIN_TEMP_EXPERIENCED_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_MAX_TEMP_EXPERIENCED_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_OVER_TEMP_TOTAL_DWELL_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_DEVICE_TEMP_ALARM_MASK_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_LOW_TEMP_THRESHOLD_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_HIGH_TEMP_THRESHOLD_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_LOW_TEMP_DWELL_TRIP_POINT_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_HIGH_TEMP_DWELL_TRIP_POINT_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ -} zb_zcl_device_temperature_configuration_server_attributes_e; - -/** - * @brief Attribute types for cluster: Identify - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_COMMISSION_STATE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ -} zb_zcl_identify_server_attributes_e; - -/** - * @brief Attribute types for cluster: Groups - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_GROUP_NAME_SUPPORT_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ -} zb_zcl_group_server_attributes_e; - -/** - * @brief Attribute types for cluster: Scenes - * @details Cluster specification level: zcl-1.0-07-5123-03\n - * - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SCENE_COUNT_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_CURRENT_SCENE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_CURRENT_GROUP_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_SCENE_VALID_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_SCENE_NAME_SUPPORT_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_LAST_CONFIGURED_BY_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ -} zb_zcl_scenes_server_attributes_e; - -/** - * @brief Attribute types for cluster: On/off - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ON_OFF_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_GLOBAL_SCENE_CONTROL_ATTRIBUTE_ID = 0x4000, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ON_TIME_ATTRIBUTE_ID = 0x4001, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_OFF_WAIT_TIME_ATTRIBUTE_ID = 0x4002, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_on_off_server_attributes_e; - -/** - * @brief Attribute types for cluster: On/off Switch Configuration - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SWITCH_TYPE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_SWITCH_ACTIONS_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ -} zb_zcl_on_off_switc_configuration_server_attributes_e; - -/** - * @brief Attribute types for cluster: Level Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_CURRENT_LEVEL_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_LEVEL_CONTROL_REMAINING_TIME_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_ON_LEVEL_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_ON_TRANSITION_TIME_ATTRIBUTE_ID = 0x0012, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_OFF_TRANSITION_TIME_ATTRIBUTE_ID = 0x0013, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_DEFAULT_MOVE_RATE_ATTRIBUTE_ID = 0x0014, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_level_control_server_attributes_e; - -/** - * @brief Attribute types for cluster: Alarms - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ALARM_COUNT_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ -} zb_zcl_alarms_server_attributes_e; - -/** - * @brief Attribute types for cluster: Time - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_TIME_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_TIME_STATUS_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_TIME_ZONE_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_DST_START_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_DST_END_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_DST_SHIFT_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_STANDARD_TIME_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_LOCAL_TIME_ATTRIBUTE_ID = 0x0007, /**< Ver.: always */ - ZB_ZCL_LAST_SET_TIME_ATTRIBUTE_ID = 0x0008, /**< Ver.: always */ - ZB_ZCL_VALID_UNTIL_TIME_ATTRIBUTE_ID = 0x0009, /**< Ver.: always */ -} zb_zcl_time_server_attributes_e; - -/** - * @brief Attribute types for cluster: RSSI Location - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_LOCATION_TYPE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_LOCATION_METHOD_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_LOCATION_AGE_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_QUALITY_MEASURE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_NUMBER_OF_DEVICES_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_COORDINATE1_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_COORDINATE2_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_COORDINATE3_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_POWER_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_PATH_LOSS_EXPONENT_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ - ZB_ZCL_REPORTING_PERIOD_ATTRIBUTE_ID = 0x0015, /**< Ver.: always */ - ZB_ZCL_CALCULATION_PERIOD_ATTRIBUTE_ID = 0x0016, /**< Ver.: always */ - ZB_ZCL_NUMBER_RSSI_MEASUREMENTS_ATTRIBUTE_ID = 0x0017, /**< Ver.: always */ -} zb_zcl_rssi_location_server_attributes_e; - -/** - * @brief Attribute types for cluster: Binary Input (Basic) - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ACTIVE_TEXT_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_DESCRIPTION_ATTRIBUTE_ID = 0x001C, /**< Ver.: always */ - ZB_ZCL_INACTIVE_TEXT_ATTRIBUTE_ID = 0x002E, /**< Ver.: always */ - ZB_ZCL_OUT_OF_SERVICE_ATTRIBUTE_ID = 0x0051, /**< Ver.: always */ - ZB_ZCL_POLARITY_ATTRIBUTE_ID = 0x0054, /**< Ver.: always */ - ZB_ZCL_PRESENT_VALUE_ATTRIBUTE_ID = 0x0055, /**< Ver.: always */ - ZB_ZCL_RELIABILITY_ATTRIBUTE_ID = 0x0067, /**< Ver.: always */ - ZB_ZCL_STATUS_FLAGS_ATTRIBUTE_ID = 0x006F, /**< Ver.: always */ - ZB_ZCL_APPLICATION_TYPE_ATTRIBUTE_ID = 0x0100, /**< Ver.: always */ -} zb_zcl_binary_input_basic_server_attributes_e; - -/** - * @brief Attribute types for cluster: Commissioning - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SHORT_ADDRESS_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_EXTENDED_PAN_ID_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_PAN_ID_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_CHANNEL_MASK_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_PROTOCOL_VERSION_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_STACK_PROFILE_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_STARTUP_CONTROL_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_TRUST_CENTER_ADDRESS_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_TRUST_CENTER_MASTER_KEY_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_NETWORK_KEY_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_USE_INSECURE_JOIN_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_PRECONFIGURED_LINK_KEY_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ - ZB_ZCL_NETWORK_KEY_SEQUENCE_NUMBER_ATTRIBUTE_ID = 0x0015, /**< Ver.: always */ - ZB_ZCL_NETWORK_KEY_TYPE_ATTRIBUTE_ID = 0x0016, /**< Ver.: always */ - ZB_ZCL_NETWORK_MANAGER_ADDRESS_ATTRIBUTE_ID = 0x0017, /**< Ver.: always */ - ZB_ZCL_SCAN_ATTEMPTS_ATTRIBUTE_ID = 0x0020, /**< Ver.: always */ - ZB_ZCL_TIME_BETWEEN_SCANS_ATTRIBUTE_ID = 0x0021, /**< Ver.: always */ - ZB_ZCL_REJOIN_INTERVAL_ATTRIBUTE_ID = 0x0022, /**< Ver.: always */ - ZB_ZCL_MAX_REJOIN_INTERVAL_ATTRIBUTE_ID = 0x0023, /**< Ver.: always */ - ZB_ZCL_INDIRECT_POLL_RATE_ATTRIBUTE_ID = 0x0030, /**< Ver.: always */ - ZB_ZCL_PARENT_RETRY_THRESHOLD_ATTRIBUTE_ID = 0x0031, /**< Ver.: always */ - ZB_ZCL_CONCENTRATOR_FLAG_ATTRIBUTE_ID = 0x0040, /**< Ver.: always */ - ZB_ZCL_CONCENTRATOR_RADIUS_ATTRIBUTE_ID = 0x0041, /**< Ver.: always */ - ZB_ZCL_CONCENTRATOR_DISCOVERY_TIME_ATTRIBUTE_ID = 0x0042, /**< Ver.: always */ -} zb_zcl_commissioning_server_attributes_e; - -/** - * @brief Attribute types for cluster: Partition - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_PARTITION_MAXIMUM_INCOMING_TRANSFER_SIZE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_PARTITION_MAXIMUM_OUTGOING_TRANSFER_SIZE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_PARTIONED_FRAME_SIZE_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_LARGE_FRAME_SIZE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_NUMBER_OF_ACK_FRAME_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_NACK_TIMEOUT_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_INTERFRAME_DELAY_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_NUMBER_OF_SEND_RETRIES_ATTRIBUTE_ID = 0x0007, /**< Ver.: always */ - ZB_ZCL_SENDER_TIMEOUT_ATTRIBUTE_ID = 0x0008, /**< Ver.: always */ - ZB_ZCL_RECEIVER_TIMEOUT_ATTRIBUTE_ID = 0x0009, /**< Ver.: always */ -} zb_zcl_partition_server_attributes_e; - -/** - * @brief Attribute types for cluster: Over the Air Bootloading - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_UPGRADE_SERVER_ID_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_FILE_OFFSET_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_CURRENT_FILE_VERSION_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_CURRENT_ZIGBEE_STACK_VERSION_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_DOWNLOADED_FILE_VERSION_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_DOWNLOADED_ZIGBEE_STACK_VERSION_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_IMAGE_UPGRADE_STATUS_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_MANUFACTURER_ID_ATTRIBUTE_ID = 0x0007, /**< Ver.: always */ - ZB_ZCL_IMAGE_TYPE_ID_ATTRIBUTE_ID = 0x0008, /**< Ver.: always */ - ZB_ZCL_MINIMUM_BLOCK_REQUEST_PERIOD_ATTRIBUTE_ID = 0x0009, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_IMAGE_STAMP_ATTRIBUTE_ID = 0x000A, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_over_the_air_bootloading_client_attributes_e; - -/** - * @brief Attribute types for cluster: Power Profile - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_TOTAL_PROFILE_NUM_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_MULTIPLE_SCHEDULING_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_ENERGY_FORMATTING_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_ENERGY_REMOTE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_SCHEDULE_MODE_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ -} zb_zcl_power_profile_server_attributes_e; - -/** - * @brief Attribute types for cluster: Appliance Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_START_TIME_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_FINISH_TIME_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_REMAINING_TIME_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ -} zb_zcl_appliance_control_server_attributes_e; - -/** - * @brief Attribute types for cluster: Poll Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_CHECK_IN_INTERVAL_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_LONG_POLL_INTERVAL_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_SHORT_POLL_INTERVAL_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_FAST_POLL_TIMEOUT_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_CHECK_IN_INTERVAL_MIN_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_LONG_POLL_INTERVAL_MIN_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_FAST_POLL_TIMEOUT_MAX_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ -} zb_zcl_poll_control_server_attributes_e; - -/** - * @brief Attribute types for cluster: Shade Configuration - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SHADE_CONFIG_PHYSICAL_CLOSED_LIMIT_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_SHADE_CONFIG_MOTOR_STEP_SIZE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_SHADE_CONFIG_STATUS_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_SHADE_CONFIG_CLOSED_LIMIT_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_SHADE_CONFIG_MODE_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ -} zb_zcl_shade_configuration_server_attributes_e; - -/** - * @brief Attribute types for cluster: Door Lock - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_LOCK_STATE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_LOCK_TYPE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_ACTUATOR_ENABLED_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_DOOR_STATE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_DOOR_OPEN_EVENTS_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_DOOR_CLOSED_EVENTS_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_OPEN_PERIOD_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_NUM_LOCK_RECORDS_SUPPORTED_ATTRIBUTE_ID = 0x0010, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_NUM_TOTAL_USERS_SUPPORTED_ATTRIBUTE_ID = 0x0011, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_NUM_PIN_USERS_SUPPORTED_ATTRIBUTE_ID = 0x0012, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_NUM_RFID_USERS_SUPPORTED_ATTRIBUTE_ID = 0x0013, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_NUM_WEEKDAY_SCHEDULES_SUPPORTED_PER_USER_ATTRIBUTE_ID = 0x0014, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_NUM_YEARDAY_SCHEDULES_SUPPORTED_PER_USER_ATTRIBUTE_ID = 0x0015, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_NUM_HOLIDAY_SCHEDULES_SUPPORTED_PER_USER_ATTRIBUTE_ID = 0x0016, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_MAX_PIN_LENGTH_ATTRIBUTE_ID = 0x0017, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_MIN_PIN_LENGTH_ATTRIBUTE_ID = 0x0018, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_MAX_RFID_CODE_LENGTH_ATTRIBUTE_ID = 0x0019, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_MIN_RFID_CODE_LENGTH_ATTRIBUTE_ID = 0x001A, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_ENABLE_LOGGING_ATTRIBUTE_ID = 0x0020, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_LANGUAGE_ATTRIBUTE_ID = 0x0021, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_LED_SETTINGS_ATTRIBUTE_ID = 0x0022, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AUTO_RELOCK_TIME_ATTRIBUTE_ID = 0x0023, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SOUND_VOLUME_ATTRIBUTE_ID = 0x0024, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_OPERATING_MODE_ATTRIBUTE_ID = 0x0025, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SUPPORTED_OPERATING_MODES_ATTRIBUTE_ID = 0x0026, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_DEFAULT_CONFIGURATION_REGISTER_ATTRIBUTE_ID = 0x0027, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_ENABLE_LOCAL_PROGRAMMING_ATTRIBUTE_ID = 0x0028, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_ENABLE_ONE_TOUCH_LOCKING_ATTRIBUTE_ID = 0x0029, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_ENABLE_INSIDE_STATUS_LED_ATTRIBUTE_ID = 0x002A, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_ENABLE_PRIVACY_MODE_BUTTON_ATTRIBUTE_ID = 0x002B, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_WRONG_CODE_ENTRY_LIMIT_ATTRIBUTE_ID = 0x0030, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_USER_CODE_TEMPORARY_DISABLE_TIME_ATTRIBUTE_ID = 0x0031, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SEND_PIN_OVER_THE_AIR_ATTRIBUTE_ID = 0x0032, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_REQUIRE_PIN_FOR_RF_OPERATION_ATTRIBUTE_ID = 0x0033, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_ZIGBEE_SECURITY_LEVEL_ATTRIBUTE_ID = 0x0034, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_DOOR_LOCK_ALARM_MASK_ATTRIBUTE_ID = 0x0040, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_KEYPAD_OPERATION_EVENT_MASK_ATTRIBUTE_ID = 0x0041, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_RF_OPERATION_EVENT_MASK_ATTRIBUTE_ID = 0x0042, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_MANUAL_OPERATION_EVENT_MASK_ATTRIBUTE_ID = 0x0043, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_RFID_OPERATION_EVENT_MASK_ATTRIBUTE_ID = 0x0044, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_KEYPAD_PROGRAMMING_EVENT_MASK_ATTRIBUTE_ID = 0x0045, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_RF_PROGRAMMING_EVENT_MASK_ATTRIBUTE_ID = 0x0046, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_RFID_PROGRAMMING_EVENT_MASK_ATTRIBUTE_ID = 0x0047, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_door_lock_server_attributes_e; - -/** - * @brief Attribute types for cluster: Window Covering - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_COVERING_TYPE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_LIMIT_LIFT_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_LIMIT_TILT_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_CURRENT_LIFT_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_CURRENT_TILT_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_NUMBER_LIFT_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_NUMBER_TILT_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_CONFIG_STATUS_ATTRIBUTE_ID = 0x0007, /**< Ver.: always */ - ZB_ZCL_CURRENT_LIFT_PERCENTAGE_ATTRIBUTE_ID = 0x0008, /**< Ver.: always */ - ZB_ZCL_CURRENT_TILT_PERCENTAGE_ATTRIBUTE_ID = 0x0009, /**< Ver.: always */ - ZB_ZCL_OPEN_LIMIT_LIFT_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_CLOSED_LIMIT_LIFT_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_OPEN_LIMIT_TILT_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_CLOSED_LIMIT_TILT_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_VELOCITY_LIFT_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ - ZB_ZCL_ACCELERATION_LIFT_ATTRIBUTE_ID = 0x0015, /**< Ver.: always */ - ZB_ZCL_DECELERATION_LIFT_ATTRIBUTE_ID = 0x0016, /**< Ver.: always */ - ZB_ZCL_MODE_ATTRIBUTE_ID = 0x0017, /**< Ver.: always */ - ZB_ZCL_SETPOINTS_LIFT_ATTRIBUTE_ID = 0x0018, /**< Ver.: always */ - ZB_ZCL_SETPOINTS_TILT_ATTRIBUTE_ID = 0x0019, /**< Ver.: always */ -} zb_zcl_window_covering_server_attributes_e; - -/** - * @brief Attribute types for cluster: Pump Configuration and Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_MAX_PRESSURE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_MAX_SPEED_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_MAX_FLOW_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_MIN_CONST_PRESSURE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_MAX_CONST_PRESSURE_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_MIN_COMP_PRESSURE_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_MAX_COMP_PRESSURE_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_MIN_CONST_SPEED_ATTRIBUTE_ID = 0x0007, /**< Ver.: always */ - ZB_ZCL_MAX_CONST_SPEED_ATTRIBUTE_ID = 0x0008, /**< Ver.: always */ - ZB_ZCL_MIN_CONST_FLOW_ATTRIBUTE_ID = 0x0009, /**< Ver.: always */ - ZB_ZCL_MAX_CONST_FLOW_ATTRIBUTE_ID = 0x000A, /**< Ver.: always */ - ZB_ZCL_MIN_CONST_TEMP_ATTRIBUTE_ID = 0x000B, /**< Ver.: always */ - ZB_ZCL_MAX_CONST_TEMP_ATTRIBUTE_ID = 0x000C, /**< Ver.: always */ - ZB_ZCL_PUMP_STATUS_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_EFFECTIVE_OPERATION_MODE_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_EFFECTIVE_CONTROL_MODE_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_CAPACITY_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_SPEED_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ - ZB_ZCL_LIFETIME_RUNNING_HOURS_ATTRIBUTE_ID = 0x0015, /**< Ver.: always */ - ZB_ZCL_PUMP_POWER_ATTRIBUTE_ID = 0x0016, /**< Ver.: always */ - ZB_ZCL_LIFETIME_ENERGY_CONSUMED_ATTRIBUTE_ID = 0x0017, /**< Ver.: always */ - ZB_ZCL_OPERATION_MODE_ATTRIBUTE_ID = 0x0020, /**< Ver.: always */ - ZB_ZCL_CONTROL_MODE_ATTRIBUTE_ID = 0x0021, /**< Ver.: always */ - ZB_ZCL_PUMP_ALARM_MASK_ATTRIBUTE_ID = 0x0022, /**< Ver.: always */ -} zb_zcl_pump_configuration_and_control_server_attributes_e; - -/** - * @brief Attribute types for cluster: Thermostat - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_OUTDOOR_TEMPERATURE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_THERMOSTAT_OCCUPANCY_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_ABS_MIN_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_ABS_MAX_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_ABS_MIN_COOL_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_ABS_MAX_COOL_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_PI_COOLING_DEMAND_ATTRIBUTE_ID = 0x0007, /**< Ver.: always */ - ZB_ZCL_PI_HEATING_DEMAND_ATTRIBUTE_ID = 0x0008, /**< Ver.: always */ - ZB_ZCL_HVAC_SYSTEM_TYPE_CONFIGURATION_ATTRIBUTE_ID = 0x0009, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_LOCAL_TEMPERATURE_CALIBRATION_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_OCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_UNOCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_UNOCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ - ZB_ZCL_MIN_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0015, /**< Ver.: always */ - ZB_ZCL_MAX_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0016, /**< Ver.: always */ - ZB_ZCL_MIN_COOL_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0017, /**< Ver.: always */ - ZB_ZCL_MAX_COOL_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0018, /**< Ver.: always */ - ZB_ZCL_MIN_SETPOINT_DEAD_BAND_ATTRIBUTE_ID = 0x0019, /**< Ver.: always */ - ZB_ZCL_REMOTE_SENSING_ATTRIBUTE_ID = 0x001A, /**< Ver.: always */ - ZB_ZCL_CONTROL_SEQUENCE_OF_OPERATION_ATTRIBUTE_ID = 0x001B, /**< Ver.: always */ - ZB_ZCL_SYSTEM_MODE_ATTRIBUTE_ID = 0x001C, /**< Ver.: always */ - ZB_ZCL_THERMOSTAT_ALARM_MASK_ATTRIBUTE_ID = 0x001D, /**< Ver.: always */ - ZB_ZCL_THERMOSTAT_RUNNING_MODE_ATTRIBUTE_ID = 0x001E, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_START_OF_WEEK_ATTRIBUTE_ID = 0x0020, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_NUMBER_OF_WEEKLY_TRANSITIONS_ATTRIBUTE_ID = 0x0021, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_NUMBER_OF_DAILY_TRANSITIONS_ATTRIBUTE_ID = 0x0022, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_TEMPERATURE_SETPOINT_HOLD_ATTRIBUTE_ID = 0x0023, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_TEMPERATURE_SETPOINT_HOLD_DURATION_ATTRIBUTE_ID = 0x0024, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_THERMOSTAT_PROGRAMMING_OPERATION_MODE_ATTRIBUTE_ID = 0x0025, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_THERMOSTAT_RUNNING_STATE_ATTRIBUTE_ID = 0x0029, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SETPOINT_CHANGE_SOURCE_ATTRIBUTE_ID = 0x0030, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SETPOINT_CHANGE_AMOUNT_ATTRIBUTE_ID = 0x0031, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SETPOINT_CHANGE_SOURCE_TIMESTAMP_ATTRIBUTE_ID = 0x0032, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AC_TYPE_ATTRIBUTE_ID = 0x0040, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AC_CAPACITY_ATTRIBUTE_ID = 0x0041, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AC_REFRIGERANT_TYPE_ATTRIBUTE_ID = 0x0042, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AC_COMPRESSOR_ATTRIBUTE_ID = 0x0043, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AC_ERROR_CODE_ATTRIBUTE_ID = 0x0044, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AC_LOUVER_POSITION_ATTRIBUTE_ID = 0x0045, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AC_COIL_TEMPERATURE_ATTRIBUTE_ID = 0x0046, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_AC_CAPACITY_FORMAT_ATTRIBUTE_ID = 0x0047, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_thermostat_server_attributes_e; - -/** - * @brief Attribute types for cluster: Fan Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ -} zb_zcl_fan_control_server_attributes_e; - -/** - * @brief Attribute types for cluster: Dehumidification Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_RELATIVE_HUMIDITY_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_DEHUMIDIFICATION_COOLING_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_RH_DEHUMIDIFICATION_SETPOINT_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_RELATIVE_HUMIDITY_MODE_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_DEHUMIDIFICATION_LOCKOUT_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_DEHUMIDIFICATION_HYSTERESIS_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_DEHUMIDIFICATION_MAX_COOL_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ - ZB_ZCL_RELATIVE_HUMIDITY_DISPLAY_ATTRIBUTE_ID = 0x0015, /**< Ver.: always */ -} zb_zcl_dehumidification_control_attributes_e; - -/** - * @brief Attribute types for cluster: Thermostat User Interface Configuration - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_TEMPERATURE_DISPLAY_MODE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_KEYPAD_LOCKOUT_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_SCHEDULE_PROGRAMMING_VISIBILITY_ATTRIBUTE_ID = 0x0002, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_thermostat_user_interface_configuration_server_attributes_e; - -/** - * @brief Attribute types for cluster: Color Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_REMAINING_TIME_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_CURRENT_X_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_CURRENT_Y_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_DRIFT_COMPENSATION_ATTRIBUTE_ID = 0x0005, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COMPENSATION_TEXT_ATTRIBUTE_ID = 0x0006, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_TEMPERATURE_ATTRIBUTE_ID = 0x0007, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_MODE_ATTRIBUTE_ID = 0x0008, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_NUMBER_OF_PRIMARIES_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_1_X_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_1_Y_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_1_INTENSITY_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_2_X_ATTRIBUTE_ID = 0x0015, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_2_Y_ATTRIBUTE_ID = 0x0016, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_2_INTENSITY_ATTRIBUTE_ID = 0x0017, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_3_X_ATTRIBUTE_ID = 0x0019, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_3_Y_ATTRIBUTE_ID = 0x001A, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_3_INTENSITY_ATTRIBUTE_ID = 0x001B, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_4_X_ATTRIBUTE_ID = 0x0020, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_4_Y_ATTRIBUTE_ID = 0x0021, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_4_INTENSITY_ATTRIBUTE_ID = 0x0022, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_5_X_ATTRIBUTE_ID = 0x0024, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_5_Y_ATTRIBUTE_ID = 0x0025, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_5_INTENSITY_ATTRIBUTE_ID = 0x0026, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_6_X_ATTRIBUTE_ID = 0x0028, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_6_Y_ATTRIBUTE_ID = 0x0029, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_PRIMARY_6_INTENSITY_ATTRIBUTE_ID = 0x002A, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_WHITE_POINT_X_ATTRIBUTE_ID = 0x0030, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_WHITE_POINT_Y_ATTRIBUTE_ID = 0x0031, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_R_X_ATTRIBUTE_ID = 0x0032, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_R_Y_ATTRIBUTE_ID = 0x0033, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_R_INTENSITY_ATTRIBUTE_ID = 0x0034, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_G_X_ATTRIBUTE_ID = 0x0036, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_G_Y_ATTRIBUTE_ID = 0x0037, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_G_INTENSITY_ATTRIBUTE_ID = 0x0038, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_B_X_ATTRIBUTE_ID = 0x003A, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_B_Y_ATTRIBUTE_ID = 0x003B, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_COLOR_POINT_B_INTENSITY_ATTRIBUTE_ID = 0x003C, /**< Ver.: always */ - ZB_ZCL_COLOR_CONTROL_ENHANCED_CURRENT_HUE_ATTRIBUTE_ID = 0x4000, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_ENHANCED_COLOR_MODE_ATTRIBUTE_ID = 0x4001, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_ACTIVE_ATTRIBUTE_ID = 0x4002, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_DIRECTION_ATTRIBUTE_ID = 0x4003, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_TIME_ATTRIBUTE_ID = 0x4004, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_START_ENHANCED_HUE_ATTRIBUTE_ID = 0x4005, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_STORED_ENHANCED_HUE_ATTRIBUTE_ID = 0x4006, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_COLOR_CAPABILITIES_ATTRIBUTE_ID = 0x400A, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_COLOR_TEMP_PHYSICAL_MIN_ATTRIBUTE_ID = 0x400B, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_CONTROL_COLOR_TEMP_PHYSICAL_MAX_ATTRIBUTE_ID = 0x400C, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_color_control_server_attributes_e; - -/** - * @brief Attribute types for cluster: Ballast Configuration - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_PHYSICAL_MIN_LEVEL_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_PHYSICAL_MAX_LEVEL_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_BALLAST_STATUS_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_MIN_LEVEL_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_MAX_LEVEL_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_POWER_ON_LEVEL_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_POWER_ON_FADE_TIME_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_INTRINSIC_BALLAST_FACTOR_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ - ZB_ZCL_BALLAST_FACTOR_ADJUSTMENT_ATTRIBUTE_ID = 0x0015, /**< Ver.: always */ - ZB_ZCL_LAMP_QUALITY_ATTRIBUTE_ID = 0x0020, /**< Ver.: always */ - ZB_ZCL_LAMP_TYPE_ATTRIBUTE_ID = 0x0030, /**< Ver.: always */ - ZB_ZCL_LAMP_MANUFACTURER_ATTRIBUTE_ID = 0x0031, /**< Ver.: always */ - ZB_ZCL_LAMP_RATED_HOURS_ATTRIBUTE_ID = 0x0032, /**< Ver.: always */ - ZB_ZCL_LAMP_BURN_HOURS_ATTRIBUTE_ID = 0x0033, /**< Ver.: always */ - ZB_ZCL_LAMP_ALARM_MODE_ATTRIBUTE_ID = 0x0034, /**< Ver.: always */ - ZB_ZCL_LAMP_BURN_HOURS_TRIP_POINT_ATTRIBUTE_ID = 0x0035, /**< Ver.: always */ -} zb_zcl_ballast_configuration_server_attributes_e; - -/** - * @brief Attribute types for cluster: Illuminance Measurement - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ILLUM_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_ILLUM_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_ILLUM_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_ILLUM_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_MEASUREMENT_LIGHT_SENSOR_TYPE_ATTRIBUTE_ID = 0x0004, /**< Ver.: always */ -} zb_zcl_illuminance_measurement_server_attributes_e; - -/** - * @brief Attribute types for cluster: Illuminance Level Sensing - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_LEVEL_STATUS_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_SENSING_LIGHT_SENSOR_TYPE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_ILLUMINANCE_TARGET_LEVEL_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ -} zb_zcl_illuminance_level_sensing_server_attributes_e; - -/** - * @brief Attribute types for cluster: Temperature Measurement - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_TEMP_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_TEMP_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_TEMP_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ -} zb_zcl_temperature_measurement_server_attributes_e; - -/** - * @brief Attribute types for cluster: Pressure Measurement - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_PRESSURE_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_PRESSURE_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_PRESSURE_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_PRESSURE_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ - ZB_ZCL_PRESSURE_SCALED_VALUE_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_PRESSURE_MIN_SCALED_VALUE_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_PRESSURE_MAX_SCALED_VALUE_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_PRESSURE_SCALED_TOLERANCE_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ - ZB_ZCL_PRESSURE_SCALE_ATTRIBUTE_ID = 0x0014, /**< Ver.: always */ -} zb_zcl_pressure_measurement_server_attributes_e; - -/** - * @brief Attribute types for cluster: Flow Measurement - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_FLOW_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_FLOW_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_FLOW_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_FLOW_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ -} zb_zcl_flow_measurement_server_attributes_e; - -/** - * @brief Attribute types for cluster: Relative Humidity Measurement - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_RELATIVE_HUMIDITY_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_RELATIVE_HUMIDITY_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_RELATIVE_HUMIDITY_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_RELATIVE_HUMIDITY_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Ver.: always */ -} zb_zcl_relative_humidity_measurement_server_attributes_e; - -/** - * @brief Attribute types for cluster: Occupancy Sensing - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_OCCUPANCY_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_OCCUPANCY_SENSOR_TYPE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_PIR_OCCUPIED_TO_UNOCCUPIED_DELAY_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_PIR_UNOCCUPIED_TO_OCCUPIED_DELAY_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_PIR_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_ULTRASONIC_OCCUPIED_TO_UNOCCUPIED_DELAY_ATTRIBUTE_ID = 0x0020, /**< Ver.: always */ - ZB_ZCL_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_DELAY_ATTRIBUTE_ID = 0x0021, /**< Ver.: always */ - ZB_ZCL_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_ATTRIBUTE_ID = 0x0022, /**< Ver.: always */ -} zb_zcl_occupancy_sensing_measurement_server_attributes_e; - -/** - * @brief Attribute types for cluster: IAS Zone - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ZONE_STATE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_ZONE_TYPE_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_ZONE_STATUS_ATTRIBUTE_ID = 0x0002, /**< Ver.: always */ - ZB_ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID = 0x0010, /**< Ver.: always */ - ZB_ZCL_ZONE_ID_ATTRIBUTE_ID = 0x0011, /**< Ver.: always */ - ZB_ZCL_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_ATTRIBUTE_ID = 0x0012, /**< Ver.: always */ - ZB_ZCL_CURRENT_ZONE_SENSITIVITY_LEVEL_ATTRIBUTE_ID = 0x0013, /**< Ver.: always */ -} zb_zcl_isa_zone_server_server_attributes_e; - -/** - * @brief Attribute types for cluster: IAS WD - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_MAX_DURATION_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ -} zb_zcl_isa_wd_server_server_attributes_e; - -/** - * @brief Attribute types for cluster: Electrical Measurement - * @details Cluster specification level: UNKNOWN - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_MEASUREMENT_TYPE_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_DC_VOLTAGE_ATTRIBUTE_ID = 0x0100, /**< Ver.: always */ - ZB_ZCL_DC_VOLTAGE_MIN_ATTRIBUTE_ID = 0x0101, /**< Ver.: always */ - ZB_ZCL_DC_VOLTAGE_MAX_ATTRIBUTE_ID = 0x0102, /**< Ver.: always */ - ZB_ZCL_DC_CURRENT_ATTRIBUTE_ID = 0x0103, /**< Ver.: always */ - ZB_ZCL_DC_CURRENT_MIN_ATTRIBUTE_ID = 0x0104, /**< Ver.: always */ - ZB_ZCL_DC_CURRENT_MAX_ATTRIBUTE_ID = 0x0105, /**< Ver.: always */ - ZB_ZCL_DC_POWER_ATTRIBUTE_ID = 0x0106, /**< Ver.: always */ - ZB_ZCL_DC_POWER_MIN_ATTRIBUTE_ID = 0x0107, /**< Ver.: always */ - ZB_ZCL_DC_POWER_MAX_ATTRIBUTE_ID = 0x0108, /**< Ver.: always */ - ZB_ZCL_DC_VOLTAGE_MULTIPLIER_ATTRIBUTE_ID = 0x0200, /**< Ver.: always */ - ZB_ZCL_DC_VOLTAGE_DIVISOR_ATTRIBUTE_ID = 0x0201, /**< Ver.: always */ - ZB_ZCL_DC_CURRENT_MULTIPLIER_ATTRIBUTE_ID = 0x0202, /**< Ver.: always */ - ZB_ZCL_DC_CURRENT_DIVISOR_ATTRIBUTE_ID = 0x0203, /**< Ver.: always */ - ZB_ZCL_DC_POWER_MULTIPLIER_ATTRIBUTE_ID = 0x0204, /**< Ver.: always */ - ZB_ZCL_DC_POWER_DIVISOR_ATTRIBUTE_ID = 0x0205, /**< Ver.: always */ - ZB_ZCL_AC_FREQUENCY_ATTRIBUTE_ID = 0x0300, /**< Ver.: always */ - ZB_ZCL_AC_FREQUENCY_MIN_ATTRIBUTE_ID = 0x0301, /**< Ver.: always */ - ZB_ZCL_AC_FREQUENCY_MAX_ATTRIBUTE_ID = 0x0302, /**< Ver.: always */ - ZB_ZCL_NEUTRAL_CURRENT_ATTRIBUTE_ID = 0x0303, /**< Ver.: always */ - ZB_ZCL_TOTAL_ACTIVE_POWER_ATTRIBUTE_ID = 0x0304, /**< Ver.: always */ - ZB_ZCL_TOTAL_REACTIVE_POWER_ATTRIBUTE_ID = 0x0305, /**< Ver.: always */ - ZB_ZCL_TOTAL_APPARENT_POWER_ATTRIBUTE_ID = 0x0306, /**< Ver.: always */ - ZB_ZCL_MEASURED_1ST_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0307, /**< Ver.: always */ - ZB_ZCL_MEASURED_3RD_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0308, /**< Ver.: always */ - ZB_ZCL_MEASURED_5TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0309, /**< Ver.: always */ - ZB_ZCL_MEASURED_7TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030A, /**< Ver.: always */ - ZB_ZCL_MEASURED_9TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030B, /**< Ver.: always */ - ZB_ZCL_MEASURED_11TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030C, /**< Ver.: always */ - ZB_ZCL_MEASURED_PHASE_1ST_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030D, /**< Ver.: always */ - ZB_ZCL_MEASURED_PHASE_3RD_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030E, /**< Ver.: always */ - ZB_ZCL_MEASURED_PHASE_5TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030F, /**< Ver.: always */ - ZB_ZCL_MEASURED_PHASE_7TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0310, /**< Ver.: always */ - ZB_ZCL_MEASURED_PHASE_9TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0311, /**< Ver.: always */ - ZB_ZCL_MEASURED_PHASE_11TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0312, /**< Ver.: always */ - ZB_ZCL_AC_FREQUENCY_MULTIPLIER_ATTRIBUTE_ID = 0x0400, /**< Ver.: always */ - ZB_ZCL_AC_FREQUENCY_DIVISOR_ATTRIBUTE_ID = 0x0401, /**< Ver.: always */ - ZB_ZCL_POWER_MULTIPLIER_ATTRIBUTE_ID = 0x0402, /**< Ver.: always */ - ZB_ZCL_POWER_DIVISOR_ATTRIBUTE_ID = 0x0403, /**< Ver.: always */ - ZB_ZCL_HARMONIC_CURRENT_MULTIPLIER_ATTRIBUTE_ID = 0x0404, /**< Ver.: always */ - ZB_ZCL_PHASE_HARMONIC_CURRENT_MULTIPLIER_ATTRIBUTE_ID = 0x0405, /**< Ver.: always */ - ZB_ZCL_INSTANTANEOUS_VOLTAGE_ATTRIBUTE_ID = 0x0500, /**< Ver.: always */ - ZB_ZCL_INSTANTANEOUS_LINE_CURRENT_ATTRIBUTE_ID = 0x0501, /**< Ver.: always */ - ZB_ZCL_INSTANTANEOUS_ACTIVE_CURRENT_ATTRIBUTE_ID = 0x0502, /**< Ver.: always */ - ZB_ZCL_INSTANTANEOUS_REACTIVE_CURRENT_ATTRIBUTE_ID = 0x0503, /**< Ver.: always */ - ZB_ZCL_INSTANTANEOUS_POWER_ATTRIBUTE_ID = 0x0504, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_ATTRIBUTE_ID = 0x0505, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_MIN_ATTRIBUTE_ID = 0x0506, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_MAX_ATTRIBUTE_ID = 0x0507, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_ATTRIBUTE_ID = 0x0508, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_MIN_ATTRIBUTE_ID = 0x0509, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_MAX_ATTRIBUTE_ID = 0x050A, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_ATTRIBUTE_ID = 0x050B, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_MIN_ATTRIBUTE_ID = 0x050C, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_MAX_ATTRIBUTE_ID = 0x050D, /**< Ver.: always */ - ZB_ZCL_REACTIVE_POWER_ATTRIBUTE_ID = 0x050E, /**< Ver.: always */ - ZB_ZCL_APPARENT_POWER_ATTRIBUTE_ID = 0x050F, /**< Ver.: always */ - ZB_ZCL_AC_POWER_FACTOR_ATTRIBUTE_ID = 0x0510, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_ATTRIBUTE_ID = 0x0511, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_ATTRIBUTE_ID = 0x0513, /**< Ver.: always */ - ZB_ZCL_RMS_EXTREME_OVER_VOLTAGE_PERIOD_ATTRIBUTE_ID = 0x0514, /**< Ver.: always */ - ZB_ZCL_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_ATTRIBUTE_ID = 0x0515, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_SAG_PERIOD_ATTRIBUTE_ID = 0x0516, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_SWELL_PERIOD_ATTRIBUTE_ID = 0x0517, /**< Ver.: always */ - ZB_ZCL_AC_VOLTAGE_MULTIPLIER_ATTRIBUTE_ID = 0x0600, /**< Ver.: always */ - ZB_ZCL_AC_VOLTAGE_DIVISOR_ATTRIBUTE_ID = 0x0601, /**< Ver.: always */ - ZB_ZCL_AC_CURRENT_MULTIPLIER_ATTRIBUTE_ID = 0x0602, /**< Ver.: always */ - ZB_ZCL_AC_CURRENT_DIVISOR_ATTRIBUTE_ID = 0x0603, /**< Ver.: always */ - ZB_ZCL_AC_POWER_MULTIPLIER_ATTRIBUTE_ID = 0x0604, /**< Ver.: always */ - ZB_ZCL_AC_POWER_DIVISOR_ATTRIBUTE_ID = 0x0605, /**< Ver.: always */ - ZB_ZCL_DC_OVERLOAD_ALARMS_MASK_ATTRIBUTE_ID = 0x0700, /**< Ver.: always */ - ZB_ZCL_DC_VOLTAGE_OVERLOAD_ATTRIBUTE_ID = 0x0701, /**< Ver.: always */ - ZB_ZCL_DC_CURRENT_OVERLOAD_ATTRIBUTE_ID = 0x0702, /**< Ver.: always */ - ZB_ZCL_AC_OVERLOAD_ALARMS_MASK_ATTRIBUTE_ID = 0x0800, /**< Ver.: always */ - ZB_ZCL_AC_VOLTAGE_OVERLOAD_ATTRIBUTE_ID = 0x0801, /**< Ver.: always */ - ZB_ZCL_AC_CURRENT_OVERLOAD_ATTRIBUTE_ID = 0x0802, /**< Ver.: always */ - ZB_ZCL_AC_POWER_OVERLOAD_ATTRIBUTE_ID = 0x0803, /**< Ver.: always */ - ZB_ZCL_AC_REACTIVE_POWER_OVERLOAD_ATTRIBUTE_ID = 0x0804, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_OVER_VOLTAGE_ATTRIBUTE_ID = 0x0805, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_UNDER_VOLTAGE_ATTRIBUTE_ID = 0x0806, /**< Ver.: always */ - ZB_ZCL_RMS_EXTREME_OVER_VOLTAGE_ATTRIBUTE_ID = 0x0807, /**< Ver.: always */ - ZB_ZCL_RMS_EXTREME_UNDER_VOLTAGE_ATTRIBUTE_ID = 0x0808, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_SAG_ATTRIBUTE_ID = 0x0809, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_SWELL_ATTRIBUTE_ID = 0x080A, /**< Ver.: always */ - ZB_ZCL_LINE_CURRENT_PHASE_B_ATTRIBUTE_ID = 0x0901, /**< Ver.: always */ - ZB_ZCL_ACTIVE_CURRENT_PHASE_B_ATTRIBUTE_ID = 0x0902, /**< Ver.: always */ - ZB_ZCL_REACTIVE_CURRENT_PHASE_B_ATTRIBUTE_ID = 0x0903, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_PHASE_B_ATTRIBUTE_ID = 0x0905, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_MIN_PHASE_B_ATTRIBUTE_ID = 0x0906, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_MAX_PHASE_B_ATTRIBUTE_ID = 0x0907, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_PHASE_B_ATTRIBUTE_ID = 0x0908, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_MIN_PHASE_B_ATTRIBUTE_ID = 0x0909, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_MAX_PHASE_B_ATTRIBUTE_ID = 0x090A, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_PHASE_B_ATTRIBUTE_ID = 0x090B, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_MIN_PHASE_B_ATTRIBUTE_ID = 0x090C, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_MAX_PHASE_B_ATTRIBUTE_ID = 0x090D, /**< Ver.: always */ - ZB_ZCL_REACTIVE_POWER_PHASE_B_ATTRIBUTE_ID = 0x090E, /**< Ver.: always */ - ZB_ZCL_APPARENT_POWER_PHASE_B_ATTRIBUTE_ID = 0x090F, /**< Ver.: always */ - ZB_ZCL_POWER_FACTOR_PHASE_B_ATTRIBUTE_ID = 0x0910, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0911, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PHASE_B_ATTRIBUTE_ID = 0x0912, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PHASE_B_ATTRIBUTE_ID = 0x0913, /**< Ver.: always */ - ZB_ZCL_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0914, /**< Ver.: always */ - ZB_ZCL_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0915, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_SAG_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0916, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_SWELL_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0917, /**< Ver.: always */ - ZB_ZCL_LINE_CURRENT_PHASE_C_ATTRIBUTE_ID = 0x0A01, /**< Ver.: always */ - ZB_ZCL_ACTIVE_CURRENT_PHASE_C_ATTRIBUTE_ID = 0x0A02, /**< Ver.: always */ - ZB_ZCL_REACTIVE_CURRENT_PHASE_C_ATTRIBUTE_ID = 0x0A03, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_PHASE_C_ATTRIBUTE_ID = 0x0A05, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_MIN_PHASE_C_ATTRIBUTE_ID = 0x0A06, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_MAX_PHASE_C_ATTRIBUTE_ID = 0x0A07, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_PHASE_C_ATTRIBUTE_ID = 0x0A08, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_MIN_PHASE_C_ATTRIBUTE_ID = 0x0A09, /**< Ver.: always */ - ZB_ZCL_RMS_CURRENT_MAX_PHASE_C_ATTRIBUTE_ID = 0x0A0A, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_PHASE_C_ATTRIBUTE_ID = 0x0A0B, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_MIN_PHASE_C_ATTRIBUTE_ID = 0x0A0C, /**< Ver.: always */ - ZB_ZCL_ACTIVE_POWER_MAX_PHASE_C_ATTRIBUTE_ID = 0x0A0D, /**< Ver.: always */ - ZB_ZCL_REACTIVE_POWER_PHASE_C_ATTRIBUTE_ID = 0x0A0E, /**< Ver.: always */ - ZB_ZCL_APPARENT_POWER_PHASE_C_ATTRIBUTE_ID = 0x0A0F, /**< Ver.: always */ - ZB_ZCL_POWER_FACTOR_PHASE_C_ATTRIBUTE_ID = 0x0A10, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A11, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PHASE_C_ATTRIBUTE_ID = 0x0A12, /**< Ver.: always */ - ZB_ZCL_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PHASE_C_ATTRIBUTE_ID = 0x0A13, /**< Ver.: always */ - ZB_ZCL_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A14, /**< Ver.: always */ - ZB_ZCL_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A15, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_SAG_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A16, /**< Ver.: always */ - ZB_ZCL_RMS_VOLTAGE_SWELL_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A17, /**< Ver.: always */ -} zb_zcl_electrical_measurement_server_attributes_e; - -/** - * @brief Attribute types for cluster: Diagnostics - * @details Cluster specification level: UNKNOWN - * @pre Server attributes - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_NUMBER_OF_RESETS_ATTRIBUTE_ID = 0x0000, /**< Ver.: always */ - ZB_ZCL_PERSISTENT_MEMORY_WRITES_ATTRIBUTE_ID = 0x0001, /**< Ver.: always */ - ZB_ZCL_MAC_RX_BCAST_ATTRIBUTE_ID = 0x0100, /**< Ver.: always */ - ZB_ZCL_MAC_TX_BCAST_ATTRIBUTE_ID = 0x0101, /**< Ver.: always */ - ZB_ZCL_MAC_RX_UCAST_ATTRIBUTE_ID = 0x0102, /**< Ver.: always */ - ZB_ZCL_MAC_TX_UCAST_ATTRIBUTE_ID = 0x0103, /**< Ver.: always */ - ZB_ZCL_MAC_TX_UCAST_RETRY_ATTRIBUTE_ID = 0x0104, /**< Ver.: always */ - ZB_ZCL_MAC_TX_UCAST_FAIL_ATTRIBUTE_ID = 0x0105, /**< Ver.: always */ - ZB_ZCL_APS_RX_BCAST_ATTRIBUTE_ID = 0x0106, /**< Ver.: always */ - ZB_ZCL_APS_TX_BCAST_ATTRIBUTE_ID = 0x0107, /**< Ver.: always */ - ZB_ZCL_APS_RX_UCAST_ATTRIBUTE_ID = 0x0108, /**< Ver.: always */ - ZB_ZCL_APS_UCAST_SUCCESS_ATTRIBUTE_ID = 0x0109, /**< Ver.: always */ - ZB_ZCL_APS_TX_UCAST_RETRY_ATTRIBUTE_ID = 0x010A, /**< Ver.: always */ - ZB_ZCL_APS_TX_UCAST_FAIL_ATTRIBUTE_ID = 0x010B, /**< Ver.: always */ - ZB_ZCL_ROUTE_DISC_INITIATED_ATTRIBUTE_ID = 0x010C, /**< Ver.: always */ - ZB_ZCL_NEIGHBOR_ADDED_ATTRIBUTE_ID = 0x010D, /**< Ver.: always */ - ZB_ZCL_NEIGHBOR_REMOVED_ATTRIBUTE_ID = 0x010E, /**< Ver.: always */ - ZB_ZCL_NEIGHBOR_STALE_ATTRIBUTE_ID = 0x010F, /**< Ver.: always */ - ZB_ZCL_JOIN_INDICATION_ATTRIBUTE_ID = 0x0110, /**< Ver.: always */ - ZB_ZCL_CHILD_MOVED_ATTRIBUTE_ID = 0x0111, /**< Ver.: always */ - ZB_ZCL_NWK_FC_FAILURE_ATTRIBUTE_ID = 0x0112, /**< Ver.: always */ - ZB_ZCL_APS_FC_FAILURE_ATTRIBUTE_ID = 0x0113, /**< Ver.: always */ - ZB_ZCL_APS_UNAUTHORIZED_KEY_ATTRIBUTE_ID = 0x0114, /**< Ver.: always */ - ZB_ZCL_NWK_DECRYPT_FAILURE_ATTRIBUTE_ID = 0x0115, /**< Ver.: always */ - ZB_ZCL_APS_DECRYPT_FAILURE_ATTRIBUTE_ID = 0x0116, /**< Ver.: always */ - ZB_ZCL_PACKET_BUFFER_ALLOC_FAILURES_ATTRIBUTE_ID = 0x0117, /**< Ver.: always */ - ZB_ZCL_RELAYED_UNICAST_ATTRIBUTE_ID = 0x0118, /**< Ver.: always */ - ZB_ZCL_PHY_TO_MAC_QUEUE_LIMIT_REACHED_ATTRIBUTE_ID = 0x0119, /**< Ver.: always */ - ZB_ZCL_PACKET_VALIDATE_DROP_COUNT_ATTRIBUTE_ID = 0x011A, /**< Ver.: always */ - ZB_ZCL_AVERAGE_MAC_RETRY_PER_APS_MSG_SENT_ATTRIBUTE_ID = 0x011B, /**< Ver.: always */ - ZB_ZCL_LAST_MESSAGE_LQI_ATTRIBUTE_ID = 0x011C, /**< Ver.: always */ - ZB_ZCL_LAST_MESSAGE_RSSI_ATTRIBUTE_ID = 0x011D, /**< Ver.: always */ -} zb_zcl_diagnostics_server_attributes_e; - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDS_H__ */ diff --git a/include/zcl/zb-zcl-attribute-type.h b/include/zcl/zb-zcl-attribute-type.h deleted file mode 100644 index 4e2d87c..0000000 --- a/include/zcl/zb-zcl-attribute-type.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_TYPE_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_TYPE_H__ - -/** - * @file zb-zcl-attribute-type.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_DATA_TYPE_MODULE Cluster Attribute Data Type - * - * @brief zigbee cluster attribute data type - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_DATA_TYPE_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/** - * @brief ZCL attribute types (See Table 2.16 Data type) - * @details ZigBee devices, such as thermostats, lamps, etc., are defined in terms of the - * attributes they contain, which can be written, read or reported using the - * commands defined in clause 2.4. Table 2.16 details the data types and formats that - * can be used for these attributes. Note that individual clusters, which may use - * different or new types, show valid values, ranges, and units for the attributes they - * represent. \n\n - * - * Each data type is allocated an 8-bit data type ID. The most significant 5 bits of this - * ID is used to divide the types into 32 type classes, and the least significant 3 bits - * specify a specific data type within this class. \n\n - * - * Table 2.16 also indicates for each data type whether it is considered to be 'analog' - * or 'discrete'. Values of analog types may be added to or subtracted from other - * values of the same type, and are typically used to measure the value of properties - * in the real world that vary continuously over a range. Values of discrete data types - * only have meaning as individual values, and may not be added or subtracted. - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_NO_DATA_ATTRIBUTE_TYPE = 0x00, /**< No data */ - ZB_ZCL_8_BIT_DATA = 0x08, /**< 8-bit data, 1-byte */ - ZB_ZCL_16_BIT_DATA = 0x09, /**< 16-bit data, 2-byte */ - ZB_ZCL_24_BIT_DATA = 0x0a, /**< 24-bit data, 3-byte */ - ZB_ZCL_32_BIT_DATA = 0x0b, /**< 32-bit data, 4-byte */ - ZB_ZCL_40_BIT_DATA = 0x0c, /**< 40-bit data, 5-byte */ - ZB_ZCL_48_BIT_DATA = 0x0d, /**< 48-bit data, 6-byte */ - ZB_ZCL_56_BIT_DATA = 0x0e, /**< 56-bit data, 7-byte */ - ZB_ZCL_64_BIT_DATA = 0x0f, /**< 64-bit data, 8-byte */ - ZB_ZCL_BOOLEAN = 0x10, /**< Boolean, 1-byte */ - ZB_ZCL_8_BIT_BITMAP = 0x18, /**< 8-bit bitmap, 1-byte */ - ZB_ZCL_16_BIT_BITMAP = 0x19, /**< 16-bit bitmap, 2-byte */ - ZB_ZCL_24_BIT_BITMAP = 0x1a, /**< 24-bit bitmap, 3-byte */ - ZB_ZCL_32_BIT_BITMAP = 0x1b, /**< 32-bit bitmap, 4-byte */ - ZB_ZCL_40_BIT_BITMAP = 0x1c, /**< 40-bit bitmap, 5-byte */ - ZB_ZCL_48_BIT_BITMAP = 0x1d, /**< 48-bit bitmap, 6-byte */ - ZB_ZCL_56_BIT_BITMAP = 0x1e, /**< 56-bit bitmap, 7-byte */ - ZB_ZCL_64_BIT_BITMAP = 0x1f, /**< 64-bit bitmap, 8-byte */ - ZB_ZCL_UNSIGNED_8_BIT_INTEGER = 0x20, /**< unsigned 8-bit integer, 1-byte */ - ZB_ZCL_UNSIGNED_16_BIT_INTEGER = 0x21, /**< unsigned 16-bit integer, 2-byte */ - ZB_ZCL_UNSIGNED_24_BIT_INTEGER = 0x22, /**< unsigned 24-bit integer, 3-byte */ - ZB_ZCL_UNSIGNED_32_BIT_INTEGER = 0x23, /**< unsigned 32-bit integer, 4-byte */ - ZB_ZCL_UNSIGNED_40_BIT_INTEGER = 0x24, /**< unsigned 40-bit integer, 5-byte */ - ZB_ZCL_UNSIGNED_48_BIT_INTEGER = 0x25, /**< unsigned 48-bit integer, 6-byte */ - ZB_ZCL_UNSIGNED_56_BIT_INTEGER = 0x26, /**< unsigned 56-bit integer, 7-byte */ - ZB_ZCL_UNSIGNED_64_BIT_INTEGER = 0x27, /**< unsigned 64-bit integer, 8-byte */ - ZB_ZCL_SIGNED_8_BIT_INTEGER = 0x28, /**< signed 8-bit integer, 1-byte */ - ZB_ZCL_SIGNED_16_BIT_INTEGER = 0x29, /**< signed 16-bit integer, 2-byte */ - ZB_ZCL_SIGNED_24_BIT_INTEGER = 0x2a, /**< signed 24-bit integer, 3-byte */ - ZB_ZCL_SIGNED_32_BIT_INTEGER = 0x2b, /**< signed 32-bit integer, 4-byte */ - ZB_ZCL_SIGNED_40_BIT_INTEGER = 0x2c, /**< signed 40-bit integer, 5-byte */ - ZB_ZCL_SIGNED_48_BIT_INTEGER = 0x2d, /**< signed 48-bit integer, 6-byte */ - ZB_ZCL_SIGNED_56_BIT_INTEGER = 0x2e, /**< signed 56-bit integer, 7-byte */ - ZB_ZCL_SIGNED_64_BIT_INTEGER = 0x2f, /**< signed 64-bit integer, 8-byte */ - ZB_ZCL_8_BIT_ENUMERATION = 0x30, /**< 8-bit enumeration, 1-byte */ - ZB_ZCL_16_BIT_ENUMERATION = 0x31, /**< 16-bit enumeration, 2-byte */ - ZB_ZCL_SEMI_PRECISION = 0x38, /**< foating point, 2-byte */ - ZB_ZCL_SINGLE_PRECISION = 0x39, /**< foating point, 4-byte */ - ZB_ZCL_DOUBLE_PRECISION = 0x3a, /**< foating point, 8-byte */ - /**< Octat string, Defined in first two octat */ - ZB_ZCL_OCTAT_STRING = 0x41, - /**< Character string, Defined in first two octat */ - ZB_ZCL_CHRACTER_STRING = 0x42, - /**< Long octat string, Defined in first two octat */ - ZB_ZCL_LONG_OCTAT_STRING = 0x43, - /**< Long character string, Defined in first 2-byte */ - ZB_ZCL_LONG_CHRACTER_STRING = 0x44, - /**< Array 2(0xffff)+Sum of lengths of contents, but we ignore 2-byte prefix */ - ZB_ZCL_ARRAY = 0x48, - /**< Structure 2(0xffff)+Sum of lengths of contents, but we ignore 2-byte prefix */ - ZB_ZCL_STRUCTURE = 0x4c, - ZB_ZCL_SET = 0x50, /**< Set, Sum of lengths of contents */ - ZB_ZCL_BAG = 0x51, /**< Bag, Sum of lengths of contents */ - ZB_ZCL_TIME_OF_DAY = 0xe0, /**< Time of day, 4-byte */ - ZB_ZCL_DATE = 0xe1, /**< Date, 4 byte */ - ZB_ZCL_UTC_TIME = 0xe2, /**< UTC Time, 4-byte */ - ZB_ZCL_CLUSTER_ID = 0xe8, /**< Cluster ID, 2-byte */ - ZB_ZCL_ATTRIBUTE_ID = 0xe9, /**< Attribute ID, 2-byte */ - ZB_ZCL_BACNET_OID = 0xea, /**< BACnet OID 4 byte */ - ZB_ZCL_IEEE_ADDRESS = 0xf0, /**< IEEE address, 8-byte */ - ZB_ZCL_128_BIT_SECURITY_KEY = 0xf1, /**< 128-bit security key, 16-byte */ -} zb_zcl_data_type_e; - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_TYPE_H__ */ diff --git a/include/zcl/zb-zcl-basic-cluster.h b/include/zcl/zb-zcl-basic-cluster.h deleted file mode 100644 index 4a3d48b..0000000 --- a/include/zcl/zb-zcl-basic-cluster.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-basic-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_MODULE Basic Cluster - * - * @brief zigbee basic cluster commands - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/** - * @brief Command description for setting configure reporting - * @details This function is aim to reset end-device as factory default settings. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] handle handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep target endpoint - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_write_attr_rsp() - */ -int zb_zcl_basic_reset_factory_default( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-cluster-ids.h b/include/zcl/zb-zcl-cluster-ids.h deleted file mode 100644 index 4bdc43a..0000000 --- a/include/zcl/zb-zcl-cluster-ids.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_CLUSTER_IDS_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_CLUSTER_IDS_H__ - -/** - * @file zb-zcl-cluster-ids.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_CLUSTER_ID_MODULE Cluster IDs - * - * @brief Zigbee Cluster IDs - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_CLUSTER_ID_MODULE_HEADER Header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_CLUSTER_ID_MODULE_OVERVIEW Overview - * Cluster domain specification levels: \n\n - * - General: zcl-1.0-07-5123-03 \n - * - HA: ha-1.2.1-05-3520-30 \n - * - Closures: zcl-1.0-07-5123-03 \n - * - HVAC: zcl-1.0-07-5123-03 \n - * - Lighting: zcl-1.0-07-5123-03 \n - * - Measurement & Sensing: zcl-1.0-07-5123-03 \n - * - Security & Safety: zcl-1.0-07-5123-03 \n - * - Home Automation: UNKNOWN \n - * - CBA: cba-1.0-05-3516-12 \n - * - SE: se-1.2-12-0517-08 \n - * - ZLL: zll-1.0-11-0037-10 \n - * - Telecom Applications: ta-1.0-07-5307-07 \n - * - Protocol Interfaces: ta-1.0-07-5307-07 \n - * - Telecommunication: ta-1.0-07-5307-07 \n - * - Financial: ta-1.0-07-5307-07 \n - * - Ember: UNKNOWN \n - * - HC: hc-1.0-07-5360-15 \n - * - * @{ - * - */ - -/** - * @brief Zigbee Cluster IDs for reference - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_BASIC_CLUSTER_ID = 0x0000, /**< Basic Cluster */ - ZB_ZCL_POWER_CONFIG_CLUSTER_ID = 0x0001, /**< Power Configuration Cluster */ - ZB_ZCL_DEVICE_TEMP_CLUSTER_ID = 0x0002, /**< Device Temperature Cluster */ - ZB_ZCL_IDENTIFY_CLUSTER_ID = 0x0003, /**< Identify Cluster */ - ZB_ZCL_GROUPS_CLUSTER_ID = 0x0004, /**< Group Cluster */ - ZB_ZCL_SCENES_CLUSTER_ID = 0x0005, /**< Scene Cluster */ - ZB_ZCL_ON_OFF_CLUSTER_ID = 0x0006, /**< On/Off Cluster */ - ZB_ZCL_ON_OFF_SWITCH_CONFIG_CLUSTER_ID = 0x0007, /**< On/Off Switch Cluster */ - ZB_ZCL_LEVEL_CONTROL_CLUSTER_ID = 0x0008, /**< Level Control Cluster */ - ZB_ZCL_ALARM_CLUSTER_ID = 0x0009, /**< Alarm Cluster */ - ZB_ZCL_TIME_CLUSTER_ID = 0x000A, /**< Time Cluster */ - ZB_ZCL_RSSI_LOCATION_CLUSTER_ID = 0x000B, /**< RSSI Location Cluster */ - ZB_ZCL_BINARY_INPUT_BASIC_CLUSTER_ID = 0x000F, /**< Binary Input Basic Cluster */ - ZB_ZCL_COMMISSIONING_CLUSTER_ID = 0x0015, /**< Commissioning Cluster */ - ZB_ZCL_PARTITION_CLUSTER_ID = 0x0016, /**< Partition Cluster */ - ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID = 0x0019, /**< OTA Bootload Cluster */ - ZB_ZCL_POWER_PROFILE_CLUSTER_ID = 0x001A, /**< Power Profile Cluster */ - ZB_ZCL_APPLIANCE_CONTROL_CLUSTER_ID = 0x001B, /**< Application Control Cluster */ - ZB_ZCL_POLL_CONTROL_CLUSTER_ID = 0x0020, /**< Poll Control Cluster */ - ZB_ZCL_SHADE_CONFIG_CLUSTER_ID = 0x0100, /**< Shade Config Cluster */ - ZB_ZCL_DOOR_LOCK_CLUSTER_ID = 0x0101, /**< Door Lock Cluster */ - ZB_ZCL_WINDOW_COVERING_CLUSTER_ID = 0x0102, /**< Window Covering Cluster */ - ZB_ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID = 0x0200, /**< Pump Configuration Cluster */ - ZB_ZCL_THERMOSTAT_CLUSTER_ID = 0x0201, /**< Thermostat Cluster */ - ZB_ZCL_FAN_CONTROL_CLUSTER_ID = 0x0202, /**< Fan Control Cluster */ - ZB_ZCL_DEHUMID_CONTROL_CLUSTER_ID = 0x0203, /**< Dehumid Control Cluster */ - ZB_ZCL_THERMOSTAT_UI_CONFIG_CLUSTER_ID = 0x0204, /**< Thermostat UI Cluster */ - ZB_ZCL_COLOR_CONTROL_CLUSTER_ID = 0x0300, /**< Color Control Cluster */ - ZB_ZCL_BALLAST_CONFIGURATION_CLUSTER_ID = 0x0301, /**< Ballast Configuration Cluster */ - ZB_ZCL_ILLUM_MEASUREMENT_CLUSTER_ID = 0x0400, /**< Illuminance Measurement Cluster */ - ZB_ZCL_ILLUM_LEVEL_SENSING_CLUSTER_ID = 0x0401, /**< Illuminance Level Sensing Cluster */ - ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID = 0x0402, /**< Temperature Measurement Cluster */ - ZB_ZCL_PRESSURE_MEASUREMENT_CLUSTER_ID = 0x0403, /**< Pressure Measurement Cluster */ - ZB_ZCL_FLOW_MEASUREMENT_CLUSTER_ID = 0x0404, /**< Flow Measurement Cluster */ - ZB_ZCL_RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER_ID = 0x0405, /**< Relative Humidity Measurement Cluster */ - ZB_ZCL_OCCUPANCY_SENSING_CLUSTER_ID = 0x0406, /**< Occupancy Sensing Cluster */ - ZB_ZCL_IAS_ZONE_CLUSTER_ID = 0x0500, /**< IAS Zone Cluster */ - ZB_ZCL_IAS_ACE_CLUSTER_ID = 0x0501, /**< IAS Ace Cluster */ - ZB_ZCL_IAS_WD_CLUSTER_ID = 0x0502, /**< IAS WD Cluster */ - ZB_ZCL_GENERIC_TUNNEL_CLUSTER_ID = 0x0600, /**< Generic Tunnel Cluster */ - ZB_ZCL_BACNET_PROTOCOL_TUNNEL_CLUSTER_ID = 0x0601, /**< Bacnet Protocol Tunnel Cluster */ - ZB_ZCL_11073_PROTOCOL_TUNNEL_CLUSTER_ID = 0x0614, /**< 11073 Protocol Tunnel Cluster */ - ZB_ZCL_ISO7816_PROTOCOL_TUNNEL_CLUSTER_ID = 0x0615, /**< ISO7816 Protocol Tunnel Cluster */ - ZB_ZCL_PRICE_CLUSTER_ID = 0x0700, /**< Price Cluster */ - ZB_ZCL_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_ID = 0x0701, /**< Demand Response Load Control Cluster */ - ZB_ZCL_SIMPLE_METERING_CLUSTER_ID = 0x0702, /**< Simple Metering Cluster */ - ZB_ZCL_MESSAGING_CLUSTER_ID = 0x0703, /**< Messaging Cluster */ - ZB_ZCL_TUNNELING_CLUSTER_ID = 0x0704, /**< Tunneling Cluster */ - ZB_ZCL_PREPAYMENT_CLUSTER_ID = 0x0705, /**< Prepayment Cluster */ - ZB_ZCL_ENERGY_MANAGEMENT_CLUSTER_ID = 0x0706, /**< Energy Management Cluster */ - ZB_ZCL_TOU_CALENDAR_CLUSTER_ID = 0x0707, /**< Calendar Cluster */ - ZB_ZCL_DEVICE_MANAGEMENT_CLUSTER_ID = 0x0708, /**< Device Management Cluster */ - ZB_ZCL_EVENTS_CLUSTER_ID = 0x0709, /**< Events Cluster */ - ZB_ZCL_MDU_PAIRING_CLUSTER_ID = 0x070A, /**< MDU Paring Cluster */ - ZB_ZCL_KEY_ESTABLISHMENT_CLUSTER_ID = 0x0800, /**< Key Establishment Cluster */ - ZB_ZCL_INFORMATION_CLUSTER_ID = 0x0900, /**< Information Cluster */ - ZB_ZCL_DATA_SHARING_CLUSTER_ID = 0x0901, /**< Data Sharing Cluster */ - ZB_ZCL_GAMING_CLUSTER_ID = 0x0902, /**< Gaming Cluster */ - ZB_ZCL_DATA_RATE_CONTROL_CLUSTER_ID = 0x0903, /**< Data Rate Control Cluster */ - ZB_ZCL_VOICE_OVER_ZIGBEE_CLUSTER_ID = 0x0904, /**< Voice Over Zigbee Cluster */ - ZB_ZCL_CHATTING_CLUSTER_ID = 0x0905, /**< Chatting Cluster */ - ZB_ZCL_PAYMENT_CLUSTER_ID = 0x0A01, /**< Payment Cluster */ - ZB_ZCL_BILLING_CLUSTER_ID = 0x0A02, /**< Billing Cluster */ - ZB_ZCL_APPLIANCE_IDENTIFICATION_CLUSTER_ID = 0x0B00, /**< Appliance Identification Cluster */ - ZB_ZCL_METER_IDENTIFICATION_CLUSTER_ID = 0x0B01, /**< Meter Identification Cluster */ - ZB_ZCL_APPLIANCE_EVENTS_AND_ALERT_CLUSTER_ID = 0x0B02, /**< Appliance Events and Alert Cluster */ - ZB_ZCL_APPLIANCE_STATISTICS_CLUSTER_ID = 0x0B03, /**< Appliance Statistics Cluster */ - ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID = 0x0B04, /**< Electrical Measurement Cluster */ - ZB_ZCL_DIAGNOSTICS_CLUSTER_ID = 0x0B05, /**< Diagnostics Cluster */ - ZB_ZCL_ZLL_COMMISSIONING_CLUSTER_ID = 0x1000, /**< ZLL Commissioning Cluster */ -} zb_zcl_cluster_ids_e; - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_CLUSTER_IDS_H__ */ diff --git a/include/zcl/zb-zcl-color-control-cluster.h b/include/zcl/zb-zcl-color-control-cluster.h deleted file mode 100644 index 5355fce..0000000 --- a/include/zcl/zb-zcl-color-control-cluster.h +++ /dev/null @@ -1,503 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_H__ - -#include - -/** - * @file zb-zcl-color-control-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_MODULE Color Control Cluster - * - * @brief zigbee color control cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 5.9 Command IDs for the Color Control Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Move to Hue | O | - * | 0x01 | Move Hue | O | - * | 0x02 | Step Hue | O | - * | 0x03 | Move to Saturation | O | - * | 0x04 | Move Saturation | O | - * | 0x05 | Step Saturation | O | - * | 0x06 | Move to Hue and Saturation | O | - * | 0x07 | Move to Color | M | - * | 0x08 | Move Color | M | - * | 0x09 | Step Color | M | - * | 0x0a | Move to Color Temperature | O | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for move to hue - * @details On receipt of this command, a device shall also set the ColorMode attribute to the - * value 0x00 and then shall move from its current hue to the value given in the Hue - * field. \n\n - * The movement shall be continuous, i.e. not a step function, and the time taken to - * move to the new hue shall be equal to the Transition time field.\n\n - * As hue is effectively measured on a circle, the new hue may be moved to in either - * direction. The direction of hue change is given by the Direction field. If Direction - * is 'Shortest distance', the direction is taken that involves the shortest path round - * the circle. This case corresponds to expected normal usage. If Direction is - * 'Longest distance', the direction is taken that involves the longest path round the - * circle. This case can be used for 'rainbow effects'. In both cases, if both distances - * are the same, the Up direction shall be taken.\n\n - * Note that if the target color specified is not achievable by the hardware then the - * command shall not be carried out, and a ZCL default response command shall be - * generated, where not disabled, with status code equal to INVALID_VALUE.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] hue The Hue field specifies the hue to be moved to. - * @param[in] direction The direction field shall be one of the non-reserved values\n - * 0x00 : Shortest distance\n - * 0x01 : Longest distance\n - * 0x02 : Up\n - * 0x03 : Down\n - * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, - * the time that shall be taken to move to the new hue - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_move_to_hue( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char hue, - unsigned char direction, - unsigned short transition_time); - -/** - * @brief Command description for move hue - * @details On receipt of this command, a device shall set the ColorMode attribute to the - * value 0x00 and shall then move from its current hue in an up or down direction in - * a continuous fashion. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] move_mode The Move mode field shall be one of the non-reserved values.\n - * 0x00 : Stop\n - * 0x01 : Up\n - * 0x02 : Reserved\n - * 0x03 : Down\n - * @param[in] rate The Rate field specifies the rate of movement in steps per second.\n - * A step is a change in the device's hue of one unit. - * If the Rate field has a value of zero, the command has no effect and - * a default response command is sent in response, with the status code - * set to INVALID_FIELD.\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_move_hue( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char move_mode, - unsigned char rate); - -/** - * @brief Command description for step hue - * @details On receipt of this command, a device shall set the ColorMode attribute to the - * value 0x00 and shall then move from its current hue in an up or down direction by - * one step. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] step_mode The Step mode field shall be one of the non-reserved values.\n - * 0x00 : Reserved\n - * 0x01 : Up\n - * 0x02 : Reserved\n - * 0x03 : Down\n - * @param[in] step_size The change to be added to (or subtracted from) the current value \n - * of the device's hue. - * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, - * the time that shall be taken to perform the step. - * A step is a change in the device's hue of 'Step size' units. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_step_hue( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char step_mode, - unsigned char step_size, - unsigned char transition_time); - -/** - * @brief Command description for move to saturation - * @details On receipt of this command, a device set the ColorMode attribute to the value - * 0x00 and shall then move from its current saturation to the value given in the - * Saturation field.\n\n - * The movement shall be continuous, i.e. not a step function, and the time taken to - * move to the new saturation shall be equal to the Transition time field, in 1/10ths of - * a second.n\n - * Note that if the target color specified is not achievable by the hardware then the - * command shall not be carried out and a ZCL default response command shall be - * generated, where not disabled, with status code equal to INVALID_VALUE. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] saturation The target saturation value - * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, - * the time that shall be taken to perform the step. - * A step is a change in the device's hue of 'Step size' units. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_move_to_saturation( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char saturation, - unsigned short transition_time); - -/** - * @brief Command description for move saturation - * @details On receipt of this command, a device shall set the ColorMode attribute to the - * value 0x00 and shall then move from its current saturation in an up or down - * direction in a continuous fashion.\n]n - * Note that if the target color specified is not achievable by the hardware then the - * command shall not be carried out and a ZCL default response command shall be - * generated, where not disabled, with status code equal to INVALID_VALUE - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] move_mode The Move mode field shall be one of the non-reserved values.\n - * 0x00 : Stop\n - * 0x01 : Up\n - * 0x02 : Reserved\n - * 0x03 : Down\n - * @param[in] rate The Rate field specifies the rate of movement in steps per second.\n - * A step is a change in the device's hue of one unit. - * If the Rate field has a value of zero, the command has no effect and - * a default response command is sent in response, with the status code - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_move_saturation( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char move_mode, - unsigned char rate); - -/** - * @brief Command description for step saturation - * @details On receipt of this command, a device shall set the ColorMode attribute to the - * value 0x00 and shall then move from its current saturation in an up or down - * direction in a continuous fashion.\n]n - * Note that if the target color specified is not achievable by the hardware then the - * command shall not be carried out and a ZCL default response command shall be - * generated, where not disabled, with status code equal to INVALID_VALUE - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] step_mode The Step mode field shall be one of the non-reserved values.\n - * 0x00 : Reserved\n - * 0x01 : Up\n - * 0x02 : Reserved\n - * 0x03 : Down\n - * @param[in] step_size The change to be added to (or subtracted from) the current value \n - * of the device's hue. - * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, - * the time that shall be taken to perform the step. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_step_saturation( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char step_mode, - unsigned char step_size, - unsigned char transition_time); - -/** - * @brief Command description for move to hue and saturation - * @details On receipt of this command, a device shall set the ColorMode attribute to the - * value 0x00 and shall then move from its current hue and saturation to the values - * given in the Hue and Saturation fields.\n\n - * The movement shall be continuous, i.e. not a step function, and the time taken to - * move to the new color shall be equal to the Transition time field, in 1/10ths of a - * second.\n\n - * The path through color space taken during the transition is not specified, but it is - * recommended that the shortest path is taken though hue/saturation space, i.e. - * movement is 'in a straight line' across the hue/saturation disk.\n\n - * Note that if the target color specified is not achievable by the hardware then the - * command shall not be carried out and a ZCL default response command shall be - * generated, where not disabled, with status code equal to INVALID_VALUE - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] hue The Hue field specifies the hue to be moved to. - * @param[in] saturation The target saturation value - * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, - * the time that shall be taken to perform the step. - * A step is a change in the device's hue of 'Step size' units. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_move_to_hue_and_saturation( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char hue, - unsigned char saturation, - unsigned short transition_time); - -/** - * @brief Command description for move to color - * @details On receipt of this command, a device shall set the value of the ColorMode - * attribute, where implemented, to 0x01, and shall then move from its current color - * to the color given in the ColorX and ColorY fields.\n\n - * The movement shall be continuous, i.e. not a step function, and the time taken to - * move to the new color shall be equal to the Transition time field, in 1/10ths of a - * second.\n\n - * The path through color space taken during the transition is not specified, but it is - * recommended that the shortest path is taken though color space, i.e. movement is - * 'in a straight line' across the CIE xyY Color Space.\n\n - * Note that if the target color specified is not achievable by the hardware then the - * command shall not be carried out, and a ZCL default response command shall be - * generated, where not disabled, with status code equal to INVALID_VALUE\n\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] color_x Target color position x - * @param[in] color_y Target color position y - * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, - * the time that shall be taken to perform the step. - * A step is a change in the device's hue of 'Step size' units. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_move_to_color( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short color_x, - unsigned short color_y, - unsigned short transition_time); - -/** - * @brief Command description for move color - * @details On receipt of this command, a device shall set the value of the ColorMode - * attribute, where implemented, to 0x01, and shall then move from its current color - * in a continuous fashion according to the rates specified. This movement shall - * continue until the target color for the next step cannot be implemented on this - * device.\n\n - * If both the RateX and RateY fields contain a value of zero, no movement shall be - * carried out, and the command execution shall have no effect other than stopping - * the operation of any previously received command of this cluster. This command - * can thus be used to stop the operation of any other command of this cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] rate_x The RateX field specifies the rate of movement in steps per second. - * A step is a change in the device's CurrentX attribute of one unit. - * @param[in] rate_y The RateY field specifies the rate of movement in steps per second. - * A step is a change in the device's CurrentY attribute of one unit. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_move_color( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short rate_x, - unsigned short rate_y); - -/** - * @brief Command description for step color - * @details On receipt of this command, a device shall set the value of the ColorMode - * attribute, where implemented, to 0x01, and shall then move from its current color - * by the color step indicated.\n\n - * The movement shall be continuous, i.e. not a step function, and the time taken to - * move to the new color shall be equal to the Transition time field, in 1/10ths of a - * second.\n\n - * The path through color space taken during the transition is not specified, but it is - * recommended that the shortest path is taken though color space, i.e. movement is - * 'in a straight line' across the CIE xyY Color Space.\n\n - * Note that if the target color specified is not achievable by this hardware then - * command shall not be carried out, and a ZCL default response command shall be - * generated, where not disabled, with status code equal to INVALID_VALUE\n\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] step_x The StepX and StepY fields specify the change to be added to the device's - * CurrentX attribute and CurrentY attribute respectively. - * @param[in] step_y The StepX and StepY fields specify the change to be added to the device's - * CurrentX attribute and CurrentY attribute respectively. - * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, - * the time that shall be taken to perform the step. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_step_color( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short step_x, - unsigned short step_y, - unsigned short transition_time); - -/** - * @brief Command description for move to color temperature - * @details On receipt of this command, a device shall set the value of the ColorMode - * attribute, where implemented, to 0x02, and shall then move from its current color - * to the color given by the Color Temperature field.\n\n - * The movement shall be continuous, i.e. not a step function, and the time taken to - * move to the new color shall be equal to the Transition time field, in 1/10ths of a - * second.\n\n - * By definition of this color mode, the path through color space taken during the - * transition is along the 'Black Body Line'.\n\n - * Note that if the target color specified is not achievable by the hardware then the - * command shall not be carried out, and a ZCL default response command shall be - * generated, where not disabled, with status code equal to INVALID_VALUE.\n\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] color_temperature The target color temperature value - * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, - * the time that shall be taken to perform the step. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_ccontrol_move_to_color_temperature( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short color_temperature, - unsigned short transition_time); - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-commands.h b/include/zcl/zb-zcl-commands.h deleted file mode 100644 index edfec8f..0000000 --- a/include/zcl/zb-zcl-commands.h +++ /dev/null @@ -1,734 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_COMMAND_IDS_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_COMMAND_IDS_H__ - -/** - * @file zb-zcl-color-control-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE Cluster Commands - * - * @brief zigbee color control cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/** - * @brief Global commands (Either direction) - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_READ_ATTRIBUTES_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_READ_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_WRITE_ATTRIBUTES_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_WRITE_ATTRIBUTES_UNDIVIDED_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_WRITE_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_WRITE_ATTRIBUTES_NO_RESPONSE_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_CONFIGURE_REPORTING_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_CONFIGURE_REPORTING_RESPONSE_COMMAND_ID = 0x07, /**< Ver.: always */ - ZB_ZCL_READ_REPORTING_CONFIGURATION_COMMAND_ID = 0x08, /**< Ver.: always */ - ZB_ZCL_READ_REPORTING_CONFIGURATION_RESPONSE_COMMAND_ID = 0x09, /**< Ver.: always */ - ZB_ZCL_REPORT_ATTRIBUTES_COMMAND_ID = 0x0A, /**< Ver.: always */ - ZB_ZCL_DEFAULT_RESPONSE_COMMAND_ID = 0x0B, /**< Ver.: always */ - ZB_ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID = 0x0C, /**< Ver.: always */ - ZB_ZCL_DISCOVER_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x0D, /**< Ver.: always */ - ZB_ZCL_READ_ATTRIBUTES_STRUCTURED_COMMAND_ID = 0x0E, /**< Ver.: always */ - ZB_ZCL_WRITE_ATTRIBUTES_STRUCTURED_COMMAND_ID = 0x0F, /**< Ver.: always */ - ZB_ZCL_WRITE_ATTRIBUTES_STRUCTURED_RESPONSE_COMMAND_ID = 0x10, /**< Ver.: always */ - ZB_ZCL_DISCOVER_COMMANDS_RECEIVED_COMMAND_ID = 0x11, /**< Ver.: always */ - ZB_ZCL_DISCOVER_COMMANDS_RECEIVED_RESPONSE_COMMAND_ID = 0x12, /**< Ver.: always */ - ZB_ZCL_DISCOVER_COMMANDS_GENERATED_COMMAND_ID = 0x13, /**< Ver.: always */ - ZB_ZCL_DISCOVER_COMMANDS_GENERATED_RESPONSE_COMMAND_ID = 0x14, /**< Ver.: always */ - ZB_ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID = 0x15, /**< Ver.: always */ - ZB_ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID = 0x16, /**< Ver.: always */ -} zb_zcl_global_commands_e; - -/** - * @brief Command types for cluster: Basic - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID = 0x00, /**< Ver.: always */ -} zb_zcl_basic_client_commands_e; - -/** - * @brief Command types for cluster: Identify - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ -} zb_zcl_identify_server_commands_e; - -/** - * @brief Command types for cluster: Identify - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_IDENTIFY_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_IDENTIFY_QUERY_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_E_Z_MODE_INVOKE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_UPDATE_COMMISSION_STATE_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_TRIGGER_EFFECT_COMMAND_ID = 0x40, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_identify_client_commands_e; - -/** - * @brief Command types for cluster: Groups - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ADD_GROUP_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID = 0x03, /**< Ver.: always */ -} zb_zcl_group_server_commands_e; - -// Client to server -typedef enum { - ZB_ZCL_ADD_GROUP_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_VIEW_GROUP_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_GET_GROUP_MEMBERSHIP_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_REMOVE_GROUP_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_REMOVE_ALL_GROUPS_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID = 0x05, /**< Ver.: always */ -} zb_zcl_group_client_commands_e; - -/** - * @brief Command types for cluster: Scenes - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ADD_SCENE_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_VIEW_SCENE_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_REMOVE_SCENE_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_STORE_SCENE_RESPONSE_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_ENHANCED_ADD_SCENE_RESPONSE_COMMAND_ID = 0x40, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ENHANCED_VIEW_SCENE_RESPONSE_COMMAND_ID = 0x41, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COPY_SCENE_RESPONSE_COMMAND_ID = 0x42, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_scenes_server_commands_e; - -/** - * @brief Command types for cluster: Scenes - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ADD_SCENE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_VIEW_SCENE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_REMOVE_SCENE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_REMOVE_ALL_SCENES_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_STORE_SCENE_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_RECALL_SCENE_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_GET_SCENE_MEMBERSHIP_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_ENHANCED_ADD_SCENE_COMMAND_ID = 0x40, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ENHANCED_VIEW_SCENE_COMMAND_ID = 0x41, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COPY_SCENE_COMMAND_ID = 0x42, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_scenes_client_commands_e; - -/** - * @brief Command types for cluster: On/off - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_OFF_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_ON_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_TOGGLE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_OFF_WITH_EFFECT_COMMAND_ID = 0x40, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID = 0x41, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ON_WITH_TIMED_OFF_COMMAND_ID = 0x42, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_SAMPLE_MFG_SPECIFIC_OFF_WITH_TRANSITION_COMMAND_ID = 0x00, /**< Ver.: always mfgCode: 0x1002 */ - ZB_ZCL_SAMPLE_MFG_SPECIFIC_ON_WITH_TRANSITION_COMMAND_ID = 0x01, /**< Ver.: always mfgCode: 0x1002 */ - ZB_ZCL_SAMPLE_MFG_SPECIFIC_TOGGLE_WITH_TRANSITION_COMMAND_ID = 0x02, /**< Ver.: always mfgCode: 0x1002 */ -} zb_zcl_on_off_client_commands_e; - -/** - * @brief Command types for cluster: Level Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_MOVE_TO_LEVEL_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_MOVE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_STEP_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_STOP_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_MOVE_TO_LEVEL_WITH_ON_OFF_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_MOVE_WITH_ON_OFF_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_STEP_WITH_ON_OFF_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_STOP_WITH_ON_OFF_COMMAND_ID = 0x07, /**< Ver.: always */ -} zb_zcl_level_control_client_commands_e; - -/** - * @brief Command types for cluster: Alarms - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ALARM_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_GET_ALARM_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ -} zb_zcl_alarms_server_commands_e; - -/** - * @brief Command types for cluster: Alarms - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_RESET_ALARM_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_RESET_ALL_ALARMS_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_GET_ALARM_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_RESET_ALARM_LOG_COMMAND_ID = 0x03, /**< Ver.: always */ -} zb_zcl_alarms_client_commands_e; - -/** - * @brief Command types for cluster: RSSI Location - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_DEVICE_CONFIGURATION_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_LOCATION_DATA_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_LOCATION_DATA_NOTIFICATION_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_COMPACT_LOCATION_DATA_NOTIFICATION_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_RSSI_PING_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_RSSI_REQUEST_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_REPORT_RSSI_MEASUREMENTS_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_REQUEST_OWN_LOCATION_COMMAND_ID = 0x07, /**< Ver.: always */ -} zb_zcl_rssi_location_server_commands_e; - -/** - * @brief Command types for cluster: RSSI Location - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SET_ABSOLUTE_LOCATION_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_SET_DEVICE_CONFIGURATION_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_GET_DEVICE_CONFIGURATION_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_GET_LOCATION_DATA_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_RSSI_RESPONSE_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_SEND_PINGS_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_ANCHOR_NODE_ANNOUNCE_COMMAND_ID = 0x06, /**< Ver.: always */ -} zb_zcl_rssi_location_client_commands_e; - -/** - * @brief Command types for cluster: Commissioning - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_RESTART_DEVICE_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_SAVE_STARTUP_PARAMETERS_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_RESTORE_STARTUP_PARAMETERS_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_RESET_STARTUP_PARAMETERS_RESPONSE_COMMAND_ID = 0x03, /**< Ver.: always */ -} zb_zcl_commissioning_server_commands_e; - -/** - * @brief Command types for cluster: Commissioning - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_RESTART_DEVICE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_SAVE_STARTUP_PARAMETERS_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_RESTORE_STARTUP_PARAMETERS_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_RESET_STARTUP_PARAMETERS_COMMAND_ID = 0x03, /**< Ver.: always */ -} zb_zcl_commissioning_client_commands_e; - -/** - * @brief Command types for cluster: Partition - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_MULTIPLE_ACK_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_READ_HANDSHAKE_PARAM_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ -} zb_zcl_partition_server_commands_e; - -/** - * @brief Command types for cluster: Partition - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_TRANSFER_PARTITIONED_FRAME_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_READ_HANDSHAKE_PARAM_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_WRITE_HANDSHAKE_PARAM_COMMAND_ID = 0x02, /**< Ver.: always */ -} zb_zcl_partition_client_commands_e; - -/** - * @brief Command types for cluster: Over the Air Bootloading - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_IMAGE_NOTIFY_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_QUERY_NEXT_IMAGE_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_IMAGE_BLOCK_RESPONSE_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_UPGRADE_END_RESPONSE_COMMAND_ID = 0x07, /**< Ver.: always */ - ZB_ZCL_QUERY_SPECIFIC_FILE_RESPONSE_COMMAND_ID = 0x09, /**< Ver.: always */ -} zb_zcl_over_the_air_bootloading_server_commands_e; - -/** - * @brief Command types for cluster: Over the Air Bootloading - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_QUERY_NEXT_IMAGE_REQUEST_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_IMAGE_BLOCK_REQUEST_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_IMAGE_PAGE_REQUEST_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_UPGRADE_END_REQUEST_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_QUERY_SPECIFIC_FILE_REQUEST_COMMAND_ID = 0x08, /**< Ver.: always */ -} zb_zcl_over_the_air_bootloading_client_commands_e; - -/** - * @brief Command types for cluster: Power Profile - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_POWER_PROFILE_NOTIFICATION_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_POWER_PROFILE_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_POWER_PROFILE_STATE_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_GET_POWER_PROFILE_PRICE_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_POWER_PROFILES_STATE_NOTIFICATION_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_GET_OVERALL_SCHEDULE_PRICE_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_ENERGY_PHASES_SCHEDULE_REQUEST_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_ENERGY_PHASES_SCHEDULE_STATE_RESPONSE_COMMAND_ID = 0x07, /**< Ver.: always */ - ZB_ZCL_ENERGY_PHASES_SCHEDULE_STATE_NOTIFICATION_COMMAND_ID = 0x08, /**< Ver.: always */ - ZB_ZCL_POWER_PROFILE_SCHEDULE_CONSTRAINTS_NOTIFICATION_COMMAND_ID = 0x09, /**< Ver.: always */ - ZB_ZCL_POWER_PROFILE_SCHEDULE_CONSTRAINTS_RESPONSE_COMMAND_ID = 0x0A, /**< Ver.: always */ - ZB_ZCL_GET_POWER_PROFILE_PRICE_EXTENDED_COMMAND_ID = 0x0B, /**< Ver.: always */ -} zb_zcl_power_profile_server_commands_e; - -/** - * @brief Command types for cluster: Power Profile - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_POWER_PROFILE_REQUEST_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_POWER_PROFILE_STATE_REQUEST_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_GET_POWER_PROFILE_PRICE_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_GET_OVERALL_SCHEDULE_PRICE_RESPONSE_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_ENERGY_PHASES_SCHEDULE_NOTIFICATION_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_ENERGY_PHASES_SCHEDULE_RESPONSE_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_POWER_PROFILE_SCHEDULE_CONSTRAINTS_REQUEST_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_ENERGY_PHASES_SCHEDULE_STATE_REQUEST_COMMAND_ID = 0x07, /**< Ver.: always */ - ZB_ZCL_GET_POWER_PROFILE_PRICE_EXTENDED_RESPONSE_COMMAND_ID = 0x08, /**< Ver.: always */ -} zb_zcl_power_profile_client_commands_e; - -/** - * @brief Command types for cluster: Appliance Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SIGNAL_STATE_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_SIGNAL_STATE_NOTIFICATION_COMMAND_ID = 0x01, /**< Ver.: always */ -} zb_zcl_appliance_control_server_commands_e; - -/** - * @brief Command types for cluster: Appliance Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_EXECUTION_OF_A_COMMAND_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_SIGNAL_STATE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_WRITE_FUNCTIONS_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_OVERLOAD_PAUSE_RESUME_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_OVERLOAD_PAUSE_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_OVERLOAD_WARNING_COMMAND_ID = 0x05, /**< Ver.: always */ -} zb_zcl_appliance_control_client_commands_e; - -/** - * @brief Command types for cluster: Poll Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_CHECK_IN_COMMAND_ID = 0x00, /**< Ver.: always */ -} zb_zcl_poll_control_server_commands_e; - -/** - * @brief Command types for cluster: Poll Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_CHECK_IN_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_FAST_POLL_STOP_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_SET_LONG_POLL_INTERVAL_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_SET_SHORT_POLL_INTERVAL_COMMAND_ID = 0x03, /**< Ver.: always */ -} zb_zcl_poll_control_client_commands_e; - -/** - * @brief Command types for cluster: Door Lock - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_UNLOCK_DOOR_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_TOGGLE_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_UNLOCK_WITH_TIMEOUT_RESPONSE_COMMAND_ID = 0x03, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_LOG_RECORD_RESPONSE_COMMAND_ID = 0x04, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_PIN_RESPONSE_COMMAND_ID = 0x05, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_PIN_RESPONSE_COMMAND_ID = 0x06, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_PIN_RESPONSE_COMMAND_ID = 0x07, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_ALL_PINS_RESPONSE_COMMAND_ID = 0x08, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_USER_STATUS_RESPONSE_COMMAND_ID = 0x09, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_USER_STATUS_RESPONSE_COMMAND_ID = 0x0A, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0B, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0C, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0D, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0E, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0F, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x10, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x11, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x12, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x13, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_USER_TYPE_RESPONSE_COMMAND_ID = 0x14, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_USER_TYPE_RESPONSE_COMMAND_ID = 0x15, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_RFID_RESPONSE_COMMAND_ID = 0x16, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_RFID_RESPONSE_COMMAND_ID = 0x17, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_RFID_RESPONSE_COMMAND_ID = 0x18, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_ALL_RFIDS_RESPONSE_COMMAND_ID = 0x19, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_OPERATION_EVENT_NOTIFICATION_COMMAND_ID = 0x20, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_PROGRAMMING_EVENT_NOTIFICATION_COMMAND_ID = 0x21, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_door_lock_server_commands_e; - -/** - * @brief Command types for cluster: Door Lock - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_LOCK_DOOR_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_UNLOCK_DOOR_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_DOOR_TOGGLE_COMMAND_ID = 0x02, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_UNLOCK_WITH_TIMEOUT_COMMAND_ID = 0x03, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_LOG_RECORD_COMMAND_ID = 0x04, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_PIN_COMMAND_ID = 0x05, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_PIN_COMMAND_ID = 0x06, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_PIN_COMMAND_ID = 0x07, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_ALL_PINS_COMMAND_ID = 0x08, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_USER_STATUS_COMMAND_ID = 0x09, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_USER_STATUS_COMMAND_ID = 0x0A, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_WEEKDAY_SCHEDULE_COMMAND_ID = 0x0B, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_WEEKDAY_SCHEDULE_COMMAND_ID = 0x0C, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_WEEKDAY_SCHEDULE_COMMAND_ID = 0x0D, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_YEARDAY_SCHEDULE_COMMAND_ID = 0x0E, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_YEARDAY_SCHEDULE_COMMAND_ID = 0x0F, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_YEARDAY_SCHEDULE_COMMAND_ID = 0x10, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_HOLIDAY_SCHEDULE_COMMAND_ID = 0x11, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_HOLIDAY_SCHEDULE_COMMAND_ID = 0x12, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_HOLIDAY_SCHEDULE_COMMAND_ID = 0x13, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_USER_TYPE_COMMAND_ID = 0x14, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_USER_TYPE_COMMAND_ID = 0x15, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_SET_RFID_COMMAND_ID = 0x16, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_RFID_COMMAND_ID = 0x17, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_RFID_COMMAND_ID = 0x18, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_ALL_RFIDS_COMMAND_ID = 0x19, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_door_lock_client_commands_e; - -/** - * @brief Command types for cluster: Window Covering - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_WINDOW_COVERING_UP_OPEN_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_WINDOW_COVERING_DOWN_CLOSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_WINDOW_COVERING_STOP_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_WINDOW_COVERING_GO_TO_LIFT_VALUE_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_WINDOW_COVERING_GO_TO_TILT_VALUE_COMMAND_ID = 0x07, /**< Ver.: always */ - ZB_ZCL_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE_COMMAND_ID = 0x08, /**< Ver.: always */ -} zb_zcl_window_covering_client_commands_e; - -/** - * @brief Command types for cluster: Thermostat - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_CURRENT_WEEKLY_SCHEDULE_COMMAND_ID = 0x00, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_RELAY_STATUS_LOG_COMMAND_ID = 0x01, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_thermostat_server_commands_e; - -/** - * @brief Command types for cluster: Thermostat - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SETPOINT_RAISE_LOWER_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_SET_WEEKLY_SCHEDULE_COMMAND_ID = 0x01, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_WEEKLY_SCHEDULE_COMMAND_ID = 0x02, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_CLEAR_WEEKLY_SCHEDULE_COMMAND_ID = 0x03, /**< Ver.: since ha-1.2-05-3520-29 */ - ZB_ZCL_GET_RELAY_STATUS_LOG_COMMAND_ID = 0x04, /**< Ver.: since ha-1.2-05-3520-29 */ -} zb_zcl_thermostat_client_commands_e; - -/** - * @brief Command types for cluster: Color Control - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_MOVE_TO_HUE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_MOVE_HUE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_STEP_HUE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_MOVE_TO_SATURATION_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_MOVE_SATURATION_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_STEP_SATURATION_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_MOVE_TO_COLOR_COMMAND_ID = 0x07, /**< Ver.: always */ - ZB_ZCL_MOVE_COLOR_COMMAND_ID = 0x08, /**< Ver.: always */ - ZB_ZCL_STEP_COLOR_COMMAND_ID = 0x09, /**< Ver.: always */ - ZB_ZCL_MOVE_TO_COLOR_TEMPERATURE_COMMAND_ID = 0x0A, /**< Ver.: always */ - ZB_ZCL_ENHANCED_MOVE_TO_HUE_COMMAND_ID = 0x40, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ENHANCED_MOVE_HUE_COMMAND_ID = 0x41, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ENHANCED_STEP_HUE_COMMAND_ID = 0x42, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ENHANCED_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID = 0x43, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_COLOR_LOOP_SET_COMMAND_ID = 0x44, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_STOP_MOVE_STEP_COMMAND_ID = 0x47, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_MOVE_COLOR_TEMPERATURE_COMMAND_ID = 0x4B, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_STEP_COLOR_TEMPERATUE_COMMAND_ID = 0x4C, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_color_control_client_commands_e; - -/** - * @brief Command types for cluster: IAS Zone - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ZONE_STATUS_CHANGE_NOTIFICATION_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_ZONE_ENROLL_REQUEST_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_INITIATE_NORMAL_OPERATION_MODE_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_INITIATE_TEST_MODE_RESPONSE_COMMAND_ID = 0x03, /**< Ver.: always */ -} zb_zcl_ias_zone_server_commands_e; - -/** - * @brief Command types for cluster: IAS Zone - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ZONE_ENROLL_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_INITIATE_NORMAL_OPERATION_MODE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_INITIATE_TEST_MODE_COMMAND_ID = 0x02, /**< Ver.: always */ -} zb_zcl_ias_zone_client_commands_e; - -/** - * @brief Command types for cluster: IAS ACE - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ARM_RESPONSE_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_GET_ZONE_ID_MAP_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_GET_ZONE_INFORMATION_RESPONSE_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_ZONE_STATUS_CHANGED_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_PANEL_STATUS_CHANGED_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_GET_PANEL_STATUS_RESPONSE_COMMAND_ID = 0x05, /**< Ver.: since ha-1.2.1-05-3520-30 */ - ZB_ZCL_SET_BYPASSED_ZONE_LIST_COMMAND_ID = 0x06, /**< Ver.: since ha-1.2.1-05-3520-30 */ - ZB_ZCL_BYPASS_RESPONSE_COMMAND_ID = 0x07, /**< Ver.: since ha-1.2.1-05-3520-30 */ - ZB_ZCL_GET_ZONE_STATUS_RESPONSE_COMMAND_ID = 0x08, /**< Ver.: since ha-1.2.1-05-3520-30 */ -} zb_zcl_ias_ace_server_commands_e; - -/** - * @brief Command types for cluster: IAS ACE - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_ARM_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_BYPASS_COMMAND_ID = 0x01, /**< Ver.: always */ - ZB_ZCL_EMERGENCY_COMMAND_ID = 0x02, /**< Ver.: always */ - ZB_ZCL_FIRE_COMMAND_ID = 0x03, /**< Ver.: always */ - ZB_ZCL_PANIC_COMMAND_ID = 0x04, /**< Ver.: always */ - ZB_ZCL_GET_ZONE_ID_MAP_COMMAND_ID = 0x05, /**< Ver.: always */ - ZB_ZCL_GET_ZONE_INFORMATION_COMMAND_ID = 0x06, /**< Ver.: always */ - ZB_ZCL_GET_PANEL_STATUS_COMMAND_ID = 0x07, /**< Ver.: since ha-1.2.1-05-3520-30 */ - ZB_ZCL_GET_BYPASSED_ZONE_LIST_COMMAND_ID = 0x08, /**< Ver.: since ha-1.2.1-05-3520-30 */ - ZB_ZCL_GET_ZONE_STATUS_COMMAND_ID = 0x09, /**< Ver.: since ha-1.2.1-05-3520-30 */ -} zb_zcl_ias_ace_client_commands_e; - -/** - * @brief Command types for cluster: IAS WD - * @details Cluster specification level: zcl-1.0-07-5123-03 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_START_WARNING_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_SQUAWK_COMMAND_ID = 0x01, /**< Ver.: always */ -} zb_zcl_ias_wd_client_commands_e; - - -/** - * @brief Command types for cluster: Electrical Measurement - * @details Cluster specification level: UNKNOWN - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_GET_PROFILE_INFO_RESPONSE_COMMAND_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_GET_MEASUREMENT_PROFILE_RESPONSE_COMMAND_COMMAND_ID = 0x01, /**< Ver.: always */ -} zb_zcl_electrical_measurement_server_commands_e; - -/** - * @brief Command types for cluster: Electrical Measurement - * @details Cluster specification level: UNKNOWN - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_GET_PROFILE_INFO_COMMAND_COMMAND_ID = 0x00, /**< Ver.: always */ - ZB_ZCL_GET_MEASUREMENT_PROFILE_COMMAND_COMMAND_ID = 0x01, /**< Ver.: always */ -} zb_zcl_electrical_measurement_client_commands_e; - -/** - * @brief Command types for cluster: ZLL Commissioning - * @details Cluster specification level: zll-1.0-11-0037-10 - * @remark Direction : Server to Client - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SCAN_RESPONSE_COMMAND_ID = 0x01, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_DEVICE_INFORMATION_RESPONSE_COMMAND_ID = 0x03, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_NETWORK_START_RESPONSE_COMMAND_ID = 0x11, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_NETWORK_JOIN_ROUTER_RESPONSE_COMMAND_ID = 0x13, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_NETWORK_JOIN_END_DEVICE_RESPONSE_COMMAND_ID = 0x15, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_ENDPOINT_INFORMATION_COMMAND_ID = 0x40, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_GET_GROUP_IDENTIFIERS_RESPONSE_COMMAND_ID = 0x41, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID = 0x42, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_zll_commissioning_server_commands_e; - -/** - * @brief Command types for cluster: ZLL Commissioning - * @details Cluster specification level: zll-1.0-11-0037-10 - * @remark Direction : Client to Server - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SCAN_REQUEST_COMMAND_ID = 0x00, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_DEVICE_INFORMATION_REQUEST_COMMAND_ID = 0x02, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_IDENTIFY_REQUEST_COMMAND_ID = 0x06, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_RESET_TO_FACTORY_NEW_REQUEST_COMMAND_ID = 0x07, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_NETWORK_START_REQUEST_COMMAND_ID = 0x10, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_NETWORK_JOIN_ROUTER_REQUEST_COMMAND_ID = 0x12, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_NETWORK_JOIN_END_DEVICE_REQUEST_COMMAND_ID = 0x14, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_NETWORK_UPDATE_REQUEST_COMMAND_ID = 0x16, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_GET_GROUP_IDENTIFIERS_REQUEST_COMMAND_ID = 0x41, /**< Ver.: since zll-1.0-11-0037-10 */ - ZB_ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID = 0x42, /**< Ver.: since zll-1.0-11-0037-10 */ -} zb_zcl_zll_commissioning_client_commands_e; - -/** - * @} - */ -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_COMMAND_IDS_H__ */ diff --git a/include/zcl/zb-zcl-door-lock-cluster.h b/include/zcl/zb-zcl-door-lock-cluster.h deleted file mode 100644 index 29d5de8..0000000 --- a/include/zcl/zb-zcl-door-lock-cluster.h +++ /dev/null @@ -1,1488 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_DOOR_LOCK_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_DOOR_LOCK_CLUSTER_H__ - -#ifdef ZB_SUPPORT_PRIORITY_5 - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-on-off-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_DOOR_LOCK_CLUSTER_MODULE Door Lock Cluster - * - * @brief zigbee door lock cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_DOOR_LOCK_CLUSTER_MODULEE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 10.13 Commands Generated by the Server Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Lock Door Response | M | - * | 0x01 | Unlock Door Response | M | - * | 0x02 | Toogle Response | O | - * | 0x03 | Unlock with Timeout Response | O | - * | 0x04 | Get Log Record Response | O | - * | 0x05 | Set PIN Code Response | O | - * | 0x06 | Get PIN Code Response | O | - * | 0x07 | Clear PIN Code | O | - * | 0x09 | Set User Status Response | O | - * | 0x0a | Get User Status Response | O | - * | 0x0b | Set Week Day Schedule Response | O | - * | 0x0c | Get Week Day Schedule Response | O | - * | 0x0d | Clear Week Day Schedule Response | O | - * | 0x0e | Set Year Day Schedule Response | O | - * | 0x0f | Get Year Day Schedule Response | O | - * | 0x10 | Clear Year Day Schedule Response | O | - * | 0x11 | Set Holiday Schedule Response | O | - * | 0x12 | Get Holiday Schedule Response | O | - * | 0x13 | Set User Type Response | O | - * | 0x14 | Get User Type Response | O | - * | 0x15 | Set RFID Code Response | O | - * | 0x16 | Get RFID Code Response | O | - * | 0x17 | Clear RFID Code Response | O | - * | 0x18 | Clear All RFID Codes Response | O | - * | 0x19 | Move to Level | O | - * | 0x20 | Operation Event Notification | O | - * | 0x21 | Programming Event Notification | O | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for lock response - * @details This command is sent in response to a commands with one status byte payload. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] status 0=Success \n - * 1=General failure \n - * 2=Memory full \n - * 3=Duplicate code error - * @param[out] user_data User data - * - * @see zb_zcl_door_lock_lock() - */ -typedef void (*zb_zcl_doorlock_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - void *user_data); - - -/** - * @brief Command description for get log record response - * @details Returns the specified log record. If an invalid log entry ID was requested, - * it is set to 0 and the most recent log entry will be returned. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] log_entry_id the index into the log table where this log entry is stored.\n - * If the log entry requested is 0, the most recent log is returned - * with the appropriate log entry ID. - * @param[out] timestamp A ZigBee LocalTime used to timestamp all events and alarms on the - * door lock. - * @param[out] event_type Indicate the type of event that took place on the door lock.\n\n - * 0x00 = Operation\n - * 0x01 = Programming\n - * 0x02 = Alarm\n - * @param[out] alarm A source value where a available sources are :\n\n - * 0x00 = Keypad\n - * 0x01 = RF\n - * 0x02 = Manual\n - * 0x02 = RFID\n - * 0xff = Indeterminate\n - * @param[out] event_id A one byte value indicating the type of event that took place on - * the door lock depending on the event code table provided for - * a given event type and source. - * @param[out] user_id A two byte value indicating the ID of the user who generated the - * event on the door lock if one is available. If none is available, - * 0xffff has to be used. - * @param[out] pin A ZigBee string indicating the PIN code or RFID code that was used to - * create the event on the door lock if one is available. - * @param[out] user_data User data - * - * @see zb_zcl_door_lock_get_log_record() - */ -typedef void (*zb_zcl_doorlock_get_log_record_rsp)( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short log_entry_id, - unsigned int timestamp, - unsigned char event_type, - unsigned char source, - unsigned char event_id, - unsigned char user_id, - const char *pin, - void *user_data); - -/** - * @brief Command description for get pin code response - * @details Returns the PIN for the specified user ID - * If the requested user ID is valid and the Code doesn't exist, Get RFID Code - * Response shall have the following format:\n\n - * UserId = requested UserId\n - * UserStatus = 0 (available)\n - * UserType = 0xFF (not supported)\n - * RFID = 0 (zero length)\n\n - * If requested user ID is invalid, send Default Response with an error status not - * equal to ZCL_SUCCESS(0x00). - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] user_id Requested user ID - * @param[out] user_status Used to indicate what the status is for a specific user ID. - * 0 - Available\n - * 1 - Occupied / Enabled\n - * 2 - Reserved\n - * 3 - Occupied / Disable\n - * 0xff - Not supported\n - * @param[out] user_type Used to indicate what the type is for a specific user ID.\n - * 0 - Unrestricted User (default)\n - * 1 - Year Day Schedule User\n - * 2 - Week Day Schedule User\n - * 3 - Master User\n - * 4 - Non Access User\n - * 0xff - Not supported\n - * Cf) User Type - * - Unrestricted User\n - * User has access 24/7 provided proper PIN is supplied (e.g., owner). Unrestricted - * user type is the default user type. - * - Year Day Schedule User\n - * User has ability to open lock within a specific time period (e.g., guest). - * - Week Day Schedule User\n - * User has ability to open lock based on specific time period within a reoccurring - * weekly schedule (e.g., cleaning worker). - * - Master User\n - * User has ability to both program and operate the door lock. This user can manage - * the users and user schedules. In all other respects this user matches the - * unrestricted (default) user. Master user is the only user that can disable the user - * interface (keypad, RF, etc...). - * - Non Access User\n - * User is recognized by the lock but does not have the ability to open the lock. This - * user will only cause the lock to generate the appropriate event notification to any - * bound devices. - * @param[out] code PIN code - * @param[out] user_data User data - * - * @see zb_zcldoor_lock_get_pin_code() - */ -typedef void (*zb_zcl_doorlock_get_pin_code_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - unsigned char user_status, - unsigned char user_type, - const char* code, - void *user_data); - -/** - * @brief Command description for get user status response - * @details Returns the user status for the specified user ID. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] user_id User ID - * @param[out] user_status Used to indicate what the status is for a specific user ID. - * 0 - Available\n - * 1 - Occupied / Enabled\n - * 2 - Reserved\n - * 3 - Occupied / Disable\n - * 0xff - Not supported\n - * @param[out] user_data User data - * - * @see zb_zcldoor_lock_get_user_status() - */ -typedef void (*zb_zcl_doorlock_get_user_status_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - unsigned char user_status, - void *user_data); - -/** - * @brief Command description for get week day schedule response - * @details Returns the weekly repeating schedule data for the specified schedule ID. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] schedule_id Requested Schedule ID - * @param[out] user_id Requested User ID - * @param[out] status #ZB_ZCL_SUCCESS (0x00) if both Schedule ID and User ID are valid and - * there is a corresponding schedule entry.\n - * #ZB_ZCL_INVALID_FIELD (0x85) if either Schedule ID and/or User ID - * values are not within valid range.\n - * #ZB_ZCL_NOT_FOUND (0x8B) if both Schedule ID and User ID are within - * the valid range, however, there is not corresponding schedule entry - * found. Only if the status is ZCL SUCCESS that other remaining fields - * are included. For other (error) status values, only the fields up to - * the status field SHALL be present. - * @param[out] days_mask Days mask is a bitmask of the effective days in the order - * [E]SMT WTFS. Bit 7 indicates the enabled status of the schedule ID, - * with the lower 7 bits indicating the effective days mask.\n\n - * Bit 0 : Sat\n - * Bit 1 : Fri\n - * Bit 2 : Thu\n - * Bit 3 : Wed\n - * Bit 4 : Tue\n - * Bit 5 : Mon\n - * Bit 6 : Sun\n - * Bit 7 : En\n - * @param[out] start_hour The Start Hour of the Week Day Schedule: 0-23 - * @param[out] start_minute The Start Min of the Week Day Schedule: 0-59 - * @param[out] end_hour The End Hour of the Week Day Schedule: 0-23, must be greater than Start Hour - * @param[out] end_minute The End Min of the Week Day Schedule: 0-59 - * @param[out] user_data User data - * - * @see zb_zcl_doorlock_set_week_day_schedule() - */ -typedef void (*zb_zcl_doorlock_get_week_day_schedule_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char schedule_id, - unsigned short user_id, - unsigned char status, - unsigned char days_mask, - unsigned char start_hour, - unsigned char start_minute, - unsigned char end_hour, - unsigned char end_minute, - void *user_data); - -/** - * @brief Command description for get year day schedule response - * @details Returns pass/fail of the command. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] schedule_id The requested schedule ID - * @param[out] user_id The requested user ID - * @param[out] status #ZB_ZCL_SUCCESS (0x00) if both Schedule ID and User ID are valid and - * there is a corresponding schedule entry.\n - * #ZB_ZCL_INVALID_FIELD (0x85) if either Schedule ID and/or User ID - * values are not within valid range.\n - * #ZB_ZCL_NOT_FOUND (0x8B) if both Schedule ID and User ID are within - * the valid range, however, there is not corresponding schedule entry - * found. Only if the status is ZCL SUCCESS that other remaining fields - * are included. For other (error) status values, only the fields up to - * the status field SHALL be present. - * @param[out] zigbee_local_start_time Start Time of the Year Day Schedule representing by - * ZigBee LocalTime. - * @param[out] zigbee_local_end_time End Time of the Year Day Schedule representing by - * ZigBee LocalTime. - * @param[out] operating_mode_during_holiday Operating Mode is valid enumeration value as - * listed in operating mode attribute - * @param[out] user_data User data - * - * @see zb_zcl_doorlock_get_year_day_schedule() - */ -typedef void (*zb_zcl_doorlock_get_year_day_schedule_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char schedule_id, - unsigned short user_id, - unsigned char status, - unsigned int zigbee_local_start_time, - unsigned int zigbee_local_end_time, - unsigned char operating_mode_during_holiday, - void *user_data); - -/** - * @brief Command description for get holiday schedule response - * @details Returns the Holiday Schedule Entry for the specified Holiday ID. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] schedule_id The requested Holiday Schedule ID - * @param[out] status - * ZCL SUCCESS (0x00) : if both Schedule ID and User ID are valid and there is a - * corresponding schedule entry.\n - * ZCL INVALID_FIELD (0x85) : if either Schedule ID and/or User ID values are - * not within valid range\n - * ZCL NOT_FOUND (0x8B) : if both Schedule ID and User ID are within the valid - * range, however, there is not corresponding schedule entry found.\n\n - * Only if the status is ZCL SUCCESS that other remaining fields are included.\n For - * other (error) status values, only the fields up to the status field SHALL be present. - * @param[out] status 0=pass, 1=fail - * @param[out] local_start_time Start Time of the Year Day Schedule representing by ZigBee - * LocalTime. - * @param[out] local_end_time End Time of the Year Day Schedule representing by ZigBee - * LocalTime. - * @param[out] operating_mode Operating Mode is valid enumeration value as listed in - * operating mode attribute\n\n - * 0 : Normal mode supported\n - * 1 : Vacation mode supported\n - * 2 : Privacy mode supported\n - * 3 : No RF Lock or Unlock mode supported\n - * 4 : Passage mdoe supported - * @param[out] user_data User data - * - * @see zb_zcl_doorlock_get_holiday_schedule() - */ -typedef void (*zb_zcl_doorlock_get_holiday_schedule_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char schedule_id, - unsigned char status, - unsigned int local_start_time, - unsigned int local_end_time, - unsigned char operating_mode, - void *user_data); - -/** - * @brief Command description for get user type response - * @details Returns the user type for the specified user ID. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] user_id Requested user ID - * @param[out] user_type Used to indicate what the type is for a specific user ID.\n - * 0 - Unrestricted User (default)\n - * 1 - Year Day Schedule User\n - * 2 - Week Day Schedule User\n - * 3 - Master User\n - * 4 - Non Access User\n - * 0xff - Not supported\n - * Cf) User Type - * - Unrestricted User\n - * User has access 24/7 provided proper PIN is supplied (e.g., owner). Unrestricted - * user type is the default user type. - * - Year Day Schedule User\n - * User has ability to open lock within a specific time period (e.g., guest). - * - Week Day Schedule User\n - * User has ability to open lock based on specific time period within a reoccurring - * weekly schedule (e.g., cleaning worker). - * - Master User\n - * User has ability to both program and operate the door lock. This user can manage - * the users and user schedules. In all other respects this user matches the - * unrestricted (default) user. Master user is the only user that can disable the user - * interface (keypad, RF, etc...). - * - Non Access User\n - * User is recognized by the lock but does not have the ability to open the lock. This - * user will only cause the lock to generate the appropriate event notification to any - * bound devices. - * @param[out] user_data User data - * - * @see zb_zcl_doorlock_set_user_type() - */ -typedef void (*zb_zcl_doorlock_get_user_type_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - unsigned char user_type, - void *user_data); - -/** - * @brief Command description for get RFID code response - * @details Returns the RFID code for the specified user ID: - * If the requested user ID is valid and the Code doesn't exist, Get RFID Code - * Response shall have the following format:\n - * UserId = requested UserId\n - * UserStatus = 0 (available)\n - * UserType = 0xFF (not supported)\n - * RFID = 0 (zero length)\n\n - * If requested user ID is invalid, send Default Response with an error status not - * equal to ZCL_SUCCESS(0x00).\n - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] user_id Requested user ID - * @param[out] user_type Used to indicate what the type is for a specific user ID.\n - * 0 - Unrestricted User (default)\n - * 1 - Year Day Schedule User\n - * 2 - Week Day Schedule User\n - * 3 - Master User\n - * 4 - Non Access User\n - * 0xff - Not supported\n - * Cf) User Type - * - Unrestricted User\n - * User has access 24/7 provided proper PIN is supplied (e.g., owner). Unrestricted - * user type is the default user type. - * - Year Day Schedule User\n - * User has ability to open lock within a specific time period (e.g., guest). - * - Week Day Schedule User\n - * User has ability to open lock based on specific time period within a reoccurring - * weekly schedule (e.g., cleaning worker). - * - Master User\n - * User has ability to both program and operate the door lock. This user can manage - * the users and user schedules. In all other respects this user matches the - * unrestricted (default) user. Master user is the only user that can disable the user - * interface (keypad, RF, etc...). - * - Non Access User\n - * User is recognized by the lock but does not have the ability to open the lock. This - * user will only cause the lock to generate the appropriate event notification to any - * bound devices. - * @param[out] rfid_code RFID code string - * @param[out] user_data User data - * - * @see zb_zcl_doorlock_get_rfid_code() - */ -typedef void (*zb_zcl_doorlock_get_rfid_code_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - unsigned char user_type, - const char *rfid_code, - void *user_data); - -#if 1 -/** - * @brief Description for operation event notification - * @details The door lock server sends out operation event notification when the event is - * triggered by the various event sources. The specific operation event will only be - * sent out if the associated bitmask is enabled in the various attributes in the Event - * Masks Attribute Set. \n - * All events are optional. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] operation_event_source This field indicates where the event was triggered from\n - * 0x00 - Keypad\n - * 0x01 - RF\n - * 0x02 - Manual\n - * 0x03 - RFID\n - * 0x04 - Indetermine\n - * @param[out] operation_event_code - * The door lock optionally sends out notifications (if they are enabled) whenever - * there is a significant operational event on the lock. When combined with a source - * from the Event Source table above, the following operational event codes - * constitute an event on the door lock that can be both logged and sent to a bound - * device using the Operation Event Notification command.\n - * Not all operation event codes are applicable to each of the event source.\n - * Below table marks each event code with ( Keypad / RF / Manuel / RFID) - * if the event code is applicable to the event source.\n\n - * 0x00 - UnknownOrMfgSpeficific (Keypad / RF / Manual / RFID)\n - * 0x01 - Lock (Keypad / RF / Manual / RFID)\n - * 0x02 - Unlock (Keypad / RF / Manual / RFID)\n - * 0x03 - LockFailureInvalidPINorID (Keypad / RF / - / RFID)\n - * 0x04 - LockFailureInvalidSchedule (Keypad / RF / - / RFID)\n - * 0x05 - UnlockFailureInvalidPINorID (Keypad / RF / - / RFID)\n - * 0x06 - UnlockFailureInvaidSchedule (Keypad / RF / - / RFID)\n - * 0x07 - OneTouchLock ( - / - / Manual / - )\n - * 0x08 - KeyLock ( - / - / Manual / - )\n - * 0x09 - KeyUnlock ( - / - / Manual / - )\n - * 0x0A - AutoLock ( - / - / Manual / - )\n - * 0x0B - ScheduleLock ( - / - / Manual / - )\n - * 0x0C - ScheduleUnlock ( - / - / Manual / - )\n - * 0x0D - Manuel Lock (Key or Thumbturn) (( - / - / Manual / - )\n - * 0x0E - Manuel Unlock (Key or Thumbturn) ( - / - / Manual / - )\n - * 0x0F - Non-Access User Operational Event (Keypad / - / - / - )\n\n - * - * @param[out] user_id The User ID who performed the event - * @param[out] pin The PIN that is assoicated with the User ID who performed the event - * @param[out] local_time The ZigBee LocalTime that indicates when the event is triggered. - * If time is not supported, the field SHALL be populated with default not - * used value 0xFFFFFFFF. - * @param[out] data The operation event notification command contains a variable string, - * which can be used to pass data associated with a particular event.\n - * Generally this field will be left empty. \n - * However, manufacturer can choose to use this field to store/display - * manufacturer-specific information. - * - */ -typedef void (*zb_zcl_doorlock_operational_event_noti)( - nwk_addr addr16, - unsigned char ep, - unsigned char operation_event_source, - unsigned char operation_event_code, - unsigned short user_id, - unsigned char pin, - unsigned int local_time, - const char *data, - void *user_data); - -/** - * @brief Description for programming event notification - * @details The door lock server sends out a programming event notification whenever a - * programming event takes place on the door lock.\n - * As with operational events, all programming events can be turned on and off by - * flipping bits in the associated event mask.\n - * The programming event notification command includes an optional string of data - * that can be used by the manufacturer to pass some manufacturer-specific - * information if that is required - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] programming_event_source This field indicates where the event was triggered from\n - * 0x00 - Keypad\n - * 0x01 - RF\n - * 0x02 - Manual\n - * 0x03 - RFID\n - * 0x04 - Indetermine\n - * @param[out] programming_event_code - * The door lock optionally sends out notifications (if they are enabled) whenever - * there is a significant operational event on the lock. When combined with a source - * from the Event Source table above, the following operational event codes - * constitute an event on the door lock that can be both logged and sent to a bound - * device using the Programming Event Notification command.\n - * Not all operation event codes are applicable to each of the event source.\n - * Below table marks each event code with ( Keypad / RF / Manuel / RFID) - * if the event code is applicable to the event source.\n\n - * 0x00 - UnknownOrMfgSpeficific (Keypad / RF / RFID)\n - * 0x01 - MasterCodeChanged (Keypad / RF / RFID)\n - * 0x02 - PINCodeAdded (Keypad / - / - )\n - * 0x03 - PINCodeDeleted (Keypad / RF / - )\n - * 0x04 - PINCodeChanged (Keypad / RF / - )\n - * 0x05 - RFIDCodeAdded (- / - / RFID)\n - * 0x06 - RFIDCodeDeleted (- / - / RFID)\n - * - * @param[out] user_id The User ID who performed the event - * @param[out] pin The PIN that is assoicated with the User ID who performed the event - * @param[out] The User Status that is associated with the User ID who performed the event - * @param[out] local_time The ZigBee LocalTime that indicates when the event is triggered. - * If time is not supported, the field SHALL be populated with default not - * used value 0xFFFFFFFF. - * @param[out] data The operation event notification command contains a variable string, - * which can be used to pass data associated with a particular event.\n - * Generally this field will be left empty. \n - * However, manufacturer can choose to use this field to store/display - * manufacturer-specific information. - - * - */ -typedef void (*zb_zcl_doorlock_programming_event_noti)( - nwk_addr addr16, - unsigned char ep, - unsigned char programming_event_source, - unsigned char programming_event_code, - unsigned short user_id, - unsigned char pin, - unsigned char status, - unsigned int local_time, - const char *data, - void *user_data); -#endif - -/* Table 10.10 Commands Received by the Server Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Lock Door | M | - * | 0x01 | Unlock Door | M | - * | 0x02 | Toogle | O | - * | 0x03 | Unlock with Timeout | O | - * | 0x04 | Get Log Record | O | - * | 0x05 | Set PIN Code | O | - * | 0x06 | Get PIN Code | O | - * | 0x07 | Clear PIN Code | O | - * | 0x09 | Set User Status | O | - * | 0x0a | Get User Status | O | - * | 0x0b | Set Week Day Schedule | O | - * | 0x0c | Get Week Day Schedule | O | - * | 0x0d | Clear Week Day Schedule | O | - * | 0x0e | Set Year Day Schedule | O | - * | 0x0f | Get Year Day Schedule | O | - * | 0x10 | Clear Year Day Schedule | O | - * | 0x11 | Set Holiday Schedule | O | - * | 0x12 | Get Holiday Schedule | O | - * | 0x13 | Clear Holiday Schedule | O | - * | 0x14 | Set User Type | O | - * | 0x15 | Get User Type | O | - * | 0x16 | Set RFID Code | O | - * | 0x17 | Get RFID Code | O | - * | 0x18 | Clear RFID Code | O | - * | 0x19 | Clear All RFID Codes | O | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Description for lock door command - * @details This command causes the lock device to lock the door. As of HA 1.2, this - * command includes an optional code for the lock. The door lock MAY require a - * PIN depending on the value of the [Require PIN for RF Operation attribute] - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] pin_or_rfid_code PIN/RFID code - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_lock( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - const char *pin_or_rfid_code, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for unlock door command - * @details This command causes the lock device to unlock the door. As of HA 1.2, this - * command includes an optional code for the lock. The door lock MAY require a - * code depending on the value of the [Require PIN for RF Operation attribute].\n\n - * Note: If the attribute AutoRelockTime is supported the lock will close when the - * auto relock time has expired. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] pin_or_rfid_code PIN/RFID code - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_unlock( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - const char *pin_or_rfid_code, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for toggle command - * @details Request the status of the lock. As of HA 1.2, this command includes an optional - * code for the lock. The door lock MAY require a code depending on the value of - * the [Require PIN for RF Operation attribute]. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] pin_or_rfid_code PIN/RFID code - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_toggle( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - const char *pin_or_rfid_code, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for unlock with timeout command - * @details This command causes the lock device to unlock the door with a timeout - * parameter. After the time in seconds specified in the timeout field, the lock device - * will relock itself automatically. This timeout parameter is only temporary for this - * message transition only and overrides the default relock time as specified in the - * [Auto Relock Time attribute] attribute. If the door lock device is not capable of or - * does not want to support temporary Relock Timeout, it SHOULD not support this - * optional command. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] timeout Timeout in seconds - * @param[in] pin_or_rfid_code PIN/RFID code - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_unlock_with_timeout( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short timeout, - const char *pin_or_rfid_code, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for get log record command - * @details Request a log record. Log number is between 1 ? [Number of Log Records - * Supported attribute]. If log number 0 is requested then the most recent log entry is - * returned.\n - * Log record format: The log record format is defined in the description of the - * GetLogRecordResponse command. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] log_index index in log repository - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_get_log_record( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short log_index, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for set PIN code command - * @details Set a PIN into the lock\n\n - * User ID is between 0 - [# of PIN Users Supported attribute]. Only the values 1 - * (Occupied/Enabled) and 3 (Occupied/Disabled) are allowed for User Status. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id Requested user ID - * @param[in] user_status Used to indicate what the status is for a specific user ID.\n - * 1 - Occupied / Enabled\n - * 3 - Occupied / Disable\n - * @param[in] user_type Used to indicate what the type is for a specific user ID.\n - * 0 - Unrestricted User (default)\n - * 1 - Year Day Schedule User\n - * 2 - Week Day Schedule User\n - * 3 - Master User\n - * 4 - Non Access User\n - * 0xff - Not supported\n - * Cf) User Type - * - Unrestricted User\n - * User has access 24/7 provided proper PIN is supplied (e.g., owner). Unrestricted - * user type is the default user type. - * - Year Day Schedule User\n - * User has ability to open lock within a specific time period (e.g., guest). - * - Week Day Schedule User\n - * User has ability to open lock based on specific time period within a reoccurring - * weekly schedule (e.g., cleaning worker). - * - Master User\n - * User has ability to both program and operate the door lock. This user can manage - * the users and user schedules. In all other respects this user matches the - * unrestricted (default) user. Master user is the only user that can disable the user - * interface (keypad, RF, etc...). - * - Non Access User\n - * User is recognized by the lock but does not have the ability to open the lock. This - * user will only cause the lock to generate the appropriate event notification to any - * bound devices. - * @param[in] pin PIN code string - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_set_pin_code( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - unsigned char user_status, - unsigned char user_type, - const char *pin, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for get PIN code command - * @details Retrieve a PIN Code. User ID is between 0 - [# of PIN Users Supported attribute]. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id Requested user ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_get_pin_code_rsp() - */ -int zb_zcl_doorlock_get_pin_code( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - zb_zcl_doorlock_get_pin_code_rsp cb, - void *user_data); - -/** - * @brief Description for clear PIN code command - * @details Delete a PIN. User ID is between 0 - [# of PIN Users Supported attribute].\n\n - * Note: If you delete a PIN Code and this user didn't have a RFID Code, the user - * status is set to "0 Available", the user type is set to the default value and all - * schedules are also set to the default values. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id Requested user ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_clear_pin_code( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for clear all PIN code command - * @details Clear out all PINs on the lock.\n\n - * Note: On the server, the clear all PIN codes command should have the same effect - * as the Clear PIN Code command with respect to the setting of user status, user - * type and schedules. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_clear_all_pin_code( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for set user status command - * @details Set the status of a user ID. User Status value of 0x00 is not allowed. - * In order to clear a user id, the Clear ID Command SHALL be used. For user status value - * please refer to User Status Value. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id Requested user ID - * @param[in] user_status Used to indicate what the status is for a specific user ID. - * 0 - Available\n - * 1 - Occupied / Enabled\n - * 2 - Reserved\n - * 3 - Occupied / Disable\n - * 0xff - Not supported\n - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_set_user_status( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - unsigned char user_status, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for set week day command - * @details Set a weekly repeating schedule for a specified user.\n - * When the Server Device receives the command, the Server Device MAY change - * the user type to the specific schedule user type.\n - * Process for Creating a New User with Schedule at the beginning of this cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] schedule_id number is between 0-[# of Week Day Schedules Per User attribute]. - * @param[in] user_id is between 0 - [# of Total Users Supported attribute]. - * @param[in] days_mask bitmask of the effective days in the order XSFTWTMS.\n\n - * Bit 0 : Sun\n - * Bit 1 : Mon\n - * Bit 2 : Tue\n - * Bit 3 : Wed\n - * Bit 4 : Thur\n - * Bit 5 : Fri\n - * Bit 6 : Sat\n - * Bit 7 : Reserved\n\n - * Days mask is listed as bitmask for flexibility to set same schedule across multiple - * days. For the door lock that does not support setting schedule across multiple days - * within one command, it SHOULD respond with ZCL INVALID_FIELD (0x85) - * status when received the set schedule command days bitmask field has multiple - * days selected. - * @param[in] start_hour in decimal format represented by 0x00-0x17 (00 to 23 hours). - * @param[in] start_minute in decimal format represented by 0x00-0x3B (00 to 59 mins). - * @param[in] end_hour in decimal format represented by 0x00-0x17 (00 to 23 hours).\n - * End Hour SHALL be equal or greater than Start Hour. - * @param[in] end_minute in decimal format represented by 0x00-0x3B (00 to 59 mins). - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_set_week_day_schedule( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char schedule_id, - unsigned short user_id, - unsigned char days_mask, - unsigned char start_hour, - unsigned char start_minute, - unsigned char end_hour, - unsigned char end_minute, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for get week day schedule command - * @details Retrieve the specific weekly schedule for the specific user. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] schedule_id Requested schedule ID - * @param[in] user_id Requested user ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_get_week_day_schedule_rsp() - */ -int zb_zcl_doorlock_get_week_day_schedule( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char schedule_id, - unsigned short user_id, - zb_zcl_doorlock_get_week_day_schedule_rsp cb, - void *user_data); - -/** - * @brief Description for set year day command - * @details Set a time-specific schedule ID for a specified user. - * When the Server Device receives the command, the Server Device MAY change - * the user type to the specific schedule user type. - * Process for Creating a New User with Schedule at the beginning of this cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] schedule_id number is between 0-[# of Week Day Schedules Per User attribute]. - * @param[in] user_id is between 0 - [# of Total Users Supported attribute]. - * @param[in] zigbee_local_start_time Start time and end time are given in ZigBee LocalTime. - * @param[in] zigbee_local_end_time Start time and end time are given in ZigBee LocalTime. - * End time must be greater than the start time - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_set_year_day_schedule( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char schedule_id, - unsigned short user_id, - unsigned int zigbee_local_start_time, - unsigned int zigbee_local_end_time, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for get year day schedule command - * @details Retrieve the specific year schedule for the specific user. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] schedule_id Requested schedule ID - * @param[in] user_id Requested user ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_get_year_day_schedule_rsp() - */ -int zb_zcl_doorlock_get_year_day_schedule( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char schedule_id, - unsigned short user_id, - zb_zcl_doorlock_get_year_day_schedule_rsp cb, - void *user_data); - -/** - * @brief Description for set holiday schedule command - * @details Set the holiday Schedule by specifying ZigBee local start time and ZigBee - * local end time with respect to any Lock Operating Mode. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] holiday_schedule_id number is between 0-[# of Holiday Schedules Supported attribute]. - * @param[in] zigbee_local_start_time Start time and end time are given in ZigBee LocalTime. - * @param[in] zigbee_local_end_time Start time and end time are given in ZigBee LocalTime. - * End time must be greater than the start time - * @param[in] operating_mode_during_holiday is valid enumeration value as listed in operating mode attribute\n - * Bit0 - Normal Mode Supported\n - * Bit1 - Vacation Mode Supported\n - * Bit2 - Privacy Mode Supported\n - * Bit3 - No RF Lock or Unlock Mode Mode Supported\n - * Bit4 - Passage Mode Supported\n - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_set_holiday_schedule( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char holiday_schedule_id, - unsigned int zigbee_local_start_time, - unsigned int zigbee_local_end_time, - unsigned char operating_mode_during_holiday, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for get holiday schedule command - * @details Get the holiday Schedule by specifying Holiday ID. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] holiday_schedule_id Requested holiday schedule ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_door_lock_get_holiday_schedule_rsp() - */ -int zb_zcl_doorlock_get_holiday_schedule( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char holiday_schedule_id, - zb_zcl_doorlock_get_holiday_schedule_rsp cb, - void *user_data); - -/** - * @brief Description for clear holiday schedule command - * @details Clear the holiday Schedule by specifying Holiday ID. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] holiday_schedule_id Requested holiday schedule ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_clear_holiday_schedule( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char holiday_schedule_id, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for set user type command - * @details Set the type byte for a specified user. \n - * For user type value please refer to User Type Value. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id Targget user ID - * @param[in] user_type Used to indicate what the type is for a specific user ID.\n - * 0 - Unrestricted User (default)\n - * 1 - Year Day Schedule User\n - * 2 - Week Day Schedule User\n - * 3 - Master User\n - * 4 - Non Access User\n - * 0xff - Not supported\n - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_set_user_type( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - unsigned char user_type, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for get user type command - * @details Retrieve the type byte for a specific user. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id Requested user ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_door_lock_get_user_type_rsp() - */ -int zb_zcl_doorlock_get_user_type( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - zb_zcl_doorlock_get_user_type_rsp cb, - void *user_data); - -/** - * @brief Description for set RFID code command - * @details Retrieve an ID. User ID is between 0 - [# of RFID Users Supported attribute]. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id is between 0 - [# of RFID Users Supported attribute] - * @param[in] user_status Used to indicate what the status is for a specific user ID. - * 1 - Occupied / Enabled\n - * 3 - Occupied / Disable\n - * @param[in] user_type Used to indicate what the type is for a specific user ID.\n - * 0 - Unrestricted User (default)\n - * 1 - Year Day Schedule User\n - * 2 - Week Day Schedule User\n - * 3 - Master User\n - * 4 - Non Access User\n - * 0xff - Not supported\n - * @param[in] rfid_code RFID code string - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_set_rfid_code( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - unsigned char user_status, - unsigned char user_type, - const char *rfid_code, - zb_zcl_doorlock_rsp cb, - void *user_data); - - -/** - * @brief Description for get RFID code command - * @details Retrieve an ID. User ID is between 0 - [# of RFID Users Supported attribute]. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id Requested user ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_door_lock_get_rfid_code_rsp() - */ -int zb_zcl_doorlock_get_rfid_code( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - zb_zcl_doorlock_get_rfid_code_rsp cb, - void *user_data); - - -/** - * @brief Description for clear RFID code command - * @details Delete an ID. User ID is between 0 - [# of RFID Users Supported attribute]. If you - * delete a RFID code and this user didn't have a PIN code, the user status has to be - * set to "0 Available", the user type has to be set to the default value, and all - * schedules which are supported have to be set to the default values. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] user_id Requested user ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_clear_rfid_code( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short user_id, - zb_zcl_doorlock_rsp cb, - void *user_data); - -/** - * @brief Description for clear all RFID code command - * @details Clear out all RFIDs on the lock. If you delete all RFID codes and this user didn't - * have a PIN code, the user status has to be set to "0 Available", the user type has to - * be set to the default value, and all schedules which are supported have to be set to - * the default values. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] cb Response callback - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_doorlock_rsp() - */ -int zb_zcl_doorlock_clear_all_rfid_code( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - zb_zcl_doorlock_rsp cb, - void *user_data); -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* ZB_SUPPORT_PRIORITY_5 */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_DOOR_LOCK_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-global-commands.h b/include/zcl/zb-zcl-global-commands.h deleted file mode 100644 index be27217..0000000 --- a/include/zcl/zb-zcl-global-commands.h +++ /dev/null @@ -1,794 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-global-commands.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_MODULE Global Commands - * - * @brief zigbee global commands description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/** - * @brief Global response callback - * @details This function is used for global response corresponding. - * - * @since_tizen 3.0 - * - * @param[out] addr16 source network address - * @param[out] ep where is sent from (ex. 1) - * @param[out] cluster_id ZCL cluster id - * @param[out] records Response record - * @param[out] records_len Length of attribute status record - * @param[out] user_data User data - * - * @see zb_zcl_global_read_attr() - * @see zb_zcl_global_write_attr() - * @see zb_zcl_global_write_attr_undivided() - * @see zb_zcl_global_config_report() - * @see zb_zcl_global_read_config_report() - * @see zb_zcl_global_read_attr_structured() - * @see zb_zcl_global_write_attr_structured() - */ -typedef void (*zb_zcl_global_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned short cluster_id, - zb_global_record_data_s *records, - int records_len, - void *user_data); - -/** - * @brief Read Attributes - * @details This function to read attributes in devices. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] attribute_ids Attributes_ids-list - * @param[in] attribute_ids_len Length of attribte_ids-list - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @post This function invokes zb_zcl_global_rsp() for each application context. - * - * @see zb_zcl_global_rsp() - */ -int zb_zcl_global_read_attr( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - unsigned short *attribute_ids, - int attribute_ids_len, - zb_zcl_global_rsp cb, - void *user_data); - -/** - * @brief write Attributes - * @details This function to write attributes to other devices. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] records structure for write_attribute_record_s - * @param[in] records_len Length of attribte_ids-list - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_rsp() - */ -int zb_zcl_global_write_attr( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - write_attr_record_h *records, - int records_len, - zb_zcl_global_rsp cb, - void *user_data); - -/** - * @brief Command description for write attributes undivided - * @details This function to write attributes without fragmentation to other devices. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] records structure for write_attribute_record_s - * @param[in] records_len Length of attribte_ids-list - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_rsp() - */ -int zb_zcl_global_write_attr_undivided( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - write_attr_record_h *records, - int records_len, - zb_zcl_global_rsp cb, - void *user_data); - -/** - * @brief write Attributes - * @details This function to write attributes to other devices without any response. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] records structure for write_attribute_record_s - * @param[in] records_len Length of attribte_ids-list - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_global_write_attr_no_rsp( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - write_attr_record_h *records, - int records_len); - -/** - * @brief Command description for setting configure reporting - * @details This function to set configuration about attribute status changing reporting. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] records structure for report_config_records - * @param[in] records_len Length of report_config_records structure - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_rsp() - */ -int zb_zcl_global_config_report( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - report_config_record_h *records, - int records_len, - zb_zcl_global_rsp cb, - void *user_data); - -/** - * @brief Command description for reading configure reporting - * @details This function to read configuration about attribute status changing reporting. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] records structure for report_config_records - * @param[in] records_len Length of report_config_records structure - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_rsp() - */ -int zb_zcl_global_read_config_report( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - read_report_config_record_h *records, - int records_len, - zb_zcl_global_rsp cb, - void *user_data); - -/** - * @brief Discover attribute callback - * @details The discover attributes response command is generated in response to a discover - * attributes command. - * - * @since_tizen 3.0 - * - * @param[out] addr16 source network address - * @param[out] ep where is sent from (ex. 1) - * @param[out] cluster_id ZCL cluster id - * @param[out] records Discover attribute information record - * @param[out] records_len Length of Discover attribute information record - * @param[out] user_data User data - * - * @see zb_zcl_global_discover_attr() - */ -typedef void (*zb_zcl_global_discover_attr_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned short cluster_id, - unsigned char discovery_complete, - discover_attr_info_record_h *records, - int records_len, - void *user_data); - -/** - * @brief Command description for discovering attributes - * @details The discover attributes command is generated when a remote device wishes to - * discover the identifiers and types of the attributes on a device which are supported - * within the cluster to which this command is directed. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] start_id The value of the identifier at which to begin the attribute discovery. - * @param[in] max_attribute_ids The maximum number of attribute identifiers - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_rsp() - */ -int zb_zcl_global_discover_attr( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - unsigned short start_id, - unsigned char max_attribute_ids, - zb_zcl_global_discover_attr_rsp cb, - void *user_data); - -/** - * @brief The read attributes structured command frame shall be formatted - * details The read attributes command is generated when a device wishes to determine the - * values of one or more attributes, or elements of attributes, located on another - * device. Each attribute identifier field shall contain the identifier of the attribute - * to be read. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] records The combination of attribute identifier and selector . - * @param[in] records_len The maximum number of read_structured_attribute_record - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_rsp() - */ -int zb_zcl_global_read_attr_structured( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - read_structured_attr_record_h *records, - int records_len, - zb_zcl_global_rsp cb, - void *user_data); - -/** - * @brief The write attributes structured command frame shall be formatted - * @details When writing an element to an array or structure, the Indicator subfield indicates - * the number of index fields that follow it. This number is limited to the range 0 - 15 - * (i.e. the upper 4 bits of the Indicator field are set to zero). It may be further limited - * by any relevant profile or application. - * If the Indicator subfield is 0, there are no index fields, and the whole of the - * attribute value is to be written. - * If this subfield is 1 or greater, the index fields indicate which element is to be - * written, nested to a depth of m. For example, if the attribute is an array of arrays - * (or structures), then if m = 2, index 1 = 5 and index 2 = 3, the third element of the - * fifth element of the attribute will be written. - * Note that elements are numbered from 1 upwards for both arrays and structures. - * The zeroth element of an array or structure has type 16 bit unsigned integer, and - * holds the number of elements in the array or structure. The zeroth element of an - * array may optionally be written (this is application dependent) and has the effect - * of changing the number of elements of the array. If the number is reduced, the - * array is truncated. If the number is increased, the content of new elements is - * application dependent. - * The zeroth element of a structure may not be written to. Writing to an element - * with an index greater than the number of elements in an array or structure is - * always an error. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] records The combination of attribute identifier and selector . - * @param[in] records_len The maximum number of write_structured_attribute_record - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported - * - * @see zb_zcl_global_rsp() - */ -int zb_zcl_global_write_attr_structured( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - write_attr_structured_record_h *records, - int records_len, - zb_zcl_global_rsp cb, - void *user_data); - -/** - * @brief The response of zb_zcl_global_discover_commands_received() and - * zb_zcl_global_discover_cmds_generated() - * @details The ZCL provides the facility to discover the commands that a cluster - * instance on a remote device can receive and generate. This is useful since an - * individual cluster instance may not be able to receive or generate all of the commands - * that are theoretically supported by the cluster. - * - * @since_tizen 3.0 - * - * @param[out] addr16 source network address - * @param[out] ep where is sent from (ex. 1) - * @param[out] cluster_id ZCL cluster id - * @param[out] discovery_complete which indicates whether the Command Discovery is - * complete, i.e. whether there are any commands remaining to be discovered:\n - * - TRUE - all commands have been discovered\n - * - FALSE - there are further commands to be discovered\n - * @param[out] command_ids Discovered commands list - * @param[out] command_ids_len The number of discovered commands reported in this response - * @param[out] user_data User data - * - * @see zb_zcl_global_discover_cmd_received() - */ -typedef void (*zb_zcl_global_discover_cmds_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned short cluster_id, - unsigned char discovery_complete, - unsigned char *command_ids, - int command_ids_len, - void *user_data); - -/** - * @brief This function to know remote cluster on remote device can handle specific commands - * @details The ZCL provides the facility to discover the commands that a cluster - * instance on a remote device can receive and generate. This is useful since an - * individual cluster instance may not be able to receive or generate all of the commands - * that are theoretically supported by the cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] start_command_id Start command id . - * @param[in] max_command_ids Last command id - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_discover_cmd_received_rsp() - */ -int zb_zcl_global_discover_cmds_received( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - unsigned char start_command_id, - unsigned char max_command_ids, - zb_zcl_global_discover_cmds_rsp cb, - void *user_data); - -/** - * @brief This function to know remote cluster on remote device can generate specific commands - * @details The ZCL provides the facility to discover the commands that a cluster - * instance on a remote device can receive and generate. This is useful since an - * individual cluster instance may not be able to receive or generate all of the commands - * that are theoretically supported by the cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] start_command_id Start command id . - * @param[in] max_command_ids Last command id - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_discover_cmds_rsp() - */ -int zb_zcl_global_discover_cmds_generated( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - unsigned char start_command_id, - unsigned char max_command_ids, - zb_zcl_global_discover_cmds_rsp cb, - void *user_data); - -/** - * @brief The response of zb_zcl_global_discover_attr_extended() - * @details The ZCL provides the facility to discover the commands that a cluster - * instance on a remote device can receive and generate. This is useful since an - * individual cluster instance may not be able to receive or generate all of the commands - * that are theoretically supported by the cluster. - * - * @since_tizen 3.0 - * - * @param[out] addr16 source network address - * @param[out] ep where is sent from (ex. 1) - * @param[out] cluster_id ZCL cluster id - * @param[out] discovery_complete which indicates whether the Command Discovery is - * complete, i.e. whether there are any commands remaining to be discovered:\n - * - TRUE - all commands have been discovered\n - * - FALSE - there are further commands to be discovered\n - * @param[out] records Discovered attribute information list - * @param[out] records_len Len The number of discovered information\n - * reported in this response - * @param[out] user_data User data - * - * @see zb_zcl_global_discover_attr_extended() - */ -typedef void (*zb_zcl_global_discover_attr_extended_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned short cluster_id, - unsigned char discovery_complete, - extended_attr_info_h *records, - unsigned short records_len, - void *user_data); - -/** - * @brief This function to know remote cluster on remote device has extended commands - * @details The ZCL provides the facility to discover the commands that a cluster - * instance on a remote device can receive and generate. This is useful since an - * individual cluster instance may not be able to receive or generate all of the commands - * that are theoretically supported by the cluster. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 target network address - * @param[in] src_ep source end-point (ex. 1) - * @param[in] dst_ep destination end-point (ex. 1) - * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n - * Only OR operation is allowed in ZCL header \n - * - Frame Type : \n - * #ZB_ZCL_FC_GLOBALLY_USED (default) \n - * #ZB_APS_FC_CLUSTER_SPECIFIC \n - * - Manufacturer Specific : \n - * - Direction : \n - * #ZB_ZCL_CLIENT_TO_SERVER (default) \n - * #ZB_ZCL_SERVER_TO_CLIENT \n - * - Disable Default Response : \n - * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n - * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n - * @param[in] cluster_id ZCL cluster id - * @param[in] start_id Start id . - * @param[in] max_attribute_ids Last command id - * @param[in] cb Response callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_discover_attr_extended_rsp() - */ -int zb_zcl_global_discover_attr_extended( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned char dst_ep, - unsigned char zcl_frame_ctl, - unsigned short cluster_id, - unsigned short start_id, - unsigned char max_attribute_ids, - zb_zcl_global_discover_attr_extended_rsp cb, - void *user_data); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_H__ */ diff --git a/include/zcl/zb-zcl-groups-cluster.h b/include/zcl/zb-zcl-groups-cluster.h deleted file mode 100644 index dad7999..0000000 --- a/include/zcl/zb-zcl-groups-cluster.h +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_GROUPS_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_GROUPS_CLUSTER_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-groups-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_GROUP_CLUSTER_MODULE Group Cluster - * - * @brief zigbee group cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_GROUP_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 3.33 Generated Command IDs for the Groups Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Add group response | M | - * | 0x01 | View group response | M | - * | 0x02 | Get group membership response | M | - * | 0x03 | Remove group response | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for add group response - * @details The add group response is sent by the groups cluster server in response to an\n - * add group command.\n - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_DUPLICATE_EXISTS \n - * #ZB_ZCL_INSUFFICIENT_SPACE - * @param[out] group_id Group id - * @param[out] user_data user data - * - * @see zb_zcl_group_add_group() - */ -typedef void (*zb_zcl_group_add_group_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned short group_id, - void *user_data); - -/** - * @brief Command description for view group response - * @details The view group response command is sent by the groups cluster server in\n - * response to a view group command.\n - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_NOT_FOUND - * @param[out] group_id Group id - * @param[out] group_name Group name - * @param[out] user_data user data - * - * @see zb_zcl_group_view_group() - */ -typedef void (*zb_zcl_group_view_group_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned short group_id, - const char *group_name, - void *user_data); - -/** - * @brief Command description for view group membership response - * @details The get group membership response command is sent by the groups cluster server\n - * in response to a get group membership command.\n - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] capacity How many we can add to this group - * @param[out] group_count The number of groups contained in the group_list - * @param[out] group_list the identifiers either of all the groups in the group table - * @param[out] user_data user data - * - * @see zb_zcl_group_view_group_membership() - */ -typedef void (*zb_zcl_group_get_group_membership_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char capacity, - unsigned char group_count, - unsigned short *group_list, - void *user_data); - -/** - * @brief Command description for remove group response - * @details The add group response is sent by the groups cluster server in response to an\n - * remove group command.\n - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_NOT_FOUND - * @param[out] group_id Group id - * @param[out] user_data user data - * - * @see zb_zcl_group_add_group() - */ -typedef void (*zb_zcl_group_remove_group_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned short group_id, - void *user_data); - -/* Table 3.32 Received Command IDs for the Groups Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Add group | M | - * | 0x01 | View group | M | - * | 0x02 | Get group membership | M | - * | 0x03 | Remove group | M | - * | 0x04 | Remove all group | M | - * | 0x05 | Add group if identifying | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for add groups - * @details The add group command allows the sending device to add group membership in a\n - * particular group for one or more endpoints on the receiving device.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Target endpoint - * @param[in] group_id Group ID - * @param[in] group_name Group name - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_group_add_group_rsp() - */ -int zb_zcl_group_add_group( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - char *group_name, - zb_zcl_group_add_group_rsp cb, - void *user_data); - -/** - * @brief Command description for view group command - * @details The view group command allows the sending device to request that the receiving\n - * entity or entities respond with a view group response command containing the\n - * application name string for a particular group.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Target endpoint - * @param[in] group_id Group ID - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_group_view_group_rsp() - */ -int zb_zcl_group_view_group( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - zb_zcl_group_view_group_rsp cb, - void *user_data); - -/** - * @brief Command description for get group membership - * @details The get group membership command allows the sending device to inquire about\n - * the group membership of the receiving device and endpoint in a number of ways.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Target endpoint - * @param[in] group_count Group count - * @param[in] group_list Group list - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_group_get_group_membership_rsp() - */ -int zb_zcl_group_get_group_membership( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char group_count, - unsigned short *group_list, - zb_zcl_group_get_group_membership_rsp cb, - void *user_data); - -/** - * @brief Command description for remove group - * @details The remove group command allows the sender to request that the receiving entity\n - * or entities remove their membership, if any, in a particular group.\n - * Note that if a group is removed the scenes associated with that group should be\n - * removed.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Target endpoint - * @param[in] group_id Group ID - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_group_remove_group_rsp() - */ -int zb_zcl_group_remove_group( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - zb_zcl_group_remove_group_rsp cb, - void *user_data); - -/** - * @brief Command description for remove group - * @details The remove all groups command allows the sending device to direct the receiving\n - * entity or entities to remove all group associations.\n - * \n - * Note that removing all groups necessitates the removal of all associated scenes as\n - * well. (Note: scenes not associated with a group need not be removed).\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Target endpoint - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_group_remove_all_group( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep); - -/** - * @brief Command description for remove group if identifying - * @details The add group if identifying command allows the sending device to add group\n - * membership in a particular group for one or more endpoints on the receiving\n - * device, on condition that it is identifying itself. Identifying functionality is\n - * controlled using the identify cluster.\n - * This command might be used to assist configuring group membership in the\n - * absence of a commissioning tool.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Target endpoint - * @param[in] group_id Group ID - * @param[in] group_name Group name - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_group_add_group_if_identifying( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - const char *group_name); - -/** - * @} - */ -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_H__ */ - diff --git a/include/zcl/zb-zcl-ias-zone-cluster.h b/include/zcl/zb-zcl-ias-zone-cluster.h deleted file mode 100644 index 51fe7a7..0000000 --- a/include/zcl/zb-zcl-ias-zone-cluster.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-ias-zone-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_MODULE IAS zone Cluster - * - * @brief zigbee IAS zone cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 8.10 Generated Command IDs for the IAS Zone Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Zone Status Change Notification | M | - * | 0x01 | Zone Enroll Request | M | - * | 0x11 | Zone Status Change Notification (Ext)| M | - * +--------------------------------+--------------------------------------+------------+ - */ - - -/* Table 8.8 Received Command IDs for the IAS Zone Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Zone Enroll Respnse | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Table 8.9 Values of the Enroll Response Code - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_IAS_ZONE_ENROLL_SUCCESS = 0x00, /**< Success */ - ZB_ZCL_IAS_ZONE_ENROLL_NOT_SUPPORT = 0x01, /**< This specific Zone type is not known - to the CIE and is not supported */ - ZB_ZCL_IAS_ZONE_ENROLL_NO_ENROLL_PERMIT = 0x02, /**< CIE does not permit new zones to - enroll at this time. */ - ZB_ZCL_IAS_ZONE_ENROLL_TOO_MANY_ZONE = 0x03, /**< CIE reached its limit of number of - enrolled zones */ -} zb_ias_zone_enroll_response_e; - -/** - * @brief Command description for zone enroll response - * @details On receipt, the device embodying the Zone server is notified that it is now - * enrolled as an active alarm device\n - * The device embodying the Zone server must authenticate received messages by - * checking the address of their sender against IAS_CIE_Address. This is to ensure - * that only messages from the correct CIE are accepted. - * - * @since_tizen 3.0 - * - * @param[in] handle handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] enroll_response_code #ZB_ZCL_IAS_ZONE_ENROLL_SUCCESS - * #ZB_ZCL_IAS_ZONE_ENROLL_NOT_SUPPORT - * #ZB_ZCL_IAS_ZONE_ENROLL_NO_ENROLL_PERMIT - * #ZB_ZCL_IAS_ZONE_ENROLL_TOO_MANY_ZONE - * @param[in] zone_id The Zone ID field is the index into the zone table of the CIE. This - * field is only relevant if the response code is success.\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_zone_enroll_response( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char enroll_response_code, - unsigned char zone_id); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-identify-cluster.h b/include/zcl/zb-zcl-identify-cluster.h deleted file mode 100644 index 6290f8e..0000000 --- a/include/zcl/zb-zcl-identify-cluster.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_IDENTIFY_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_IDENTIFY_CLUSTER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-identify-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_IDENTITY_CLUSTER_MODULE Identity Cluster - * - * @brief zigbee identity cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_IDENTITY_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/** - * @brief Make devices as Identify mode within specific time - * @details The identify command starts or stops the receiving device identifying itself. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep endpoint number - * @param[in] identify_time Identify time - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_identify( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short identify_time); - -/** - * @brief Identify query response from devices keep identifying mode - * @details The identify query command allows the sending device to request the target or - * targets to respond if they are currently identifying themselves.\n - * This command has no payload.\n - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] identify_time Identify time - * @param[out] user_data user data - * - * @see zb_zcl_identify_query() - */ -typedef void (*zb_zcl_identify_query_cb)( - nwk_addr addr16, - unsigned short identify_time, - void *user_data); - -/** - * @brief Find devices which sustains identify mode - * @details The identify query command allows the sending device to request the target or - * targets to respond if they are currently identifying themselves.\n - * This command has no payload.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep endpoint number - * @param[in] cb response callback function - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_global_write_attr_rsp() - */ -int zb_zcl_identify_query( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - zb_zcl_identify_query_cb cb, - void *user_data); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_IDENTIFY_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-level-control-cluster.h b/include/zcl/zb-zcl-level-control-cluster.h deleted file mode 100644 index 0d45101..0000000 --- a/include/zcl/zb-zcl-level-control-cluster.h +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-on-off-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_MODULE Level Control Cluster - * - * @brief zigbee level control cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 3.48 Command IDs for the Level Control Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Move to Level | M | - * | 0x01 | Move | M | - * | 0x02 | Step | M | - * | 0x03 | Stop | M | - * | 0x04 | Move to Level (with On/Off) | M | - * | 0x05 | Move (with On/Off) | M | - * | 0x06 | Step (with On/Off) | M | - * | 0x07 | Stop | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command for move to level - * @details On receipt of this command, a device shall move from its current level to the - * value given in the Level field. The meaning of 'level' is device dependent ? e.g. - * for a light it may mean brightness level.\n\n - * The movement shall be as continuous as technically practical, i.e. not a step - * function, and the time taken to move to the new level shall be equal to the value of - * the Transition time field, in tenths of a second, or as close to this as the device is - * able.\n\n - * If the Transition time field takes the value 0xffff then the time taken to move to - * the new level shall instead be determined by the OnOffTransitionTime attribute. If - * OnOffTransitionTime , which is an optional attribute, is not present, the device - * shall move to its new level as fast as it is able.\n\n - * If the device is not able to move at a variable rate, the Transition time field may be - * disregarded.\n\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] level Brightness level - * @param[in] transition_time The Transition time field, in tenths of a second, \n - * or as close to this as the device is able - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_levelctrl_move_to_level( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char level, - unsigned short transition_time); - -/** - * @brief Command for move - * @details On receipt of this command, a device shall move from its current level in an - * up or down direction in a continuous fashion - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] move_mode The Move mode field shall be one of the non-reserved values\n - * 0x00 : Up\n - * 0x01 : Down\n - * @param[in] rate The Rate field specifies the rate of movement in units per second. \n - * The actual rate of movement should be as close to this rate as the device is able.\n - * If the Rate field is 0xff the device should move as fast as it is able.\n - * If the device is not able to move at a variable rate, this field may be disregarded.\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_levelctrl_move( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char move_mode, - unsigned char rate); - -/** - * @brief Command for step - * @details On receipt of this command, a device shall move from its current level in an - * up or down direction in a continuous fashion - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] step_mode The Step mode field shall be one of the non-reserved values\n - * 0x00 : Up\n - * 0x01 : Down\n - * @param[in] step_size Step size - * @param[in] transition_time The Transition time field specifies the time that shall be taken to perform the step,\n - * in tenths of a second. A step is a change in the CurrentLevel of 'Step size' units.\n - * The actual time taken should be as close to this as the device is able. If the\n - * Transition time field is 0xffff the device should move as fast as it is able.\n - * If the device is not able to move at a variable rate, the Transition time field may be\n - * disregarded.\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_levelctrl_step( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char step_mode, - unsigned char step_size, - unsigned short transition_time); - -/** - * @brief Command for stop - * @details This command has no payload. Upon receipt of this command, any Move to - * Level, Move or Step command (and their 'with On/Off' variants) currently in - * process shall be terminated. The value of CurrentLevel shall be left at its value - * upon receipt of the Stop command, and RemainingTime shall be set to zero. - * This command has two entries in Table 3.1, one for the Move to Level, Move and - * Set commands, and one for their 'with On/Off' counterparts. This is solely for - * symmetry, to allow easy choice of one or other set of commands ? the Stop - * commands are identical. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_levelctrl_stop( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep); - -/** - * @brief Command for move to level with on/off - * @details On receipt of this command, a device shall move from its current level to the - * value given in the Level field. The meaning of 'level' is device dependent ? e.g. - * for a light it may mean brightness level.\n\n - * The movement shall be as continuous as technically practical, i.e. not a step - * function, and the time taken to move to the new level shall be equal to the value of - * the Transition time field, in tenths of a second, or as close to this as the device is - * able.\n\n - * If the Transition time field takes the value 0xffff then the time taken to move to - * the new level shall instead be determined by the OnOffTransitionTime attribute. If - * OnOffTransitionTime , which is an optional attribute, is not present, the device - * shall move to its new level as fast as it is able.\n\n - * If the device is not able to move at a variable rate, the Transition time field may be - * disregarded.\n\n - * The Move to Level (with On/Off), Move (with On/Off) and Step (with On/Off) - * commands have identical payloads to the Move to Level, Move and Step - * commands respectively. The also have the same effects, except for the following - * additions. - * * Before commencing any command that has the effect of increasing - * CurrentLevel, the OnOff attribute of the On/Off cluster on the same endpoint, if - * implemented, shall be set to On. - * * If any command that decreases CurrentLevel reduces it to the minimum level - * allowed by the device, the OnOff attribute of the On/Off cluster on the same - * endpoint, if implemented, shall be set to Off. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] level Brightness level - * @param[in] transition_time The Transition time field, in tenths of a second, \n - * or as close to this as the device is able - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_levelctrl_move_to_level_with_on_off( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char level, - unsigned short transition_time); - -/** - * @brief Command for move with on/off - * @details On receipt of this command, a device shall move from its current level in an - * up or down direction in a continuous fashion\n - * The Move to Level (with On/Off), Move (with On/Off) and Step (with On/Off) - * commands have identical payloads to the Move to Level, Move and Step - * commands respectively. The also have the same effects, except for the following - * additions. - * * Before commencing any command that has the effect of increasing - * CurrentLevel, the OnOff attribute of the On/Off cluster on the same endpoint, if - * implemented, shall be set to On. - * * If any command that decreases CurrentLevel reduces it to the minimum level - * allowed by the device, the OnOff attribute of the On/Off cluster on the same - * endpoint, if implemented, shall be set to Off. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] move_mode The Move mode field shall be one of the non-reserved values\n - * 0x00 : Up\n - * 0x01 : Down\n - * @param[in] rate The Rate field specifies the rate of movement in units per second. \n - * The actual rate of movement should be as close to this rate as the device is able.\n - * If the Rate field is 0xff the device should move as fast as it is able.\n - * If the device is not able to move at a variable rate, this field may be disregarded.\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_levelctrl_move_with_on_off( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char move_mode, - unsigned char rate); - -/** - * @brief Command for step with on/off - * @details On receipt of this command, a device shall move from its current level in an - * up or down direction in a continuous fashion. \n\n - * The Move to Level (with On/Off), Move (with On/Off) and Step (with On/Off) - * commands have identical payloads to the Move to Level, Move and Step - * commands respectively. The also have the same effects, except for the following - * additions. \n\n - * * Before commencing any command that has the effect of increasing - * CurrentLevel, the OnOff attribute of the On/Off cluster on the same endpoint, if - * implemented, shall be set to On. \n\n - * * If any command that decreases CurrentLevel reduces it to the minimum level - * allowed by the device, the OnOff attribute of the On/Off cluster on the same - * endpoint, if implemented, shall be set to Off. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] step_mode The Step mode field shall be one of the non-reserved values\n - * 0x00 : Up\n - * 0x01 : Down\n - * @param[in] step_size Step size - * @param[in] transition_time The Transition time field specifies the time that shall be - * taken to perform the step, in tenths of a second. A step is a change in the - * CurrentLevel of 'Step size' units.\n\n - * The actual time taken should be as close to this as the device is able. If the - * Transition time field is 0xffff the device should move as fast as it is able. \n\n - * If the device is not able to move at a variable rate, the Transition time field may be - * disregarded.\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_levelctrl_step_with_on_off( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char step_mode, - unsigned char step_size, - unsigned short transition_time); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-on-off-cluster.h b/include/zcl/zb-zcl-on-off-cluster.h deleted file mode 100644 index e214d69..0000000 --- a/include/zcl/zb-zcl-on-off-cluster.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-on-off-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_MODULE On/Off Cluster - * - * @brief zigbee on/off cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 3.40 Command IDs for the On/Off Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Off | M | - * | 0x01 | On | M | - * | 0x02 | Toggle | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief On/Off value - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_OFF = 0x00, /**< off */ - ZB_ZCL_ON = 0x01, /**< on */ - ZB_ZCL_TOGGLE = 0x02, /**< toggle */ -} zb_zcl_onoff_e; - -/** - * @brief Command for on - * @details On receipt of 'on' command, a device shall enter its 'Off' state. - * This state is device dependent, but it is recommended that it is used for power off or\n - * similar functions.\n - * On receipt of 'off' command, a device shall enter its 'On' state. This state is\n - * device dependent, but it is recommended that it is used for power on or similar - * functions.\n - * On receipt of this command, if a device is in its 'Off' state it shall enter\n - * its 'On' state. Otherwise, if it is in its 'On' state it shall enter its 'Off' state\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] on_off_type #ZB_ZCL_OFF \n - * #ZB_ZCL_ON \n - * #ZB_ZCL_TOGGLE \n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_onoff_control( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - zb_zcl_onoff_e on_off_type); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-poll-control-cluster.h b/include/zcl/zb-zcl-poll-control-cluster.h deleted file mode 100644 index fd47808..0000000 --- a/include/zcl/zb-zcl-poll-control-cluster.h +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-poll-control-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_MODULE Poll Control Cluster - * - * @brief zigbee poll control cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - - -/* Table 9.28 Commands Generated by the Poll Control Server - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Check-in | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for check-in response - * @details The Poll Control Cluster server sends out a Check-in command to the devices to - * which it is paired based on the server's Check-inInterval attribute. It does this to - * find out if any of the Poll Control Cluster Clients with which it is paired are - * interested in having it enter fast poll mode so that it can be managed. This request - * is sent out based on either the Check-inInterval, or the next Check-in value in the - * Fast Poll Stop Request generated by the Poll Control Cluster Client.\n - * The Check-in command expects a Check-in Response command to be sent back - * from the Poll Control Client. If the Poll Control Server does not receive a Check- - * in response back from the Poll Control Client up to7.68 seconds it is free to return - * to polling according to the LongPollInterval.\n - * \n - * The Poll Control Cluster is used on end devices that may be battery powered. In - * order to conserve battery life, it is important that the Poll Control Server maintain - * certain boundaries for the setting of the Check-inInterval, LongPollInterval and - * the ShortPollInterval. Therefore, while these attributes are all Read/Write, it is - * possible that a battery-powered device might maintain its own boundary for the - * min and max of each of these attributes. The end device implementing the Poll - * Control Cluster Server may define its own boundaries for these attributes in order - * to protect itself against a power drain due to improper configuration. - * For instance a battery powered device may not allow another device to set its - * Check-inInterval to too short a value or its FastPollTimeout to too long an interval - * because it might cause the device to send too frequent check-in messages on the - * network and stay in fast poll mode for too long a time resulting in a drain on the - * battery.\n - * The Check-inInterval, LongPollInterval and ShortPollInterval should be set such - * that:\n - * \n - * - Check-in Interval >= Long Poll Interval >= Short Poll Interval\n - * - The default values chosen for this cluster are:\n - * - Check-in Interval = 1 hour = 0x3840 quarterseconds.\n - * - Long Poll Interval = 5 seconds = 0x14 quarterseconds.\n - * - Short Poll Interval = 2 quarterseconds = 0x02 quarterseconds.\n - * - Fast Poll Timeout = 10 seconds = 0x28 quarterseconds.\n - * \n - * It should be noted that for the Check-in Interval, 0 is a special value and does not\n - * apply to this equation.\n - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] user_data user data - * - * @see zb_zcl_pollctrl_set_long_poll_interval() - * @see zb_zcl_pollctrl_set_short_poll_interval() - */ -typedef void (*zb_zcl_pollctrl_check_in)( - nwk_addr addr16, - unsigned char ep, - void *user_data); - -/* Table 9.29 Commands Generated by the Poll Control Client - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Check-in Response | M | - * | 0x00 | Fast Poll Stop | M | - * | 0x00 | Set Long Poll Interval | O | - * | 0x00 | Set Short Poll Interval | O | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for check-in response - * @details The Check-in Response is sent in response to the receipt of a Check-in command.\n - * The Check-in Response is used by the Poll Control Client to indicate whether it - * would like the device implementing the Poll Control Cluster Server to go into a - * fast poll mode and for how long. If the Poll Control Cluster Client indicates that it - * would like the device to go into a fast poll mode, it is responsible for telling the - * device to stop fast polling when it is done sending messages to the fast polling - * device. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] start_fast_polling This Boolean value indicates whether or not the Poll - * Control Server device should begin fast polling or not.\n - * If the Start Fast Polling value is true, the server device - * is expected to begin fast polling until the Fast Poll - * Timeout has expired. If the Start Fast Polling argument - * is false, the Poll Control Server may continue in normal - * operation and is not required to go into fast poll mode.\n - * @param[in] fast_poll_timeout The Fast Poll Timeout value indicates the number of - * quarterseconds during which the device should continue - * fast polling. If the Fast Poll Timeout value is 0, the - * device is expected to continue fast polling until the - * amount of time indicated it the FastPollTimeout attribute - * has elapsed or it receives a Fast Poll Stop command\n - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_pollctrl_check_in_response( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char start_fast_polling, - unsigned short fast_poll_timeout); - -/** - * @brief Command description for fast poll stop - * @details The Fast Poll Stop command is used to stop the fast poll mode initiated by the\n - * Check-in response. The Fast Poll Stop command has no payload. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_pollctrl_fast_poll_stop( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep); - -/** - * @brief Command description for set long poll interval - * @details The Set Long Poll Interval command is used to set the read only LongPollInterval - * attribute.\n - * When the Poll Control Server receives the Set Long Poll Interval Command, it - * should check its internal minimal limit and the attributes relationship defined in - * 9.6.4.2 if the new Long Poll Interval is acceptable. If the new value is acceptable, - * the new value shall be saved to the LongPollInterval attribute.If the new value is - * not acceptable, the Poll Control Server shall send a default response of - * INVALID_VALUE (0x87) and the LongPollInterval attribute value is not updated.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] new_long_poll_interval long poll interval - * @param[in] cb Resopnse callback function - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_pollctrl_check_in() - * - */ -int zb_zcl_pollctrl_set_long_poll_interval( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned int new_long_poll_interval, - zb_zcl_pollctrl_check_in cb, - void *user_data); - -/** - * @brief Command description for set short poll interval - * @details The Set Short Poll Interval command is used to set the read only - * ShortPollInterval attribute.\n - * When the Poll Control Server receives the Set Short Poll Interval Command, it - * should check its internal minimal limit and the attributes relationship defined in - * 9.6.4.2 if the new Short Poll Interval is acceptable. If the new value is acceptable, - * the new value shall be saved to the ShortPollInterval attribute. If the new value is - * not acceptable, the Poll Control Server shall send a default response of - * INVALID_VALUE (0x87) and the ShortPollInterval attribute value is not updated.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] new_short_poll_interval long poll interval - * @param[in] cb Resopnse callback function - * @param[in] user_data user_data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_pollctrl_check_in() - */ -int zb_zcl_pollctrl_set_short_poll_interval( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned int new_short_poll_interval, - zb_zcl_pollctrl_check_in cb, - void *user_data); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-scenes-cluster.h b/include/zcl/zb-zcl-scenes-cluster.h deleted file mode 100644 index bc9cf6c..0000000 --- a/include/zcl/zb-zcl-scenes-cluster.h +++ /dev/null @@ -1,521 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_SCENES_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_SCENES_CLUSTER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zcl-scenes-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_SCENE_CLUSTER_MODULE Scene Cluster - * - * @brief zigbee scene cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_SCENE_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 3.38 Generated Command IDs for the Scenes Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Add scene response | M | - * | 0x01 | View scene response | M | - * | 0x02 | Remove scene response | M | - * | 0x03 | Remove all scene response | M | - * | 0x04 | Store scene response | M | - * | 0x05 | Reserved | - | - * | 0x06 | Get scene membership response | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for add scene response - * @details This command is generated in response to a received Add Scene command. - * The Status field is set to SUCCESS, INSUFFICIENT_SPACE or - * INVALID_FIELD (the group is not present in the Group Table) as appropriate. - * The Group ID and Scene ID fields are set to the corresponding fields of the - * received Add Scene command. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_NOT_FOUND \n - * #ZB_ZCL_INVALID_FIELD - * @param[out] group_id Group id - * @param[out] scene_id Scene id - * @param[out] user_data user data - * - * @see zb_zcl_group_add_scene() - */ -typedef void (*zb_zcl_scene_add_scene_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned short group_id, - unsigned char scene_id, - void *user_data); - -/** - * @brief Command description for view scene response - * @details This command is generated in response to a received View Scene command - * The entry in the Scene Table with Scene ID and Group ID given in the received - * View Scene command is located (if possible). The Status field is set to SUCCESS, - * NOT_FOUND (the scene is not present in the Scene Table) or INVALID_FIELD - * (the group is not present in the Group Table) as appropriate. The Group ID and - * Scene ID fields are set to the corresponding fields in the received View Scene - * command. - * If the status is SUCCESS, the Transition time, Scene Name and Extension field - * fields are copied from the corresponding fields in the table entry, otherwise they - * are omitted. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_NOT_FOUND \n - * #ZB_ZCL_INVALID_FIELD - * @param[out] group_id Group id - * @param[out] scene_id Scene id - * @param[out] transition_time Transition time - * @param[out] scene_name Scene name - * @param[out] extension_field_sets Extension field sets, one per cluster\n - * Extension field sets =\n - * {{ClusterID 1, length 1, {extension field set 1}},\n - * {ClusterID 2, length 2, {extension field set 2}}, ... }. - * @param[out] ext_len length of extension fields set - * @param[out] user_data user data - * - * @see zb_zcl_group_view_scene() - */ -typedef void (*zb_zcl_scene_view_scene_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned short group_id, - unsigned char scene_id, - unsigned short transition_time, - const char *scene_name, - const char *extension_field_set, - unsigned short ext_len, - void *user_data); - -/** - * @brief Command description for remove scene response - * @details This command is generated in response to a received Remove Scene command. - * The Status field is set to SUCCESS, NOT_FOUND (the scene is not - * present in the Scene Table) or INVALID_FIELD (the group is not present in the - * Group Table) as appropriate. The Group ID and Scene ID fields are set to the - * corresponding fields of the received Remove Scene command. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_INVALID_FIELD \n - * @param[out] group_id Group id - * @param[out] scene_id Scene id - * @param[out] user_data user data - * - * @see zb_zcl_group_remove_scene() - */ -typedef void (*zb_zcl_scene_remove_scene_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned short group_id, - unsigned char scene_id, - void *user_data); - -/** - * @brief Command description for remove all scene response - * @details This command is generated in response to a received Remove All Scenes - * command. The Status field is set to SUCCESS or INVALID_FIELD - * (the group is not present in the Group Table) as appropriate. The Group ID field is - * set to the corresponding field of the received Remove All Scenes command. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_INVALID_FIELD \n - * @param[out] group_id Group id - * @param[out] scene_id Scene id - * @param[out] user_data user data - * - * @see zb_zcl_group_remove_all_scene() - */ -typedef void (*zb_zcl_scene_remove_all_scene_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned short group_id, - void *user_data); - -/** - * @brief Command description for store scene response - * @details This command is generated in response to a received Store Scene command. - * The Status field is set to SUCCESS, INSUFFICIENT_SPACE or - * INVALID_FIELD (the group is not present in the Group Table) as appropriate. - * The Group ID and Scene ID fields are set to the corresponding fields of the - * received Store Scene command. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_INVALID_FIELD \n - * #ZB_ZCL_INSUFFICIENT_SPACE - * @param[out] group_id Group id - * @param[out] scene_id Scene id - * @param[out] user_data user data - * - * @see zb_zcl_group_store_scene() - */ -typedef void (*zb_zcl_scene_store_scene_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned short group_id, - unsigned char scene_id, - void *user_data); - -/** - * @brief Command description for get all scene membership response - * @details This command is generated in response to a received Get Scene Membership - * command - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint number - * @param[out] status Status code see zb-zcl-type.h\n - * #ZB_ZCL_SUCCESS \n - * #ZB_ZCL_INVALID_FIELD \n - * @param[out] capacity The Capacity field shall contain the remaining capacity of the \n - * scene table of the device. (for all groups). The following values\n - * apply:\n - * 0 : No further scenes may be added.\n - * 0 < Capacity < 0xfeCapacity holds the number of scenes that may be added\n - * 0xfe : At least 1 further scene may be added (exact number is unknown)\n - * 0xff : It is unknown if any further scenes may be added\n - * @param[out] group_id Group id - * @param[out] scene_count The Scene count field shall contain the number of scenes \n - * contained in the Scene list field. - * @param[out] scene_list The Scene list field shall contain the identifiers of all the \n - * scenes in the scene table with the corresponding Group ID. - * @param[out] user_data user data - * - * @see zb_zcl_scene_get_scene_membership() - */ -typedef void (*zb_zcl_scene_get_scene_membership_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned char status, - unsigned char capacity, - unsigned short group_id, - unsigned char scene_count, - unsigned char *scene_list, - void *user_data); - -/* Table 3.37 Received Command IDs for the Scenes Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Add scene | M | - * | 0x01 | View scene | M | - * | 0x02 | Remove scene | M | - * | 0x03 | Remove all scene | M | - * | 0x04 | Store scene | M | - * | 0x05 | Recall scene | M | - * | 0x06 | Get scene membership | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/* Reference : Extension field sets = - * {{ClusterID 1, length 1, {extension field set 1}}, {ClusterID 2, length 2, - * {extension field set 2}}, ... }. - */ - -/** - * @brief Command description for add scenes - * @details The Add Scene command shall be addressed to a single device (not a group) - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] group_id Group ID - * @param[in] scene_id Scene ID - * @param[in] transition_time Transition time - * @param[in] scene_name Scene name - * @param[in] ext_field_len length of extension fields sets - * @param[in] extension_field_sets Extension field sets, one per cluster\n - * Extension field sets = \n - * {{ClusterID 1, length 1, {extension field set 1}}, \n - * {ClusterID 2, length 2, {extension field set 2}}, ... }. - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_scene_add_scene_rsp() - */ -int zb_zcl_scene_add_scene( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - unsigned char scene_id, - unsigned short transition_time, - const char *scene_name, - unsigned short ext_field_len, - const char *extension_field_sets, - zb_zcl_scene_add_scene_rsp cb, - void *user_data); - -/** - * @brief Command description for view scenes - * @details The View Scene command shall be addressed to a single device (not a group) - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] group_id Group ID - * @param[in] scene_id Scene ID - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_scene_view_scene_rsp() - */ -int zb_zcl_scene_view_scene( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - unsigned char scene_id, - zb_zcl_scene_view_scene_rsp cb, - void *user_data); - -/** - * @brief Command description for remove scenes command - * @details The Remove Scene command may be addressed to a single device or to a group. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] group_id Group ID - * @param[in] scene_id Scene ID - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_scene_view_scene_rsp() - */ -int zb_zcl_scene_remove_scene( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - unsigned char scene_id, - zb_zcl_scene_remove_scene_rsp cb, - void *user_data); - -/** - * @brief Command description for remove all scenes command - * @details The Remove All Scenes may be addressed to a single device or to a group. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] group_id Group ID - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_scene_remove_all_scene_rsp() - */ -int zb_zcl_scene_remove_all_scene( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - zb_zcl_scene_remove_all_scene_rsp cb, - void *user_data); - -/** - * @brief Command description for remove scenes command - * @details The Store Scene command may be addressed to a single device or to a group. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] group_id Group ID - * @param[in] scene_id Scene ID - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_scene_store_scene_rsp() - */ -int zb_zcl_scene_store_scene( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - unsigned char scene_id, - zb_zcl_scene_store_scene_rsp cb, - void *user_data); - -/** - * @brief Command description for recall scenes command - * @details The Recall Scene command may be addressed to a single device or to a group. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] group_id Group ID - * @param[in] scene_id Scene ID - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - */ -int zb_zcl_scene_recall_scene( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - unsigned char scene_id); - -/** - * @brief Command description to get scenes membership - * @details The Get Scene Membership command can be used to find an unused scene - * number within the group when no commissioning tool is in the network, or for a - * commissioning tool to get used scenes for a group on a single device or on all - * devices in the group. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] group_id Group ID - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_scene_store_scene_rsp() - */ -int zb_zcl_scene_get_scene_membership( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned short group_id, - zb_zcl_scene_get_scene_membership_rsp cb, - void *user_data); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_SCENES_CLUSTER_H__ */ - diff --git a/include/zcl/zb-zcl-simple-metering-cluster.h b/include/zcl/zb-zcl-simple-metering-cluster.h deleted file mode 100644 index a8b4ca1..0000000 --- a/include/zcl/zb-zcl-simple-metering-cluster.h +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_SIMPLE_METERING_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_SIMPLE_METERING_CLUSTER_H__ - -#include - -/** - * @file zb-zcl-simple-metering-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_SIMPLE_METERING_CLUSTER_MODULE Simple Metering Cluster - * - * @brief zigbee simple metering cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_SIMPLE_METERING_CLUSTER_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table D.22 Generated Command IDs for the Simple Metering Server - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Get Profile Response | O | - * | 0x01 | Request Mirror | O | - * | 0x02 | Remove Mirror | O | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for get profile response - * @details This command is generated when the Client command GetProfile is received. - * - * @since_tizen 3.0 - * - * @param[out] addr16 Network address - * @param[out] ep Endpoint ID - * @param[out] end_time EndTime: - * 32 bit value (in UTC) representing the end time of the most - * chronologically recent interval being requested. Example: Data collected from - * 2:00 PM to 3:00 PM would be specified as a 3:00 PM interval (end time).\n\n It is - * important to note that the current interval accumulating is not included in most - * recent block but can be retrieved using the CurrentPartialProfileIntervalValue - * attribute. - * @param[out] status Status: below lists the valid values returned in the Status field.\n - * 0x00 : Success\n - * 0x01 : Undefined Interval Channel requested\n - * 0x02 : Interval Channel not supported\n - * 0x03 : Invalid End Time\n - * 0x04 : More periods requested than can be returned\n - * 0x05 : No intervals available for the requested time\n - * @param[out] profile_interval_period ProfileIntervalPeriod: - * Represents the interval or time frame used to capture - * metered Energy, Gas, and Water consumption for profiling purposes. - * ProfileIntervalPeriod is an enumerated field representing the following - * timeframes listed in below :\n\n - * 0 : Daily\n - * 1 : 60 minutes\n - * 2 : 30 minutes\n - * 3 : 15 minutes\n - * 4 : 10 minutes\n - * 5 : 7.5 minutes\n - * 6 : 5 minutes\n - * 7 : 2.5 minutes\n - * @param[out] number_of_period_delivered NumberofPeriodsDelivered: - * Represents the number of intervals the device is returning. - * Please note the number of periods returned in the Get Profile Response - * command can be calculated when the packets are received and can replace the - * usage of this field. The intent is to provide this information as a convenience. - * @param[out] interval Intervals (24bit integer array) : - * Series of interval data captured using the period specified by the - * ProfileIntervalPeriod field. The content of the interval data depend of the type of - * information requested using the Channel field in the Get Profile Command. Data - * is organized in a reverse chronological order, the most recent interval is - * transmitted first and the oldest interval is transmitted last. Invalid intervals - * should be marked as 0xFFFFFF. - * @param[out] user_data User data - * - * @see zb_zcl_simple_metering_get_profile() - * - */ -typedef void (*zb_zcl_smetering_get_profile_rsp)( - nwk_addr addr16, - unsigned char ep, - unsigned int end_time, - unsigned char status, - unsigned char profile_interval_period, - unsigned char number_of_period_delivered, - unsigned char *interval, - void *user_data); - -/* Table 3.56 Received Command IDs for the Alarms Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Get Profile | O | - * | 0x01 | Request Mirror Response | O | - * | 0x02 | Removed Mirror | O | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for get profile - * @details The GetProfile command is generated when a client device wishes to retrieve a - * list of captured Energy, Gas or water consumption for profiling purposes.\n\n Due to - * the potentially large amount of profile data available, the client device should - * store previously gathered data and only request the most current data.\n\n When - * initially gathering significant amounts of historical interval data, the GetProfile - * command should not be issued any more frequently than 7.5 seconds to prevent - * overwhelming the ZigBee network. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] interval_channel Enumerated value used to select the quantity of interest - * returned by the Get Profile Response Command. The Interval - * Channel values are listed in \n\n - * Bit 0 : Consumption Delivered - * Bit 1 : Consumption Received - * @param[in] end_time 32 bit value (in UTCTime) used to select an Intervals block from - * all the Intervals blocks available. The Intervals block returned is the - * most recentblock with its EndTime equal or older to the one provided.\n\n - * The most recent Intervals block is requested using an End Time set to 0x00000000, - * subsequent Intervals block are requested using an End time set to the EndTime of the - * previous block - (number of intervals of the previous block * ProfileIntervalPeriod). - * @param[in] number_of_periods Represents the number of intervals being requested. This - * value can't exceed the size stipulated in the MaxNumberOfPeriodsDelivered - * attribute. If more intervals are requested than can be delivered, the - * GetProfileResponse will return the number of intervals equal to - * MaxNumberOfPeriodsDelivered. If fewer intervals available for the time period, - * only those available are returned. - * @param[in] cb Resopnse callback function - * @param[in] user_data User data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zcl_smetering_get_profile_rsp() - */ -int zb_zcl_smetering_get_profile( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char interval_channel, - unsigned char end_time, - unsigned char number_of_periods, - zb_zcl_smetering_get_profile_rsp cb, - void *user_data); - -/** - * @brief Command description for request mirror response - * @details The Request Mirror Response Command allows the ESP to inform a sleepy - * Metering Device it has the ability to store and mirror its data. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] src_ep Endpoint ID - * @param[in] endpoint_id 16 Bit Unsigned Integer indicating the End Point ID to contain - * the Metering Devices meter data. Valid End Point ID values are 0x0001 to 0x00F0. If - * the ESP is unable to mirror the Metering Device data, EndPoint ID shall be - * returned as 0xFFFF. All other EndPoint ID values are reserved. If valid, the - * Metering device shall use the EndPoint ID to forward its metered data. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_smetering_request_mirror_rsp( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned short endpoint_id); - -/** - * @brief Command description for mirror removed - * @details The Mirror Removed Command allows the ESP to inform a sleepy Metering - * Device mirroring support has been removed or halted. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] src_ep Endpoint ID - * @param[in] removed_endpoint_id 16 Bit Unsigned Integer indicating the End Point ID - * previously containing the Metering Devices meter data. - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_smetering_mirror_removed( - zigbee_h handle, - nwk_addr addr16, - unsigned char src_ep, - unsigned short removed_endpoint_id); - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_SIMPLE_METERING_CLUSTER_H__ */ diff --git a/include/zcl/zb-zcl-thermostat-cluster.h b/include/zcl/zb-zcl-thermostat-cluster.h deleted file mode 100644 index 85fd563..0000000 --- a/include/zcl/zb-zcl-thermostat-cluster.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_THERMOSTAT_CLUSTER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_THERMOSTAT_CLUSTER_H__ - -#include - -/** - * @file zb-zcl-thermostat-cluster.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_THERMOSTAT_MODULE Thermostat Cluster - * - * @brief zigbee thermostat cluster description - * - * @section CAPI_NETWORK_ZIGBEE_ZCL_THERMOSTAT_MODULE_HEADER Header - * \#include - * - * @since_tizen 3.0 - * - * @{ - */ - -/* Table 6.18 Command IDs for the Thermostat Cluster - * +--------------------------------+--------------------------------------+------------+ - * |Command Identifier Field Value | Description | Mandatory/ | - * | | | Optional | - * +--------------------------------+--------------------------------------+------------+ - * | 0x00 | Setpoint Raise/Lower | M | - * +--------------------------------+--------------------------------------+------------+ - */ - -/** - * @brief Command description for setpoint raise/lower - * @details The attributes for the indicated setpoint(s) shall be increased by the amount - * specified in the Amount field. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address - * @param[in] ep Endpoint ID - * @param[in] mode The mode field shall be set to one of the non-reserved values in below. It - * specifies which setpoint is to be configured. If it is set to auto, then both setpoints - * shall be adjusted.\n - * 0x00 : Heat (adjust Heat setpoint)\n - * 0x01 : Cool (adjust Cool setpoint)\n - * 0x02 : Both (adjust Heat and Cool setpoint)\n - * @param[in] amount The amount field is a signed 8-bit integer that specifies the amount the setpoint(s) - * are to be a increased (or decreased) by, in steps of 0.1C - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - */ -int zb_zcl_thermostat_adjust_setpoint( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - unsigned char mode, - unsigned char amount); - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_THERMOSTAT_CLUSTER_H__ */ - diff --git a/include/zcl/zb-zcl-type.h b/include/zcl/zb-zcl-type.h deleted file mode 100644 index 4073a7e..0000000 --- a/include/zcl/zb-zcl-type.h +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_TYPE_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZCL_TYPE_H__ - -#include -#include - -/** - * @file zb-zcl-type.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief ACL type - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_WRITABLE = 1, /**< Writable */ - ZB_ZCL_REPORTABLE = 2, /**< Reportable */ -} zb_zcl_acl_type_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief data measuring type - * - * @since_tizen 3.0 - */ -typedef enum { - DATA_TYPE_NONE = 0, /**< Data type none */ - DATA_TYPE_DISCRETE = 1, /**< Discrete data type */ - DATA_TYPE_ANALOG = 2 /**< Analog data type */ -} zb_zcl_data_category_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Table 2.138 ZCL Enumerations Description - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZCL_SUCCESS = 0x00, /**< Operation was successful */ - ZB_ZCL_FAILURE = 0x01, /**< Operation was not successful. */ - /**< The sender of the command does not have authorization to carry out this command. */ - ZB_ZCL_NOT_AUTHORIZED = 0x7E, - /**< reserved field/subfield/bit contains a non-zero value. */ - ZB_ZCL_RESERVED_FIELD_NOT_ZERO = 0x7F, - /**< The command appears to contain the wrong fields, as - detected either by the presence of one or more invalid - field entries or by there being missing fields. Command - not carried out. Implementer has discretion as to - whether to return this error or INVALID_FIELD. */ - ZB_ZCL_MALFORMED_COMMAND = 0x80, - /**< The specified cluster command is not supported on the device. */ - ZB_ZCL_UNSUP_CLUSTER_COMMAND = 0x81, - /**< The specified general ZCL command is not supported on the device. */ - ZB_ZCL_UNSUP_GENERAL_COMMAND = 0x82, - /**< A manufacturer specific unicast, cluster specific - command was received with an unknown manufacturer - code, or the manufacturer code was recognized but the - command is not supported. */ - ZB_ZCL_UNSUP_MANUF_CLUSTER_COMMAND = 0x83, - /**< A manufacturer specific unicast, ZCL specific command - was received with an unknown manufacturer code, or - the manufacturer code was recognized but the command - is not supported. */ - ZB_ZCL_UNSUP_MANUF_GENERAL_COMMAND = 0x84, - /**< At least one field of the command contains an incorrect - value, according to the specification the device is - implemented to. */ - ZB_ZCL_INVALID_FIELD = 0x85, - /**< The specified attribute does not exist on the device. */ - ZB_ZCL_UNSUPPORTED_ATTRIBUTE = 0x86, - /**< Out of range error, or set to a reserved value. Attribute - keeps its old value. - Note that an attribute value may be out of range if an - attribute is related to another, e.g. with minimum and - maximum attributes. See the individual attribute - descriptions for specific details. */ - ZB_ZCL_INVALID_VALUE = 0x87, - /**< Attempt to write a read only attribute. */ - ZB_ZCL_READ_ONLY = 0x88, - /**< An operation (e.g. an attempt to create an entry in a - table) failed due to an insufficient amount of free space - available. */ - ZB_ZCL_INSUFFICIENT_SPACE = 0x89, - /**< An attempt to create an entry in a table failed due to a - duplicate entry already being present in the table. */ - ZB_ZCL_DUPLICATE_EXISTS = 0x8A, - /**< The requested information (e.g. table entry) could not be found. */ - ZB_ZCL_NOT_FOUND = 0x8B, - /**< Periodic reports cannot be issued for this attribute. */ - ZB_ZCL_UNREPORTABLE_ATTRIBUTE = 0x8C, - /**< The data type given for an attribute is incorrect. - Command not carried out. */ - ZB_ZCL_INVALID_DATA_TYPE = 0x8D, - /**< The selector for an attribute is incorrect. */ - ZB_ZCL_INVALID_SELECTOR = 0x8E, - /**< A request has been made to read an attribute that the - requestor is not authorized to read. No action taken. */ - ZB_ZCL_WRITE_ONLY = 0x8F, - /**< Setting the requested values would put the device in an - inconsistent state on startup. No action taken. */ - ZB_ZCL_INCONSISTENT_STARTUP_STATE = 0x90, - /**< An attempt has been made to write an attribute that is - present but is defined using an out-of-band method and - not over the air. */ - ZB_ZCL_DEFINED_OUT_OF_BAND = 0x91, - /**< The supplied values (e.g. contents of table cells) are - inconsistent. */ - ZB_ZCL_INCONSISTENT = 0x92, - /**< The credentials presented by the device sending the - command are not sufficient to perform this action. */ - ZB_ZCL_ACTION_DENIED = 0x93, - /**< The exchange was aborted due to excessive response time. */ - ZB_ZCL_TIMEOUT = 0x94, - /**< Failed case when a client or a server decides to abort the - upgrade process. */ - ZB_ZCL_ABORT = 0x95, - /**< Invalid OTA upgrade image (ex. failed signature - validation or signer information check or CRC check). */ - ZB_ZCL_INVALID_IMAGE = 0x96, - /**< Server does not have data block available yet. */ - ZB_ZCL_WAIT_FOR_DATA = 0x97, - /**< No OTA upgrade image available for a particular client. */ - ZB_ZCL_NO_IMAGE_AVAILABLE = 0x98, - /**< The client still requires more OTA upgrade image files - in order to successfully upgrade. */ - ZB_ZCL_REQUIRE_MORE_IMAGE = 0x99, -} zb_zcl_status_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Figure 2.28 Format of the Attribute Report Fields - * - * @since_tizen 3.0 - */ -typedef struct discover_attribute_info_record_s* discover_attr_info_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief structure for reading attribute - * - * @since_tizen 3.0 - */ -typedef struct read_structured_attribute_record_s* read_structured_attr_record_h; - - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Figure 2.16 Format of the Attribute Reporting Configuration Record - * - * @since_tizen 3.0 - */ -typedef struct read_attribute_status_record_s* read_attr_status_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief write attributes data structure - * - * @since_tizen 3.0 - */ -typedef struct write_attribute_record_s* write_attr_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief For write attribute response command - * - * @since_tizen 3.0 - */ -typedef struct write_attribute_status_record_s* write_attr_status_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Figure 2.11 Format of the Write Attribute Record Field - * - * @since_tizen 3.0 - */ -typedef struct write_attribute_structured_status_record_s* write_attr_structured_status_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Figure 2.32 Format of the Write Attribute Record Field - * - * @since_tizen 3.0 - */ -typedef struct write_attribute_structured_record_s* write_attr_structured_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Figure 2.24 Format of the Attribute Report Fields - * - * @since_tizen 3.0 - */ -typedef struct attribute_report_s* attr_report_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief reporting configuration record structure - * - * @since_tizen 3.0 - */ -typedef struct reporting_configuration_record_s* report_config_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Read reporting configuration record - * - * @since_tizen 3.0 - */ -typedef struct read_reporting_configuration_record_s* read_report_config_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Figure 2.18 Format of the Attribute Status Record Field - * - * @since_tizen 3.0 - */ -typedef struct reporting_configuration_response_record_s* report_config_response_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Figure 12.5 Format of the Extended Attribute Information Fields - * - * @since_tizen 3.0 - */ -typedef struct extended_attribute_infomation_s* extended_attr_info_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Table 2.16 simple data type - * - * @since_tizen 3.0 - */ -typedef struct zb_value_s* zb_value_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Figure 2.8 Format of Attribute Value Field for an array, Set or Bag - * - * @since_tizen 3.0 - */ -typedef struct attribute_array_s* attribute_array_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE - * @brief Global record type - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_GLOBAL_READ_ATTR = 0, - ZB_GLOBAL_WRITE_ATTR, - ZB_GLOBAL_CONFIG_REPORT, - ZB_GLOBAL_READ_REPORT_CONFIG, - ZB_GLOBAL_WRITE_ATTR_STRUCTURED -} zb_zcl_global_record_e; - -/** - * @brief The structure type for record data of zigbee global request. - * @details This structure contains record data of zigbee global request. - * ex) Read/Write attributes response, Configure reporting response. - * - * @since_tizen 3.0 - */ -typedef struct { - zb_zcl_global_record_e type; - union { - read_attr_status_record_h *read_attr; /**< Attribute Reporting Configuration Record */ - write_attr_status_record_h *write_attr; /**< For write attribute response command */ - report_config_response_record_h *report_config_rsp; /**< Attribute Status Record Field */ - report_config_record_h *report_config; /**< Reporting configuration record structure */ - write_attr_structured_record_h *write_attr_structured; /**< Write Attribute Record Field */ - } record; - int records_len; /**< The number of records */ -} zb_global_record_data_s; - -/** - * @} - */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_TYPE_H__ */ diff --git a/include/zcl/zb_zcl_alarm_cluster.h b/include/zcl/zb_zcl_alarm_cluster.h new file mode 100644 index 0000000..949277d --- /dev/null +++ b/include/zcl/zb_zcl_alarm_cluster.h @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_alarm_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_MODULE Alarm Cluster + * + * @brief Zigbee alarm cluster commands + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/* Table 3.57 Generated Command IDs for the Alarms Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Alarm | M | + * | 0x01 | Get alarm response | O | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Called after 'get alarm' command + * @details The get alarm response command returns the results of a request to retrieve + * information from the alarm log, along with a time stamp indicating when the + * alarm situation was detected. + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Destination endpoint + * @param[out] status Status code \n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_NOT_FOUND + * @param[out] alarm_code Alarm code (8bit enumeration) + * @ Identifying code for the cause of the alarm, + * @ as given in the specification of the cluster + * @ whose attribute generated this alarm. + * @param[out] cluster_id Custer identifier + * @param[out] time_stamp Unsigned 32bit time stamp + * @param[out] user_data User data + * + * @see zb_zcl_alarm_get_alarm() + */ +typedef void (*zb_zcl_alarm_get_alarm_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned char alarm_code, + unsigned short cluster_id, + unsigned int time_stamp, + void *user_data); + +/* Table 3.56 Received Command IDs for the Alarms Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Reset Alarm | M | + * | 0x01 | Reset all alarms | M | + * | 0x02 | Get Alarm | O | + * | 0x03 | Reset alarm log | O | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Sends 'reset alarm' command + * @details This command resets a specific alarm. This is needed for some alarms that do + * not reset automatically. If the alarm condition being reset was in fact still active + * then a new notification will be generated and, where implemented, a new record added + * to the alarm log. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Destination endpoint + * @param[in] alarm_code Alarm code (8bit enumeration) + * @ Identifying code for the cause of the alarm, + * @ as given in the specification of the cluster + * @ whose attribute generated this alarm. + * @param[in] cluster_id Custer identifier + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + */ +int zb_zcl_alarm_reset_alarm( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char alarm_code, + unsigned short cluster_id); + +/** + * @brief Sends 'reset all alarm' command + * @details This command resets all alarms. Any alarm conditions that were in fact still + * active will cause a new notification to be generated and, where implemented, a new + * record added to the alarm log. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Destination endpoint + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + */ +int zb_zcl_alarm_reset_all_alarm( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep); + +/** + * @brief Sends 'get alarm' coommand + * @details This command causes the alarm with the earliest timestamp in the alarm table + * to be reported in a get alarm response command 3.11.2.5.2. This command enables + * the reading of logged alarm conditions from the alarm table. Once an alarm + * condition has been reported the corresponding entry in the table is removed. + * This command does not have a payload. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Destination endpoint + * @param[in] cb Response callback function pointer + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_alarm_get_alarm_rsp() + */ +int zb_zcl_alarm_get_alarm( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + zb_zcl_alarm_get_alarm_rsp cb, + void *user_data); + +/** + * @brief Sends 'reset all alarm log' command + * @details This command causes the alarm table to be cleared, and does not have a payload. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Destination endpoint + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + */ +int zb_zcl_alarm_reset_all_alarm_log( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ALARM_CLUSTER_H__ */ diff --git a/include/zcl/zb_zcl_attribute_ids.h b/include/zcl/zb_zcl_attribute_ids.h new file mode 100644 index 0000000..7daed48 --- /dev/null +++ b/include/zcl/zb_zcl_attribute_ids.h @@ -0,0 +1,1057 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDS_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDS_H__ + +/** + * @file zb_zcl_attribute_ids.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDENTIFIER_MODULE Cluster Attribute Identifier + * + * @brief Zigbee cluster attribute type + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDENTIFIER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/** + * @brief Attribute types for cluster: Basic + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_VERSION_ATTRIBUTE_ID = 0x0000, /**< Version */ + ZB_ZCL_APPLICATION_VERSION_ATTRIBUTE_ID = 0x0001, /**< Application version */ + ZB_ZCL_STACK_VERSION_ATTRIBUTE_ID = 0x0002, /**< Stack version */ + ZB_ZCL_HW_VERSION_ATTRIBUTE_ID = 0x0003, /**< HW version */ + ZB_ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID = 0x0004, /**< Manufacturer name */ + ZB_ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID = 0x0005, /**< Model identifer */ + ZB_ZCL_DATE_CODE_ATTRIBUTE_ID = 0x0006, /**< Date code */ + ZB_ZCL_POWER_SOURCE_ATTRIBUTE_ID = 0x0007, /**< Power source */ + ZB_ZCL_APPLICATION_PROFILE_VERSION_ATTRIBUTE_ID = 0x0008, /**< Application profile version */ + ZB_ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID = 0x0010, /**< Location description */ + ZB_ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID = 0x0011, /**< Physical environment */ + ZB_ZCL_DEVICE_ENABLED_ATTRIBUTE_ID = 0x0012, /**< Device enabled */ + ZB_ZCL_ALARM_MASK_ATTRIBUTE_ID = 0x0013, /**< Alarm mask */ + ZB_ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID = 0x0014, /**< Disable local config */ + ZB_ZCL_SW_BUILD_ID_ATTRIBUTE_ID = 0x4000, /**< SW build id ((since zll-1.0-11-0037-10)) */ +} zb_zcl_basic_server_attributes_e; + +/** + * @brief Attribute types for cluster: Power Configuration + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_MAINS_VOLTAGE_ATTRIBUTE_ID = 0x0000, /**< Mains voltage */ + ZB_ZCL_MAINS_FREQUENCY_ATTRIBUTE_ID = 0x0001, /**< Mains frequency */ + ZB_ZCL_MAINS_ALARM_MASK_ATTRIBUTE_ID = 0x0010, /**< Mains alarm mask */ + ZB_ZCL_MAINS_VOLTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x0011, /**< Mains voltage min. threshold */ + ZB_ZCL_MAINS_VOLTAGE_MAX_THRESHOLD_ATTRIBUTE_ID = 0x0012, /**< Mains voltage max. threshold */ + ZB_ZCL_MAINS_VOLTAGE_DWELL_TRIP_POINT_ATTRIBUTE_ID = 0x0013, /**< Mains voltage dwell trip point */ + ZB_ZCL_BATTERY_VOLTAGE_ATTRIBUTE_ID = 0x0020, /**< Battery voltage */ + ZB_ZCL_BATTERY_PERCENTAGE_REMAINING_ATTRIBUTE_ID = 0x0021, /**< Battery percentage remaining (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_MANUFACTURER_ATTRIBUTE_ID = 0x0030, /**< Battery manufacturer id */ + ZB_ZCL_BATTERY_SIZE_ATTRIBUTE_ID = 0x0031, /**< Battery size */ + ZB_ZCL_BATTERY_AHR_RATING_ATTRIBUTE_ID = 0x0032, /**< Battery Ampere/Hr rating */ + ZB_ZCL_BATTERY_QUANTITY_ATTRIBUTE_ID = 0x0033, /**< Battery quantity */ + ZB_ZCL_BATTERY_RATED_VOLTAGE_ATTRIBUTE_ID = 0x0034, /**< Battery rated voltage */ + ZB_ZCL_BATTERY_ALARM_MASK_ATTRIBUTE_ID = 0x0035, /**< Battery alarm mask */ + ZB_ZCL_BATTERY_VOLTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x0036, /**< Battery voltage min. threshold */ + ZB_ZCL_BATTERY_VOLTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x0037, /**< Battery voltage threshold 1 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_VOLTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x0038, /**< Battery voltage threshold 2 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_VOLTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x0039, /**< Battery voltage threshold 3 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_PERCENTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x003A, /**< Battery percentage min. threshold (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_PERCENTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x003B, /**< Battery percentage threshold 1 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_PERCENTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x003C, /**< Battery percentage threshold 2 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_PERCENTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x003D, /**< Battery percentage threshold 3 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_ALARM_STATE_ATTRIBUTE_ID = 0x003E, /**< Battery alarm state (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_VOLTAGE_ATTRIBUTE_ID = 0x0040, /**< Battery 2 voltage (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_PERCENTAGE_REMAINING_ATTRIBUTE_ID = 0x0041, /**< Battery 2 percentage remaining (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_MANUFACTURER_ATTRIBUTE_ID = 0x0050, /**< Battery 2 manufacturer (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_SIZE_ATTRIBUTE_ID = 0x0051, /**< Battery 2 size (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_AHR_RATING_ATTRIBUTE_ID = 0x0052, /**< Battery 2 Ampere/Hr rating (since ha-1.2-05-3520-29 */ + ZB_ZCL_BATTERY_2_QUANTITY_ATTRIBUTE_ID = 0x0053, /**< Battery 2 quantity (since ha-1.2-05-3520-29 */ + ZB_ZCL_BATTERY_2_RATED_VOLTAGE_ATTRIBUTE_ID = 0x0054, /**< Battery 2 rated voltage (since ha-1.2-05-3520-29 */ + ZB_ZCL_BATTERY_2_ALARM_MASK_ATTRIBUTE_ID = 0x0055, /**< Batery 2 alarm mask (since ha-1.2-05-3520-29 */ + ZB_ZCL_BATTERY_2_VOLTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x0056, /**< Batery 2 voltage min. threshold (since ha-1.2-05-3520-29 */ + ZB_ZCL_BATTERY_2_VOLTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x0057, /**< Battery 2 voltage threshold 1 (since ha-1.2-05-3520-29 */ + ZB_ZCL_BATTERY_2_VOLTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x0058, /**< Battery 2 voltage threshold 2 (since ha-1.2-05-3520-29 */ + ZB_ZCL_BATTERY_2_VOLTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x0059, /**< Battery 2 voltage threshold 3 (since ha-1.2-05-3520-29 */ + ZB_ZCL_BATTERY_2_PERCENTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x005A, /**< Battery 2 percentage min. threshold (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_PERCENTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x005B, /**< Battery 2 percentage threshold 1 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_PERCENTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x005C, /**< Battery 2 percentage threshold 2 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_PERCENTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x005D, /**< Battery 2 percentage threshold 3 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_2_ALARM_STATE_ATTRIBUTE_ID = 0x005E, /**< Battery 2 alarm state (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_VOLTAGE_ATTRIBUTE_ID = 0x0060, /**< Battery 3 voltage (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_PERCENTAGE_REMAINING_ATTRIBUTE_ID = 0x0061, /**< Battery 3 percentage remaining (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_MANUFACTURER_ATTRIBUTE_ID = 0x0070, /**< Battery 3 manufacturer (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_SIZE_ATTRIBUTE_ID = 0x0071, /**< Battery 3 size (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_AHR_RATING_ATTRIBUTE_ID = 0x0072, /**< Battery 3 Ampere/Hr rating (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_QUANTITY_ATTRIBUTE_ID = 0x0073, /**< Battery 3 quantity (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_RATED_VOLTAGE_ATTRIBUTE_ID = 0x0074, /**< Battery 3 rated voltage (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_ALARM_MASK_ATTRIBUTE_ID = 0x0075, /**< Battery 3 alarm mask (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_VOLTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x0076, /**< Battery 3 voltage min. threshold (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_VOLTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x0077, /**< Battery 3 voltage threshold 1 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_VOLTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x0078, /**< Battery 3 voltage threshold 2 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_VOLTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x0079, /**< Battery 3 voltage threshold 3 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_PERCENTAGE_MIN_THRESHOLD_ATTRIBUTE_ID = 0x007A, /**< Battery 3 percentage min. threshold (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_PERCENTAGE_THRESHOLD_1_ATTRIBUTE_ID = 0x007B, /**< Battery 3 percentage threshold 1 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_PERCENTAGE_THRESHOLD_2_ATTRIBUTE_ID = 0x007C, /**< Battery 3 percentage threshold 2 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_PERCENTAGE_THRESHOLD_3_ATTRIBUTE_ID = 0x007D, /**< Battery 3 percentage threshold 3 (since ha-1.2-05-3520-29) */ + ZB_ZCL_BATTERY_3_ALARM_STATE_ATTRIBUTE_ID = 0x007E, /**< Battery 3 alarm state (since ha-1.2-05-3520-29) */ +} zb_zcl_power_configuration_server_attributes_e; + +/** + * @brief Attribute types for cluster: Device Temperature Configuration + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_CURRENT_TEMPERATURE_ATTRIBUTE_ID = 0x0000, /**< Current temperature */ + ZB_ZCL_MIN_TEMP_EXPERIENCED_ATTRIBUTE_ID = 0x0001, /**< Min. temp. experienced */ + ZB_ZCL_MAX_TEMP_EXPERIENCED_ATTRIBUTE_ID = 0x0002, /**< Max. temp. experienced */ + ZB_ZCL_OVER_TEMP_TOTAL_DWELL_ATTRIBUTE_ID = 0x0003, /**< Over temp. total dwell mask */ + ZB_ZCL_DEVICE_TEMP_ALARM_MASK_ATTRIBUTE_ID = 0x0010, /**< Device temp. alarm mask */ + ZB_ZCL_LOW_TEMP_THRESHOLD_ATTRIBUTE_ID = 0x0011, /**< Low temp. threshold */ + ZB_ZCL_HIGH_TEMP_THRESHOLD_ATTRIBUTE_ID = 0x0012, /**< High temp. threshold */ + ZB_ZCL_LOW_TEMP_DWELL_TRIP_POINT_ATTRIBUTE_ID = 0x0013, /**< Low temp. dwell trip point */ + ZB_ZCL_HIGH_TEMP_DWELL_TRIP_POINT_ATTRIBUTE_ID = 0x0014, /**< HIgh temp. dwell trip point */ +} zb_zcl_device_temperature_configuration_server_attributes_e; + +/** + * @brief Attribute types for cluster: Identify + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID = 0x0000, /**< Identiy time */ + ZB_ZCL_COMMISSION_STATE_ATTRIBUTE_ID = 0x0001, /**< Commision state */ +} zb_zcl_identify_server_attributes_e; + +/** + * @brief Attribute types for cluster: Groups + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_GROUP_NAME_SUPPORT_ATTRIBUTE_ID = 0x0000, /**< Group name support */ +} zb_zcl_group_server_attributes_e; + +/** + * @brief Attribute types for cluster: Scenes + * @details Cluster specification level: zcl-1.0-07-5123-03\n + * + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SCENE_COUNT_ATTRIBUTE_ID = 0x0000, /**< Scene count */ + ZB_ZCL_CURRENT_SCENE_ATTRIBUTE_ID = 0x0001, /**< Current scene */ + ZB_ZCL_CURRENT_GROUP_ATTRIBUTE_ID = 0x0002, /**< Current group */ + ZB_ZCL_SCENE_VALID_ATTRIBUTE_ID = 0x0003, /**< Scene valid */ + ZB_ZCL_SCENE_NAME_SUPPORT_ATTRIBUTE_ID = 0x0004, /**< Scene name support */ + ZB_ZCL_LAST_CONFIGURED_BY_ATTRIBUTE_ID = 0x0005, /**< Last congigured by */ +} zb_zcl_scenes_server_attributes_e; + +/** + * @brief Attribute types for cluster: On/off + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ON_OFF_ATTRIBUTE_ID = 0x0000, /**< On/off */ + ZB_ZCL_SAMPLE_MFG_SPECIFIC_TRANSITION_TIME_ATTRIBUTE_ID = 0x0000, /**< Sample manufacturer specific transition time */ + ZB_ZCL_GLOBAL_SCENE_CONTROL_ATTRIBUTE_ID = 0x4000, /**< Global scene control (since zll-1.0-11-0037-10) */ + ZB_ZCL_ON_TIME_ATTRIBUTE_ID = 0x4001, /**< On time (since zll-1.0-11-0037-10) */ + ZB_ZCL_OFF_WAIT_TIME_ATTRIBUTE_ID = 0x4002, /**< Off wait time (since zll-1.0-11-0037-10) */ +} zb_zcl_on_off_server_attributes_e; + +/** + * @brief Attribute types for cluster: On/off Switch Configuration + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SWITCH_TYPE_ATTRIBUTE_ID = 0x0000, /**< Switch type */ + ZB_ZCL_SWITCH_ACTIONS_ATTRIBUTE_ID = 0x0010, /**< Swicth action */ +} zb_zcl_on_off_switc_configuration_server_attributes_e; + +/** + * @brief Attribute types for cluster: Level Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_CURRENT_LEVEL_ATTRIBUTE_ID = 0x0000, /**< Current level */ + ZB_ZCL_LEVEL_CONTROL_REMAINING_TIME_ATTRIBUTE_ID = 0x0001, /**< Level control remaining */ + ZB_ZCL_ON_OFF_TRANSITION_TIME_ATTRIBUTE_ID = 0x0010, /**< On/off transition time */ + ZB_ZCL_ON_LEVEL_ATTRIBUTE_ID = 0x0011, /**< On level */ + ZB_ZCL_ON_TRANSITION_TIME_ATTRIBUTE_ID = 0x0012, /**< On transition time (since ha-1.2-05-3520-29) */ + ZB_ZCL_OFF_TRANSITION_TIME_ATTRIBUTE_ID = 0x0013, /**< Off transition time (since ha-1.2-05-3520-29) */ + ZB_ZCL_DEFAULT_MOVE_RATE_ATTRIBUTE_ID = 0x0014, /**< Default move rate (since ha-1.2-05-3520-29) */ +} zb_zcl_level_control_server_attributes_e; + +/** + * @brief Attribute types for cluster: Alarms + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ALARM_COUNT_ATTRIBUTE_ID = 0x0000, /**< alarm count */ +} zb_zcl_alarms_server_attributes_e; + +/** + * @brief Attribute types for cluster: Time + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_TIME_ATTRIBUTE_ID = 0x0000, /**< Time */ + ZB_ZCL_TIME_STATUS_ATTRIBUTE_ID = 0x0001, /**< Time status */ + ZB_ZCL_TIME_ZONE_ATTRIBUTE_ID = 0x0002, /**< Time zone */ + ZB_ZCL_DST_START_ATTRIBUTE_ID = 0x0003, /**< Destination start */ + ZB_ZCL_DST_END_ATTRIBUTE_ID = 0x0004, /**< Destination end */ + ZB_ZCL_DST_SHIFT_ATTRIBUTE_ID = 0x0005, /**< Destination shift */ + ZB_ZCL_STANDARD_TIME_ATTRIBUTE_ID = 0x0006, /**< Standard time */ + ZB_ZCL_LOCAL_TIME_ATTRIBUTE_ID = 0x0007, /**< Local time */ + ZB_ZCL_LAST_SET_TIME_ATTRIBUTE_ID = 0x0008, /**< Last set time */ + ZB_ZCL_VALID_UNTIL_TIME_ATTRIBUTE_ID = 0x0009, /**< Valid until time */ +} zb_zcl_time_server_attributes_e; + +/** + * @brief Attribute types for cluster: RSSI Location + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_LOCATION_TYPE_ATTRIBUTE_ID = 0x0000, /**< Location type */ + ZB_ZCL_LOCATION_METHOD_ATTRIBUTE_ID = 0x0001, /**< Location method */ + ZB_ZCL_LOCATION_AGE_ATTRIBUTE_ID = 0x0002, /**< Location age */ + ZB_ZCL_QUALITY_MEASURE_ATTRIBUTE_ID = 0x0003, /**< Quality measure */ + ZB_ZCL_NUMBER_OF_DEVICES_ATTRIBUTE_ID = 0x0004, /**< Number of devices */ + ZB_ZCL_COORDINATE1_ATTRIBUTE_ID = 0x0010, /**< Coordinate 1 */ + ZB_ZCL_COORDINATE2_ATTRIBUTE_ID = 0x0011, /**< Coordinate 2 */ + ZB_ZCL_COORDINATE3_ATTRIBUTE_ID = 0x0012, /**< Coordinate 3 */ + ZB_ZCL_POWER_ATTRIBUTE_ID = 0x0013, /**< Power */ + ZB_ZCL_PATH_LOSS_EXPONENT_ATTRIBUTE_ID = 0x0014, /**< Path loss exponent */ + ZB_ZCL_REPORTING_PERIOD_ATTRIBUTE_ID = 0x0015, /**< Reporting period */ + ZB_ZCL_CALCULATION_PERIOD_ATTRIBUTE_ID = 0x0016, /**< Calculatoin period */ + ZB_ZCL_NUMBER_RSSI_MEASUREMENTS_ATTRIBUTE_ID = 0x0017, /**< Number RSSI measurements */ +} zb_zcl_rssi_location_server_attributes_e; + +/** + * @brief Attribute types for cluster: Binary Input (Basic) + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ACTIVE_TEXT_ATTRIBUTE_ID = 0x0004, /**< Active text */ + ZB_ZCL_DESCRIPTION_ATTRIBUTE_ID = 0x001C, /**< Description */ + ZB_ZCL_INACTIVE_TEXT_ATTRIBUTE_ID = 0x002E, /**< Inactive text */ + ZB_ZCL_OUT_OF_SERVICE_ATTRIBUTE_ID = 0x0051, /**< Out of service */ + ZB_ZCL_POLARITY_ATTRIBUTE_ID = 0x0054, /**< Polarity */ + ZB_ZCL_PRESENT_VALUE_ATTRIBUTE_ID = 0x0055, /**< Present value */ + ZB_ZCL_RELIABILITY_ATTRIBUTE_ID = 0x0067, /**< Reliability */ + ZB_ZCL_STATUS_FLAGS_ATTRIBUTE_ID = 0x006F, /**< Status flag */ + ZB_ZCL_APPLICATION_TYPE_ATTRIBUTE_ID = 0x0100, /**< Applicatoin type */ +} zb_zcl_binary_input_basic_server_attributes_e; + +/** + * @brief Attribute types for cluster: Commissioning + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SHORT_ADDRESS_ATTRIBUTE_ID = 0x0000, /**< Short address */ + ZB_ZCL_EXTENDED_PAN_ID_ATTRIBUTE_ID = 0x0001, /**< Extended PAN ID */ + ZB_ZCL_PAN_ID_ATTRIBUTE_ID = 0x0002, /**< PAN ID */ + ZB_ZCL_CHANNEL_MASK_ATTRIBUTE_ID = 0x0003, /**< Channel mask */ + ZB_ZCL_PROTOCOL_VERSION_ATTRIBUTE_ID = 0x0004, /**< Protocol version */ + ZB_ZCL_STACK_PROFILE_ATTRIBUTE_ID = 0x0005, /**< Stack profile */ + ZB_ZCL_STARTUP_CONTROL_ATTRIBUTE_ID = 0x0006, /**< Startup control */ + ZB_ZCL_TRUST_CENTER_ADDRESS_ATTRIBUTE_ID = 0x0010, /**< Trust center address */ + ZB_ZCL_TRUST_CENTER_MASTER_KEY_ATTRIBUTE_ID = 0x0011, /**< Trust center master key */ + ZB_ZCL_NETWORK_KEY_ATTRIBUTE_ID = 0x0012, /**< Network key */ + ZB_ZCL_USE_INSECURE_JOIN_ATTRIBUTE_ID = 0x0013, /**< Use insecure join */ + ZB_ZCL_PRECONFIGURED_LINK_KEY_ATTRIBUTE_ID = 0x0014, /**< Preconfigured link key */ + ZB_ZCL_NETWORK_KEY_SEQUENCE_NUMBER_ATTRIBUTE_ID = 0x0015, /**< Network key sequence number */ + ZB_ZCL_NETWORK_KEY_TYPE_ATTRIBUTE_ID = 0x0016, /**< Network key type */ + ZB_ZCL_NETWORK_MANAGER_ADDRESS_ATTRIBUTE_ID = 0x0017, /**< Network manager address */ + ZB_ZCL_SCAN_ATTEMPTS_ATTRIBUTE_ID = 0x0020, /**< Scan attempts */ + ZB_ZCL_TIME_BETWEEN_SCANS_ATTRIBUTE_ID = 0x0021, /**< Time between scans */ + ZB_ZCL_REJOIN_INTERVAL_ATTRIBUTE_ID = 0x0022, /**< Re-join interval */ + ZB_ZCL_MAX_REJOIN_INTERVAL_ATTRIBUTE_ID = 0x0023, /**< Max re-join interval */ + ZB_ZCL_INDIRECT_POLL_RATE_ATTRIBUTE_ID = 0x0030, /**< Indirect poll rate */ + ZB_ZCL_PARENT_RETRY_THRESHOLD_ATTRIBUTE_ID = 0x0031, /**< Parent retry threshold */ + ZB_ZCL_CONCENTRATOR_FLAG_ATTRIBUTE_ID = 0x0040, /**< Concentrator flag */ + ZB_ZCL_CONCENTRATOR_RADIUS_ATTRIBUTE_ID = 0x0041, /**< Concentrator radius */ + ZB_ZCL_CONCENTRATOR_DISCOVERY_TIME_ATTRIBUTE_ID = 0x0042, /**< Concentrator discovery time */ +} zb_zcl_commissioning_server_attributes_e; + +/** + * @brief Attribute types for cluster: Partition + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_PARTITION_MAXIMUM_INCOMING_TRANSFER_SIZE_ATTRIBUTE_ID = 0x0000, /**< Partition maximum incomming transfer size */ + ZB_ZCL_PARTITION_MAXIMUM_OUTGOING_TRANSFER_SIZE_ATTRIBUTE_ID = 0x0001, /**< Partition maximum outgoing transfer size */ + ZB_ZCL_PARTIONED_FRAME_SIZE_ATTRIBUTE_ID = 0x0002, /**< Partioned frame size */ + ZB_ZCL_LARGE_FRAME_SIZE_ATTRIBUTE_ID = 0x0003, /**< Large frame size */ + ZB_ZCL_NUMBER_OF_ACK_FRAME_ATTRIBUTE_ID = 0x0004, /**< Number of ACK frame */ + ZB_ZCL_NACK_TIMEOUT_ATTRIBUTE_ID = 0x0005, /**< NACK timeout */ + ZB_ZCL_INTERFRAME_DELAY_ATTRIBUTE_ID = 0x0006, /**< Interframe delay */ + ZB_ZCL_NUMBER_OF_SEND_RETRIES_ATTRIBUTE_ID = 0x0007, /**< Number of send retries */ + ZB_ZCL_SENDER_TIMEOUT_ATTRIBUTE_ID = 0x0008, /**< Sender timeout */ + ZB_ZCL_RECEIVER_TIMEOUT_ATTRIBUTE_ID = 0x0009, /**< Receiver timeout */ +} zb_zcl_partition_server_attributes_e; + +/** + * @brief Attribute types for cluster: Over the Air Bootloading + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_UPGRADE_SERVER_ID_ATTRIBUTE_ID = 0x0000, /**< Upgrade server ID */ + ZB_ZCL_FILE_OFFSET_ATTRIBUTE_ID = 0x0001, /**< File offset */ + ZB_ZCL_CURRENT_FILE_VERSION_ATTRIBUTE_ID = 0x0002, /**< Current file version */ + ZB_ZCL_CURRENT_ZIGBEE_STACK_VERSION_ATTRIBUTE_ID = 0x0003, /**< Current Zigbee stack version */ + ZB_ZCL_DOWNLOADED_FILE_VERSION_ATTRIBUTE_ID = 0x0004, /**< Download file version */ + ZB_ZCL_DOWNLOADED_ZIGBEE_STACK_VERSION_ATTRIBUTE_ID = 0x0005, /**< Download Zigbee stack version */ + ZB_ZCL_IMAGE_UPGRADE_STATUS_ATTRIBUTE_ID = 0x0006, /**< Image upgrade status */ + ZB_ZCL_MANUFACTURER_ID_ATTRIBUTE_ID = 0x0007, /**< Manufacturer ID */ + ZB_ZCL_IMAGE_TYPE_ID_ATTRIBUTE_ID = 0x0008, /**< Image type ID */ + ZB_ZCL_MINIMUM_BLOCK_REQUEST_PERIOD_ATTRIBUTE_ID = 0x0009, /**< Minimum block request period (since ha-1.2-05-3520-29) */ + ZB_ZCL_IMAGE_STAMP_ATTRIBUTE_ID = 0x000A, /**< Image stamp (since ha-1.2-05-3520-29) */ +} zb_zcl_over_the_air_bootloading_client_attributes_e; + +/** + * @brief Attribute types for cluster: Power Profile + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_TOTAL_PROFILE_NUM_ATTRIBUTE_ID = 0x0000, /**< Totgal profile number */ + ZB_ZCL_MULTIPLE_SCHEDULING_ATTRIBUTE_ID = 0x0001, /**< Multiple scheduling */ + ZB_ZCL_ENERGY_FORMATTING_ATTRIBUTE_ID = 0x0002, /**< Energy formatting */ + ZB_ZCL_ENERGY_REMOTE_ATTRIBUTE_ID = 0x0003, /**< Enegery remote */ + ZB_ZCL_SCHEDULE_MODE_ATTRIBUTE_ID = 0x0004, /**< Schedule mode */ +} zb_zcl_power_profile_server_attributes_e; + +/** + * @brief Attribute types for cluster: Appliance Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_START_TIME_ATTRIBUTE_ID = 0x0000, /**< Start time */ + ZB_ZCL_FINISH_TIME_ATTRIBUTE_ID = 0x0001, /**< Finish time */ + ZB_ZCL_REMAINING_TIME_ATTRIBUTE_ID = 0x0002, /**< Remaining time */ +} zb_zcl_appliance_control_server_attributes_e; + +/** + * @brief Attribute types for cluster: Poll Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_CHECK_IN_INTERVAL_ATTRIBUTE_ID = 0x0000, /**< Check-in interval */ + ZB_ZCL_LONG_POLL_INTERVAL_ATTRIBUTE_ID = 0x0001, /**< Long poll interval */ + ZB_ZCL_SHORT_POLL_INTERVAL_ATTRIBUTE_ID = 0x0002, /**< Short poll interval */ + ZB_ZCL_FAST_POLL_TIMEOUT_ATTRIBUTE_ID = 0x0003, /**< Fast poll interval */ + ZB_ZCL_CHECK_IN_INTERVAL_MIN_ATTRIBUTE_ID = 0x0004, /**< Check-in interval min. */ + ZB_ZCL_LONG_POLL_INTERVAL_MIN_ATTRIBUTE_ID = 0x0005, /**< Long poll interval min. */ + ZB_ZCL_FAST_POLL_TIMEOUT_MAX_ATTRIBUTE_ID = 0x0006, /**< Fast poll interval min. */ +} zb_zcl_poll_control_server_attributes_e; + +/** + * @brief Attribute types for cluster: Shade Configuration + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SHADE_CONFIG_PHYSICAL_CLOSED_LIMIT_ATTRIBUTE_ID = 0x0000, /**< Shade config physical close limit */ + ZB_ZCL_SHADE_CONFIG_MOTOR_STEP_SIZE_ATTRIBUTE_ID = 0x0001, /**< Shade config motor step size */ + ZB_ZCL_SHADE_CONFIG_STATUS_ATTRIBUTE_ID = 0x0002, /**< Shade config status */ + ZB_ZCL_SHADE_CONFIG_CLOSED_LIMIT_ATTRIBUTE_ID = 0x0010, /**< Shade config close limit */ + ZB_ZCL_SHADE_CONFIG_MODE_ATTRIBUTE_ID = 0x0011, /**< Shade config mode */ +} zb_zcl_shade_configuration_server_attributes_e; + +/** + * @brief Attribute types for cluster: Door Lock + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_LOCK_STATE_ATTRIBUTE_ID = 0x0000, /**< Lock state */ + ZB_ZCL_LOCK_TYPE_ATTRIBUTE_ID = 0x0001, /**< Lock type */ + ZB_ZCL_ACTUATOR_ENABLED_ATTRIBUTE_ID = 0x0002, /**< Actuator enabled */ + ZB_ZCL_DOOR_STATE_ATTRIBUTE_ID = 0x0003, /**< Door state */ + ZB_ZCL_DOOR_OPEN_EVENTS_ATTRIBUTE_ID = 0x0004, /**< Door open event */ + ZB_ZCL_DOOR_CLOSED_EVENTS_ATTRIBUTE_ID = 0x0005, /**< Door closed event */ + ZB_ZCL_OPEN_PERIOD_ATTRIBUTE_ID = 0x0006, /**< Open period */ + ZB_ZCL_NUM_LOCK_RECORDS_SUPPORTED_ATTRIBUTE_ID = 0x0010, /**< Number of lock records supported (since ha-1.2-05-3520-29) */ + ZB_ZCL_NUM_TOTAL_USERS_SUPPORTED_ATTRIBUTE_ID = 0x0011, /**< Number of total users supported (since ha-1.2-05-3520-29) */ + ZB_ZCL_NUM_PIN_USERS_SUPPORTED_ATTRIBUTE_ID = 0x0012, /**< Number of PIN users supproted (since ha-1.2-05-3520-29) */ + ZB_ZCL_NUM_RFID_USERS_SUPPORTED_ATTRIBUTE_ID = 0x0013, /**< Number of RFID users supported (since ha-1.2-05-3520-29) */ + ZB_ZCL_NUM_WEEKDAY_SCHEDULES_SUPPORTED_PER_USER_ATTRIBUTE_ID = 0x0014, /**< Number of weekday schedules supported per user (since ha-1.2-05-3520-29) */ + ZB_ZCL_NUM_YEARDAY_SCHEDULES_SUPPORTED_PER_USER_ATTRIBUTE_ID = 0x0015, /**< Number of yearday schedules supported per user (since ha-1.2-05-3520-29) */ + ZB_ZCL_NUM_HOLIDAY_SCHEDULES_SUPPORTED_PER_USER_ATTRIBUTE_ID = 0x0016, /**< Number of holiday schedules supported per user (since ha-1.2-05-3520-29) */ + ZB_ZCL_MAX_PIN_LENGTH_ATTRIBUTE_ID = 0x0017, /**< Max. PIN length (since ha-1.2-05-3520-29) */ + ZB_ZCL_MIN_PIN_LENGTH_ATTRIBUTE_ID = 0x0018, /**< Min. PIN length (since ha-1.2-05-3520-29) */ + ZB_ZCL_MAX_RFID_CODE_LENGTH_ATTRIBUTE_ID = 0x0019, /**< Max. RFID code length (since ha-1.2-05-3520-29) */ + ZB_ZCL_MIN_RFID_CODE_LENGTH_ATTRIBUTE_ID = 0x001A, /**< Min. RFID code length (since ha-1.2-05-3520-29) */ + ZB_ZCL_ENABLE_LOGGING_ATTRIBUTE_ID = 0x0020, /**< Enable logging (since ha-1.2-05-3520-29) */ + ZB_ZCL_LANGUAGE_ATTRIBUTE_ID = 0x0021, /**< Language (since ha-1.2-05-3520-29) */ + ZB_ZCL_LED_SETTINGS_ATTRIBUTE_ID = 0x0022, /**< LED settings (since ha-1.2-05-3520-29) */ + ZB_ZCL_AUTO_RELOCK_TIME_ATTRIBUTE_ID = 0x0023, /**< Auto relock time (since ha-1.2-05-3520-29) */ + ZB_ZCL_SOUND_VOLUME_ATTRIBUTE_ID = 0x0024, /**< Sound volume (since ha-1.2-05-3520-29) */ + ZB_ZCL_OPERATING_MODE_ATTRIBUTE_ID = 0x0025, /**< Operating mode (since ha-1.2-05-3520-29) */ + ZB_ZCL_SUPPORTED_OPERATING_MODES_ATTRIBUTE_ID = 0x0026, /**< Supported operating modes (since ha-1.2-05-3520-29) */ + ZB_ZCL_DEFAULT_CONFIGURATION_REGISTER_ATTRIBUTE_ID = 0x0027, /**< Default configuratoin registger (since ha-1.2-05-3520-29) */ + ZB_ZCL_ENABLE_LOCAL_PROGRAMMING_ATTRIBUTE_ID = 0x0028, /**< Enable local programming (since ha-1.2-05-3520-29) */ + ZB_ZCL_ENABLE_ONE_TOUCH_LOCKING_ATTRIBUTE_ID = 0x0029, /**< Enable one touch locking (since ha-1.2-05-3520-29) */ + ZB_ZCL_ENABLE_INSIDE_STATUS_LED_ATTRIBUTE_ID = 0x002A, /**< Enable inside status LED (since ha-1.2-05-3520-29) */ + ZB_ZCL_ENABLE_PRIVACY_MODE_BUTTON_ATTRIBUTE_ID = 0x002B, /**< Enable privacy mode button (since ha-1.2-05-3520-29) */ + ZB_ZCL_WRONG_CODE_ENTRY_LIMIT_ATTRIBUTE_ID = 0x0030, /**< Wrong code entry limit (since ha-1.2-05-3520-29) */ + ZB_ZCL_USER_CODE_TEMPORARY_DISABLE_TIME_ATTRIBUTE_ID = 0x0031, /**< User code temporary disable time (since ha-1.2-05-3520-29) */ + ZB_ZCL_SEND_PIN_OVER_THE_AIR_ATTRIBUTE_ID = 0x0032, /**< Send PIN Over-The-Air (since ha-1.2-05-3520-29) */ + ZB_ZCL_REQUIRE_PIN_FOR_RF_OPERATION_ATTRIBUTE_ID = 0x0033, /**< Require PIN for RF operation (since ha-1.2-05-3520-29) */ + ZB_ZCL_ZIGBEE_SECURITY_LEVEL_ATTRIBUTE_ID = 0x0034, /**< Zigbee security level (since ha-1.2-05-3520-29) */ + ZB_ZCL_DOOR_LOCK_ALARM_MASK_ATTRIBUTE_ID = 0x0040, /**< Door lock alarm mask (since ha-1.2-05-3520-29) */ + ZB_ZCL_KEYPAD_OPERATION_EVENT_MASK_ATTRIBUTE_ID = 0x0041, /**< Keypad operation event mask (since ha-1.2-05-3520-29) */ + ZB_ZCL_RF_OPERATION_EVENT_MASK_ATTRIBUTE_ID = 0x0042, /**< RF operation event mask (since ha-1.2-05-3520-29) */ + ZB_ZCL_MANUAL_OPERATION_EVENT_MASK_ATTRIBUTE_ID = 0x0043, /**< Manual operation event mask (since ha-1.2-05-3520-29) */ + ZB_ZCL_RFID_OPERATION_EVENT_MASK_ATTRIBUTE_ID = 0x0044, /**< RFID operation event mask (since ha-1.2-05-3520-29) */ + ZB_ZCL_KEYPAD_PROGRAMMING_EVENT_MASK_ATTRIBUTE_ID = 0x0045, /**< Keypad programming event mask (since ha-1.2-05-3520-29) */ + ZB_ZCL_RF_PROGRAMMING_EVENT_MASK_ATTRIBUTE_ID = 0x0046, /**< RF programming event mask (since ha-1.2-05-3520-29) */ + ZB_ZCL_RFID_PROGRAMMING_EVENT_MASK_ATTRIBUTE_ID = 0x0047, /**< RFID pgramming event mask (since ha-1.2-05-3520-29) */ +} zb_zcl_door_lock_server_attributes_e; + +/** + * @brief Attribute types for cluster: Window Covering + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_COVERING_TYPE_ATTRIBUTE_ID = 0x0000, /**< Covering type */ + ZB_ZCL_LIMIT_LIFT_ATTRIBUTE_ID = 0x0001, /**< Limit lift */ + ZB_ZCL_LIMIT_TILT_ATTRIBUTE_ID = 0x0002, /**< Limit tilt */ + ZB_ZCL_CURRENT_LIFT_ATTRIBUTE_ID = 0x0003, /**< Current lift */ + ZB_ZCL_CURRENT_TILT_ATTRIBUTE_ID = 0x0004, /**< Current tilt */ + ZB_ZCL_NUMBER_LIFT_ATTRIBUTE_ID = 0x0005, /**< Number lift */ + ZB_ZCL_NUMBER_TILT_ATTRIBUTE_ID = 0x0006, /**< Number tilt */ + ZB_ZCL_CONFIG_STATUS_ATTRIBUTE_ID = 0x0007, /**< Config status */ + ZB_ZCL_CURRENT_LIFT_PERCENTAGE_ATTRIBUTE_ID = 0x0008, /**< Current lift percentage */ + ZB_ZCL_CURRENT_TILT_PERCENTAGE_ATTRIBUTE_ID = 0x0009, /**< Current tilt percentage */ + ZB_ZCL_OPEN_LIMIT_LIFT_ATTRIBUTE_ID = 0x0010, /**< Open limit lift */ + ZB_ZCL_CLOSED_LIMIT_LIFT_ATTRIBUTE_ID = 0x0011, /**< Closed limit lift */ + ZB_ZCL_OPEN_LIMIT_TILT_ATTRIBUTE_ID = 0x0012, /**< Open limit tilt */ + ZB_ZCL_CLOSED_LIMIT_TILT_ATTRIBUTE_ID = 0x0013, /**< Closed limit tilt */ + ZB_ZCL_VELOCITY_LIFT_ATTRIBUTE_ID = 0x0014, /**< Velocity lift */ + ZB_ZCL_ACCELERATION_LIFT_ATTRIBUTE_ID = 0x0015, /**< Acceleration lift */ + ZB_ZCL_DECELERATION_LIFT_ATTRIBUTE_ID = 0x0016, /**< Deceleration lift */ + ZB_ZCL_MODE_ATTRIBUTE_ID = 0x0017, /**< Mode */ + ZB_ZCL_SETPOINTS_LIFT_ATTRIBUTE_ID = 0x0018, /**< Setpoints lift */ + ZB_ZCL_SETPOINTS_TILT_ATTRIBUTE_ID = 0x0019, /**< Setpoints tilt */ +} zb_zcl_window_covering_server_attributes_e; + +/** + * @brief Attribute types for cluster: Pump Configuration and Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_MAX_PRESSURE_ATTRIBUTE_ID = 0x0000, /**< Max. pressure */ + ZB_ZCL_MAX_SPEED_ATTRIBUTE_ID = 0x0001, /**< Max. speed */ + ZB_ZCL_MAX_FLOW_ATTRIBUTE_ID = 0x0002, /**< Max. flow */ + ZB_ZCL_MIN_CONST_PRESSURE_ATTRIBUTE_ID = 0x0003, /**< Min. const. pressure */ + ZB_ZCL_MAX_CONST_PRESSURE_ATTRIBUTE_ID = 0x0004, /**< Max. const. pressure */ + ZB_ZCL_MIN_COMP_PRESSURE_ATTRIBUTE_ID = 0x0005, /**< Min. comp pressure */ + ZB_ZCL_MAX_COMP_PRESSURE_ATTRIBUTE_ID = 0x0006, /**< Max. comp pressure */ + ZB_ZCL_MIN_CONST_SPEED_ATTRIBUTE_ID = 0x0007, /**< Min. const. speed */ + ZB_ZCL_MAX_CONST_SPEED_ATTRIBUTE_ID = 0x0008, /**< Max. const. speed */ + ZB_ZCL_MIN_CONST_FLOW_ATTRIBUTE_ID = 0x0009, /**< Min. const. flow */ + ZB_ZCL_MAX_CONST_FLOW_ATTRIBUTE_ID = 0x000A, /**< Max const. flow */ + ZB_ZCL_MIN_CONST_TEMP_ATTRIBUTE_ID = 0x000B, /**< Min. const. temperature */ + ZB_ZCL_MAX_CONST_TEMP_ATTRIBUTE_ID = 0x000C, /**< Max. const. temperature */ + ZB_ZCL_PUMP_STATUS_ATTRIBUTE_ID = 0x0010, /**< Pump status */ + ZB_ZCL_EFFECTIVE_OPERATION_MODE_ATTRIBUTE_ID = 0x0011, /**< Effective operation mode */ + ZB_ZCL_EFFECTIVE_CONTROL_MODE_ATTRIBUTE_ID = 0x0012, /**< Effective control mode */ + ZB_ZCL_CAPACITY_ATTRIBUTE_ID = 0x0013, /**< Capacity */ + ZB_ZCL_SPEED_ATTRIBUTE_ID = 0x0014, /**< Speed */ + ZB_ZCL_LIFETIME_RUNNING_HOURS_ATTRIBUTE_ID = 0x0015, /**< Lifetime runnging hours */ + ZB_ZCL_PUMP_POWER_ATTRIBUTE_ID = 0x0016, /**< Pump power */ + ZB_ZCL_LIFETIME_ENERGY_CONSUMED_ATTRIBUTE_ID = 0x0017, /**< Lifetime enerfy consumed */ + ZB_ZCL_OPERATION_MODE_ATTRIBUTE_ID = 0x0020, /**< Operation mode */ + ZB_ZCL_CONTROL_MODE_ATTRIBUTE_ID = 0x0021, /**< Control mode */ + ZB_ZCL_PUMP_ALARM_MASK_ATTRIBUTE_ID = 0x0022, /**< Pump alarm mask */ +} zb_zcl_pump_configuration_and_control_server_attributes_e; + +/** + * @brief Attribute types for cluster: Thermostat + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_LOCAL_TEMPERATURE_ATTRIBUTE_ID = 0x0000, /**< Local temperature */ + ZB_ZCL_OUTDOOR_TEMPERATURE_ATTRIBUTE_ID = 0x0001, /**< Outdoor temperature */ + ZB_ZCL_THERMOSTAT_OCCUPANCY_ATTRIBUTE_ID = 0x0002, /**< Thermostat occupancy */ + ZB_ZCL_ABS_MIN_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0003, /**< Abs. min. heat setpoint limit */ + ZB_ZCL_ABS_MAX_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0004, /**< Abs. max. heat setpoint limit */ + ZB_ZCL_ABS_MIN_COOL_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0005, /**< Abs. min. cool setpoint limit */ + ZB_ZCL_ABS_MAX_COOL_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0006, /**< Abs. max. cool setpoint limit */ + ZB_ZCL_PI_COOLING_DEMAND_ATTRIBUTE_ID = 0x0007, /**< PI cooling demand */ + ZB_ZCL_PI_HEATING_DEMAND_ATTRIBUTE_ID = 0x0008, /**< PI heating demand */ + ZB_ZCL_HVAC_SYSTEM_TYPE_CONFIGURATION_ATTRIBUTE_ID = 0x0009, /**< HVAC system type configuration (since ha-1.2-05-3520-29) */ + ZB_ZCL_LOCAL_TEMPERATURE_CALIBRATION_ATTRIBUTE_ID = 0x0010, /**< Local temperature calibration */ + ZB_ZCL_OCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID = 0x0011, /**< Occupied cooling setpoint */ + ZB_ZCL_OCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID = 0x0012, /**< Occupied heating setpoint */ + ZB_ZCL_UNOCCUPIED_COOLING_SETPOINT_ATTRIBUTE_ID = 0x0013, /**< Unoccupied cooling setpoint */ + ZB_ZCL_UNOCCUPIED_HEATING_SETPOINT_ATTRIBUTE_ID = 0x0014, /**< Unoccupied heating setpoint */ + ZB_ZCL_MIN_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0015, /**< Min. heat setpoint limit */ + ZB_ZCL_MAX_HEAT_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0016, /**< Max. heat setpoint limit */ + ZB_ZCL_MIN_COOL_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0017, /**< Min. cool setpoint limit */ + ZB_ZCL_MAX_COOL_SETPOINT_LIMIT_ATTRIBUTE_ID = 0x0018, /**< Max. cool setpoint limit */ + ZB_ZCL_MIN_SETPOINT_DEAD_BAND_ATTRIBUTE_ID = 0x0019, /**< Min. setpoint dead band */ + ZB_ZCL_REMOTE_SENSING_ATTRIBUTE_ID = 0x001A, /**< Remote sensing */ + ZB_ZCL_CONTROL_SEQUENCE_OF_OPERATION_ATTRIBUTE_ID = 0x001B, /**< Control sequence of operation */ + ZB_ZCL_SYSTEM_MODE_ATTRIBUTE_ID = 0x001C, /**< System mode */ + ZB_ZCL_THERMOSTAT_ALARM_MASK_ATTRIBUTE_ID = 0x001D, /**< Thermostat alarm mask */ + ZB_ZCL_THERMOSTAT_RUNNING_MODE_ATTRIBUTE_ID = 0x001E, /**< Thermostat running mode (since ha-1.2-05-3520-29) */ + ZB_ZCL_START_OF_WEEK_ATTRIBUTE_ID = 0x0020, /**< Smart of week (since ha-1.2-05-3520-29) */ + ZB_ZCL_NUMBER_OF_WEEKLY_TRANSITIONS_ATTRIBUTE_ID = 0x0021, /**< Number of weekly transitions (since ha-1.2-05-3520-29) */ + ZB_ZCL_NUMBER_OF_DAILY_TRANSITIONS_ATTRIBUTE_ID = 0x0022, /**< Number of daily transition (since ha-1.2-05-3520-29) */ + ZB_ZCL_TEMPERATURE_SETPOINT_HOLD_ATTRIBUTE_ID = 0x0023, /**< Temperature setpoint hold (since ha-1.2-05-3520-29) */ + ZB_ZCL_TEMPERATURE_SETPOINT_HOLD_DURATION_ATTRIBUTE_ID = 0x0024, /**< Temperature setpoint hold duration mode (since ha-1.2-05-3520-29) */ + ZB_ZCL_THERMOSTAT_PROGRAMMING_OPERATION_MODE_ATTRIBUTE_ID = 0x0025, /**< Thermostat programming operation mode (since ha-1.2-05-3520-29) */ + ZB_ZCL_THERMOSTAT_RUNNING_STATE_ATTRIBUTE_ID = 0x0029, /**< Thermostat running state (since ha-1.2-05-3520-29) */ + ZB_ZCL_SETPOINT_CHANGE_SOURCE_ATTRIBUTE_ID = 0x0030, /**< Setpoint change source (since ha-1.2-05-3520-29) */ + ZB_ZCL_SETPOINT_CHANGE_AMOUNT_ATTRIBUTE_ID = 0x0031, /**< Setpoint change amount (since ha-1.2-05-3520-29) */ + ZB_ZCL_SETPOINT_CHANGE_SOURCE_TIMESTAMP_ATTRIBUTE_ID = 0x0032, /**< Setpoint change source timestamp (since ha-1.2-05-3520-29) */ + ZB_ZCL_AC_TYPE_ATTRIBUTE_ID = 0x0040, /**< AC type (since ha-1.2-05-3520-29) */ + ZB_ZCL_AC_CAPACITY_ATTRIBUTE_ID = 0x0041, /**< AC capacity (since ha-1.2-05-3520-29) */ + ZB_ZCL_AC_REFRIGERANT_TYPE_ATTRIBUTE_ID = 0x0042, /**< AC refrigerant type (since ha-1.2-05-3520-29) */ + ZB_ZCL_AC_COMPRESSOR_ATTRIBUTE_ID = 0x0043, /**< AC compressor (since ha-1.2-05-3520-29) */ + ZB_ZCL_AC_ERROR_CODE_ATTRIBUTE_ID = 0x0044, /**< AC error mode (since ha-1.2-05-3520-29) */ + ZB_ZCL_AC_LOUVER_POSITION_ATTRIBUTE_ID = 0x0045, /**< AC lovver position (since ha-1.2-05-3520-29) */ + ZB_ZCL_AC_COIL_TEMPERATURE_ATTRIBUTE_ID = 0x0046, /**< AC coli temperature (since ha-1.2-05-3520-29) */ + ZB_ZCL_AC_CAPACITY_FORMAT_ATTRIBUTE_ID = 0x0047, /**< AC capacity foramt (since ha-1.2-05-3520-29) */ +} zb_zcl_thermostat_server_attributes_e; + +/** + * @brief Attribute types for cluster: Fan Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_FAN_CONTROL_FAN_MODE_ATTRIBUTE_ID = 0x0000, /**< Fan mode */ + ZB_ZCL_FAN_CONTROL_FAN_MODE_SEQUENCE_ATTRIBUTE_ID = 0x0001, /**< Fan mode sequence */ +} zb_zcl_fan_control_server_attributes_e; + +/** + * @brief Attribute types for cluster: Dehumidification Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_RELATIVE_HUMIDITY_ATTRIBUTE_ID = 0x0000, /**< Relative humidity */ + ZB_ZCL_DEHUMIDIFICATION_COOLING_ATTRIBUTE_ID = 0x0001, /**< Dehumidication cooling */ + ZB_ZCL_RH_DEHUMIDIFICATION_SETPOINT_ATTRIBUTE_ID = 0x0010, /**< RH dehumidification setpoint */ + ZB_ZCL_RELATIVE_HUMIDITY_MODE_ATTRIBUTE_ID = 0x0011, /**< Relative humidity mode */ + ZB_ZCL_DEHUMIDIFICATION_LOCKOUT_ATTRIBUTE_ID = 0x0012, /**< Dehumidification lockout */ + ZB_ZCL_DEHUMIDIFICATION_HYSTERESIS_ATTRIBUTE_ID = 0x0013, /**< Dehumidification hysteresis */ + ZB_ZCL_DEHUMIDIFICATION_MAX_COOL_ATTRIBUTE_ID = 0x0014, /**< Dehumidification max. cool */ + ZB_ZCL_RELATIVE_HUMIDITY_DISPLAY_ATTRIBUTE_ID = 0x0015, /**< Relative humidity display */ +} zb_zcl_dehumidification_control_attributes_e; + +/** + * @brief Attribute types for cluster: Thermostat User Interface Configuration + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_TEMPERATURE_DISPLAY_MODE_ATTRIBUTE_ID = 0x0000, /**< Temperature display mode */ + ZB_ZCL_KEYPAD_LOCKOUT_ATTRIBUTE_ID = 0x0001, /**< Keypad lockout */ + ZB_ZCL_SCHEDULE_PROGRAMMING_VISIBILITY_ATTRIBUTE_ID = 0x0002, /**< Schedule programming visibility (since ha-1.2-05-3520-29) */ +} zb_zcl_thermostat_user_interface_configuration_server_attributes_e; + +/** + * @brief Attribute types for cluster: Color Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID = 0x0000, /**< Current hue */ + ZB_ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID = 0x0001, /**< Current saturation */ + ZB_ZCL_COLOR_CONTROL_REMAINING_TIME_ATTRIBUTE_ID = 0x0002, /**< Remaining time */ + ZB_ZCL_COLOR_CONTROL_CURRENT_X_ATTRIBUTE_ID = 0x0003, /**< Current x */ + ZB_ZCL_COLOR_CONTROL_CURRENT_Y_ATTRIBUTE_ID = 0x0004, /**< Current y */ + ZB_ZCL_COLOR_CONTROL_DRIFT_COMPENSATION_ATTRIBUTE_ID = 0x0005, /**< Drift compensation */ + ZB_ZCL_COLOR_CONTROL_COMPENSATION_TEXT_ATTRIBUTE_ID = 0x0006, /**< Compensation text */ + ZB_ZCL_COLOR_CONTROL_COLOR_TEMPERATURE_ATTRIBUTE_ID = 0x0007, /**< Color temperature */ + ZB_ZCL_COLOR_CONTROL_COLOR_MODE_ATTRIBUTE_ID = 0x0008, /**< Color mode */ + ZB_ZCL_COLOR_CONTROL_NUMBER_OF_PRIMARIES_ATTRIBUTE_ID = 0x0010, /**< Number of primaries */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_1_X_ATTRIBUTE_ID = 0x0011, /**< Primary 1 x */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_1_Y_ATTRIBUTE_ID = 0x0012, /**< Primary 1 y */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_1_INTENSITY_ATTRIBUTE_ID = 0x0013, /**< Primary 1 intensity */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_2_X_ATTRIBUTE_ID = 0x0015, /**< Primary 2 x */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_2_Y_ATTRIBUTE_ID = 0x0016, /**< Primary 2 y */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_2_INTENSITY_ATTRIBUTE_ID = 0x0017, /**< Primary 2 intensity */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_3_X_ATTRIBUTE_ID = 0x0019, /**< Primary 3 x */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_3_Y_ATTRIBUTE_ID = 0x001A, /**< Primary 3 y */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_3_INTENSITY_ATTRIBUTE_ID = 0x001B, /**< Primary 3 intensity */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_4_X_ATTRIBUTE_ID = 0x0020, /**< Primary 4 x */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_4_Y_ATTRIBUTE_ID = 0x0021, /**< Primary 4 y */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_4_INTENSITY_ATTRIBUTE_ID = 0x0022, /**< Primary 4 intensity */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_5_X_ATTRIBUTE_ID = 0x0024, /**< Primary 5 x */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_5_Y_ATTRIBUTE_ID = 0x0025, /**< Primary 5 y */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_5_INTENSITY_ATTRIBUTE_ID = 0x0026, /**< Primary 5 intensity */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_6_X_ATTRIBUTE_ID = 0x0028, /**< Primary 6 x */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_6_Y_ATTRIBUTE_ID = 0x0029, /**< Primary 6 y */ + ZB_ZCL_COLOR_CONTROL_PRIMARY_6_INTENSITY_ATTRIBUTE_ID = 0x002A, /**< Primary 6 intensity */ + ZB_ZCL_COLOR_CONTROL_WHITE_POINT_X_ATTRIBUTE_ID = 0x0030, /**< White point x */ + ZB_ZCL_COLOR_CONTROL_WHITE_POINT_Y_ATTRIBUTE_ID = 0x0031, /**< White point y */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_R_X_ATTRIBUTE_ID = 0x0032, /**< Color point R x */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_R_Y_ATTRIBUTE_ID = 0x0033, /**< Color point R y */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_R_INTENSITY_ATTRIBUTE_ID = 0x0034, /**< Color point R intensity */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_G_X_ATTRIBUTE_ID = 0x0036, /**< Color point G x */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_G_Y_ATTRIBUTE_ID = 0x0037, /**< Color point G y */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_G_INTENSITY_ATTRIBUTE_ID = 0x0038, /**< Color point G intensity */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_B_X_ATTRIBUTE_ID = 0x003A, /**< Color point B x */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_B_Y_ATTRIBUTE_ID = 0x003B, /**< Color point B y */ + ZB_ZCL_COLOR_CONTROL_COLOR_POINT_B_INTENSITY_ATTRIBUTE_ID = 0x003C, /**< Color point B intensity */ + ZB_ZCL_COLOR_CONTROL_ENHANCED_CURRENT_HUE_ATTRIBUTE_ID = 0x4000, /**< Enhanced current hue (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_ENHANCED_COLOR_MODE_ATTRIBUTE_ID = 0x4001, /**< Enhanced color mode (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_ACTIVE_ATTRIBUTE_ID = 0x4002, /**< Color loop active (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_DIRECTION_ATTRIBUTE_ID = 0x4003, /**< Color loop direction (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_TIME_ATTRIBUTE_ID = 0x4004, /**< Color loop time (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_START_ENHANCED_HUE_ATTRIBUTE_ID = 0x4005, /**< Color start enhanced hue (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_COLOR_LOOP_STORED_ENHANCED_HUE_ATTRIBUTE_ID = 0x4006, /**< Color loop stored enhanced hue (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_COLOR_CAPABILITIES_ATTRIBUTE_ID = 0x400A, /**< Color capabilities (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_COLOR_TEMP_PHYSICAL_MIN_ATTRIBUTE_ID = 0x400B, /**< Color temp. physical min. (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_CONTROL_COLOR_TEMP_PHYSICAL_MAX_ATTRIBUTE_ID = 0x400C, /**< Color temp. physical max. (since zll-1.0-11-0037-10) */ +} zb_zcl_color_control_server_attributes_e; + +/** + * @brief Attribute types for cluster: Ballast Configuration + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_PHYSICAL_MIN_LEVEL_ATTRIBUTE_ID = 0x0000, /**< Physical min. level */ + ZB_ZCL_PHYSICAL_MAX_LEVEL_ATTRIBUTE_ID = 0x0001, /**< Physical max. level */ + ZB_ZCL_BALLAST_STATUS_ATTRIBUTE_ID = 0x0002, /**< Ballast status */ + ZB_ZCL_MIN_LEVEL_ATTRIBUTE_ID = 0x0010, /**< Min. level */ + ZB_ZCL_MAX_LEVEL_ATTRIBUTE_ID = 0x0011, /**< Max. level */ + ZB_ZCL_POWER_ON_LEVEL_ATTRIBUTE_ID = 0x0012, /**< Power on level */ + ZB_ZCL_POWER_ON_FADE_TIME_ATTRIBUTE_ID = 0x0013, /**< Power on fade time */ + ZB_ZCL_INTRINSIC_BALLAST_FACTOR_ATTRIBUTE_ID = 0x0014, /**< Intrinsic ballast factor */ + ZB_ZCL_BALLAST_FACTOR_ADJUSTMENT_ATTRIBUTE_ID = 0x0015, /**< Ballast factor adjustment */ + ZB_ZCL_LAMP_QUALITY_ATTRIBUTE_ID = 0x0020, /**< Lamp quality */ + ZB_ZCL_LAMP_TYPE_ATTRIBUTE_ID = 0x0030, /**< Lamp type */ + ZB_ZCL_LAMP_MANUFACTURER_ATTRIBUTE_ID = 0x0031, /**< Lamp manufacturer */ + ZB_ZCL_LAMP_RATED_HOURS_ATTRIBUTE_ID = 0x0032, /**< Lamp rated hours */ + ZB_ZCL_LAMP_BURN_HOURS_ATTRIBUTE_ID = 0x0033, /**< Lamp burn hours */ + ZB_ZCL_LAMP_ALARM_MODE_ATTRIBUTE_ID = 0x0034, /**< Lamp alarm mode */ + ZB_ZCL_LAMP_BURN_HOURS_TRIP_POINT_ATTRIBUTE_ID = 0x0035, /**< Lamp burn hours */ +} zb_zcl_ballast_configuration_server_attributes_e; + +/** + * @brief Attribute types for cluster: Illuminance Measurement + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ILLUM_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Illuminance measured value */ + ZB_ZCL_ILLUM_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Illuminance Min. measured value */ + ZB_ZCL_ILLUM_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Illuminance Max. measured value */ + ZB_ZCL_ILLUM_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Illuminance Tolerance */ + ZB_ZCL_MEASUREMENT_LIGHT_SENSOR_TYPE_ATTRIBUTE_ID = 0x0004, /**< Measurement light sensor type */ +} zb_zcl_illuminance_measurement_server_attributes_e; + +/** + * @brief Attribute types for cluster: Illuminance Level Sensing + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ILLUS_LEVEL_STATUS_ATTRIBUTE_ID = 0x0000, /**< Illuminance level status */ + ZB_ZCL_ILLUS_SENSING_LIGHT_SENSOR_TYPE_ATTRIBUTE_ID = 0x0001, /**< Illuminance sensing light sensor type */ + ZB_ZCL_ILLUMINANCE_TARGET_LEVEL_ATTRIBUTE_ID = 0x0010, /**< Illuminance target level */ +} zb_zcl_illuminance_level_sensing_server_attributes_e; + +/** + * @brief Attribute types for cluster: Temperature Measurement + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Measured value */ + ZB_ZCL_TEMP_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Min. measured value */ + ZB_ZCL_TEMP_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Max. measured value */ + ZB_ZCL_TEMP_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Tolerance */ +} zb_zcl_temperature_measurement_server_attributes_e; + +/** + * @brief Attribute types for cluster: Pressure Measurement + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_PRESSURE_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Measured value */ + ZB_ZCL_PRESSURE_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Min. measured value */ + ZB_ZCL_PRESSURE_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Max. measured value */ + ZB_ZCL_PRESSURE_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Tolerance */ + ZB_ZCL_PRESSURE_SCALED_VALUE_ATTRIBUTE_ID = 0x0010, /**< Scaled value */ + ZB_ZCL_PRESSURE_MIN_SCALED_VALUE_ATTRIBUTE_ID = 0x0011, /**< Min. scaled value */ + ZB_ZCL_PRESSURE_MAX_SCALED_VALUE_ATTRIBUTE_ID = 0x0012, /**< Max. scaled value */ + ZB_ZCL_PRESSURE_SCALED_TOLERANCE_ATTRIBUTE_ID = 0x0013, /**< Scaled tolerance */ + ZB_ZCL_PRESSURE_SCALE_ATTRIBUTE_ID = 0x0014, /**< Scale */ +} zb_zcl_pressure_measurement_server_attributes_e; + +/** + * @brief Attribute types for cluster: Flow Measurement + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_FLOW_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Measured value */ + ZB_ZCL_FLOW_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Min. measured value */ + ZB_ZCL_FLOW_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Max. measured value */ + ZB_ZCL_FLOW_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Tolerance */ +} zb_zcl_flow_measurement_server_attributes_e; + +/** + * @brief Attribute types for cluster: Relative Humidity Measurement + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_RELATIVE_HUMIDITY_MEASURED_VALUE_ATTRIBUTE_ID = 0x0000, /**< Measured value */ + ZB_ZCL_RELATIVE_HUMIDITY_MIN_MEASURED_VALUE_ATTRIBUTE_ID = 0x0001, /**< Min. measured value */ + ZB_ZCL_RELATIVE_HUMIDITY_MAX_MEASURED_VALUE_ATTRIBUTE_ID = 0x0002, /**< Max. measured value */ + ZB_ZCL_RELATIVE_HUMIDITY_TOLERANCE_ATTRIBUTE_ID = 0x0003, /**< Tolerance */ +} zb_zcl_relative_humidity_measurement_server_attributes_e; + +/** + * @brief Attribute types for cluster: Occupancy Sensing + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_OCCUPANCY_ATTRIBUTE_ID = 0x0000, /**< Occupancy */ + ZB_ZCL_OCCUPANCY_SENSOR_TYPE_ATTRIBUTE_ID = 0x0001, /**< Occupancy sensor type */ + ZB_ZCL_PIR_OCCUPIED_TO_UNOCCUPIED_DELAY_ATTRIBUTE_ID = 0x0010, /**< PIR occupied to unoccupied delay */ + ZB_ZCL_PIR_UNOCCUPIED_TO_OCCUPIED_DELAY_ATTRIBUTE_ID = 0x0011, /**< PIR unoccupied to occupied delay */ + ZB_ZCL_PIR_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_ATTRIBUTE_ID = 0x0012, /**< PIR unoccupied to occupied threshold */ + ZB_ZCL_ULTRASONIC_OCCUPIED_TO_UNOCCUPIED_DELAY_ATTRIBUTE_ID = 0x0020, /**< Ultrasonic occupied to unoccupied delay */ + ZB_ZCL_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_DELAY_ATTRIBUTE_ID = 0x0021, /**< Ultrasonic unoccupied to occupied delay */ + ZB_ZCL_ULTRASONIC_UNOCCUPIED_TO_OCCUPIED_THRESHOLD_ATTRIBUTE_ID = 0x0022, /**< Ultrasonic unoccupied to occupied threshold */ +} zb_zcl_occupancy_sensing_measurement_server_attributes_e; + +/** + * @brief Attribute types for cluster: IAS Zone + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ZONE_STATE_ATTRIBUTE_ID = 0x0000, /**< Zone state */ + ZB_ZCL_ZONE_TYPE_ATTRIBUTE_ID = 0x0001, /**< Zone type */ + ZB_ZCL_ZONE_STATUS_ATTRIBUTE_ID = 0x0002, /**< Zone status */ + ZB_ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID = 0x0010, /**< IAS CIE address */ + ZB_ZCL_ZONE_ID_ATTRIBUTE_ID = 0x0011, /**< Zone ID */ + ZB_ZCL_NUMBER_OF_ZONE_SENSITIVITY_LEVELS_SUPPORTED_ATTRIBUTE_ID = 0x0012, /**< Number of zone sensitivity levels supported */ + ZB_ZCL_CURRENT_ZONE_SENSITIVITY_LEVEL_ATTRIBUTE_ID = 0x0013, /**< Current zone sensitivitiy level */ +} zb_zcl_isa_zone_server_server_attributes_e; + +/** + * @brief Attribute types for cluster: IAS WD + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_MAX_DURATION_ATTRIBUTE_ID = 0x0000, /**< Max. duration */ +} zb_zcl_isa_wd_server_server_attributes_e; + +/** + * @brief Attribute types for cluster: Electrical Measurement + * @details Cluster specification level: UNKNOWN + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_MEASUREMENT_TYPE_ATTRIBUTE_ID = 0x0000, /**< Measurement type */ + ZB_ZCL_DC_VOLTAGE_ATTRIBUTE_ID = 0x0100, /**< DC voltage */ + ZB_ZCL_DC_VOLTAGE_MIN_ATTRIBUTE_ID = 0x0101, /**< DC voltage min. */ + ZB_ZCL_DC_VOLTAGE_MAX_ATTRIBUTE_ID = 0x0102, /**< DC voltage max. */ + ZB_ZCL_DC_CURRENT_ATTRIBUTE_ID = 0x0103, /**< DC current */ + ZB_ZCL_DC_CURRENT_MIN_ATTRIBUTE_ID = 0x0104, /**< DC current min. */ + ZB_ZCL_DC_CURRENT_MAX_ATTRIBUTE_ID = 0x0105, /**< DC current max. */ + ZB_ZCL_DC_POWER_ATTRIBUTE_ID = 0x0106, /**< DC power */ + ZB_ZCL_DC_POWER_MIN_ATTRIBUTE_ID = 0x0107, /**< DC power min. */ + ZB_ZCL_DC_POWER_MAX_ATTRIBUTE_ID = 0x0108, /**< DC Power max. */ + ZB_ZCL_DC_VOLTAGE_MULTIPLIER_ATTRIBUTE_ID = 0x0200, /**< DC voltage multiplier */ + ZB_ZCL_DC_VOLTAGE_DIVISOR_ATTRIBUTE_ID = 0x0201, /**< DC voltage divisor */ + ZB_ZCL_DC_CURRENT_MULTIPLIER_ATTRIBUTE_ID = 0x0202, /**< DC current multiplier */ + ZB_ZCL_DC_CURRENT_DIVISOR_ATTRIBUTE_ID = 0x0203, /**< DC current divisior */ + ZB_ZCL_DC_POWER_MULTIPLIER_ATTRIBUTE_ID = 0x0204, /**< DC power multiplier */ + ZB_ZCL_DC_POWER_DIVISOR_ATTRIBUTE_ID = 0x0205, /**< DC power divisor */ + ZB_ZCL_AC_FREQUENCY_ATTRIBUTE_ID = 0x0300, /**< AC frequency */ + ZB_ZCL_AC_FREQUENCY_MIN_ATTRIBUTE_ID = 0x0301, /**< AC frequency min. */ + ZB_ZCL_AC_FREQUENCY_MAX_ATTRIBUTE_ID = 0x0302, /**< AC frequency max. */ + ZB_ZCL_NEUTRAL_CURRENT_ATTRIBUTE_ID = 0x0303, /**< Neutral current */ + ZB_ZCL_TOTAL_ACTIVE_POWER_ATTRIBUTE_ID = 0x0304, /**< Total active power */ + ZB_ZCL_TOTAL_REACTIVE_POWER_ATTRIBUTE_ID = 0x0305, /**< Total reactive power */ + ZB_ZCL_TOTAL_APPARENT_POWER_ATTRIBUTE_ID = 0x0306, /**< Total apparent power */ + ZB_ZCL_MEASURED_1ST_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0307, /**< Measured 1st harmonic current */ + ZB_ZCL_MEASURED_3RD_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0308, /**< Measured 3rd harmonic current */ + ZB_ZCL_MEASURED_5TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0309, /**< Measured 5th harmonic current */ + ZB_ZCL_MEASURED_7TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030A, /**< Measured 7th harmonic current */ + ZB_ZCL_MEASURED_9TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030B, /**< Measured 9th harmonic current */ + ZB_ZCL_MEASURED_11TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030C, /**< Measured 11th harmonic current */ + ZB_ZCL_MEASURED_PHASE_1ST_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030D, /**< Measured phase 1st harmonic current */ + ZB_ZCL_MEASURED_PHASE_3RD_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030E, /**< Measured phase 3rd harmonic current */ + ZB_ZCL_MEASURED_PHASE_5TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x030F, /**< Measured phase 5th harmonic current */ + ZB_ZCL_MEASURED_PHASE_7TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0310, /**< Measured phase 7th harmonic current */ + ZB_ZCL_MEASURED_PHASE_9TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0311, /**< Measured phase 9th harmonic current */ + ZB_ZCL_MEASURED_PHASE_11TH_HARMONIC_CURRENT_ATTRIBUTE_ID = 0x0312, /**< Measured phase 11th harmonic current */ + ZB_ZCL_AC_FREQUENCY_MULTIPLIER_ATTRIBUTE_ID = 0x0400, /**< AC frequency multiplier */ + ZB_ZCL_AC_FREQUENCY_DIVISOR_ATTRIBUTE_ID = 0x0401, /**< AC frequency divisor */ + ZB_ZCL_POWER_MULTIPLIER_ATTRIBUTE_ID = 0x0402, /**< Power multiplier */ + ZB_ZCL_POWER_DIVISOR_ATTRIBUTE_ID = 0x0403, /**< Power divisor */ + ZB_ZCL_HARMONIC_CURRENT_MULTIPLIER_ATTRIBUTE_ID = 0x0404, /**< Harmonic current multiplier */ + ZB_ZCL_PHASE_HARMONIC_CURRENT_MULTIPLIER_ATTRIBUTE_ID = 0x0405, /**< Phase harmonic current multiplier */ + ZB_ZCL_INSTANTANEOUS_VOLTAGE_ATTRIBUTE_ID = 0x0500, /**< Instaneous voltage */ + ZB_ZCL_INSTANTANEOUS_LINE_CURRENT_ATTRIBUTE_ID = 0x0501, /**< Instaneous line current */ + ZB_ZCL_INSTANTANEOUS_ACTIVE_CURRENT_ATTRIBUTE_ID = 0x0502, /**< Instaneous active current */ + ZB_ZCL_INSTANTANEOUS_REACTIVE_CURRENT_ATTRIBUTE_ID = 0x0503, /**< Instaneous reactive current */ + ZB_ZCL_INSTANTANEOUS_POWER_ATTRIBUTE_ID = 0x0504, /**< Instaneous power */ + ZB_ZCL_RMS_VOLTAGE_ATTRIBUTE_ID = 0x0505, /**< RMS voltage */ + ZB_ZCL_RMS_VOLTAGE_MIN_ATTRIBUTE_ID = 0x0506, /**< RMS voltage min. */ + ZB_ZCL_RMS_VOLTAGE_MAX_ATTRIBUTE_ID = 0x0507, /**< RMS voltage max. */ + ZB_ZCL_RMS_CURRENT_ATTRIBUTE_ID = 0x0508, /**< RMS current */ + ZB_ZCL_RMS_CURRENT_MIN_ATTRIBUTE_ID = 0x0509, /**< RMS current min. */ + ZB_ZCL_RMS_CURRENT_MAX_ATTRIBUTE_ID = 0x050A, /**< RMS current max. */ + ZB_ZCL_ACTIVE_POWER_ATTRIBUTE_ID = 0x050B, /**< Active power */ + ZB_ZCL_ACTIVE_POWER_MIN_ATTRIBUTE_ID = 0x050C, /**< Active power min. */ + ZB_ZCL_ACTIVE_POWER_MAX_ATTRIBUTE_ID = 0x050D, /**< Active power max. */ + ZB_ZCL_REACTIVE_POWER_ATTRIBUTE_ID = 0x050E, /**< Reactive power */ + ZB_ZCL_APPARENT_POWER_ATTRIBUTE_ID = 0x050F, /**< Apprent power */ + ZB_ZCL_AC_POWER_FACTOR_ATTRIBUTE_ID = 0x0510, /**< AC power factor */ + ZB_ZCL_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_ATTRIBUTE_ID = 0x0511, /**< Average RMS voltage measurement period */ + ZB_ZCL_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_ATTRIBUTE_ID = 0x0513, /**< Average RMS under voltage counter */ + ZB_ZCL_RMS_EXTREME_OVER_VOLTAGE_PERIOD_ATTRIBUTE_ID = 0x0514, /**< RMS extrem over voltage period */ + ZB_ZCL_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_ATTRIBUTE_ID = 0x0515, /**< RMS extrem under voltage period */ + ZB_ZCL_RMS_VOLTAGE_SAG_PERIOD_ATTRIBUTE_ID = 0x0516, /**< RMS voltage sag period */ + ZB_ZCL_RMS_VOLTAGE_SWELL_PERIOD_ATTRIBUTE_ID = 0x0517, /**< RMS voltage swell period */ + ZB_ZCL_AC_VOLTAGE_MULTIPLIER_ATTRIBUTE_ID = 0x0600, /**< AC voltage multiplier */ + ZB_ZCL_AC_VOLTAGE_DIVISOR_ATTRIBUTE_ID = 0x0601, /**< AC voltage divisor */ + ZB_ZCL_AC_CURRENT_MULTIPLIER_ATTRIBUTE_ID = 0x0602, /**< AC current multiplier */ + ZB_ZCL_AC_CURRENT_DIVISOR_ATTRIBUTE_ID = 0x0603, /**< AC current divisor */ + ZB_ZCL_AC_POWER_MULTIPLIER_ATTRIBUTE_ID = 0x0604, /**< AC power multiplier */ + ZB_ZCL_AC_POWER_DIVISOR_ATTRIBUTE_ID = 0x0605, /**< AC power divisor */ + ZB_ZCL_DC_OVERLOAD_ALARMS_MASK_ATTRIBUTE_ID = 0x0700, /**< DC overload alarms mask */ + ZB_ZCL_DC_VOLTAGE_OVERLOAD_ATTRIBUTE_ID = 0x0701, /**< DC voltage overload */ + ZB_ZCL_DC_CURRENT_OVERLOAD_ATTRIBUTE_ID = 0x0702, /**< DC current overload */ + ZB_ZCL_AC_OVERLOAD_ALARMS_MASK_ATTRIBUTE_ID = 0x0800, /**< Overload alarms mask */ + ZB_ZCL_AC_VOLTAGE_OVERLOAD_ATTRIBUTE_ID = 0x0801, /**< AC voltage overload */ + ZB_ZCL_AC_CURRENT_OVERLOAD_ATTRIBUTE_ID = 0x0802, /**< AC current overload */ + ZB_ZCL_AC_POWER_OVERLOAD_ATTRIBUTE_ID = 0x0803, /**< AC power overload */ + ZB_ZCL_AC_REACTIVE_POWER_OVERLOAD_ATTRIBUTE_ID = 0x0804, /**< AC reactive power overload */ + ZB_ZCL_AVERAGE_RMS_OVER_VOLTAGE_ATTRIBUTE_ID = 0x0805, /**< Average RMS over voltage */ + ZB_ZCL_AVERAGE_RMS_UNDER_VOLTAGE_ATTRIBUTE_ID = 0x0806, /**< Average RMS under voltage */ + ZB_ZCL_RMS_EXTREME_OVER_VOLTAGE_ATTRIBUTE_ID = 0x0807, /**< RMS extreme over voltage */ + ZB_ZCL_RMS_EXTREME_UNDER_VOLTAGE_ATTRIBUTE_ID = 0x0808, /**< RMS extreme under voltage */ + ZB_ZCL_RMS_VOLTAGE_SAG_ATTRIBUTE_ID = 0x0809, /**< RMS voltage sag */ + ZB_ZCL_RMS_VOLTAGE_SWELL_ATTRIBUTE_ID = 0x080A, /**< RMS voltage swell */ + ZB_ZCL_LINE_CURRENT_PHASE_B_ATTRIBUTE_ID = 0x0901, /**< Line current phase B */ + ZB_ZCL_ACTIVE_CURRENT_PHASE_B_ATTRIBUTE_ID = 0x0902, /**< Active current phase B */ + ZB_ZCL_REACTIVE_CURRENT_PHASE_B_ATTRIBUTE_ID = 0x0903, /**< Reactive current phase B */ + ZB_ZCL_RMS_VOLTAGE_PHASE_B_ATTRIBUTE_ID = 0x0905, /**< RMS voltage phase B */ + ZB_ZCL_RMS_VOLTAGE_MIN_PHASE_B_ATTRIBUTE_ID = 0x0906, /**< RMS voltage min. phase B */ + ZB_ZCL_RMS_VOLTAGE_MAX_PHASE_B_ATTRIBUTE_ID = 0x0907, /**< RMS voltage max. phase B */ + ZB_ZCL_RMS_CURRENT_PHASE_B_ATTRIBUTE_ID = 0x0908, /**< RMS current phase B */ + ZB_ZCL_RMS_CURRENT_MIN_PHASE_B_ATTRIBUTE_ID = 0x0909, /**< RMS current min. phase B */ + ZB_ZCL_RMS_CURRENT_MAX_PHASE_B_ATTRIBUTE_ID = 0x090A, /**< RMS current max. phase B */ + ZB_ZCL_ACTIVE_POWER_PHASE_B_ATTRIBUTE_ID = 0x090B, /**< Active power phase B */ + ZB_ZCL_ACTIVE_POWER_MIN_PHASE_B_ATTRIBUTE_ID = 0x090C, /**< Active power min. phase B */ + ZB_ZCL_ACTIVE_POWER_MAX_PHASE_B_ATTRIBUTE_ID = 0x090D, /**< Active power max. B */ + ZB_ZCL_REACTIVE_POWER_PHASE_B_ATTRIBUTE_ID = 0x090E, /**< Reactive power phase B */ + ZB_ZCL_APPARENT_POWER_PHASE_B_ATTRIBUTE_ID = 0x090F, /**< Apprent power phase B */ + ZB_ZCL_POWER_FACTOR_PHASE_B_ATTRIBUTE_ID = 0x0910, /**< Power factor phase B */ + ZB_ZCL_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0911, /**< Average RMS voltage measurement period phase B */ + ZB_ZCL_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PHASE_B_ATTRIBUTE_ID = 0x0912, /**< RMS over voltage counter phase B */ + ZB_ZCL_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PHASE_B_ATTRIBUTE_ID = 0x0913, /**< Average RMS under vlotage counter phase B */ + ZB_ZCL_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0914, /**< RMS extreme over voltage period phase B */ + ZB_ZCL_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0915, /**< RMS extreme under voltage period phase B */ + ZB_ZCL_RMS_VOLTAGE_SAG_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0916, /**< RMS voltage sag period phase B */ + ZB_ZCL_RMS_VOLTAGE_SWELL_PERIOD_PHASE_B_ATTRIBUTE_ID = 0x0917, /**< RMS voltage swell period phase B */ + ZB_ZCL_LINE_CURRENT_PHASE_C_ATTRIBUTE_ID = 0x0A01, /**< Line current phase C */ + ZB_ZCL_ACTIVE_CURRENT_PHASE_C_ATTRIBUTE_ID = 0x0A02, /**< Active current phase C */ + ZB_ZCL_REACTIVE_CURRENT_PHASE_C_ATTRIBUTE_ID = 0x0A03, /**< Reactive current phase C */ + ZB_ZCL_RMS_VOLTAGE_PHASE_C_ATTRIBUTE_ID = 0x0A05, /**< RMS voltage phase C */ + ZB_ZCL_RMS_VOLTAGE_MIN_PHASE_C_ATTRIBUTE_ID = 0x0A06, /**< RMS voltage min. phase C */ + ZB_ZCL_RMS_VOLTAGE_MAX_PHASE_C_ATTRIBUTE_ID = 0x0A07, /**< RMS voltage max. phase C */ + ZB_ZCL_RMS_CURRENT_PHASE_C_ATTRIBUTE_ID = 0x0A08, /**< RMS current phase C */ + ZB_ZCL_RMS_CURRENT_MIN_PHASE_C_ATTRIBUTE_ID = 0x0A09, /**< RMS current min. phase C */ + ZB_ZCL_RMS_CURRENT_MAX_PHASE_C_ATTRIBUTE_ID = 0x0A0A, /**< RMS current max. phase C */ + ZB_ZCL_ACTIVE_POWER_PHASE_C_ATTRIBUTE_ID = 0x0A0B, /**< Active power phase C */ + ZB_ZCL_ACTIVE_POWER_MIN_PHASE_C_ATTRIBUTE_ID = 0x0A0C, /**< Active power min. phase C */ + ZB_ZCL_ACTIVE_POWER_MAX_PHASE_C_ATTRIBUTE_ID = 0x0A0D, /**< Active power max. phase C */ + ZB_ZCL_REACTIVE_POWER_PHASE_C_ATTRIBUTE_ID = 0x0A0E, /**< Reactive power phase C */ + ZB_ZCL_APPARENT_POWER_PHASE_C_ATTRIBUTE_ID = 0x0A0F, /**< Reactive power phase C */ + ZB_ZCL_POWER_FACTOR_PHASE_C_ATTRIBUTE_ID = 0x0A10, /**< Power factor phase C */ + ZB_ZCL_AVERAGE_RMS_VOLTAGE_MEASUREMENT_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A11, /**< Average RMS voltage measurement period phase C */ + ZB_ZCL_AVERAGE_RMS_OVER_VOLTAGE_COUNTER_PHASE_C_ATTRIBUTE_ID = 0x0A12, /**< Average RMS over voltage counter phase C */ + ZB_ZCL_AVERAGE_RMS_UNDER_VOLTAGE_COUNTER_PHASE_C_ATTRIBUTE_ID = 0x0A13, /**< Average RMS under voltage counter phase C */ + ZB_ZCL_RMS_EXTREME_OVER_VOLTAGE_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A14, /**< RMS extreme over voltage period phase C */ + ZB_ZCL_RMS_EXTREME_UNDER_VOLTAGE_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A15, /**< RMS extreme under voltage period phase C */ + ZB_ZCL_RMS_VOLTAGE_SAG_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A16, /**< RMS voltage sag period phase C */ + ZB_ZCL_RMS_VOLTAGE_SWELL_PERIOD_PHASE_C_ATTRIBUTE_ID = 0x0A17, /**< RMS voltage swell peroid phase C */ +} zb_zcl_electrical_measurement_server_attributes_e; + +/** + * @brief Attribute types for cluster: Diagnostics + * @details Cluster specification level: UNKNOWN + * @pre Server attributes + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_NUMBER_OF_RESETS_ATTRIBUTE_ID = 0x0000, /**< Number of resets */ + ZB_ZCL_PERSISTENT_MEMORY_WRITES_ATTRIBUTE_ID = 0x0001, /**< Rersistent memory write */ + ZB_ZCL_MAC_RX_BCAST_ATTRIBUTE_ID = 0x0100, /**< MAC Rx broadcast count */ + ZB_ZCL_MAC_TX_BCAST_ATTRIBUTE_ID = 0x0101, /**< MAC Tx broadcas count t */ + ZB_ZCL_MAC_RX_UCAST_ATTRIBUTE_ID = 0x0102, /**< MAC Rx unicast */ + ZB_ZCL_MAC_TX_UCAST_ATTRIBUTE_ID = 0x0103, /**< MAC Tx unicast */ + ZB_ZCL_MAC_TX_UCAST_RETRY_ATTRIBUTE_ID = 0x0104, /**< MAC Tx unicast retry count */ + ZB_ZCL_MAC_TX_UCAST_FAIL_ATTRIBUTE_ID = 0x0105, /**< MAC Tx unicast fail count */ + ZB_ZCL_APS_RX_BCAST_ATTRIBUTE_ID = 0x0106, /**< APS Tx broadcast count */ + ZB_ZCL_APS_TX_BCAST_ATTRIBUTE_ID = 0x0107, /**< APS Tx broadcast count */ + ZB_ZCL_APS_RX_UCAST_ATTRIBUTE_ID = 0x0108, /**< APX Rx unicast count */ + ZB_ZCL_APS_UCAST_SUCCESS_ATTRIBUTE_ID = 0x0109, /**< APS unicast success count */ + ZB_ZCL_APS_TX_UCAST_RETRY_ATTRIBUTE_ID = 0x010A, /**< APS Tx unicast retry count */ + ZB_ZCL_APS_TX_UCAST_FAIL_ATTRIBUTE_ID = 0x010B, /**< APS Tx unicast fail count */ + ZB_ZCL_ROUTE_DISC_INITIATED_ATTRIBUTE_ID = 0x010C, /**< Number of Route discovery initiated */ + ZB_ZCL_NEIGHBOR_ADDED_ATTRIBUTE_ID = 0x010D, /**< Number of Neighbor added */ + ZB_ZCL_NEIGHBOR_REMOVED_ATTRIBUTE_ID = 0x010E, /**< Number of Neighbor removed */ + ZB_ZCL_NEIGHBOR_STALE_ATTRIBUTE_ID = 0x010F, /**< Number of Neighbor stale */ + ZB_ZCL_JOIN_INDICATION_ATTRIBUTE_ID = 0x0110, /**< Join indication count */ + ZB_ZCL_CHILD_MOVED_ATTRIBUTE_ID = 0x0111, /**< Number of Child moved */ + ZB_ZCL_NWK_FC_FAILURE_ATTRIBUTE_ID = 0x0112, /**< Network layer flow-control failure count */ + ZB_ZCL_APS_FC_FAILURE_ATTRIBUTE_ID = 0x0113, /**< APS layer flow-control failure count */ + ZB_ZCL_APS_UNAUTHORIZED_KEY_ATTRIBUTE_ID = 0x0114, /**< APS layer unauthorized key */ + ZB_ZCL_NWK_DECRYPT_FAILURE_ATTRIBUTE_ID = 0x0115, /**< Network layer decrypt failure count */ + ZB_ZCL_APS_DECRYPT_FAILURE_ATTRIBUTE_ID = 0x0116, /**< AOS layer decrypt failure count */ + ZB_ZCL_PACKET_BUFFER_ALLOC_FAILURES_ATTRIBUTE_ID = 0x0117, /**< Packet buffer allocation fauilure count */ + ZB_ZCL_RELAYED_UNICAST_ATTRIBUTE_ID = 0x0118, /**< Relayed unicast count */ + ZB_ZCL_PHY_TO_MAC_QUEUE_LIMIT_REACHED_ATTRIBUTE_ID = 0x0119, /**< PHY to MAC queue limit reached */ + ZB_ZCL_PACKET_VALIDATE_DROP_COUNT_ATTRIBUTE_ID = 0x011A, /**< Packet validate drop count */ + ZB_ZCL_AVERAGE_MAC_RETRY_PER_APS_MSG_SENT_ATTRIBUTE_ID = 0x011B, /**< Average MAC retry per APS message sent */ + ZB_ZCL_LAST_MESSAGE_LQI_ATTRIBUTE_ID = 0x011C, /**< Last message LQI */ + ZB_ZCL_LAST_MESSAGE_RSSI_ATTRIBUTE_ID = 0x011D, /**< Last message RSSI */ +} zb_zcl_diagnostics_server_attributes_e; + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_IDS_H__ */ diff --git a/include/zcl/zb_zcl_attribute_type.h b/include/zcl/zb_zcl_attribute_type.h new file mode 100644 index 0000000..5c1fde0 --- /dev/null +++ b/include/zcl/zb_zcl_attribute_type.h @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_TYPE_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_TYPE_H__ + +/** + * @file zb_zcl_attribute_type.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_DATA_TYPE_MODULE Cluster Attribute Data Type + * + * @brief zigbee cluster attribute data type + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_DATA_TYPE_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/** + * @brief ZCL attribute types (See Table 2.16 Data type of the Zigbee Cluster Library) + * @details ZigBee devices, such as thermostats, lamps, etc., are defined in terms of the + * attributes they contain, which can be written, read or reported using the + * commands defined in clause 2.4. Table 2.16 details the data types and formats that + * can be used for these attributes. Note that individual clusters, which may use + * different or new types, show valid values, ranges, and units for the attributes they + * represent. \n\n + * + * Each data type is allocated an 8-bit data type ID. The most significant 5 bits of this + * ID is used to divide the types into 32 type classes, and the least significant 3 bits + * specify a specific data type within this class. \n\n + * + * Table 2.16 also indicates for each data type whether it is considered to be 'analog' + * or 'discrete'. Values of analog types may be added to or subtracted from other + * values of the same type, and are typically used to measure the value of properties + * in the real world that vary continuously over a range. Values of discrete data types + * only have meaning as individual values, and may not be added or subtracted. + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_NO_DATA_ATTRIBUTE_TYPE = 0x00, /**< No data */ + ZB_ZCL_8_BIT_DATA = 0x08, /**< 8-bit data, 1-byte */ + ZB_ZCL_16_BIT_DATA = 0x09, /**< 16-bit data, 2-byte */ + ZB_ZCL_24_BIT_DATA = 0x0a, /**< 24-bit data, 3-byte */ + ZB_ZCL_32_BIT_DATA = 0x0b, /**< 32-bit data, 4-byte */ + ZB_ZCL_40_BIT_DATA = 0x0c, /**< 40-bit data, 5-byte */ + ZB_ZCL_48_BIT_DATA = 0x0d, /**< 48-bit data, 6-byte */ + ZB_ZCL_56_BIT_DATA = 0x0e, /**< 56-bit data, 7-byte */ + ZB_ZCL_64_BIT_DATA = 0x0f, /**< 64-bit data, 8-byte */ + ZB_ZCL_BOOLEAN = 0x10, /**< Boolean, 1-byte */ + ZB_ZCL_8_BIT_BITMAP = 0x18, /**< 8-bit bitmap, 1-byte */ + ZB_ZCL_16_BIT_BITMAP = 0x19, /**< 16-bit bitmap, 2-byte */ + ZB_ZCL_24_BIT_BITMAP = 0x1a, /**< 24-bit bitmap, 3-byte */ + ZB_ZCL_32_BIT_BITMAP = 0x1b, /**< 32-bit bitmap, 4-byte */ + ZB_ZCL_40_BIT_BITMAP = 0x1c, /**< 40-bit bitmap, 5-byte */ + ZB_ZCL_48_BIT_BITMAP = 0x1d, /**< 48-bit bitmap, 6-byte */ + ZB_ZCL_56_BIT_BITMAP = 0x1e, /**< 56-bit bitmap, 7-byte */ + ZB_ZCL_64_BIT_BITMAP = 0x1f, /**< 64-bit bitmap, 8-byte */ + ZB_ZCL_UNSIGNED_8_BIT_INTEGER = 0x20, /**< unsigned 8-bit integer, 1-byte */ + ZB_ZCL_UNSIGNED_16_BIT_INTEGER = 0x21, /**< unsigned 16-bit integer, 2-byte */ + ZB_ZCL_UNSIGNED_24_BIT_INTEGER = 0x22, /**< unsigned 24-bit integer, 3-byte */ + ZB_ZCL_UNSIGNED_32_BIT_INTEGER = 0x23, /**< unsigned 32-bit integer, 4-byte */ + ZB_ZCL_UNSIGNED_40_BIT_INTEGER = 0x24, /**< unsigned 40-bit integer, 5-byte */ + ZB_ZCL_UNSIGNED_48_BIT_INTEGER = 0x25, /**< unsigned 48-bit integer, 6-byte */ + ZB_ZCL_UNSIGNED_56_BIT_INTEGER = 0x26, /**< unsigned 56-bit integer, 7-byte */ + ZB_ZCL_UNSIGNED_64_BIT_INTEGER = 0x27, /**< unsigned 64-bit integer, 8-byte */ + ZB_ZCL_SIGNED_8_BIT_INTEGER = 0x28, /**< signed 8-bit integer, 1-byte */ + ZB_ZCL_SIGNED_16_BIT_INTEGER = 0x29, /**< signed 16-bit integer, 2-byte */ + ZB_ZCL_SIGNED_24_BIT_INTEGER = 0x2a, /**< signed 24-bit integer, 3-byte */ + ZB_ZCL_SIGNED_32_BIT_INTEGER = 0x2b, /**< signed 32-bit integer, 4-byte */ + ZB_ZCL_SIGNED_40_BIT_INTEGER = 0x2c, /**< signed 40-bit integer, 5-byte */ + ZB_ZCL_SIGNED_48_BIT_INTEGER = 0x2d, /**< signed 48-bit integer, 6-byte */ + ZB_ZCL_SIGNED_56_BIT_INTEGER = 0x2e, /**< signed 56-bit integer, 7-byte */ + ZB_ZCL_SIGNED_64_BIT_INTEGER = 0x2f, /**< signed 64-bit integer, 8-byte */ + ZB_ZCL_8_BIT_ENUMERATION = 0x30, /**< 8-bit enumeration, 1-byte */ + ZB_ZCL_16_BIT_ENUMERATION = 0x31, /**< 16-bit enumeration, 2-byte */ + ZB_ZCL_SEMI_PRECISION = 0x38, /**< foating point, 2-byte */ + ZB_ZCL_SINGLE_PRECISION = 0x39, /**< foating point, 4-byte */ + ZB_ZCL_DOUBLE_PRECISION = 0x3a, /**< foating point, 8-byte */ + /**< Octat string, Defined in first two octat */ + ZB_ZCL_OCTAT_STRING = 0x41, + /**< Character string, Defined in first two octat */ + ZB_ZCL_CHRACTER_STRING = 0x42, + /**< Long octat string, Defined in first two octat */ + ZB_ZCL_LONG_OCTAT_STRING = 0x43, + /**< Long character string, Defined in first 2-byte */ + ZB_ZCL_LONG_CHRACTER_STRING = 0x44, + /**< Array 2(0xffff)+Sum of lengths of contents, but we ignore 2-byte prefix */ + ZB_ZCL_ARRAY = 0x48, + /**< Structure 2(0xffff)+Sum of lengths of contents, but we ignore 2-byte prefix */ + ZB_ZCL_STRUCTURE = 0x4c, + ZB_ZCL_SET = 0x50, /**< Set, Sum of lengths of contents */ + ZB_ZCL_BAG = 0x51, /**< Bag, Sum of lengths of contents */ + ZB_ZCL_TIME_OF_DAY = 0xe0, /**< Time of day, 4-byte */ + ZB_ZCL_DATE = 0xe1, /**< Date, 4 byte */ + ZB_ZCL_UTC_TIME = 0xe2, /**< UTC Time, 4-byte */ + ZB_ZCL_CLUSTER_ID = 0xe8, /**< Cluster ID, 2-byte */ + ZB_ZCL_ATTRIBUTE_ID = 0xe9, /**< Attribute ID, 2-byte */ + ZB_ZCL_BACNET_OID = 0xea, /**< BACnet OID 4 byte */ + ZB_ZCL_IEEE_ADDRESS = 0xf0, /**< IEEE address, 8-byte */ + ZB_ZCL_128_BIT_SECURITY_KEY = 0xf1, /**< 128-bit security key, 16-byte */ +} zb_zcl_data_type_e; + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ATTRIBUTE_TYPE_H__ */ diff --git a/include/zcl/zb_zcl_basic_cluster.h b/include/zcl/zb_zcl_basic_cluster.h new file mode 100644 index 0000000..66ecee5 --- /dev/null +++ b/include/zcl/zb_zcl_basic_cluster.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_basic_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_MODULE Basic Cluster + * + * @brief Zigbee basic cluster commands + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/** + * @brief Sends 'reset factory default' command + * @details This function is aim to reset end-device as factory default settings. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] handle handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep target endpoint + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_write_attr_rsp() + */ +int zb_zcl_basic_reset_factory_default( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_BASIC_CLUSTER_H__ */ diff --git a/include/zcl/zb_zcl_cluster_ids.h b/include/zcl/zb_zcl_cluster_ids.h new file mode 100644 index 0000000..9d85bec --- /dev/null +++ b/include/zcl/zb_zcl_cluster_ids.h @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_CLUSTER_IDS_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_CLUSTER_IDS_H__ + +/** + * @file zb_zcl_cluster_ids.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_CLUSTER_ID_MODULE Cluster IDs + * + * @brief Zigbee Cluster IDs + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_CLUSTER_ID_MODULE_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_CLUSTER_ID_MODULE_OVERVIEW Overview + * Cluster domain specification levels: \n\n + * - General: zcl-1.0-07-5123-03 \n + * - HA: ha-1.2.1-05-3520-30 \n + * - Closures: zcl-1.0-07-5123-03 \n + * - HVAC: zcl-1.0-07-5123-03 \n + * - Lighting: zcl-1.0-07-5123-03 \n + * - Measurement & Sensing: zcl-1.0-07-5123-03 \n + * - Security & Safety: zcl-1.0-07-5123-03 \n + * - Home Automation: UNKNOWN \n + * - CBA: cba-1.0-05-3516-12 \n + * - SE: se-1.2-12-0517-08 \n + * - ZLL: zll-1.0-11-0037-10 \n + * - Telecom Applications: ta-1.0-07-5307-07 \n + * - Protocol Interfaces: ta-1.0-07-5307-07 \n + * - Telecommunication: ta-1.0-07-5307-07 \n + * - Financial: ta-1.0-07-5307-07 \n + * - Ember: UNKNOWN \n + * - HC: hc-1.0-07-5360-15 \n + * + * @{ + * + */ + +/** + * @brief Zigbee Cluster IDs for reference + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_BASIC_CLUSTER_ID = 0x0000, /**< Basic Cluster */ + ZB_ZCL_POWER_CONFIG_CLUSTER_ID = 0x0001, /**< Power Configuration Cluster */ + ZB_ZCL_DEVICE_TEMP_CLUSTER_ID = 0x0002, /**< Device Temperature Cluster */ + ZB_ZCL_IDENTIFY_CLUSTER_ID = 0x0003, /**< Identify Cluster */ + ZB_ZCL_GROUPS_CLUSTER_ID = 0x0004, /**< Group Cluster */ + ZB_ZCL_SCENES_CLUSTER_ID = 0x0005, /**< Scene Cluster */ + ZB_ZCL_ON_OFF_CLUSTER_ID = 0x0006, /**< On/Off Cluster */ + ZB_ZCL_ON_OFF_SWITCH_CONFIG_CLUSTER_ID = 0x0007, /**< On/Off Switch Cluster */ + ZB_ZCL_LEVEL_CONTROL_CLUSTER_ID = 0x0008, /**< Level Control Cluster */ + ZB_ZCL_ALARM_CLUSTER_ID = 0x0009, /**< Alarm Cluster */ + ZB_ZCL_TIME_CLUSTER_ID = 0x000A, /**< Time Cluster */ + ZB_ZCL_RSSI_LOCATION_CLUSTER_ID = 0x000B, /**< RSSI Location Cluster */ + ZB_ZCL_BINARY_INPUT_BASIC_CLUSTER_ID = 0x000F, /**< Binary Input Basic Cluster */ + ZB_ZCL_COMMISSIONING_CLUSTER_ID = 0x0015, /**< Commissioning Cluster */ + ZB_ZCL_PARTITION_CLUSTER_ID = 0x0016, /**< Partition Cluster */ + ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID = 0x0019, /**< OTA Bootload Cluster */ + ZB_ZCL_POWER_PROFILE_CLUSTER_ID = 0x001A, /**< Power Profile Cluster */ + ZB_ZCL_APPLIANCE_CONTROL_CLUSTER_ID = 0x001B, /**< Application Control Cluster */ + ZB_ZCL_POLL_CONTROL_CLUSTER_ID = 0x0020, /**< Poll Control Cluster */ + ZB_ZCL_SHADE_CONFIG_CLUSTER_ID = 0x0100, /**< Shade Config Cluster */ + ZB_ZCL_DOOR_LOCK_CLUSTER_ID = 0x0101, /**< Door Lock Cluster */ + ZB_ZCL_WINDOW_COVERING_CLUSTER_ID = 0x0102, /**< Window Covering Cluster */ + ZB_ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID = 0x0200, /**< Pump Configuration Cluster */ + ZB_ZCL_THERMOSTAT_CLUSTER_ID = 0x0201, /**< Thermostat Cluster */ + ZB_ZCL_FAN_CONTROL_CLUSTER_ID = 0x0202, /**< Fan Control Cluster */ + ZB_ZCL_DEHUMID_CONTROL_CLUSTER_ID = 0x0203, /**< Dehumid Control Cluster */ + ZB_ZCL_THERMOSTAT_UI_CONFIG_CLUSTER_ID = 0x0204, /**< Thermostat UI Cluster */ + ZB_ZCL_COLOR_CONTROL_CLUSTER_ID = 0x0300, /**< Color Control Cluster */ + ZB_ZCL_BALLAST_CONFIGURATION_CLUSTER_ID = 0x0301, /**< Ballast Configuration Cluster */ + ZB_ZCL_ILLUM_MEASUREMENT_CLUSTER_ID = 0x0400, /**< Illuminance Measurement Cluster */ + ZB_ZCL_ILLUM_LEVEL_SENSING_CLUSTER_ID = 0x0401, /**< Illuminance Level Sensing Cluster */ + ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID = 0x0402, /**< Temperature Measurement Cluster */ + ZB_ZCL_PRESSURE_MEASUREMENT_CLUSTER_ID = 0x0403, /**< Pressure Measurement Cluster */ + ZB_ZCL_FLOW_MEASUREMENT_CLUSTER_ID = 0x0404, /**< Flow Measurement Cluster */ + ZB_ZCL_RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER_ID = 0x0405, /**< Relative Humidity Measurement Cluster */ + ZB_ZCL_OCCUPANCY_SENSING_CLUSTER_ID = 0x0406, /**< Occupancy Sensing Cluster */ + ZB_ZCL_IAS_ZONE_CLUSTER_ID = 0x0500, /**< IAS Zone Cluster */ + ZB_ZCL_IAS_ACE_CLUSTER_ID = 0x0501, /**< IAS Ace Cluster */ + ZB_ZCL_IAS_WD_CLUSTER_ID = 0x0502, /**< IAS WD Cluster */ + ZB_ZCL_GENERIC_TUNNEL_CLUSTER_ID = 0x0600, /**< Generic Tunnel Cluster */ + ZB_ZCL_BACNET_PROTOCOL_TUNNEL_CLUSTER_ID = 0x0601, /**< Bacnet Protocol Tunnel Cluster */ + ZB_ZCL_11073_PROTOCOL_TUNNEL_CLUSTER_ID = 0x0614, /**< 11073 Protocol Tunnel Cluster */ + ZB_ZCL_ISO7816_PROTOCOL_TUNNEL_CLUSTER_ID = 0x0615, /**< ISO7816 Protocol Tunnel Cluster */ + ZB_ZCL_PRICE_CLUSTER_ID = 0x0700, /**< Price Cluster */ + ZB_ZCL_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_ID = 0x0701, /**< Demand Response Load Control Cluster */ + ZB_ZCL_SIMPLE_METERING_CLUSTER_ID = 0x0702, /**< Simple Metering Cluster */ + ZB_ZCL_MESSAGING_CLUSTER_ID = 0x0703, /**< Messaging Cluster */ + ZB_ZCL_TUNNELING_CLUSTER_ID = 0x0704, /**< Tunneling Cluster */ + ZB_ZCL_PREPAYMENT_CLUSTER_ID = 0x0705, /**< Prepayment Cluster */ + ZB_ZCL_ENERGY_MANAGEMENT_CLUSTER_ID = 0x0706, /**< Energy Management Cluster */ + ZB_ZCL_TOU_CALENDAR_CLUSTER_ID = 0x0707, /**< Calendar Cluster */ + ZB_ZCL_DEVICE_MANAGEMENT_CLUSTER_ID = 0x0708, /**< Device Management Cluster */ + ZB_ZCL_EVENTS_CLUSTER_ID = 0x0709, /**< Events Cluster */ + ZB_ZCL_MDU_PAIRING_CLUSTER_ID = 0x070A, /**< MDU Paring Cluster */ + ZB_ZCL_KEY_ESTABLISHMENT_CLUSTER_ID = 0x0800, /**< Key Establishment Cluster */ + ZB_ZCL_INFORMATION_CLUSTER_ID = 0x0900, /**< Information Cluster */ + ZB_ZCL_DATA_SHARING_CLUSTER_ID = 0x0901, /**< Data Sharing Cluster */ + ZB_ZCL_GAMING_CLUSTER_ID = 0x0902, /**< Gaming Cluster */ + ZB_ZCL_DATA_RATE_CONTROL_CLUSTER_ID = 0x0903, /**< Data Rate Control Cluster */ + ZB_ZCL_VOICE_OVER_ZIGBEE_CLUSTER_ID = 0x0904, /**< Voice Over Zigbee Cluster */ + ZB_ZCL_CHATTING_CLUSTER_ID = 0x0905, /**< Chatting Cluster */ + ZB_ZCL_PAYMENT_CLUSTER_ID = 0x0A01, /**< Payment Cluster */ + ZB_ZCL_BILLING_CLUSTER_ID = 0x0A02, /**< Billing Cluster */ + ZB_ZCL_APPLIANCE_IDENTIFICATION_CLUSTER_ID = 0x0B00, /**< Appliance Identification Cluster */ + ZB_ZCL_METER_IDENTIFICATION_CLUSTER_ID = 0x0B01, /**< Meter Identification Cluster */ + ZB_ZCL_APPLIANCE_EVENTS_AND_ALERT_CLUSTER_ID = 0x0B02, /**< Appliance Events and Alert Cluster */ + ZB_ZCL_APPLIANCE_STATISTICS_CLUSTER_ID = 0x0B03, /**< Appliance Statistics Cluster */ + ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID = 0x0B04, /**< Electrical Measurement Cluster */ + ZB_ZCL_DIAGNOSTICS_CLUSTER_ID = 0x0B05, /**< Diagnostics Cluster */ + ZB_ZCL_ZLL_COMMISSIONING_CLUSTER_ID = 0x1000, /**< ZLL Commissioning Cluster */ +} zb_zcl_cluster_ids_e; + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_CLUSTER_IDS_H__ */ diff --git a/include/zcl/zb_zcl_color_control_cluster.h b/include/zcl/zb_zcl_color_control_cluster.h new file mode 100644 index 0000000..c330541 --- /dev/null +++ b/include/zcl/zb_zcl_color_control_cluster.h @@ -0,0 +1,503 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_H__ + +#include + +/** + * @file zb_zcl_color_control_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_MODULE Color Control Cluster + * + * @brief Zigbee color control cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/* Table 5.9 Command IDs for the Color Control Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Move to Hue | O | + * | 0x01 | Move Hue | O | + * | 0x02 | Step Hue | O | + * | 0x03 | Move to Saturation | O | + * | 0x04 | Move Saturation | O | + * | 0x05 | Step Saturation | O | + * | 0x06 | Move to Hue and Saturation | O | + * | 0x07 | Move to Color | M | + * | 0x08 | Move Color | M | + * | 0x09 | Step Color | M | + * | 0x0a | Move to Color Temperature | O | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Sends 'move to hue' command + * @details On receipt of this command, a device shall also set the ColorMode attribute to the + * value 0x00 and then shall move from its current hue to the value given in the Hue + * field. \n\n + * The movement shall be continuous, i.e. not a step function, and the time taken to + * move to the new hue shall be equal to the Transition time field.\n\n + * As hue is effectively measured on a circle, the new hue may be moved to in either + * direction. The direction of hue change is given by the Direction field. If Direction + * is 'Shortest distance', the direction is taken that involves the shortest path round + * the circle. This case corresponds to expected normal usage. If Direction is + * 'Longest distance', the direction is taken that involves the longest path round the + * circle. This case can be used for 'rainbow effects'. In both cases, if both distances + * are the same, the Up direction shall be taken.\n\n + * Note that if the target color specified is not achievable by the hardware then the + * command shall not be carried out, and a ZCL default response command shall be + * generated, where not disabled, with status code equal to INVALID_VALUE.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] hue The Hue field specifies the hue to be moved to. + * @param[in] direction The direction field shall be one of the non-reserved values\n + * 0x00 : Shortest distance\n + * 0x01 : Longest distance\n + * 0x02 : Up\n + * 0x03 : Down\n + * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, + * the time that shall be taken to move to the new hue + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_move_to_hue( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char hue, + unsigned char direction, + unsigned short transition_time); + +/** + * @brief Sends 'move hue' command + * @details On receipt of this command, a device shall set the ColorMode attribute to the + * value 0x00 and shall then move from its current hue in an up or down direction in + * a continuous fashion. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] move_mode The Move mode field shall be one of the non-reserved values.\n + * 0x00 : Stop\n + * 0x01 : Up\n + * 0x02 : Reserved\n + * 0x03 : Down\n + * @param[in] rate The Rate field specifies the rate of movement in steps per second.\n + * A step is a change in the device's hue of one unit. + * If the Rate field has a value of zero, the command has no effect and + * a default response command is sent in response, with the status code + * set to INVALID_FIELD.\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_move_hue( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char move_mode, + unsigned char rate); + +/** + * @brief Sends 'step hue' command + * @details On receipt of this command, a device shall set the ColorMode attribute to the + * value 0x00 and shall then move from its current hue in an up or down direction by + * one step. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] step_mode The Step mode field shall be one of the non-reserved values.\n + * 0x00 : Reserved\n + * 0x01 : Up\n + * 0x02 : Reserved\n + * 0x03 : Down\n + * @param[in] step_size The change to be added to (or subtracted from) the current value \n + * of the device's hue. + * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, + * the time that shall be taken to perform the step. + * A step is a change in the device's hue of 'Step size' units. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_step_hue( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char step_mode, + unsigned char step_size, + unsigned char transition_time); + +/** + * @brief Sends 'move to saturation' command + * @details On receipt of this command, a device set the ColorMode attribute to the value + * 0x00 and shall then move from its current saturation to the value given in the + * Saturation field.\n\n + * The movement shall be continuous, i.e. not a step function, and the time taken to + * move to the new saturation shall be equal to the Transition time field, in 1/10ths of + * a second.n\n + * Note that if the target color specified is not achievable by the hardware then the + * command shall not be carried out and a ZCL default response command shall be + * generated, where not disabled, with status code equal to INVALID_VALUE. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] saturation The target saturation value + * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, + * the time that shall be taken to perform the step. + * A step is a change in the device's hue of 'Step size' units. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_move_to_saturation( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char saturation, + unsigned short transition_time); + +/** + * @brief Sends 'move saturation' command + * @details On receipt of this command, a device shall set the ColorMode attribute to the + * value 0x00 and shall then move from its current saturation in an up or down + * direction in a continuous fashion.\n]n + * Note that if the target color specified is not achievable by the hardware then the + * command shall not be carried out and a ZCL default response command shall be + * generated, where not disabled, with status code equal to INVALID_VALUE + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] move_mode The Move mode field shall be one of the non-reserved values.\n + * 0x00 : Stop\n + * 0x01 : Up\n + * 0x02 : Reserved\n + * 0x03 : Down\n + * @param[in] rate The Rate field specifies the rate of movement in steps per second.\n + * A step is a change in the device's hue of one unit. + * If the Rate field has a value of zero, the command has no effect and + * a default response command is sent in response, with the status code + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_move_saturation( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char move_mode, + unsigned char rate); + +/** + * @brief Sends 'step saturation' command + * @details On receipt of this command, a device shall set the ColorMode attribute to the + * value 0x00 and shall then move from its current saturation in an up or down + * direction in a continuous fashion.\n]n + * Note that if the target color specified is not achievable by the hardware then the + * command shall not be carried out and a ZCL default response command shall be + * generated, where not disabled, with status code equal to INVALID_VALUE + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] step_mode The Step mode field shall be one of the non-reserved values.\n + * 0x00 : Reserved\n + * 0x01 : Up\n + * 0x02 : Reserved\n + * 0x03 : Down\n + * @param[in] step_size The change to be added to (or subtracted from) the current value \n + * of the device's hue. + * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, + * the time that shall be taken to perform the step. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_step_saturation( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char step_mode, + unsigned char step_size, + unsigned char transition_time); + +/** + * @brief Sends 'move to hue and saturation' command + * @details On receipt of this command, a device shall set the ColorMode attribute to the + * value 0x00 and shall then move from its current hue and saturation to the values + * given in the Hue and Saturation fields.\n\n + * The movement shall be continuous, i.e. not a step function, and the time taken to + * move to the new color shall be equal to the Transition time field, in 1/10ths of a + * second.\n\n + * The path through color space taken during the transition is not specified, but it is + * recommended that the shortest path is taken though hue/saturation space, i.e. + * movement is 'in a straight line' across the hue/saturation disk.\n\n + * Note that if the target color specified is not achievable by the hardware then the + * command shall not be carried out and a ZCL default response command shall be + * generated, where not disabled, with status code equal to INVALID_VALUE + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] hue The Hue field specifies the hue to be moved to. + * @param[in] saturation The target saturation value + * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, + * the time that shall be taken to perform the step. + * A step is a change in the device's hue of 'Step size' units. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_move_to_hue_and_saturation( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char hue, + unsigned char saturation, + unsigned short transition_time); + +/** + * @brief Sends 'move to color' command + * @details On receipt of this command, a device shall set the value of the ColorMode + * attribute, where implemented, to 0x01, and shall then move from its current color + * to the color given in the ColorX and ColorY fields.\n\n + * The movement shall be continuous, i.e. not a step function, and the time taken to + * move to the new color shall be equal to the Transition time field, in 1/10ths of a + * second.\n\n + * The path through color space taken during the transition is not specified, but it is + * recommended that the shortest path is taken though color space, i.e. movement is + * 'in a straight line' across the CIE xyY Color Space.\n\n + * Note that if the target color specified is not achievable by the hardware then the + * command shall not be carried out, and a ZCL default response command shall be + * generated, where not disabled, with status code equal to INVALID_VALUE\n\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] color_x Target color position x + * @param[in] color_y Target color position y + * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, + * the time that shall be taken to perform the step. + * A step is a change in the device's hue of 'Step size' units. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_move_to_color( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short color_x, + unsigned short color_y, + unsigned short transition_time); + +/** + * @brief Sends 'move color' commmand + * @details On receipt of this command, a device shall set the value of the ColorMode + * attribute, where implemented, to 0x01, and shall then move from its current color + * in a continuous fashion according to the rates specified. This movement shall + * continue until the target color for the next step cannot be implemented on this + * device.\n\n + * If both the RateX and RateY fields contain a value of zero, no movement shall be + * carried out, and the command execution shall have no effect other than stopping + * the operation of any previously received command of this cluster. This command + * can thus be used to stop the operation of any other command of this cluster. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] rate_x The RateX field specifies the rate of movement in steps per second. + * A step is a change in the device's CurrentX attribute of one unit. + * @param[in] rate_y The RateY field specifies the rate of movement in steps per second. + * A step is a change in the device's CurrentY attribute of one unit. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_move_color( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short rate_x, + unsigned short rate_y); + +/** + * @brief Sends 'step color' command + * @details On receipt of this command, a device shall set the value of the ColorMode + * attribute, where implemented, to 0x01, and shall then move from its current color + * by the color step indicated.\n\n + * The movement shall be continuous, i.e. not a step function, and the time taken to + * move to the new color shall be equal to the Transition time field, in 1/10ths of a + * second.\n\n + * The path through color space taken during the transition is not specified, but it is + * recommended that the shortest path is taken though color space, i.e. movement is + * 'in a straight line' across the CIE xyY Color Space.\n\n + * Note that if the target color specified is not achievable by this hardware then + * command shall not be carried out, and a ZCL default response command shall be + * generated, where not disabled, with status code equal to INVALID_VALUE\n\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] step_x The StepX and StepY fields specify the change to be added to the device's + * CurrentX attribute and CurrentY attribute respectively. + * @param[in] step_y The StepX and StepY fields specify the change to be added to the device's + * CurrentX attribute and CurrentY attribute respectively. + * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, + * the time that shall be taken to perform the step. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_step_color( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short step_x, + unsigned short step_y, + unsigned short transition_time); + +/** + * @brief Sends 'move to color temperature' command + * @details On receipt of this command, a device shall set the value of the ColorMode + * attribute, where implemented, to 0x02, and shall then move from its current color + * to the color given by the Color Temperature field.\n\n + * The movement shall be continuous, i.e. not a step function, and the time taken to + * move to the new color shall be equal to the Transition time field, in 1/10ths of a + * second.\n\n + * By definition of this color mode, the path through color space taken during the + * transition is along the 'Black Body Line'.\n\n + * Note that if the target color specified is not achievable by the hardware then the + * command shall not be carried out, and a ZCL default response command shall be + * generated, where not disabled, with status code equal to INVALID_VALUE.\n\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] color_temperature The target color temperature value + * @param[in] transition_time The Transition time field specifies, in 1/10ths of a second, + * the time that shall be taken to perform the step. + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_ccontrol_move_to_color_temperature( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short color_temperature, + unsigned short transition_time); + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_COLOR_CONTROL_CLUSTER_H__ */ diff --git a/include/zcl/zb_zcl_commands.h b/include/zcl/zb_zcl_commands.h new file mode 100644 index 0000000..0b2dcf7 --- /dev/null +++ b/include/zcl/zb_zcl_commands.h @@ -0,0 +1,737 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_COMMAND_IDS_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_COMMAND_IDS_H__ + +/** + * @file zb_zcl_color_control_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE Cluster Commands + * + * @brief Zigbee color control cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/** + * @brief Global commands (Either direction) + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_READ_ATTRIBUTES_COMMAND_ID = 0x00, /**< Read attributes */ + ZB_ZCL_READ_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x01, /**< Read attributes response */ + ZB_ZCL_WRITE_ATTRIBUTES_COMMAND_ID = 0x02, /**< Write attributes */ + ZB_ZCL_WRITE_ATTRIBUTES_UNDIVIDED_COMMAND_ID = 0x03, /**< Write attributes undivided */ + ZB_ZCL_WRITE_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x04, /**< Write attributes response */ + ZB_ZCL_WRITE_ATTRIBUTES_NO_RESPONSE_COMMAND_ID = 0x05, /**< Write attributes no response */ + ZB_ZCL_CONFIGURE_REPORTING_COMMAND_ID = 0x06, /**< Configure reporting */ + ZB_ZCL_CONFIGURE_REPORTING_RESPONSE_COMMAND_ID = 0x07, /**< Configure reporting response */ + ZB_ZCL_READ_REPORTING_CONFIGURATION_COMMAND_ID = 0x08, /**< Read reporting configuration */ + ZB_ZCL_READ_REPORTING_CONFIGURATION_RESPONSE_COMMAND_ID = 0x09, /**< Read reporting configuration response */ + ZB_ZCL_REPORT_ATTRIBUTES_COMMAND_ID = 0x0A, /**< Report attributes */ + ZB_ZCL_DEFAULT_RESPONSE_COMMAND_ID = 0x0B, /**< Default response */ + ZB_ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID = 0x0C, /**< Discover attributes */ + ZB_ZCL_DISCOVER_ATTRIBUTES_RESPONSE_COMMAND_ID = 0x0D, /**< Discover attributes response */ + ZB_ZCL_READ_ATTRIBUTES_STRUCTURED_COMMAND_ID = 0x0E, /**< Read attributes structured */ + ZB_ZCL_WRITE_ATTRIBUTES_STRUCTURED_COMMAND_ID = 0x0F, /**< Write attributes structured */ + ZB_ZCL_WRITE_ATTRIBUTES_STRUCTURED_RESPONSE_COMMAND_ID = 0x10, /**< Write attributes structured response */ + ZB_ZCL_DISCOVER_COMMANDS_RECEIVED_COMMAND_ID = 0x11, /**< Discover commands received */ + ZB_ZCL_DISCOVER_COMMANDS_RECEIVED_RESPONSE_COMMAND_ID = 0x12, /**< Discover commands received */ + ZB_ZCL_DISCOVER_COMMANDS_GENERATED_COMMAND_ID = 0x13, /**< Discover commands generated */ + ZB_ZCL_DISCOVER_COMMANDS_GENERATED_RESPONSE_COMMAND_ID = 0x14, /**< Discover commands generated response */ + ZB_ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID = 0x15, /**< Discover attributes exteneded */ + ZB_ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID = 0x16, /**< Discover attributes extended response */ +} zb_zcl_global_commands_e; + +/** + * @brief Command types for cluster: Basic + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID = 0x00, /**< Reset to factory default mode */ +} zb_zcl_basic_client_commands_e; + +/** + * @brief Command types for cluster: Identify + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID = 0x00, /**< Identify query response */ +} zb_zcl_identify_server_commands_e; + +/** + * @brief Command types for cluster: Identify + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_IDENTIFY_COMMAND_ID = 0x00, /**< Identify */ + ZB_ZCL_IDENTIFY_QUERY_COMMAND_ID = 0x01, /**< Identify query */ + ZB_ZCL_E_Z_MODE_INVOKE_COMMAND_ID = 0x02, /**< EZ mode invoke */ + ZB_ZCL_UPDATE_COMMISSION_STATE_COMMAND_ID = 0x03, /**< Update commission state */ + ZB_ZCL_TRIGGER_EFFECT_COMMAND_ID = 0x40, /**< (since zll-1.0-11-0037-10) */ +} zb_zcl_identify_client_commands_e; + +/** + * @brief Command types for cluster: Groups + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ADD_GROUP_RESPONSE_COMMAND_ID = 0x00, /**< Add group response */ + ZB_ZCL_VIEW_GROUP_RESPONSE_COMMAND_ID = 0x01, /**< View group response */ + ZB_ZCL_GET_GROUP_MEMBERSHIP_RESPONSE_COMMAND_ID = 0x02, /**< Get group membership response */ + ZB_ZCL_REMOVE_GROUP_RESPONSE_COMMAND_ID = 0x03, /**< Remove group response */ +} zb_zcl_group_server_commands_e; + +/** + * @brief Command types for cluster: Groups + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ADD_GROUP_COMMAND_ID = 0x00, /**< Add group */ + ZB_ZCL_VIEW_GROUP_COMMAND_ID = 0x01, /**< View group */ + ZB_ZCL_GET_GROUP_MEMBERSHIP_COMMAND_ID = 0x02, /**< Get group membership */ + ZB_ZCL_REMOVE_GROUP_COMMAND_ID = 0x03, /**< Remove group */ + ZB_ZCL_REMOVE_ALL_GROUPS_COMMAND_ID = 0x04, /**< Remove all groups */ + ZB_ZCL_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID = 0x05, /**< Add group if identifying */ +} zb_zcl_group_client_commands_e; + +/** + * @brief Command types for cluster: Scenes + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ADD_SCENE_RESPONSE_COMMAND_ID = 0x00, /**< Add scene response */ + ZB_ZCL_VIEW_SCENE_RESPONSE_COMMAND_ID = 0x01, /**< View scene response */ + ZB_ZCL_REMOVE_SCENE_RESPONSE_COMMAND_ID = 0x02, /**< Remove scene response */ + ZB_ZCL_REMOVE_ALL_SCENES_RESPONSE_COMMAND_ID = 0x03, /**< Remove all scenes response */ + ZB_ZCL_STORE_SCENE_RESPONSE_COMMAND_ID = 0x04, /**< Store scenes response */ + ZB_ZCL_GET_SCENE_MEMBERSHIP_RESPONSE_COMMAND_ID = 0x06, /**< Get scene membership response */ + ZB_ZCL_ENHANCED_ADD_SCENE_RESPONSE_COMMAND_ID = 0x40, /**< Enhanced add scene response (since zll-1.0-11-0037-10) */ + ZB_ZCL_ENHANCED_VIEW_SCENE_RESPONSE_COMMAND_ID = 0x41, /**< Enhanced view scene response (since zll-1.0-11-0037-10) */ + ZB_ZCL_COPY_SCENE_RESPONSE_COMMAND_ID = 0x42, /**< Copy scene response (since zll-1.0-11-0037-10) */ +} zb_zcl_scenes_server_commands_e; + +/** + * @brief Command types for cluster: Scenes + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ADD_SCENE_COMMAND_ID = 0x00, /**< Add scene */ + ZB_ZCL_VIEW_SCENE_COMMAND_ID = 0x01, /**< View scenen */ + ZB_ZCL_REMOVE_SCENE_COMMAND_ID = 0x02, /**< Remove scnene */ + ZB_ZCL_REMOVE_ALL_SCENES_COMMAND_ID = 0x03, /**< Remove all scenens */ + ZB_ZCL_STORE_SCENE_COMMAND_ID = 0x04, /**< Store scene */ + ZB_ZCL_RECALL_SCENE_COMMAND_ID = 0x05, /**< Recall scene */ + ZB_ZCL_GET_SCENE_MEMBERSHIP_COMMAND_ID = 0x06, /**< Get scene membership */ + ZB_ZCL_ENHANCED_ADD_SCENE_COMMAND_ID = 0x40, /**< Enhanced add scene (since zll-1.0-11-0037-10) */ + ZB_ZCL_ENHANCED_VIEW_SCENE_COMMAND_ID = 0x41, /**< Enhanced view scene (since zll-1.0-11-0037-10) */ + ZB_ZCL_COPY_SCENE_COMMAND_ID = 0x42, /**< Copy scene (since zll-1.0-11-0037-10) */ +} zb_zcl_scenes_client_commands_e; + +/** + * @brief Command types for cluster: On/off + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_OFF_COMMAND_ID = 0x00, /**< Off */ + ZB_ZCL_ON_COMMAND_ID = 0x01, /**< On */ + ZB_ZCL_TOGGLE_COMMAND_ID = 0x02, /**< Toggle */ + ZB_ZCL_OFF_WITH_EFFECT_COMMAND_ID = 0x40, /**< Off with effect (since zll-1.0-11-0037-10) */ + ZB_ZCL_ON_WITH_RECALL_GLOBAL_SCENE_COMMAND_ID = 0x41, /**< On with recall golbal scene (since zll-1.0-11-0037-10) */ + ZB_ZCL_ON_WITH_TIMED_OFF_COMMAND_ID = 0x42, /**< on with timed off (since zll-1.0-11-0037-10) */ +} zb_zcl_on_off_client_commands_e; + +/** + * @brief Command types for cluster: Level Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_MOVE_TO_LEVEL_COMMAND_ID = 0x00, /**< Move to level */ + ZB_ZCL_MOVE_COMMAND_ID = 0x01, /**< Move */ + ZB_ZCL_STEP_COMMAND_ID = 0x02, /**< Step */ + ZB_ZCL_STOP_COMMAND_ID = 0x03, /**< Stop */ + ZB_ZCL_MOVE_TO_LEVEL_WITH_ON_OFF_COMMAND_ID = 0x04, /**< Move to level with on/off */ + ZB_ZCL_MOVE_WITH_ON_OFF_COMMAND_ID = 0x05, /**< Move with on/off */ + ZB_ZCL_STEP_WITH_ON_OFF_COMMAND_ID = 0x06, /**< Step with on/off */ + ZB_ZCL_STOP_WITH_ON_OFF_COMMAND_ID = 0x07, /**< Stop with on/off */ +} zb_zcl_level_control_client_commands_e; + +/** + * @brief Command types for cluster: Alarms + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ALARM_COMMAND_ID = 0x00, /**< Alarm */ + ZB_ZCL_GET_ALARM_RESPONSE_COMMAND_ID = 0x01, /**< Alarm reponse */ +} zb_zcl_alarms_server_commands_e; + +/** + * @brief Command types for cluster: Alarms + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_RESET_ALARM_COMMAND_ID = 0x00, /**< Reset alarm */ + ZB_ZCL_RESET_ALL_ALARMS_COMMAND_ID = 0x01, /**< Reset all alarms */ + ZB_ZCL_GET_ALARM_COMMAND_ID = 0x02, /**< Get alarm */ + ZB_ZCL_RESET_ALARM_LOG_COMMAND_ID = 0x03, /**< Reset alarm log */ +} zb_zcl_alarms_client_commands_e; + +/** + * @brief Command types for cluster: RSSI Location + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_DEVICE_CONFIGURATION_RESPONSE_COMMAND_ID = 0x00, /**< Device configuration response */ + ZB_ZCL_LOCATION_DATA_RESPONSE_COMMAND_ID = 0x01, /**< Location data response */ + ZB_ZCL_LOCATION_DATA_NOTIFICATION_COMMAND_ID = 0x02, /**< Location data notification */ + ZB_ZCL_COMPACT_LOCATION_DATA_NOTIFICATION_COMMAND_ID = 0x03, /**< Compact location data notification */ + ZB_ZCL_RSSI_PING_COMMAND_ID = 0x04, /**< RSSI ping */ + ZB_ZCL_RSSI_REQUEST_COMMAND_ID = 0x05, /**< RSSI request */ + ZB_ZCL_REPORT_RSSI_MEASUREMENTS_COMMAND_ID = 0x06, /**< Report RSSI measurements */ + ZB_ZCL_REQUEST_OWN_LOCATION_COMMAND_ID = 0x07, /**< Request own location */ +} zb_zcl_rssi_location_server_commands_e; + +/** + * @brief Command types for cluster: RSSI Location + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SET_ABSOLUTE_LOCATION_COMMAND_ID = 0x00, /**< Set absolute location */ + ZB_ZCL_SET_DEVICE_CONFIGURATION_COMMAND_ID = 0x01, /**< Set device configuration */ + ZB_ZCL_GET_DEVICE_CONFIGURATION_COMMAND_ID = 0x02, /**< Get device configuration */ + ZB_ZCL_GET_LOCATION_DATA_COMMAND_ID = 0x03, /**< Get location data */ + ZB_ZCL_RSSI_RESPONSE_COMMAND_ID = 0x04, /**< RSSI response */ + ZB_ZCL_SEND_PINGS_COMMAND_ID = 0x05, /**< Send ping */ + ZB_ZCL_ANCHOR_NODE_ANNOUNCE_COMMAND_ID = 0x06, /**< Anchor node announce */ +} zb_zcl_rssi_location_client_commands_e; + +/** + * @brief Command types for cluster: Commissioning + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_RESTART_DEVICE_RESPONSE_COMMAND_ID = 0x00, /**< Restart device response */ + ZB_ZCL_SAVE_STARTUP_PARAMETERS_RESPONSE_COMMAND_ID = 0x01, /**< Svae startup parameters response */ + ZB_ZCL_RESTORE_STARTUP_PARAMETERS_RESPONSE_COMMAND_ID = 0x02, /**< Restrore startup parameters response */ + ZB_ZCL_RESET_STARTUP_PARAMETERS_RESPONSE_COMMAND_ID = 0x03, /**< Reset startup parameters resonse */ +} zb_zcl_commissioning_server_commands_e; + +/** + * @brief Command types for cluster: Commissioning + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_RESTART_DEVICE_COMMAND_ID = 0x00, /**< Restart device */ + ZB_ZCL_SAVE_STARTUP_PARAMETERS_COMMAND_ID = 0x01, /**< Save startup parameters */ + ZB_ZCL_RESTORE_STARTUP_PARAMETERS_COMMAND_ID = 0x02, /**< Restore startup parameters */ + ZB_ZCL_RESET_STARTUP_PARAMETERS_COMMAND_ID = 0x03, /**< Reset startup parameters */ +} zb_zcl_commissioning_client_commands_e; + +/** + * @brief Command types for cluster: Partition + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_MULTIPLE_ACK_COMMAND_ID = 0x00, /**< Multiple ack */ + ZB_ZCL_READ_HANDSHAKE_PARAM_RESPONSE_COMMAND_ID = 0x01, /**< Read handshake parameters response */ +} zb_zcl_partition_server_commands_e; + +/** + * @brief Command types for cluster: Partition + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_TRANSFER_PARTITIONED_FRAME_COMMAND_ID = 0x00, /**< Transfer partitioned frame */ + ZB_ZCL_READ_HANDSHAKE_PARAM_COMMAND_ID = 0x01, /**< Read handshake parameters */ + ZB_ZCL_WRITE_HANDSHAKE_PARAM_COMMAND_ID = 0x02, /**< Write handshake parameters */ +} zb_zcl_partition_client_commands_e; + +/** + * @brief Command types for cluster: Over the Air Bootloading + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_IMAGE_NOTIFY_COMMAND_ID = 0x00, /**< Image notify */ + ZB_ZCL_QUERY_NEXT_IMAGE_RESPONSE_COMMAND_ID = 0x02, /**< Query next image response */ + ZB_ZCL_IMAGE_BLOCK_RESPONSE_COMMAND_ID = 0x05, /**< Image block response */ + ZB_ZCL_UPGRADE_END_RESPONSE_COMMAND_ID = 0x07, /**< Upgrade end response */ + ZB_ZCL_QUERY_SPECIFIC_FILE_RESPONSE_COMMAND_ID = 0x09, /**< Query specific file response */ +} zb_zcl_over_the_air_bootloading_server_commands_e; + +/** + * @brief Command types for cluster: Over the Air Bootloading + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_QUERY_NEXT_IMAGE_REQUEST_COMMAND_ID = 0x01, /**< Query next image request */ + ZB_ZCL_IMAGE_BLOCK_REQUEST_COMMAND_ID = 0x03, /**< Image block request */ + ZB_ZCL_IMAGE_PAGE_REQUEST_COMMAND_ID = 0x04, /**< Image page request */ + ZB_ZCL_UPGRADE_END_REQUEST_COMMAND_ID = 0x06, /**< Upgrade end request */ + ZB_ZCL_QUERY_SPECIFIC_FILE_REQUEST_COMMAND_ID = 0x08, /**< Query specific file request */ +} zb_zcl_over_the_air_bootloading_client_commands_e; + +/** + * @brief Command types for cluster: Power Profile + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_POWER_PROFILE_NOTIFICATION_COMMAND_ID = 0x00, /**< Power profile notification */ + ZB_ZCL_POWER_PROFILE_RESPONSE_COMMAND_ID = 0x01, /**< Power profile response */ + ZB_ZCL_POWER_PROFILE_STATE_RESPONSE_COMMAND_ID = 0x02, /**< Power profile state response */ + ZB_ZCL_GET_POWER_PROFILE_PRICE_COMMAND_ID = 0x03, /**< Get power profile price */ + ZB_ZCL_POWER_PROFILES_STATE_NOTIFICATION_COMMAND_ID = 0x04, /**< Power profiles state notification */ + ZB_ZCL_GET_OVERALL_SCHEDULE_PRICE_COMMAND_ID = 0x05, /**< Get overall schedule price */ + ZB_ZCL_ENERGY_PHASES_SCHEDULE_REQUEST_COMMAND_ID = 0x06, /**< Energy phases schedule request */ + ZB_ZCL_ENERGY_PHASES_SCHEDULE_STATE_RESPONSE_COMMAND_ID = 0x07, /**< Energy phrase schedule state response */ + ZB_ZCL_ENERGY_PHASES_SCHEDULE_STATE_NOTIFICATION_COMMAND_ID = 0x08, /**< Energy phrase schedule state notification */ + ZB_ZCL_POWER_PROFILE_SCHEDULE_CONSTRAINTS_NOTIFICATION_COMMAND_ID = 0x09, /**< Power profile schedule constraints notification */ + ZB_ZCL_POWER_PROFILE_SCHEDULE_CONSTRAINTS_RESPONSE_COMMAND_ID = 0x0A, /**< Power profile schedule constraints response */ + ZB_ZCL_GET_POWER_PROFILE_PRICE_EXTENDED_COMMAND_ID = 0x0B, /**< Get power profile price extended */ +} zb_zcl_power_profile_server_commands_e; + +/** + * @brief Command types for cluster: Power Profile + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_POWER_PROFILE_REQUEST_COMMAND_ID = 0x00, /**< Power profile request */ + ZB_ZCL_POWER_PROFILE_STATE_REQUEST_COMMAND_ID = 0x01, /**< Power profile state request */ + ZB_ZCL_GET_POWER_PROFILE_PRICE_RESPONSE_COMMAND_ID = 0x02, /**< Get power profile price response */ + ZB_ZCL_GET_OVERALL_SCHEDULE_PRICE_RESPONSE_COMMAND_ID = 0x03, /**< Get overall schedule price response */ + ZB_ZCL_ENERGY_PHASES_SCHEDULE_NOTIFICATION_COMMAND_ID = 0x04, /**< Energy phrases schedules notificatoin */ + ZB_ZCL_ENERGY_PHASES_SCHEDULE_RESPONSE_COMMAND_ID = 0x05, /**< Energy phrases schedules response */ + ZB_ZCL_POWER_PROFILE_SCHEDULE_CONSTRAINTS_REQUEST_COMMAND_ID = 0x06, /**< Power profile schedule constraints request */ + ZB_ZCL_ENERGY_PHASES_SCHEDULE_STATE_REQUEST_COMMAND_ID = 0x07, /**< Energy phrases schedules state request */ + ZB_ZCL_GET_POWER_PROFILE_PRICE_EXTENDED_RESPONSE_COMMAND_ID = 0x08, /**< Get power profile price extended response */ +} zb_zcl_power_profile_client_commands_e; + +/** + * @brief Command types for cluster: Appliance Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SIGNAL_STATE_RESPONSE_COMMAND_ID = 0x00, /**< Signal state response */ + ZB_ZCL_SIGNAL_STATE_NOTIFICATION_COMMAND_ID = 0x01, /**< Signal state notification */ +} zb_zcl_appliance_control_server_commands_e; + +/** + * @brief Command types for cluster: Appliance Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_EXECUTION_OF_A_COMMAND_COMMAND_ID = 0x00, /**< Execution of a command */ + ZB_ZCL_SIGNAL_STATE_COMMAND_ID = 0x01, /**< Signal state */ + ZB_ZCL_WRITE_FUNCTIONS_COMMAND_ID = 0x02, /**< Write functions */ + ZB_ZCL_OVERLOAD_PAUSE_RESUME_COMMAND_ID = 0x03, /**< Overload pause/resume */ + ZB_ZCL_OVERLOAD_PAUSE_COMMAND_ID = 0x04, /**< Overload pause */ + ZB_ZCL_OVERLOAD_WARNING_COMMAND_ID = 0x05, /**< Overload warning */ +} zb_zcl_appliance_control_client_commands_e; + +/** + * @brief Command types for cluster: Poll Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_CHECK_IN_COMMAND_ID = 0x00, /**< Check-in */ +} zb_zcl_poll_control_server_commands_e; + +/** + * @brief Command types for cluster: Poll Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_CHECK_IN_RESPONSE_COMMAND_ID = 0x00, /**< Chec-in response */ + ZB_ZCL_FAST_POLL_STOP_COMMAND_ID = 0x01, /**< Fast poll stop */ + ZB_ZCL_SET_LONG_POLL_INTERVAL_COMMAND_ID = 0x02, /**< Set long poll interval */ + ZB_ZCL_SET_SHORT_POLL_INTERVAL_COMMAND_ID = 0x03, /**< Set short poll interval */ +} zb_zcl_poll_control_client_commands_e; + +/** + * @brief Command types for cluster: Door Lock + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID = 0x00, /**< Lock door response */ + ZB_ZCL_UNLOCK_DOOR_RESPONSE_COMMAND_ID = 0x01, /**< Unlock door response */ + ZB_ZCL_TOGGLE_RESPONSE_COMMAND_ID = 0x02, /**< Toggle resposne (since ha-1.2-05-3520-29) */ + ZB_ZCL_UNLOCK_WITH_TIMEOUT_RESPONSE_COMMAND_ID = 0x03, /**< Unlock with timeout response (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_LOG_RECORD_RESPONSE_COMMAND_ID = 0x04, /**< Get log record response (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_PIN_RESPONSE_COMMAND_ID = 0x05, /**< Set PIN response (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_PIN_RESPONSE_COMMAND_ID = 0x06, /**< Get PIN response (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_PIN_RESPONSE_COMMAND_ID = 0x07, /**< Clear PIN response (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_ALL_PINS_RESPONSE_COMMAND_ID = 0x08, /**< Clear all PINs response (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_USER_STATUS_RESPONSE_COMMAND_ID = 0x09, /**< Set user status response (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_USER_STATUS_RESPONSE_COMMAND_ID = 0x0A, /**< Get user status response (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0B, /**< Set weekday schedule response (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0C, /**< Get weekday schedule response (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_WEEKDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0D, /**< Clear weekday schedule resposne (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0E, /**< Set yearday schedule response (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x0F, /**< Get yearday schedule response (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_YEARDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x10, /**< Clear yearday schedule response (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x11, /**< Set holiday schedule response (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x12, /**< Get holiday schedule response (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_HOLIDAY_SCHEDULE_RESPONSE_COMMAND_ID = 0x13, /**< Clear holiday schedule response (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_USER_TYPE_RESPONSE_COMMAND_ID = 0x14, /**< Set user type response (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_USER_TYPE_RESPONSE_COMMAND_ID = 0x15, /**< Get user type response (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_RFID_RESPONSE_COMMAND_ID = 0x16, /**< Set RFID response (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_RFID_RESPONSE_COMMAND_ID = 0x17, /**< Get RFID response (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_RFID_RESPONSE_COMMAND_ID = 0x18, /**< Clear RFID response (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_ALL_RFIDS_RESPONSE_COMMAND_ID = 0x19, /**< CLear ALL RFIDs response (since ha-1.2-05-3520-29) */ + ZB_ZCL_OPERATION_EVENT_NOTIFICATION_COMMAND_ID = 0x20, /**< Operation event notification (since ha-1.2-05-3520-29) */ + ZB_ZCL_PROGRAMMING_EVENT_NOTIFICATION_COMMAND_ID = 0x21, /**< Programming event notification (since ha-1.2-05-3520-29) */ +} zb_zcl_door_lock_server_commands_e; + +/** + * @brief Command types for cluster: Door Lock + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_LOCK_DOOR_COMMAND_ID = 0x00, /**< Lock door */ + ZB_ZCL_UNLOCK_DOOR_COMMAND_ID = 0x01, /**< Unlock door */ + ZB_ZCL_DOOR_TOGGLE_COMMAND_ID = 0x02, /**< Door toggle (since ha-1.2-05-3520-29) */ + ZB_ZCL_UNLOCK_WITH_TIMEOUT_COMMAND_ID = 0x03, /**< Unlock with timeout (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_LOG_RECORD_COMMAND_ID = 0x04, /**< Get log record (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_PIN_COMMAND_ID = 0x05, /**< Set PIN (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_PIN_COMMAND_ID = 0x06, /**< Get PIN (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_PIN_COMMAND_ID = 0x07, /**< Clear PIN (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_ALL_PINS_COMMAND_ID = 0x08, /**< Clear all PINs (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_USER_STATUS_COMMAND_ID = 0x09, /**< Set user status (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_USER_STATUS_COMMAND_ID = 0x0A, /**< Get user status (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_WEEKDAY_SCHEDULE_COMMAND_ID = 0x0B, /**< Set weekday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_WEEKDAY_SCHEDULE_COMMAND_ID = 0x0C, /**< Get weekday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_WEEKDAY_SCHEDULE_COMMAND_ID = 0x0D, /**< Clear weekday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_YEARDAY_SCHEDULE_COMMAND_ID = 0x0E, /**< Set yearday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_YEARDAY_SCHEDULE_COMMAND_ID = 0x0F, /**< Get yearday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_YEARDAY_SCHEDULE_COMMAND_ID = 0x10, /**< Clear yearday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_HOLIDAY_SCHEDULE_COMMAND_ID = 0x11, /**< Set holiday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_HOLIDAY_SCHEDULE_COMMAND_ID = 0x12, /**< Get holiday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_HOLIDAY_SCHEDULE_COMMAND_ID = 0x13, /**< Clear holiday schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_USER_TYPE_COMMAND_ID = 0x14, /**< Set user type (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_USER_TYPE_COMMAND_ID = 0x15, /**< Get user type (since ha-1.2-05-3520-29) */ + ZB_ZCL_SET_RFID_COMMAND_ID = 0x16, /**< Set RFID (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_RFID_COMMAND_ID = 0x17, /**< Get RFID (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_RFID_COMMAND_ID = 0x18, /**< Clear RFID (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_ALL_RFIDS_COMMAND_ID = 0x19, /**< Clear all RFIDs (since ha-1.2-05-3520-29) */ +} zb_zcl_door_lock_client_commands_e; + +/** + * @brief Command types for cluster: Window Covering + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_WINDOW_COVERING_UP_OPEN_COMMAND_ID = 0x00, /**< Window covering up(open) */ + ZB_ZCL_WINDOW_COVERING_DOWN_CLOSE_COMMAND_ID = 0x01, /**< Window covering down(close) */ + ZB_ZCL_WINDOW_COVERING_STOP_COMMAND_ID = 0x02, /**< Window covering stop */ + ZB_ZCL_WINDOW_COVERING_GO_TO_LIFT_VALUE_COMMAND_ID = 0x04, /**< Window covering go to lift value */ + ZB_ZCL_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE_COMMAND_ID = 0x05, /**< Window covering go to lift percentage */ + ZB_ZCL_WINDOW_COVERING_GO_TO_TILT_VALUE_COMMAND_ID = 0x07, /**< Window covering go to tilt value */ + ZB_ZCL_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE_COMMAND_ID = 0x08, /**< Window covering go to tilt percentage */ +} zb_zcl_window_covering_client_commands_e; + +/** + * @brief Command types for cluster: Thermostat + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_CURRENT_WEEKLY_SCHEDULE_COMMAND_ID = 0x00, /**< Current weekly schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_RELAY_STATUS_LOG_COMMAND_ID = 0x01, /**< Relay status log (since ha-1.2-05-3520-29) */ +} zb_zcl_thermostat_server_commands_e; + +/** + * @brief Command types for cluster: Thermostat + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SETPOINT_RAISE_LOWER_COMMAND_ID = 0x00, /**< Setpoint raise or lower */ + ZB_ZCL_SET_WEEKLY_SCHEDULE_COMMAND_ID = 0x01, /**< Set weekly schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_WEEKLY_SCHEDULE_COMMAND_ID = 0x02, /**< Get weekly schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_CLEAR_WEEKLY_SCHEDULE_COMMAND_ID = 0x03, /**< Clear weekly schedule (since ha-1.2-05-3520-29) */ + ZB_ZCL_GET_RELAY_STATUS_LOG_COMMAND_ID = 0x04, /**< Get relay status log (since ha-1.2-05-3520-29) */ +} zb_zcl_thermostat_client_commands_e; + +/** + * @brief Command types for cluster: Color Control + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_MOVE_TO_HUE_COMMAND_ID = 0x00, /**< Move to hue */ + ZB_ZCL_MOVE_HUE_COMMAND_ID = 0x01, /**< Move hue */ + ZB_ZCL_STEP_HUE_COMMAND_ID = 0x02, /**< Step hue */ + ZB_ZCL_MOVE_TO_SATURATION_COMMAND_ID = 0x03, /**< Move to saturation */ + ZB_ZCL_MOVE_SATURATION_COMMAND_ID = 0x04, /**< Move saturation */ + ZB_ZCL_STEP_SATURATION_COMMAND_ID = 0x05, /**< Step saturation */ + ZB_ZCL_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID = 0x06, /**< Move to hue and saturation */ + ZB_ZCL_MOVE_TO_COLOR_COMMAND_ID = 0x07, /**< Move to color */ + ZB_ZCL_MOVE_COLOR_COMMAND_ID = 0x08, /**< Move color */ + ZB_ZCL_STEP_COLOR_COMMAND_ID = 0x09, /**< Step color */ + ZB_ZCL_MOVE_TO_COLOR_TEMPERATURE_COMMAND_ID = 0x0A, /**< Move to color temperature */ + ZB_ZCL_ENHANCED_MOVE_TO_HUE_COMMAND_ID = 0x40, /**< Enhanced move to hue (since zll-1.0-11-0037-10) */ + ZB_ZCL_ENHANCED_MOVE_HUE_COMMAND_ID = 0x41, /**< Enhanced move hue (since zll-1.0-11-0037-10) */ + ZB_ZCL_ENHANCED_STEP_HUE_COMMAND_ID = 0x42, /**< Enhanced step hue (since zll-1.0-11-0037-10) */ + ZB_ZCL_ENHANCED_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID = 0x43, /**< Enhanced move to hue and saturation (since zll-1.0-11-0037-10) */ + ZB_ZCL_COLOR_LOOP_SET_COMMAND_ID = 0x44, /**< Color loop set (since zll-1.0-11-0037-10) */ + ZB_ZCL_STOP_MOVE_STEP_COMMAND_ID = 0x47, /**< Stop move step (since zll-1.0-11-0037-10) */ + ZB_ZCL_MOVE_COLOR_TEMPERATURE_COMMAND_ID = 0x4B, /**< Move color temperature (since zll-1.0-11-0037-10) */ + ZB_ZCL_STEP_COLOR_TEMPERATUE_COMMAND_ID = 0x4C, /**< Step color temperature (since zll-1.0-11-0037-10) */ +} zb_zcl_color_control_client_commands_e; + +/** + * @brief Command types for cluster: IAS Zone + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ZONE_STATUS_CHANGE_NOTIFICATION_COMMAND_ID = 0x00, /**< Zone status change notification */ + ZB_ZCL_ZONE_ENROLL_REQUEST_COMMAND_ID = 0x01, /**< Zone enroll request */ + ZB_ZCL_INITIATE_NORMAL_OPERATION_MODE_RESPONSE_COMMAND_ID = 0x02, /**< Initiate normal operation mode response */ + ZB_ZCL_INITIATE_TEST_MODE_RESPONSE_COMMAND_ID = 0x03, /**< Initiate test mode response */ +} zb_zcl_ias_zone_server_commands_e; + +/** + * @brief Command types for cluster: IAS Zone + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ZONE_ENROLL_RESPONSE_COMMAND_ID = 0x00, /**< Zone enroll response */ + ZB_ZCL_INITIATE_NORMAL_OPERATION_MODE_COMMAND_ID = 0x01, /**< Initiate normal operation mode */ + ZB_ZCL_INITIATE_TEST_MODE_COMMAND_ID = 0x02, /**< Initiate test mode */ +} zb_zcl_ias_zone_client_commands_e; + +/** + * @brief Command types for cluster: IAS ACE + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ARM_RESPONSE_COMMAND_ID = 0x00, /**< Arm response */ + ZB_ZCL_GET_ZONE_ID_MAP_RESPONSE_COMMAND_ID = 0x01, /**< Get zone id map response */ + ZB_ZCL_GET_ZONE_INFORMATION_RESPONSE_COMMAND_ID = 0x02, /**< Get zone information response */ + ZB_ZCL_ZONE_STATUS_CHANGED_COMMAND_ID = 0x03, /**< Zone status change */ + ZB_ZCL_PANEL_STATUS_CHANGED_COMMAND_ID = 0x04, /**< Panel status change */ + ZB_ZCL_GET_PANEL_STATUS_RESPONSE_COMMAND_ID = 0x05, /**< Get panel status response (since ha-1.2.1-05-3520-30) */ + ZB_ZCL_SET_BYPASSED_ZONE_LIST_COMMAND_ID = 0x06, /**< Set bypass zone list (since ha-1.2.1-05-3520-30) */ + ZB_ZCL_BYPASS_RESPONSE_COMMAND_ID = 0x07, /**< Bypass response (since ha-1.2.1-05-3520-30) */ + ZB_ZCL_GET_ZONE_STATUS_RESPONSE_COMMAND_ID = 0x08, /**< Get zone status response (since ha-1.2.1-05-3520-30) */ +} zb_zcl_ias_ace_server_commands_e; + +/** + * @brief Command types for cluster: IAS ACE + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_ARM_COMMAND_ID = 0x00, /**< Arm */ + ZB_ZCL_BYPASS_COMMAND_ID = 0x01, /**< Bypass */ + ZB_ZCL_EMERGENCY_COMMAND_ID = 0x02, /**< Emergency */ + ZB_ZCL_FIRE_COMMAND_ID = 0x03, /**< Fire */ + ZB_ZCL_PANIC_COMMAND_ID = 0x04, /**< Panic */ + ZB_ZCL_GET_ZONE_ID_MAP_COMMAND_ID = 0x05, /**< Get zone id map */ + ZB_ZCL_GET_ZONE_INFORMATION_COMMAND_ID = 0x06, /**< Get zone information */ + ZB_ZCL_GET_PANEL_STATUS_COMMAND_ID = 0x07, /**< Get panel status (since ha-1.2.1-05-3520-30) */ + ZB_ZCL_GET_BYPASSED_ZONE_LIST_COMMAND_ID = 0x08, /**< Bypassed zone lise (since ha-1.2.1-05-3520-30) */ + ZB_ZCL_GET_ZONE_STATUS_COMMAND_ID = 0x09, /**< Get zone status (since ha-1.2.1-05-3520-30) */ +} zb_zcl_ias_ace_client_commands_e; + +/** + * @brief Command types for cluster: IAS WD + * @details Cluster specification level: zcl-1.0-07-5123-03 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_START_WARNING_COMMAND_ID = 0x00, /**< Start warning */ + ZB_ZCL_SQUAWK_COMMAND_ID = 0x01, /**< Squawk */ +} zb_zcl_ias_wd_client_commands_e; + + +/** + * @brief Command types for cluster: Electrical Measurement + * @details Cluster specification level: UNKNOWN + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_GET_PROFILE_INFO_RESPONSE_COMMAND_COMMAND_ID = 0x00, /**< Get profile info. response command */ + ZB_ZCL_GET_MEASUREMENT_PROFILE_RESPONSE_COMMAND_COMMAND_ID = 0x01, /**< Get measurement profile response command */ +} zb_zcl_electrical_measurement_server_commands_e; + +/** + * @brief Command types for cluster: Electrical Measurement + * @details Cluster specification level: UNKNOWN + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_GET_PROFILE_INFO_COMMAND_COMMAND_ID = 0x00, /**< Get profile info. command */ + ZB_ZCL_GET_MEASUREMENT_PROFILE_COMMAND_COMMAND_ID = 0x01, /**< Get measurement profile command */ +} zb_zcl_electrical_measurement_client_commands_e; + +/** + * @brief Command types for cluster: ZLL Commissioning + * @details Cluster specification level: zll-1.0-11-0037-10 + * @remark Direction : Server to Client + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SCAN_RESPONSE_COMMAND_ID = 0x01, /**< Scan response (since zll-1.0-11-0037-10) */ + ZB_ZCL_DEVICE_INFORMATION_RESPONSE_COMMAND_ID = 0x03, /**< Device informatio response (since zll-1.0-11-0037-10) */ + ZB_ZCL_NETWORK_START_RESPONSE_COMMAND_ID = 0x11, /**< Network start reponse (since zll-1.0-11-0037-10) */ + ZB_ZCL_NETWORK_JOIN_ROUTER_RESPONSE_COMMAND_ID = 0x13, /**< Network join router response (since zll-1.0-11-0037-10) */ + ZB_ZCL_NETWORK_JOIN_END_DEVICE_RESPONSE_COMMAND_ID = 0x15, /**< Network join end device response (since zll-1.0-11-0037-10) */ + ZB_ZCL_ENDPOINT_INFORMATION_COMMAND_ID = 0x40, /**< Endpoint information (since zll-1.0-11-0037-10) */ + ZB_ZCL_GET_GROUP_IDENTIFIERS_RESPONSE_COMMAND_ID = 0x41, /**< Get group identifiers response (since zll-1.0-11-0037-10) */ + ZB_ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID = 0x42, /**< Get endpoint list response (since zll-1.0-11-0037-10) */ +} zb_zcl_zll_commissioning_server_commands_e; + +/** + * @brief Command types for cluster: ZLL Commissioning + * @details Cluster specification level: zll-1.0-11-0037-10 + * @remark Direction : Client to Server + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SCAN_REQUEST_COMMAND_ID = 0x00, /**< Scan request (since zll-1.0-11-0037-10) */ + ZB_ZCL_DEVICE_INFORMATION_REQUEST_COMMAND_ID = 0x02, /**< Device information (since zll-1.0-11-0037-10) */ + ZB_ZCL_IDENTIFY_REQUEST_COMMAND_ID = 0x06, /**< Idenfity request (since zll-1.0-11-0037-10) */ + ZB_ZCL_RESET_TO_FACTORY_NEW_REQUEST_COMMAND_ID = 0x07, /**< Reset to factory new request (since zll-1.0-11-0037-10) */ + ZB_ZCL_NETWORK_START_REQUEST_COMMAND_ID = 0x10, /**< Network start request (since zll-1.0-11-0037-10) */ + ZB_ZCL_NETWORK_JOIN_ROUTER_REQUEST_COMMAND_ID = 0x12, /**< Network join router request (since zll-1.0-11-0037-10) */ + ZB_ZCL_NETWORK_JOIN_END_DEVICE_REQUEST_COMMAND_ID = 0x14, /**< Network join end device request (since zll-1.0-11-0037-10) */ + ZB_ZCL_NETWORK_UPDATE_REQUEST_COMMAND_ID = 0x16, /**< Network update request (since zll-1.0-11-0037-10) */ + ZB_ZCL_GET_GROUP_IDENTIFIERS_REQUEST_COMMAND_ID = 0x41, /**< Get group identifiers request (since zll-1.0-11-0037-10) */ + ZB_ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID = 0x42, /**< Get end-point list request (since zll-1.0-11-0037-10) */ +} zb_zcl_zll_commissioning_client_commands_e; + +/** + * @} + */ +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_COMMAND_IDS_H__ */ diff --git a/include/zcl/zb_zcl_global_commands.h b/include/zcl/zb_zcl_global_commands.h new file mode 100644 index 0000000..fcec6d9 --- /dev/null +++ b/include/zcl/zb_zcl_global_commands.h @@ -0,0 +1,796 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_H__ + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_global_commands.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_MODULE Global Commands + * + * @brief Zigbee global commands description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/** + * @brief Called when receiving general response + * @details This function is used for global response corresponding. + * + * @since_tizen 4.0 + * + * @param[out] addr16 source network address + * @param[out] ep where is sent from (ex. 1) + * @param[out] cluster_id ZCL cluster id + * @param[out] records Response record + * @param[out] records_len Length of attribute status record + * @param[out] user_data User data + * + * @see zb_zcl_global_read_attr() + * @see zb_zcl_global_write_attr() + * @see zb_zcl_global_write_attr_undivided() + * @see zb_zcl_global_config_report() + * @see zb_zcl_global_read_config_report() + * @see zb_zcl_global_read_attr_structured() + * @see zb_zcl_global_write_attr_structured() + */ +typedef void (*zb_zcl_global_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned short cluster_id, + zb_global_record_data_s *records, + int records_len, + void *user_data); + +/** + * @brief Sends 'reads attributes' commands + * @details This function to read attributes in devices. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] attribute_ids Attributes_ids-list + * @param[in] attribute_ids_len Length of attribte_ids-list + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @post This function invokes zb_zcl_global_rsp() for each application context. + * + * @see zb_zcl_global_rsp() + */ +int zb_zcl_global_read_attr( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + unsigned short *attribute_ids, + int attribute_ids_len, + zb_zcl_global_rsp cb, + void *user_data); + +/** + * @brief Sends 'write Attributes' command + * @details This function to write attributes to other devices. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] records structure for write_attribute_record_s + * @param[in] records_len Length of attribte_ids-list + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_rsp() + */ +int zb_zcl_global_write_attr( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + write_attr_record_h *records, + int records_len, + zb_zcl_global_rsp cb, + void *user_data); + +/** + * @brief Sends 'write attributes undivided' command + * @details This function to write attributes without fragmentation to other devices. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] records structure for write_attribute_record_s + * @param[in] records_len Length of attribte_ids-list + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_rsp() + */ +int zb_zcl_global_write_attr_undivided( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + write_attr_record_h *records, + int records_len, + zb_zcl_global_rsp cb, + void *user_data); + +/** + * @brief Sends 'write Attributes' command + * @details This function to write attributes to other devices without any response. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] records structure for write_attribute_record_s + * @param[in] records_len Length of attribte_ids-list + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_global_write_attr_no_rsp( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + write_attr_record_h *records, + int records_len); + +/** + * @brief Sends 'setting configure reporting' command + * @details This function to set configuration about attribute status changing reporting. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] records structure for report_config_records + * @param[in] records_len Length of report_config_records structure + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_rsp() + */ +int zb_zcl_global_config_report( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + report_config_record_h *records, + int records_len, + zb_zcl_global_rsp cb, + void *user_data); + +/** + * @brief Sends 'reading configure reporting' command + * @details This function to read configuration about attribute status changing reporting. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] records structure for report_config_records + * @param[in] records_len Length of report_config_records structure + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_rsp() + */ +int zb_zcl_global_read_config_report( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + read_report_config_record_h *records, + int records_len, + zb_zcl_global_rsp cb, + void *user_data); + +/** + * @brief Called after 'discover attribute' command + * @details The discover attributes response command is generated in response to a discover + * attributes command. + * + * @since_tizen 4.0 + * + * @param[out] addr16 source network address + * @param[out] ep where is sent from (ex. 1) + * @param[out] cluster_id ZCL cluster id + * @param[out] records Discover attribute information record + * @param[out] records_len Length of Discover attribute information record + * @param[out] user_data User data + * + * @see zb_zcl_global_discover_attr() + */ +typedef void (*zb_zcl_global_discover_attr_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned short cluster_id, + unsigned char discovery_complete, + discover_attr_info_record_h *records, + int records_len, + void *user_data); + +/** + * @brief Sends 'discovering attributes' command + * @details The discover attributes command is generated when a remote device wishes to + * discover the identifiers and types of the attributes on a device which are supported + * within the cluster to which this command is directed. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] start_id The value of the identifier at which to begin the attribute discovery. + * @param[in] max_attribute_ids The maximum number of attribute identifiers + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_rsp() + */ +int zb_zcl_global_discover_attr( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + unsigned short start_id, + unsigned char max_attribute_ids, + zb_zcl_global_discover_attr_rsp cb, + void *user_data); + +/** + * @brief Sends 'read attributes structured' command + * details The read attributes command is generated when a device wishes to determine the + * values of one or more attributes, or elements of attributes, located on another + * device. Each attribute identifier field shall contain the identifier of the attribute + * to be read. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] records The combination of attribute identifier and selector . + * @param[in] records_len The maximum number of read_structured_attribute_record + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_rsp() + */ +int zb_zcl_global_read_attr_structured( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + read_structured_attr_record_h *records, + int records_len, + zb_zcl_global_rsp cb, + void *user_data); + +/** + * @brief Sends 'write attributes structured' command + * @details When writing an element to an array or structure, the Indicator subfield indicates + * the number of index fields that follow it. This number is limited to the range 0 - 15 + * (i.e. the upper 4 bits of the Indicator field are set to zero). It may be further limited + * by any relevant profile or application. + * If the Indicator subfield is 0, there are no index fields, and the whole of the + * attribute value is to be written. + * If this subfield is 1 or greater, the index fields indicate which element is to be + * written, nested to a depth of m. For example, if the attribute is an array of arrays + * (or structures), then if m = 2, index 1 = 5 and index 2 = 3, the third element of the + * fifth element of the attribute will be written. + * Note that elements are numbered from 1 upwards for both arrays and structures. + * The zeroth element of an array or structure has type 16 bit unsigned integer, and + * holds the number of elements in the array or structure. The zeroth element of an + * array may optionally be written (this is application dependent) and has the effect + * of changing the number of elements of the array. If the number is reduced, the + * array is truncated. If the number is increased, the content of new elements is + * application dependent. + * The zeroth element of a structure may not be written to. Writing to an element + * with an index greater than the number of elements in an array or structure is + * always an error. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] records The combination of attribute identifier and selector . + * @param[in] records_len The maximum number of write_structured_attribute_record + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * @retval #ZIGBEE_ERROR_NOT_SUPPORTED Not supported + * + * @see zb_zcl_global_rsp() + */ +int zb_zcl_global_write_attr_structured( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + write_attr_structured_record_h *records, + int records_len, + zb_zcl_global_rsp cb, + void *user_data); + +/** + * @brief Called after zb_zcl_global_discover_commands_received() and + * zb_zcl_global_discover_cmds_generated() + * @details The ZCL provides the facility to discover the commands that a cluster + * instance on a remote device can receive and generate. This is useful since an + * individual cluster instance may not be able to receive or generate all of the commands + * that are theoretically supported by the cluster. + * + * @since_tizen 4.0 + * + * @param[out] addr16 source network address + * @param[out] ep where is sent from (ex. 1) + * @param[out] cluster_id ZCL cluster id + * @param[out] discovery_complete which indicates whether the Command Discovery is + * complete, i.e. whether there are any commands remaining to be discovered:\n + * - TRUE - all commands have been discovered\n + * - FALSE - there are further commands to be discovered\n + * @param[out] command_ids Discovered commands list + * @param[out] command_ids_len The number of discovered commands reported in this response + * @param[out] user_data User data + * + * @see zb_zcl_global_discover_cmd_received() + */ +typedef void (*zb_zcl_global_discover_cmds_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned short cluster_id, + unsigned char discovery_complete, + unsigned char *command_ids, + int command_ids_len, + void *user_data); + +/** + * @brief Sends 'discover command recevied' command + * @details This function to know remote cluster on remote device can handle specific commands. + * The ZCL provides the facility to discover the commands that a cluster + * instance on a remote device can receive and generate. This is useful since an + * individual cluster instance may not be able to receive or generate all of the commands + * that are theoretically supported by the cluster. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] start_command_id Start command id . + * @param[in] max_command_ids Last command id + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_discover_cmd_received_rsp() + */ +int zb_zcl_global_discover_cmds_received( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + unsigned char start_command_id, + unsigned char max_command_ids, + zb_zcl_global_discover_cmds_rsp cb, + void *user_data); + +/** + * @brief Sends 'discover command generated' command + * @details The ZCL provides the facility to discover the commands that a cluster + * instance on a remote device can receive and generate. This is useful since an + * individual cluster instance may not be able to receive or generate all of the commands + * that are theoretically supported by the cluster. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] start_command_id Start command id . + * @param[in] max_command_ids Last command id + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_discover_cmds_rsp() + */ +int zb_zcl_global_discover_cmds_generated( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + unsigned char start_command_id, + unsigned char max_command_ids, + zb_zcl_global_discover_cmds_rsp cb, + void *user_data); + +/** + * @brief Called after zb_zcl_global_discover_attr_extended() + * @details The ZCL provides the facility to discover the commands that a cluster + * instance on a remote device can receive and generate. This is useful since an + * individual cluster instance may not be able to receive or generate all of the commands + * that are theoretically supported by the cluster. + * + * @since_tizen 4.0 + * + * @param[out] addr16 source network address + * @param[out] ep where is sent from (ex. 1) + * @param[out] cluster_id ZCL cluster id + * @param[out] discovery_complete which indicates whether the Command Discovery is + * complete, i.e. whether there are any commands remaining to be discovered:\n + * - TRUE - all commands have been discovered\n + * - FALSE - there are further commands to be discovered\n + * @param[out] records Discovered attribute information list + * @param[out] records_len Len The number of discovered information\n + * reported in this response + * @param[out] user_data User data + * + * @see zb_zcl_global_discover_attr_extended() + */ +typedef void (*zb_zcl_global_discover_attr_extended_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned short cluster_id, + unsigned char discovery_complete, + extended_attr_info_h *records, + unsigned short records_len, + void *user_data); + +/** + * @brief Sends 'discover attributes extended' command + * @details This function to know remote cluster on remote device has extended commands. + * The ZCL provides the facility to discover the commands that a cluster + * instance on a remote device can receive and generate. This is useful since an + * individual cluster instance may not be able to receive or generate all of the commands + * that are theoretically supported by the cluster. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 target network address + * @param[in] src_ep source end-point (ex. 1) + * @param[in] dst_ep destination end-point (ex. 1) + * @param[in] zcl_frame_ctl frame control bits (default 0x00). \n + * Only OR operation is allowed in ZCL header \n + * - Frame Type : \n + * #ZB_ZCL_FC_GLOBALLY_USED (default) \n + * #ZB_APS_FC_CLUSTER_SPECIFIC \n + * - Manufacturer Specific : \n + * - Direction : \n + * #ZB_ZCL_CLIENT_TO_SERVER (default) \n + * #ZB_ZCL_SERVER_TO_CLIENT \n + * - Disable Default Response : \n + * #ZB_ZCL_LEAVE_WELL_ALONE (default) \n + * #ZB_ZCL_DISABLE_DEFAULT_RESPONSE \n + * @param[in] cluster_id ZCL cluster id + * @param[in] start_id Start id . + * @param[in] max_attribute_ids Last command id + * @param[in] cb Response callback function + * @param[in] user_data User data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_discover_attr_extended_rsp() + */ +int zb_zcl_global_discover_attr_extended( + zigbee_h handle, + nwk_addr addr16, + unsigned char src_ep, + unsigned char dst_ep, + unsigned char zcl_frame_ctl, + unsigned short cluster_id, + unsigned short start_id, + unsigned char max_attribute_ids, + zb_zcl_global_discover_attr_extended_rsp cb, + void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_GLOBAL_COMMAND_H__ */ diff --git a/include/zcl/zb_zcl_groups_cluster.h b/include/zcl/zb_zcl_groups_cluster.h new file mode 100644 index 0000000..72c88cf --- /dev/null +++ b/include/zcl/zb_zcl_groups_cluster.h @@ -0,0 +1,363 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_GROUPS_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_GROUPS_CLUSTER_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_groups_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_GROUP_CLUSTER_MODULE Group Cluster + * + * @brief Zigbee group cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_GROUP_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/* Table 3.33 Generated Command IDs for the Groups Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Add group response | M | + * | 0x01 | View group response | M | + * | 0x02 | Get group membership response | M | + * | 0x03 | Remove group response | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Called after 'add group' command + * @details The add group response is sent by the groups cluster server in response to an\n + * add group command.\n + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_DUPLICATE_EXISTS \n + * #ZB_ZCL_INSUFFICIENT_SPACE + * @param[out] group_id Group id + * @param[out] user_data user data + * + * @see zb_zcl_group_add_group() + */ +typedef void (*zb_zcl_group_add_group_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned short group_id, + void *user_data); + +/** + * @brief Called after 'view group' command + * @details The view group response command is sent by the groups cluster server in\n + * response to a view group command.\n + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_NOT_FOUND + * @param[out] group_id Group id + * @param[out] group_name Group name + * @param[out] user_data user data + * + * @see zb_zcl_group_view_group() + */ +typedef void (*zb_zcl_group_view_group_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned short group_id, + const char *group_name, + void *user_data); + +/** + * @brief Called after 'view group membership' command + * @details The get group membership response command is sent by the groups cluster server\n + * in response to a get group membership command.\n + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] capacity How many we can add to this group + * @param[out] group_count The number of groups contained in the group_list + * @param[out] group_list the identifiers either of all the groups in the group table + * @param[out] user_data user data + * + * @see zb_zcl_group_view_group_membership() + */ +typedef void (*zb_zcl_group_get_group_membership_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char capacity, + unsigned char group_count, + unsigned short *group_list, + void *user_data); + +/** + * @brief Called after 'remove group' command + * @details The add group response is sent by the groups cluster server in response to an\n + * remove group command.\n + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_NOT_FOUND + * @param[out] group_id Group id + * @param[out] user_data user data + * + * @see zb_zcl_group_add_group() + */ +typedef void (*zb_zcl_group_remove_group_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned short group_id, + void *user_data); + +/* Table 3.32 Received Command IDs for the Groups Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Add group | M | + * | 0x01 | View group | M | + * | 0x02 | Get group membership | M | + * | 0x03 | Remove group | M | + * | 0x04 | Remove all group | M | + * | 0x05 | Add group if identifying | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Sends 'add groups' command + * @details The add group command allows the sending device to add group membership in a\n + * particular group for one or more endpoints on the receiving device.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Target endpoint + * @param[in] group_id Group ID + * @param[in] group_name Group name + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_group_add_group_rsp() + */ +int zb_zcl_group_add_group( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + char *group_name, + zb_zcl_group_add_group_rsp cb, + void *user_data); + +/** + * @brief Sends 'view group' command + * @details The view group command allows the sending device to request that the receiving\n + * entity or entities respond with a view group response command containing the\n + * application name string for a particular group.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Target endpoint + * @param[in] group_id Group ID + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_group_view_group_rsp() + */ +int zb_zcl_group_view_group( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + zb_zcl_group_view_group_rsp cb, + void *user_data); + +/** + * @brief Sends 'get group membership' command + * @details The get group membership command allows the sending device to inquire about\n + * the group membership of the receiving device and endpoint in a number of ways.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Target endpoint + * @param[in] group_count Group count + * @param[in] group_list Group list + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_group_get_group_membership_rsp() + */ +int zb_zcl_group_get_group_membership( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char group_count, + unsigned short *group_list, + zb_zcl_group_get_group_membership_rsp cb, + void *user_data); + +/** + * @brief Sends 'remove group' command + * @details The remove group command allows the sender to request that the receiving entity\n + * or entities remove their membership, if any, in a particular group.\n + * Note that if a group is removed the scenes associated with that group should be\n + * removed.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Target endpoint + * @param[in] group_id Group ID + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_group_remove_group_rsp() + */ +int zb_zcl_group_remove_group( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + zb_zcl_group_remove_group_rsp cb, + void *user_data); + +/** + * @brief Sends 'remove group' command + * @details The remove all groups command allows the sending device to direct the receiving\n + * entity or entities to remove all group associations.\n + * \n + * Note that removing all groups necessitates the removal of all associated scenes as\n + * well. (Note: scenes not associated with a group need not be removed).\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Target endpoint + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_group_remove_all_group( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep); + +/** + * @brief Sends 'remove group if identifying' command + * @details The add group if identifying command allows the sending device to add group\n + * membership in a particular group for one or more endpoints on the receiving\n + * device, on condition that it is identifying itself. Identifying functionality is\n + * controlled using the identify cluster.\n + * This command might be used to assist configuring group membership in the\n + * absence of a commissioning tool.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Target endpoint + * @param[in] group_id Group ID + * @param[in] group_name Group name + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_group_add_group_if_identifying( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + const char *group_name); + +/** + * @} + */ +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_H__ */ + diff --git a/include/zcl/zb_zcl_ias_zone_cluster.h b/include/zcl/zb_zcl_ias_zone_cluster.h new file mode 100644 index 0000000..2f42ae7 --- /dev/null +++ b/include/zcl/zb_zcl_ias_zone_cluster.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_ias_zone_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_MODULE IAS zone Cluster + * + * @brief Zigbee IAS zone cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/* Table 8.10 Generated Command IDs for the IAS Zone Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Zone Status Change Notification | M | + * | 0x01 | Zone Enroll Request | M | + * | 0x11 | Zone Status Change Notification (Ext)| M | + * +--------------------------------+--------------------------------------+------------+ + */ + + +/* Table 8.8 Received Command IDs for the IAS Zone Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Zone Enroll Respnse | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Table 8.9 Values of the Enroll Response Code in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_IAS_ZONE_ENROLL_SUCCESS = 0x00, /**< Success */ + ZB_ZCL_IAS_ZONE_ENROLL_NOT_SUPPORT = 0x01, /**< This specific Zone type is not known + to the CIE and is not supported */ + ZB_ZCL_IAS_ZONE_ENROLL_NO_ENROLL_PERMIT = 0x02, /**< CIE does not permit new zones to + enroll at this time. */ + ZB_ZCL_IAS_ZONE_ENROLL_TOO_MANY_ZONE = 0x03, /**< CIE reached its limit of number of + enrolled zones */ +} zb_ias_zone_enroll_response_e; + +/** + * @brief Sends 'zone enroll response' command + * @details On receipt, the device embodying the Zone server is notified that it is now + * enrolled as an active alarm device\n + * The device embodying the Zone server must authenticate received messages by + * checking the address of their sender against IAS_CIE_Address. This is to ensure + * that only messages from the correct CIE are accepted. + * + * @since_tizen 4.0 + * + * @param[in] handle handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] enroll_response_code #ZB_ZCL_IAS_ZONE_ENROLL_SUCCESS + * #ZB_ZCL_IAS_ZONE_ENROLL_NOT_SUPPORT + * #ZB_ZCL_IAS_ZONE_ENROLL_NO_ENROLL_PERMIT + * #ZB_ZCL_IAS_ZONE_ENROLL_TOO_MANY_ZONE + * @param[in] zone_id The Zone ID field is the index into the zone table of the CIE. This + * field is only relevant if the response code is success.\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_zone_enroll_response( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char enroll_response_code, + unsigned char zone_id); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_IAS_ZONE_CLUSTER_H__ */ diff --git a/include/zcl/zb_zcl_identify_cluster.h b/include/zcl/zb_zcl_identify_cluster.h new file mode 100644 index 0000000..ae3fafd --- /dev/null +++ b/include/zcl/zb_zcl_identify_cluster.h @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_IDENTIFY_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_IDENTIFY_CLUSTER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_identify_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_IDENTITY_CLUSTER_MODULE Identity Cluster + * + * @brief Zigbee identity cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_IDENTITY_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/** + * @brief Makes devices as Identify mode within specific time + * @details The identify command starts or stops the receiving device identifying itself. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep endpoint number + * @param[in] identify_time Identify time + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_identify( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short identify_time); + +/** + * @brief Called after receiving identify query command + * @details The identify query command allows the sending device to request the target or + * targets to respond if they are currently identifying themselves.\n + * This command has no payload.\n + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] identify_time Identify time + * @param[out] user_data user data + * + * @see zb_zcl_identify_query() + */ +typedef void (*zb_zcl_identify_query_cb)( + nwk_addr addr16, + unsigned short identify_time, + void *user_data); + +/** + * @brief Finds devices which sustains identify mode + * @details The identify query command allows the sending device to request the target or + * targets to respond if they are currently identifying themselves.\n + * This command has no payload.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep endpoint number + * @param[in] cb response callback function + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_global_write_attr_rsp() + */ +int zb_zcl_identify_query( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + zb_zcl_identify_query_cb cb, + void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_IDENTIFY_CLUSTER_H__ */ diff --git a/include/zcl/zb_zcl_level_control_cluster.h b/include/zcl/zb_zcl_level_control_cluster.h new file mode 100644 index 0000000..92ad5b1 --- /dev/null +++ b/include/zcl/zb_zcl_level_control_cluster.h @@ -0,0 +1,348 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_on_off_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_MODULE Level Control Cluster + * + * @brief Zigbee level control cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/* Table 3.48 Command IDs for the Level Control Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Move to Level | M | + * | 0x01 | Move | M | + * | 0x02 | Step | M | + * | 0x03 | Stop | M | + * | 0x04 | Move to Level (with On/Off) | M | + * | 0x05 | Move (with On/Off) | M | + * | 0x06 | Step (with On/Off) | M | + * | 0x07 | Stop | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Sends 'move to level' command + * @details On receipt of this command, a device shall move from its current level to the + * value given in the Level field. The meaning of 'level' is device dependent ? e.g. + * for a light it may mean brightness level.\n\n + * The movement shall be as continuous as technically practical, i.e. not a step + * function, and the time taken to move to the new level shall be equal to the value of + * the Transition time field, in tenths of a second, or as close to this as the device is + * able.\n\n + * If the Transition time field takes the value 0xffff then the time taken to move to + * the new level shall instead be determined by the OnOffTransitionTime attribute. If + * OnOffTransitionTime , which is an optional attribute, is not present, the device + * shall move to its new level as fast as it is able.\n\n + * If the device is not able to move at a variable rate, the Transition time field may be + * disregarded.\n\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] level Brightness level + * @param[in] transition_time The Transition time field, in tenths of a second, \n + * or as close to this as the device is able + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_levelctrl_move_to_level( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char level, + unsigned short transition_time); + +/** + * @brief Sends 'move' command + * @details On receipt of this command, a device shall move from its current level in an + * up or down direction in a continuous fashion + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] move_mode The Move mode field shall be one of the non-reserved values\n + * 0x00 : Up\n + * 0x01 : Down\n + * @param[in] rate The Rate field specifies the rate of movement in units per second. \n + * The actual rate of movement should be as close to this rate as the device is able.\n + * If the Rate field is 0xff the device should move as fast as it is able.\n + * If the device is not able to move at a variable rate, this field may be disregarded.\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_levelctrl_move( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char move_mode, + unsigned char rate); + +/** + * @brief Sends 'step' command + * @details On receipt of this command, a device shall move from its current level in an + * up or down direction in a continuous fashion + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] step_mode The Step mode field shall be one of the non-reserved values\n + * 0x00 : Up\n + * 0x01 : Down\n + * @param[in] step_size Step size + * @param[in] transition_time The Transition time field specifies the time that shall be taken to perform the step,\n + * in tenths of a second. A step is a change in the CurrentLevel of 'Step size' units.\n + * The actual time taken should be as close to this as the device is able. If the\n + * Transition time field is 0xffff the device should move as fast as it is able.\n + * If the device is not able to move at a variable rate, the Transition time field may be\n + * disregarded.\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_levelctrl_step( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char step_mode, + unsigned char step_size, + unsigned short transition_time); + +/** + * @brief Sends 'stop' command + * @details This command has no payload. Upon receipt of this command, any Move to + * Level, Move or Step command (and their 'with On/Off' variants) currently in + * process shall be terminated. The value of CurrentLevel shall be left at its value + * upon receipt of the Stop command, and RemainingTime shall be set to zero. + * This command has two entries in Table 3.1, one for the Move to Level, Move and + * Set commands, and one for their 'with On/Off' counterparts. This is solely for + * symmetry, to allow easy choice of one or other set of commands ? the Stop + * commands are identical. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_levelctrl_stop( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep); + +/** + * @brief Sends 'move to level with on/off' command + * @details On receipt of this command, a device shall move from its current level to the + * value given in the Level field. The meaning of 'level' is device dependent ? e.g. + * for a light it may mean brightness level.\n\n + * The movement shall be as continuous as technically practical, i.e. not a step + * function, and the time taken to move to the new level shall be equal to the value of + * the Transition time field, in tenths of a second, or as close to this as the device is + * able.\n\n + * If the Transition time field takes the value 0xffff then the time taken to move to + * the new level shall instead be determined by the OnOffTransitionTime attribute. If + * OnOffTransitionTime , which is an optional attribute, is not present, the device + * shall move to its new level as fast as it is able.\n\n + * If the device is not able to move at a variable rate, the Transition time field may be + * disregarded.\n\n + * The Move to Level (with On/Off), Move (with On/Off) and Step (with On/Off) + * commands have identical payloads to the Move to Level, Move and Step + * commands respectively. The also have the same effects, except for the following + * additions. + * * Before commencing any command that has the effect of increasing + * CurrentLevel, the OnOff attribute of the On/Off cluster on the same endpoint, if + * implemented, shall be set to On. + * * If any command that decreases CurrentLevel reduces it to the minimum level + * allowed by the device, the OnOff attribute of the On/Off cluster on the same + * endpoint, if implemented, shall be set to Off. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] level Brightness level + * @param[in] transition_time The Transition time field, in tenths of a second, \n + * or as close to this as the device is able + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_levelctrl_move_to_level_with_on_off( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char level, + unsigned short transition_time); + +/** + * @brief Sends 'move with on/off' command + * @details On receipt of this command, a device shall move from its current level in an + * up or down direction in a continuous fashion\n + * The Move to Level (with On/Off), Move (with On/Off) and Step (with On/Off) + * commands have identical payloads to the Move to Level, Move and Step + * commands respectively. The also have the same effects, except for the following + * additions. + * * Before commencing any command that has the effect of increasing + * CurrentLevel, the OnOff attribute of the On/Off cluster on the same endpoint, if + * implemented, shall be set to On. + * * If any command that decreases CurrentLevel reduces it to the minimum level + * allowed by the device, the OnOff attribute of the On/Off cluster on the same + * endpoint, if implemented, shall be set to Off. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] move_mode The Move mode field shall be one of the non-reserved values\n + * 0x00 : Up\n + * 0x01 : Down\n + * @param[in] rate The Rate field specifies the rate of movement in units per second. \n + * The actual rate of movement should be as close to this rate as the device is able.\n + * If the Rate field is 0xff the device should move as fast as it is able.\n + * If the device is not able to move at a variable rate, this field may be disregarded.\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_levelctrl_move_with_on_off( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char move_mode, + unsigned char rate); + +/** + * @brief Sends 'step with on/off' command + * @details On receipt of this command, a device shall move from its current level in an + * up or down direction in a continuous fashion. \n\n + * The Move to Level (with On/Off), Move (with On/Off) and Step (with On/Off) + * commands have identical payloads to the Move to Level, Move and Step + * commands respectively. The also have the same effects, except for the following + * additions. \n\n + * * Before commencing any command that has the effect of increasing + * CurrentLevel, the OnOff attribute of the On/Off cluster on the same endpoint, if + * implemented, shall be set to On. \n\n + * * If any command that decreases CurrentLevel reduces it to the minimum level + * allowed by the device, the OnOff attribute of the On/Off cluster on the same + * endpoint, if implemented, shall be set to Off. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] step_mode The Step mode field shall be one of the non-reserved values\n + * 0x00 : Up\n + * 0x01 : Down\n + * @param[in] step_size Step size + * @param[in] transition_time The Transition time field specifies the time that shall be + * taken to perform the step, in tenths of a second. A step is a change in the + * CurrentLevel of 'Step size' units.\n\n + * The actual time taken should be as close to this as the device is able. If the + * Transition time field is 0xffff the device should move as fast as it is able. \n\n + * If the device is not able to move at a variable rate, the Transition time field may be + * disregarded.\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_levelctrl_step_with_on_off( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char step_mode, + unsigned char step_size, + unsigned short transition_time); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_LEVEL_CONTROL_CLUSTER_H__ */ diff --git a/include/zcl/zb_zcl_on_off_cluster.h b/include/zcl/zb_zcl_on_off_cluster.h new file mode 100644 index 0000000..a8c7cb3 --- /dev/null +++ b/include/zcl/zb_zcl_on_off_cluster.h @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_on_off_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_MODULE On/Off Cluster + * + * @brief Zigbee on/off cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/* Table 3.40 Command IDs for the On/Off Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Off | M | + * | 0x01 | On | M | + * | 0x02 | Toggle | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief On/Off value + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_OFF = 0x00, /**< off */ + ZB_ZCL_ON = 0x01, /**< on */ + ZB_ZCL_TOGGLE = 0x02, /**< toggle */ +} zb_zcl_onoff_e; + +/** + * @brief Sends 'on/off/toogle' command + * @details On receipt of 'on' command, a device shall enter its 'Off' state. + * This state is device dependent, but it is recommended that it is used for power off or\n + * similar functions.\n + * On receipt of 'off' command, a device shall enter its 'On' state. This state is\n + * device dependent, but it is recommended that it is used for power on or similar + * functions.\n + * On receipt of this command, if a device is in its 'Off' state it shall enter\n + * its 'On' state. Otherwise, if it is in its 'On' state it shall enter its 'Off' state\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] on_off_type #ZB_ZCL_OFF \n + * #ZB_ZCL_ON \n + * #ZB_ZCL_TOGGLE \n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_onoff_control( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + zb_zcl_onoff_e on_off_type); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_ON_OFF_CLUSTER_H__ */ diff --git a/include/zcl/zb_zcl_poll_control_cluster.h b/include/zcl/zb_zcl_poll_control_cluster.h new file mode 100644 index 0000000..295cd64 --- /dev/null +++ b/include/zcl/zb_zcl_poll_control_cluster.h @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_poll_control_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_MODULE Poll Control Cluster + * + * @brief Zigbee poll control cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + + +/* Table 9.28 Commands Generated by the Poll Control Server + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Check-in | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Called after receiving 'check-in' event + * @details The Poll Control Cluster server sends out a Check-in command to the devices to + * which it is paired based on the server's Check-inInterval attribute. It does this to + * find out if any of the Poll Control Cluster Clients with which it is paired are + * interested in having it enter fast poll mode so that it can be managed. This request + * is sent out based on either the Check-inInterval, or the next Check-in value in the + * Fast Poll Stop Request generated by the Poll Control Cluster Client.\n + * The Check-in command expects a Check-in Response command to be sent back + * from the Poll Control Client. If the Poll Control Server does not receive a Check- + * in response back from the Poll Control Client up to7.68 seconds it is free to return + * to polling according to the LongPollInterval.\n + * \n + * The Poll Control Cluster is used on end devices that may be battery powered. In + * order to conserve battery life, it is important that the Poll Control Server maintain + * certain boundaries for the setting of the Check-inInterval, LongPollInterval and + * the ShortPollInterval. Therefore, while these attributes are all Read/Write, it is + * possible that a battery-powered device might maintain its own boundary for the + * min and max of each of these attributes. The end device implementing the Poll + * Control Cluster Server may define its own boundaries for these attributes in order + * to protect itself against a power drain due to improper configuration. + * For instance a battery powered device may not allow another device to set its + * Check-inInterval to too short a value or its FastPollTimeout to too long an interval + * because it might cause the device to send too frequent check-in messages on the + * network and stay in fast poll mode for too long a time resulting in a drain on the + * battery.\n + * The Check-inInterval, LongPollInterval and ShortPollInterval should be set such + * that:\n + * \n + * - Check-in Interval >= Long Poll Interval >= Short Poll Interval\n + * - The default values chosen for this cluster are:\n + * - Check-in Interval = 1 hour = 0x3840 quarterseconds.\n + * - Long Poll Interval = 5 seconds = 0x14 quarterseconds.\n + * - Short Poll Interval = 2 quarterseconds = 0x02 quarterseconds.\n + * - Fast Poll Timeout = 10 seconds = 0x28 quarterseconds.\n + * \n + * It should be noted that for the Check-in Interval, 0 is a special value and does not\n + * apply to this equation.\n + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] user_data user data + * + * @see zb_zcl_pollctrl_set_long_poll_interval() + * @see zb_zcl_pollctrl_set_short_poll_interval() + */ +typedef void (*zb_zcl_pollctrl_check_in)( + nwk_addr addr16, + unsigned char ep, + void *user_data); + +/* Table 9.29 Commands Generated by the Poll Control Client in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Check-in Response | M | + * | 0x00 | Fast Poll Stop | M | + * | 0x00 | Set Long Poll Interval | O | + * | 0x00 | Set Short Poll Interval | O | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Sends 'check-in response' + * @details The Check-in Response is sent in response to the receipt of a Check-in command.\n + * The Check-in Response is used by the Poll Control Client to indicate whether it + * would like the device implementing the Poll Control Cluster Server to go into a + * fast poll mode and for how long. If the Poll Control Cluster Client indicates that it + * would like the device to go into a fast poll mode, it is responsible for telling the + * device to stop fast polling when it is done sending messages to the fast polling + * device. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] start_fast_polling This Boolean value indicates whether or not the Poll + * Control Server device should begin fast polling or not.\n + * If the Start Fast Polling value is true, the server device + * is expected to begin fast polling until the Fast Poll + * Timeout has expired. If the Start Fast Polling argument + * is false, the Poll Control Server may continue in normal + * operation and is not required to go into fast poll mode.\n + * @param[in] fast_poll_timeout The Fast Poll Timeout value indicates the number of + * quarterseconds during which the device should continue + * fast polling. If the Fast Poll Timeout value is 0, the + * device is expected to continue fast polling until the + * amount of time indicated it the FastPollTimeout attribute + * has elapsed or it receives a Fast Poll Stop command\n + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_pollctrl_check_in_response( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char start_fast_polling, + unsigned short fast_poll_timeout); + +/** + * @brief Sends 'fast poll stop' command + * @details The Fast Poll Stop command is used to stop the fast poll mode initiated by the\n + * Check-in response. The Fast Poll Stop command has no payload. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_pollctrl_fast_poll_stop( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep); + +/** + * @brief Sends 'set long poll interval' command + * @details The Set Long Poll Interval command is used to set the read only LongPollInterval + * attribute.\n + * When the Poll Control Server receives the Set Long Poll Interval Command, it + * should check its internal minimal limit and the attributes relationship defined in + * 9.6.4.2 if the new Long Poll Interval is acceptable. If the new value is acceptable, + * the new value shall be saved to the LongPollInterval attribute.If the new value is + * not acceptable, the Poll Control Server shall send a default response of + * INVALID_VALUE (0x87) and the LongPollInterval attribute value is not updated.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] new_long_poll_interval long poll interval + * @param[in] cb Resopnse callback function + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_pollctrl_check_in() + * + */ +int zb_zcl_pollctrl_set_long_poll_interval( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned int new_long_poll_interval, + zb_zcl_pollctrl_check_in cb, + void *user_data); + +/** + * @brief Sends 'set short poll interval' command + * @details The Set Short Poll Interval command is used to set the read only + * ShortPollInterval attribute.\n + * When the Poll Control Server receives the Set Short Poll Interval Command, it + * should check its internal minimal limit and the attributes relationship defined in + * 9.6.4.2 if the new Short Poll Interval is acceptable. If the new value is acceptable, + * the new value shall be saved to the ShortPollInterval attribute. If the new value is + * not acceptable, the Poll Control Server shall send a default response of + * INVALID_VALUE (0x87) and the ShortPollInterval attribute value is not updated.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] new_short_poll_interval long poll interval + * @param[in] cb Resopnse callback function + * @param[in] user_data user_data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_pollctrl_check_in() + */ +int zb_zcl_pollctrl_set_short_poll_interval( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned int new_short_poll_interval, + zb_zcl_pollctrl_check_in cb, + void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_POLL_CONTROL_CLUSTER_H__ */ diff --git a/include/zcl/zb_zcl_scenes_cluster.h b/include/zcl/zb_zcl_scenes_cluster.h new file mode 100644 index 0000000..fc900ab --- /dev/null +++ b/include/zcl/zb_zcl_scenes_cluster.h @@ -0,0 +1,521 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_SCENES_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_SCENES_CLUSTER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zcl_scenes_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_SCENE_CLUSTER_MODULE Scene Cluster + * + * @brief Zigbee scene cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_SCENE_CLUSTER_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/* Table 3.38 Generated Command IDs for the Scenes Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Add scene response | M | + * | 0x01 | View scene response | M | + * | 0x02 | Remove scene response | M | + * | 0x03 | Remove all scene response | M | + * | 0x04 | Store scene response | M | + * | 0x05 | Reserved | - | + * | 0x06 | Get scene membership response | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Called after 'add scene' command + * @details This command is generated in response to a received Add Scene command. + * The Status field is set to SUCCESS, INSUFFICIENT_SPACE or + * INVALID_FIELD (the group is not present in the Group Table) as appropriate. + * The Group ID and Scene ID fields are set to the corresponding fields of the + * received Add Scene command. + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_NOT_FOUND \n + * #ZB_ZCL_INVALID_FIELD + * @param[out] group_id Group id + * @param[out] scene_id Scene id + * @param[out] user_data user data + * + * @see zb_zcl_group_add_scene() + */ +typedef void (*zb_zcl_scene_add_scene_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned short group_id, + unsigned char scene_id, + void *user_data); + +/** + * @brief Called after 'view scene' command + * @details This command is generated in response to a received View Scene command + * The entry in the Scene Table with Scene ID and Group ID given in the received + * View Scene command is located (if possible). The Status field is set to SUCCESS, + * NOT_FOUND (the scene is not present in the Scene Table) or INVALID_FIELD + * (the group is not present in the Group Table) as appropriate. The Group ID and + * Scene ID fields are set to the corresponding fields in the received View Scene + * command. + * If the status is SUCCESS, the Transition time, Scene Name and Extension field + * fields are copied from the corresponding fields in the table entry, otherwise they + * are omitted. + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_NOT_FOUND \n + * #ZB_ZCL_INVALID_FIELD + * @param[out] group_id Group id + * @param[out] scene_id Scene id + * @param[out] transition_time Transition time + * @param[out] scene_name Scene name + * @param[out] extension_field_sets Extension field sets, one per cluster\n + * Extension field sets =\n + * {{ClusterID 1, length 1, {extension field set 1}},\n + * {ClusterID 2, length 2, {extension field set 2}}, ... }. + * @param[out] ext_len length of extension fields set + * @param[out] user_data user data + * + * @see zb_zcl_group_view_scene() + */ +typedef void (*zb_zcl_scene_view_scene_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned short group_id, + unsigned char scene_id, + unsigned short transition_time, + const char *scene_name, + const char *extension_field_set, + unsigned short ext_len, + void *user_data); + +/** + * @brief Called after 'remove scene' command + * @details This command is generated in response to a received Remove Scene command. + * The Status field is set to SUCCESS, NOT_FOUND (the scene is not + * present in the Scene Table) or INVALID_FIELD (the group is not present in the + * Group Table) as appropriate. The Group ID and Scene ID fields are set to the + * corresponding fields of the received Remove Scene command. + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_INVALID_FIELD \n + * @param[out] group_id Group id + * @param[out] scene_id Scene id + * @param[out] user_data user data + * + * @see zb_zcl_group_remove_scene() + */ +typedef void (*zb_zcl_scene_remove_scene_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned short group_id, + unsigned char scene_id, + void *user_data); + +/** + * @brief Called after 'remove all scene' command + * @details This command is generated in response to a received Remove All Scenes + * command. The Status field is set to SUCCESS or INVALID_FIELD + * (the group is not present in the Group Table) as appropriate. The Group ID field is + * set to the corresponding field of the received Remove All Scenes command. + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_INVALID_FIELD \n + * @param[out] group_id Group id + * @param[out] scene_id Scene id + * @param[out] user_data user data + * + * @see zb_zcl_group_remove_all_scene() + */ +typedef void (*zb_zcl_scene_remove_all_scene_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned short group_id, + void *user_data); + +/** + * @brief Called after 'store scene' command + * @details This command is generated in response to a received Store Scene command. + * The Status field is set to SUCCESS, INSUFFICIENT_SPACE or + * INVALID_FIELD (the group is not present in the Group Table) as appropriate. + * The Group ID and Scene ID fields are set to the corresponding fields of the + * received Store Scene command. + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_INVALID_FIELD \n + * #ZB_ZCL_INSUFFICIENT_SPACE + * @param[out] group_id Group id + * @param[out] scene_id Scene id + * @param[out] user_data user data + * + * @see zb_zcl_group_store_scene() + */ +typedef void (*zb_zcl_scene_store_scene_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned short group_id, + unsigned char scene_id, + void *user_data); + +/** + * @brief Called after 'get all scene membership' command + * @details This command is generated in response to a received Get Scene Membership + * command + * + * @since_tizen 4.0 + * + * @param[out] addr16 Network address + * @param[out] ep Endpoint number + * @param[out] status Status code see zb_zcl_type.h\n + * #ZB_ZCL_SUCCESS \n + * #ZB_ZCL_INVALID_FIELD \n + * @param[out] capacity The Capacity field shall contain the remaining capacity of the \n + * scene table of the device. (for all groups). The following values\n + * apply:\n + * 0 : No further scenes may be added.\n + * 0 < Capacity < 0xfeCapacity holds the number of scenes that may be added\n + * 0xfe : At least 1 further scene may be added (exact number is unknown)\n + * 0xff : It is unknown if any further scenes may be added\n + * @param[out] group_id Group id + * @param[out] scene_count The Scene count field shall contain the number of scenes \n + * contained in the Scene list field. + * @param[out] scene_list The Scene list field shall contain the identifiers of all the \n + * scenes in the scene table with the corresponding Group ID. + * @param[out] user_data user data + * + * @see zb_zcl_scene_get_scene_membership() + */ +typedef void (*zb_zcl_scene_get_scene_membership_rsp)( + nwk_addr addr16, + unsigned char ep, + unsigned char status, + unsigned char capacity, + unsigned short group_id, + unsigned char scene_count, + unsigned char *scene_list, + void *user_data); + +/* Table 3.37 Received Command IDs for the Scenes Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Add scene | M | + * | 0x01 | View scene | M | + * | 0x02 | Remove scene | M | + * | 0x03 | Remove all scene | M | + * | 0x04 | Store scene | M | + * | 0x05 | Recall scene | M | + * | 0x06 | Get scene membership | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/* Reference : Extension field sets = + * {{ClusterID 1, length 1, {extension field set 1}}, {ClusterID 2, length 2, + * {extension field set 2}}, ... }. + */ + +/** + * @brief Sends 'add scenes' command + * @details The Add Scene command shall be addressed to a single device (not a group) + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] group_id Group ID + * @param[in] scene_id Scene ID + * @param[in] transition_time Transition time + * @param[in] scene_name Scene name + * @param[in] ext_field_len length of extension fields sets + * @param[in] extension_field_sets Extension field sets, one per cluster\n + * Extension field sets = \n + * {{ClusterID 1, length 1, {extension field set 1}}, \n + * {ClusterID 2, length 2, {extension field set 2}}, ... }. + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_scene_add_scene_rsp() + */ +int zb_zcl_scene_add_scene( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + unsigned char scene_id, + unsigned short transition_time, + const char *scene_name, + unsigned short ext_field_len, + const char *extension_field_sets, + zb_zcl_scene_add_scene_rsp cb, + void *user_data); + +/** + * @brief Sends 'view scene' command + * @details The View Scene command shall be addressed to a single device (not a group) + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] group_id Group ID + * @param[in] scene_id Scene ID + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_scene_view_scene_rsp() + */ +int zb_zcl_scene_view_scene( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + unsigned char scene_id, + zb_zcl_scene_view_scene_rsp cb, + void *user_data); + +/** + * @brief Sends 'remove scene' command + * @details The Remove Scene command may be addressed to a single device or to a group. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] group_id Group ID + * @param[in] scene_id Scene ID + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_scene_view_scene_rsp() + */ +int zb_zcl_scene_remove_scene( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + unsigned char scene_id, + zb_zcl_scene_remove_scene_rsp cb, + void *user_data); + +/** + * @brief Sends 'remove all scenes' command + * @details The Remove All Scenes may be addressed to a single device or to a group. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] group_id Group ID + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_scene_remove_all_scene_rsp() + */ +int zb_zcl_scene_remove_all_scene( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + zb_zcl_scene_remove_all_scene_rsp cb, + void *user_data); + +/** + * @brief Sends 'store scene' command + * @details The Store Scene command may be addressed to a single device or to a group. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] group_id Group ID + * @param[in] scene_id Scene ID + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_scene_store_scene_rsp() + */ +int zb_zcl_scene_store_scene( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + unsigned char scene_id, + zb_zcl_scene_store_scene_rsp cb, + void *user_data); + +/** + * @brief Sends 'recall scene' command + * @details The Recall Scene command may be addressed to a single device or to a group. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] group_id Group ID + * @param[in] scene_id Scene ID + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + */ +int zb_zcl_scene_recall_scene( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + unsigned char scene_id); + +/** + * @brief Sends 'get scenes membership' command + * @details The Get Scene Membership command can be used to find an unused scene + * number within the group when no commissioning tool is in the network, or for a + * commissioning tool to get used scenes for a group on a single device or on all + * devices in the group. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] group_id Group ID + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zcl_scene_store_scene_rsp() + */ +int zb_zcl_scene_get_scene_membership( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned short group_id, + zb_zcl_scene_get_scene_membership_rsp cb, + void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_SCENES_CLUSTER_H__ */ + diff --git a/include/zcl/zb_zcl_thermostat_cluster.h b/include/zcl/zb_zcl_thermostat_cluster.h new file mode 100644 index 0000000..dade763 --- /dev/null +++ b/include/zcl/zb_zcl_thermostat_cluster.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_THERMOSTAT_CLUSTER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_THERMOSTAT_CLUSTER_H__ + +#include + +/** + * @file zb_zcl_thermostat_cluster.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_COMMAND_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZCL_THERMOSTAT_MODULE Thermostat Cluster + * + * @brief Zigbee thermostat cluster description + * + * @section CAPI_NETWORK_ZIGBEE_ZCL_THERMOSTAT_MODULE_HEADER Header + * \#include + * + * @since_tizen 4.0 + * + * @{ + */ + +/* Table 6.18 Command IDs for the Thermostat Cluster in Zigbee Cluster Library + * +--------------------------------+--------------------------------------+------------+ + * |Command Identifier Field Value | Description | Mandatory/ | + * | | | Optional | + * +--------------------------------+--------------------------------------+------------+ + * | 0x00 | Setpoint Raise/Lower | M | + * +--------------------------------+--------------------------------------+------------+ + */ + +/** + * @brief Sends 'setpoint raise/lower' command + * @details The attributes for the indicated setpoint(s) shall be increased by the amount + * specified in the Amount field. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address + * @param[in] ep Endpoint ID + * @param[in] mode The mode field shall be set to one of the non-reserved values in below. It + * specifies which setpoint is to be configured. If it is set to auto, then both setpoints + * shall be adjusted.\n + * 0x00 : Heat (adjust Heat setpoint)\n + * 0x01 : Cool (adjust Cool setpoint)\n + * 0x02 : Both (adjust Heat and Cool setpoint)\n + * @param[in] amount The amount field is a signed 8-bit integer that specifies the amount the setpoint(s) + * are to be a increased (or decreased) by, in steps of 0.1C + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE Out of range error + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + */ +int zb_zcl_thermostat_adjust_setpoint( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + unsigned char mode, + unsigned char amount); + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_THERMOSTAT_CLUSTER_H__ */ + diff --git a/include/zcl/zb_zcl_type.h b/include/zcl/zb_zcl_type.h new file mode 100644 index 0000000..b8da9cf --- /dev/null +++ b/include/zcl/zb_zcl_type.h @@ -0,0 +1,297 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZCL_TYPE_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZCL_TYPE_H__ + +#include +#include + +/** + * @file zb_zcl_type.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief ACL type + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_WRITABLE = 1, /**< Writable */ + ZB_ZCL_REPORTABLE = 2, /**< Reportable */ +} zb_zcl_acl_type_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief data measuring type + * + * @since_tizen 4.0 + */ +typedef enum { + DATA_TYPE_NONE = 0, /**< Data type none */ + DATA_TYPE_DISCRETE = 1, /**< Discrete data type */ + DATA_TYPE_ANALOG = 2 /**< Analog data type */ +} zb_zcl_data_category_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief ZCL Enumerations Description in Zigbee Cluster Library + * see. http://www.zigbee.org/download/standards-zigbee-cluster-library/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZCL_SUCCESS = 0x00, /**< Operation was successful */ + ZB_ZCL_FAILURE = 0x01, /**< Operation was not successful. */ + /**< The sender of the command does not have authorization to carry out this command. */ + ZB_ZCL_NOT_AUTHORIZED = 0x7E, + /**< reserved field/subfield/bit contains a non-zero value. */ + ZB_ZCL_RESERVED_FIELD_NOT_ZERO = 0x7F, + /**< The command appears to contain the wrong fields, as + detected either by the presence of one or more invalid + field entries or by there being missing fields. Command + not carried out. Implementer has discretion as to + whether to return this error or INVALID_FIELD. */ + ZB_ZCL_MALFORMED_COMMAND = 0x80, + /**< The specified cluster command is not supported on the device. */ + ZB_ZCL_UNSUP_CLUSTER_COMMAND = 0x81, + /**< The specified general ZCL command is not supported on the device. */ + ZB_ZCL_UNSUP_GENERAL_COMMAND = 0x82, + /**< A manufacturer specific unicast, cluster specific + command was received with an unknown manufacturer + code, or the manufacturer code was recognized but the + command is not supported. */ + ZB_ZCL_UNSUP_MANUF_CLUSTER_COMMAND = 0x83, + /**< A manufacturer specific unicast, ZCL specific command + was received with an unknown manufacturer code, or + the manufacturer code was recognized but the command + is not supported. */ + ZB_ZCL_UNSUP_MANUF_GENERAL_COMMAND = 0x84, + /**< At least one field of the command contains an incorrect + value, according to the specification the device is + implemented to. */ + ZB_ZCL_INVALID_FIELD = 0x85, + /**< The specified attribute does not exist on the device. */ + ZB_ZCL_UNSUPPORTED_ATTRIBUTE = 0x86, + /**< Out of range error, or set to a reserved value. Attribute + keeps its old value. + Note that an attribute value may be out of range if an + attribute is related to another, e.g. with minimum and + maximum attributes. See the individual attribute + descriptions for specific details. */ + ZB_ZCL_INVALID_VALUE = 0x87, + /**< Attempt to write a read only attribute. */ + ZB_ZCL_READ_ONLY = 0x88, + /**< An operation (e.g. an attempt to create an entry in a + table) failed due to an insufficient amount of free space + available. */ + ZB_ZCL_INSUFFICIENT_SPACE = 0x89, + /**< An attempt to create an entry in a table failed due to a + duplicate entry already being present in the table. */ + ZB_ZCL_DUPLICATE_EXISTS = 0x8A, + /**< The requested information (e.g. table entry) could not be found. */ + ZB_ZCL_NOT_FOUND = 0x8B, + /**< Periodic reports cannot be issued for this attribute. */ + ZB_ZCL_UNREPORTABLE_ATTRIBUTE = 0x8C, + /**< The data type given for an attribute is incorrect. + Command not carried out. */ + ZB_ZCL_INVALID_DATA_TYPE = 0x8D, + /**< The selector for an attribute is incorrect. */ + ZB_ZCL_INVALID_SELECTOR = 0x8E, + /**< A request has been made to read an attribute that the + requestor is not authorized to read. No action taken. */ + ZB_ZCL_WRITE_ONLY = 0x8F, + /**< Setting the requested values would put the device in an + inconsistent state on startup. No action taken. */ + ZB_ZCL_INCONSISTENT_STARTUP_STATE = 0x90, + /**< An attempt has been made to write an attribute that is + present but is defined using an out-of-band method and + not over the air. */ + ZB_ZCL_DEFINED_OUT_OF_BAND = 0x91, + /**< The supplied values (e.g. contents of table cells) are + inconsistent. */ + ZB_ZCL_INCONSISTENT = 0x92, + /**< The credentials presented by the device sending the + command are not sufficient to perform this action. */ + ZB_ZCL_ACTION_DENIED = 0x93, + /**< The exchange was aborted due to excessive response time. */ + ZB_ZCL_TIMEOUT = 0x94, + /**< Failed case when a client or a server decides to abort the + upgrade process. */ + ZB_ZCL_ABORT = 0x95, + /**< Invalid OTA upgrade image (ex. failed signature + validation or signer information check or CRC check). */ + ZB_ZCL_INVALID_IMAGE = 0x96, + /**< Server does not have data block available yet. */ + ZB_ZCL_WAIT_FOR_DATA = 0x97, + /**< No OTA upgrade image available for a particular client. */ + ZB_ZCL_NO_IMAGE_AVAILABLE = 0x98, + /**< The client still requires more OTA upgrade image files + in order to successfully upgrade. */ + ZB_ZCL_REQUIRE_MORE_IMAGE = 0x99, +} zb_zcl_status_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Discover Attribute Info Record in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct discover_attribute_info_record_s* discover_attr_info_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Structure for Read Structured Attribute Record in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct read_structured_attribute_record_s* read_structured_attr_record_h; + + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Attribute Status Record in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct read_attribute_status_record_s* read_attr_status_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Write Attributes Data Structure in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct write_attribute_record_s* write_attr_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Write Attribute Status Record Field in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct write_attribute_status_record_s* write_attr_status_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Write Attribute Record Field in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct write_attribute_structured_status_record_s* write_attr_structured_status_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Write Attribute Record Field in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct write_attribute_structured_record_s* write_attr_structured_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Attribute Report Fields in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct attribute_report_s* attr_report_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of Reporting Configuration Record Structure in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct reporting_configuration_record_s* report_config_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of Read Reporting Configuration Record in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct read_reporting_configuration_record_s* read_report_config_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Attribute Status Record Field in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct reporting_configuration_response_record_s* report_config_response_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of the Extended Attribute Information Fields in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct extended_attribute_infomation_s* extended_attr_info_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief simple data type in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct zb_value_s* zb_value_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Format of Attribute Value Field for an array, Set or Bag in Zigbee Cluster Library + * + * @since_tizen 4.0 + */ +typedef struct attribute_array_s* attribute_array_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZCL_MODULE + * @brief Global record type + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_GLOBAL_READ_ATTR = 0, /**< Read attributes type */ + ZB_GLOBAL_WRITE_ATTR, /**< Write attributes type */ + ZB_GLOBAL_CONFIG_REPORT, /**< Configure reporting type */ + ZB_GLOBAL_READ_REPORT_CONFIG, /**< Read reporting config type */ + ZB_GLOBAL_WRITE_ATTR_STRUCTURED/**< Write attributes structued type */ +} zb_zcl_global_record_e; + +/** + * @brief The structure type for record data of zigbee global request. + * @details This structure contains record data of zigbee global request. + * ex) Read/Write attributes response, Configure reporting response. + * + * @since_tizen 4.0 + */ +typedef struct { + zb_zcl_global_record_e type; + union { + read_attr_status_record_h *read_attr; /**< Attribute Reporting Configuration Record */ + write_attr_status_record_h *write_attr; /**< For write attribute response command */ + report_config_response_record_h *report_config_rsp; /**< Attribute Status Record Field */ + report_config_record_h *report_config; /**< Reporting configuration record structure */ + write_attr_structured_record_h *write_attr_structured; /**< Write Attribute Record Field */ + } record; + int records_len; /**< The number of records */ +} zb_global_record_data_s; + +/** + * @} + */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZCL_TYPE_H__ */ diff --git a/include/zdo/zb-zdo-bind-mgr.h b/include/zdo/zb-zdo-bind-mgr.h deleted file mode 100644 index 2a83866..0000000 --- a/include/zdo/zb-zdo-bind-mgr.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_BIND_MANAGER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZDO_BIND_MANAGER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zdo-bind-mgr.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_BINDING_MANAGER_MODULE Binding Manager - * - * @brief zigbee provides API for Binding. - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_BINDING_MANAGER_HEADER Header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_BINDING_MANAGER_OVERVIEW Overview - * This API set consists of ZDP device discovery API - * - * @{ - */ - -/** - * @brief Bind response - * @details The Bind_rsp is generated in response to a Bind_req. If the Bind_req is - * processed and the Binding Table entry committed on the Remote Device, a Status of - * SUCCESS is returned.\n\n If the Remote Device is not a Primary binding table cache - * or the SrcAddress, a Status of NOT_SUPPORTED is returned.\n\n The supplied - * endpoint shall be checked to determine whether it falls within the specified range. - * If it does not, a Status of INVALID_EP shall be returned.\n\n If the Remote Device is - * the Primary binding table cache or SrcAddress but does not have Binding Table - * resources for the request, a Status of TABLE_FULL is returned. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * #ZB_ZDP_INVALID_EP \n - * #ZB_ZDP_TABLE_FULL \n - * #ZB_ZDP_NOT_AUTHORIZED \n - * @param[out] user_data user data - * - * @see zb_zdo_bind_req() - * - */ -typedef void (*zb_zdo_bind_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Binding request when destination address present but not endpoint present - * @details The Bind_req is generated from a Local Device wishing to create a Binding - * Table entry for the source and destination addresses contained as parameters.\n\n The - * destination addressing on this command shall be unicast only, and the destination - * address shall be that of a Primary binding table cache or to the SrcAddress itself. - * The Binding Manager is optionally supported on the source device (unless that - * device is also the ZigBee Coordinator) so that device shall issue a - * NOT_SUPPORTED status to the Bind_req if not supported. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] dst_addr16 The Network address of destination - * @param[in] src_addr64 The IEEE address of source - * @param[in] src_ep The source endpoint for the binding entry - * @param[in] cluster_id The identifier of the cluster on the source device that is bound - * to the destination. - * @param[in] dst_addr64 The IEEE address of destination - * @param[in] type ZB_UNICAST_BINDING : A unicast binding whose 64-bit identifier is the - * destination ieee_addr. \n - * ZB_MANY_TO_ONE_BINDING : A unicast binding whose 64-bit identifier is - * the many-to-one destination ieee_addr. - * A Route discovery should be disabled when - * sending unicast via may-to-one binding \n - * ZB_MULTICAST_BINDING : A multicast binding whose 64-bit identifier is - * the group address. A multicast binding can be - * used to send messages to the group and to - * receive message sent to the group - * @param[in] group_addr The destination address for the binding entry - * @param[in] dst_ep The destination endpoint for the binding entry. - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_bind_rsp() - */ -int zb_zdo_bind_req( - zigbee_h handle, - nwk_addr dst_addr16, - ieee_addr src_addr64, - unsigned char src_ep, - unsigned short cluster_id, - ieee_addr dst_addr64, - unsigned char type, - nwk_addr group_addr, - unsigned char dst_ep, - zb_zdo_bind_rsp cb, - void *user_data); - -/** - * @brief Unbind response - * @details The Unbind_rsp is generated in response to an Unbind_req. If the Unbind_req is - * processed and the corresponding Binding Table entry is removed from the Remote - * Device, a Status of SUCCESS is returned. If the Remote Device is not the ZigBee - * Coordinator or the SrcAddress, a Status of NOT_SUPPORTED is returned.\n\n The - * supplied endpoint shall be checked to determine whether it falls within the - * specified range. If it does not, a Status of INVALID_EP shall be returned If the - * Remote Device is the ZigBee Coordinator or SrcAddress but does not have a - * Binding Table entry corresponding to the parameters received in the request, a - * Status of NO_ENTRY is returned. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * #ZB_ZDP_INVALID_EP \n - * #ZB_ZDP_NO_ENTRY \n - * #ZB_ZDP_NOT_AUTHORIZED - * @param[out] user_data user data - * - * @see zb_zdo_unbind_req_addr() - * - */ -typedef void (*zb_zdo_unbind_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Binding request when destination address present but not endpoint present - * @details The Unbind_req is generated from a Local Device wishing to remove a Binding - * Table entry for the source and destination addresses contained as parameters.\n\n The - * destination addressing on this command shall be unicast only and the destination - * address must be that of the a Primary binding table cache or the SrcAddress. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] dst_addr16 The Network address of destination - * @param[in] src_addr64 The IEEE address of source - * @param[in] src_ep The source endpoint for the binding entry - * @param[in] cluster_id The identifier of the cluster on the source device that is bound - * to the destination. - * @param[in] dst_addr64 The IEEE address of destination - * @param[in] type #ZB_UNICAST_BINDING : A unicast binding whose 64-bit identifier is the - * destination ieee_addr. \n - * #ZB_MANY_TO_ONE_BINDING : A unicast binding whose 64-bit identifier is - * the many-to-one destination ieee_addr. - * A Route discovery should be disabled when - * sending unicast via may-to-one binding \n - * #ZB_MULTICAST_BINDING : A multicast binding whose 64-bit identifier is - * the group address. A multicast binding can be - * used to send messages to the group and to - * receive message sent to the group - * @param[in] group_addr The destination address for the binding entry - * @param[in] dst_ep The destination endpoint for the binding entry. - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_unbind_rsp() - * - */ -int zb_zdo_unbind_req( - zigbee_h handle, - nwk_addr dst_addr16, - ieee_addr src_addr64, - unsigned char src_ep, - unsigned short cluster_id, - ieee_addr dst_addr64, - unsigned char type, - nwk_addr group_addr, - unsigned char dst_ep, - zb_zdo_unbind_rsp cb, - void *user_data); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_BIND_MANAGER_H__ */ diff --git a/include/zdo/zb-zdo-config.h b/include/zdo/zb-zdo-config.h deleted file mode 100644 index c32a7ca..0000000 --- a/include/zdo/zb-zdo-config.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_CONFIG_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZDO_CONFIG_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * @file zb-zdo-config.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_MODULE_ZDO_MODULE - * @brief zigbee configuration API. - * @since_tizen 3.0 - * - * @{ - */ - -/** - * @brief Set start-up attribute set - * @details In order to ensure interoperability, all ZigBee HA devices should implement - * compatible Startup Attribute Sets (SAS). This does not mean that set must be - * modifiable through a commissioning cluster, but that the device must internally - * implement these stack settings to ensure compatibility and consistent user - * experience. The start up set parameters described by the Commissioning cluster - * provide a good basis to specify a HA startup set. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] pan_id Short address - * @param[in] epan_id Usually 00-50-C2-77-10-00-00-00 is the global commissioning EPID - * @param[in] channel_mask - * @param[in] start_control - * @param[in] trust_center_addr - * @param[in] master_key - * @param[in] master_key_len - * @param[in] network_key - * @param[in] network_key_len - * @param[in] default_link_key_join - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - */ -int zb_zdo_set_compatible_startup_parameters( - zigbee_h handle, - nwk_addr pan_id, /* default : NULL (0xFFFF) */ - ieee_addr epan_id, /* default : NULL (0x0000000000000000) */ - unsigned int channel_mask, /* default : NULL (0x07FFF800) */ - unsigned char start_control, /* default : 3 (un-comissioned, simlely push end-device's button when joining) */ - ieee_addr trust_center_addr, /* default : NULL (0x0000000000000000) */ - const unsigned char *master_key, /* default : NULL */ - unsigned char master_key_len, /* default : 0 */ - const unsigned char *network_key, /* default : NULL */ - unsigned char network_key_len, /* default : 0 */ - unsigned char default_link_key_join /* default : 0 */ - ); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_CONFIG_H__ */ - diff --git a/include/zdo/zb-zdo-dev-disc.h b/include/zdo/zb-zdo-dev-disc.h deleted file mode 100644 index e4c3c16..0000000 --- a/include/zdo/zb-zdo-dev-disc.h +++ /dev/null @@ -1,1084 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zdo-dev-disc.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_MODULE Device Discovery - * - * @brief zigbee provides API for Device Discovery. - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_HEADER Header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_OVERVIEW Overview - * This API set consists of ZDP device discovery API - * - * @{ - */ - - -/** - * @brief Network / IEEE address response - * @details The NWK_addr_rsp is generated by a Remote Device in response to a\n - * NWK_addr_req or IEEE_addr_req command inquiring as to the NWK address of the Remote - * Device or the NWK address of an address held in a local discovery cache.\n - * The destination addressing on this command is unicast.\n - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_DEVICE_NOT_FOUND - * @param[out] remote_dev_addr64 64-bit address for the remote device - * @param[out] remote_dev_addr16 16-bit address for the remote device - * @param[out] num_of_assoc_dev Count of the number of 16-bit short addresses to follow. - * If the RequestType in the request is Extended Response - * and there are no associated devices on the Remote Device, - * this field shall be set to 0. - * If an error occurs or the RequestType in the request is - * for a Single Device Response, this field shall not - * be included in the frame. - * @param[out] start_idx Starting index into the list of associated devices for this - * report. If the RequestType in the request is Extended Response - * and there are no associated devices on the Remote Device, - * this field shall not be included in the frame. - * If an error occurs or the RequestType in the request is - * for a Single Device Response, this field shall not - * be included in the frame. - * @param[out] assoc_dev_addr_list A list of 16-bit addresses, one corresponding to each - * associated device to Remote Device; The number of 16-bit - * network addresses contained in this field is specified - * in the NumAssocDev field. - * If the RequestType in the request is Extended Response - * and there are no associated devices on the Remote Device, - * this field shall not be included in the frame. - * If an error occurs or the RequestType in the request is - * for a Single Device Response, this field shall not - * be included in the frame. - * @param[out] user_data user data - * - * @see zb_zdo_nwk_addr_req() - */ -typedef void (*zb_zdo_addr_rsp)( - unsigned char status, - ieee_addr remote_dev_addr64, - nwk_addr remote_dev_addr16, - unsigned char num_of_assoc_dev, - unsigned char start_idx, - unsigned short *assoc_dev_addr_list, - void *user_data); - -/** - * @brief Network address request - * @details The NWK_addr_req is generated from a Local Device wishing to inquire as to the\n - * 16-bit address of the Remote Device based on its known IEEE address. The\n - * destination addressing on this command shall be unicast or broadcast to all\n - * devices for which macRxOnWhenIdle = TRUE.\n - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr64 IEEE address for device of interest - * @param[in] request_type \n - * 0x00 - Single device response \n - * 0x01 - Extended response \n - * @param[in] start_idx If the Request type for this command is Extended response, - * is StartIndex provides the starting index for the requested - * elements of the associated devices list - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_nwk_addr_rsp() - */ -int zb_zdo_nwk_addr_req( - zigbee_h handle, - ieee_addr addr64, - unsigned char request_type, - unsigned char start_idx, - zb_zdo_addr_rsp cb, - void *user_data); - -/** - * @brief IEEE address request - * @details The IEEE_addr_req is generated from a Local Device wishing to inquire as to - * the 64-bit IEEE address of the Remote Device based on their known 16-bit address. - * The destination addressing on this command shall be unicast. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_ieee_addr_rsp() - */ -int zb_zdo_ieee_addr_req( - zigbee_h handle, - nwk_addr addr16, - zb_zdo_addr_rsp cb, - void *user_data); - -/** - * @brief Active endpoint response - * @details The Active_EP_rsp is generated by a remote device in response to an - * Active_EP_req directed to the remote device. This command shall be unicast to - * the originator of the Active_EP_req command.\n\n - * The remote device shall generate the Active_EP_rsp command using the format - * illustrated param list. The NWKAddrOfInterest field shall match that specified - * in the original Active_EP_req command. If the NWKAddrOfInterest field - * matches the network address of the remote device, it shall set the Status field to - * SUCCESS, set the ActiveEPCount field to the number of active endpoints on that - * device and include an ascending list of all the identifiers of the active endpoints on - * that device in the ActiveEPList field.\n\n - * If the NWKAddrOfInterest field does not match the network address of the - * remote device and it is an end device, it shall set the Status field to - * INV_REQUESTTYPE, set the ActiveEPCount field to 0, and not include the - * ActiveEPList field.\n\n If the NWKAddrOfInterest field does not match the network - * address of the remote device and it is the coordinator or a router, it shall determine - * whether the NWKAddrOfInterest field matches the network address of a device it - * holds in a discovery cache. \n\n If the NWKAddrOfInterest field does not match the - * network address of a device it holds in a discovery cache, it shall set the Status - * field to DEVICE_NOT_FOUND, set the ActiveEPCount field to 0, and not - * include the ActiveEPList field.\n\n If the NWKAddrOfInterest matches the network - * address of a device held in a discovery cache on the remote device, it shall - * determine whether that device has any active endpoints. If the discovery - * information corresponding to the ActiveEP request has not yet been uploaded to - * the discovery cache, the remote device shall set the Status field to - * NO_DESCRIPTOR, set the ActiveEPCount field to 0 and not include the - * ActiveEPList field.\n\n If the cached device has no active endpoints, the remote - * device shall set the Status field to SUCCESS, set the ActiveEPCount field to 0, - * and not include the ActiveEPList field.\n\n If the cached device has active endpoints, - * the remote device shall set the Status field to SUCCESS, set the ActiveEPCount - * field to the number of active endpoints on that device, and include an ascending - * list of all the identifiers of the active endpoints on that device in the ActiveEPList - * field . - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_DEVICE_NOT_FOUND \n - * #ZB_ZDP_NO_DESCRIPTOR \n - * @param[out] addr16 Network address for the request - * @param[out] count The count of active endpoint on the remote device - * @param[out] ep_list List of bytes each of which represents an 8-bit endpoint - * @param[out] user_data user data - * - * @see zb_zdo_active_ep() - */ -typedef void (*zb_zdo_active_ep_rsp)( - unsigned char status, - nwk_addr addr16, - unsigned char count, - unsigned char *ep_list, - void *user_data); - -/** - * @brief Active EP request - * @details The Active_EP_req command is generated from a local device wishing to acquire - * the list of endpoints on a remote device with simple descriptors. This command - * shall be unicast either to the remote device itself or to an alternative device that - * contains the discovery information of the remote device.\n\n - * The local device shall generate the Active_EP_req command using the format - * illustrated in param list. The NWKAddrOfInterest field shall contain the network - * address of the remote device for which the active endpoint list is required. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_active_ep_rsp() - */ -int zb_zdo_active_ep( - zigbee_h handle, - nwk_addr addr16, - zb_zdo_active_ep_rsp cb, - void *user_data); - -/** - * @brief Simple descriptor response - * @details The Simple_Desc_rsp is generated by a remote device in response to a - * Simple_Desc_req directed to the remote device. This command shall be unicast to - * the originator of the Simple_Desc_req command. - * The remote device shall generate the Simple_Desc_rsp command using the format - * illustrated in Table 2.94. The NWKAddrOfInterest field shall match that specified - * in the original Simple_Desc_req command. If the endpoint field specified in the - * original Simple_Desc_req command does not fall within the correct range - * specified in param list, the remote device shall set the Status field to - * INVALID_EP, set the Length field to 0 and not include the SimpleDescriptor - * field.\n\n - * If the NWKAddrOfInterest field matches the network address of the remote - * device, it shall determine whether the endpoint field specifies the identifier of an - * active endpoint on the device. If the endpoint field corresponds to an active - * endpoint, the remote device shall set the Status field to SUCCESS, set the Length - * field to the length of the simple descriptor on that endpoint, and include the simple - * descriptor for that endpoint in the SimpleDescriptor field. - * If the endpoint field does not correspond to an active endpoint, the remote device - * shall set the Status field to NOT_ACTIVE, set the Length field to 0, and not - * include the SimpleDescriptor field.\n\n - * If the NWKAddrOfInterest field does not match the network address of the - * remote device and it is an end device, it shall set the Status field to - * INV_REQUESTTYPE, set the Length field to 0, and not include the - * SimpleDescriptor field. If the NWKAddrOfInterest field does not match the - * network address of the remote device and it is the coordinator or a router, it shall - * determine whether the NWKAddrOfInterest field matches the network address of - * one of its children. If the NWKAddrOfInterest field does not match the network - * address of one of the children of the remote device, it shall set the Status field to - * DEVICE_NOT_FOUND, set the Length field to 0, and not include the - * SimpleDescriptor field.\n\n - * If the NWKAddrOfInterest matches the network address of one of the children of - * the remote device, it shall determine whether a simple descriptor for that device - * and on the requested endpoint is available. If a simple descriptor is not available - * on the requested endpoint of the child indicated by the NWKAddrOfInterest field, - * the remote device shall set the Status field to NO_DESCRIPTOR, set the Length - * field to 0, and not include the SimpleDescriptor field. If a simple descriptor is - * available on the requested endpoint of the child indicated by the - * NWKAddrOfInterest field, the remote device shall set the Status field to - * SUCCESS, set the Length field to the length of the simple descriptor on that - * endpoint, and include the simple descriptor for that - * endpoint of the matching child device in the SimpleDescriptor field. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INVALID_EP \n - * #ZB_ZDP_NOT_ACTIVE \n - * #ZB_ZDP_DEVICE_NOT_FOUND \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_NO_DESCRIPTOR - * @param[out] addr16 Network address for the request - * @param[out] len Length in bytes of the simple descriptor to follow - * @param[out] handle Simple descriptor structure this filed shall only be included - * in the frame if the status field is equal to ZB_ZDP_SUCCESS - * @param[out] user_data user data - * - * @see zb_zdo_simple_desc_req() - */ -typedef void (*zb_zdo_simple_desc_rsp)( - nwk_addr addr16, - unsigned char len, - const zb_zdo_simple_desc_h handle, - void *user_data); - -/** - * @brief Simple descriptor request - * @details The Simple_Desc_req command is generated from a local device wishing to - * inquire as to the simple descriptor of a remote device on a specified endpoint. This - * command shall be unicast either to the remote device itself or to an alternative - * device that contains the discovery information of the remote device.\n\n - * The local device shall generate the Simple_Desc_req command using the format - * illustrated in param list. The NWKAddrOfInterest field shall contain the network - * address of the remote device for which the simple descriptor is required and the - * endpoint field shall contain the endpoint identifier from which to obtain the - * required simple descriptor. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] ep The endpoint on the destination - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_simple_desc_rsp() - */ -int zb_zdo_simple_desc_req( - zigbee_h handle, - nwk_addr addr16, - unsigned char ep, - zb_zdo_simple_desc_rsp cb, - void *user_data); - -#ifdef ZB_SUPPORT_PRIORITY_5 -/** - * @brief Extended simple descriptor response - * @details The Extended_Simple_Desc_rsp is generated by a remote device in response to an - * Extended_Simple_Desc_req directed to the remote device. This command shall - * be unicast to the originator of the Extended_Simple_Desc_req command. - * The remote device shall generate the Extended_Simple_Desc_rsp command using - * the format illustrated in param list. The NWKAddrOfInterest field shall match - * that specified in the original Extended_Simple_Desc_req command. If the - * endpoint field specified in the original Extended_Simple_Desc_req command - * does not fall within the correct range specified in Table 2.49, the remote device - * shall set the Status field to INVALID_EP, set the Endpoint and StartIndex fields to - * their respective values supplied in the request, and not include the AppClusterList - * field.\n\n - * If the NWKAddrOfInterest field matches the network address of the remote - * device, it shall determine whether the endpoint field specifies the identifier of an - * active endpoint on the device.\n\n If the endpoint field corresponds to an active - * endpoint, the remote device shall set the Status field to SUCCESS, set the - * AppClusterList field to the sequence of octets from the concatenated AppInput - * ClusterList and AppOutputClusterList from the Simple Descriptor (Tables 2.39), - * and supply that field as AppClusterList in the response. Note that dependent on - * the value of StartIndex in the request, the results in AppClusterList may be empty - * (for example, the StartIndex begins after the sequence of octets given by the - * concatenation of AppInputClusterList and AppOutputClusterList).\n\n If the endpoint - * field does not correspond to an active endpoint, the remote device shall set the - * Status field to NOT_ACTIVE, set the StartIndex field to the value supplied in the - * request, and not include the AppClusterList field. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INVALID_EP \n - * #ZB_ZDP_NOT_ACTIVE \n - * #ZB_ZDP_DEVICE_NOT_FOUND \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_NO_DESCRIPTOR - * @param[out] addr16 Network address for the request - * @param[out] ep The endpoint on the destination - * @param[out] app_input_cluster_count The total count of application input cluster in - * the simple descriptor for this endpoint - * @param[out] app_output_cluster_count The total count of application output cluster in - * the simple descriptor for this endpoint - * @param[out] start_idx Starting index within the AppClusterList of the response - * represented by an ordered list of the Application Input - * Cluster List and Application Output Cluster List from the - * Simple Descriptor for this endpoint. - * @param[out] app_cluster_list A concatenated, ordered list of the AppInputClusterList - * and AppOutputClusterList, beginning with StartIndex, - * from the Simple Descriptor. - * This field shall only be included in the frame if the - * status field is equal to ZB_ZDP_SUCCESS. - * @param[out] user_data user data - * - * @see zb_zdo_extended_simple_desc_req() - */ -typedef void (*zb_zdo_extended_simple_desc_rsp)( - unsigned char status, - nwk_addr addr16, - unsigned char ep, - unsigned char app_input_cluster_count, - unsigned char app_output_cluster_count, - unsigned char start_idx, - const unsigned char *app_cluster_list, - void *user_data); - -/** - * @brief Extended simple descriptor request - * @details The Extended_Active_EP_req command is generated from a local device wishing - * to acquire the list of endpoints on a remote device with simple descriptors. This - * command shall be unicast either to the remote device itself or to an alternative - * device that contains the discovery information of the remote device.n\n The - * Extended_Active_EP_req is used for devices which support more active - * endpoints than can be returned by a single Active_EP_req. - * The local device shall generate the Extended_Active_EP_req command using the - * format illustrated in Table 2.66.\n\n The NWKAddrOfInterest field shall contain the - * network address of the remote device for which the active endpoint list is - * required.\n\n The StartIndex field shall be set in the request to enable retrieval of - * lists of active endpoints from devices whose list exceeds the size of a single ASDU and - * where fragmentation is not supported. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] start_idx Starting index within the active endpoint list in the response - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_extended_simple_desc_rsp() - */ -int zb_zdo_extended_simple_desc_req( - zigbee_h handle, - nwk_addr addr16, - unsigned char start_idx, - zb_zdo_extended_simple_desc_rsp cb, - void *user_data); - -#endif /* ZB_SUPPORT_PRIORITY_5 */ - -/** - * @brief Matching descriptor response - * @details The Match_Desc_rsp is generated by a remote device in response to a - * Match_Desc_req either broadcast or directed to the remote device. This command - * shall be unicast to the originator of the Match_Desc_req command. - * The remote device shall generate the Match_Desc_rsp command using the format - * illustrated in Table 2.96. If the NWKAddrOfInterest field of the original - * Match_Desc_req was equal to the broadcast network address for all devices for - * which macRxOnWhenIdle = TRUE (0xfffd), the remote device shall apply the - * match criterion, as described below, that was specified in the original - * Match_Desc_req command to each of its simple descriptors. If the remote device - * is the coordinator or a router, it shall also apply the match criterion, as described - * below, to each simple descriptor that it may have obtained from each of its - * children. - * \n\n - * If the NWKAddrOfInterest field of the original Match_Desc_req was not equal to - * the broadcast network address for all devices for which macRxOnWhenIdle = - * TRUE (0xfffd), the remote device shall set the NWKAddrOfInterest field to the - * same network address that was specified in the original Match_Desc_req - * command. - * \n\n - * If the NWKAddrOfInterest field matches the network address of the remote - * device, it shall apply the match criterion, as described below, that was specified in - * the original Match_Desc_req command to each of its simple descriptors. - * If the NWKAddrOfInterest field does not match the network address of the - * remote device and it is an end device, it shall set the Status field to - * INV_REQUESTTYPE, set the MatchLength field to 0, and not include the - * MatchList field. If the NWKAddrOfInterest field does not match the network - * address of the remote device and it is the coordinator or a router, it shall determine - * whether the NWKAddrOfInterest field matches the network address of one of its - * children. If the NWKAddrOfInterest field does not match the network address of - * one of the children of the remote device, it shall set the Status field to - * DEVICE_NOT_FOUND, set the MatchLength field to 0, and not include the - * MatchList field. - * \n\n - * If the NWKAddrOfInterest matches the network address of one of the children of - * the remote device, it shall determine whether any simple descriptors for that - * device are available. If no simple descriptors are available for the child indicated - * by the NWKAddrOfInterest field, the remote device shall set the Status field to - * NO_DESCRIPTOR, set the MatchLength field to 0, and not include the - * MatchList field. If any simple descriptors are available for the child indicated by - * the NWKAddrOfInterest field, the remote device shall apply the match criterion, - * as described below, that was specified in the original Match_Desc_req command - * to each of these simple descriptors. - * \n\n - * The remote device shall apply the match criteria to each simple descriptor as follows. - * The remote device shall first check if the ProfileID - * field matches exactly the application profile identifier field of the simple - * descriptor. If the profileID field does not match exactly the remote device shall - * check if the Profile ID of the Match_desc_req matches the wildcard profile - * (0xFFFF) and the Profile ID of the Simple Descriptor is within the Standard range - * (a public profile) as dictated by document [B25]. 14 If the profile identifiers do not - * match, the remote device shall assume the match to be unsuccessful and perform - * no further matching. - * \n\n - * If the profile identifiers match, the remote device shall determine whether the - * match criteria contains a list of input clusters (the NumInClusters field is not equal - * to 0). If the match criteria contains a list of input clusters, the remote device shall - * check that at least one of the cluster identifiers listed in the InClusterList field - * matches one of the cluster identifiers in the application input cluster list field of - * the simple descriptor. If at least one matching input cluster is found, the remote - * device shall assume the match to be successful, note the identifier of the endpoint - * to which this simple descriptor refers and perform no further matching. - * If the remote device is unable to find any matching input clusters, it shall - * determine whether the match criterion contains a list of output clusters (the - * NumOutClusters field is not equal to 0). If the match criterion contains a list of - * output clusters, the remote device shall check that at least one of the cluster - * identifiers listed in the OutClusterList field matches one of the cluster identifiers - * in the application output cluster list field of the simple descriptor. If at least one - * matching output cluster is found, the remote device shall assume the match to be - * successful and note the identifier of the endpoint to which this simple descriptor - * refers. If the remote device is unable to find any output matching clusters, it shall - * assume the match to be unsuccessful. - * \n\n - * If the above procedure produces one or more matches, the remote device shall - * construct a separate Match_Desc_rsp command for each matching device - * (including itself). For each response, the Status field shall be set to SUCCESS, the - * NWKAddrOfInterest field shall be set to the address of the appropriate matching - * device, the MatchLength field shall be set to the number of simple descriptors that - * matched the criteria for the appropriate matching device, and the MatchList field - * shall contain an ascending list of the endpoints on which a simple descriptor - * matched the criteria for the appropriate matching device. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_DEVICE_NOT_FOUND \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_NO_DESCRIPTOR - * @param[out] addr16 Network address for the request - * @param[out] match_length The count of endpoint on the remote device that match - * the request criteria - * @param[out] match_list List of bytes each of which represents an 8-bit endpoint - * @param[out] user_data user data - * - * @see zb_zdo_match_desc_req() - */ -typedef void (*zb_zdo_match_desc_rsp)( - unsigned char status, - nwk_addr addr16, - unsigned char match_length, - unsigned char *match_list, - void *user_data); - -/** - * @brief Matching descriptor request - * @details The Match_Desc_req command is generated from a local device wishing to find - * remote devices supporting a specific simple descriptor match criterion. This - * command shall either be broadcast to all devices for which macRxOnWhenIdle = - * TRUE, or unicast. If the command is unicast, it shall be directed either to the - * remote device itself or to an alternative device that contains the discovery - * information of the remote device. - * \n\n - * The local device shall generate the Match_Desc_req command using the format - * illustrated in param list. The NWKAddrOfInterest field shall contain the network - * address indicating a broadcast to all devices for which macRxOnWhenIdle = - * TRUE (0xfffd) if the command is to be broadcast, or the network address of the - * remote device for which the match is required. - * The remaining fields shall contain the required criterion for which the simple - * descriptor match is requested. The ProfileID field shall contain the identifier of - * the profile for which the match is being sought or the wildcard profile ID of - * 0xFFFF. - * \n\n - * The NumInClusters field shall contain the number of elements in the InClusterList - * field. If the value of this field is 0, the InClusterList field shall not be included. If - * the value of the NumInClusters field is not equal to 0, the InClusterList field shall - * contain the list of input cluster identifiers for which the match is being sought. - * The NumOutClusters field shall contain the number of elements in the - * OutClusterList field. If the value of this field is 0, the OutClusterList field shall - * not be included. If the value of the NumOutClusters field is not equal to 0, the - * OutClusterList field shall contain the list of output cluster identifiers for which the - * match is being sought. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] profile_id Profile ID to be matched at the destination - * @param[in] num_in_clusters The number of input clusters provided for matching within - * the in_cluster_list - * @param[in] in_cluster_list List of input cluster ids to b used for matching - * @param[in] num_out_clusters The number of output clusters provided for matching within - * the out_cluster_list - * @param[in] out_cluster_list List of output cluster ids to b used for matching - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_match_desc_rsp() - */ -int zb_zdo_match_desc_req( - zigbee_h handle, - nwk_addr addr16, - unsigned short profile_id, - unsigned char num_in_clusters, - unsigned short *in_cluster_list, - unsigned char num_out_clusters, - unsigned short *out_cluster_list, - zb_zdo_match_desc_rsp cb, - void *user_data); - -/** - * @brief Node descriptor response - * @details The Node_Desc_rsp is generated by a remote device in response to a - * Node_Desc_req directed to the remote device. This command shall be unicast to - * the originator of the Node_Desc_req command. - * \n\n - * The remote device shall generate the Node_Desc_rsp command using the format - * illustrated in param list. The NWKAddrOfInterest field shall match that specified - * in the original Node_Desc_req command. If the NWKAddrOfInterest field - * matches the network address of the remote device, it shall set the Status field to - * SUCCESS and include its node descriptor in the NodeDescriptor field. - * If the NWKAddrOfInterest field does not match the network address of the - * remote device and it is an end device, it shall set the Status field to - * INV_REQUESTTYPE and not include the NodeDescriptor field.\n\n If the - * NWKAddrOfInterest field does not match the network address of the remote - * device and it is the coordinator or a router, it shall determine whether the - * NWKAddrOfInterest field matches the network address of one of its children. If - * the NWKAddrOfInterest field does not match the network address of one of the - * children of the remote device, it shall set the Status field to - * DEVICE_NOT_FOUND and not include the NodeDescriptor field.\n\n If the - * NWKAddrOfInterest matches the network address of one of the children of the - * remote device, it shall determine whether a node descriptor for that device is - * available. If a node descriptor is not available for the child indicated by the - * NWKAddrOfInterest field, the remote device shall set the Status field to - * NO_DESCRIPTOR and not include the NodeDescriptor field.\n\n If a node descriptor - * is available for the child indicated by the NWKAddrOfInterest field, the remote - * device shall set the Status field to SUCCESS and include the node descriptor - * of the matching child device in the NodeDescriptor field. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_DEVICE_NOT_FOUND \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_NO_DESCRIPTOR - * @param[out] addr16 Network address for the request - * @param[out] node_desc This field shall only be included in the frame if the - * status field is equal to ZB_ZDP_SUCCESS. - * @param[out] user_data user data - * - * @see zb_zdo_node_desc_req() - */ -typedef void (*zb_zdo_node_desc_rsp)( - unsigned char status, - nwk_addr addr16, - const zb_zdo_node_descriptor_h node_desc, - void *user_data); - -/** - * @brief Node descriptor request - * @details The Node_Desc_req command is generated from a local device wishing to inquire - * as to the node descriptor of a remote device. This command shall be unicast either - * to the remote device itself or to an alternative device that contains the discovery - * information of the remote device. - * \n\n - * The local device shall generate the Node_Desc_req command using the format - * illustrated in param list. The NWKAddrOfInterest field shall contain the network - * address of the remote device for which the node descriptor is required. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_node_desc_rsp() - */ -int zb_zdo_node_desc_req( - zigbee_h handle, - nwk_addr addr16, - zb_zdo_node_desc_rsp cb, - void *user_data); - -/** - * @brief Power descriptor response - * @details The Power_Desc_rsp is generated by a remote device in response to a - * Power_Desc_req directed to the remote device. This command shall be unicast to - * the originator of the Power_Desc_req command.\n - * \n - * The remote device shall generate the Power_Desc_rsp command using the format - * illustrated in Table 2.93. The NWKAddrOfInterest field shall match that specified - * in the original Power_Desc_req command. If the NWKAddrOfInterest field - * matches the network address of the remote device, it shall set the Status field to - * SUCCESS and include its power descriptor in the PowerDescriptor field. - * If the NWKAddrOfInterest field does not match the network address of the - * remote device and it is an end device, it shall set the Status field to - * INV_REQUESTTYPE and not include the PowerDescriptor field. If the - * NWKAddrOfInterest field does not match the network address of the remote - * device and it is the coordinator or a router, it shall determine whether the - * NWKAddrOfInterest field matches the network address of one of its children. If - * the NWKAddrOfInterest field does not match the network address of one of the - * children of the remote device, it shall set the Status field to - * DEVICE_NOT_FOUND and not include the PowerDescriptor field.\n\n If the - * NWKAddrOfInterest matches the network address of one of the children of the - * remote device, it shall determine whether a power descriptor for that device is - * available. If a power descriptor is not available for the child indicated by the - * NWKAddrOfInterest field, the remote device shall set the Status field to - * NO_DESCRIPTOR and not include the PowerDescriptor field.\n\n If a power - * descriptor is available for the child indicated by the NWKAddrOfInterest field, - * the remote device shall set the Status field to SUCCESS and include the power - * descriptor of the matching child device in the PowerDescriptor field. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_DEVICE_NOT_FOUND \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_NO_DESCRIPTOR - * @param[out] addr16 Network address for the request - * @param[out] power_desc This field shall only be included in the frame if the - * @ status field is equal to ZB_ZDP_SUCCESS. - * @param[out] user_data user data - * - * @see zb_zdo_power_desc_req() - */ -typedef void (*zb_zdo_power_desc_rsp)( - unsigned char status, - nwk_addr addr16, - const zb_zdo_node_power_descriptor_h power_desc, - void *user_data); - -/** - * @brief Power descriptor request - * @details The Power_Desc_req command is generated from a local device wishing to - * inquire as to the power descriptor of a remote device. This command shall be - * unicast either to the remote device itself or to an alternative device that contains - * the discovery information of the remote device. - * \n\n - * The local device shall generate the Power_Desc_req command using the format - * illustrated in param list. The NWKAddrOfInterest field shall contain the network - * address of the remote device for which the power descriptor is required. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_power_desc_rsp() - */ -int zb_zdo_power_desc_req( - zigbee_h handle, - nwk_addr addr16, - zb_zdo_power_desc_rsp cb, - void *user_data); - -/** - * @brief Complex descriptor response - * @details The Complex_Desc_rsp is generated by a remote device in response to a - * Complex_Desc_req directed to the remote device. This command shall be unicast - * to the originator of the Complex_Desc_req command. - * The remote device shall generate the Complex_Desc_rsp command using the - * format illustrated in param list. The NWKAddrOfInterest field shall match that - * specified in the original Complex_Desc_req command. If the - * NWKAddrOfInterest field matches the network address of the remote device but a - * complex descriptor does not exist, it shall set the Status field to - * NOT_SUPPORTED, set the Length field to 0, and not include the - * ComplexDescriptor field. If the NWKAddrOfInterest field matches the network - * address of the remote device and a complex descriptor exists, it shall set the Status - * field to SUCCESS, set the Length field to the length of the complex descriptor, - * and include its complex descriptor (see sub-clause 2.3.2.6) in the - * ComplexDescriptor field.\n - * \n - * If the NWKAddrOfInterest field does not match the network address of the - * remote device and it is an end device, it shall set the Status field to - * INV_REQUESTTYPE, set the Length field to 0, and not include the - * ComplexDescriptor field. If the NWKAddrOfInterest field does not match the - * network address of the remote device and it is the coordinator or a router, it shall - * determine whether the NWKAddrOfInterest field matches the network address of - * one of its children. If the NWKAddrOfInterest field does not match the network - * address of one of the children of the remote device, it shall set the Status field to - * DEVICE_NOT_FOUND, set the Length field to 0, and not include the - * ComplexDescriptor field.\n\n If the NWKAddrOfInterest matches the network - * address of one of the children of the remote device, it shall determine whether a - * complex descriptor for that device is available. If a complex descriptor is not - * available for the child indicated by the NWKAddrOfInterest field, the remote - * device shall set the Status field to NO_DESCRIPTOR, set the Length field to 0, - * and not include the ComplexDescriptor field.\n\n If a complex descriptor is available - * for the child indicated by the NWKAddrOfInterest field, the remote device shall - * set the Status field to SUCCESS, set the Length field to the length of the complex - * descriptor for that device, and include the complex descriptor of the matching - * child device in the ComplexDescriptor field. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * #ZB_ZDP_DEVICE_NOT_FOUND \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_NO_DESCRIPTOR - * @param[out] addr16 Network address for the request - * @param[out] length Length in bytes of the complex_desc field - * @param[out] complex_desc This field shall only be included in the frame if the - * @ status field is equal to ZB_ZDP_SUCCESS. - * @param[out] user_data user data - * - * @see zb_zdo_complex_desc_req() - */ -typedef void (*zb_zdo_complex_desc_rsp)( - unsigned char status, - nwk_addr addr16, - unsigned char length, - unsigned char *complex_desc, - void *user_data); - -/** - * @brief Complex descriptor request - * @details The Complex_Desc_req command is generated from a local device wishing to - * inquire as to the complex descriptor of a remote device. This command shall be - * unicast either to the remote device itself or to an alternative device that contains - * the discovery information of the remote device. - * \n - * The local device shall generate the Complex_Desc_req command using the - * format illustrated in param list. The NWKAddrOfInterest field shall contain the - * network address of the remote device for which the complex descriptor is - * required. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_complex_desc_rsp() - */ -int zb_zdo_complex_desc_req( - zigbee_h handle, - nwk_addr addr16, - zb_zdo_complex_desc_rsp cb, - void *user_data); - -/** - * @brief User descriptor response - * @details The User_Desc_rsp is generated by a remote device in response to a - * User_Desc_req directed to the remote device. This command shall be unicast to - * the originator of the User_Desc_req command.\n - * \n - * The remote device shall generate the User_Desc_rsp command using the format - * illustrated in Table 2.98. The NWKAddrOfInterest field shall match that specified - * in the original User_Desc_req command. If the NWKAddrOfInterest field - * matches the network address of the remote device but a user descriptor does not - * exist, it shall set the Status field to NO_DESCRIPTOR, set the Length field to 0, - * and not include the UserDescriptor field. If the NWKAddrOfInterest field - * matches the network address of the remote device and a user descriptor exists, it - * shall set the Status field to SUCCESS, set the Length field to the length of the user - * descriptor, and include its user descriptor in the UserDescriptor field. - * If the NWKAddrOfInterest field does not match the network address of the - * remote device and it is an end device, it shall set the Status field to - * INV_REQUESTTYPE, set the Length field to 0, and not include the - * UserDescriptor field.\n\n If the NWKAddrOfInterest field does not match the network - * address of the remote device and it is the coordinator or a router, it shall determine - * whether the NWKAddrOfInterest field matches the network address of one of its - * children.\n\n If the NWKAddrOfInterest field does not match the network address of - * one of the children of the remote device, it shall set the Status field to - * DEVICE_NOT_FOUND, set the Length field to 0, and not include the - * UserDescriptor field.\n\n If the NWKAddrOfInterest matches the network address of - * one of the children of the remote device, it shall determine whether a user - * descriptor for that device is available.\n\n If a user descriptor is not available for the - * child indicated by the NWKAddrOfInterest field, the remote device shall set the - * Status field to NO_DESCRIPTOR, set the Length field to 0, and not include the - * UserDescriptor field.\n\n If a user descriptor is available for the child indicated by the - * NWKAddrOfInterest field, the remote device shall set the Status field to - * SUCCESS, set the Length field to the length of the user descriptor for that device, - * and include the user descriptor of the matching child device in the UserDescriptor - * field. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * #ZB_ZDP_DEVICE_NOT_FOUND \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * #ZB_ZDP_NO_DESCRIPTOR - * @param[out] addr16 Network address for the request - * @param[out] length Length in bytes of the user_desc field - * @param[out] user_desc This field shall only be included in the frame if the - * status field is equal to ZB_ZDP_SUCCESS. - * @param[out] user_data user data - * - * @see zb_zdo_user_desc_req() - */ -typedef void (*zb_zdo_user_desc_rsp)( - unsigned char status, - nwk_addr addr16, - unsigned char len, - unsigned char *user_desc, - void *user_data); - -/** - * @brief Complex descriptor request - * @details The User_Desc_req command is generated from a local device wishing to inquire - * as to the user descriptor of a remote device. This command shall be unicast either - * to the remote device itself or to an alternative device that contains the discovery - * information of the remote device. - * \n - * The local device shall generate the User_Desc_req command using the format - * illustrated in Table 2.53. The NWKAddrOfInterest field shall contain the network - * address of the remote device for which the user descriptor is required. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_complex_desc_rsp() - */ -int zb_zdo_user_desc_req( - zigbee_h handle, - nwk_addr addr16, - zb_zdo_user_desc_rsp cb, - void *user_data); -/** - * @brief User descriptor confirm response - * @details The User_Desc_conf is generated by a remote device in response to a - * User_Desc_set directed to the remote device. This command shall be unicast to - * the originator of the User_Desc_set command. - * \n - * The remote device shall generate the User_Desc_conf command using the format - * illustrated in param list. The NWKAddrOfInterest field shall match that - * specified in the original User_Desc_set command. If the NWKAddrOfInterest - * field matches the network address of the remote device but a user descriptor does - * not exist, it shall set the Status field to NOT_SUPPORTED. If the - * NWKAddrOfInterest field matches the network address of the remote device and - * a user descriptor exists, it shall set the Status field to SUCCESS and configure the - * user descriptor with the ASCII character string specified in the original - * User_Desc_set command.\n - * \n - * If the NWKAddrOfInterest field does not match the network address of the - * remote device and it is an end device, it shall set the Status field to - * INV_REQUESTTYPE.\n\n If the NWKAddrOfInterest field does not match the - * network address of the remote device and it is the coordinator or a router, it shall - * determine whether the NWKAddrOfInterest field matches the network address of - * one of its children. If the NWKAddrOfInterest field does not match the network - * address of one of the children of the remote device, it shall set the Status field to - * DEVICE_NOT_FOUND.\n\n If the NWKAddrOfInterest matches the network - * address of one of the children of the remote device, it shall determine whether a - * user descriptor for that device is available. If a user descriptor is not available for - * the child indicated by the NWKAddrOfInterest field, the remote device shall set - * the Status field to NO_DESCRIPTOR.\n\n If a user descriptor is available for the - * child indicated by the NWKAddrOfInterest field, the remote device shall set the - * Status field to SUCCESS and configure the user descriptor with the ASCII - * character string specified in the original User_Desc_set command. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * returned value from NLME-GET.confirm primitive \n - * @param[out] user_data user data - * - * @see zb_zdo_user_desc_req() - */ -typedef void (*zb_zdo_user_desc_conf)( - unsigned char status, - void *user_data); - -/** - * @brief User descriptor set request - * @details The User_Desc_set command is generated from a local device wishing to - * configure the user descriptor on a remote device. This command shall be unicast - * either to the remote device itself or to an alternative device that contains the - * discovery information of the remote device. - * \n\n - * The local device shall generate the User_Desc_set command using the format - * illustrated in param list. The NWKAddrOfInterest field shall contain the network - * address of the remote device for which the user descriptor is to be configured and - * the UserDescription field shall contain the ASCII character string that is to be - * configured in the user descriptor. Characters with ASCII codes numbered 0x00 - * through 0x1f are not permitted to be included in this string. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] len Length of the user_desc filed in bytes - * @param[in] user_desc Pointer of user description - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_user_desc_conf() - */ -int zb_zdo_user_desc_set( - zigbee_h handle, - nwk_addr addr16, - unsigned char len, - unsigned char *user_desc, - zb_zdo_user_desc_conf cb, - void *user_data); - -/** - * @brief device announce request - * @details The Device_annce is provided to enable ZigBee devices on the network to notify - * other ZigBee devices that the device has joined or re-joined the network, - * identifying the device's 64-bit IEEE address and new 16-bit NWK address, and - * informing the Remote Devices of the capability of the ZigBee device.\n\n This - * command shall be invoked for all ZigBee end devices upon join or rejoin. This - * command may also be invoked by ZigBee routers upon join or rejoin as part of - * NWK address conflict resolution.\n\n The destination addressing on this primitive is - * broadcast to all devices for which macRxOnWhenIdle = TRUE. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 The IEEE address for device of interest - * @param[in] capability See zb_zdo_mac_capability_field_e in zb-zdo.h header file - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_user_desc_conf() - */ -int zb_zdo_device_annce( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - unsigned char capability); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_H__ */ diff --git a/include/zdo/zb-zdo-nwk-mgr.h b/include/zdo/zb-zdo-nwk-mgr.h deleted file mode 100644 index 4c22040..0000000 --- a/include/zdo/zb-zdo-nwk-mgr.h +++ /dev/null @@ -1,712 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zdo-nwk-mgr.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_MODULE Network Manager - * - * @brief zigbee provides API for Network Management. - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_HEADER Header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_OVERVIEW Overview - * This API set consists of ZDP network manager API - * - * @{ - */ - -/** - * @brief Network management discovery response - * @details The Mgmt_NWK_Disc_rsp is generated in response to an Mgmt_NWK_Disc_req. - * If this management command is not supported, a status - * of NOT_SUPPORTED shall be returned and all parameter fields after the Status - * field shall be omitted.\n\n Otherwise, the Remote Device shall implement the - * following process.\n\n - * Upon receipt of and after support for the Mgmt_NWK_Disc_req has been - * verified, the Remote Device shall issue an NLME-NETWORK- - * DISCOVERY.request primitive using the ScanChannels and ScanDuration - * parameters, supplied in the Mgmt_NWK_Disc_req command.\n\n Upon receipt of the - * NLME-NETWORK-DISCOVERY.confirm primitive, the Remote Device shall - * report the results, starting with the StartIndex element, via the\ - * Mgmt_NWK_Disc_rsp command.\n\n The NetworkList field shall contain whole - * NetworkList records, formatted as specified in Table 2.125, until the limit on - * MSDU size, i.e., aMaxMACFrameSize (see [B1]), is reached.\n\n The number of - * results reported shall be set in the NetworkListCount.\n\n - * - * @since_tizen 3.0 - * - * @param[out] status ZB_ZDP_NOT_SUPPORTED or returned value from NLME-NETWORK.DISCOVERY. - * request - * @param[out] network_count The total number of networks reported by the NLME-NETWORK- - * DISCOVERY.confirm. - * @param[out] start_idx The starting point in the NetworkList from the NLME-NETWORK- - * DISCOVERY.confirm where reporting begins for this response. - * @param[out] network_list_count The number of network list descriptors reported within - * this response. - * @param[out] nwk_list A list of network list descriptors. - * @param[out] user_data User data - * - * @see zb_zdo_mgmt_nwk_disc_req() - */ -typedef void (*zb_zdo_mgmt_nwk_disc_rsp)( - unsigned char status, - unsigned char network_count, - unsigned char start_idx, - unsigned char network_list_count, - const zb_zdo_network_list_record_h *nwk_list, - void *user_data); - -/** - * @brief Bitmask to scan all 802.15.4 channels. - */ -#define ZB_802_15_4_CHANNELS_MASK 0x07FFF800UL - -/** - * @brief Network discover management request - * @details The Mgmt_NWK_Disc_req is generated from a Local Device requesting that the - * Remote Device execute a Scan to report back networks in the vicinity of the Local - * Device.\n\n The destination addressing on this command shall be unicast. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 destination address - * @param[in] scan_channels The five most significant bits (b27,...,b31) are reserved. - * The 27 least significant bits (b0, b1,... b26) indicate - * which channels are to be scanned (1 = scan, 0 = do not scan) - * for each of the 27 valid channels. - * @param[in] scan_duration A value used to calculate the length of time to spend - * scanning each channel. The time spent scanning each channel is - * (aBaseSuperframeDuration * (2 n + 1)) symbols, where n is - * the value of the ScanDuration parameter. For more information - * on MAC sub-layer scanning - * @param[in] scan_count A number of beacon-request in one scan-duration - * @param[in] start_idx Starting index - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_nwk_disc_rsp() - */ -int zb_zdo_mgmt_nwk_disc_req( - zigbee_h handle, - nwk_addr addr16, - unsigned int scan_channels, - unsigned char scan_duration, - unsigned char scan_count, - unsigned char start_idx, - zb_zdo_mgmt_nwk_disc_rsp cb, - void *user_data); - -/** - * @brief Network management LQI response - * @details The Recover_Source_Bind_rsp is generated from a backup binding table cache - * device in response to a Recover_Source_Bind_req from a primary binding table - * cache and contains the status of the request.\n\n This command shall be unicast to the - * requesting device. If the responding device is not a backup binding table cache, it - * shall return a status of NOT_SUPPORTED.\n\n If the originator of the request is not - * recognized as a primary binding table cache, it shall return a status of - * INV_REQUESTTYPE. \n\n Otherwise, the backup binding table cache shall prepare a - * list of binding table entries from its backup beginning with StartIndex. \n\n It will - * fit in as many entries as possible into a Recover_Source_Bind_rsp command and return - * a status of SUCCESS.\n\n If StartIndex is more than the number of entries in the - * Source table, a status of NO_ENTRY is returned.\n\n For a successful response, - * SourceTableEntries is the total number of entries in the backup source table, and - * SourceTableListCount is the number of entries which is being returned in the - * response. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * #ZB_ZDP_TABLE_FULL \n - * #ZB_ZDP_INV_REQUESTTYPE \n - * @param[out] source_table_entries Total number of source table entries in the backup - * binding cache. - * @param[out] start_idx Starting index within the neighbor table to begin reporting for - * the neighbor table list. - * @param[out] neighbor_table_list_count The number of neighbor table entries included - * within neighbor table list. - * @param[out] neighbor_table_list A list of neighbor table list. - * @param[out] user_data User data - * - * @see zb_zdo_mgmt_lqi_req() - */ -typedef void (*zb_zdo_mgmt_lqi_rsp)( - unsigned char status, - unsigned char neighbor_table_entries, - unsigned char start_idx, - unsigned char neighbor_table_list_count, - const zb_zdo_neighbor_table_desc_h *neighbor_table_list, - void *user_data); - -/** - * @brief LQI management request - * @details The Mgmt_Lqi_req is generated from a Local Device wishing to obtain a - * neighbor list for the Remote Device along with associated LQI values to each - * neighbor. The destination addressing on this command shall be unicast only and - * the destination address must be that of a ZigBee Coordinator or ZigBee Router. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 destination address - * @param[in] start_idx Starting index for the requested elements of the neighbor table - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_lqi_rsp() - */ -int zb_zdo_mgmt_lqi_req( - zigbee_h handle, - nwk_addr addr16, - unsigned char start_idx, - zb_zdo_mgmt_lqi_rsp cb, - void *user_data); - -/** - * @brief Routing management response - * @details The Mgmt_Rtg_rsp is generated in response to an Mgmt_Rtg_req. If this - * management command is not supported, a status of NOT_SUPPORTED shall be - * returned and all parameter fields after the Status field shall be omitted. Otherwise, - * the Remote Device shall implement the following processing. - * Upon receipt of and after support for the Mgmt_Rtg_req has been verified, the - * Remote Device shall perform an NLME-GET.request (for the nwkRouteTable - * attribute) and process the resulting NLME-GET.confirm (containing the - * nwkRouteTable attribute) to create the Mgmt_Rtg_rsp command. The - * Mgmt_Rtg_rsp command shall contain the same status that was contained in the - * NLME-GET.confirm primitive and if this was not SUCCESS, all parameter fields - * after the status field shall be omitted. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * returned value from NLME-GET.confirm primitive \n - * @param[out] routing_table_entries Total number of routing table entries within the - * remote device. - * @param[out] start_idx Starting index within the Routing Table to begin reporting for - * the RoutingTableList. - * @param[out] routing_table_list_count The number of routing table entries included - * within RoutingTableList. - * @param[out] neighbor_table_list A list of routing table list. - * @param[out] user_data User data - * - * @see zb_zdo_mgmt_rtg_req() - */ -typedef void (*zb_zdo_mgmt_rtg_rsp)( - unsigned char status, - unsigned char routing_table_entries, - unsigned char start_idx, - unsigned char routing_table_list_count, - const zb_zdo_routing_table_h *routing_table_list, - void *user_data); - -/** - * @brief Routing management request - * @details The Mgmt_Rtg_req is generated from a Local Device wishing to retrieve the - * ontents of the Routing Table from the Remote Device. The destination - * addressing on this command shall be unicast only and the destination address - * must be that of the ZigBee Router or ZigBee Coordinator. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 destination network address - * @param[in] start_idx Starting index for the requested elements of the routing table - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_rtg_rsp() - */ -int zb_zdo_mgmt_rtg_req( - zigbee_h handle, - nwk_addr addr16, - unsigned char start_idx, - zb_zdo_mgmt_rtg_rsp cb, - void *user_data); - -/** - * @brief Binding management response - * @details The Mgmt_Bind_rsp is generated in response to a Mgmt_Bind_req. If this - * management command is not supported, a status of NOT_SUPPORTED shall be - * returned and all parameter fields after the Status field shall be omitted. Otherwise, - * the Remote Device shall implement the following processing.\n\n - * Upon receipt of and after support for the Mgmt_Bind_req has been verified, the - * Remote Device shall perform an APSME-GET.request (for the apsBindingTable - * attribute) and process the resulting APSME-GET.confirm (containing the - * apsBindingTable attribute) to create the Mgmt_Bind_rsp command. The - * Mgmt_Bind_rsp command shall contain the same status that was contained in the - * APSME-GET.confirm primitive and if this was not SUCCESS, all parameter - * fields after the status field shall be omitted.\n\n - * From the apsBindingTable attribute, the binding table shall be accessed, starting - * with the index specified by StartIndex, and moved to the BindingTableList field of - * the Mgmt_Bind_rsp command. The entries reported from the binding table shall - * be those, starting with StartIndex and including whole BindingTableList records - * until the MSDU size limit, i.e., aMaxMACFrameSize, - * is reached. Within the Mgmt_Bind_Rsp command, the BindingTableEntries field - * shall represent the total number of Binding Table entries in the Remote Device. - * The BindingTableListCount field shall be the number of entries reported in the - * BindingTableList field of the Mgmt_Bind_req command. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * returned value from NLME-GET.confirm primitive \n - * @param[out] binding_table_entries Total number of Binding Table entries within the - * Remote Device. - * @param[out] start_idx Starting index within the Binding Table to begin reporting for - * the BindingTableList. - * @param[out] binding_table_list_count The number of binding table entries included - * within BindingTableList. - * @param[out] neighbor_table_list A list of routing table list. - * @param[out] user_data User data - * - * @see zb_zdo_mgmt_bind_req() - */ -typedef void (*zb_zdo_mgmt_bind_rsp)( - unsigned char status, - unsigned char binding_table_entries, - unsigned char start_idx, - unsigned char binding_table_list_count, - const zb_zdo_binding_table_h *binding_table_list, - void *user_data); - -/** - * @brief Binding management request - * @details The Mgmt_Bind_req is generated from a Local Device wishing to retrieve the - * contents of the Binding Table from the Remote Device. \n\n The destination - * addressing on this command shall be unicast only and the destination address - * must be that of a Primary binding table cache or source device holding its own - * binding table. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 destination network address - * @param[in] start_idx Starting index for the requested elements of the binding table - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_bind_rsp() - */ -int zb_zdo_mgmt_bind_req( - zigbee_h handle, - nwk_addr addr16, - unsigned char start_idx, - zb_zdo_mgmt_bind_rsp cb, - void *user_data); - -/** - * @brief Leave management response - * @details The Mgmt_Leave_rsp is generated in response to a Mgmt_Leave_req. \n\n If this - * management command is not supported, a status of NOT_SUPPORTED shall be - * returned. \n\n Otherwise, the Remote Device shall implement the following - * processing. - * Upon receipt of and after support for the Mgmt_Leave_req has been verified, the - * Remote Device shall execute the NLME-LEAVE.request to disassociate from the - * currently associated network. The Mgmt_Leave_rsp shall contain the same status - * that was contained in the NLME-LEAVE.confirm primitive. \n\n - * Once a device has disassociated, it may execute pre-programmed logic to perform - * NLME-NETWORK-DISCOVERY and NLME-JOIN to join/re-join a network. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * #ZB_ZDP_NOT_AUTHORIZED \n - * returned value from NLME-LEAVE.confirm primitive \n - * @param[out] user_data User data - * - * @see zb_zdo_mgmt_leave_req() - */ -typedef void (*zb_zdo_mgmt_leave_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Leave device management request - * @details The Mgmt_Bind_req is generated from a Local Device wishing to retrieve the - * contents of the Binding Table from the Remote Device.\n\n The destination - * addressing on this command shall be unicast only and the destination address - * must be that of a Primary binding table cache or source device holding its own - * binding table. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr64 The IEEE address for designated device to leave - * @param[in] remove_children This field has a value of 1 if the device being asked to - * leave the network is also being asked to remove its child - * devices, if any. Otherwise, it has a value of 0. - * @param[in] rejoin This field has a value of 1 if the device being asked to leave from - * the current parent is requested to rejoin the network. Otherwise, - * it has a value of 0. - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_leave_rsp() - */ -int zb_zdo_mgmt_leave_req( - zigbee_h handle, - ieee_addr addr64, - bool remove_children, - bool rejoin, - zb_zdo_mgmt_leave_rsp cb, - void *user_data); - -#ifdef ZB_SUPPORT_PRIORITY_5 -/** - * @brief Direct join management response - * @details The Mgmt_Direct_Join_rsp is generated in response to a Mgmt_Direct_Join_req. - * If this management command is not supported, a status of NOT_SUPPORTED - * shall be returned.\n\n Otherwise, the Remote Device shall implement the following - * processing.\n\n - * Upon receipt and after support for the Mgmt_Direct_Join_req has been verified, - * the Remote Device shall execute the NLME-DIRECT-JOIN.request to directly - * associate the DeviceAddress contained in the Mgmt_Direct_Join_req to the - * network.\n\n The Mgmt_Direct_Join_rsp shall contain the same status that was - * contained in the NLME-DIRECT-JOIN.confirm primitive. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * #ZB_ZDP_NOT_AUTHORIZED \n - * returned value from NLME-DIRECT-JOIN.confirm primitive \n - * @param[out] user_data User data - * - * @see zb_zdo_mgmt_direct_join_rsp() - */ -typedef void (*zb_zdo_mgmt_direct_join_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Direct join device management request - * @details The Mgmt_Direct_Join_req is generated from a Local Device requesting that a - * Remote Device permit a device designated by DeviceAddress to join the network - * directly.\n\n The Mgmt_Direct_Join_req is generated by a management application - * which directs the request to a Remote Device where the NLME-DIRECT- - * JOIN.request is to be executed using the parameter supplied by - * Mgmt_Direct_Join_req. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr64 The IEEE address for designated device to leave - * @param[in] capability See zb_zdo_mac_capability_field_e in zb-zdo.h header file - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_direct_join_rsp() - */ -int zb_zdo_mgmt_direct_join_req( - zigbee_h handle, - ieee_addr addr64, - unsigned char capability, - zb_zdo_mgmt_direct_join_rsp cb, - void *user_data); - -#endif /* ZB_SUPPORT_PRIORITY_5*/ - -/** - * @brief Permit joining management response - * @details The Mgmt_Permit_Joining_rsp is generated in response to a unicast - * Mgmt_Permit_Joining_req.\n\n In the description which follows, note that no - * response shall be sent if the Mgmt_Permit_Joining_req was received as a - * broadcast to all routers.\n\n If this management command is not permitted by the - * requesting device, a status of INVALID_REQUEST shall be returned.\n\n Upon - * receipt and after support for Mgmt_Permit_Joining_req has been verified, the - * Remote Device shall execute the NLME-PERMIT-JOINING.request.\n\n The - * Mgmt_Permit-Joining_rsp shall contain the same status that was contained in the - * NLME-PERMIT-JOINING.confirm primitive. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * #ZB_ZDP_NOT_AUTHORIZED \n - * returned value from NLME-DIRECT-JOINING.confirm primitive \n - * @param[out] user_data User data - * - * @see zb_zdo_mgmt_direct_join_rsp() - */ -typedef void (*zb_zdo_mgmt_permit_joining_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Permit join device management request - * @details The Mgmt_Permit_Joining_req is generated from a Local Device requesting that - * a remote device or devices allow or disallow association.\n\n The - * Mgmt_Permit_Joining_req is generated by a management application or - * commissioning tool which directs the request to a remote device(s) where the - * NLME-PERMIT-JOINING.request is executed using the PermitDuration - * parameter supplied by Mgmt_Permit_Joining_req.\n\n Additionally, if the remote - * device is the Trust Center and TC_Significance is set to 1, the Trust Center - * authentication policy will be affected. The addressing may be unicast or - * 'broadcast to all routers and coordinator'. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 destination network address - * @param[in] permit_duration The length of time in seconds during which the ZigBee - * coordinator or router will allow associations. \n - * The value 0x00 and 0xff indicate that permission is - * disabled or enabled, respectively, without a specified time - * limit. - * @param[in] tc_significance If this is set to 0x01 and the remote device is the Trust Center, - * the command affects the Trust Center authentication policy as - * described in the sub-clauses below; \n \n - * If this is set to 0x00, there is no effect on the Trust Center. - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_permit_joining_rsp() - */ -int zb_zdo_mgmt_permit_joining_req( - zigbee_h handle, - nwk_addr addr16, - unsigned char permit_duration, - unsigned char tc_significance, - zb_zdo_mgmt_permit_joining_rsp cb, - void *user_data); - -#ifdef ZB_SUPPORT_PRIORITY_5 -/** - * @brief Cache management response - * @details The Mgmt_Cache_rsp is generated in response to an Mgmt_Cache_req. If this - * management command is not supported, or the Remote Device is not a Primary - * Cache Device, a status of NOT_SUPPORTED shall be returned and all parameter - * fields after the Status field shall be omitted. Otherwise, the Remote Device shall - * implement the following processing.\n\n Upon receipt of the Mgmt_Cache_req and - * after support for the Mgmt_Cache_req has been verified, the Remote Device shall - * access an internally maintained list of registered ZigBee End Devices utilizing the - * discovery cache on this Primary Discovery Cache device.\n\n The entries reported - * shall be those, starting with StartIndex and including whole DiscoveryCacheList - * records (see Table 2.139) until the limit on MSDU size, i.e., aMaxMACFrameSize - * (see [B1]), is reached.\n\n Within the Mgmt_Cache_rsp command, the - * DiscoveryCacheListEntries field shall represent the total number of registered - * entries in the Remote Device. The parameter DiscoveryCacheListCount shall be - * the number of entries reported in the DiscoveryCacheList field of the - * Mgmt_Cache_rsp command. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_NOT_SUPPORTED \n - * @param[out] discovery_cache_entries discovery cache entries - * @param[out] start_idx data User data - * @param[out] discovery_cache_list_count The list shall contain the number of elements - * given by the DiscoveryCacheListCount parameter. - * @param[out] discover_cache_list A list of descriptors. - * @param[out] user_data User data - * - * @see zb_zdo_mgmt_cache_req() - */ -typedef void (*zb_zdo_mgmt_cache_rsp)( - unsigned char status, - unsigned char discovery_cache_entries, - unsigned char start_idx, - unsigned char discovery_cache_list_count, - const zb_zdo_discovery_cache_h *discover_cache_list, - void *user_data); - -/** - * @brief Cache management request - * @details The Mgmt_Cache_req is provided to enable ZigBee devices on the network to - * retrieve a list of ZigBee End Devices registered with a Primary Discovery Cache - * device.\n\n The destination addressing on this primitive shall be unicast. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 destination network address - * @param[in] start_idx Starring index for the requested elements of the discover cache - * list - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_cache_rsp() - */ -int zb_zdo_mgmt_cache_req( - zigbee_h handle, - nwk_addr addr16, - unsigned char start_idx, - zb_zdo_mgmt_cache_rsp cb, - void *user_data); -#endif /* ZB_SUPPORT_PRIORITY_5 */ - -#if 0 /* This will be handled evnt_handler */ -/** - * @brief Update network management notify - * @details The Mgmt_NWK_Update_notify is provided to enable ZigBee devices to report - * @the condition on local channels to a network manager. The scanned channel list is - * @the report of channels scanned and it is followed by a list of records, one for each - * @channel scanned, each record including one byte of the energy level measured - * @during the scan, or 0xff if there is too much interference on this channel. - * @When sent in response to a Mgmt_NWK_Update_req command the status field - * @shall represent the status of the request. When sent unsolicited the status field - * @shall be set to SUCCESS. - * - * @since_tizen 3.0 - * - * @param[out] addr16 source address from - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INVALID_REQUEST \n - * #ZB_ZDP_NOT_SUPPORTED \n - * any status value returned from the PLME-SET.confirm primitive - * @param[out] scanned_channels List of channels scanned by the request - * @param[out] total_transmissions Count of the total transmissions reported by the - * device. - * @param[out] transmission_failures Sum ot the total transmissions failure reported by - * the end device. - * @param[out] scanned_channel_list_count The list shall contain the number of records - * contained in the EnergyValues parameter. - * @param[out] energy_values The result of an energy measurement made on this - * channel in accordance with. - * - * @see zb_zdo_mgmt_nwk_update_req() - */ -typedef void (*zb_zdo_mgmt_nwk_update_noti)( - nwk_addr addr16, - unsigned char status, - unsigned int scanned_channels, - unsigned short total_transmissions, - unsigned short transmission_failures, - unsigned char scanned_channel_list_count, - unsigned char *energy_values); -#endif -/** - * @brief Update network management request - * @details This command is provided to allow updating of network configuration parameters - * or to request information from devices on network conditions in the local - * operating environment.\n\n The destination addressing on this primitive shall be - * unicast or broadcast to all devices for which macRxOnWhenIdle = TRUE. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] scan_channels The five most significant bits (b27,...,b31) are reserved. - * The 27 least significant bits (b0, b1,... b26) indicate - * which channels are to be scanned (1 = scan, 0 = do not scan) - * for each of the 27 valid channels. - * @param[in] scan_duration A value used to calculate the length of time to spend - * scanning each channel.\n The time spent scanning each channel - * is (aBaseSuperframeDuration * (2 n + 1)) symbols, where n is - * the value of the ScanDuration parameter. For more information - * on MAC sub-layer scanning - * @param[in] scan_count This field represents the number of energy scan to be conducted - * and reported - * @param[in] nwk_update_id The value of the nwkUpdateId contained in this request. - * This value is set by the Network Channel Manager prior to - * sending the message. \n - * This field shall only be present of the ScanDuration is 0xfe - * or 0xff. If the ScanDuration is 0xff, then the value in the - * nwkUpdateID shall be ignored. \n - * @param[in] nwk_manager_addr This field shall be present only if the ScanDuration is set - * to 0xff, and, where present, indicates the NWK address for - * the device with the Network Manager bit set in its Node - * Descriptor - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_mgmt_nwk_update_noti() - */ -int zb_zdo_mgmt_nwk_update_req( - zigbee_h handle, - unsigned int scan_channels, - unsigned char scan_duration, - unsigned char scan_count, - unsigned char nwk_update_id, - nwk_addr nwk_manager_addr); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_H__ */ diff --git a/include/zdo/zb-zdo-svc-disc.h b/include/zdo/zb-zdo-svc-disc.h deleted file mode 100644 index 1a05682..0000000 --- a/include/zdo/zb-zdo-svc-disc.h +++ /dev/null @@ -1,570 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_H__ -#define __TIZEN_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_H__ - -#ifdef ZB_SUPPORT_PRIORITY_5 - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file zb-zdo-svc-disc.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_MODULE Service Discovery - * - * @brief zigbee provides API for Service Discover. - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_HEADER Header - * \#include - * - * @section CAPI_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_OVERVIEW Overview - * This API set consists of ZDP service discovery API - * - * @{ - */ - -/** - * @brief Find system server request's response - * @details The System_Server_Discovery_rsp is generated from Remote Devices on receipt - * of a System_Server_Discovery_req primitive if the parameter matches the Server - * Mask field in its node descriptor. If there is no match, the - * System_Server_Discovery_req shall be ignored and no response given. Matching - * is performed by masking the ServerMask parameter of the - * System_Server_Discovery_req with the Server Mask field in the node descriptor. - * This command shall be unicast to the device which sent - * System_Server_Discovery_req with Acknowledge request set in TxOptions. The - * parameter ServerMask contains the bits in the parameter of the request which - * match the server mask in the node descriptor. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * returned value from NLME-GET.confirm primitive \n - * @param[out] server_mask Server Mask Bit Assignment - * @param[out] user_data user data - * - * @see zb_zdo_system_server_discover_req() - */ -typedef void (*zb_zdo_system_server_discover_rsp)( - unsigned char status, - unsigned short server_mask, - void *user_data); - -/** - * @brief Find system server request - * @details The System_Server_Discovery_req is generated from a Local Device wishing to - * discover the location of a particular system server or servers as indicated by the - * ServerMask parameter.\n\n The destination addressing on this request is 'broadcast to - * all devices for which macRxOnWhenIdle = TRUE.' - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] server_mask Server Mask Bit Assignment - * @param[in] cb The callback function - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_system_server_discover_rsp() - */ -int zb_zdo_system_server_discover_req( - zigbee_h handle, - unsigned short server_mask, - zb_zdo_system_server_discover_rsp cb, - void *user_data); - -/** - * @brief Find node cache request's response - * @details The Find_node_cache_rsp is provided to notify a Local Device of the successful - * iscovery of the Primary Discovery Cache device for the given NWKAddr and - * EEEAddr fields supplied in the request, or to signify that the device of interest is - * apable of responding to discovery requests.\n\n The Find_node_cache_rsp shall be - * enerated only by Primary Discovery Cache devices holding discovery - * nformation for the NWKAddr and IEEEAddr in the request or the device of - * nterest itself and all other Remote Devices shall not supply a response. - * - * @since_tizen 3.0 - * - * @param[out] cache_nwk_addr NWK Address for the Primary Discovery Cache device holding - * the discovery information. - * @param[out] addr16 Server NWK Address for the device of interest. - * @param[out] addr64 Server IEEE Address for the device of interest. - * @param[out] user_data user data - * - * @see zb_zdo_find_node_cache_req() - */ -typedef void (*zb_zdo_find_node_cache_rsp)( - nwk_addr cache_nwk_addr, - nwk_addr addr16, - ieee_addr addr64, - void *user_data); - -/** - * @brief Find Node cache store request - * @details The Find_node_cache_req is provided to enable ZigBee devices on the network to - * broadcast to all devices for which macRxOnWhenIdle = TRUE a request to find a - * device on the network that holds discovery information for the device of interest, - * as specified in the request parameters.\n\n The effect of a successful - * Find_node_cache_req is to have the Primary Discovery Cache device, holding - * discovery information for the device of interest, unicast a Find_node_cache_rsp - * back to the Local Device. Note that, like the NWK_addr_req, only the device - * meeting this criteria shall respond to the request generated by - * Find_node_cache_req. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 IEEE address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_remove_node_cache_rsp() - */ -int zb_zdo_find_node_cache_req( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - zb_zdo_find_node_cache_rsp cb, - void *user_data); - -/** - * @brief Find discovery cache request's response - * @details The Find_node_cache_rsp is provided to notify a Local Device of the successful - * discovery of the Primary Discovery Cache device for the given NWKAddr and - * IEEEAddr fields supplied in the request, or to signify that the device of interest is - * capable of responding to discovery requests.\n\n The Find_node_cache_rsp shall be - * generated only by Primary Discovery Cache devices holding discovery - * information for the NWKAddr and IEEEAddr in the request or the device of - * interest itself and all other Remote Devices shall not supply a response. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * returned value from NLME-GET.confirm primitive \n - * @param[out] user_data user data - * - * @see zb_zdo_discovery_cache_req() - */ -typedef void (*zb_zdo_discovery_cache_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Discovery cache request - * @details The Discovery_Cache_req is provided to enable devices on the network to locate - * a Primary Discovery Cache device on the network.\n\n The destination addressing on - * this primitive shall be broadcast to all devices for which macRxOnWhenIdle = - * TRUE. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 IEEE address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_remove_node_cache_rsp() - */ -int zb_zdo_discovery_cache_req( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - zb_zdo_discovery_cache_rsp cb, - void *user_data); - -/** - * @brief Find discovery store request's response - * @details The Discovery_store_rsp is provided to notify a Local Device of the request status - * from a Primary Discovery Cache device. Included in the response is a status code - * to notify the Local Device whether the request is successful (the Primary Cache - * Device has space to store the discovery cache data for the Local Device), whether - * the request is unsupported (meaning the Remote Device is not a Primary - * Discovery Cache device), or insufficient space exists. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INSUFFICIENT_SPACE \n - * #ZB_ZDP_NOT_SUPPORTED \n - * @param[out] user_data user data - * - * @see zb_zdo_discovery_store_req() - */ -typedef void (*zb_zdo_discovery_store_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Discovery store request - * @details The Discovery_store_req is provided to enable ZigBee end devices on the - * network to request storage of their discovery cache information on a Primary - * Discovery Cache device.\n\n Included in the request is the amount of storage space - * the Local Device requires.\n\n - * The destination addressing on this request is unicast. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 IEEE address for device of interest - * @param[in] node_desc_size Size of node description structure - * @param[in] power_desc_size Size of power description structure - * @param[in] active_ep_size Number of active EP - * @param[in] simple_desc_count Number of simple description structure - * @param[in] simple_desc_list Pointer of simple description structure size - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_remove_node_cache_rsp() - */ -int zb_zdo_discovery_store_req( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - unsigned char node_desc_size, - unsigned char power_desc_size, - unsigned char active_ep_size, - unsigned char simple_desc_count, - unsigned char *simple_desc_list, - zb_zdo_discovery_store_rsp cb, - void *user_data); - -/** - * @brief Node description store request's response - * @details The Node_store_rsp is provided to notify a Local Device of the request status - * from a Primary Discovery Cache device.\n\n Included in the response is a status code - * to notify the Local Device whether the request is successful (the Primary Cache - * Device has space to store the discovery cache data for the Local Device), whether - * the request is not supported (meaning the Remote Device is not a Primary - * Discovery Cache device), or insufficient space exists. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INSUFFICIENT_SPACE \n - * #ZB_ZDP_NOT_PERMITED \n - * #ZB_ZDP_NOT_SUPPORTED \n - * @param[out] user_data user data - * - * @see zb_zdo_node_desc_store_req() - */ -typedef void (*zb_zdo_node_desc_store_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Node description store request - * @details The Node_Desc_store_req is provided to enable ZigBee end devices on the - * network to request storage of their Node Descriptor on a Primary Discovery - * Cache device which has previously received a SUCCESS status from a - * Discovery_store_req to the same Primary Discovery Cache device.\n\n Included in - * this request is the Node Descriptor the Local Device wishes to cache. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 IEEE address for device of interest - * @param[in] nodedsc Pointer of node description structure - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_remove_node_cache_rsp() - */ -int zb_zdo_node_desc_store_req( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - zb_zdo_node_descriptor_h nodedsc, - zb_zdo_node_desc_store_rsp cb, - void *user_data); - -/** - * @brief Power description store request's response - * @details The Power_Desc_store_rsp is provided to notify a Local Device of the request - * status from a Primary Discovery Cache device. Included in the response is a status - * code to notify the Local Device whether the request is successful (the Primary - * Cache Device has space to store the discovery cache data for the Local Device), - * whether the request is not supported (meaning the Remote Device is not a Primary - * Discovery Cache device), or insufficient space exists. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INSUFFICIENT_SPACE \n - * #ZB_ZDP_NOT_PERMITED \n - * #ZB_ZDP_NOT_SUPPORTED \n - * @param[out] user_data user data - * - * @see zb_zdo_power_desc_store_req() - */ -typedef void (*zb_zdo_power_desc_store_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Power description store request - * @details The Power_Desc_store_req is provided to enable ZigBee end devices on the - * network to request storage of their Power Descriptor on a Primary Discovery - * Cache device which has previously received a SUCCESS status from a - * Discovery_store_req to the same Primary Discovery Cache device. Included in - * this request is the Power Descriptor the Local Device wishes to cache. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 IEEE address for device of interest - * @param[in] powerdsc Pointer of power description structure - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_remove_node_cache_rsp() - */ -int zb_zdo_power_desc_store_req( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - zb_zdo_node_power_descriptor_h powerdsc, - zb_zdo_power_desc_store_rsp cb, - void *user_data); - -/** - * @brief Active EP store request's response - * @details The Active_EP_store_rsp is provided to notify a Local Device of the request - * status from a Primary Discovery Cache device.\n\n Included in the response is a status - * code to notify the Local Device whether the request is successful (the Primary - * Cache Device has space to store the discovery cache data for the Local Device), - * the request is not supported (meaning the Remote Device is not a Primary - * Discovery Cache device), or insufficient space exists. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INSUFFICIENT_SPACE \n - * #ZB_ZDP_NOT_PERMITED \n - * #ZB_ZDP_NOT_SUPPORTED \n - * @param[out] user_data user data - * - * @see zb_zdo_active_ep_store_req() - */ -typedef void (*zb_zdo_active_ep_store_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Active EP store request - * @details The Simple_desc_store_req is provided to enable ZigBee end devices on the - * network to request storage of their list of Simple Descriptors on a Primary - * Discovery Cache device which has previously received a SUCCESS status from a - * Discovery_store_req to the same Primary Discovery Cache device. Note that each - * Simple Descriptor for every active endpoint on the Local Device must be - * individually uploaded to the Primary Discovery Cache device via this command - * to enable cached discovery.\n\n Included in this request is the length of the Simple - * Descriptor the Local Device wishes to cache and the Simple Descriptor itself.\n\n The - * endpoint is a field within the Simple Descriptor and is accessed by the Remote - * Device to manage the discovery cache information for the Local Device. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 IEEE address for device of interest - * @param[in] active_ep_count Number of End-point List - * @param[in] ep_list End-point list - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_remove_node_cache_rsp() - */ -int zb_zdo_active_ep_store_req( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - unsigned char active_ep_count, - unsigned char *ep_list, - zb_zdo_active_ep_store_rsp cb, - void *user_data); - -/** - * @brief Simple description store request's response - * @details The Simple_Desc_store_rsp is provided to notify a Local Device of the request - * status from a Primary Discovery Cache device.\n\n Included in the response is a status - * code to notify the Local Device whether the request is successful (the Primary - * Cache Device has space to store the discovery cache data for the Local Device), - * the request is not supported (meaning the Remote Device is not a Primary - * Discovery Cache device), or insufficient space exists. - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INSUFFICIENT_SPACE \n - * #ZB_ZDP_NOT_PERMITED \n - * #ZB_ZDP_NOT_SUPPORTED \n - * @param[out] user_data user data - * - * @see zb_zdo_simple_desc_store_req() - */ -typedef void (*zb_zdo_simple_desc_store_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Simple description store request - * @details The Simple_desc_store_req is provided to enable ZigBee end devices on the - * network to request storage of their list of Simple Descriptors on a Primary - * Discovery Cache device which has previously received a SUCCESS status from a - * Discovery_store_req to the same Primary Discovery Cache device.\n\n Note that each - * Simple Descriptor for every active endpoint on the Local Device must be - * individually uploaded to the Primary Discovery Cache device via this command - * to enable cached discovery.\n\n Included in this request is the length of the Simple - * Descriptor the Local Device wishes to cache and the Simple Descriptor itself. The - * endpoint is a field within the Simple Descriptor and is accessed by the Remote - * Device to manage the discovery cache information for the Local Device. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 IEEE address for device of interest - * @param[in] simpledsc Pointer of simple description structure - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_remove_node_cache_rsp() - */ -int zb_zdo_simple_desc_store_req( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - zb_zdo_simple_desc_h simpledsc, - zb_zdo_simple_desc_store_rsp cb, - void *user_data); - -/** - * @brief Simple description remove request's response - * @details The Remove_node_cache_rsp is provided to notify a Local Device of the request - * status from a Primary Discovery Cache device.\n\n Included in the response is a status - * code to notify the Local Device whether the request is successful (the Primary - * Cache Device has removed the discovery cache data for the indicated device of - * interest), or the request is not supported (meaning the Remote Device is not a - * Primary Discovery Cache device). - * - * @since_tizen 3.0 - * - * @param[out] status #ZB_ZDP_SUCCESS \n - * #ZB_ZDP_INSUFFICIENT_SPACE \n - * #ZB_ZDP_NOT_PERMITED \n - * #ZB_ZDP_NOT_SUPPORTED \n - * @param[out] user_data user data - * - * @see zb_zdo_remove_node_cache_req() - */ -typedef void (*zb_zdo_remove_node_cache_rsp)( - unsigned char status, - void *user_data); - -/** - * @brief Remove node cache request - * @details The Remove_node_cache_req is provided to enable ZigBee devices on the - * network to request removal of discovery cache information for a specified ZigBee - * end device from a Primary Discovery Cache device.\n\n The effect of a successful - * Remove_node_cache_req is to undo a previously successful Discovery_store_req - * and additionally remove any cache information stored on behalf of the specified - * ZigBee end device on the Primary Discovery Cache device. - * - * @since_tizen 3.0 - * - * @param[in] handle The handle of zigbee - * @param[in] addr16 Network address for device of interest - * @param[in] addr64 IEEE address for device of interest - * @param[in] cb Response callback - * @param[in] user_data user data - * - * @return 0 on success, otherwise a negative error value. - * @retval #ZIGBEE_ERROR_NONE Successful - * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error - * - * @see zb_zdo_remove_node_cache_rsp() - */ -int zb_zdo_remove_node_cache_req( - zigbee_h handle, - nwk_addr addr16, - ieee_addr addr64, - zb_zdo_remove_node_cache_rsp cb, - void *user_data); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* ZB_SUPPORT_PRIORITY_5 */ - -#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_H__ */ diff --git a/include/zdo/zb-zdo-type.h b/include/zdo/zb-zdo-type.h deleted file mode 100644 index 7cd745c..0000000 --- a/include/zdo/zb-zdo-type.h +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __ZB_ZDO_TYPE_H__ -#define __ZB_ZDO_TYPE_H__ - -#include - -/** - * @file zb-zdo-type.h - */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.138 ZDP Enumerations Description - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_SUCCESS = 0, /**< Success */ - ZB_ZDP_INV_REQUESTTYPE = 0x80, /**< Invalid Request Type */ - ZB_ZDP_DEVICE_NOT_FOUND = 0x81, /**< Device Not Found */ - ZB_ZDP_INVALID_EP = 0x82, /**< Invalid Endpoint */ - ZB_ZDP_NOT_ACTIVE = 0x83, /**< Not Active */ - ZB_ZDP_NOT_SUPPORTED = 0x84, /**< Not Supported */ - ZB_ZDP_TIMEOUT = 0x85, /**< Timeout */ - ZB_ZDP_NO_MATCH = 0x86, /**< No Match */ - ZB_ZDP_NO_ENTRY = 0x88, /**< No Entry */ - ZB_ZDP_NO_DESCRIPTOR = 0x89, /**< No Descriptor */ - ZB_ZDP_INSUFFICIENT_SPACE = 0x8A, /**< Insufficient Space */ - ZB_ZDP_NOT_PERMITED = 0x8B, /**< Not Permitted */ - ZB_ZDP_TABLE_FULL = 0x8C, /**< Table Full */ - ZB_ZDP_NOT_AUTHORIZED = 0x8D, /**< Not Authorized */ - ZB_ZDP_DEVICE_BINDING_TABLE_FULL = 0x8E, /**< Binding Table Full */ - ZB_ZDP_UNKNOWN = 0xFF /**< Unknown */ -} zb_zdo_status_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief RequestType Enumeration - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_SINGLE_DEVICE_RESPONSE = 0, /**< 0 : Single Device Response */ - ZB_ZDP_EXTENDED_RESPONSE = 1, /**< 1 : Extended Response */ -} zb_zdo_request_type_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.30 Values of the Logical Type Field - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_COORDINATOR = 0, /**< Coordinator */ - ZB_ZDP_ROUTER = 1, /**< Router */ - ZB_ZDP_END_DEVIEC = 2, /**< End Device */ -} zb_zdo_logical_type_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.31 Values of the Frequency Band Field - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_868_868_6_MHZ = 0, /**< 868~888.6MHz */ - ZB_ZDP_902_928_MHA = 2, /**< 902~928MHz */ - ZB_ZDP_2400_2483_5_MHZ = 3, /**< 2400~2483.5MHz */ -} zb_zdo_frequency_band_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Alternative PAN coordinator bit in MAC capability Flags - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_DO_NOT_SUPPORT_PAN_COORDINATOR = 0, /**< Otherwise..*/ - ZB_ZDP_SUPPORT_PAN_COORDINATOR = 1, /**< This node is capable of becoming a PAN - coordinator. */ -} zb_zdo_alternative_pan_coordinator_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Device type bit in MAC capability Flags - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_RFD = 0, /**< This node is a reduced function device (RFD) */ - ZB_ZDP_FFD = 1, /**< This node is a full function device (FFD) */ -} zb_zdo_device_type_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Power Source bit in MAC capability Flags - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_NO_NODE_POWER_DESCRIPTION = 0, /**< Otherwise.. */ - ZB_ZDP_MAIN_POWER = 1, /**< Current power source is main power. This information is - derived from the node current power source field of the node power descriptor */ -} zb_zdo_power_source_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Receiver on when idle bit in MAC capability Flags - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_KEEP_POWER_SAVE_MODE = 0, /**< Otherwise.. */ - ZB_ZDP_DO_NOT_POWER_SAVE_MODE = 1, /**< The device does not disable its receiver to - conserve power during idle periods. */ -} zb_zdo_receiver_on_when_idle_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Security capability bit in MAC capability Flags - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_DO_NOT_SUPPORT_SECURITY_MODE = 0, - ZB_ZDP_SUPPORT_SECURITY_MODE = 1, -} zb_zdo_security_capability_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Figure 2.17 Format of the MAC Capability Flags Field - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR = (1 << 0), /**< Alternative Pan Coordinator see - #zb_zdo_alternative_pan_coordinator_e */ - ZB_ZDP_DEVICE_TYPE = (1 << 1), /**< Device Type see #zb_zdo_device_type_e */ - ZB_ZDP_POWER_SOURCE = (1 << 2), /**< Power Source see #zb_zdo_power_source_e */ - ZB_ZDP_RECEIVER_ON_WHEN_IDLE = (1 << 3), /**< Register on When Idle - see #zb_zdo_receiver_on_when_idle_e */ - ZB_ZDP_SECURITY_CAPABILITY = (1 << 6), /**< Security Capability - see #zb_zdo_security_capability_e */ - ZB_ZDP_ALLOCATE_ADDRESS = (1 << 7), /**< Allocated Address.\n - This mean device receive network address from coordinator\n - This field will always have a value of 1 in implementations of IEEE 802.15.4 spec, - indicating that the joining device must be issued a 16-bit short address */ -} zb_zdo_mac_capability_field_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.32 Server Mask Bit Assignments - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_PRIMARY_TRUST_CENTER = (1 << 0), /**< Primary Trust Center */ - ZB_ZDP_BACKUP_TRUST_CENTER = (1 << 1), /**< Backup Trust Center */ - ZB_ZDP_PRIMARY_BINDING_TABLE_CACHE = (1 << 2), /**< Primary Binding Table Cache */ - ZB_ZDP_BACKUP_BINDING_TABLE_CACHE = (1 << 3), /**< Backup Binding Table Cache */ - ZB_ZDP_PRIMARY_DISCOVERY_CACHE = (1 << 4), /**< Primary Discovery Cache */ - ZB_ZDP_BACKUP_DISCOVERY_CACHE = (1 << 5), /**< Backup Discovery Cache */ - ZB_ZDP_NETWORK_MANAGER = (1 << 6), /**< Network Manager */ -} zb_zdo_server_mask_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.29 Fields of the Node Descriptor - * @details Type and capabilities of the node. - * - * @since_tizen 3.0 - */ -typedef struct zb_zdo_node_descriptor_s* zb_zdo_node_descriptor_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.35 Values of the Current Power Mode Field - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_RECEVIER_SYNCHRONIZED_WITH_RECEVIER_ON = 0, /**< Register Synchronized with Receiver On */ - ZB_ZDP_RECEIVER_COMES_ON_PERIODICALLY = (1 << 0), /**< Register Comes on Periodically */ - ZB_ZDP_RECEIVER_COMES_ON_WHEN_STIMULATED = (1 << 1), /**< Register Comes on When Stimulated */ -} zb_zdo_current_power_mode_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.34 Fields of the Node Power Descriptor - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_CONSTANT_POWER = 0, /**< Constant Power */ - ZB_ZDP_RECHARGEABLE_BATTERY = 1, /**< Rechargeable Battery */ - ZB_ZDP_DISPOSABLE_BATTERY = 2, /**< Disposable Battery */ -} zb_zdo_available_power_source_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.36 Values of the Available Power Sources Field - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_ZDP_CHARGE_LEVEL_CRITICAL = 0, /**< Charge Level Critical */ - ZB_ZDP_CHARGE_LEVEL_33 = 1, /**< Charge Level 33% */ - ZB_ZDP_CHARGE_LEVEL_66 = 2, /**< Charge Level 66% */ - ZB_ZDP_CHARGE_LEVEL_100 = 3, /**< Charge Level 100% */ -} zb_zdo_current_power_source_level_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Binding type - * - * @since_tizen 3.0 - */ -typedef enum { - ZB_UNICAST_BINDING = 0x03, /**< A unicast binding whose 64-bit identifier is the - destination ieee_addr. */ - ZB_MANY_TO_ONE_BINDING = 0x83, /**< A unicast binding whose 64-bit identifier is the - many-to-one destination ieee_addr. A Route discovery - should be disabled when sending unicast via may-to-one - binding */ - ZB_MULTICAST_BINDING = 0x01, /**< A multicast binding whose 64-bit identifier is the - group address. A multicast binding can be used to send - messages to the group and to receive message sent to - the group */ -} zb_binding_type_e; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.34 Fields of the Node Power Descriptor . - * @details Node power characteristics. - * - * @since_tizen 3.0 - */ -typedef struct zb_zdo_node_power_descriptor_s* zb_zdo_node_power_descriptor_h; - - -#define MAX_ENDPOINT_CLUSTERS 32 /**< Cluster counts to handle with */ - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @details Device descriptions contained in node. - * - * @since_tizen 3.0 - */ -typedef struct zb_zdo_simple_desc_s* zb_zdo_simple_desc_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief The handle of zigbee end-device information - * @details a zb_end_device_info_h is an opaque data structure.\n - * zb_end_device_info_h is a data type of network address, IEEE address, endpoint count - * and endpoint information structure. - * - * @since_tizen 3.0 - */ -typedef struct zb_end_device_info_s* zb_end_device_info_h; - - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.125 NetworkList Record Format. - * - * @since_tizen 3.0 - */ -typedef struct zb_zdo_network_list_record_s* zb_zdo_network_list_record_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.127 NeighborTableList Record Format. - * - * @since_tizen 3.0 - */ -typedef struct zb_zdo_neighbor_table_desc_s* zb_zdo_neighbor_table_desc_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.129 RoutingTableList Record Format. - * - * @since_tizen 3.0 - */ -typedef struct zb_zdo_routing_table_s* zb_zdo_routing_table_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.131 BindingTableList Record Format. - * - * @since_tizen 3.0 - */ -typedef struct zb_zdo_binding_table_s* zb_zdo_binding_table_h; - -/** - * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE - * @brief Table 2.136 DiscoveryCacheList Record Format. - * - * @since_tizen 3.0 - */ -typedef struct zb_zdo_discovery_cache_s* zb_zdo_discovery_cache_h; - - -/** - * @} - */ - -#endif /* __ZB_ZDO_TYPE_H__ */ - diff --git a/include/zdo/zb_zdo_bind_mgr.h b/include/zdo/zb_zdo_bind_mgr.h new file mode 100644 index 0000000..43fb51f --- /dev/null +++ b/include/zdo/zb_zdo_bind_mgr.h @@ -0,0 +1,219 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_BIND_MANAGER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZDO_BIND_MANAGER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zdo_bind_mgr.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_BINDING_MANAGER_MODULE Binding Manager + * + * @brief Zigbee provides API for Binding. + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_BINDING_MANAGER_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_BINDING_MANAGER_OVERVIEW Overview + * This API set consists of ZDP device discovery API + * + * @{ + */ + +/** + * @brief Called after 'bind' command + * @details The Bind_rsp is generated in response to a Bind_req. If the Bind_req is + * processed and the Binding Table entry committed on the Remote Device, a Status of + * SUCCESS is returned.\n\n If the Remote Device is not a Primary binding table cache + * or the SrcAddress, a Status of NOT_SUPPORTED is returned.\n\n The supplied + * endpoint shall be checked to determine whether it falls within the specified range. + * If it does not, a Status of INVALID_EP shall be returned.\n\n If the Remote Device is + * the Primary binding table cache or SrcAddress but does not have Binding Table + * resources for the request, a Status of TABLE_FULL is returned. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * #ZB_ZDP_INVALID_EP \n + * #ZB_ZDP_TABLE_FULL \n + * #ZB_ZDP_NOT_AUTHORIZED \n + * @param[out] user_data user data + * + * @see zb_zdo_bind_req() + * + */ +typedef void (*zb_zdo_bind_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'bind' command + * @details Binding request when destination address present but not endpoint present. + * The Bind_req is generated from a Local Device wishing to create a Binding + * Table entry for the source and destination addresses contained as parameters.\n\n The + * destination addressing on this command shall be unicast only, and the destination + * address shall be that of a Primary binding table cache or to the SrcAddress itself. + * The Binding Manager is optionally supported on the source device (unless that + * device is also the ZigBee Coordinator) so that device shall issue a + * NOT_SUPPORTED status to the Bind_req if not supported. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] dst_addr16 The Network address of destination + * @param[in] src_addr64 The IEEE address of source + * @param[in] src_ep The source endpoint for the binding entry + * @param[in] cluster_id The identifier of the cluster on the source device that is bound + * to the destination. + * @param[in] dst_addr64 The IEEE address of destination + * @param[in] type ZB_UNICAST_BINDING : A unicast binding whose 64-bit identifier is the + * destination ieee_addr. \n + * ZB_MANY_TO_ONE_BINDING : A unicast binding whose 64-bit identifier is + * the many-to-one destination ieee_addr. + * A Route discovery should be disabled when + * sending unicast via may-to-one binding \n + * ZB_MULTICAST_BINDING : A multicast binding whose 64-bit identifier is + * the group address. A multicast binding can be + * used to send messages to the group and to + * receive message sent to the group + * @param[in] group_addr The destination address for the binding entry + * @param[in] dst_ep The destination endpoint for the binding entry. + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_bind_rsp() + */ +int zb_zdo_bind_req( + zigbee_h handle, + nwk_addr dst_addr16, + ieee_addr src_addr64, + unsigned char src_ep, + unsigned short cluster_id, + ieee_addr dst_addr64, + unsigned char type, + nwk_addr group_addr, + unsigned char dst_ep, + zb_zdo_bind_rsp cb, + void *user_data); + +/** + * @brief Called after 'unbind' command + * @details The Unbind_rsp is generated in response to an Unbind_req. If the Unbind_req is + * processed and the corresponding Binding Table entry is removed from the Remote + * Device, a Status of SUCCESS is returned. If the Remote Device is not the ZigBee + * Coordinator or the SrcAddress, a Status of NOT_SUPPORTED is returned.\n\n The + * supplied endpoint shall be checked to determine whether it falls within the + * specified range. If it does not, a Status of INVALID_EP shall be returned If the + * Remote Device is the ZigBee Coordinator or SrcAddress but does not have a + * Binding Table entry corresponding to the parameters received in the request, a + * Status of NO_ENTRY is returned. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * #ZB_ZDP_INVALID_EP \n + * #ZB_ZDP_NO_ENTRY \n + * #ZB_ZDP_NOT_AUTHORIZED + * @param[out] user_data user data + * + * @see zb_zdo_unbind_req_addr() + * + */ +typedef void (*zb_zdo_unbind_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'bind' command + * @details Binding request when destination address present but not endpoint present + * The Unbind_req is generated from a Local Device wishing to remove a Binding + * Table entry for the source and destination addresses contained as parameters.\n\n The + * destination addressing on this command shall be unicast only and the destination + * address must be that of the a Primary binding table cache or the SrcAddress. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] dst_addr16 The Network address of destination + * @param[in] src_addr64 The IEEE address of source + * @param[in] src_ep The source endpoint for the binding entry + * @param[in] cluster_id The identifier of the cluster on the source device that is bound + * to the destination. + * @param[in] dst_addr64 The IEEE address of destination + * @param[in] type #ZB_UNICAST_BINDING : A unicast binding whose 64-bit identifier is the + * destination ieee_addr. \n + * #ZB_MANY_TO_ONE_BINDING : A unicast binding whose 64-bit identifier is + * the many-to-one destination ieee_addr. + * A Route discovery should be disabled when + * sending unicast via may-to-one binding \n + * #ZB_MULTICAST_BINDING : A multicast binding whose 64-bit identifier is + * the group address. A multicast binding can be + * used to send messages to the group and to + * receive message sent to the group + * @param[in] group_addr The destination address for the binding entry + * @param[in] dst_ep The destination endpoint for the binding entry. + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_unbind_rsp() + * + */ +int zb_zdo_unbind_req( + zigbee_h handle, + nwk_addr dst_addr16, + ieee_addr src_addr64, + unsigned char src_ep, + unsigned short cluster_id, + ieee_addr dst_addr64, + unsigned char type, + nwk_addr group_addr, + unsigned char dst_ep, + zb_zdo_unbind_rsp cb, + void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_BIND_MANAGER_H__ */ diff --git a/include/zdo/zb_zdo_config.h b/include/zdo/zb_zdo_config.h new file mode 100644 index 0000000..a09adf7 --- /dev/null +++ b/include/zdo/zb_zdo_config.h @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_CONFIG_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZDO_CONFIG_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * @file zb_zdo_config.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_MODULE_ZDO_MODULE + * @brief Zigbee configuration API. + * @since_tizen 4.0 + * + * @{ + */ + +/** + * @brief Sets start-up attribute set + * @details In order to ensure interoperability, all ZigBee HA devices should implement + * compatible Startup Attribute Sets (SAS). This does not mean that set must be + * modifiable through a commissioning cluster, but that the device must internally + * implement these stack settings to ensure compatibility and consistent user + * experience. The start up set parameters described by the Commissioning cluster + * provide a good basis to specify a HA startup set. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] pan_id Short address + * @param[in] epan_id Usually 00-50-C2-77-10-00-00-00 is the global commissioning EPID + * @param[in] channel_mask + * @param[in] start_control + * @param[in] trust_center_addr + * @param[in] master_key + * @param[in] master_key_len + * @param[in] network_key + * @param[in] network_key_len + * @param[in] default_link_key_join + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + */ +int zb_zdo_set_compatible_startup_parameters( + zigbee_h handle, + nwk_addr pan_id, /* default : NULL (0xFFFF) */ + ieee_addr epan_id, /* default : NULL (0x0000000000000000) */ + unsigned int channel_mask, /* default : NULL (0x07FFF800) */ + unsigned char start_control, /* default : 3 (un-comissioned, simlely push end-device's button when joining) */ + ieee_addr trust_center_addr, /* default : NULL (0x0000000000000000) */ + const unsigned char *master_key, /* default : NULL */ + unsigned char master_key_len, /* default : 0 */ + const unsigned char *network_key, /* default : NULL */ + unsigned char network_key_len, /* default : 0 */ + unsigned char default_link_key_join /* default : 0 */ + ); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_CONFIG_H__ */ + diff --git a/include/zdo/zb_zdo_dev_disc.h b/include/zdo/zb_zdo_dev_disc.h new file mode 100644 index 0000000..d47f16a --- /dev/null +++ b/include/zdo/zb_zdo_dev_disc.h @@ -0,0 +1,1089 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zdo_dev_disc.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_MODULE Device Discovery + * + * @brief Zigbee provides API for Device Discovery. + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_OVERVIEW Overview + * This API set consists of ZDP device discovery API + * + * @{ + */ + + +/** + * @brief Called after Network / IEEE address request + * @details The NWK_addr_rsp is generated by a Remote Device in response to a\n + * NWK_addr_req or IEEE_addr_req command inquiring as to the NWK address of the Remote + * Device or the NWK address of an address held in a local discovery cache.\n + * The destination addressing on this command is unicast.\n + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_DEVICE_NOT_FOUND + * @param[out] remote_dev_addr64 64-bit address for the remote device + * @param[out] remote_dev_addr16 16-bit address for the remote device + * @param[out] num_of_assoc_dev Count of the number of 16-bit short addresses to follow. + * If the RequestType in the request is Extended Response + * and there are no associated devices on the Remote Device, + * this field shall be set to 0. + * If an error occurs or the RequestType in the request is + * for a Single Device Response, this field shall not + * be included in the frame. + * @param[out] start_idx Starting index into the list of associated devices for this + * report. If the RequestType in the request is Extended Response + * and there are no associated devices on the Remote Device, + * this field shall not be included in the frame. + * If an error occurs or the RequestType in the request is + * for a Single Device Response, this field shall not + * be included in the frame. + * @param[out] assoc_dev_addr_list A list of 16-bit addresses, one corresponding to each + * associated device to Remote Device; The number of 16-bit + * network addresses contained in this field is specified + * in the NumAssocDev field. + * If the RequestType in the request is Extended Response + * and there are no associated devices on the Remote Device, + * this field shall not be included in the frame. + * If an error occurs or the RequestType in the request is + * for a Single Device Response, this field shall not + * be included in the frame. + * @param[out] user_data user data + * + * @see zb_zdo_nwk_addr_req() + */ +typedef void (*zb_zdo_addr_rsp)( + unsigned char status, + ieee_addr remote_dev_addr64, + nwk_addr remote_dev_addr16, + unsigned char num_of_assoc_dev, + unsigned char start_idx, + unsigned short *assoc_dev_addr_list, + void *user_data); + +/** + * @brief Sends 'Network address request' command + * @details The NWK_addr_req is generated from a Local Device wishing to inquire as to the\n + * 16-bit address of the Remote Device based on its known IEEE address. The\n + * destination addressing on this command shall be unicast or broadcast to all\n + * devices for which macRxOnWhenIdle = TRUE.\n + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr64 IEEE address for device of interest + * @param[in] request_type \n + * 0x00 - Single device response \n + * 0x01 - Extended response \n + * @param[in] start_idx If the Request type for this command is Extended response, + * is StartIndex provides the starting index for the requested + * elements of the associated devices list + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_nwk_addr_rsp() + */ +int zb_zdo_nwk_addr_req( + zigbee_h handle, + ieee_addr addr64, + unsigned char request_type, + unsigned char start_idx, + zb_zdo_addr_rsp cb, + void *user_data); + +/** + * @brief Sends 'IEEE address request' command + * @details The IEEE_addr_req is generated from a Local Device wishing to inquire as to + * the 64-bit IEEE address of the Remote Device based on their known 16-bit address. + * The destination addressing on this command shall be unicast. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_ieee_addr_rsp() + */ +int zb_zdo_ieee_addr_req( + zigbee_h handle, + nwk_addr addr16, + zb_zdo_addr_rsp cb, + void *user_data); + +/** + * @brief Called after active endpoint request command + * @details The Active_EP_rsp is generated by a remote device in response to an + * Active_EP_req directed to the remote device. This command shall be unicast to + * the originator of the Active_EP_req command.\n\n + * The remote device shall generate the Active_EP_rsp command using the format + * illustrated param list. The NWKAddrOfInterest field shall match that specified + * in the original Active_EP_req command. If the NWKAddrOfInterest field + * matches the network address of the remote device, it shall set the Status field to + * SUCCESS, set the ActiveEPCount field to the number of active endpoints on that + * device and include an ascending list of all the identifiers of the active endpoints on + * that device in the ActiveEPList field.\n\n + * If the NWKAddrOfInterest field does not match the network address of the + * remote device and it is an end device, it shall set the Status field to + * INV_REQUESTTYPE, set the ActiveEPCount field to 0, and not include the + * ActiveEPList field.\n\n If the NWKAddrOfInterest field does not match the network + * address of the remote device and it is the coordinator or a router, it shall determine + * whether the NWKAddrOfInterest field matches the network address of a device it + * holds in a discovery cache. \n\n If the NWKAddrOfInterest field does not match the + * network address of a device it holds in a discovery cache, it shall set the Status + * field to DEVICE_NOT_FOUND, set the ActiveEPCount field to 0, and not + * include the ActiveEPList field.\n\n If the NWKAddrOfInterest matches the network + * address of a device held in a discovery cache on the remote device, it shall + * determine whether that device has any active endpoints. If the discovery + * information corresponding to the ActiveEP request has not yet been uploaded to + * the discovery cache, the remote device shall set the Status field to + * NO_DESCRIPTOR, set the ActiveEPCount field to 0 and not include the + * ActiveEPList field.\n\n If the cached device has no active endpoints, the remote + * device shall set the Status field to SUCCESS, set the ActiveEPCount field to 0, + * and not include the ActiveEPList field.\n\n If the cached device has active endpoints, + * the remote device shall set the Status field to SUCCESS, set the ActiveEPCount + * field to the number of active endpoints on that device, and include an ascending + * list of all the identifiers of the active endpoints on that device in the ActiveEPList + * field . + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_DEVICE_NOT_FOUND \n + * #ZB_ZDP_NO_DESCRIPTOR \n + * @param[out] addr16 Network address for the request + * @param[out] count The count of active endpoint on the remote device + * @param[out] ep_list List of bytes each of which represents an 8-bit endpoint + * @param[out] user_data user data + * + * @see zb_zdo_active_ep() + */ +typedef void (*zb_zdo_active_ep_rsp)( + unsigned char status, + nwk_addr addr16, + unsigned char count, + unsigned char *ep_list, + void *user_data); + +/** + * @brief Sends 'active end-point request' command + * @details The Active_EP_req command is generated from a local device wishing to acquire + * the list of endpoints on a remote device with simple descriptors. This command + * shall be unicast either to the remote device itself or to an alternative device that + * contains the discovery information of the remote device.\n\n + * The local device shall generate the Active_EP_req command using the format + * illustrated in param list. The NWKAddrOfInterest field shall contain the network + * address of the remote device for which the active endpoint list is required. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_active_ep_rsp() + */ +int zb_zdo_active_ep( + zigbee_h handle, + nwk_addr addr16, + zb_zdo_active_ep_rsp cb, + void *user_data); + +/** + * @brief Called after 'simple descriptor request' command + * @details The Simple_Desc_rsp is generated by a remote device in response to a + * Simple_Desc_req directed to the remote device. This command shall be unicast to + * the originator of the Simple_Desc_req command. + * The remote device shall generate the Simple_Desc_rsp command using the format + * illustrated in Table 2.94 in Zigbee Specification. The NWKAddrOfInterest field shall + * match that specified in the original Simple_Desc_req command. + * If the endpoint field specified in the original Simple_Desc_req command does not fall + * within the correct range specified in param list, the remote device shall set the Status + * field to INVALID_EP, set the Length field to 0 and not include the SimpleDescriptor + * field.\n\n + * If the NWKAddrOfInterest field matches the network address of the remote + * device, it shall determine whether the endpoint field specifies the identifier of an + * active endpoint on the device. If the endpoint field corresponds to an active + * endpoint, the remote device shall set the Status field to SUCCESS, set the Length + * field to the length of the simple descriptor on that endpoint, and include the simple + * descriptor for that endpoint in the SimpleDescriptor field. + * If the endpoint field does not correspond to an active endpoint, the remote device + * shall set the Status field to NOT_ACTIVE, set the Length field to 0, and not + * include the SimpleDescriptor field.\n\n + * If the NWKAddrOfInterest field does not match the network address of the + * remote device and it is an end device, it shall set the Status field to + * INV_REQUESTTYPE, set the Length field to 0, and not include the + * SimpleDescriptor field. If the NWKAddrOfInterest field does not match the + * network address of the remote device and it is the coordinator or a router, it shall + * determine whether the NWKAddrOfInterest field matches the network address of + * one of its children. If the NWKAddrOfInterest field does not match the network + * address of one of the children of the remote device, it shall set the Status field to + * DEVICE_NOT_FOUND, set the Length field to 0, and not include the + * SimpleDescriptor field.\n\n + * If the NWKAddrOfInterest matches the network address of one of the children of + * the remote device, it shall determine whether a simple descriptor for that device + * and on the requested endpoint is available. If a simple descriptor is not available + * on the requested endpoint of the child indicated by the NWKAddrOfInterest field, + * the remote device shall set the Status field to NO_DESCRIPTOR, set the Length + * field to 0, and not include the SimpleDescriptor field. If a simple descriptor is + * available on the requested endpoint of the child indicated by the + * NWKAddrOfInterest field, the remote device shall set the Status field to + * SUCCESS, set the Length field to the length of the simple descriptor on that + * endpoint, and include the simple descriptor for that + * endpoint of the matching child device in the SimpleDescriptor field. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INVALID_EP \n + * #ZB_ZDP_NOT_ACTIVE \n + * #ZB_ZDP_DEVICE_NOT_FOUND \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_NO_DESCRIPTOR + * @param[out] addr16 Network address for the request + * @param[out] len Length in bytes of the simple descriptor to follow + * @param[out] handle Simple descriptor structure this filed shall only be included + * in the frame if the status field is equal to ZB_ZDP_SUCCESS + * @param[out] user_data user data + * + * @see zb_zdo_simple_desc_req() + */ +typedef void (*zb_zdo_simple_desc_rsp)( + nwk_addr addr16, + unsigned char len, + const zb_zdo_simple_desc_h handle, + void *user_data); + +/** + * @brief Sends 'simple descriptor request' command + * @details The Simple_Desc_req command is generated from a local device wishing to + * inquire as to the simple descriptor of a remote device on a specified endpoint. This + * command shall be unicast either to the remote device itself or to an alternative + * device that contains the discovery information of the remote device.\n\n + * The local device shall generate the Simple_Desc_req command using the format + * illustrated in param list. The NWKAddrOfInterest field shall contain the network + * address of the remote device for which the simple descriptor is required and the + * endpoint field shall contain the endpoint identifier from which to obtain the + * required simple descriptor. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] ep The endpoint on the destination + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ENDPOINT Invalid endpoint. 0 is reserved for ZDP + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_simple_desc_rsp() + */ +int zb_zdo_simple_desc_req( + zigbee_h handle, + nwk_addr addr16, + unsigned char ep, + zb_zdo_simple_desc_rsp cb, + void *user_data); + +#ifdef ZB_SUPPORT_PRIORITY_5 +/** + * @brief Called after 'extended simple descriptor request' command + * @details The Extended_Simple_Desc_rsp is generated by a remote device in response to an + * Extended_Simple_Desc_req directed to the remote device. This command shall + * be unicast to the originator of the Extended_Simple_Desc_req command. + * The remote device shall generate the Extended_Simple_Desc_rsp command using + * the format illustrated in param list. The NWKAddrOfInterest field shall match + * that specified in the original Extended_Simple_Desc_req command. If the + * endpoint field specified in the original Extended_Simple_Desc_req command + * does not fall within the correct range specified in Table 2.49, the remote device + * shall set the Status field to INVALID_EP, set the Endpoint and StartIndex fields to + * their respective values supplied in the request, and not include the AppClusterList + * field.\n\n + * If the NWKAddrOfInterest field matches the network address of the remote + * device, it shall determine whether the endpoint field specifies the identifier of an + * active endpoint on the device.\n\n If the endpoint field corresponds to an active + * endpoint, the remote device shall set the Status field to SUCCESS, set the + * AppClusterList field to the sequence of octets from the concatenated AppInput + * ClusterList and AppOutputClusterList from the Simple Descriptor (Tables 2.39), + * and supply that field as AppClusterList in the response. Note that dependent on + * the value of StartIndex in the request, the results in AppClusterList may be empty + * (for example, the StartIndex begins after the sequence of octets given by the + * concatenation of AppInputClusterList and AppOutputClusterList).\n\n If the endpoint + * field does not correspond to an active endpoint, the remote device shall set the + * Status field to NOT_ACTIVE, set the StartIndex field to the value supplied in the + * request, and not include the AppClusterList field. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INVALID_EP \n + * #ZB_ZDP_NOT_ACTIVE \n + * #ZB_ZDP_DEVICE_NOT_FOUND \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_NO_DESCRIPTOR + * @param[out] addr16 Network address for the request + * @param[out] ep The endpoint on the destination + * @param[out] app_input_cluster_count The total count of application input cluster in + * the simple descriptor for this endpoint + * @param[out] app_output_cluster_count The total count of application output cluster in + * the simple descriptor for this endpoint + * @param[out] start_idx Starting index within the AppClusterList of the response + * represented by an ordered list of the Application Input + * Cluster List and Application Output Cluster List from the + * Simple Descriptor for this endpoint. + * @param[out] app_cluster_list A concatenated, ordered list of the AppInputClusterList + * and AppOutputClusterList, beginning with StartIndex, + * from the Simple Descriptor. + * This field shall only be included in the frame if the + * status field is equal to ZB_ZDP_SUCCESS. + * @param[out] user_data user data + * + * @see zb_zdo_extended_simple_desc_req() + */ +typedef void (*zb_zdo_extended_simple_desc_rsp)( + unsigned char status, + nwk_addr addr16, + unsigned char ep, + unsigned char app_input_cluster_count, + unsigned char app_output_cluster_count, + unsigned char start_idx, + const unsigned char *app_cluster_list, + void *user_data); + +/** + * @brief Sends 'extended simple descriptor request' command + * @details The Extended_Active_EP_req command is generated from a local device wishing + * to acquire the list of endpoints on a remote device with simple descriptors. This + * command shall be unicast either to the remote device itself or to an alternative + * device that contains the discovery information of the remote device.n\n The + * Extended_Active_EP_req is used for devices which support more active + * endpoints than can be returned by a single Active_EP_req. + * The local device shall generate the Extended_Active_EP_req command using the + * format illustrated in Table 2.66. in Zigbee Specification\n\n + * The NWKAddrOfInterest field shall contain the + * network address of the remote device for which the active endpoint list is + * required.\n\n The StartIndex field shall be set in the request to enable retrieval of + * lists of active endpoints from devices whose list exceeds the size of a single ASDU and + * where fragmentation is not supported. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] start_idx Starting index within the active endpoint list in the response + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_extended_simple_desc_rsp() + */ +int zb_zdo_extended_simple_desc_req( + zigbee_h handle, + nwk_addr addr16, + unsigned char start_idx, + zb_zdo_extended_simple_desc_rsp cb, + void *user_data); + +#endif /* ZB_SUPPORT_PRIORITY_5 */ + +/** + * @brief Called after 'matching descriptor request' command + * @details The Match_Desc_rsp is generated by a remote device in response to a + * Match_Desc_req either broadcast or directed to the remote device. This command + * shall be unicast to the originator of the Match_Desc_req command. + * The remote device shall generate the Match_Desc_rsp command using the format + * illustrated in Table 2.96 in Zigbee Specification. + * If the NWKAddrOfInterest field of the original + * Match_Desc_req was equal to the broadcast network address for all devices for + * which macRxOnWhenIdle = TRUE (0xfffd), the remote device shall apply the + * match criterion, as described below, that was specified in the original + * Match_Desc_req command to each of its simple descriptors. If the remote device + * is the coordinator or a router, it shall also apply the match criterion, as described + * below, to each simple descriptor that it may have obtained from each of its + * children. + * \n\n + * If the NWKAddrOfInterest field of the original Match_Desc_req was not equal to + * the broadcast network address for all devices for which macRxOnWhenIdle = + * TRUE (0xfffd), the remote device shall set the NWKAddrOfInterest field to the + * same network address that was specified in the original Match_Desc_req + * command. + * \n\n + * If the NWKAddrOfInterest field matches the network address of the remote + * device, it shall apply the match criterion, as described below, that was specified in + * the original Match_Desc_req command to each of its simple descriptors. + * If the NWKAddrOfInterest field does not match the network address of the + * remote device and it is an end device, it shall set the Status field to + * INV_REQUESTTYPE, set the MatchLength field to 0, and not include the + * MatchList field. If the NWKAddrOfInterest field does not match the network + * address of the remote device and it is the coordinator or a router, it shall determine + * whether the NWKAddrOfInterest field matches the network address of one of its + * children. If the NWKAddrOfInterest field does not match the network address of + * one of the children of the remote device, it shall set the Status field to + * DEVICE_NOT_FOUND, set the MatchLength field to 0, and not include the + * MatchList field. + * \n\n + * If the NWKAddrOfInterest matches the network address of one of the children of + * the remote device, it shall determine whether any simple descriptors for that + * device are available. If no simple descriptors are available for the child indicated + * by the NWKAddrOfInterest field, the remote device shall set the Status field to + * NO_DESCRIPTOR, set the MatchLength field to 0, and not include the + * MatchList field. If any simple descriptors are available for the child indicated by + * the NWKAddrOfInterest field, the remote device shall apply the match criterion, + * as described below, that was specified in the original Match_Desc_req command + * to each of these simple descriptors. + * \n\n + * The remote device shall apply the match criteria to each simple descriptor as follows. + * The remote device shall first check if the ProfileID + * field matches exactly the application profile identifier field of the simple + * descriptor. If the profileID field does not match exactly the remote device shall + * check if the Profile ID of the Match_desc_req matches the wildcard profile + * (0xFFFF) and the Profile ID of the Simple Descriptor is within the Standard range + * (a public profile) as dictated by document [B25]. 14 If the profile identifiers do not + * match, the remote device shall assume the match to be unsuccessful and perform + * no further matching. + * \n\n + * If the profile identifiers match, the remote device shall determine whether the + * match criteria contains a list of input clusters (the NumInClusters field is not equal + * to 0). If the match criteria contains a list of input clusters, the remote device shall + * check that at least one of the cluster identifiers listed in the InClusterList field + * matches one of the cluster identifiers in the application input cluster list field of + * the simple descriptor. If at least one matching input cluster is found, the remote + * device shall assume the match to be successful, note the identifier of the endpoint + * to which this simple descriptor refers and perform no further matching. + * If the remote device is unable to find any matching input clusters, it shall + * determine whether the match criterion contains a list of output clusters (the + * NumOutClusters field is not equal to 0). If the match criterion contains a list of + * output clusters, the remote device shall check that at least one of the cluster + * identifiers listed in the OutClusterList field matches one of the cluster identifiers + * in the application output cluster list field of the simple descriptor. If at least one + * matching output cluster is found, the remote device shall assume the match to be + * successful and note the identifier of the endpoint to which this simple descriptor + * refers. If the remote device is unable to find any output matching clusters, it shall + * assume the match to be unsuccessful. + * \n\n + * If the above procedure produces one or more matches, the remote device shall + * construct a separate Match_Desc_rsp command for each matching device + * (including itself). For each response, the Status field shall be set to SUCCESS, the + * NWKAddrOfInterest field shall be set to the address of the appropriate matching + * device, the MatchLength field shall be set to the number of simple descriptors that + * matched the criteria for the appropriate matching device, and the MatchList field + * shall contain an ascending list of the endpoints on which a simple descriptor + * matched the criteria for the appropriate matching device. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_DEVICE_NOT_FOUND \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_NO_DESCRIPTOR + * @param[out] addr16 Network address for the request + * @param[out] match_length The count of endpoint on the remote device that match + * the request criteria + * @param[out] match_list List of bytes each of which represents an 8-bit endpoint + * @param[out] user_data user data + * + * @see zb_zdo_match_desc_req() + */ +typedef void (*zb_zdo_match_desc_rsp)( + unsigned char status, + nwk_addr addr16, + unsigned char match_length, + unsigned char *match_list, + void *user_data); + +/** + * @brief Sends 'matching descriptor request' command + * @details The Match_Desc_req command is generated from a local device wishing to find + * remote devices supporting a specific simple descriptor match criterion. This + * command shall either be broadcast to all devices for which macRxOnWhenIdle = + * TRUE, or unicast. If the command is unicast, it shall be directed either to the + * remote device itself or to an alternative device that contains the discovery + * information of the remote device. + * \n\n + * The local device shall generate the Match_Desc_req command using the format + * illustrated in param list. The NWKAddrOfInterest field shall contain the network + * address indicating a broadcast to all devices for which macRxOnWhenIdle = + * TRUE (0xfffd) if the command is to be broadcast, or the network address of the + * remote device for which the match is required. + * The remaining fields shall contain the required criterion for which the simple + * descriptor match is requested. The ProfileID field shall contain the identifier of + * the profile for which the match is being sought or the wildcard profile ID of + * 0xFFFF. + * \n\n + * The NumInClusters field shall contain the number of elements in the InClusterList + * field. If the value of this field is 0, the InClusterList field shall not be included. If + * the value of the NumInClusters field is not equal to 0, the InClusterList field shall + * contain the list of input cluster identifiers for which the match is being sought. + * The NumOutClusters field shall contain the number of elements in the + * OutClusterList field. If the value of this field is 0, the OutClusterList field shall + * not be included. If the value of the NumOutClusters field is not equal to 0, the + * OutClusterList field shall contain the list of output cluster identifiers for which the + * match is being sought. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] profile_id Profile ID to be matched at the destination + * @param[in] num_in_clusters The number of input clusters provided for matching within + * the in_cluster_list + * @param[in] in_cluster_list List of input cluster ids to b used for matching + * @param[in] num_out_clusters The number of output clusters provided for matching within + * the out_cluster_list + * @param[in] out_cluster_list List of output cluster ids to b used for matching + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_match_desc_rsp() + */ +int zb_zdo_match_desc_req( + zigbee_h handle, + nwk_addr addr16, + unsigned short profile_id, + unsigned char num_in_clusters, + unsigned short *in_cluster_list, + unsigned char num_out_clusters, + unsigned short *out_cluster_list, + zb_zdo_match_desc_rsp cb, + void *user_data); + +/** + * @brief called after 'node descriptor request' command + * @details The Node_Desc_rsp is generated by a remote device in response to a + * Node_Desc_req directed to the remote device. This command shall be unicast to + * the originator of the Node_Desc_req command. + * \n\n + * The remote device shall generate the Node_Desc_rsp command using the format + * illustrated in param list. The NWKAddrOfInterest field shall match that specified + * in the original Node_Desc_req command. If the NWKAddrOfInterest field + * matches the network address of the remote device, it shall set the Status field to + * SUCCESS and include its node descriptor in the NodeDescriptor field. + * If the NWKAddrOfInterest field does not match the network address of the + * remote device and it is an end device, it shall set the Status field to + * INV_REQUESTTYPE and not include the NodeDescriptor field.\n\n If the + * NWKAddrOfInterest field does not match the network address of the remote + * device and it is the coordinator or a router, it shall determine whether the + * NWKAddrOfInterest field matches the network address of one of its children. If + * the NWKAddrOfInterest field does not match the network address of one of the + * children of the remote device, it shall set the Status field to + * DEVICE_NOT_FOUND and not include the NodeDescriptor field.\n\n If the + * NWKAddrOfInterest matches the network address of one of the children of the + * remote device, it shall determine whether a node descriptor for that device is + * available. If a node descriptor is not available for the child indicated by the + * NWKAddrOfInterest field, the remote device shall set the Status field to + * NO_DESCRIPTOR and not include the NodeDescriptor field.\n\n If a node descriptor + * is available for the child indicated by the NWKAddrOfInterest field, the remote + * device shall set the Status field to SUCCESS and include the node descriptor + * of the matching child device in the NodeDescriptor field. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_DEVICE_NOT_FOUND \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_NO_DESCRIPTOR + * @param[out] addr16 Network address for the request + * @param[out] node_desc This field shall only be included in the frame if the + * status field is equal to ZB_ZDP_SUCCESS. + * @param[out] user_data user data + * + * @see zb_zdo_node_desc_req() + */ +typedef void (*zb_zdo_node_desc_rsp)( + unsigned char status, + nwk_addr addr16, + const zb_zdo_node_descriptor_h node_desc, + void *user_data); + +/** + * @brief Sends 'node descriptor request' command + * @details The Node_Desc_req command is generated from a local device wishing to inquire + * as to the node descriptor of a remote device. This command shall be unicast either + * to the remote device itself or to an alternative device that contains the discovery + * information of the remote device. + * \n\n + * The local device shall generate the Node_Desc_req command using the format + * illustrated in param list. The NWKAddrOfInterest field shall contain the network + * address of the remote device for which the node descriptor is required. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_node_desc_rsp() + */ +int zb_zdo_node_desc_req( + zigbee_h handle, + nwk_addr addr16, + zb_zdo_node_desc_rsp cb, + void *user_data); + +/** + * @brief Called after 'power descriptor request' command + * @details The Power_Desc_rsp is generated by a remote device in response to a + * Power_Desc_req directed to the remote device. This command shall be unicast to + * the originator of the Power_Desc_req command.\n + * \n + * The remote device shall generate the Power_Desc_rsp command using the format + * illustrated in Table 2.93 in Zigbee Specification. + * The NWKAddrOfInterest field shall match that specified + * in the original Power_Desc_req command. If the NWKAddrOfInterest field + * matches the network address of the remote device, it shall set the Status field to + * SUCCESS and include its power descriptor in the PowerDescriptor field. + * If the NWKAddrOfInterest field does not match the network address of the + * remote device and it is an end device, it shall set the Status field to + * INV_REQUESTTYPE and not include the PowerDescriptor field. If the + * NWKAddrOfInterest field does not match the network address of the remote + * device and it is the coordinator or a router, it shall determine whether the + * NWKAddrOfInterest field matches the network address of one of its children. If + * the NWKAddrOfInterest field does not match the network address of one of the + * children of the remote device, it shall set the Status field to + * DEVICE_NOT_FOUND and not include the PowerDescriptor field.\n\n If the + * NWKAddrOfInterest matches the network address of one of the children of the + * remote device, it shall determine whether a power descriptor for that device is + * available. If a power descriptor is not available for the child indicated by the + * NWKAddrOfInterest field, the remote device shall set the Status field to + * NO_DESCRIPTOR and not include the PowerDescriptor field.\n\n If a power + * descriptor is available for the child indicated by the NWKAddrOfInterest field, + * the remote device shall set the Status field to SUCCESS and include the power + * descriptor of the matching child device in the PowerDescriptor field. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_DEVICE_NOT_FOUND \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_NO_DESCRIPTOR + * @param[out] addr16 Network address for the request + * @param[out] power_desc This field shall only be included in the frame if the + * @ status field is equal to ZB_ZDP_SUCCESS. + * @param[out] user_data user data + * + * @see zb_zdo_power_desc_req() + */ +typedef void (*zb_zdo_power_desc_rsp)( + unsigned char status, + nwk_addr addr16, + const zb_zdo_node_power_descriptor_h power_desc, + void *user_data); + +/** + * @brief Sends 'power descriptor request' command + * @details The Power_Desc_req command is generated from a local device wishing to + * inquire as to the power descriptor of a remote device. This command shall be + * unicast either to the remote device itself or to an alternative device that contains + * the discovery information of the remote device. + * \n\n + * The local device shall generate the Power_Desc_req command using the format + * illustrated in param list. The NWKAddrOfInterest field shall contain the network + * address of the remote device for which the power descriptor is required. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_power_desc_rsp() + */ +int zb_zdo_power_desc_req( + zigbee_h handle, + nwk_addr addr16, + zb_zdo_power_desc_rsp cb, + void *user_data); + +/** + * @brief Called after 'complex descriptor request' command + * @details The Complex_Desc_rsp is generated by a remote device in response to a + * Complex_Desc_req directed to the remote device. This command shall be unicast + * to the originator of the Complex_Desc_req command. + * The remote device shall generate the Complex_Desc_rsp command using the + * format illustrated in param list. The NWKAddrOfInterest field shall match that + * specified in the original Complex_Desc_req command. If the + * NWKAddrOfInterest field matches the network address of the remote device but a + * complex descriptor does not exist, it shall set the Status field to + * NOT_SUPPORTED, set the Length field to 0, and not include the + * ComplexDescriptor field. If the NWKAddrOfInterest field matches the network + * address of the remote device and a complex descriptor exists, it shall set the Status + * field to SUCCESS, set the Length field to the length of the complex descriptor, + * and include its complex descriptor (see sub-clause 2.3.2.6) in the + * ComplexDescriptor field.\n + * \n + * If the NWKAddrOfInterest field does not match the network address of the + * remote device and it is an end device, it shall set the Status field to + * INV_REQUESTTYPE, set the Length field to 0, and not include the + * ComplexDescriptor field. If the NWKAddrOfInterest field does not match the + * network address of the remote device and it is the coordinator or a router, it shall + * determine whether the NWKAddrOfInterest field matches the network address of + * one of its children. If the NWKAddrOfInterest field does not match the network + * address of one of the children of the remote device, it shall set the Status field to + * DEVICE_NOT_FOUND, set the Length field to 0, and not include the + * ComplexDescriptor field.\n\n If the NWKAddrOfInterest matches the network + * address of one of the children of the remote device, it shall determine whether a + * complex descriptor for that device is available. If a complex descriptor is not + * available for the child indicated by the NWKAddrOfInterest field, the remote + * device shall set the Status field to NO_DESCRIPTOR, set the Length field to 0, + * and not include the ComplexDescriptor field.\n\n If a complex descriptor is available + * for the child indicated by the NWKAddrOfInterest field, the remote device shall + * set the Status field to SUCCESS, set the Length field to the length of the complex + * descriptor for that device, and include the complex descriptor of the matching + * child device in the ComplexDescriptor field. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * #ZB_ZDP_DEVICE_NOT_FOUND \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_NO_DESCRIPTOR + * @param[out] addr16 Network address for the request + * @param[out] length Length in bytes of the complex_desc field + * @param[out] complex_desc This field shall only be included in the frame if the + * @ status field is equal to ZB_ZDP_SUCCESS. + * @param[out] user_data user data + * + * @see zb_zdo_complex_desc_req() + */ +typedef void (*zb_zdo_complex_desc_rsp)( + unsigned char status, + nwk_addr addr16, + unsigned char length, + unsigned char *complex_desc, + void *user_data); + +/** + * @brief Sends 'complex descriptor request' command + * @details The Complex_Desc_req command is generated from a local device wishing to + * inquire as to the complex descriptor of a remote device. This command shall be + * unicast either to the remote device itself or to an alternative device that contains + * the discovery information of the remote device. + * \n + * The local device shall generate the Complex_Desc_req command using the + * format illustrated in param list. The NWKAddrOfInterest field shall contain the + * network address of the remote device for which the complex descriptor is + * required. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_complex_desc_rsp() + */ +int zb_zdo_complex_desc_req( + zigbee_h handle, + nwk_addr addr16, + zb_zdo_complex_desc_rsp cb, + void *user_data); + +/** + * @brief Called after 'user descriptor request' command + * @details The User_Desc_rsp is generated by a remote device in response to a + * User_Desc_req directed to the remote device. This command shall be unicast to + * the originator of the User_Desc_req command.\n + * \n + * The remote device shall generate the User_Desc_rsp command using the format + * illustrated in Table 2.98 in Zigbee Specification. + * The NWKAddrOfInterest field shall match that specified + * in the original User_Desc_req command. If the NWKAddrOfInterest field + * matches the network address of the remote device but a user descriptor does not + * exist, it shall set the Status field to NO_DESCRIPTOR, set the Length field to 0, + * and not include the UserDescriptor field. If the NWKAddrOfInterest field + * matches the network address of the remote device and a user descriptor exists, it + * shall set the Status field to SUCCESS, set the Length field to the length of the user + * descriptor, and include its user descriptor in the UserDescriptor field. + * If the NWKAddrOfInterest field does not match the network address of the + * remote device and it is an end device, it shall set the Status field to + * INV_REQUESTTYPE, set the Length field to 0, and not include the + * UserDescriptor field.\n\n If the NWKAddrOfInterest field does not match the network + * address of the remote device and it is the coordinator or a router, it shall determine + * whether the NWKAddrOfInterest field matches the network address of one of its + * children.\n\n If the NWKAddrOfInterest field does not match the network address of + * one of the children of the remote device, it shall set the Status field to + * DEVICE_NOT_FOUND, set the Length field to 0, and not include the + * UserDescriptor field.\n\n If the NWKAddrOfInterest matches the network address of + * one of the children of the remote device, it shall determine whether a user + * descriptor for that device is available.\n\n If a user descriptor is not available for the + * child indicated by the NWKAddrOfInterest field, the remote device shall set the + * Status field to NO_DESCRIPTOR, set the Length field to 0, and not include the + * UserDescriptor field.\n\n If a user descriptor is available for the child indicated by the + * NWKAddrOfInterest field, the remote device shall set the Status field to + * SUCCESS, set the Length field to the length of the user descriptor for that device, + * and include the user descriptor of the matching child device in the UserDescriptor + * field. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * #ZB_ZDP_DEVICE_NOT_FOUND \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * #ZB_ZDP_NO_DESCRIPTOR + * @param[out] addr16 Network address for the request + * @param[out] length Length in bytes of the user_desc field + * @param[out] user_desc This field shall only be included in the frame if the + * status field is equal to ZB_ZDP_SUCCESS. + * @param[out] user_data user data + * + * @see zb_zdo_user_desc_req() + */ +typedef void (*zb_zdo_user_desc_rsp)( + unsigned char status, + nwk_addr addr16, + unsigned char len, + unsigned char *user_desc, + void *user_data); + +/** + * @brief Sends 'complex descriptor request' command + * @details The User_Desc_req command is generated from a local device wishing to inquire + * as to the user descriptor of a remote device. This command shall be unicast either + * to the remote device itself or to an alternative device that contains the discovery + * information of the remote device. + * \n + * The local device shall generate the User_Desc_req command using the format + * illustrated in Table 2.53 in Zigbee Specification. + * The NWKAddrOfInterest field shall contain the network + * address of the remote device for which the user descriptor is required. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_complex_desc_rsp() + */ +int zb_zdo_user_desc_req( + zigbee_h handle, + nwk_addr addr16, + zb_zdo_user_desc_rsp cb, + void *user_data); +/** + * @brief Called after 'user descriptor confirm' request + * @details The User_Desc_conf is generated by a remote device in response to a + * User_Desc_set directed to the remote device. This command shall be unicast to + * the originator of the User_Desc_set command. + * \n + * The remote device shall generate the User_Desc_conf command using the format + * illustrated in param list. The NWKAddrOfInterest field shall match that + * specified in the original User_Desc_set command. If the NWKAddrOfInterest + * field matches the network address of the remote device but a user descriptor does + * not exist, it shall set the Status field to NOT_SUPPORTED. If the + * NWKAddrOfInterest field matches the network address of the remote device and + * a user descriptor exists, it shall set the Status field to SUCCESS and configure the + * user descriptor with the ASCII character string specified in the original + * User_Desc_set command.\n + * \n + * If the NWKAddrOfInterest field does not match the network address of the + * remote device and it is an end device, it shall set the Status field to + * INV_REQUESTTYPE.\n\n If the NWKAddrOfInterest field does not match the + * network address of the remote device and it is the coordinator or a router, it shall + * determine whether the NWKAddrOfInterest field matches the network address of + * one of its children. If the NWKAddrOfInterest field does not match the network + * address of one of the children of the remote device, it shall set the Status field to + * DEVICE_NOT_FOUND.\n\n If the NWKAddrOfInterest matches the network + * address of one of the children of the remote device, it shall determine whether a + * user descriptor for that device is available. If a user descriptor is not available for + * the child indicated by the NWKAddrOfInterest field, the remote device shall set + * the Status field to NO_DESCRIPTOR.\n\n If a user descriptor is available for the + * child indicated by the NWKAddrOfInterest field, the remote device shall set the + * Status field to SUCCESS and configure the user descriptor with the ASCII + * character string specified in the original User_Desc_set command. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * returned value from NLME-GET.confirm primitive \n + * @param[out] user_data user data + * + * @see zb_zdo_user_desc_req() + */ +typedef void (*zb_zdo_user_desc_conf)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'user descriptor set request' command + * @details The User_Desc_set command is generated from a local device wishing to + * configure the user descriptor on a remote device. This command shall be unicast + * either to the remote device itself or to an alternative device that contains the + * discovery information of the remote device. + * \n\n + * The local device shall generate the User_Desc_set command using the format + * illustrated in param list. The NWKAddrOfInterest field shall contain the network + * address of the remote device for which the user descriptor is to be configured and + * the UserDescription field shall contain the ASCII character string that is to be + * configured in the user descriptor. Characters with ASCII codes numbered 0x00 + * through 0x1f are not permitted to be included in this string. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] len Length of the user_desc filed in bytes + * @param[in] user_desc Pointer of user description + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_user_desc_conf() + */ +int zb_zdo_user_desc_set( + zigbee_h handle, + nwk_addr addr16, + unsigned char len, + unsigned char *user_desc, + zb_zdo_user_desc_conf cb, + void *user_data); + +/** + * @brief Sends 'device announce request' command + * @details The Device_annce is provided to enable ZigBee devices on the network to notify + * other ZigBee devices that the device has joined or re-joined the network, + * identifying the device's 64-bit IEEE address and new 16-bit NWK address, and + * informing the Remote Devices of the capability of the ZigBee device.\n\n This + * command shall be invoked for all ZigBee end devices upon join or rejoin. This + * command may also be invoked by ZigBee routers upon join or rejoin as part of + * NWK address conflict resolution.\n\n The destination addressing on this primitive is + * broadcast to all devices for which macRxOnWhenIdle = TRUE. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 The IEEE address for device of interest + * @param[in] capability See zb_zdo_mac_capability_field_e in zb_zdo.h header file + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_user_desc_conf() + */ +int zb_zdo_device_annce( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + unsigned char capability); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_DEVICE_DISCOVERY_H__ */ diff --git a/include/zdo/zb_zdo_nwk_mgr.h b/include/zdo/zb_zdo_nwk_mgr.h new file mode 100644 index 0000000..dfff316 --- /dev/null +++ b/include/zdo/zb_zdo_nwk_mgr.h @@ -0,0 +1,672 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zdo_nwk_mgr.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_MODULE Network Manager + * + * @brief Zigbee provides API for Network Management. + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_OVERVIEW Overview + * This API set consists of ZDP network manager API + * + * @{ + */ + +/** + * @brief Called after 'network management discovery request' command + * @details The Mgmt_NWK_Disc_rsp is generated in response to an Mgmt_NWK_Disc_req. + * If this management command is not supported, a status + * of NOT_SUPPORTED shall be returned and all parameter fields after the Status + * field shall be omitted.\n\n Otherwise, the Remote Device shall implement the + * following process.\n\n + * Upon receipt of and after support for the Mgmt_NWK_Disc_req has been + * verified, the Remote Device shall issue an NLME-NETWORK- + * DISCOVERY.request primitive using the ScanChannels and ScanDuration + * parameters, supplied in the Mgmt_NWK_Disc_req command.\n\n Upon receipt of the + * NLME-NETWORK-DISCOVERY.confirm primitive, the Remote Device shall + * report the results, starting with the StartIndex element, via the\ + * Mgmt_NWK_Disc_rsp command.\n\n The NetworkList field shall contain whole + * NetworkList records, formatted as specified in Table 2.125, until the limit on + * MSDU size, i.e., aMaxMACFrameSize (see [B1]), is reached.\n\n The number of + * results reported shall be set in the NetworkListCount.\n\n + * + * @since_tizen 4.0 + * + * @param[out] status ZB_ZDP_NOT_SUPPORTED or returned value from NLME-NETWORK.DISCOVERY. + * request + * @param[out] network_count The total number of networks reported by the NLME-NETWORK- + * DISCOVERY.confirm. + * @param[out] start_idx The starting point in the NetworkList from the NLME-NETWORK- + * DISCOVERY.confirm where reporting begins for this response. + * @param[out] network_list_count The number of network list descriptors reported within + * this response. + * @param[out] nwk_list A list of network list descriptors. + * @param[out] user_data User data + * + * @see zb_zdo_mgmt_nwk_disc_req() + */ +typedef void (*zb_zdo_mgmt_nwk_disc_rsp)( + unsigned char status, + unsigned char network_count, + unsigned char start_idx, + unsigned char network_list_count, + const zb_zdo_network_list_record_h *nwk_list, + void *user_data); + +/** + * @brief Bitmask to scan all 802.15.4 channels. + */ +#define ZB_802_15_4_CHANNELS_MASK 0x07FFF800UL + +/** + * @brief Sends 'network discover management request' command + * @details The Mgmt_NWK_Disc_req is generated from a Local Device requesting that the + * Remote Device execute a Scan to report back networks in the vicinity of the Local + * Device.\n\n The destination addressing on this command shall be unicast. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 destination address + * @param[in] scan_channels The five most significant bits (b27,...,b31) are reserved. + * The 27 least significant bits (b0, b1,... b26) indicate + * which channels are to be scanned (1 = scan, 0 = do not scan) + * for each of the 27 valid channels. + * @param[in] scan_duration A value used to calculate the length of time to spend + * scanning each channel. The time spent scanning each channel is + * (aBaseSuperframeDuration * (2 n + 1)) symbols, where n is + * the value of the ScanDuration parameter. For more information + * on MAC sub-layer scanning + * @param[in] scan_count A number of beacon-request in one scan-duration + * @param[in] start_idx Starting index + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_nwk_disc_rsp() + */ +int zb_zdo_mgmt_nwk_disc_req( + zigbee_h handle, + nwk_addr addr16, + unsigned int scan_channels, + unsigned char scan_duration, + unsigned char scan_count, + unsigned char start_idx, + zb_zdo_mgmt_nwk_disc_rsp cb, + void *user_data); + +/** + * @brief Called after 'network management LQI request' command + * @details The Recover_Source_Bind_rsp is generated from a backup binding table cache + * device in response to a Recover_Source_Bind_req from a primary binding table + * cache and contains the status of the request.\n\n This command shall be unicast to the + * requesting device. If the responding device is not a backup binding table cache, it + * shall return a status of NOT_SUPPORTED.\n\n If the originator of the request is not + * recognized as a primary binding table cache, it shall return a status of + * INV_REQUESTTYPE. \n\n Otherwise, the backup binding table cache shall prepare a + * list of binding table entries from its backup beginning with StartIndex. \n\n It will + * fit in as many entries as possible into a Recover_Source_Bind_rsp command and return + * a status of SUCCESS.\n\n If StartIndex is more than the number of entries in the + * Source table, a status of NO_ENTRY is returned.\n\n For a successful response, + * SourceTableEntries is the total number of entries in the backup source table, and + * SourceTableListCount is the number of entries which is being returned in the + * response. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * #ZB_ZDP_TABLE_FULL \n + * #ZB_ZDP_INV_REQUESTTYPE \n + * @param[out] source_table_entries Total number of source table entries in the backup + * binding cache. + * @param[out] start_idx Starting index within the neighbor table to begin reporting for + * the neighbor table list. + * @param[out] neighbor_table_list_count The number of neighbor table entries included + * within neighbor table list. + * @param[out] neighbor_table_list A list of neighbor table list. + * @param[out] user_data User data + * + * @see zb_zdo_mgmt_lqi_req() + */ +typedef void (*zb_zdo_mgmt_lqi_rsp)( + unsigned char status, + unsigned char neighbor_table_entries, + unsigned char start_idx, + unsigned char neighbor_table_list_count, + const zb_zdo_neighbor_table_desc_h *neighbor_table_list, + void *user_data); + +/** + * @brief Sends 'LQI management request' command + * @details The Mgmt_Lqi_req is generated from a Local Device wishing to obtain a + * neighbor list for the Remote Device along with associated LQI values to each + * neighbor. The destination addressing on this command shall be unicast only and + * the destination address must be that of a ZigBee Coordinator or ZigBee Router. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 destination address + * @param[in] start_idx Starting index for the requested elements of the neighbor table + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_lqi_rsp() + */ +int zb_zdo_mgmt_lqi_req( + zigbee_h handle, + nwk_addr addr16, + unsigned char start_idx, + zb_zdo_mgmt_lqi_rsp cb, + void *user_data); + +/** + * @brief Called after 'routing management request' command + * @details The Mgmt_Rtg_rsp is generated in response to an Mgmt_Rtg_req. If this + * management command is not supported, a status of NOT_SUPPORTED shall be + * returned and all parameter fields after the Status field shall be omitted. Otherwise, + * the Remote Device shall implement the following processing. + * Upon receipt of and after support for the Mgmt_Rtg_req has been verified, the + * Remote Device shall perform an NLME-GET.request (for the nwkRouteTable + * attribute) and process the resulting NLME-GET.confirm (containing the + * nwkRouteTable attribute) to create the Mgmt_Rtg_rsp command. The + * Mgmt_Rtg_rsp command shall contain the same status that was contained in the + * NLME-GET.confirm primitive and if this was not SUCCESS, all parameter fields + * after the status field shall be omitted. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * returned value from NLME-GET.confirm primitive \n + * @param[out] routing_table_entries Total number of routing table entries within the + * remote device. + * @param[out] start_idx Starting index within the Routing Table to begin reporting for + * the RoutingTableList. + * @param[out] routing_table_list_count The number of routing table entries included + * within RoutingTableList. + * @param[out] neighbor_table_list A list of routing table list. + * @param[out] user_data User data + * + * @see zb_zdo_mgmt_rtg_req() + */ +typedef void (*zb_zdo_mgmt_rtg_rsp)( + unsigned char status, + unsigned char routing_table_entries, + unsigned char start_idx, + unsigned char routing_table_list_count, + const zb_zdo_routing_table_h *routing_table_list, + void *user_data); + +/** + * @brief Sends 'routing management request' command + * @details The Mgmt_Rtg_req is generated from a Local Device wishing to retrieve the + * ontents of the Routing Table from the Remote Device. The destination + * addressing on this command shall be unicast only and the destination address + * must be that of the ZigBee Router or ZigBee Coordinator. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 destination network address + * @param[in] start_idx Starting index for the requested elements of the routing table + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_rtg_rsp() + */ +int zb_zdo_mgmt_rtg_req( + zigbee_h handle, + nwk_addr addr16, + unsigned char start_idx, + zb_zdo_mgmt_rtg_rsp cb, + void *user_data); + +/** + * @brief Called after 'binding management request' command + * @details The Mgmt_Bind_rsp is generated in response to a Mgmt_Bind_req. If this + * management command is not supported, a status of NOT_SUPPORTED shall be + * returned and all parameter fields after the Status field shall be omitted. Otherwise, + * the Remote Device shall implement the following processing.\n\n + * Upon receipt of and after support for the Mgmt_Bind_req has been verified, the + * Remote Device shall perform an APSME-GET.request (for the apsBindingTable + * attribute) and process the resulting APSME-GET.confirm (containing the + * apsBindingTable attribute) to create the Mgmt_Bind_rsp command. The + * Mgmt_Bind_rsp command shall contain the same status that was contained in the + * APSME-GET.confirm primitive and if this was not SUCCESS, all parameter + * fields after the status field shall be omitted.\n\n + * From the apsBindingTable attribute, the binding table shall be accessed, starting + * with the index specified by StartIndex, and moved to the BindingTableList field of + * the Mgmt_Bind_rsp command. The entries reported from the binding table shall + * be those, starting with StartIndex and including whole BindingTableList records + * until the MSDU size limit, i.e., aMaxMACFrameSize, + * is reached. Within the Mgmt_Bind_Rsp command, the BindingTableEntries field + * shall represent the total number of Binding Table entries in the Remote Device. + * The BindingTableListCount field shall be the number of entries reported in the + * BindingTableList field of the Mgmt_Bind_req command. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * returned value from NLME-GET.confirm primitive \n + * @param[out] binding_table_entries Total number of Binding Table entries within the + * Remote Device. + * @param[out] start_idx Starting index within the Binding Table to begin reporting for + * the BindingTableList. + * @param[out] binding_table_list_count The number of binding table entries included + * within BindingTableList. + * @param[out] neighbor_table_list A list of routing table list. + * @param[out] user_data User data + * + * @see zb_zdo_mgmt_bind_req() + */ +typedef void (*zb_zdo_mgmt_bind_rsp)( + unsigned char status, + unsigned char binding_table_entries, + unsigned char start_idx, + unsigned char binding_table_list_count, + const zb_zdo_binding_table_h *binding_table_list, + void *user_data); + +/** + * @brief Sends 'binding management request' command + * @details The Mgmt_Bind_req is generated from a Local Device wishing to retrieve the + * contents of the Binding Table from the Remote Device. \n\n The destination + * addressing on this command shall be unicast only and the destination address + * must be that of a Primary binding table cache or source device holding its own + * binding table. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 destination network address + * @param[in] start_idx Starting index for the requested elements of the binding table + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_bind_rsp() + */ +int zb_zdo_mgmt_bind_req( + zigbee_h handle, + nwk_addr addr16, + unsigned char start_idx, + zb_zdo_mgmt_bind_rsp cb, + void *user_data); + +/** + * @brief Called after 'leave management request' command + * @details The Mgmt_Leave_rsp is generated in response to a Mgmt_Leave_req. \n\n If this + * management command is not supported, a status of NOT_SUPPORTED shall be + * returned. \n\n Otherwise, the Remote Device shall implement the following + * processing. + * Upon receipt of and after support for the Mgmt_Leave_req has been verified, the + * Remote Device shall execute the NLME-LEAVE.request to disassociate from the + * currently associated network. The Mgmt_Leave_rsp shall contain the same status + * that was contained in the NLME-LEAVE.confirm primitive. \n\n + * Once a device has disassociated, it may execute pre-programmed logic to perform + * NLME-NETWORK-DISCOVERY and NLME-JOIN to join/re-join a network. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * #ZB_ZDP_NOT_AUTHORIZED \n + * returned value from NLME-LEAVE.confirm primitive \n + * @param[out] user_data User data + * + * @see zb_zdo_mgmt_leave_req() + */ +typedef void (*zb_zdo_mgmt_leave_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Send 'leave device management request' command + * @details The Mgmt_Bind_req is generated from a Local Device wishing to retrieve the + * contents of the Binding Table from the Remote Device.\n\n The destination + * addressing on this command shall be unicast only and the destination address + * must be that of a Primary binding table cache or source device holding its own + * binding table. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr64 The IEEE address for designated device to leave + * @param[in] remove_children This field has a value of 1 if the device being asked to + * leave the network is also being asked to remove its child + * devices, if any. Otherwise, it has a value of 0. + * @param[in] rejoin This field has a value of 1 if the device being asked to leave from + * the current parent is requested to rejoin the network. Otherwise, + * it has a value of 0. + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_leave_rsp() + */ +int zb_zdo_mgmt_leave_req( + zigbee_h handle, + ieee_addr addr64, + bool remove_children, + bool rejoin, + zb_zdo_mgmt_leave_rsp cb, + void *user_data); + +#ifdef ZB_SUPPORT_PRIORITY_5 +/** + * @brief Called after 'direct join management request' command + * @details The Mgmt_Direct_Join_rsp is generated in response to a Mgmt_Direct_Join_req. + * If this management command is not supported, a status of NOT_SUPPORTED + * shall be returned.\n\n Otherwise, the Remote Device shall implement the following + * processing.\n\n + * Upon receipt and after support for the Mgmt_Direct_Join_req has been verified, + * the Remote Device shall execute the NLME-DIRECT-JOIN.request to directly + * associate the DeviceAddress contained in the Mgmt_Direct_Join_req to the + * network.\n\n The Mgmt_Direct_Join_rsp shall contain the same status that was + * contained in the NLME-DIRECT-JOIN.confirm primitive. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * #ZB_ZDP_NOT_AUTHORIZED \n + * returned value from NLME-DIRECT-JOIN.confirm primitive \n + * @param[out] user_data User data + * + * @see zb_zdo_mgmt_direct_join_rsp() + */ +typedef void (*zb_zdo_mgmt_direct_join_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'direct join device management request' command + * @details The Mgmt_Direct_Join_req is generated from a Local Device requesting that a + * Remote Device permit a device designated by DeviceAddress to join the network + * directly.\n\n The Mgmt_Direct_Join_req is generated by a management application + * which directs the request to a Remote Device where the NLME-DIRECT- + * JOIN.request is to be executed using the parameter supplied by + * Mgmt_Direct_Join_req. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr64 The IEEE address for designated device to leave + * @param[in] capability See zb_zdo_mac_capability_field_e in zb_zdo.h header file + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_direct_join_rsp() + */ +int zb_zdo_mgmt_direct_join_req( + zigbee_h handle, + ieee_addr addr64, + unsigned char capability, + zb_zdo_mgmt_direct_join_rsp cb, + void *user_data); + +#endif /* ZB_SUPPORT_PRIORITY_5*/ + +/** + * @brief Called after 'permit joining management request' command + * @details The Mgmt_Permit_Joining_rsp is generated in response to a unicast + * Mgmt_Permit_Joining_req.\n\n In the description which follows, note that no + * response shall be sent if the Mgmt_Permit_Joining_req was received as a + * broadcast to all routers.\n\n If this management command is not permitted by the + * requesting device, a status of INVALID_REQUEST shall be returned.\n\n Upon + * receipt and after support for Mgmt_Permit_Joining_req has been verified, the + * Remote Device shall execute the NLME-PERMIT-JOINING.request.\n\n The + * Mgmt_Permit-Joining_rsp shall contain the same status that was contained in the + * NLME-PERMIT-JOINING.confirm primitive. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * #ZB_ZDP_NOT_AUTHORIZED \n + * returned value from NLME-DIRECT-JOINING.confirm primitive \n + * @param[out] user_data User data + * + * @see zb_zdo_mgmt_direct_join_rsp() + */ +typedef void (*zb_zdo_mgmt_permit_joining_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'permit join device management request' command + * @details The Mgmt_Permit_Joining_req is generated from a Local Device requesting that + * a remote device or devices allow or disallow association.\n\n The + * Mgmt_Permit_Joining_req is generated by a management application or + * commissioning tool which directs the request to a remote device(s) where the + * NLME-PERMIT-JOINING.request is executed using the PermitDuration + * parameter supplied by Mgmt_Permit_Joining_req.\n\n Additionally, if the remote + * device is the Trust Center and TC_Significance is set to 1, the Trust Center + * authentication policy will be affected. The addressing may be unicast or + * 'broadcast to all routers and coordinator'. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 destination network address + * @param[in] permit_duration The length of time in seconds during which the ZigBee + * coordinator or router will allow associations. \n + * The value 0x00 and 0xff indicate that permission is + * disabled or enabled, respectively, without a specified time + * limit. + * @param[in] tc_significance If this is set to 0x01 and the remote device is the Trust Center, + * the command affects the Trust Center authentication policy as + * described in the sub-clauses below; \n \n + * If this is set to 0x00, there is no effect on the Trust Center. + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_OUT_OF_MEMORY Out-of-memory + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_permit_joining_rsp() + */ +int zb_zdo_mgmt_permit_joining_req( + zigbee_h handle, + nwk_addr addr16, + unsigned char permit_duration, + unsigned char tc_significance, + zb_zdo_mgmt_permit_joining_rsp cb, + void *user_data); + +#ifdef ZB_SUPPORT_PRIORITY_5 +/** + * @brief Called after 'cache management request' command + * @details The Mgmt_Cache_rsp is generated in response to an Mgmt_Cache_req. If this + * management command is not supported, or the Remote Device is not a Primary + * Cache Device, a status of NOT_SUPPORTED shall be returned and all parameter + * fields after the Status field shall be omitted. Otherwise, the Remote Device shall + * implement the following processing.\n\n Upon receipt of the Mgmt_Cache_req and + * after support for the Mgmt_Cache_req has been verified, the Remote Device shall + * access an internally maintained list of registered ZigBee End Devices utilizing the + * discovery cache on this Primary Discovery Cache device.\n\n The entries reported + * shall be those, starting with StartIndex and including whole DiscoveryCacheList + * records (see Table 2.139) until the limit on MSDU size, i.e., aMaxMACFrameSize + * (see [B1]), is reached.\n\n Within the Mgmt_Cache_rsp command, the + * DiscoveryCacheListEntries field shall represent the total number of registered + * entries in the Remote Device. The parameter DiscoveryCacheListCount shall be + * the number of entries reported in the DiscoveryCacheList field of the + * Mgmt_Cache_rsp command. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_NOT_SUPPORTED \n + * @param[out] discovery_cache_entries discovery cache entries + * @param[out] start_idx data User data + * @param[out] discovery_cache_list_count The list shall contain the number of elements + * given by the DiscoveryCacheListCount parameter. + * @param[out] discover_cache_list A list of descriptors. + * @param[out] user_data User data + * + * @see zb_zdo_mgmt_cache_req() + */ +typedef void (*zb_zdo_mgmt_cache_rsp)( + unsigned char status, + unsigned char discovery_cache_entries, + unsigned char start_idx, + unsigned char discovery_cache_list_count, + const zb_zdo_discovery_cache_h *discover_cache_list, + void *user_data); + +/** + * @brief Sends 'cache management request' command + * @details The Mgmt_Cache_req is provided to enable ZigBee devices on the network to + * retrieve a list of ZigBee End Devices registered with a Primary Discovery Cache + * device.\n\n The destination addressing on this primitive shall be unicast. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 destination network address + * @param[in] start_idx Starring index for the requested elements of the discover cache + * list + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_cache_rsp() + */ +int zb_zdo_mgmt_cache_req( + zigbee_h handle, + nwk_addr addr16, + unsigned char start_idx, + zb_zdo_mgmt_cache_rsp cb, + void *user_data); +#endif /* ZB_SUPPORT_PRIORITY_5 */ + +/** + * @brief Sends 'update network management request' command + * @details This command is provided to allow updating of network configuration parameters + * or to request information from devices on network conditions in the local + * operating environment.\n\n The destination addressing on this primitive shall be + * unicast or broadcast to all devices for which macRxOnWhenIdle = TRUE. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] scan_channels The five most significant bits (b27,...,b31) are reserved. + * The 27 least significant bits (b0, b1,... b26) indicate + * which channels are to be scanned (1 = scan, 0 = do not scan) + * for each of the 27 valid channels. + * @param[in] scan_duration A value used to calculate the length of time to spend + * scanning each channel.\n The time spent scanning each channel + * is (aBaseSuperframeDuration * (2 n + 1)) symbols, where n is + * the value of the ScanDuration parameter. For more information + * on MAC sub-layer scanning + * @param[in] scan_count This field represents the number of energy scan to be conducted + * and reported + * @param[in] nwk_update_id The value of the nwkUpdateId contained in this request. + * This value is set by the Network Channel Manager prior to + * sending the message. \n + * This field shall only be present of the ScanDuration is 0xfe + * or 0xff. If the ScanDuration is 0xff, then the value in the + * nwkUpdateID shall be ignored. \n + * @param[in] nwk_manager_addr This field shall be present only if the ScanDuration is set + * to 0xff, and, where present, indicates the NWK address for + * the device with the Network Manager bit set in its Node + * Descriptor + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_INVALID_ADDRESS Invalid address + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_mgmt_nwk_update_noti() + */ +int zb_zdo_mgmt_nwk_update_req( + zigbee_h handle, + unsigned int scan_channels, + unsigned char scan_duration, + unsigned char scan_count, + unsigned char nwk_update_id, + nwk_addr nwk_manager_addr); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_NETWORK_MANAGER_H__ */ diff --git a/include/zdo/zb_zdo_svc_disc.h b/include/zdo/zb_zdo_svc_disc.h new file mode 100644 index 0000000..03c538b --- /dev/null +++ b/include/zdo/zb_zdo_svc_disc.h @@ -0,0 +1,570 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_H__ +#define __TIZEN_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_H__ + +#ifdef ZB_SUPPORT_PRIORITY_5 + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file zb_zdo_dev_disc.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @defgroup CAPI_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_MODULE Service Discovery + * + * @brief Zigbee provides API for Service Discover. + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_HEADER Header + * \#include + * + * @section CAPI_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_OVERVIEW Overview + * This API set consists of ZDP service discovery API + * + * @{ + */ + +/** + * @brief Called after receiving 'find system server request' + * @details The System_Server_Discovery_rsp is generated from Remote Devices on receipt + * of a System_Server_Discovery_req primitive if the parameter matches the Server + * Mask field in its node descriptor. If there is no match, the + * System_Server_Discovery_req shall be ignored and no response given. Matching + * is performed by masking the ServerMask parameter of the + * System_Server_Discovery_req with the Server Mask field in the node descriptor. + * This command shall be unicast to the device which sent + * System_Server_Discovery_req with Acknowledge request set in TxOptions. The + * parameter ServerMask contains the bits in the parameter of the request which + * match the server mask in the node descriptor. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * returned value from NLME-GET.confirm primitive \n + * @param[out] server_mask Server Mask Bit Assignment + * @param[out] user_data user data + * + * @see zb_zdo_system_server_discover_req() + */ +typedef void (*zb_zdo_system_server_discover_rsp)( + unsigned char status, + unsigned short server_mask, + void *user_data); + +/** + * @brief Sends 'find system server request' command + * @details The System_Server_Discovery_req is generated from a Local Device wishing to + * discover the location of a particular system server or servers as indicated by the + * ServerMask parameter.\n\n The destination addressing on this request is 'broadcast to + * all devices for which macRxOnWhenIdle = TRUE.' + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] server_mask Server Mask Bit Assignment + * @param[in] cb The callback function + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_system_server_discover_rsp() + */ +int zb_zdo_system_server_discover_req( + zigbee_h handle, + unsigned short server_mask, + zb_zdo_system_server_discover_rsp cb, + void *user_data); + +/** + * @brief Called after 'find node cache request' command + * @details The Find_node_cache_rsp is provided to notify a Local Device of the successful + * iscovery of the Primary Discovery Cache device for the given NWKAddr and + * EEEAddr fields supplied in the request, or to signify that the device of interest is + * apable of responding to discovery requests.\n\n The Find_node_cache_rsp shall be + * enerated only by Primary Discovery Cache devices holding discovery + * nformation for the NWKAddr and IEEEAddr in the request or the device of + * nterest itself and all other Remote Devices shall not supply a response. + * + * @since_tizen 4.0 + * + * @param[out] cache_nwk_addr NWK Address for the Primary Discovery Cache device holding + * the discovery information. + * @param[out] addr16 Server NWK Address for the device of interest. + * @param[out] addr64 Server IEEE Address for the device of interest. + * @param[out] user_data user data + * + * @see zb_zdo_find_node_cache_req() + */ +typedef void (*zb_zdo_find_node_cache_rsp)( + nwk_addr cache_nwk_addr, + nwk_addr addr16, + ieee_addr addr64, + void *user_data); + +/** + * @brief Send 'find Node cache store request' command + * @details The Find_node_cache_req is provided to enable ZigBee devices on the network to + * broadcast to all devices for which macRxOnWhenIdle = TRUE a request to find a + * device on the network that holds discovery information for the device of interest, + * as specified in the request parameters.\n\n The effect of a successful + * Find_node_cache_req is to have the Primary Discovery Cache device, holding + * discovery information for the device of interest, unicast a Find_node_cache_rsp + * back to the Local Device. Note that, like the NWK_addr_req, only the device + * meeting this criteria shall respond to the request generated by + * Find_node_cache_req. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 IEEE address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_remove_node_cache_rsp() + */ +int zb_zdo_find_node_cache_req( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + zb_zdo_find_node_cache_rsp cb, + void *user_data); + +/** + * @brief Called after 'find discovery cache request' command + * @details The Find_node_cache_rsp is provided to notify a Local Device of the successful + * discovery of the Primary Discovery Cache device for the given NWKAddr and + * IEEEAddr fields supplied in the request, or to signify that the device of interest is + * capable of responding to discovery requests.\n\n The Find_node_cache_rsp shall be + * generated only by Primary Discovery Cache devices holding discovery + * information for the NWKAddr and IEEEAddr in the request or the device of + * interest itself and all other Remote Devices shall not supply a response. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * returned value from NLME-GET.confirm primitive \n + * @param[out] user_data user data + * + * @see zb_zdo_discovery_cache_req() + */ +typedef void (*zb_zdo_discovery_cache_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'discovery cache request' command + * @details The Discovery_Cache_req is provided to enable devices on the network to locate + * a Primary Discovery Cache device on the network.\n\n The destination addressing on + * this primitive shall be broadcast to all devices for which macRxOnWhenIdle = + * TRUE. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 IEEE address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_remove_node_cache_rsp() + */ +int zb_zdo_discovery_cache_req( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + zb_zdo_discovery_cache_rsp cb, + void *user_data); + +/** + * @brief Called after 'find discovery store request' command + * @details The Discovery_store_rsp is provided to notify a Local Device of the request status + * from a Primary Discovery Cache device. Included in the response is a status code + * to notify the Local Device whether the request is successful (the Primary Cache + * Device has space to store the discovery cache data for the Local Device), whether + * the request is unsupported (meaning the Remote Device is not a Primary + * Discovery Cache device), or insufficient space exists. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INSUFFICIENT_SPACE \n + * #ZB_ZDP_NOT_SUPPORTED \n + * @param[out] user_data user data + * + * @see zb_zdo_discovery_store_req() + */ +typedef void (*zb_zdo_discovery_store_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'discovery store request' command + * @details The Discovery_store_req is provided to enable ZigBee end devices on the + * network to request storage of their discovery cache information on a Primary + * Discovery Cache device.\n\n Included in the request is the amount of storage space + * the Local Device requires.\n\n + * The destination addressing on this request is unicast. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 IEEE address for device of interest + * @param[in] node_desc_size Size of node description structure + * @param[in] power_desc_size Size of power description structure + * @param[in] active_ep_size Number of active EP + * @param[in] simple_desc_count Number of simple description structure + * @param[in] simple_desc_list Pointer of simple description structure size + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_remove_node_cache_rsp() + */ +int zb_zdo_discovery_store_req( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + unsigned char node_desc_size, + unsigned char power_desc_size, + unsigned char active_ep_size, + unsigned char simple_desc_count, + unsigned char *simple_desc_list, + zb_zdo_discovery_store_rsp cb, + void *user_data); + +/** + * @brief Called after 'node description store request' command + * @details The Node_store_rsp is provided to notify a Local Device of the request status + * from a Primary Discovery Cache device.\n\n Included in the response is a status code + * to notify the Local Device whether the request is successful (the Primary Cache + * Device has space to store the discovery cache data for the Local Device), whether + * the request is not supported (meaning the Remote Device is not a Primary + * Discovery Cache device), or insufficient space exists. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INSUFFICIENT_SPACE \n + * #ZB_ZDP_NOT_PERMITED \n + * #ZB_ZDP_NOT_SUPPORTED \n + * @param[out] user_data user data + * + * @see zb_zdo_node_desc_store_req() + */ +typedef void (*zb_zdo_node_desc_store_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'node description store request' command + * @details The Node_Desc_store_req is provided to enable ZigBee end devices on the + * network to request storage of their Node Descriptor on a Primary Discovery + * Cache device which has previously received a SUCCESS status from a + * Discovery_store_req to the same Primary Discovery Cache device.\n\n Included in + * this request is the Node Descriptor the Local Device wishes to cache. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 IEEE address for device of interest + * @param[in] nodedsc Pointer of node description structure + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_remove_node_cache_rsp() + */ +int zb_zdo_node_desc_store_req( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + zb_zdo_node_descriptor_h nodedsc, + zb_zdo_node_desc_store_rsp cb, + void *user_data); + +/** + * @brief Called after 'power description store request' command + * @details The Power_Desc_store_rsp is provided to notify a Local Device of the request + * status from a Primary Discovery Cache device. Included in the response is a status + * code to notify the Local Device whether the request is successful (the Primary + * Cache Device has space to store the discovery cache data for the Local Device), + * whether the request is not supported (meaning the Remote Device is not a Primary + * Discovery Cache device), or insufficient space exists. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INSUFFICIENT_SPACE \n + * #ZB_ZDP_NOT_PERMITED \n + * #ZB_ZDP_NOT_SUPPORTED \n + * @param[out] user_data user data + * + * @see zb_zdo_power_desc_store_req() + */ +typedef void (*zb_zdo_power_desc_store_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'power description store request' command + * @details The Power_Desc_store_req is provided to enable ZigBee end devices on the + * network to request storage of their Power Descriptor on a Primary Discovery + * Cache device which has previously received a SUCCESS status from a + * Discovery_store_req to the same Primary Discovery Cache device. Included in + * this request is the Power Descriptor the Local Device wishes to cache. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 IEEE address for device of interest + * @param[in] powerdsc Pointer of power description structure + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_remove_node_cache_rsp() + */ +int zb_zdo_power_desc_store_req( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + zb_zdo_node_power_descriptor_h powerdsc, + zb_zdo_power_desc_store_rsp cb, + void *user_data); + +/** + * @brief Called after 'active end-point store request' command + * @details The Active_EP_store_rsp is provided to notify a Local Device of the request + * status from a Primary Discovery Cache device.\n\n Included in the response is a status + * code to notify the Local Device whether the request is successful (the Primary + * Cache Device has space to store the discovery cache data for the Local Device), + * the request is not supported (meaning the Remote Device is not a Primary + * Discovery Cache device), or insufficient space exists. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INSUFFICIENT_SPACE \n + * #ZB_ZDP_NOT_PERMITED \n + * #ZB_ZDP_NOT_SUPPORTED \n + * @param[out] user_data user data + * + * @see zb_zdo_active_ep_store_req() + */ +typedef void (*zb_zdo_active_ep_store_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'active end-point store request' command + * @details The Simple_desc_store_req is provided to enable ZigBee end devices on the + * network to request storage of their list of Simple Descriptors on a Primary + * Discovery Cache device which has previously received a SUCCESS status from a + * Discovery_store_req to the same Primary Discovery Cache device. Note that each + * Simple Descriptor for every active endpoint on the Local Device must be + * individually uploaded to the Primary Discovery Cache device via this command + * to enable cached discovery.\n\n Included in this request is the length of the Simple + * Descriptor the Local Device wishes to cache and the Simple Descriptor itself.\n\n The + * endpoint is a field within the Simple Descriptor and is accessed by the Remote + * Device to manage the discovery cache information for the Local Device. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 IEEE address for device of interest + * @param[in] active_ep_count Number of End-point List + * @param[in] ep_list End-point list + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_remove_node_cache_rsp() + */ +int zb_zdo_active_ep_store_req( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + unsigned char active_ep_count, + unsigned char *ep_list, + zb_zdo_active_ep_store_rsp cb, + void *user_data); + +/** + * @brief Called after 'simple description store request' command + * @details The Simple_Desc_store_rsp is provided to notify a Local Device of the request + * status from a Primary Discovery Cache device.\n\n Included in the response is a status + * code to notify the Local Device whether the request is successful (the Primary + * Cache Device has space to store the discovery cache data for the Local Device), + * the request is not supported (meaning the Remote Device is not a Primary + * Discovery Cache device), or insufficient space exists. + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INSUFFICIENT_SPACE \n + * #ZB_ZDP_NOT_PERMITED \n + * #ZB_ZDP_NOT_SUPPORTED \n + * @param[out] user_data user data + * + * @see zb_zdo_simple_desc_store_req() + */ +typedef void (*zb_zdo_simple_desc_store_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'simple description store request' command + * @details The Simple_desc_store_req is provided to enable ZigBee end devices on the + * network to request storage of their list of Simple Descriptors on a Primary + * Discovery Cache device which has previously received a SUCCESS status from a + * Discovery_store_req to the same Primary Discovery Cache device.\n\n Note that each + * Simple Descriptor for every active endpoint on the Local Device must be + * individually uploaded to the Primary Discovery Cache device via this command + * to enable cached discovery.\n\n Included in this request is the length of the Simple + * Descriptor the Local Device wishes to cache and the Simple Descriptor itself. The + * endpoint is a field within the Simple Descriptor and is accessed by the Remote + * Device to manage the discovery cache information for the Local Device. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 IEEE address for device of interest + * @param[in] simpledsc Pointer of simple description structure + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_remove_node_cache_rsp() + */ +int zb_zdo_simple_desc_store_req( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + zb_zdo_simple_desc_h simpledsc, + zb_zdo_simple_desc_store_rsp cb, + void *user_data); + +/** + * @brief Called after 'simple description remove request' command + * @details The Remove_node_cache_rsp is provided to notify a Local Device of the request + * status from a Primary Discovery Cache device.\n\n Included in the response is a status + * code to notify the Local Device whether the request is successful (the Primary + * Cache Device has removed the discovery cache data for the indicated device of + * interest), or the request is not supported (meaning the Remote Device is not a + * Primary Discovery Cache device). + * + * @since_tizen 4.0 + * + * @param[out] status #ZB_ZDP_SUCCESS \n + * #ZB_ZDP_INSUFFICIENT_SPACE \n + * #ZB_ZDP_NOT_PERMITED \n + * #ZB_ZDP_NOT_SUPPORTED \n + * @param[out] user_data user data + * + * @see zb_zdo_remove_node_cache_req() + */ +typedef void (*zb_zdo_remove_node_cache_rsp)( + unsigned char status, + void *user_data); + +/** + * @brief Sends 'remove node cache request' command + * @details The Remove_node_cache_req is provided to enable ZigBee devices on the + * network to request removal of discovery cache information for a specified ZigBee + * end device from a Primary Discovery Cache device.\n\n The effect of a successful + * Remove_node_cache_req is to undo a previously successful Discovery_store_req + * and additionally remove any cache information stored on behalf of the specified + * ZigBee end device on the Primary Discovery Cache device. + * + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee + * @param[in] addr16 Network address for device of interest + * @param[in] addr64 IEEE address for device of interest + * @param[in] cb Response callback + * @param[in] user_data user data + * + * @return 0 on success, otherwise a negative error value. + * @retval #ZIGBEE_ERROR_NONE Successful + * @retval #ZIGBEE_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #ZIGBEE_ERROR_IO_ERROR Unexpected d-bus error + * + * @see zb_zdo_remove_node_cache_rsp() + */ +int zb_zdo_remove_node_cache_req( + zigbee_h handle, + nwk_addr addr16, + ieee_addr addr64, + zb_zdo_remove_node_cache_rsp cb, + void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZB_SUPPORT_PRIORITY_5 */ + +#endif /* __TIZEN_NETWORK_ZIGBEE_ZDO_SERVICE_DISCOVERY_H__ */ diff --git a/include/zdo/zb_zdo_type.h b/include/zdo/zb_zdo_type.h new file mode 100644 index 0000000..e40f74c --- /dev/null +++ b/include/zdo/zb_zdo_type.h @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __ZB_ZDO_TYPE_H__ +#define __ZB_ZDO_TYPE_H__ + +#include + +/** + * @file zb_zdo_type.h + */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.138 ZDP Enumerations Description + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_SUCCESS = 0, /**< Success */ + ZB_ZDP_INV_REQUESTTYPE = 0x80, /**< Invalid Request Type */ + ZB_ZDP_DEVICE_NOT_FOUND = 0x81, /**< Device Not Found */ + ZB_ZDP_INVALID_EP = 0x82, /**< Invalid Endpoint */ + ZB_ZDP_NOT_ACTIVE = 0x83, /**< Not Active */ + ZB_ZDP_NOT_SUPPORTED = 0x84, /**< Not Supported */ + ZB_ZDP_TIMEOUT = 0x85, /**< Timeout */ + ZB_ZDP_NO_MATCH = 0x86, /**< No Match */ + ZB_ZDP_NO_ENTRY = 0x88, /**< No Entry */ + ZB_ZDP_NO_DESCRIPTOR = 0x89, /**< No Descriptor */ + ZB_ZDP_INSUFFICIENT_SPACE = 0x8A, /**< Insufficient Space */ + ZB_ZDP_NOT_PERMITED = 0x8B, /**< Not Permitted */ + ZB_ZDP_TABLE_FULL = 0x8C, /**< Table Full */ + ZB_ZDP_NOT_AUTHORIZED = 0x8D, /**< Not Authorized */ + ZB_ZDP_DEVICE_BINDING_TABLE_FULL = 0x8E, /**< Binding Table Full */ + ZB_ZDP_UNKNOWN = 0xFF /**< Unknown */ +} zb_zdo_status_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief RequestType Enumeration + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_SINGLE_DEVICE_RESPONSE = 0, /**< 0 : Single Device Response */ + ZB_ZDP_EXTENDED_RESPONSE = 1, /**< 1 : Extended Response */ +} zb_zdo_request_type_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.30 Values of the Logical Type Field + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_COORDINATOR = 0, /**< Coordinator */ + ZB_ZDP_ROUTER = 1, /**< Router */ + ZB_ZDP_END_DEVIEC = 2, /**< End Device */ +} zb_zdo_logical_type_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.31 Values of the Frequency Band Field + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_868_868_6_MHZ = 0, /**< 868~888.6MHz */ + ZB_ZDP_902_928_MHA = 2, /**< 902~928MHz */ + ZB_ZDP_2400_2483_5_MHZ = 3, /**< 2400~2483.5MHz */ +} zb_zdo_frequency_band_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Alternative PAN coordinator bit in MAC capability Flags + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_DO_NOT_SUPPORT_PAN_COORDINATOR = 0, /**< Otherwise..*/ + ZB_ZDP_SUPPORT_PAN_COORDINATOR = 1, /**< This node is capable of becoming a PAN + coordinator. */ +} zb_zdo_alternative_pan_coordinator_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Device type bit in MAC capability Flags + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_RFD = 0, /**< This node is a reduced function device (RFD) */ + ZB_ZDP_FFD = 1, /**< This node is a full function device (FFD) */ +} zb_zdo_device_type_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Power Source bit in MAC capability Flags + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_NO_NODE_POWER_DESCRIPTION = 0, /**< Otherwise.. */ + ZB_ZDP_MAIN_POWER = 1, /**< Current power source is main power. This information is + derived from the node current power source field of the node power descriptor */ +} zb_zdo_power_source_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Receiver on when idle bit in MAC capability Flags + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_KEEP_POWER_SAVE_MODE = 0, /**< Otherwise.. */ + ZB_ZDP_DO_NOT_POWER_SAVE_MODE = 1, /**< The device does not disable its receiver to + conserve power during idle periods. */ +} zb_zdo_receiver_on_when_idle_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Security capability bit in MAC capability Flags + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_DO_NOT_SUPPORT_SECURITY_MODE = 0, /**< ZDP does not support security mode */ + ZB_ZDP_SUPPORT_SECURITY_MODE = 1, /**< ZDP support security mode */ +} zb_zdo_security_capability_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Format of the MAC Capability Flags Field in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR = (1 << 0), /**< Alternative Pan Coordinator see + #zb_zdo_alternative_pan_coordinator_e */ + ZB_ZDP_DEVICE_TYPE = (1 << 1), /**< Device Type see #zb_zdo_device_type_e */ + ZB_ZDP_POWER_SOURCE = (1 << 2), /**< Power Source see #zb_zdo_power_source_e */ + ZB_ZDP_RECEIVER_ON_WHEN_IDLE = (1 << 3), /**< Register on When Idle + see #zb_zdo_receiver_on_when_idle_e */ + ZB_ZDP_SECURITY_CAPABILITY = (1 << 6), /**< Security Capability + see #zb_zdo_security_capability_e */ + ZB_ZDP_ALLOCATE_ADDRESS = (1 << 7), /**< Allocated Address.\n + This mean device receive network address from coordinator\n + This field will always have a value of 1 in implementations of IEEE 802.15.4 spec, + indicating that the joining device must be issued a 16-bit short address */ +} zb_zdo_mac_capability_field_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.32 Server Mask Bit Assignments + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_PRIMARY_TRUST_CENTER = (1 << 0), /**< Primary Trust Center */ + ZB_ZDP_BACKUP_TRUST_CENTER = (1 << 1), /**< Backup Trust Center */ + ZB_ZDP_PRIMARY_BINDING_TABLE_CACHE = (1 << 2), /**< Primary Binding Table Cache */ + ZB_ZDP_BACKUP_BINDING_TABLE_CACHE = (1 << 3), /**< Backup Binding Table Cache */ + ZB_ZDP_PRIMARY_DISCOVERY_CACHE = (1 << 4), /**< Primary Discovery Cache */ + ZB_ZDP_BACKUP_DISCOVERY_CACHE = (1 << 5), /**< Backup Discovery Cache */ + ZB_ZDP_NETWORK_MANAGER = (1 << 6), /**< Network Manager */ +} zb_zdo_server_mask_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.29 Fields of the Node Descriptor + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * @details Type and capabilities of the node. + * + * @since_tizen 4.0 + */ +typedef struct zb_zdo_node_descriptor_s* zb_zdo_node_descriptor_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.35 Values of the Current Power Mode Field in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_RECEVIER_SYNCHRONIZED_WITH_RECEVIER_ON = 0, /**< Register Synchronized with Receiver On */ + ZB_ZDP_RECEIVER_COMES_ON_PERIODICALLY = (1 << 0), /**< Register Comes on Periodically */ + ZB_ZDP_RECEIVER_COMES_ON_WHEN_STIMULATED = (1 << 1), /**< Register Comes on When Stimulated */ +} zb_zdo_current_power_mode_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.34 Fields of the Node Power Descriptor + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_CONSTANT_POWER = 0, /**< Constant Power */ + ZB_ZDP_RECHARGEABLE_BATTERY = 1, /**< Rechargeable Battery */ + ZB_ZDP_DISPOSABLE_BATTERY = 2, /**< Disposable Battery */ +} zb_zdo_available_power_source_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.36 Values of the Available Power Sources Field in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_ZDP_CHARGE_LEVEL_CRITICAL = 0, /**< Charge Level Critical */ + ZB_ZDP_CHARGE_LEVEL_33 = 1, /**< Charge Level 33% */ + ZB_ZDP_CHARGE_LEVEL_66 = 2, /**< Charge Level 66% */ + ZB_ZDP_CHARGE_LEVEL_100 = 3, /**< Charge Level 100% */ +} zb_zdo_current_power_source_level_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Binding type + * + * @since_tizen 4.0 + */ +typedef enum { + ZB_UNICAST_BINDING = 0x03, /**< A unicast binding whose 64-bit identifier is the + destination ieee_addr. */ + ZB_MANY_TO_ONE_BINDING = 0x83, /**< A unicast binding whose 64-bit identifier is the + many-to-one destination ieee_addr. A Route discovery + should be disabled when sending unicast via may-to-one + binding */ + ZB_MULTICAST_BINDING = 0x01, /**< A multicast binding whose 64-bit identifier is the + group address. A multicast binding can be used to send + messages to the group and to receive message sent to + the group */ +} zb_binding_type_e; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.34 Fields of the Node Power Descriptor in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * @details Node power characteristics. + * + * @since_tizen 4.0 + */ +typedef struct zb_zdo_node_power_descriptor_s* zb_zdo_node_power_descriptor_h; + + +#define MAX_ENDPOINT_CLUSTERS 32 /**< Cluster counts to handle with */ + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @details Device descriptions contained in node. + * + * @since_tizen 4.0 + */ +typedef struct zb_zdo_simple_desc_s* zb_zdo_simple_desc_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief The handle of zigbee end-device information + * @details a zb_end_device_info_h is an opaque data structure.\n + * zb_end_device_info_h is a data type of network address, IEEE address, endpoint count + * and endpoint information structure. + * + * @since_tizen 4.0 + */ +typedef struct zb_end_device_info_s* zb_end_device_info_h; + + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.125 NetworkList Record Format in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef struct zb_zdo_network_list_record_s* zb_zdo_network_list_record_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.127 NeighborTableList Record Format in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef struct zb_zdo_neighbor_table_desc_s* zb_zdo_neighbor_table_desc_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.129 RoutingTableList Record Format in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef struct zb_zdo_routing_table_s* zb_zdo_routing_table_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.131 BindingTableList Record Format in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef struct zb_zdo_binding_table_s* zb_zdo_binding_table_h; + +/** + * @ingroup CAPI_NETWORK_ZIGBEE_ZDO_MODULE + * @brief Table 2.135 DiscoveryCacheList Record Format in Zigbee Specification. + * See more http://www.zigbee.org/download/standards-zigbee-specification/ + * + * @since_tizen 4.0 + */ +typedef struct zb_zdo_discovery_cache_s* zb_zdo_discovery_cache_h; + + +/** + * @} + */ + +#endif /* __ZB_ZDO_TYPE_H__ */ + diff --git a/include/zigbee.h b/include/zigbee.h index 2e08a88..9828d52 100644 --- a/include/zigbee.h +++ b/include/zigbee.h @@ -25,28 +25,29 @@ extern "C" { #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /** * @file zigbee.h */ /** + * @ingroup CAPI_NETWORK_FRAMEWORK * @addtogroup CAPI_NETWORK_ZIGBEE_MODULE ZigBee * * @{ */ /** - * @brief create handle to access the zigbee service. + * @brief Creates handle to access the zigbee service. * @details all this function to start zigbee service * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks You must free all resources of the zigbee by calling zigbee_disconnect() * if zigbee service is no longer needed. @@ -64,10 +65,10 @@ extern "C" { int zb_create(zigbee_h *handle); /** - * @brief Disconnect to the zigbee service. + * @brief Destroys to the zigbee service handle. * @details all this function to stop zigbee service * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks You must free all resources of the zigbee by calling zb_disconnect() * if zigbee service is no longer needed. @@ -81,10 +82,10 @@ int zb_create(zigbee_h *handle); void zb_destroy(zigbee_h handle); /** - * @brief response of enabling the zigbee service + * @brief Called after enabling zigbee service * @details response of enabling the zigbee service * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[out] status #ZB_ZDP_SUCCESS \n * #ZB_ZDP_NOT_SUPPORTED \n @@ -95,10 +96,10 @@ void zb_destroy(zigbee_h handle); typedef void (*zb_enable_cb)(unsigned char status, void *user_data); /** - * @brief enable the zigbee service. + * @brief Enables the zigbee service. * @details all this function to start zigbee service * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks You must free all resources of the zigbee by calling zb_destroy() * if zigbee service is no longer needed. @@ -119,11 +120,11 @@ typedef void (*zb_enable_cb)(unsigned char status, void *user_data); int zb_enable(zigbee_h handle, zb_enable_cb cb, void *user_data); /** - * @brief Specifies the type of function passed to zb_set_event_handler() + * @brief Called after receiving events from zigbee service * @details This function can receive events from the devices in the network. * ex) join, re-join, leave and attribute change report * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks You can receive below events. * @see #ZB_ZDP_ENABLE_EVENT @@ -159,10 +160,10 @@ typedef void (*zb_event_cb)(nwk_addr addr16, ieee_addr addr64, zb_event_e event_ zb_event_data_s lparam); /** - * @brief set event handler for the zigbee service. + * @brief Sets event handler for the zigbee service. * @details to set event handler to get events from the zigbee service * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks You must free all resources of the zigbee by calling zb_destroy() * if zigbee service is no longer needed. @@ -182,10 +183,10 @@ typedef void (*zb_event_cb)(nwk_addr addr16, ieee_addr addr64, zb_event_e event_ int zb_set_event_cb(zigbee_h handle, zb_event_cb event_handler); /** - * @brief disable the zigbee service. + * @brief Disables the zigbee service. * @details all this function to stop zigbee service * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @@ -206,10 +207,10 @@ int zb_set_event_cb(zigbee_h handle, zb_event_cb event_handler); int zb_disable(zigbee_h handle); /** - * @brief Chip reset for the zigbee transceiver. + * @brief Resets chip for the zigbee transceiver. * @details If the Zigbee transceiver works abnormally, this function do HW reset. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @@ -222,10 +223,10 @@ int zb_disable(zigbee_h handle); int zb_hw_reset(zigbee_h handle); /** - * @brief Switch channel when an occupied channel is noisy. + * @brief Switchs channel when an occupied channel is noisy. * @details When noisy, do energy scan and active scan to switch operational channel. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @param[in] channel target channel number to switch @@ -241,10 +242,12 @@ int zb_hw_reset(zigbee_h handle); int zb_coex_start(zigbee_h handle, unsigned char channel); /** - * @brief Stop channel switching operation. + * @brief Stops channel switching operation. * @details Halt current operation related to channel switching. * - * @since_tizen 3.0 + * @since_tizen 4.0 + * + * @param[in] handle The handle of zigbee * * @return 0 on success, otherwise a negative error value. * @retval #ZIGBEE_ERROR_NONE Successful @@ -257,10 +260,10 @@ int zb_coex_start(zigbee_h handle, unsigned char channel); int zb_coex_stop(zigbee_h handle); /** - * @brief response of forming the zigbee networl - * @details response of forming the zigbee networl + * @brief Called after zigbee network formation is completed. + * @details response of forming the zigbee network * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[out] panid PAN ID * @param[out] user_data user data @@ -270,10 +273,10 @@ int zb_coex_stop(zigbee_h handle); typedef void (*zb_form_network_cb)(nwk_addr panid, void *user_data); /** - * @brief Make network to operate as zigbee coordinator - * @details This function to enable zigbee coordinator. + * @brief Makes network works as a zigbee coordinator + * @details This function to enable the zigbee coordinator. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks If you want to change parameters related to network configuration you should * call zb_zdo_set_compatible_startup_parameters() API @@ -295,10 +298,10 @@ typedef void (*zb_form_network_cb)(nwk_addr panid, void *user_data); int zb_form_network(zigbee_h handle, zb_form_network_cb cb, void *user_data); /** - * @brief response of disabling the zigbee networl + * @brief Called after disabling the zigbee networl * @details response of disabling the zigbee networl * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[out] status #ZB_ZDP_SUCCESS \n * #ZB_ZDP_NOT_SUPPORTED \n @@ -308,10 +311,10 @@ int zb_form_network(zigbee_h handle, zb_form_network_cb cb, void *user_data); */ typedef void (*zb_disable_network_cb)(unsigned char status, void *user_data); /** - * @brief Disable network and stop zigbee coordinator role + * @brief Disables network and stops zigbee coordinator role * @details This function to stop zigbee coordinator * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks You must destroy all device and routing information before calling this * function. @@ -334,7 +337,7 @@ int zb_disable_network(zigbee_h handle, zb_disable_network_cb cb, void *user_dat * @details Force a node to leave one network and to rejoin the other. If remove_children * sets true, the the target end device will reset its state-machine as factory default. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @param[in] addr The source EUI64 of the binding (the remote device's EUI64) @@ -351,11 +354,11 @@ int zb_disable_network(zigbee_h handle, zb_disable_network_cb cb, void *user_dat int zb_leave_device(zigbee_h handle, ieee_addr addr, bool remove_children, bool rejoin); /** - * @brief enable or disable coordinator device can accept other device's association request + * @brief Enables or disables coordinator device can accept other device's association request * @details The function is generated from a Local Device requesting that * a remote device or devices allow or disallow association. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks Especially, this can be very useful for disabling joining all throughout the * network. Typically, this is the last step when commissioning a network. It closes it @@ -375,11 +378,11 @@ int zb_leave_device(zigbee_h handle, ieee_addr addr, bool remove_children, bool int zb_permit_join(zigbee_h handle, unsigned char timeout); /** - * @brief show current coordinator's IEEE MAC address + * @brief Shows current coordinator's IEEE MAC address * @details The function gets the coordinator's MAC address from the machine which runs * zigbee-service daemon. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @param[out] addr64 the Zigbee IEEE MAC address of this machine. @@ -394,10 +397,10 @@ int zb_permit_join(zigbee_h handle, unsigned char timeout); int zb_get_controller_mac_address(zigbee_h handle, ieee_addr addr64); /** - * @brief get information of the current network environment of coordinator + * @brief Gets information of the current network environment of coordinator * @details The function shows network environment * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @param[out] addr64 the Zigbee IEEE MAC address @@ -417,11 +420,11 @@ int zb_get_network_info(zigbee_h handle, ieee_addr addr64, nwk_addr *nodeid, nwk_addr *panid, unsigned char *channel, unsigned char *tx_power); /** - * @brief Get all children device list information. + * @brief Gets all children device list information. * @details This function return end-point list and simple description per each end-point * at each device. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @param[out] count The number of end-devices @@ -437,10 +440,10 @@ int zb_get_network_info(zigbee_h handle, ieee_addr addr64, nwk_addr *nodeid, int zb_get_all_device_list(zigbee_h handle, int *count, zb_end_device_info_h **list); /** - * @brief Get endpoint list information. + * @brief Gets endpoint list information. * @details This function return end-point list at each device. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @param[in] addr64 the Zigbee IEEE MAC address @@ -456,10 +459,10 @@ int zb_get_endpoint_list(zigbee_h handle, ieee_addr addr64, unsigned char *count unsigned char *ep_list); /** - * @brief Get cluster list information. + * @brief Gets cluster list information. * @details This function return in and out cluster list at each device. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] handle The handle of zigbee * @param[in] addr64 the Zigbee IEEE MAC address @@ -479,11 +482,11 @@ int zb_get_cluster_list(zigbee_h handle, ieee_addr addr64, unsigned char ep, unsigned char *out_cluster_count, unsigned short *out_cluster_list); /** - * @brief free all children device list information. + * @brief Frees all children device list information. * @details This function return end-point list and simple description per each end-point * at each device. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] list The device information list * @@ -496,9 +499,9 @@ int zb_get_cluster_list(zigbee_h handle, ieee_addr addr64, unsigned char ep, int zb_device_list_free(zb_end_device_info_h *list); /** - * @brief callback function when getting end-device information. + * @brief Called after getting end-device information. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[out] index nth child * @param[out] child handle of a end-device @@ -506,7 +509,7 @@ int zb_device_list_free(zb_end_device_info_h *list); * * @pre The callback must be registered when using zb_devices_info_foreach_end_device() * - * @return ZIGBEE_FUNC_CONTINUE to continue iteration, otherwise ZIGBEE_FUNC_STOP to stop iteration. + * @return #ZIGBEE_FUNC_CONTINUE to continue iteration, otherwise #ZIGBEE_FUNC_STOP to stop iteration. * @retval #ZIGBEE_FUNC_CONTINUE Continue iteration * @retval #ZIGBEE_FUNC_STOP Stop iteration * @@ -517,7 +520,7 @@ typedef bool (*zb_end_device_cb)(int index, zb_end_device_info_h child, void *us /** * @brief Calls a function for each children end-point of parent. * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @param[in] list handle of end-devices parent * @param[in] cb zb_end_device_cb() @@ -533,9 +536,9 @@ int zb_devices_info_foreach_end_device(zb_end_device_info_h *list, zb_end_device_cb cb, void *user_data); /** - * @brief get network address of a specific end-point + * @brief Gets network address of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -553,9 +556,9 @@ int zb_devices_info_foreach_end_device(zb_end_device_info_h *list, int zb_get_network_address(zb_end_device_info_h handle, nwk_addr *addr16); /** - * @brief get ieee address of a specific end-point + * @brief Gets ieee address of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -573,9 +576,9 @@ int zb_get_network_address(zb_end_device_info_h handle, nwk_addr *addr16); int zb_get_ieee_address(zb_end_device_info_h handle, ieee_addr addr64); /** - * @brief get a number of end-points of a specific end-point + * @brief Gets a number of end-points of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -593,9 +596,9 @@ int zb_get_ieee_address(zb_end_device_info_h handle, ieee_addr addr64); int zb_get_num_of_ep(zb_end_device_info_h handle, unsigned char *count); /** - * @brief get list of end-points of a specific end-point + * @brief Gets list of end-points of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -613,9 +616,9 @@ int zb_get_num_of_ep(zb_end_device_info_h handle, unsigned char *count); int zb_get_ep_list(zb_end_device_info_h handle, unsigned char *ep_list); /** - * @brief get 802.15.4 MAC capability of a specific end-point + * @brief Gets 802.15.4 MAC capability of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -634,9 +637,9 @@ int zb_get_ep_list(zb_end_device_info_h handle, unsigned char *ep_list); int zb_get_mac_capabiity(zb_end_device_info_h handle, unsigned char *capability); /** - * @brief get ability of alternative PAN coordinator of a specific end-point + * @brief Gets ability of alternative PAN coordinator of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -656,9 +659,9 @@ int zb_get_alternative_pan_coordinator(zb_end_device_info_h handle, unsigned char *can_do_it); /** - * @brief get device id of a specific end-point + * @brief Gets device id of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -678,9 +681,9 @@ int zb_get_alternative_pan_coordinator(zb_end_device_info_h handle, int zb_get_device_id(zb_end_device_info_h handle, unsigned char ep, unsigned short *device_id); /** - * @brief get profile id of a specific end-point + * @brief Gets profile id of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -700,9 +703,9 @@ int zb_get_device_id(zb_end_device_info_h handle, unsigned char ep, unsigned sho int zb_get_profile_id(zb_end_device_info_h handle, unsigned char ep, unsigned short *profile_id); /** - * @brief get power source type of a specific end-point + * @brief Gets power source type of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * @@ -721,9 +724,9 @@ int zb_get_profile_id(zb_end_device_info_h handle, unsigned char ep, unsigned sh int zb_get_power_source(zb_end_device_info_h handle, unsigned char *power_src); /** - * @brief get security capability of a specific end-point + * @brief Gets security capability of a specific end-point * - * @since_tizen 3.0 + * @since_tizen 4.0 * * @remarks This function should be called in zb_end_device_cb() * diff --git a/lib/zbl-custom.c b/lib/zbl-custom.c deleted file mode 100644 index 20e130e..0000000 --- a/lib/zbl-custom.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 -#include -#include -#include - -#include "zbl.h" -#include "zbl-dbus.h" -#include "zigbee.h" - -API int zb_aps_send(zigbee_h handle, nwk_addr addr16, unsigned char aps_frame_ctl, - unsigned char src_ep, unsigned char dst_ep, unsigned short cluster_id, - unsigned short profile_id, unsigned char zcl_frame_ctl, unsigned short mfg_code, - unsigned char cmd_id, unsigned short payload_len, unsigned char *payload, - zb_aps_send_rsp cb, void *user_data) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - - ret = zbl_aps_send(addr16, aps_frame_ctl, src_ep, dst_ep, cluster_id, profile_id, - zcl_frame_ctl, mfg_code, cmd_id, payload_len, payload, cb, user_data); - DBG("zbl_aps_send()=0x%X", ret); - return ret; -} - -API int zb_zcl_send(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned short cluster_id, unsigned char zcl_frame_ctl, - unsigned char cmd, unsigned short payload_len, unsigned char *payload, - zb_zcl_send_rsp cb, void *user_data) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - - ret = zbl_zcl_send(addr16, src_ep, dst_ep, cluster_id, zcl_frame_ctl, - cmd, payload_len, payload, cb, user_data); - DBG("zbl_zcl_send()=0x%X", ret); - return ret; -} - -API int zb_send_to_local(zigbee_h handle, unsigned short length, unsigned char *data, - zb_send_to_local_rsp cb, void *user_data) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - - ret = zbl_send_to_local(length, data, cb, user_data); - DBG("zbl_send_to_local()=0x%X", ret); - return ret; -} diff --git a/lib/zbl-dbus.c b/lib/zbl-dbus.c deleted file mode 100644 index bf9e72f..0000000 --- a/lib/zbl-dbus.c +++ /dev/null @@ -1,7923 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "zbl.h" -#include "zbl-dbus.h" - -#define USE_ASYNC_DBUS_CALL - -static int zbl_ref_count; - -static GDBusConnection *gdbus_conn = NULL; -static GDBusProxy *service_gproxy = NULL; -static GDBusProxy *on_off_gproxy = NULL; -static GDBusProxy *door_lock_gproxy = NULL; -static GDBusProxy *level_control_gproxy = NULL; -static GDBusProxy *thermostat_gproxy = NULL; -static GDBusProxy *alarm_gproxy = NULL; -static GDBusProxy *fan_control_gproxy = NULL; -static GDBusProxy *mfglib_gproxy = NULL; -static GDBusProxy *zcl_global_proxy = NULL; -static GDBusProxy *zdo_dev_proxy = NULL; -static GDBusProxy *zcl_basic_proxy = NULL; -static GDBusProxy *zcl_identify_proxy = NULL; -static GDBusProxy *zcl_ias_zone_proxy = NULL; -static GDBusProxy *zcl_poll_control_proxy = NULL; -static GDBusProxy *zcl_group_proxy = NULL; -static GDBusProxy *zcl_scene_proxy = NULL; -static GDBusProxy *zdo_bind_proxy = NULL; -static GDBusProxy *zcl_color_control_proxy = NULL; -static GDBusProxy *custom_gproxy = NULL; - -/* command id */ -typedef enum { - /* Service */ - ZBL_SERVICE_FORM_NETWORK = 0, - ZBL_SERVICE_DISABLE_NETWORK, - /* ZDP except Bind */ - ZBL_ZDO_NWK_ADDR_REQ, - ZBL_ZDO_NWK_ADDR_EXT_REQ, - ZBL_ZDO_ACTIVE_EP_REQ, - ZBL_ZDO_SIMPLE_DESC_REQ, - ZBL_ZDO_MATCHED_DESCRIPTOR_REQ, - ZBL_ZDO_COMPLEX_DESC_REQ, - ZBL_ZDO_MGMT_BIND_REQ, - ZBL_ZDO_MGMT_LQI_REQ, - ZBL_ZDO_MGMT_RTG_REQ, - ZBL_ZDO_MGMT_NWK_DISC_REQ, - ZBL_ZDO_MGMT_PERMIT_JOIN_REQ, - ZBL_ZDO_MGMT_LEAVE_REQ, - ZBL_ZDO_NODE_DESC_REQ, - ZBL_ZDO_POWER_DESC_REQ, - ZBL_ZDO_USER_DESC_REQ, - ZBL_ZDO_USER_DESC_SET_REQ, - /* ZDP Bind */ - ZBL_ZDO_BIND_REQ, - ZBL_ZDO_UNBIND_REQ, - /* ZCL Global */ - ZBL_ZCL_GLOBAL_READ_ATTRIBUTE_REQ, - ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ, - ZBL_ZCL_GLOBAL_CONFIGURE_REPORTING_REQ, - ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_REQ, - ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_STRUCTURED_REQ, - ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_RECEIVED_REQ, - ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_GENERATED_REQ, - ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_EXTENDED_REQ, - ZBL_ZCL_GLOBAL_READ_CONFIGURE_REPORTING_REQ, - /* Custom */ - ZBL_CUSTOM_APS_SEND_REQ, - ZBL_CUSTOM_ZCL_SEND_REQ, - ZBL_CUSTOM_LOCAL_SEND_REQ, - /* ZCL Alarm */ - ZBL_ZCL_ALARM_GET_ALARM_REQ, - /* ZCL Doorlock */ - ZBL_ZCL_DOORLOCK_LOCK_STATE, - /* ZCL Fanmode */ - ZBL_ZCL_FANMODE_FAN_MODE_STATE, - /* ZCL Group */ - ZBL_ZCL_GROUP_ADD_GROUP_REQ, - ZBL_ZCL_GROUP_VIEW_GROUP_REQ, - ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ, - ZBL_ZCL_GROUP_REMOVE_GROUP_REQ, - /* ZCL Identify */ - ZBL_ZCL_IDENTIFY_QUERY_REQ, - /* ZCL On/Off */ - ZBL_ZCL_ON_OFF_GET_ON_OFF_STATE, - /* ZCL Pollcontrol */ - ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ, - /* ZCL Scene */ - ZBL_ZCL_SCENE_ADD_SCENE_REQ, - ZBL_ZCL_SCENE_VIEW_SCENE_REQ, - ZBL_ZCL_SCENE_REMOVE_SCENE_REQ, - ZBL_ZCL_SCENE_STORE_SCENE_REQ, - ZBL_ZCL_SCENE_REMOVE_ALL_SCENE_REQ, - ZBL_ZCL_SCENE_GET_SCENE_MEMBERSHIP_REQ, - /* ZCL Thermostat */ - ZBL_ZCL_THERMOSTAT_GET_LOCAL_TEMP, -} zbl_command_id_e; - -typedef struct { - bool found; - void *cb; - void *userdata; - unsigned int sid; - int tid; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - void *global_cmd; - void *handle; -#endif - zbl_command_id_e cid; -} zbl_req_cb_s; - -#define ZCL_REPORTING_DIRECTION_REPORTED 0x00 -#define ZCL_REPORTING_DIRECTION_RECEIVED 0x01 - -static GDBusProxy *_zbl_get_service_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == service_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_SERVICE_INTERFACE, - NULL, NULL); - } else - proxy = service_gproxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_on_off_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == on_off_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_ON_OFF_INTERFACE, NULL, NULL); - } else - proxy = on_off_gproxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_door_lock_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == door_lock_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_DOOR_LOCK_INTERFACE, NULL, NULL); - } else - proxy = door_lock_gproxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_level_control_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == level_control_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_LEVEL_CONTROL_INTERFACE, NULL, NULL); - } else - proxy = level_control_gproxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_thermostat_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == thermostat_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_THERMOSTAT_INTERFACE, NULL, NULL); - } else - proxy = thermostat_gproxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_alarm_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == alarm_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZCL_ALARM_INTERFACE, - NULL, NULL); - } else - proxy = alarm_gproxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_fan_control_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == fan_control_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_FAN_CONTROL_INTERFACE, NULL, NULL); - } else - proxy = fan_control_gproxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_mfglib_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == mfglib_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_MFGLIB_CONTROL_INTERFACE, NULL, NULL); - } else - proxy = mfglib_gproxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_zcl_global_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zcl_global_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, NULL, NULL); - } else - proxy = zcl_global_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_zdo_dev_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zdo_dev_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, NULL, NULL); - } else - proxy = zdo_dev_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_basic_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zcl_basic_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZCL_BASIC_INTERFACE, - NULL, NULL); - } else - proxy = zcl_basic_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_identify_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zcl_identify_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_IDENTIFY_INTERFACE, NULL, NULL); - } else - proxy = zcl_identify_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_ias_zone_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zcl_ias_zone_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_IAS_ZONE_INTERFACE, NULL, NULL); - } else - proxy = zcl_ias_zone_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_poll_control_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zcl_poll_control_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_POLL_CONTROL_INTERFACE, NULL, NULL); - } else - proxy = zcl_poll_control_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_group_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zcl_group_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZCL_GROUP_INTERFACE, - NULL, NULL); - } else - proxy = zcl_group_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_scene_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zcl_scene_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZCL_SCENE_INTERFACE, - NULL, NULL); - } else - proxy = zcl_scene_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_zdo_bind_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zdo_bind_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZDO_BIND_INTERFACE, - NULL, NULL); - } else - proxy = zdo_bind_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_color_control_proxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); - - if (NULL == zcl_color_control_proxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, - ZIGBEE_ZCL_COLOR_CONTROL_INTERFACE, NULL, NULL); - } else - proxy = zcl_color_control_proxy; - - return proxy; -} - -static GDBusProxy *_zbl_get_custom_gproxy(void) -{ - GDBusProxy *proxy = NULL; - RETVM_IF(NULL == gdbus_conn, NULL, "Custom Object is invalid"); - - if (NULL == custom_gproxy) { - proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, - ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_CUSTOM_INTERFACE, - NULL, NULL); - } else - proxy = custom_gproxy; - - return proxy; -} - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC -static gint _global_compare_func(gconstpointer a, gconstpointer b) -{ - const zbl_req_cb_s *left = (const zbl_req_cb_s*)a; - const zbl_req_cb_s *right = (const zbl_req_cb_s*)b; - zb_event_global_default_rsp_s *left_data = NULL; - zb_event_global_default_rsp_s *right_data = NULL; - - if (NULL == left || NULL == left->global_cmd) - return -1; - if (NULL == right || NULL == right->global_cmd) - return 1; - - left_data = left->global_cmd; - right_data = right->global_cmd; - - if (left_data->ep > right_data->ep) - return 1; - else if (left_data->ep < right_data->ep) - return -1; - - if (left_data->cluster_id > right_data->cluster_id) - return 1; - else if (left_data->cluster_id < right_data->cluster_id) - return -1; - - if (left_data->command_id > right_data->command_id) - return 1; - else if (left_data->command_id < right_data->command_id) - return -1; - - /* endpoint, cluster_id and command_id are equal */ - return 0; -} - -static void _zbl_register_global_req(zigbee_h handle, zbl_req_cb_s *container) -{ - GList *list = NULL; - GList *item = NULL; - - if (NULL == handle || NULL == container) - return; - - list = handle->global_cmd_req; - - /* Insert item if not exists */ - DBG("Insert global cmd info"); - if (list) { - item = g_list_find_custom(list, container, _global_compare_func); - if (NULL != item) - handle->global_cmd_req = g_list_append(list, container); - } else - handle->global_cmd_req = g_list_append(list, container); -} - -static void _zbl_deregister_global_req(zigbee_h handle, zbl_req_cb_s *container) -{ - GList *list = NULL; - GList *item = NULL; - - if (NULL == handle || NULL == container) - return; - - list = handle->global_cmd_req; - if (NULL == list) - return; - - /* Remove item if exists */ - DBG("Remove global cmd info"); - item = g_list_find_custom(list, container, _global_compare_func); - if (NULL != item) - handle->global_cmd_req = g_list_remove(list, container); -} - -static void _zbl_remove_global_req(zigbee_h handle, unsigned char ep, - unsigned short cluster_id, unsigned char command_id) -{ - GList *head = NULL; - GList *iter = NULL; - zbl_req_cb_s *ret = NULL; - - if (NULL == handle) - return; - - head = handle->global_cmd_req; - iter = head; - - while (NULL != iter) { - GList *next = iter->next; - zbl_req_cb_s *container = iter->data; - if (container && container->global_cmd) { - zb_event_global_default_rsp_s *data = container->global_cmd; - - if (data && data->ep == ep && data->cluster_id == cluster_id - && data->command_id == command_id) { - DBG(" Found: ep[%d] cluster_id[%X] command_id[%X] / sid[%d]", - ep, cluster_id, command_id, container->sid); - ret = container; - break; - } - } - iter = next; - } - - if (ret) { - if (ret->sid) - g_dbus_connection_signal_unsubscribe(gdbus_conn, ret->sid); - - if (ret->tid) { - g_source_remove(ret->tid); - DBG("tid=%d removed"); - ret->tid = 0; - } - - _zbl_deregister_global_req(handle, ret); - } - -} -#endif /* ZB_FEATURE_GLOBAL_RSP_SYNC */ - -static void _zbl_signal_handler(GDBusConnection *connection, - const gchar *sender_name, const gchar *object_path, const gchar *interface_name, - const gchar *signal_name, GVariant *parameters, gpointer user_data) -{ - zigbee_h container = (zigbee_h)user_data; - RETM_IF(NULL == container, "container is null"); - RETM_IF(NULL == container->event_handler, "event_handler is null"); - DBG("%s signal received", signal_name); - - if (g_strcmp0(signal_name, "service_enabled") == 0) { - gboolean enabled; - g_variant_get(parameters, "(b)", &enabled); - - zb_event_data_s ev; - ev.data.enable = calloc(1, sizeof(zb_event_enable_s)); - RETM_IF(NULL == ev.data.enable, "Failed to memory allocation !"); - - ev.data.enable->status = (unsigned char)enabled; - container->event_handler(0, NULL, ZB_ZDP_ENABLE_EVENT, ev); - free(ev.data.enable); - } else if (g_strcmp0(signal_name, "form_network_done") == 0) { - nwk_addr pan_id; - g_variant_get(parameters, "(q)", &pan_id); - - zb_event_data_s ev; - ev.data.form_network = calloc(1, sizeof(zb_event_form_network_s)); - RETM_IF(NULL == ev.data.form_network, "Failed to memory allocation !"); - - memcpy(&ev.data.form_network->pan_id, &pan_id, sizeof(nwk_addr)); - container->event_handler(pan_id, NULL, ZB_ZDP_FORM_NETWORK_DONE, ev); - free(ev.data.form_network); - } else if (g_strcmp0(signal_name, "child_joined") == 0) { - nwk_addr addr16; - ieee_addr addr64; - unsigned char count; - unsigned char ep[10]; - unsigned char value; - - int j = 0; - GVariantIter *iter1 = NULL; - GVariantIter *iter2 = NULL; - - g_variant_get(parameters, "(a(y)ya(y)q)", &iter1, &count, &iter2, &addr16); - while (g_variant_iter_loop(iter1, "(y)", &value)) { - addr64[j] = value; - j++; - } - if (NULL != iter1) - g_variant_iter_free(iter1); - - j = 0; - while (g_variant_iter_loop(iter2, "(y)", &value)) { - ep[j] = value; - j++; - } - if (NULL != iter2) - g_variant_iter_free(iter2); - - zb_event_data_s ev; - ev.data.join = calloc(1, sizeof(zb_event_join_s)); - RETM_IF(NULL == ev.data.join, "Failed to memory allocation !"); - - ev.data.join->count = count; - memcpy(ev.data.join->ep, ep, count); - container->event_handler(addr16, addr64, ZB_ZDP_JOIN_EVENT, ev); - free(ev.data.join); - } else if (g_strcmp0(signal_name, "child_rejoined") == 0) { - ieee_addr addr64; - unsigned char value; - - int j = 0; - GVariantIter *iter = NULL; - - g_variant_get(parameters, "(a(y))", &iter); - while (g_variant_iter_loop(iter, "(y)", &value)) { - addr64[j] = value; - j++; - } - if (NULL != iter) - g_variant_iter_free(iter); - - zb_event_data_s ev; - memset(&ev, 0, sizeof(zb_event_data_s)); - container->event_handler(0, addr64, ZB_ZDP_REJOIN_EVENT, ev); - } else if (g_strcmp0(signal_name, "child_left") == 0) { - int j = 0; - ieee_addr addr64; - GVariantIter *iter = NULL; - unsigned char value, status; - - g_variant_get(parameters, "(a(y)y)", &iter, &status); - while (g_variant_iter_loop(iter, "(y)", &value)) { - addr64[j] = value; - j++; - } - if (NULL != iter) - g_variant_iter_free(iter); - - zb_event_data_s ev; - ev.data.child_left = calloc(1, sizeof(zb_event_child_left_s)); - RETM_IF(NULL == ev.data.child_left, "Failed to memory allocation !"); - - ev.data.child_left->status = status; - container->event_handler(0, addr64, ZB_ZDP_CHILD_LEFT, ev); - free(ev.data.child_left); - } else if (g_strcmp0(signal_name, "leave_network_done") == 0) { - nwk_addr addr16; - g_variant_get(parameters, "(q)", &addr16); - - zb_event_data_s ev; - memset(&ev, 0, sizeof(zb_event_data_s)); - container->event_handler(addr16, NULL, ZB_ZDP_LEAVE_DONE_EVENT, ev); - } else if (!g_strcmp0(signal_name, "zcl_global_default_response")) { - nwk_addr addr16; - unsigned char ep; - unsigned short cluster_id; - unsigned char command_id; - unsigned char status; - - g_variant_get(parameters, "(qyqyy)", &addr16, &ep, &cluster_id, &command_id, &status); - - zb_event_data_s ev; - ev.data.global_default_rsp = calloc(1, sizeof(zb_event_global_default_rsp_s)); - RETM_IF(NULL == ev.data.global_default_rsp, "Failed to memory allocation !"); - - ev.data.global_default_rsp->ep = ep; - ev.data.global_default_rsp->cluster_id = cluster_id; - ev.data.global_default_rsp->command_id = command_id; - ev.data.global_default_rsp->status = status; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - /* If there is global request already, remove that. */ - if (0x00 != status) - _zbl_remove_global_req(container, ep, cluster_id, command_id); -#endif - - container->event_handler(addr16, NULL, ZB_ZCL_GLOBAL_DEFAULT_RSP_EVENT, ev); - free(ev.data.global_default_rsp); - } else if (!g_strcmp0(signal_name, "alarm_count")) { - unsigned short alarm_count; - g_variant_get(parameters, "(q)", &alarm_count); - - zb_event_data_s ev; - ev.data.alarm = calloc(1, sizeof(zb_event_alarm_s)); - RETM_IF(NULL == ev.data.alarm, "Failed to memory allocation !"); - - ev.data.alarm->count = alarm_count; - container->event_handler(0, NULL, ZB_ZCL_ALARM_EVENT, ev); - free(ev.data.alarm); - } else if (!g_strcmp0(signal_name, "report_attr_handler_rsp")) { - nwk_addr addr16; - unsigned char ep; - unsigned char value; - unsigned short attrData; - unsigned short cluster_id; - unsigned char dataType; - unsigned short data_size; - int dsizeIndex = 0; - char dSize[3] = {'\0', '\0'}; - int i = 0, j = 0, records_len; - GVariantIter *attr_iter = NULL; - GVariantIter *dataType_iter = NULL; - GVariantIter *data_iter = NULL; - - attr_report_h *records = NULL; - - g_variant_get(parameters, "(qyqaqayayi)", &addr16, &ep, - &cluster_id, &attr_iter, &dataType_iter, &data_iter, &records_len); - - records = calloc(records_len, sizeof(attr_report_h)); - RETM_IF(NULL == records, "calloc() Fail(%d)", errno); - for (j = 0; j < records_len; j++) { - records[j] = calloc(1, sizeof(struct attribute_report_s)); - if (NULL == records[j]) { - for (i = 0; i < j; i++) - free(records[i]); - free(records); - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - if (NULL != dataType_iter) - g_variant_iter_free(dataType_iter); - if (NULL != data_iter) - g_variant_iter_free(data_iter); - - ERR("calloc() Fail(%d)", errno); - return; - } - } - DBG("record_length %d", records_len); - - j = 0; - while (g_variant_iter_loop(attr_iter, "q", &attrData) - && g_variant_iter_loop(dataType_iter, "y", &dataType)) { - records[j]->id = attrData; - records[j]->type = dataType; - DBG("dataType 0x%02x", records[j]->type); - DBG("AttributeId 0x%04x", records[j]->id); - j++; - } - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - if (NULL != dataType_iter) - g_variant_iter_free(dataType_iter); - - j = 0; - while (j < records_len) { - switch (records[j]->type) { - /* String */ - case ZB_ZCL_OCTAT_STRING: - case ZB_ZCL_CHRACTER_STRING: - g_variant_iter_loop(data_iter, "y", &value); - data_size = value + 1; - records[j]->value = calloc(data_size, sizeof(unsigned char)); - if (NULL == records[j]->value) { - for (i = 0; i < j; i++) - free(records[i]->value); - for (i = 0; i < records_len; i++) - free(records[i]); - free(records); - ERR("calloc() Fail(%d)", errno); - return; - } - records[j]->value[dsizeIndex] = value; - dsizeIndex++; - for (i = dsizeIndex; i < data_size - 2; i++) { - g_variant_iter_loop(data_iter, "y", &value); - records[j]->value[i] = value; - } - if (NULL != data_iter) - g_variant_iter_free(data_iter); - break; - case ZB_ZCL_LONG_OCTAT_STRING: - case ZB_ZCL_LONG_CHRACTER_STRING: - g_variant_iter_loop(data_iter, "y", &value); - dSize[0] = value; - g_variant_iter_loop(data_iter, "y", &value); - dSize[1] = value; - data_size = dSize[1]; - data_size = (data_size << 8) | dSize[0]; - data_size += 2; - records[j]->value = calloc(data_size, sizeof(unsigned char)); - if (NULL == records[j]->value) { - for (i = 0; i < j; i++) - free(records[i]->value); - for (i = 0; i < records_len; i++) - free(records[i]); - free(records); - ERR("calloc() Fail(%d)", errno); - return; - } - records[j]->value[dsizeIndex] = dSize[dsizeIndex]; - dsizeIndex++; - records[j]->value[dsizeIndex] = dSize[dsizeIndex]; - dsizeIndex++; - for (i = dsizeIndex; i < data_size - 2; i++) { - g_variant_iter_loop(data_iter, "y", &value); - records[j]->value[i] = value; - } - if (NULL != data_iter) - g_variant_iter_free(data_iter); - break; - /* Array, set and bag */ - case ZB_ZCL_ARRAY: - case ZB_ZCL_SET: - case ZB_ZCL_BAG: - /* structure */ - case ZB_ZCL_STRUCTURE: - ERR("Not supported type = %d", records[i]->type); - continue; - default: - data_size = zb_get_data_size(records[j]->type); - records[j]->value = calloc(data_size, sizeof(unsigned char)); - if (NULL == records[j]->value) { - for (i = 0; i < j; i++) - free(records[i]->value); - for (i = 0; i < records_len; i++) - free(records[i]); - free(records); - ERR("calloc() Fail(%d)", errno); - return; - } - if (data_size != 0xFF) { - for (i = 0; i < data_size; i++) { - g_variant_iter_loop(data_iter, "y", &value); - records[j]->value[i] = value; - DBG("value[%d] 0x%02X", i, records[j]->value[i]); - } - } - if (NULL != data_iter) - g_variant_iter_free(data_iter); - } - DBG("DataType = 0x%02X Data Size = %d", records[j]->type, data_size); - j++; - } - - zb_event_data_s ev; - ev.data.global_attr_report = calloc(1, sizeof(zb_event_global_attr_report_s)); - if (NULL == ev.data.global_attr_report) { - ERR("Failed to memory allocation !"); - for (j = 0; j < records_len; j++) { - free(records[j]->value); - free(records[j]); - } - return; - } - - ev.data.global_attr_report->records = records; - ev.data.global_attr_report->count = records_len; - container->event_handler(addr16, NULL, ZB_ZCL_GLOBAL_ATTRIBUTE_REPORT_EVENT, ev); - for (j = 0; j < records_len; j++) { - free(records[j]->value); - free(records[j]); - } - free(records); - free(ev.data.global_attr_report); - } else if (!g_strcmp0(signal_name, "status_change_rpt")) { - zb_event_data_s ev; - nwk_addr addr16; - unsigned char src_ep; - unsigned char extended_status; - unsigned short zone_status; - unsigned short delay; - unsigned char zone_id; - g_variant_get(parameters, "(qyqyyq)", &addr16, &src_ep, &zone_status, - &extended_status, &zone_id, &delay); - if (0xff == zone_id) { - ev.data.ias_noti = calloc(1, sizeof(zb_event_ias_noti_s)); - RETM_IF(NULL == ev.data.ias_noti, "Failed to memory allocation !"); - - ev.data.ias_noti->src_ep = src_ep; - ev.data.ias_noti->zone_status = zone_status; - container->event_handler(addr16, NULL, - ZB_ZCL_IAS_ZONE_STATUS_CHANGE_NOTIFICATION_EVENT, ev); - - free(ev.data.ias_noti); - } else { - ev.data.ias_extended_noti = calloc(1, sizeof(zb_event_ias_extended_noti_s)); - RETM_IF(NULL == ev.data.ias_extended_noti, "Failed to memory allocation !"); - - ev.data.ias_extended_noti->src_ep = src_ep; - ev.data.ias_extended_noti->zone_status = zone_status; - ev.data.ias_extended_noti->extended_status = extended_status; - ev.data.ias_extended_noti->zone_id = zone_id; - ev.data.ias_extended_noti->delay = delay; - container->event_handler(addr16, NULL, - ZB_ZCL_IAS_ZONE_STATUS_CHANGE_EXTENDED_NOTIFICATION_EVENT, ev); - - free(ev.data.ias_extended_noti); - } - } else if (!g_strcmp0(signal_name, "enroll_request")) { - nwk_addr addr16; - unsigned char src_ep; - unsigned short zone_type; - unsigned char mfg_code; - zb_event_data_s ev; - ev.data.ias_enroll_request = calloc(1, sizeof(zb_event_ias_enroll_request_s)); - RETM_IF(NULL == ev.data.ias_enroll_request, "Failed to memory allocation !"); - - g_variant_get(parameters, "(qyqy)", &addr16, &src_ep, &zone_type, &mfg_code); - ev.data.ias_enroll_request->src_ep = src_ep; - ev.data.ias_enroll_request->zone_type = zone_type; - ev.data.ias_enroll_request->mfg_code = mfg_code; - container->event_handler(addr16, NULL, ZB_ZCL_IAS_ZONE_ENROLL_REQUEST_EVENT, ev); - free(ev.data.ias_enroll_request); - } else - ERR("Can't handle this signal=%s", signal_name); - return; -} - -static void _zbl_dbus_unsubscribe_signal(GList *sub_ids) -{ - RET_IF(NULL == gdbus_conn); - RET_IF(NULL == sub_ids); - - while (sub_ids) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, GPOINTER_TO_UINT(sub_ids->data)); - sub_ids = g_list_remove(sub_ids, sub_ids->data); - } - g_list_free(sub_ids); -} - -static int _zbl_dbus_subscribe_signal(zigbee_h handle) -{ - unsigned int id; - - /* Section 1. Subscribe ZDO signal */ - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, - "service_enabled", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(service_enabled) Fail(%d)", errno); - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for service_enabled signal %d", id); - - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, - "child_joined", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(child_rejoined) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for child_joined signal %d", id); - - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, - "child_rejoined", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(child_rejoined) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for child_rejoined signal %d", id); - - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, - "child_left", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(child_left) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for child_left signal %d", id); - - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, - "leave_network_done", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(leave_network_done) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for leave_network_done signal %d", id); - - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, - "form_network_done", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(form_network_done) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for form_network_done signal %d", id); - - /* Section 3. Subscribe ZCL global command */ - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "zcl_global_default_response", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, G_DBUS_CALL_FLAGS_NONE, - _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(zcl_global_default_response) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for zcl_global_default_response signal %d", id); - - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "report_attr_handler_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, G_DBUS_CALL_FLAGS_NONE, - _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(report_attr_handler_rsp) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for report_attr_handler_rsp signal %d", id); - - /* Section 2. Subscribe ZCL alarm cluster signal */ - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_ZCL_ALARM_INTERFACE, - "alarm_count", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(alarm_count) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for alarm_count signal %d", id); - - /* Section 3. Subscribe ZCL IAS cluster signal */ - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_ZCL_IAS_ZONE_INTERFACE, - "status_change_rpt", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(status_change_rpt) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for status_change_rpt signal %d", id); - - id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_ZCL_IAS_ZONE_INTERFACE, - "enroll_request", ZIGBEE_CONTROL_OBJECT_PATH, NULL, - G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); - if (0 == id) { - ERR("g_dbus_connection_signal_subscribe(enroll_request) Fail(%d)\n", errno); - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - return ZIGBEE_ERROR_IO_ERROR; - } - handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); - DBG("subscribed for enroll_request signal %d", id); - - return ZIGBEE_ERROR_NONE; -} - -static void _zbl_dbus_name_owner_notify(GObject *object, GParamSpec *pspec, - gpointer *user_data) -{ - GDBusProxy *proxy = G_DBUS_PROXY(object); - gchar *name_owner = g_dbus_proxy_get_name_owner(proxy); - zigbee_h handle = (zigbee_h)user_data; - - if (name_owner) - return; - - zbl_dbus_stop(handle); -} - -static void _zbl_request_cleanup(gpointer data) -{ - zbl_req_cb_s *container = data; - RET_IF(NULL == container); - - if (container->tid) { - g_source_remove(container->tid); - DBG("tid=%d removed"); - container->tid = 0; - } - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - _zbl_deregister_global_req(container->handle, container); -#endif - - free(container); -} - -static gboolean _zbl_timeout_cb(gpointer p) -{ - zbl_req_cb_s *container = (zbl_req_cb_s *)p; - - RETVM_IF(NULL == gdbus_conn, G_SOURCE_REMOVE, "gdbus_conn is NULL"); - RETVM_IF(NULL == p, G_SOURCE_REMOVE, "container is NULL"); - RETVM_IF(NULL == container->cb, G_SOURCE_REMOVE, "cb is NULL"); - RETVM_IF(true == container->found, G_SOURCE_REMOVE, "cb was alreay handled"); - - switch (container->cid) { - /* Service */ - case ZBL_SERVICE_FORM_NETWORK: { - zb_form_network_cb cb = container->cb; - cb(0x0000, container->userdata); - } - break; - case ZBL_SERVICE_DISABLE_NETWORK: { - zb_disable_network_cb cb = container->cb; - cb(0x0000, container->userdata); - cb(ZB_ZDP_TIMEOUT, container->userdata); - } - break; - /* ZDP except Bind */ - case ZBL_ZDO_NWK_ADDR_REQ: { - zb_zdo_addr_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, NULL, 0, 0, 0, NULL, container->userdata); - } - break; - case ZBL_ZDO_NWK_ADDR_EXT_REQ: { - zb_zdo_addr_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, NULL, 0, 0, 0, NULL, container->userdata); - } - break; - case ZBL_ZDO_ACTIVE_EP_REQ: { - zb_zdo_active_ep_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, 0, 0, NULL, container->userdata); - } - break; - case ZBL_ZDO_SIMPLE_DESC_REQ: { - zb_zdo_simple_desc_rsp cb = container->cb; - cb(0, 0, NULL, container->userdata); - } - break; - case ZBL_ZDO_MATCHED_DESCRIPTOR_REQ: { - zb_zdo_match_desc_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, 0, 0, NULL, container->userdata); - } - break; - case ZBL_ZDO_COMPLEX_DESC_REQ: { - zb_zdo_complex_desc_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, 0, 0, NULL, container->userdata); - } - break; - case ZBL_ZDO_MGMT_BIND_REQ: { - zb_zdo_mgmt_bind_rsp cb = container->cb; - zb_zdo_binding_table_h *records = NULL; - - records = calloc(1, sizeof(zb_zdo_binding_table_h)); - if (records) - records[0] = calloc(1, sizeof(struct zb_zdo_binding_table_s)); - - cb(ZB_ZDP_TIMEOUT, 0, 0, 0, records, container->userdata); - - free(records[0]); - free(records); - } - break; - case ZBL_ZDO_MGMT_LQI_REQ: { - zb_zdo_mgmt_lqi_rsp cb = container->cb; - zb_zdo_neighbor_table_desc_h *records = NULL; - - records = calloc(1, sizeof(zb_zdo_neighbor_table_desc_h)); - if (records) - records[0] = calloc(1, sizeof(struct zb_zdo_neighbor_table_desc_s)); - - cb(ZB_ZDP_TIMEOUT, 0, 0, 0, records, container->userdata); - - free(records[0]); - free(records); - } - break; - case ZBL_ZDO_MGMT_RTG_REQ: { - zb_zdo_mgmt_rtg_rsp cb = container->cb; - zb_zdo_routing_table_h *records = NULL; - - records = calloc(1, sizeof(zb_zdo_routing_table_h)); - if (records) - records[0] = calloc(1, sizeof(struct zb_zdo_routing_table_s)); - - cb(ZB_ZDP_TIMEOUT, 0, 0, 0, records, container->userdata); - - free(records[0]); - free(records); - } - break; - case ZBL_ZDO_MGMT_NWK_DISC_REQ: { - zb_zdo_mgmt_nwk_disc_rsp cb = container->cb; - zb_zdo_network_list_record_h *records = NULL; - records = calloc(1, sizeof(zb_zdo_network_list_record_h)); - if (records) - records[0] = calloc(1, sizeof(struct zb_zdo_network_list_record_s)); - - cb(0, 0, 0, 0, records, container->userdata); - free(records[0]); - free(records); - } - break; - case ZBL_ZDO_MGMT_PERMIT_JOIN_REQ: { - zb_zdo_mgmt_permit_joining_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, container->userdata); - } - break; - case ZBL_ZDO_MGMT_LEAVE_REQ: { - zb_zdo_mgmt_leave_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, container->userdata); - } - break; - case ZBL_ZDO_NODE_DESC_REQ: { - zb_zdo_node_desc_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, 0, NULL, container->userdata); - } - break; - case ZBL_ZDO_POWER_DESC_REQ: { - zb_zdo_power_desc_rsp cb = container->cb; - cb(0, 0, NULL, container->userdata); - } - break; - case ZBL_ZDO_USER_DESC_REQ: { - zb_zdo_user_desc_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, 0, 0, NULL, container->userdata); - } - case ZBL_ZDO_USER_DESC_SET_REQ: { - zb_zdo_user_desc_conf cb = container->cb; - cb(ZB_ZDP_TIMEOUT, container->userdata); - } - break; - /* ZDP Bind */ - case ZBL_ZDO_BIND_REQ: { - zb_zdo_bind_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, container->userdata); - } - break; - case ZBL_ZDO_UNBIND_REQ: { - zb_zdo_unbind_rsp cb = container->cb; - cb(ZB_ZDP_TIMEOUT, container->userdata); - } - break; - /* Custom */ - case ZBL_CUSTOM_APS_SEND_REQ: { - zb_aps_send_rsp cb = container->cb; - cb(0, 0, 0, 0, 0, 0, NULL, container->userdata); - } break; - case ZBL_CUSTOM_ZCL_SEND_REQ: { - zb_zcl_send_rsp cb = container->cb; - cb(0, 0, 0, 0, 0, 0, NULL, container->userdata); - } - break; - case ZBL_CUSTOM_LOCAL_SEND_REQ: { - zb_send_to_local_rsp cb = container->cb; - cb(0, NULL, container->userdata); - } - break; - /* ZCL Global */ - case ZBL_ZCL_GLOBAL_READ_ATTRIBUTE_REQ: { - zb_zcl_global_rsp cb = container->cb; - cb(0, 0, 0, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ: { - zb_zcl_global_rsp cb = container->cb; - cb(0, 0, 0, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_GLOBAL_CONFIGURE_REPORTING_REQ: { - zb_zcl_global_rsp cb = container->cb; - cb(0, 0, 0, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_REQ: { - zb_zcl_global_discover_attr_rsp cb = container->cb; - cb(0, 0, 0, 0, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_STRUCTURED_REQ: { - zb_zcl_global_rsp cb = container->cb; - cb(0, 0, 0, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_RECEIVED_REQ: { - zb_zcl_global_discover_cmds_rsp cb = container->cb; - cb(0, 0, 0, 0, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_GENERATED_REQ: { - zb_zcl_global_discover_cmds_rsp cb = container->cb; - cb(0, 0, 0, 0, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_EXTENDED_REQ: { - zb_zcl_global_discover_attr_extended_rsp cb = container->cb; - cb(0, 0, 0, 0, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_GLOBAL_READ_CONFIGURE_REPORTING_REQ: { - zb_zcl_global_rsp cb = container->cb; - cb(0, 0, 0, NULL, 0, container->userdata); - } - break; - /* ZCL Alarm */ - case ZBL_ZCL_ALARM_GET_ALARM_REQ: { - zb_zcl_alarm_get_alarm_rsp cb = container->cb; - cb(ZB_ZCL_TIMEOUT, 0, ZB_ZCL_UNSUP_CLUSTER_COMMAND, 0, 0, 0, container->userdata); - } - break; - /* ZCL Doorlock */ - case ZBL_ZCL_DOORLOCK_LOCK_STATE: { - zb_form_network_cb cb = container->cb; - cb(0x0000, container->userdata); - } - break; - /* ZCL Fanmode */ - case ZBL_ZCL_FANMODE_FAN_MODE_STATE: { - zb_form_network_cb cb = container->cb; - cb(0x0000, container->userdata); - } - break; - /* ZCL Group */ - case ZBL_ZCL_GROUP_ADD_GROUP_REQ: { - zb_zcl_group_add_group_rsp cb = container->cb; - cb(0, 0, 0, 0, container->userdata); - } - break; - case ZBL_ZCL_GROUP_VIEW_GROUP_REQ: { - zb_zcl_group_view_group_rsp cb = container->cb; - cb(0, 0, 0, 0, NULL, container->userdata); - } - break; - case ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ: { - zb_zcl_group_get_group_membership_rsp cb = container->cb; - cb(0, 0, 0, 0, NULL, container->userdata); - } - break; - case ZBL_ZCL_GROUP_REMOVE_GROUP_REQ: { - zb_zcl_group_remove_group_rsp cb = container->cb; - cb(0, 0, 0, 0, container->userdata); - } - break; - /* ZCL Identify */ - case ZBL_ZCL_IDENTIFY_QUERY_REQ: { - zb_zcl_identify_query_cb cb = container->cb; - cb(0, 0, container->userdata); - } - break; - /* ZCL On/Off */ - case ZBL_ZCL_ON_OFF_GET_ON_OFF_STATE: { - zb_form_network_cb cb = container->cb; - cb(0x0000, container->userdata); - } - break; - /* ZCL Pollcontrol */ - case ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ: { - zb_zcl_pollctrl_check_in cb = container->cb; - cb(0, 0, container->userdata); - } - break; - /* ZCL Scene */ - case ZBL_ZCL_SCENE_ADD_SCENE_REQ: { - zb_zcl_scene_add_scene_rsp cb = container->cb; - cb(0, 0, 0, 0, 0, container->userdata); - } - break; - case ZBL_ZCL_SCENE_VIEW_SCENE_REQ: { - zb_zcl_scene_view_scene_rsp cb = container->cb; - cb(0, 0, 0, 0, 0, 0, NULL, NULL, 0, container->userdata); - } - break; - case ZBL_ZCL_SCENE_REMOVE_SCENE_REQ: { - zb_zcl_scene_remove_scene_rsp cb = container->cb; - cb(0, 0, 0, 0, 0, container->userdata); - } - break; - case ZBL_ZCL_SCENE_STORE_SCENE_REQ: { - zb_zcl_scene_store_scene_rsp cb = container->cb; - cb(0, 0, 0, 0, 0, container->userdata); - } - break; - case ZBL_ZCL_SCENE_REMOVE_ALL_SCENE_REQ: { - zb_zcl_scene_remove_all_scene_rsp cb = container->cb; - cb(0, 0, 0, 0, container->userdata); - } - break; - case ZBL_ZCL_SCENE_GET_SCENE_MEMBERSHIP_REQ: { - zb_zcl_scene_get_scene_membership_rsp cb = container->cb; - cb(0, 0, 0, 0, 0, 0, NULL, container->userdata); - } - break; - /* ZCL Thermostat */ - case ZBL_ZCL_THERMOSTAT_GET_LOCAL_TEMP: { - zb_form_network_cb cb = container->cb; - cb(0x0000, container->userdata); - } - break; - default: - ERR("Unhandled cid = %d", container->cid); - } - - container->tid = 0; - g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); - container->sid = 0; - - return G_SOURCE_REMOVE; -} - -static void _zbl_response_cb(GDBusConnection *connection, - const gchar *sender_name, const gchar *object_path, const gchar *interface_name, - const gchar *signal_name, GVariant *parameters, gpointer user_data) -{ - zbl_req_cb_s *container = user_data; - RETM_IF(NULL == container, "container is null"); - RETM_IF(NULL == container->cb, "cb is NULL"); - - container->found = true; - g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); - - switch (container->cid) { - /* Service */ - case ZBL_SERVICE_FORM_NETWORK: { - zb_form_network_cb cb = container->cb; - nwk_addr panid; - g_variant_get(parameters, "(q)", &panid); - cb(panid, container->userdata); - } - break; - case ZBL_SERVICE_DISABLE_NETWORK: { - zb_disable_network_cb cb = container->cb; - unsigned char ret = ZB_ZDP_SUCCESS; - g_variant_get(parameters, "(y)", &ret); - cb(ret, container->userdata); - } - break; - /* ZDP except Bind */ - case ZBL_ZDO_NWK_ADDR_REQ: { - zb_zdo_addr_rsp cb = container->cb; - - int j = 0; - nwk_addr addr16; - ieee_addr addr64; - unsigned char status; - unsigned char num; - unsigned char start_idx; - unsigned char value; - GVariantIter *mac_iter = NULL; - - g_variant_get(parameters, "(ya(y)qyy)", &status, &mac_iter, &addr16, &num, &start_idx); - while (g_variant_iter_loop(mac_iter, "(y)", &value)) { - addr64[j] = value; - j++; - } - - cb(status, addr64, addr16, num, start_idx, NULL, container->userdata); - if (NULL != mac_iter) - g_variant_iter_free(mac_iter); - } - break; - case ZBL_ZDO_NWK_ADDR_EXT_REQ: { - zb_zdo_addr_rsp cb = container->cb; - - int j = 0; - nwk_addr addr16; - ieee_addr addr64; - unsigned char status; - unsigned char num; - unsigned char start_idx; - unsigned char value; - GVariantIter *mac_iter = NULL; - GVariantIter *assoc_iter = NULL; - - g_variant_get(parameters, "(ya(y)qyyaq)", &status, &mac_iter, - &addr16, &num, &start_idx, &assoc_iter); - while (g_variant_iter_loop(mac_iter, "(y)", &value)) { - addr64[j] = value; - j++; - } - if (NULL != mac_iter) - g_variant_iter_free(mac_iter); - if (NULL != assoc_iter) - g_variant_iter_free(assoc_iter); - - cb(status, addr64, addr16, num, start_idx, NULL, container->userdata); - } - break; - case ZBL_ZDO_ACTIVE_EP_REQ: { - zb_zdo_active_ep_rsp cb = container->cb; - - int j = 0; - nwk_addr addr16; - unsigned char status; - unsigned char count; - unsigned char value; - GVariantIter *ep_iter = NULL; - unsigned char *ep_list; - - g_variant_get(parameters, "(yqa(y)y)", &status, &addr16, &ep_iter, &count); - ep_list = calloc(count+1, sizeof(unsigned char)); - RETM_IF(NULL == ep_list, "calloc() Fail(%d)", errno); - - while (g_variant_iter_loop(ep_iter, "(y)", &value)) { - ep_list[j] = value; - j++; - } - if (NULL != ep_iter) - g_variant_iter_free(ep_iter); - - cb(status, addr16, count, ep_list, container->userdata); - free(ep_list); - } - break; - case ZBL_ZDO_SIMPLE_DESC_REQ: { - zb_zdo_simple_desc_rsp cb = container->cb; - - int j = 0; - int count; - unsigned short addr16; - unsigned short value; - GVariantIter *in_iter = NULL; - GVariantIter *out_iter = NULL; - zb_zdo_simple_desc_h records; - - records = calloc(1, sizeof(struct zb_zdo_simple_desc_s)); - RETM_IF(NULL == records, "calloc() Fail(%d)", errno); - - container->found = true; - - g_variant_get(parameters, "(qiyyqqyyaqaq)", &addr16, &count, - &records->device_ver, - &records->ep, &records->profile_id, &records->device_id, - &records->num_of_in_clusters, &records->num_of_out_clusters, - &in_iter, &out_iter); -#if 0 - records->in_clusters = calloc(records->num_of_in_clusters, sizeof(unsigned short)); - if (NULL == records->in_clusters) { - ERR("calloc() Fail(%d)", errno); - if (NULL != in_iter) - g_variant_iter_free(in_iter); - if (NULL != out_iter) - g_variant_iter_free(out_iter); - return; - } - records->out_clusters = calloc(records->num_of_out_clusters, sizeof(unsigned short)); - if (NULL == records->out_clusters) { - ERR("calloc() Fail(%d)", errno); - free(records->in_clusters); - if (NULL != in_iter) - g_variant_iter_free(in_iter); - if (NULL != out_iter) - g_variant_iter_free(out_iter); - return; - } -#endif - while (g_variant_iter_loop(in_iter, "q", &value)) { - records->in_clusters[j] = value; - j++; - } - if (NULL != in_iter) - g_variant_iter_free(in_iter); - - j = 0; - while (g_variant_iter_loop(out_iter, "q", &value)) { - records->out_clusters[j] = value; - j++; - } - if (NULL != out_iter) - g_variant_iter_free(out_iter); - - DBG("addr16=0x%x, count=%d, records->ep=%d, records->device_id=0x%x", - addr16, count, records->ep, records->device_id); - for (j = 0; j < records->num_of_in_clusters; j++) - DBG("in_clusters[%d] = 0x%x", j, records->in_clusters[j]); - for (j = 0; j < records->num_of_out_clusters; j++) - DBG("out_clusters[%d] = 0x%x", j, records->out_clusters[j]); - - cb(addr16, count, records, container->userdata); -#if 0 - free(records->in_clusters); - free(records->out_clusters); -#endif - free(records); - } - break; - case ZBL_ZDO_MATCHED_DESCRIPTOR_REQ: { - zb_zdo_match_desc_rsp cb = container->cb; - - int j = 0; - int match_len; - nwk_addr addr16; - unsigned char value; - unsigned char status; - GVariantIter *ml_iter = NULL; - unsigned char *match_list = NULL; - g_variant_get(parameters, "(yqya(y))", &status, &addr16, &value, &ml_iter); - match_len = value; - - if (match_len > 0) { - match_list = calloc(match_len+1, sizeof(unsigned char)); - RETM_IF(NULL == match_list, "calloc() Fail(%d)", errno); - while (g_variant_iter_loop(ml_iter, "(y)", &value)) { - match_list[j] = value; - DBG("match_list[i]=%d", j, match_list[j]); - j++; - } - if (NULL != ml_iter) - g_variant_iter_free(ml_iter); - } - - DBG("Match count : [%d]", match_len); - DBG("Match list : [%p]", match_list); - - cb(status, addr16, match_len, match_list, container->userdata); - - if (match_list) - free(match_list); - } - break; - case ZBL_ZDO_NODE_DESC_REQ: { - zb_zdo_node_desc_rsp cb = container->cb; - - nwk_addr addr16; - unsigned char status; - zb_zdo_node_descriptor_h desc; - - desc = calloc(1, sizeof(struct zb_zdo_node_descriptor_s)); - RETM_IF(NULL == desc, "calloc() Fail(%d)", errno); - - container->found = true; - - g_variant_get(parameters, "(yqyyyyyyqyqqqy)", &status, &addr16, - &desc->logical_type, &desc->complex_desciptor_available, - &desc->user_descriptor_available, &desc->aps_flags, &desc->frequency_band, - &desc->mac_capability_flags, &desc->manufacturer_code, &desc->maximum_buffer_size, - &desc->maximum_incoming_transfer_size, &desc->server_mask, - &desc->maximum_outgoing_transfer_size, &desc->descriptor_capability_field); - - cb(status, addr16, desc, container->userdata); - free(desc); - } - break; - case ZBL_ZDO_POWER_DESC_REQ: { - zb_zdo_power_desc_rsp cb = container->cb; - - nwk_addr addr16; - unsigned char status; - zb_zdo_node_power_descriptor_h desc; - - desc = calloc(1, sizeof(struct zb_zdo_node_power_descriptor_s)); - RETM_IF(NULL == desc, "calloc() Fail(%d)", errno); - - g_variant_get(parameters, "(yqyyyy)", &status, &addr16, - &desc->current_power_mode, &desc->available_power_sources, - &desc->current_power_source, &desc->current_power_source_level); - - cb(status, addr16, desc, container->userdata); - free(desc); - } - break; - case ZBL_ZDO_COMPLEX_DESC_REQ: { - zb_zdo_complex_desc_rsp cb = container->cb; - - int length; - nwk_addr addr16; - unsigned char j = 0; - unsigned char value; - unsigned char status; - GVariantIter *comp_iter = NULL; - unsigned char *complex_desc = NULL; - - g_variant_get(parameters, "(yqya(y))", &status, &addr16, &length, &comp_iter); - if (length > 0) { - complex_desc = calloc(length, sizeof(char)); - if (NULL == complex_desc) { - if (NULL != comp_iter) - g_variant_iter_free(comp_iter); - ERR("calloc() Fail(%d)", errno); - return; - } - - while (g_variant_iter_loop(comp_iter, "(y)", &value)) { - complex_desc[j] = value; - j++; - } - if (NULL != comp_iter) - g_variant_iter_free(comp_iter); - } - - cb(status, addr16, length, complex_desc, container->userdata); - free(complex_desc); - } - break; - case ZBL_ZDO_USER_DESC_REQ: { - zb_zdo_user_desc_rsp cb = container->cb; - - int length; - nwk_addr addr16; - unsigned char j = 0; - unsigned char value; - unsigned char status; - GVariantIter *comp_iter = NULL; - unsigned char *complex_desc = NULL; - - g_variant_get(parameters, "(yqya(y))", &status, &addr16, &length, &comp_iter); - if (length > 0) { - complex_desc = calloc(length, sizeof(char)); - if (NULL == complex_desc) { - if (NULL != comp_iter) - g_variant_iter_free(comp_iter); - ERR("calloc() Fail(%d)", errno); - return; - } - while (g_variant_iter_loop(comp_iter, "(y)", &value)) { - complex_desc[j] = value; - j++; - } - if (NULL != comp_iter) - g_variant_iter_free(comp_iter); - } - - cb(status, addr16, length, complex_desc, container->userdata); - free(complex_desc); - } - case ZBL_ZDO_USER_DESC_SET_REQ: { - zb_zdo_user_desc_conf cb = container->cb; - unsigned char status; - g_variant_get(parameters, "(y)", &status); - cb(status, container->userdata); - } - break; - case ZBL_ZDO_MGMT_BIND_REQ: { - zb_zdo_mgmt_bind_rsp cb = container->cb; - - unsigned char status; - unsigned char value; - - int i = 0; - int j = 0; - unsigned char binding_table_enteries; - unsigned char binding_table_list_count; - unsigned char start_index; - unsigned short dst_addr16 = 0; - unsigned char dst_ep = 0; - - GVariantIter *mac_iter = NULL; - GVariantIter *rsp_iter = NULL; - GVariantIter *destep_iter = NULL; - zb_zdo_binding_table_h *records = NULL; - - g_variant_get(parameters, "(yyyya(ayyqyqayy))", &status, - &binding_table_enteries, &start_index, - &binding_table_list_count, &rsp_iter); - - if (binding_table_list_count > 0) { - records = calloc(binding_table_list_count, sizeof(zb_zdo_binding_table_h)); - RETM_IF(NULL == records, "calloc() Fail(%d)", errno); - for (i = 0; i < binding_table_list_count; i++) { - records[i] = calloc(binding_table_list_count, sizeof(struct zb_zdo_binding_table_s)); - if (NULL == records[i]) { - if (NULL != mac_iter) - g_variant_iter_free(mac_iter); - if (NULL != rsp_iter) - g_variant_iter_free(rsp_iter); - if (NULL != destep_iter) - g_variant_iter_free(destep_iter); - ERR("calloc() Fail(%d)", errno); - goto MGMT_NWK_BIND_REQ_OUT; - } - } - } - for (i = 0; i < binding_table_list_count; i++) { - g_variant_iter_loop(rsp_iter, "(ayyqyqayy)", &mac_iter, - &records[i]->src_ep, &records[i]->cluster_id, - &records[i]->dst_addr_mode, &dst_addr16, - &destep_iter, &dst_ep); - for (j = 0; j < 8; j++) { - g_variant_iter_loop(mac_iter, "y", &value); - records[i]->src_addr64[j] = value; - } - if (NULL != mac_iter) - g_variant_iter_free(mac_iter); - - if (0x03 == records[i]->dst_addr_mode) { - for (j = 0; j < 8; j++) { - g_variant_iter_loop(destep_iter, "y", &value); - records[i]->dst_addr64[j] = value; - } - records[i]->dst_ep = dst_ep; - DBG("Destination MAC Addr : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - records[i]->dst_addr64[7], records[i]->dst_addr64[6], - records[i]->dst_addr64[5], records[i]->dst_addr64[4], - records[i]->dst_addr64[3], records[i]->dst_addr64[2], - records[i]->dst_addr64[1], records[i]->dst_addr64[0]); - - } else if (0x01 == records[i]->dst_addr_mode) { - records[i]->dst_addr16 = dst_addr16; - } - if (NULL != destep_iter) - g_variant_iter_free(destep_iter); - } - if (NULL != rsp_iter) - g_variant_iter_free(rsp_iter); - - cb(status, binding_table_enteries, start_index, binding_table_list_count, - records, container->userdata); - -MGMT_NWK_BIND_REQ_OUT: - for (i = 0; i < binding_table_list_count; i++) { - if (records[i]) - free(records[i]); - } - free(records); - } - break; - case ZBL_ZDO_MGMT_LQI_REQ: { - zb_zdo_mgmt_lqi_rsp cb = container->cb; - - int i = 0; - int j = 0; - unsigned char value; - unsigned char status; - unsigned char start_index; - unsigned char neighbor_table_enteries; - unsigned char neighbor_table_list_count; - - GVariantIter *resp_iter = NULL; - GVariantIter *mac_iter = NULL; - GVariantIter *mac_iter1 = NULL; - zb_zdo_neighbor_table_desc_h *records = NULL; - - g_variant_get(parameters, "(yyyya(ayayyqyyyyy))", &status, &neighbor_table_enteries, - &start_index, &neighbor_table_list_count, &resp_iter); - - if (neighbor_table_list_count > 0) { - records = calloc(neighbor_table_list_count, sizeof(zb_zdo_neighbor_table_desc_h)); - RETM_IF(NULL == records, "calloc() Fail(%d)", errno); - for (i = 0; i < neighbor_table_list_count; i++) { - records[i] = calloc(1, sizeof(struct zb_zdo_neighbor_table_desc_s)); - if (NULL == records[i]) { - ERR("calloc() Fail(%d)", errno); - goto MGMT_LQI_REQ_OUT; - } - } - } - for (i = 0; i < neighbor_table_list_count; i++) { - g_variant_iter_loop(resp_iter, "(ayayyqyyyyy)", - &mac_iter, &mac_iter1, - &records[i]->device_type, &records[i]->addr16, - &records[i]->rx_on_when_idle, &records[i]->relationship, - &records[i]->permit_joining, &records[i]->depth, - &records[i]->lqi); - for (j = 0; j < 8; j++) { - g_variant_iter_loop(mac_iter, "y", &value); - records[i]->extended_pan_id[j] = value; - g_variant_iter_loop(mac_iter1, "y", &value); - records[i]->addr64[j] = value; - } - if (NULL != mac_iter) - g_variant_iter_free(mac_iter); - if (NULL != mac_iter1) - g_variant_iter_free(mac_iter1); - - DBG("ext PAN ID = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - records[i]->extended_pan_id[0], records[i]->extended_pan_id[1], - records[i]->extended_pan_id[2], records[i]->extended_pan_id[3], - records[i]->extended_pan_id[4], records[i]->extended_pan_id[5], - records[i]->extended_pan_id[6], records[i]->extended_pan_id[7]); - - DBG("IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - records[i]->addr64[0], records[i]->addr64[1], records[i]->addr64[2], records[i]->addr64[3], - records[i]->addr64[4], records[i]->addr64[5], records[i]->addr64[6], records[i]->addr64[7]); - } - if (NULL != resp_iter) - g_variant_iter_free(resp_iter); - - cb(status, neighbor_table_enteries, start_index, neighbor_table_list_count, - records, container->userdata); - -MGMT_LQI_REQ_OUT: - for (i = 0; i < neighbor_table_list_count; i++) { - if (records[i]) - free(records[i]); - } - free(records); - } - break; - case ZBL_ZDO_MGMT_RTG_REQ: { - zb_zdo_mgmt_rtg_rsp cb = container->cb; - - int i; - unsigned char status; - unsigned char start_index; - unsigned char routing_table_enteries; - unsigned char routing_table_list_count; - - GVariantIter *rsp_iter = NULL; - zb_zdo_routing_table_h *records = NULL; - - g_variant_get(parameters, "(yyyya(qyyyyq))", &status, &routing_table_enteries, - &start_index, &routing_table_list_count, &rsp_iter); - - if (routing_table_list_count > 0) { - records = calloc(routing_table_list_count, sizeof(zb_zdo_routing_table_h)); - RETM_IF(NULL == records, "calloc() Fail(%d)", errno); - for (i = 0; i < routing_table_list_count; i++) { - records[i] = calloc(1, sizeof(struct zb_zdo_routing_table_s)); - if (NULL == records[i]) { - ERR("calloc() Fail(%d)", errno); - goto MGMT_NWK_RTG_REQ_OUT; - } - } - } - - for (i = 0; i < routing_table_list_count; i++) { - g_variant_iter_loop(rsp_iter, "(qyyyyq)", &records[i]->dst_addr, - &records[i]->status, &records[i]->memory_constrained, - &records[i]->route_record_required, - &records[i]->many_to_one, &records[i]->next_hop_addr); - } - if (NULL != rsp_iter) - g_variant_iter_free(rsp_iter); - - cb(status, routing_table_enteries, start_index, routing_table_list_count, - records, container->userdata); - -MGMT_NWK_RTG_REQ_OUT: - for (i = 0; i < routing_table_list_count; i++) { - if (records[i]) - free(records[i]); - } - free(records); - } - break; - case ZBL_ZDO_MGMT_NWK_DISC_REQ: { - zb_zdo_mgmt_nwk_disc_rsp cb = container->cb; - int i = 0; - int j = 0; - unsigned char value; - unsigned char status = 0; - unsigned char nwk_count = 0; - unsigned char start_index = 0; - unsigned char nwk_list_count = 0; - - GVariantIter *mac_iter = NULL; - GVariantIter *resp_iter = NULL; - - DBG("_zbl_mgmt_nwk_disc_req_cb()"); - - g_variant_get(parameters, "(yyyya(ayyyyyyy))", &status, &nwk_count, - &start_index, &nwk_list_count, &resp_iter); - - zb_zdo_network_list_record_h *records = NULL; - - if (!status) { - if (nwk_list_count > 0) { - records = calloc(nwk_list_count, sizeof(zb_zdo_network_list_record_h)); - RETM_IF(NULL == records, "calloc() Fail(%d)", errno); - for (i = 0; i < nwk_list_count; i++) { - records[i] = calloc(1, sizeof(struct zb_zdo_network_list_record_s)); - if (NULL == records[i]) { - ERR("calloc() Fail(%d)", errno); - goto MGMT_NWK_DISC_REQ_OUT; - } - } - } - for (i = 0; i < nwk_list_count; i++) { - g_variant_iter_loop(resp_iter, "(ayyyyyyy)", &mac_iter, &records[i]->logical_channel, - &records[i]->stack_profile, &records[i]->zigbee_version, &records[i]->beacon_order, - &records[i]->superframe_order, &records[i]->permit_joining); - for (j = 0; j < 8; j++) { - g_variant_iter_loop(mac_iter, "y", &value); - records[i]->extended_pan_id[j] = value; - } - if (NULL != mac_iter) - g_variant_iter_free(mac_iter); - } - if (NULL != resp_iter) - g_variant_iter_free(resp_iter); - } - - cb(status, nwk_count, start_index, nwk_list_count, records, container->userdata); - -MGMT_NWK_DISC_REQ_OUT: - for (i = 0; i < nwk_list_count; i++) { - if (records[i]) - free(records[i]); - } - free(records); - } - break; - case ZBL_ZDO_MGMT_PERMIT_JOIN_REQ: { - zb_zdo_mgmt_permit_joining_rsp cb = container->cb; - unsigned char status; - g_variant_get(parameters, "(y)", &status); - cb(status, container->userdata); - } - break; - case ZBL_ZDO_MGMT_LEAVE_REQ: { - zb_zdo_mgmt_leave_rsp cb = container->cb; - unsigned char status; - g_variant_get(parameters, "(y)", &status); - cb(status, container->userdata); - } - break; - /* ZDP Bind */ - case ZBL_ZDO_BIND_REQ: { - zb_zdo_bind_rsp cb = container->cb; - unsigned char status; - g_variant_get(parameters, "(y)", &status); - cb(status, container->userdata); - } - break; - case ZBL_ZDO_UNBIND_REQ: { - zb_zdo_unbind_rsp cb = container->cb; - unsigned char status; - g_variant_get(parameters, "(y)", &status); - cb(status, container->userdata); - } - break; - /* Custom */ - case ZBL_CUSTOM_APS_SEND_REQ: { - zb_aps_send_rsp cb = container->cb; - - unsigned short addr16; - unsigned char src_ep; - unsigned char dst_ep; - unsigned short cluster_id; - unsigned short profile_id; - unsigned short payload_len = 0; - unsigned char *payload = NULL; - - unsigned char value; - GVariantIter *payload_iter = NULL; - int i = 0; - - g_variant_get(parameters, "(qyyqqqa(y))", &addr16, &src_ep, &dst_ep, - &cluster_id, &profile_id, &payload_len, &payload_iter); - - if (payload_len > 0) { - payload = calloc(payload_len+1, sizeof(unsigned char)); - while (g_variant_iter_loop(payload_iter, "(y)", &value)) - payload[i++] = value; - - if (NULL != payload_iter) - g_variant_iter_free(payload_iter); - } - - cb(addr16, src_ep, dst_ep, cluster_id, profile_id, payload_len, payload, - container->userdata); - - free(payload); - } - break; - case ZBL_CUSTOM_ZCL_SEND_REQ: { - zb_zcl_send_rsp cb = container->cb; - - unsigned short addr16; - unsigned char src_ep; - unsigned char dst_ep; - unsigned short cluster_id; - unsigned short profile_id; - unsigned short payload_len = 0; - unsigned char *payload = NULL; - - unsigned char value; - GVariantIter *payload_iter = NULL; - int i = 0; - - g_variant_get(parameters, "(qyyqqqa(y))", &addr16, &src_ep, &dst_ep, - &cluster_id, &profile_id, &payload_len, &payload_iter); - - if (payload_len > 0) { - payload = calloc(payload_len + 1, sizeof(unsigned char)); - while (g_variant_iter_loop(payload_iter, "(y)", &value)) - payload[i++] = value; - - if (NULL != payload_iter) - g_variant_iter_free(payload_iter); - } - - cb(addr16, src_ep, dst_ep, cluster_id, profile_id, payload_len, payload, - container->userdata); - - free(payload); - } - break; - case ZBL_CUSTOM_LOCAL_SEND_REQ: { - zb_send_to_local_rsp cb = container->cb; - - unsigned char *data = NULL; - unsigned short length = 0; - unsigned char value; - GVariantIter *payload_iter = NULL; - int i = 0; - - g_variant_get(parameters, "(qa(y))", &length, &payload_iter); - - if (length > 0) { - data = calloc(length, sizeof(unsigned char)); - while (g_variant_iter_loop(payload_iter, "(y)", &value)) - data[i++] = value; - - if (NULL != payload_iter) - g_variant_iter_free(payload_iter); - } - - cb(length, data, container->userdata); - - free(data); - } - break; - /* ZCL Global */ - case ZBL_ZCL_GLOBAL_READ_ATTRIBUTE_REQ: { - zb_zcl_global_rsp cb = container->cb; - - int j = 0; - int isString; - unsigned char value; - - nwk_addr addr16; - unsigned char ep; - unsigned short attr_id; - unsigned short cluster_id; - unsigned char status; - unsigned char type; - unsigned short records_len; - unsigned char attr_value[128]; - - GVariantIter *iter = NULL; - read_attr_status_record_h records; - zb_global_record_data_s *data; - - data = calloc(1, sizeof(zb_global_record_data_s)); - records = calloc(1, sizeof(struct read_attribute_status_record_s)); - if (!records || !data) { - ERR("calloc() Fail(%d)", errno); - goto GLOBAL_READ_ATTRIBUTE_REQ_OUT; - } - - g_variant_get(parameters, "(qya(y)qqyyqi)", - &addr16, &ep, &iter, &attr_id, &cluster_id, &status, &type, &records_len, &isString); - if (!isString) { - while (g_variant_iter_loop(iter, "(y)", &value)) { - attr_value[j] = value; - DBG("attr_value[%d] = 0x%02X", j, value); - j++; - } - if (NULL != iter) - g_variant_iter_free(iter); - } else { - while (g_variant_iter_loop(iter, "(y)", &value)) { - if (j == 0) - records_len = value; - attr_value[j] = value; - DBG("attr_value[%d] = 0x%02X", j, value); - j++; - } - if (NULL != iter) - g_variant_iter_free(iter); - } - - records->id = attr_id; - records->status = status; - records->type = type; - records->value = attr_value; - data->type = ZB_GLOBAL_READ_ATTR; - data->record.read_attr = &records; - data->records_len = records_len; - - cb(addr16, ep, cluster_id, data, records_len, container->userdata); - -GLOBAL_READ_ATTRIBUTE_REQ_OUT: - if (records) - free(records); - if (data) - free(data); - } - break; - case ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ: { - zb_zcl_global_rsp cb = container->cb; - - int i = 0; - nwk_addr addr16; - unsigned char ep; - unsigned short cluster_id; - unsigned short attribute_id; - int records_len; - unsigned char value; - - GVariantIter *stat_iter = NULL; - GVariantIter *attr_iter = NULL; - write_attr_status_record_h records; - zb_global_record_data_s *data; - - g_variant_get(parameters, "(qya(y)aqqi)", - &addr16, &ep, &stat_iter, &attr_iter, &cluster_id, &records_len); - - records = calloc(records_len, sizeof(struct write_attribute_status_record_s)); - data = calloc(1, sizeof(zb_global_record_data_s)); - if (!records || !data) { - if (NULL != stat_iter) - g_variant_iter_free(stat_iter); - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - ERR("calloc() Fail(%d)", errno); - goto GLOBAL_WRITE_ATTRIBUTE_REQ_OUT; - } - - while (g_variant_iter_loop(stat_iter, "(y)", &value)) { - records[i].status = value; - i++; - } - if (NULL != stat_iter) - g_variant_iter_free(stat_iter); - - i = 0; - while (g_variant_iter_loop(attr_iter, "q", &attribute_id)) { - records[i].id = attribute_id; - DBG("Attribute Id 0x%04X", attribute_id); - i++; - } - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - - data->type = ZB_GLOBAL_WRITE_ATTR; - data->record.write_attr = &records; - data->records_len = records_len; - - cb(addr16, ep, cluster_id, data, records_len, container->userdata); - -GLOBAL_WRITE_ATTRIBUTE_REQ_OUT: - free(records); - free(data); - } - break; - case ZBL_ZCL_GLOBAL_CONFIGURE_REPORTING_REQ: { - zb_zcl_global_rsp cb = container->cb; - nwk_addr addr16; - unsigned char ep; - unsigned short cluster_id; - unsigned short attIdVal; - unsigned char value; - int j = 0, l = 0, k = 0, rec_len; - GVariantIter *stat_iter = NULL; - GVariantIter *attr_iter = NULL; - GVariantIter *dir_iter = NULL; - report_config_response_record_h records; - zb_global_record_data_s *data; - - g_variant_get(parameters, "(a(y)aqa(y)qiqy)", - &stat_iter, &attr_iter, &dir_iter, &cluster_id, &rec_len, &addr16, &ep); - - records = calloc(rec_len, sizeof(struct reporting_configuration_response_record_s)); - data = calloc(1, sizeof(zb_global_record_data_s)); - if (!data || !records) { - if (NULL != stat_iter) - g_variant_iter_free(stat_iter); - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - if (NULL != dir_iter) - g_variant_iter_free(dir_iter); - ERR("calloc() Fail(%d)", errno); - goto GLOBAL_CONFIGURE_REPORTING_REQ_OUT; - } - - while (g_variant_iter_loop(stat_iter, "(y)", &value)) { - DBG("Value 0x%02X", value); - records[j].status = value; - j++; - } - if (NULL != stat_iter) - g_variant_iter_free(stat_iter); - - while (g_variant_iter_loop(attr_iter, "q", &attIdVal)) { - if (records[l].status != ZB_ZCL_SUCCESS) - records[l].id = attIdVal; - l++; - } - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - - while (g_variant_iter_loop(dir_iter, "(y)", &value)) { - if (records[k].status != ZB_ZCL_SUCCESS) - records[k].dir = value; - k++; - } - if (NULL != dir_iter) - g_variant_iter_free(dir_iter); - - data->type = ZB_GLOBAL_CONFIG_REPORT; - data->record.report_config_rsp = &records; - data->records_len = rec_len; - - cb(addr16, ep, cluster_id, data, rec_len, container->userdata); - -GLOBAL_CONFIGURE_REPORTING_REQ_OUT: - free(records); - free(data); - } - break; - case ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_REQ: { - zb_zcl_global_discover_attr_rsp cb = container->cb; - nwk_addr addr16; - unsigned char ep; - discover_attr_info_record_h *records; - - int records_len; - unsigned short cluster_id; - unsigned short attribute_id; - unsigned char value; - int j = 0, l = 0; - int discovery_complete; - GVariantIter *stat_iter = NULL; - GVariantIter *attr_iter = NULL; - - g_variant_get(parameters, "(qya(y)aqqii)", &addr16, &ep, &stat_iter, - &attr_iter, &cluster_id, &records_len, &discovery_complete); - records = calloc(records_len, sizeof(discover_attr_info_record_h)); - RETM_IF(NULL == records, "calloc() Fail(%d)", errno); - for (j = 0; j < records_len; j++) { - records[j] = calloc(1, sizeof(struct discover_attribute_info_record_s)); - if (NULL == records[j]) { - ERR("calloc() Fail(%d)", errno); - for (l = 0; l < j; l++) - free(records[l]); - free(records); - if (NULL != stat_iter) - g_variant_iter_free(stat_iter); - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - return; - } - } - - j = 0; - while (g_variant_iter_loop(stat_iter, "(y)", &value)) { - records[j]->type = value; - DBG("Attribute Type 0x%02X", value); - j++; - } - if (NULL != stat_iter) - g_variant_iter_free(stat_iter); - - while (g_variant_iter_loop(attr_iter, "q", &attribute_id)) { - records[l]->id = attribute_id; - DBG("Attribute Id 0x%04X", attribute_id); - l++; - } - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - - cb(addr16, ep, cluster_id, discovery_complete, records, records_len, - container->userdata); - - for (j = 0; j < records_len; j++) - free(records[j]); - free(records); - } - break; - case ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_STRUCTURED_REQ: { - zb_zcl_global_rsp cb = container->cb; - cb(0, 0, 0, NULL, 0, container->userdata); - } - break; - /* GLOBAL_DISCOVER_COMMAND_RECEIVED and GLOBAL_DISCOVER_COMMAND_GENERATED should be handled as same way */ - case ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_RECEIVED_REQ: - case ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_GENERATED_REQ: { - zb_zcl_global_discover_cmds_rsp cb = container->cb; - - nwk_addr addr16; - unsigned char ep; - - int j = 0; - char value; - unsigned short cluster_id; - unsigned short cmd_len; - unsigned char *cmd_data; - unsigned char discoveryComplete; - GVariantIter *cmd_iter = NULL; - - g_variant_get(parameters, "(a(y)qqqyy)", &cmd_iter, &cluster_id, &cmd_len, - &addr16, &ep, &discoveryComplete); - - cmd_data = calloc(cmd_len+1, sizeof(char)); - if (NULL == cmd_data) { - ERR("calloc() Fail(%d)", errno); - if (NULL != cmd_iter) - g_variant_iter_free(cmd_iter); - return; - } - - while (g_variant_iter_loop(cmd_iter, "(y)", &value)) { - DBG("Value 0x%02X", value); - cmd_data[j] = value; - j++; - } - if (NULL != cmd_iter) - g_variant_iter_free(cmd_iter); - - cb(addr16, ep, cluster_id, discoveryComplete, cmd_data, cmd_len, container->userdata); - free(cmd_data); - } - break; - case ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_EXTENDED_REQ: { - zb_zcl_global_discover_attr_extended_rsp cb = container->cb; - nwk_addr addr16; - unsigned char ep; - - int i = 0; - int j = 0; - unsigned short cluster_id; - unsigned char t_value; - unsigned char ac_value; - - unsigned short rec_len; - unsigned short attr_data; - unsigned char discoveryComplete; - GVariantIter *attr_iter = NULL; - GVariantIter *type_iter = NULL; - GVariantIter *ac_iter = NULL; - extended_attr_info_h *records; - - DBG("Will get the value now"); - - g_variant_get(parameters, "(aqa(y)a(y)qqqyy)", &attr_iter, &type_iter, &ac_iter, - &cluster_id, &rec_len, &addr16, &ep, &discoveryComplete); - - DBG("records length 0x%04X", rec_len); - - records = calloc(rec_len, sizeof(extended_attr_info_h)); - RETM_IF(NULL == records, "calloc() Fail(%d)", errno); - for (j = 0; j < rec_len; j++) { - records[j] = calloc(1, sizeof(struct extended_attribute_infomation_s)); - if (NULL == records[j]) { - for (i = 0; i < j; i++) - free(records[i]); - free(records); - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - if (NULL != type_iter) - g_variant_iter_free(type_iter); - if (NULL != ac_iter) - g_variant_iter_free(ac_iter); - - ERR("calloc() Fail(%d)", errno); - return; - } - } - - j = 0; - while (g_variant_iter_loop(attr_iter, "q", &attr_data) - && g_variant_iter_loop(type_iter, "(y)", &t_value) - && g_variant_iter_loop(ac_iter, "(y)", &ac_value)) { - DBG("attrData 0x%04X", attr_data); - DBG("t_value 0x%02X", t_value); - DBG("ac_value 0x%02X", ac_value); - records[j]->id = attr_data; - records[j]->type = t_value; - records[j]->acl = ac_value; - j++; - } - if (NULL != attr_iter) - g_variant_iter_free(attr_iter); - if (NULL != type_iter) - g_variant_iter_free(type_iter); - if (NULL != ac_iter) - g_variant_iter_free(ac_iter); - - cb(addr16, ep, cluster_id, discoveryComplete, records, rec_len, container->userdata); - - for (j = 0; j < rec_len; j++) - free(records[j]); - free(records); - } - break; - case ZBL_ZCL_GLOBAL_READ_CONFIGURE_REPORTING_REQ: { - zb_zcl_global_rsp cb = container->cb; - nwk_addr addr16; - unsigned char ep; - unsigned short cluster_id; - - int i = 0; - int j = 0; - char value; - unsigned char *status = NULL; - unsigned char *data_size = NULL; - unsigned char *change = NULL; - unsigned short record_length; - GVariantIter *resp_iter = NULL; - GVariantIter *data_iter = NULL; - - report_config_record_h *records = NULL; - zb_global_record_data_s *data = NULL; - - g_variant_get(parameters, "(qyqqa(yyqyqqayq))", - &addr16, &ep, &cluster_id, &record_length, &resp_iter); - - records = calloc(record_length, sizeof(report_config_record_h)); - for (i = 0; i < record_length; i++) { - records[i] = calloc(1, sizeof(struct reporting_configuration_record_s)); - if (NULL == records[i]) { - ERR("calloc() Fail(%d)", errno); - goto GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT; - } - } - data = calloc(1, sizeof(zb_global_record_data_s)); - if (!data || !records) { - ERR("calloc() Fail(%d)", errno); - goto GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT; - } - - DBG("record_length %d", record_length); - status = calloc(record_length, sizeof(unsigned char)); - data_size = calloc(record_length, sizeof(unsigned char)); - if (!status || !data_size) { - ERR("Couldn't allocate the memory (%s)", errno); - goto GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT; - } - - for (i = 0; i < record_length; i++) { - g_variant_iter_loop(resp_iter, "(yyqyqqayq)", &status[i], &records[i]->dir, - &records[i]->id, &records[i]->type, &records[i]->max_i, &records[i]->min_i, - &data_iter, &records[i]->to); - if (records[i]->dir != ZCL_REPORTING_DIRECTION_REPORTED && - (zb_get_analog_or_discret(records[i]->type) == DATA_TYPE_ANALOG)) { - data_size[i] = zb_get_data_size(records[j]->type); - j = 0; - if (data_size[i] != 0xff) { - change = calloc(data_size[i]+1, sizeof(unsigned char)); - if (!change) { - ERR("calloc() Fail(%d)", errno); - records[i]->change = NULL; - if (NULL != data_iter) - g_variant_iter_free(data_iter); - continue; - } - while (g_variant_iter_loop(data_iter, "y", &value)) { - change[j] = value; - j++; - } - if (NULL != data_iter) - g_variant_iter_free(data_iter); - records[i]->change = change; - } else - records[i]->change = NULL; - } else - records[i]->change = NULL; - } - if (NULL != resp_iter) - g_variant_iter_free(resp_iter); - - data->type = ZB_GLOBAL_READ_REPORT_CONFIG; - data->record.report_config = records; - data->records_len = record_length; - - cb(addr16, ep, cluster_id, data, record_length, container->userdata); - -GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT: - free(data_size); - free(status); - for (i = 0; i < record_length; i++) - free(records[i]); - free(records); - free(data); - } - break; - /* ZCL Alarm */ - case ZBL_ZCL_ALARM_GET_ALARM_REQ: { - zb_zcl_alarm_get_alarm_rsp cb = container->cb; - - nwk_addr addr16 = 0; - unsigned char ep = 0; - unsigned char status = 0; - unsigned char alarm_code = 0; - unsigned short cluster_id = 0; - unsigned int time_stamp = 0; - - g_variant_get(parameters, "(qyyyqu)", &addr16, &ep, &status, &alarm_code, - &cluster_id, &time_stamp); - cb(addr16, ep, status, alarm_code, cluster_id, time_stamp, container->userdata); - } - break; - /* ZCL Doorlock */ - case ZBL_ZCL_DOORLOCK_LOCK_STATE: { - ERR("Unhandled cid = %d", container->cid); - } - break; - /* ZCL Fanmode */ - case ZBL_ZCL_FANMODE_FAN_MODE_STATE: { - ERR("Unhandled cid = %d", container->cid); - } - break; - /* ZCL Group */ - case ZBL_ZCL_GROUP_ADD_GROUP_REQ: { - zb_zcl_group_add_group_rsp cb = container->cb; - - nwk_addr addr16; - unsigned char ep; - unsigned char status; - unsigned short group_id; - - g_variant_get(parameters, "(qyyq)", &addr16, &ep, &status, &group_id); - cb(addr16, ep, status, group_id, container->userdata); - } - break; - case ZBL_ZCL_GROUP_VIEW_GROUP_REQ: { - zb_zcl_group_view_group_rsp cb = container->cb; - - int j = 0; - nwk_addr addr16; - unsigned char ep; - unsigned char value; - unsigned char status; - unsigned short group_id; - char *group_name = NULL; - GVariantIter *grpNameiter = NULL; - - g_variant_get(parameters, "(qyyqay)", &addr16, &ep, &status, &group_id, &grpNameiter); - g_variant_iter_loop(grpNameiter, "y", &value); - /* first byte indicates the length of the string */ - if ((value - '0') > 0) { - DBG("Value %d ", (value - '0')); - group_name = calloc((value - '0') + 1, sizeof(char)); - if (NULL == group_name) { - if (NULL != grpNameiter) - g_variant_iter_free(grpNameiter); - ERR("calloc() Fail(%d)", errno); - goto GROUP_VIEW_GROUP_REQ_OUT; - } - group_name[j] = value; - j++; - while (g_variant_iter_loop(grpNameiter, "y", &value) && (j <= (value - '0'))) { - group_name[j] = value; - DBG("Name %c", group_name[j]); - j++; - } - if (NULL != grpNameiter) - g_variant_iter_free(grpNameiter); - } else { - group_name = calloc(1, sizeof(char)); - if (NULL == group_name) { - if (NULL != grpNameiter) - g_variant_iter_free(grpNameiter); - ERR("calloc() Fail(%d)", errno); - goto GROUP_VIEW_GROUP_REQ_OUT; - } - group_name[j] = value; - j++; - group_name[j] = '\0'; - j++; - } - - DBG("GroupName = %s", group_name); - cb(addr16, ep, status, group_id, group_name, container->userdata); -GROUP_VIEW_GROUP_REQ_OUT: - free(group_name); - } - break; - case ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ: { - zb_zcl_group_get_group_membership_rsp cb = container->cb; - - int j = 0; - nwk_addr addr16; - unsigned char ep; - unsigned short gl_value; - unsigned char capacity; - unsigned char group_count; - unsigned short *grouplist = NULL; - GVariantIter *grpListiter = NULL; - - g_variant_get(parameters, "(qyyyaq)", &addr16, &ep, &capacity, &group_count, &grpListiter); - - if (group_count > 0) { - grouplist = calloc(group_count+1, sizeof(unsigned short)); - if (NULL == grouplist) { - if (NULL != grpListiter) - g_variant_iter_free(grpListiter); - ERR("calloc() Fail(%d)", errno); - return; - } - RETM_IF(NULL == grouplist, "calloc() Fail(%d)", errno); - - while (g_variant_iter_loop(grpListiter, "q", &gl_value)) { - grouplist[j] = gl_value; - j++; - } - if (NULL != grpListiter) - g_variant_iter_free(grpListiter); - } - - cb(addr16, ep, capacity, group_count, grouplist, container->userdata); - - free(grouplist); - } - break; - case ZBL_ZCL_GROUP_REMOVE_GROUP_REQ: { - zb_zcl_group_remove_group_rsp cb = container->cb; - - nwk_addr addr16; - unsigned char ep; - unsigned char status; - unsigned short group_id; - - g_variant_get(parameters, "(qyyq)", &addr16, &ep, &status, &group_id); - - cb(addr16, ep, status, group_id, container->userdata); - } - break; - /* ZCL Identify */ - case ZBL_ZCL_IDENTIFY_QUERY_REQ: { - zb_zcl_identify_query_cb cb = container->cb; - - nwk_addr addr16 = 0; - unsigned short identify_time = 0; - g_variant_get(parameters, "(qq)", &addr16, &identify_time); - - cb(addr16, identify_time, container->userdata); - } - break; - /* ZCL On/Off */ - case ZBL_ZCL_ON_OFF_GET_ON_OFF_STATE: { - ERR("Unhandled cid = %d", container->cid); - } - break; - /* ZCL Pollcontrol */ - case ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ: { - zb_zcl_pollctrl_check_in cb = container->cb; - - nwk_addr addr16 = 0; - unsigned char ep = 0; - - g_variant_get(parameters, "(qy)", &addr16, &ep); - cb(addr16, ep, container->userdata); - } - break; - /* ZCL Scene */ - case ZBL_ZCL_SCENE_ADD_SCENE_REQ: { - zb_zcl_scene_add_scene_rsp cb = container->cb; - - nwk_addr addr16 = 0; - unsigned char ep; - unsigned char status; - unsigned short group_id; - unsigned char scene_id; - - g_variant_get(parameters, "(qyyqy)", &addr16, &ep, &status, &group_id, &scene_id); - cb(addr16, ep, status, group_id, scene_id, container->userdata); - } - break; - case ZBL_ZCL_SCENE_VIEW_SCENE_REQ: { - zb_zcl_scene_view_scene_rsp cb = container->cb; - - int j = 0; - int len; - nwk_addr addr16 = 0; - unsigned char ep; - unsigned char status; - unsigned short group_id; - unsigned char scene_id; - unsigned short transition_time = 0; - unsigned char value; - unsigned short ext_len = 0; - char *scene_name = NULL; - char *extendedFieldSets = NULL; - GVariantIter *sceneNameIter = NULL; - GVariantIter *extendedSetIter = NULL; - - g_variant_get(parameters, "(qyyqyqa(y)ya(y))", &addr16, &ep, &status, &group_id, &scene_id, - &transition_time, &sceneNameIter, &ext_len, &extendedSetIter); - - g_variant_iter_loop(sceneNameIter, "(y)", &value); - - /** first byte indicates the length of the string */ - len = value -'0'; - if (0 < len) { - scene_name = calloc(len + 1, sizeof(char)); - if (NULL == scene_name) { - ERR("calloc() Fail(%d)", errno); - goto SCENE_VIEW_SCENE_REQ_OUT; - } - scene_name[j] = value; - j++; - while (g_variant_iter_loop(sceneNameIter, "(y)", &value)) { - scene_name[j] = value; - j++; - } - } else { - scene_name = calloc(1 + 1, sizeof(char)); - if (NULL == scene_name) { - ERR("calloc() Fail(%d)", errno); - goto SCENE_VIEW_SCENE_REQ_OUT; - } - scene_name[j] = value; - } - - j = 0; - if (0 < ext_len) { - extendedFieldSets = calloc(ext_len + 1, sizeof(char)); - if (NULL == extendedFieldSets) { - ERR("calloc() Fail(%d)", errno); - goto SCENE_VIEW_SCENE_REQ_OUT; - } - while (g_variant_iter_loop(extendedSetIter, "(y)", &value)) { - extendedFieldSets[j] = value; - j++; - } - } - - cb(addr16, ep, status, group_id, scene_id, transition_time, scene_name, - extendedFieldSets, ext_len, container->userdata); - -SCENE_VIEW_SCENE_REQ_OUT: - free(scene_name); - free(extendedFieldSets); - } - break; - case ZBL_ZCL_SCENE_REMOVE_SCENE_REQ: { - zb_zcl_scene_remove_scene_rsp cb = container->cb; - - nwk_addr addr16 = 0; - unsigned char ep; - unsigned char status; - unsigned short group_id; - unsigned char scene_id; - - g_variant_get(parameters, "(qyyqy)", &addr16, &ep, &status, &group_id, &scene_id); - cb(addr16, ep, status, group_id, scene_id, container->userdata); - } - break; - case ZBL_ZCL_SCENE_STORE_SCENE_REQ: { - zb_zcl_scene_store_scene_rsp cb = container->cb; - - nwk_addr addr16 = 0; - unsigned char ep; - unsigned char status; - unsigned short group_id; - unsigned char scene_id; - - g_variant_get(parameters, "(qyyqy)", &addr16, &ep, &status, &group_id, &scene_id); - cb(addr16, ep, status, group_id, scene_id, container->userdata); - } - break; - case ZBL_ZCL_SCENE_REMOVE_ALL_SCENE_REQ: { - zb_zcl_scene_remove_all_scene_rsp cb = container->cb; - - nwk_addr addr16 = 0; - unsigned char ep; - unsigned char status; - unsigned short group_id; - - g_variant_get(parameters, "(qyyq)", &addr16, &ep, &status, &group_id); - cb(addr16, ep, status, group_id, container->userdata); - } - break; - case ZBL_ZCL_SCENE_GET_SCENE_MEMBERSHIP_REQ: { - zb_zcl_scene_get_scene_membership_rsp cb = container->cb; - - int j = 0; - nwk_addr addr16 = 0; - unsigned char ep; - unsigned char status; - unsigned short group_id; - unsigned char capacity; - unsigned char value; - unsigned char scene_count = 0; - unsigned char *scene_list = NULL; - GVariantIter *sceneListIter = NULL; - - g_variant_get(parameters, "(qyyyqya(y))", &addr16, &ep, &status, &capacity, &group_id, - &scene_count, &sceneListIter); - - if (0 < scene_count) { - scene_list = calloc(scene_count+1, sizeof(char)); - if (NULL == scene_list) { - ERR("calloc() Fail(%d)", errno); - goto SCENE_GET_SCENE_MEMBERSHIP_REQ_OUT; - } - while (g_variant_iter_loop(sceneListIter, "(y)", &value)) { - scene_list[j] = value; - DBG("Scene_List 0x%02X", scene_list[j]); - j++; - } - } - - cb(addr16, ep, status, capacity, group_id, scene_count, scene_list, container->userdata); -SCENE_GET_SCENE_MEMBERSHIP_REQ_OUT: - free(scene_list); - } - break; - /* ZCL Thermostat */ - case ZBL_ZCL_THERMOSTAT_GET_LOCAL_TEMP: { - ERR("Unhandled cid = %d", container->cid); - } - break; - default: - ERR("Unhandled cid = %d", container->cid); - } -} - -int zbl_set_event_cb(zigbee_h handle, zb_event_cb event_handler) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->event_handler = event_handler; - return ZIGBEE_ERROR_NONE; -} - -static gboolean _zbl_timeout_enable(gpointer p) -{ - zbl_req_cb_s *container = NULL; - zb_enable_cb cb = NULL; - - DBG("zb_enable_cb()"); - - RETVM_IF(NULL == gdbus_conn, G_SOURCE_REMOVE, "gdbus_conn is NULL"); - container = p; - RETVM_IF(NULL == container, G_SOURCE_REMOVE, "cb_container is NULL"); - cb = container->cb; - - if (false == container->found && container->cb) - cb(ZB_ZDP_NOT_SUPPORTED, container->userdata); - - container->tid = 0; - - g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); - DBG("container->sid=%d unsubscribed"); - container->sid = 0; - - return G_SOURCE_REMOVE; -} - -static void _zbl_enable_cb(GDBusConnection *connection, - const gchar *sender_name, const gchar *object_path, const gchar *interface_name, - const gchar *signal_name, GVariant *parameters, gpointer user_data) -{ - zbl_req_cb_s *container = user_data; - zb_enable_cb cb = container->cb; - - unsigned char ret = ZB_ZDP_SUCCESS; - gboolean value = TRUE; - - container->found = true; - - DBG("_zbl_enable_cb"); - - g_variant_get(parameters, "(b)", &value); - if (!value) - ret = ZB_ZDP_UNKNOWN; - - if (cb) - cb(ret, container->userdata); - - if (container->sid) - g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); -} - - -int zbl_enable(zigbee_h handle, zb_enable_cb cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - - DBG("zbl_enable()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = ZIGBEE_BROADCAST_TIMEOUT; - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_MANAGER_INTERFACE, "zigbee_state", ZIGBEE_DBUS_OBJPATH, - NULL, G_DBUS_SIGNAL_FLAGS_NONE, - _zbl_enable_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_enable, container); - container->userdata = user_data; - - g_dbus_connection_call(gdbus_conn, - ZIGBEE_MANAGER_INTERFACE, - ZIGBEE_DBUS_OBJPATH, - ZIGBEE_MANAGER_INTERFACE, - "enable", - NULL, NULL, - G_DBUS_CALL_FLAGS_NONE, - to, NULL, - NULL, NULL); - - return ZIGBEE_ERROR_NONE; -} - -int zbl_disable(void) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_disable()"); - - variant = g_dbus_connection_call_sync(gdbus_conn, - ZIGBEE_SERVER_NAME, - ZIGBEE_DBUS_OBJPATH, - ZIGBEE_MANAGER_INTERFACE, - "disable", - NULL, NULL, - G_DBUS_CALL_FLAGS_NONE, - -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'disable' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_hw_reset(void) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(service_gproxy, "zb_hw_reset", NULL, - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'zb_hw_reset' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_get_network_info(ieee_addr addr64, nwk_addr *nodeid, nwk_addr *panid, - unsigned char *channel, unsigned char *tx_power) -{ - GVariant *variant = NULL; - GVariantIter *iter = NULL; - GError *dbus_err = NULL; - int result = ZIGBEE_ERROR_NONE; - - nwk_addr _nodeid; - nwk_addr _panid; - unsigned char _radio_channel; - unsigned char _radio_tx_power; - unsigned char value; - int i = 0; - - DBG("zbl_get_network_info()"); - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(service_gproxy, "get_network_info", - NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to 'get_network_info' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(ia(y)qqyy)", &result, &iter, - &_nodeid, &_panid, &_radio_channel, &_radio_tx_power); - - /* Get EUI */ - i = 0; - while (g_variant_iter_loop(iter, "(y)", &value)) { - addr64[i] = value; - i++; - } - - DBG(" Result: [%X]", result); - DBG(" EUI(%d) : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", i, - addr64[0], addr64[1], addr64[2], addr64[3], - addr64[4], addr64[5], addr64[6], addr64[7]); - DBG(" nodeID [0x%04X]", _nodeid); - DBG(" PanID [0x%04X]", _panid); - DBG(" Channel [%d] Tx Power [%d]", _radio_channel, _radio_tx_power); - - if (nodeid) - *nodeid = _nodeid; - if (panid) - *panid = _panid; - if (channel) - *channel = _radio_channel; - if (tx_power) - *tx_power = _radio_tx_power; - - if (iter) - g_variant_iter_free(iter); - g_variant_unref(variant); - - return result; -} - -int zbl_get_controller_mac_address(ieee_addr addr64) -{ - GVariant *variant = NULL; - GVariantIter *iter = NULL; - GError *dbus_err = NULL; - - char value; - int j = 0; - int result = ZIGBEE_ERROR_NONE; - - DBG("zbl_get_controller_mac_address()"); - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(service_gproxy, "get_mac", - NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get_mac [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - g_variant_get(variant, "(ia(y))", &result, &iter); - - while (g_variant_iter_loop(iter, "(y)", &value)) { - addr64[j] = value; - j++; - } - - DBG("IEEE ADDR 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X, Ret=%d ", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], - addr64[6], addr64[7], result); - - if (iter) - g_variant_iter_free(iter); - g_variant_unref(variant); - - return result; -} - -int zbl_get_cluster_list(ieee_addr eui64, unsigned char endpoint, - unsigned char *in_cluster_count, unsigned short in_cluster_list[], - unsigned char *out_cluster_count, unsigned short out_cluster_list[]) -{ - GVariant *variant = NULL; - GVariantBuilder *mac_builder = NULL; - GVariant *mac_variant = NULL; - GVariantIter *in_cluster_iter = NULL; - GVariantIter *out_cluster_iter = NULL; - GError *dbus_err = NULL; - unsigned short cluster = 0; - int i = 0; - int result = 0; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - g_variant_builder_add(mac_builder, "(y)", eui64[7]); - g_variant_builder_add(mac_builder, "(y)", eui64[6]); - g_variant_builder_add(mac_builder, "(y)", eui64[5]); - g_variant_builder_add(mac_builder, "(y)", eui64[4]); - g_variant_builder_add(mac_builder, "(y)", eui64[3]); - g_variant_builder_add(mac_builder, "(y)", eui64[2]); - g_variant_builder_add(mac_builder, "(y)", eui64[1]); - g_variant_builder_add(mac_builder, "(y)", eui64[0]); - mac_variant = g_variant_builder_end(mac_builder); - g_variant_builder_unref(mac_builder); - - variant = g_dbus_proxy_call_sync(service_gproxy, "get_cluster_list", - g_variant_new("(@a(y)y)", mac_variant, endpoint), G_DBUS_CALL_FLAGS_NONE, - -1, NULL, &dbus_err); - - if (variant) { - g_variant_get(variant, "(iaqaq)", &result, &in_cluster_iter, &out_cluster_iter); - DBG("ret = [0x%x]", result); - - /* In clusters */ - while (g_variant_iter_loop(in_cluster_iter, "q", &cluster)) { - DBG("In Cluster 0x%04X", cluster); - in_cluster_list[i++] = cluster; - } - *in_cluster_count = i; - if (0 == i) - ERR("No In Clusters for Endpoint %0X", endpoint); - - /* Out clusters */ - i = 0; - while (g_variant_iter_loop(out_cluster_iter, "q", &cluster)) { - DBG("Out Cluster 0x%04X", cluster); - out_cluster_list[i++] = cluster; - } - *out_cluster_count = i; - if (0 == i) - ERR("No Out Clusters for Endpoint %0X", endpoint); - - if (NULL != in_cluster_iter) - g_variant_iter_free(in_cluster_iter); - if (NULL != out_cluster_iter) - g_variant_iter_free(out_cluster_iter); - g_variant_unref(variant); - } else { - ERR("No In/Out Clusters for Endpoint %0X [%s]", endpoint, dbus_err->message); - g_error_free(dbus_err); - *in_cluster_count = 0; - *out_cluster_count = 0; - } - - return ZIGBEE_ERROR_NONE; -} - -int zbl_get_endpoint_list(ieee_addr eui64, unsigned char *count, unsigned char list[]) -{ - GVariant *variant = NULL; - GVariantBuilder *mac_builder = NULL; - GVariant *mac_variant = NULL; - GVariantIter *iter = NULL; - GError *dbus_err = NULL; - unsigned char endpoint; - int i = 0; - int result = ZIGBEE_ERROR_NONE; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - g_variant_builder_add(mac_builder, "(y)", eui64[7]); - g_variant_builder_add(mac_builder, "(y)", eui64[6]); - g_variant_builder_add(mac_builder, "(y)", eui64[5]); - g_variant_builder_add(mac_builder, "(y)", eui64[4]); - g_variant_builder_add(mac_builder, "(y)", eui64[3]); - g_variant_builder_add(mac_builder, "(y)", eui64[2]); - g_variant_builder_add(mac_builder, "(y)", eui64[1]); - g_variant_builder_add(mac_builder, "(y)", eui64[0]); - mac_variant = g_variant_builder_end(mac_builder); - g_variant_builder_unref(mac_builder); - - variant = g_dbus_proxy_call_sync(service_gproxy, "get_endpoint_list", - g_variant_new("(@a(y))", mac_variant), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (variant) { - g_variant_get(variant, "(ia(y))", &result, &iter); - DBG("ret = [0x%x]", result); - - while (g_variant_iter_loop(iter, "(y)", &endpoint)) { - DBG("Endpoint 0x%X", endpoint); - list[i++] = endpoint; - } - if (i > 0) { - *count = i; - DBG("Endpoint Count %d", i); - } else { - ERR("No Endpoints"); - *count = 0; - } - if (NULL != iter) - g_variant_iter_free(iter); - g_variant_unref(variant); - - } else { - ERR("NULL Variant"); - ERR("No Endpoints"); - ERR("[%s]", dbus_err->message); - g_error_free(dbus_err); - *count = 0; - } - - return ZIGBEE_ERROR_NONE; -} - -int zbl_api_get_node_type(ieee_addr eui64, unsigned char *node_type) -{ - GVariant *variant = NULL; - GVariantBuilder *mac_builder = NULL; - int result = ZIGBEE_ERROR_NONE; - GVariant *mac_variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - g_variant_builder_add(mac_builder, "(y)", eui64[7]); - g_variant_builder_add(mac_builder, "(y)", eui64[6]); - g_variant_builder_add(mac_builder, "(y)", eui64[5]); - g_variant_builder_add(mac_builder, "(y)", eui64[4]); - g_variant_builder_add(mac_builder, "(y)", eui64[3]); - g_variant_builder_add(mac_builder, "(y)", eui64[2]); - g_variant_builder_add(mac_builder, "(y)", eui64[1]); - g_variant_builder_add(mac_builder, "(y)", eui64[0]); - mac_variant = g_variant_builder_end(mac_builder); - g_variant_builder_unref(mac_builder); - - variant = g_dbus_proxy_call_sync(service_gproxy, "get_node_type", - g_variant_new("(@a(y))", mac_variant), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'get_node_type' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_get_all_device_info(zb_end_device_info_h **dev_list, unsigned char* num) -{ - int i = 0; - int j = 0; - int k = 0; - struct zb_end_device_info_s **list; - GVariant *variant = NULL; - GVariantIter *iter = NULL; - GVariantIter *mac_iter = NULL; - GVariantIter *endpoint_iter = NULL; - GError *dbus_err = NULL; - int result = 0; - unsigned short node_id; - unsigned char node_type; - unsigned char node_mac_address[8] = {0x00}; - unsigned char endpoint_cnt = 0; - unsigned char value; - unsigned char value_endpoint; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - /* check the format string when there are no input args */ - variant = g_dbus_proxy_call_sync(service_gproxy, "get_device_info", - NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (variant) { - g_variant_get(variant, "(ia(qyayyay))", &result, &iter); - DBG("ret = [0x%x]", result); - - list = calloc(MAX_DEVICE_LIST+1, sizeof(zb_end_device_info_h)); - RETV_IF(NULL == list, ZIGBEE_ERROR_OUT_OF_MEMORY); - for (i = 0; i < MAX_DEVICE_LIST && list; i++) { - list[i] = calloc(1, sizeof(struct zb_end_device_info_s)); - if (NULL == list[i]) { - for (j = 0; j < i; j++) - free(list[j]); - free(list); - g_variant_unref(variant); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - } - - i = 0; - while (g_variant_iter_loop(iter, "(qyayyay)", &node_id, &node_type, &mac_iter, - &endpoint_cnt, &endpoint_iter)) { - j = 0; - k = 0; - /* Get Network Address */ - list[i]->addr16 = node_id; - DBG("Node ID: 0x%04X", node_id); - /* Get Node Type */ - list[i]->node_type = node_type; - DBG("Node Type : 0x%02X", node_type); - /* Get End-Point count */ - list[i]->num_of_ep = endpoint_cnt; - DBG("Endpoint Count: 0x%X", endpoint_cnt); - /* Get End-Point list */ - list[i]->num_of_ep = endpoint_cnt; - while (g_variant_iter_loop(endpoint_iter, "y", &value_endpoint)) { - list[i]->ep[k] = value_endpoint; - DBG("Endpoint : %d", value_endpoint); - k++; - } - /* Get IEEE address */ - while (g_variant_iter_loop(mac_iter, "y", &value)) { - node_mac_address[j] = value; - j++; - } - memcpy(list[i]->addr64, node_mac_address, sizeof(ieee_addr)); - DBG("Node MAC Addr : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - node_mac_address[0], node_mac_address[1], node_mac_address[2], - node_mac_address[3], node_mac_address[4], node_mac_address[5], - node_mac_address[6], node_mac_address[7]); - i++; - - } - if (0 == i) - ERR("No attached nodes"); - - *num = i; - *dev_list = list; - if (NULL != iter) - g_variant_iter_free(iter); - g_variant_unref(variant); - } else { - ERR("NULL Variant [%s]", dbus_err->message); - ERR("No attached nodes"); - g_error_free(dbus_err); - *num = 0; - } - - return ZIGBEE_ERROR_NONE; -} - -int zbl_coex_start(unsigned char channel) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(service_gproxy, "coex_start", g_variant_new("(y)", channel), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'coex_start' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_coex_stop(void) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - DBG("zbl_coex_stop()"); - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(service_gproxy, "coex_stop", NULL, - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'coex_stop' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_form_network(zigbee_h handle, zb_form_network_cb cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(service_gproxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_SERVICE_INTERFACE, "form_network_done", ZIGBEE_SERVICE_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_SERVICE_FORM_NETWORK; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(service_gproxy, "form_network", NULL, - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'form_network' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_disable_network(zigbee_h handle, zb_disable_network_cb cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_disable_network()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(service_gproxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_SERVICE_INTERFACE, "disable_network_done", ZIGBEE_SERVICE_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_SERVICE_DISABLE_NETWORK; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(service_gproxy, "leave_network", NULL, - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'leave_network' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_leave_device(ieee_addr addr64, bool remove_children, bool rejoin) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - GVariantBuilder *mac_builder = NULL; - GVariant* mac_variant = NULL; - unsigned char _remove_children = (remove_children) ? 1 : 0; - unsigned char _rejoin = (rejoin) ? 1 : 0; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("IEEE Address = %X:%X:%X:%X:%X:%X:%X:%X", - addr64[0], addr64[1], addr64[2], addr64[3], - addr64[4], addr64[5], addr64[6], addr64[7]); - - mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - g_variant_builder_add(mac_builder, "(y)", addr64[7]); - g_variant_builder_add(mac_builder, "(y)", addr64[6]); - g_variant_builder_add(mac_builder, "(y)", addr64[5]); - g_variant_builder_add(mac_builder, "(y)", addr64[4]); - g_variant_builder_add(mac_builder, "(y)", addr64[3]); - g_variant_builder_add(mac_builder, "(y)", addr64[2]); - g_variant_builder_add(mac_builder, "(y)", addr64[1]); - g_variant_builder_add(mac_builder, "(y)", addr64[0]); - mac_variant = g_variant_builder_end(mac_builder); - g_variant_builder_unref(mac_builder); - - variant = g_dbus_proxy_call_sync(service_gproxy, "leave_request", - g_variant_new("(@a(y)yy)", mac_variant, _remove_children, _rejoin), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'leave_request' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_permit_join(unsigned char duration, bool broadcast) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(service_gproxy, "permit_join", - g_variant_new("(ib)", duration, broadcast), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'permit_join' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_nwk_addr_req(zigbee_h handle, ieee_addr addr64, unsigned char request_type, - unsigned char start_idx, zb_zdo_addr_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - GVariantBuilder *mac_builder = NULL; - GVariant* mac_variant = NULL; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG(" zbl_nwk_addr_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "nwk_addr_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_NWK_ADDR_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - g_variant_builder_add(mac_builder, "(y)", addr64[7]); - g_variant_builder_add(mac_builder, "(y)", addr64[6]); - g_variant_builder_add(mac_builder, "(y)", addr64[5]); - g_variant_builder_add(mac_builder, "(y)", addr64[4]); - g_variant_builder_add(mac_builder, "(y)", addr64[3]); - g_variant_builder_add(mac_builder, "(y)", addr64[2]); - g_variant_builder_add(mac_builder, "(y)", addr64[1]); - g_variant_builder_add(mac_builder, "(y)", addr64[0]); - mac_variant = g_variant_builder_end(mac_builder); - g_variant_builder_unref(mac_builder); - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "nwk_addr_req", - g_variant_new("(@a(y)yy)", mac_variant, request_type, start_idx), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'nwk_addr_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ieee_addr_req(zigbee_h handle, nwk_addr addr16, zb_zdo_addr_rsp cb, - void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_ieee_addr_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "nwk_addr_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_NWK_ADDR_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "ieee_addr_req", g_variant_new("(q)", addr16), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'ieee_addr_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_active_ep(zigbee_h handle, nwk_addr addr16, zb_zdo_active_ep_rsp cb, - void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_active_ep()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "active_ep_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_ACTIVE_EP_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "active_ep_req", - g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'active_ep_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_simple_desc_req(zigbee_h handle, nwk_addr addr16, unsigned char ep, - zb_zdo_simple_desc_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_simple_desc_req() : [%X]", addr16); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "simple_desc_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_SIMPLE_DESC_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "simple_desc_req", - g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'simple_desc_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -#ifdef ZB_SUPPORT_PRIORITY_5 -int zbl_extended_simple_desc_req(zigbee_h handle, nwk_addr addr16, - unsigned char start_idx, zb_zdo_extended_simple_desc_rsp cb, void *user_data) -{ - return ZIGBEE_ERROR_NOT_SUPPORTED; -} -#endif /* ZB_SUPPORT_PRIORITY_5 */ - -int zbl_match_desc_req(zigbee_h handle, nwk_addr addr16, - unsigned short profile_id, unsigned char num_in_clusters, - unsigned short *in_clusters, unsigned char num_out_clusters, - unsigned short *out_clusters, zb_zdo_match_desc_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - int i; - GVariantBuilder *incl_builder = NULL; - GVariant* incl_variant = NULL; - GVariantBuilder *outcl_builder = NULL; - GVariant* outcl_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_match_desc_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "matched_descriptor_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_MATCHED_DESCRIPTOR_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - incl_builder = g_variant_builder_new(G_VARIANT_TYPE("aq")); - for (i = 0; i < num_in_clusters; i++) - g_variant_builder_add(incl_builder, "q", in_clusters[i]); - - outcl_builder = g_variant_builder_new(G_VARIANT_TYPE("aq")); - for (i = 0; i < num_out_clusters; i++) - g_variant_builder_add(outcl_builder, "q", out_clusters[i]); - - incl_variant = g_variant_builder_end(incl_builder); - outcl_variant = g_variant_builder_end(outcl_builder); - g_variant_builder_unref(incl_builder); - g_variant_builder_unref(outcl_builder); - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "matched_descriptor_req", - g_variant_new("(qqy@aqy@aq)", addr16, profile_id, num_in_clusters, - incl_variant, num_out_clusters, outcl_variant), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'matched_descriptor_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_node_desc_req(nwk_addr addr16, zb_zdo_node_desc_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_node_desc_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "node_desc_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_NODE_DESC_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "node_desc_req", - g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'node_desc_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_power_desc_req(nwk_addr addr16, zb_zdo_power_desc_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "power_desc_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_POWER_DESC_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "power_desc_req", - g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'power_desc_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_complex_desc_req(nwk_addr addr16, zb_zdo_complex_desc_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "complex_desc_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_COMPLEX_DESC_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "complex_desc_req", - g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'complex_desc_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_user_desc_req(nwk_addr addr16, zb_zdo_user_desc_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "user_desc_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_USER_DESC_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "user_desc_req", - g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'user_desc_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -#define MAX_USER_DESC_SIZE 0x10 -#define USER_DESC_COMMAND_SIZE 20 - -int zbl_user_desc_set(zigbee_h handle, nwk_addr addr16, unsigned char len, - unsigned char *user_desc, zb_zdo_user_desc_conf cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - unsigned char j = 0x00; - GVariantBuilder *user_desc_builder = NULL; - GVariant *user_desc_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - RETVM_IF(len > MAX_USER_DESC_SIZE || len < 0x00, ZIGBEE_ERROR_INVALID_PARAMETER, - "invalid length=%d", len); - RETVM_IF(NULL == user_data, ZIGBEE_ERROR_INVALID_PARAMETER, "invalid data"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "user_desc_confirm", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_USER_DESC_SET_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - user_desc_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - for (j = 0; j < len; j++) - g_variant_builder_add(user_desc_builder, "(y)", user_desc[j]); - - user_desc_variant = g_variant_builder_end(user_desc_builder); - g_variant_builder_unref(user_desc_builder); - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "user_desc_set_req", - g_variant_new("(qy@a(y))", addr16, len, user_desc_variant), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'user_desc_set_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_device_annce(zigbee_h handle, nwk_addr addr16, ieee_addr addr64, - unsigned char capability) -{ - int result = ZIGBEE_ERROR_NONE; - GError *dbus_err = NULL; - GVariant *variant = NULL; - - GVariantBuilder *mac_builder = NULL; - GVariant* mac_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - g_variant_builder_add(mac_builder, "(y)", addr64[7]); - g_variant_builder_add(mac_builder, "(y)", addr64[6]); - g_variant_builder_add(mac_builder, "(y)", addr64[5]); - g_variant_builder_add(mac_builder, "(y)", addr64[4]); - g_variant_builder_add(mac_builder, "(y)", addr64[3]); - g_variant_builder_add(mac_builder, "(y)", addr64[2]); - g_variant_builder_add(mac_builder, "(y)", addr64[1]); - g_variant_builder_add(mac_builder, "(y)", addr64[0]); - mac_variant = g_variant_builder_end(mac_builder); - g_variant_builder_unref(mac_builder); - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "device_announce", - g_variant_new("(q@a(y)y)", addr16, mac_variant, capability), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'device_announce' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_bind_req(nwk_addr dst_addr16, ieee_addr src_addr64, - unsigned char src_ep, unsigned short cluster_id, ieee_addr dst_addr64, - unsigned char type, nwk_addr group_addr, unsigned char dst_ep, - zb_zdo_bind_rsp cb, void *user_data) -{ - int i; - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GError *dbus_err = NULL; - GVariant *variant = NULL; - - GVariantBuilder *src_addr64_builder = NULL; - GVariant* src_addr64_variant = NULL; - GVariantBuilder *dst_addr64_builder = NULL; - GVariant* dst_addr64_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_bind_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_zdo_bind_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_bind_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_BIND_INTERFACE, "bind_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_BIND_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - src_addr64_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - - if (src_addr64) { - for (i = sizeof(ieee_addr) - 1 ; i >= 0; i--) - g_variant_builder_add(src_addr64_builder, "(y)", src_addr64[i]); - } - src_addr64_variant = g_variant_builder_end(src_addr64_builder); - g_variant_builder_unref(src_addr64_builder); - - dst_addr64_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - if (dst_addr64) { - for (i = sizeof(ieee_addr) - 1 ; i >= 0; i--) - g_variant_builder_add(dst_addr64_builder, "(y)", dst_addr64[i]); - } - dst_addr64_variant = g_variant_builder_end(dst_addr64_builder); - g_variant_builder_unref(dst_addr64_builder); - - variant = g_dbus_proxy_call_sync(zdo_bind_proxy, "bind_req", - g_variant_new("(q@a(y)yq@a(y)yqy)", dst_addr16, src_addr64_variant, src_ep, - cluster_id, dst_addr64_variant, type, group_addr, dst_ep), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'bind_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_unbind_req(nwk_addr dst_addr16, - ieee_addr src_addr64, unsigned char src_ep, unsigned short cluster_id, - ieee_addr dst_addr64, unsigned char type, nwk_addr group_addr, - unsigned char dst_ep, zb_zdo_unbind_rsp cb, void *user_data) -{ - int i; - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GError *dbus_err = NULL; - GVariant *variant = NULL; - - GVariantBuilder *src_addr64_builder = NULL; - GVariant* src_addr64_variant = NULL; - GVariantBuilder *dst_addr64_builder = NULL; - GVariant* dst_addr64_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_bind_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_zdo_unbind_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_bind_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_BIND_INTERFACE, "unbind_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_UNBIND_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - src_addr64_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - if (src_addr64) { - for (i = sizeof(ieee_addr) - 1 ; i >= 0; i--) - g_variant_builder_add(src_addr64_builder, "(y)", src_addr64[i]); - } - src_addr64_variant = g_variant_builder_end(src_addr64_builder); - g_variant_builder_unref(src_addr64_builder); - - dst_addr64_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - if (dst_addr64) { - for (i = sizeof(ieee_addr) - 1 ; i >= 0; i--) - g_variant_builder_add(dst_addr64_builder, "(y)", dst_addr64[i]); - } - dst_addr64_variant = g_variant_builder_end(dst_addr64_builder); - g_variant_builder_unref(dst_addr64_builder); - - variant = g_dbus_proxy_call_sync(zdo_bind_proxy, "unbind_req", - g_variant_new("(q@a(y)yq@a(y)yqy)", dst_addr16, src_addr64_variant, src_ep, - cluster_id, dst_addr64_variant, type, group_addr, dst_ep), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'unbind_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_mgmt_nwk_disc_req(nwk_addr addr16, unsigned int scan_channels, - unsigned char scan_duration, unsigned char scan_count, unsigned char start_idx, - zb_zdo_mgmt_nwk_disc_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_mgmt_nwk_disc_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_nwk_disc_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, - container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_MGMT_NWK_DISC_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_nwk_disc_req", - g_variant_new("(quyqy)", addr16, scan_channels, scan_duration, scan_count, start_idx), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'mgmt_nwk_disc_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_mgmt_nwk_update_req(unsigned int scan_channels, unsigned char scan_duration, - unsigned char scan_count, unsigned char nwk_update_id, nwk_addr nwk_manager_addr) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_mgmt_nwk_update_req()"); - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_nwk_update_req", - g_variant_new("(quyyy)", nwk_manager_addr, scan_channels, scan_duration, - scan_count, nwk_update_id), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'mgmt_nwk_update_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_mgmt_lqi_req(nwk_addr addr16, unsigned char start_idx, - zb_zdo_mgmt_lqi_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_mgmt_lqi_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_lqi_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_MGMT_LQI_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_lqi_req", - g_variant_new("(qy)", addr16, start_idx), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'mgmt_lqi_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_mgmt_rtg_req(nwk_addr addr16, unsigned char start_idx, - zb_zdo_mgmt_rtg_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_mgmt_rtg_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_rtg_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_MGMT_RTG_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_rtg_req", - g_variant_new("(qy)", addr16, start_idx), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'mgmt_rtg_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_mgmt_bind_req(nwk_addr addr16, unsigned char start_idx, - zb_zdo_mgmt_bind_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_mgmt_bind_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_bind_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_MGMT_BIND_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_bind_req", - g_variant_new("(qy)", addr16, start_idx), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'mgmt_bind_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_mgmt_leave_device(ieee_addr addr64, unsigned char remove_children, - unsigned rejoin, zb_zdo_mgmt_leave_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - GVariantBuilder *mac_builder = NULL; - GVariant* mac_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_leave_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_MGMT_LEAVE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - g_variant_builder_add(mac_builder, "(y)", addr64[7]); - g_variant_builder_add(mac_builder, "(y)", addr64[6]); - g_variant_builder_add(mac_builder, "(y)", addr64[5]); - g_variant_builder_add(mac_builder, "(y)", addr64[4]); - g_variant_builder_add(mac_builder, "(y)", addr64[3]); - g_variant_builder_add(mac_builder, "(y)", addr64[2]); - g_variant_builder_add(mac_builder, "(y)", addr64[1]); - g_variant_builder_add(mac_builder, "(y)", addr64[0]); - mac_variant = g_variant_builder_end(mac_builder); - g_variant_builder_unref(mac_builder); - - variant = g_dbus_proxy_call_sync(service_gproxy, "leave_request", - g_variant_new("(@a(y)yy)", mac_variant, remove_children, rejoin), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'leave_request' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_mgmt_permit_joining_req(nwk_addr addr16, unsigned char duration, - unsigned char tc_significance, zb_zdo_mgmt_permit_joining_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zdo_dev_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_permit_join_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, - container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZDO_MGMT_PERMIT_JOIN_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_permit_join_req", - g_variant_new("(qyy)", addr16, duration, tc_significance), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'mgmt_permit_join_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_aps_send(nwk_addr addr16, unsigned char aps_frame_ctl, unsigned char src_ep, - unsigned char dst_ep, unsigned short cluster_id, unsigned short profile_id, - unsigned char zcl_frame_ctl, unsigned short mfg_code, unsigned char cmd_id, - unsigned short payload_len, unsigned char *payload, zb_aps_send_rsp cb, void *user_data) -{ - int sub_id, to, i; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - GVariantBuilder *payload_builder = NULL; - GVariant *payload_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == custom_gproxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(custom_gproxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_CUSTOM_INTERFACE, "aps_send_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_CUSTOM_APS_SEND_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - payload_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - if (payload_len > 0) { - for (i = payload_len - 1; i >= 0 ; i--) - g_variant_builder_add(payload_builder, "(y)", payload[i]); - } - payload_variant = g_variant_builder_end(payload_builder); - g_variant_builder_unref(payload_builder); - - variant = g_dbus_proxy_call_sync(custom_gproxy, "aps_send", - g_variant_new("(qyyyqqyqyq@a(y))", addr16, aps_frame_ctl, src_ep, dst_ep, cluster_id, - profile_id, zcl_frame_ctl, mfg_code, cmd_id, payload_len, payload_variant), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'aps_send' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_zcl_send(nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned short cluster_id, unsigned char zcl_frame_ctl, unsigned char cmd, - unsigned short payload_len, unsigned char *payload, - zb_zcl_send_rsp cb, void *user_data) -{ - int sub_id, to, i; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - GVariantBuilder *payload_builder = NULL; - GVariant *payload_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == custom_gproxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(custom_gproxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_CUSTOM_INTERFACE, "zcl_send_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_CUSTOM_ZCL_SEND_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - payload_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - if (payload_len > 0) { - for (i = payload_len - 1; i >= 0 ; i--) - g_variant_builder_add(payload_builder, "(y)", payload[i]); - } - payload_variant = g_variant_builder_end(payload_builder); - g_variant_builder_unref(payload_builder); - - variant = g_dbus_proxy_call_sync(custom_gproxy, "zcl_send", - g_variant_new("(qyyqyyq@a(y))", addr16, src_ep, dst_ep, cluster_id, zcl_frame_ctl, - cmd, payload_len, payload_variant), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'zcl_send' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_send_to_local(unsigned short length, unsigned char *data, - zb_send_to_local_rsp cb, void *user_data) -{ - int sub_id, to, i; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - GVariantBuilder *payload_builder = NULL; - GVariant *payload_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == custom_gproxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(custom_gproxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_CUSTOM_INTERFACE, "send_to_local_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_CUSTOM_LOCAL_SEND_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - payload_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - if (length > 0) { - for (i = length - 1; i >= 0 ; i--) - g_variant_builder_add(payload_builder, "(y)", data[i]); - } - payload_variant = g_variant_builder_end(payload_builder); - g_variant_builder_unref(payload_builder); - - variant = g_dbus_proxy_call_sync(custom_gproxy, "send_to_local", - g_variant_new("(q@a(y))", length, payload_variant), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'send_to_local' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_read_attr_req(zigbee_h handle, unsigned short addr16, unsigned char dest_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short *attribute_ids, - int attribute_ids_len, zb_zcl_global_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - int i = 0; - unsigned char *t; - GVariant *attr_variant = NULL; - GVariantBuilder *attr_builder = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_read_attr_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "read_attributes_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_READ_ATTRIBUTE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dest_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_READ_ATTRIBUTES_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - t = (unsigned char *)attribute_ids; - attr_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - for (i = 0; i < attribute_ids_len*sizeof(unsigned short); i++) - g_variant_builder_add(attr_builder, "(y)", t[i]); - attr_variant = g_variant_builder_end(attr_builder); - g_variant_builder_unref(attr_builder); - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "read_attributes_req", - g_variant_new("(@a(y)iqqyy)", attr_variant, attribute_ids_len, - addr16, cluster_id, zcl_frame_ctl, dest_ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'read_attributes_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, write_attr_record_h *records, - int records_len, zb_zcl_global_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_write_attr_req()"); - - GVariantBuilder *rec_builder = NULL; - GVariant *rec_variant = NULL; - - int i = 0; - int j = 0; - - char dSize[3] = {'\0', '\0'}; - int writeAttributeIndex = 0; - int size_of_allo = 0; - - unsigned char *isString = NULL; - unsigned short *dataSize = NULL; - unsigned char *writeAttribute = NULL; - - isString = calloc(records_len + 1, sizeof(unsigned char)); - RETVM_IF(NULL == isString, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - dataSize = calloc(records_len + 1, sizeof(unsigned short)); - if (NULL == dataSize) { - ERR("calloc() Fail(%d)", errno); - free(isString); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - - DBG("Records Length %d", records_len); - - while (j < records_len) { - dataSize[j] = zb_get_data_size((*records)[j].type); - if (0xff != dataSize[j]) { - isString[j] = 0; - size_of_allo = size_of_allo + (dataSize[j] + 3); - } else { - if ((*records)[j].value) { - if ((*records)[j].type == ZB_ZCL_CHRACTER_STRING - || (*records)[j].type == ZB_ZCL_OCTAT_STRING) { - isString[j] = 1; - dataSize[j] = (*records)[j].value[0]; - size_of_allo = size_of_allo + (dataSize[j] + 3 + 1); - } else if ((*records)[j].type == ZB_ZCL_LONG_OCTAT_STRING - || (*records)[j].type == ZB_ZCL_LONG_CHRACTER_STRING) { - isString[j] = 2; - dSize[0] = (*records)[j].value[0]; - dSize[1] = (*records)[j].value[1]; - dataSize[j] = dSize[1]; - dataSize[j] = (dataSize[j] << 8) | dSize[0]; - size_of_allo = size_of_allo + (dataSize[j] + 3 + 2); - } - } else - ERR("Data is not present"); - } - j++; - } - DBG("size_of_allo Length %d", size_of_allo); - - writeAttribute = calloc(size_of_allo + 1, sizeof(unsigned char)); - if (NULL == writeAttribute) { - ERR("Couldn't Allocate Memory"); - free(isString); - free(dataSize); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - - j = 0; - while (j < records_len && writeAttributeIndex < size_of_allo) { - writeAttribute[writeAttributeIndex++] = ((*records)[j].id) & 0xff; - writeAttribute[writeAttributeIndex++] = (((*records)[j].id) >> 8) & 0xff; - writeAttribute[writeAttributeIndex++] = (*records)[j].type; - for (i = 0; i < (dataSize[j] + isString[j]); i++) { - writeAttribute[writeAttributeIndex++] = (*records)[j].value[i]; - DBG("0x%02X", (*records)[j].value[i]); - } - j++; - } - - rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - DBG(" "); - for (i = 0; i < writeAttributeIndex ; i++) { - DBG("0x%02X", writeAttribute[i]); - g_variant_builder_add(rec_builder, "(y)", writeAttribute[i]); - } - - rec_variant = g_variant_builder_end(rec_builder); - g_variant_builder_unref(rec_builder); - - container = calloc(1, sizeof(zbl_req_cb_s)); - if (NULL == container) { - ERR("calloc() Fail(%d)", errno); - free(isString); - free(dataSize); - free(writeAttribute); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "write_attributes_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, - container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(isString); - free(dataSize); - free(container); - free(writeAttribute); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - free(isString); - free(dataSize); - free(writeAttribute); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dst_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_WRITE_ATTRIBUTES_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "write_attributes_req", - g_variant_new("(@a(y)iqqyyy)", rec_variant, writeAttributeIndex, addr16, - cluster_id, zcl_frame_ctl, src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, - to, NULL, &dbus_err); - - free(isString); - free(dataSize); - free(writeAttribute); - - if (!variant) { - ERR("Failed to get 'write_attributes_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_wattr_undivided_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - write_attr_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_wattr_undivided_req()"); - - GVariantBuilder *rec_builder = NULL; - GVariant *rec_variant = NULL; - - int i = 0; - int j = 0; - - char dSize[3] = {'\0', '\0'}; - int writeAttributeIndex = 0; - int size_of_allo = 0; - - unsigned char *isString = NULL; - unsigned short *dataSize = NULL; - unsigned char *writeAttribute = NULL; - - isString = calloc(records_len + 1, sizeof(unsigned char)); - RETVM_IF(NULL == isString, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - dataSize = calloc(records_len + 1, sizeof(unsigned short)); - if (NULL == dataSize) { - ERR("calloc() Fail(%d)", errno); - free(isString); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - - DBG("Records Length %d", records_len); - - while (j < records_len) { - dataSize[j] = zb_get_data_size((*records)[j].type); - if (0xff != dataSize[j]) { - isString[j] = 0; - size_of_allo = size_of_allo + (dataSize[j] + 3); - } else { - if ((*records)[j].value) { - if ((*records)[j].type == ZB_ZCL_CHRACTER_STRING - || (*records)[j].type == ZB_ZCL_OCTAT_STRING) { - isString[j] = 1; - dataSize[j] = (*records)[j].value[0]; - size_of_allo = size_of_allo + (dataSize[j] + 3 + 1); - } else if ((*records)[j].type == ZB_ZCL_LONG_OCTAT_STRING - || (*records)[j].type == ZB_ZCL_LONG_CHRACTER_STRING) { - isString[j] = 2; - dSize[0] = (*records)[j].value[0]; - dSize[1] = (*records)[j].value[1]; - dataSize[j] = dSize[1]; - dataSize[j] = (dataSize[j] << 8) | dSize[0]; - size_of_allo = size_of_allo + (dataSize[j] + 3 + 2); - } - } else - ERR("Data is not present"); - } - j++; - } - DBG("size_of_allo Length %d", size_of_allo); - - writeAttribute = calloc(size_of_allo + 1, sizeof(unsigned char)); - if (NULL == writeAttribute) { - ERR("Couldn't Allocate Memory"); - free(isString); - free(dataSize); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - - j = 0; - while (j < records_len && writeAttributeIndex < size_of_allo) { - writeAttribute[writeAttributeIndex++] = ((*records)[j].id) & 0xff; - writeAttribute[writeAttributeIndex++] = (((*records)[j].id) >> 8) & 0xff; - writeAttribute[writeAttributeIndex++] = (*records)[j].type; - for (i = 0; i < (dataSize[j] + isString[j]); i++) { - writeAttribute[writeAttributeIndex++] = (*records)[j].value[i]; - DBG("0x%02X", (*records)[j].value[i]); - } - j++; - } - - rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - DBG(" "); - for (i = 0; i < writeAttributeIndex ; i++) { - DBG("0x%02X", writeAttribute[i]); - g_variant_builder_add(rec_builder, "(y)", writeAttribute[i]); - } - - rec_variant = g_variant_builder_end(rec_builder); - g_variant_builder_unref(rec_builder); - - container = calloc(1, sizeof(zbl_req_cb_s)); - if (NULL == container) { - ERR("calloc() Fail(%d)", errno); - free(isString); - free(dataSize); - free(writeAttribute); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "write_attributes_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, - container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(isString); - free(dataSize); - free(container); - free(writeAttribute); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - free(isString); - free(dataSize); - free(writeAttribute); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dst_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_WRITE_ATTRIBUTES_UNDIVIDED_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "write_attributes_undivided_req", - g_variant_new("(@a(y)iqqyyy)", rec_variant, writeAttributeIndex, addr16, - cluster_id, zcl_frame_ctl, src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, - to, NULL, &dbus_err); - - free(isString); - free(dataSize); - free(writeAttribute); - - if (!variant) { - ERR("Failed to get 'write_attributes_undivided_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_wattr_req_no_rsp(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - write_attr_record_h *records, int records_len) -{ - int result = ZIGBEE_ERROR_NONE; - GError *dbus_err = NULL; - GVariant *variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_wattr_req_no_rsp()"); - - GVariantBuilder *rec_builder = NULL; - GVariant *rec_variant = NULL; - - int i = 0; - int j = 0; - - char dSize[3] = {'\0', '\0'}; - int writeAttributeIndex = 0; - int size_of_allo = 0; - - unsigned char *isString = NULL; - unsigned short *dataSize = NULL; - unsigned char *writeAttribute = NULL; - - isString = calloc(records_len + 1, sizeof(unsigned char)); - RETVM_IF(NULL == isString, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - dataSize = calloc(records_len + 1, sizeof(unsigned short)); - if (NULL == dataSize) { - ERR("calloc() Fail(%d)", errno); - free(isString); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - - DBG("Records Length %d", records_len); - - while (j < records_len) { - dataSize[j] = zb_get_data_size((*records)[j].type); - if (0xff != dataSize[j]) { - isString[j] = 0; - size_of_allo = size_of_allo + (dataSize[j] + 3); - } else { - if ((*records)[j].value) { - if ((*records)[j].type == ZB_ZCL_CHRACTER_STRING - || (*records)[j].type == ZB_ZCL_OCTAT_STRING) { - isString[j] = 1; - dataSize[j] = (*records)[j].value[0]; - size_of_allo = size_of_allo + (dataSize[j] + 3 + 1); - } else if ((*records)[j].type == ZB_ZCL_LONG_OCTAT_STRING - || (*records)[j].type == ZB_ZCL_LONG_CHRACTER_STRING) { - isString[j] = 2; - dSize[0] = (*records)[j].value[0]; - dSize[1] = (*records)[j].value[1]; - dataSize[j] = dSize[1]; - dataSize[j] = (dataSize[j] << 8) | dSize[0]; - size_of_allo = size_of_allo + (dataSize[j] + 3 + 2); - } - } else - ERR("Data is not present"); - } - j++; - } - DBG("size_of_allo Length %d", size_of_allo); - - writeAttribute = calloc(size_of_allo + 1, sizeof(unsigned char)); - if (NULL == writeAttribute) { - ERR("Couldn't Allocate Memory"); - free(isString); - free(dataSize); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - - j = 0; - while (j < records_len && writeAttributeIndex < size_of_allo) { - writeAttribute[writeAttributeIndex++] = ((*records)[j].id) & 0xff; - writeAttribute[writeAttributeIndex++] = (((*records)[j].id) >> 8) & 0xff; - writeAttribute[writeAttributeIndex++] = (*records)[j].type; - for (i = 0; i < (dataSize[j] + isString[j]); i++) { - writeAttribute[writeAttributeIndex++] = (*records)[j].value[i]; - DBG("0x%02X", (*records)[j].value[i]); - } - j++; - } - - rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - DBG(" "); - for (i = 0; i < writeAttributeIndex ; i++) { - DBG("0x%02X", writeAttribute[i]); - g_variant_builder_add(rec_builder, "(y)", writeAttribute[i]); - } - - rec_variant = g_variant_builder_end(rec_builder); - g_variant_builder_unref(rec_builder); - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "write_attributes_no_resp", - g_variant_new("(@a(y)iqqyyy)", rec_variant, writeAttributeIndex, addr16, - cluster_id, zcl_frame_ctl, src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, - -1, NULL, &dbus_err); - - free(isString); - free(dataSize); - free(writeAttribute); - - if (!variant) { - ERR("Failed to get 'write_attributes_no_rep' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - report_config_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - int i = 0; - int j = 0; - int len = 0; - int count = 0; - - GVariantBuilder *rec_builder = NULL; - GVariant *rec_variant = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_configure_reporting()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "configure_reporting_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, - container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_CONFIGURE_REPORTING_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dst_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_CONFIGURE_REPORTING_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - for (i = 0; i < records_len; i++) { - g_variant_builder_add(rec_builder, "(y)", (*records)[i].dir); - DBG("dir = 0x%02X", (*records)[i].dir); - count += sizeof((*records)[i].dir); - g_variant_builder_add(rec_builder, "(y)", (*records)[i].id & 0xff); - g_variant_builder_add(rec_builder, "(y)", ((*records)[i].id >> 8) & 0xff); - DBG("id = 0x%04X", (*records)[i].id); - count += sizeof((*records)[i].id); - g_variant_builder_add(rec_builder, "(y)", (*records)[i].type); - count += sizeof((*records)[i].type); - DBG("type = 0x%04X", (*records)[i].type); - g_variant_builder_add(rec_builder, "(y)", (*records)[i].min_i & 0xff); - g_variant_builder_add(rec_builder, "(y)", ((*records)[i].min_i >> 8) & 0xff); - DBG("min_i = 0x%04X", (*records)[i].min_i); - count += sizeof((*records)[i].min_i); - g_variant_builder_add(rec_builder, "(y)", (*records)[i].max_i & 0xff); - g_variant_builder_add(rec_builder, "(y)", ((*records)[i].max_i >> 8) & 0xff); - DBG("max_i = 0x%04X", (*records)[i].max_i); - count += sizeof((*records)[i].max_i); - - len = zb_get_data_size((*records)[i].type); - count += len; - DBG("change length = %d", len); - DBG("payload length = %d", count); - - for (j = 0; j < len && (*records)[i].change+j; j++) { - DBG("records[%d]->value[%d] = %d", i, j, (*records)[i].change[j]); - g_variant_builder_add(rec_builder, "(y)", (*records)[i].change[j]); - } - - } - rec_variant = g_variant_builder_end(rec_builder); - g_variant_builder_unref(rec_builder); - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "configure_reporting_req", - g_variant_new("(@a(y)qqqyyy)", rec_variant, count, addr16, cluster_id, - zcl_frame_ctl, src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'configure_reporting_req' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_read_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - read_report_config_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - int i = 0; - int j = 0; - int size_of_allo = 0; - unsigned short idx = 0; - GVariantBuilder *rec_builder = NULL; - GVariant *rec_variant = NULL; - unsigned char *read_attributes; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_read_configure_reporting()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "read_configure_reporting_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, - container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_READ_CONFIGURE_REPORTING_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dst_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_READ_REPORTING_CONFIGURATION_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - DBG("Records Length %d", records_len); - /** - * According to zcl spec - * Memory needed for the read_reporting_configured_frame. - * 1 byte(direction) + 2 bytes(AttributeId) - * = 3 bytes/variable - */ - while (j < records_len) { - size_of_allo = size_of_allo + 3; - j++; - } - DBG("size_of_allo Length %d", size_of_allo); - - read_attributes = calloc(size_of_allo, sizeof(unsigned char)); - if (NULL == read_attributes) { - ERR("Couldn't Allocate Memory"); - g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); - g_source_remove(container->tid); - container->tid = 0; - free(container); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - j = 0; - while (j < records_len && idx < size_of_allo) { - read_attributes[idx++] = (*records)[j].dir; - read_attributes[idx++] = (*records)[j].id & 0xff; - read_attributes[idx++] = (*records)[j].id >> 8 & 0xff; - DBG("Id copied \n"); - j++; - } - - rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - - for (i = 0; i < idx ; i++) { - DBG("0x%02X", read_attributes[i]); - g_variant_builder_add(rec_builder, "(y)", read_attributes[i]); - } - - rec_variant = g_variant_builder_end(rec_builder); - g_variant_builder_unref(rec_builder); - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "read_configure_reporting", - g_variant_new("(@a(y)qqqyyy)", rec_variant, idx, addr16, cluster_id, zcl_frame_ctl, - src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - free(read_attributes); - - if (!variant) { - ERR("Failed to get 'read_configure_reporting' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_discover_attr_req(zigbee_h handle, unsigned short addr16, unsigned char src_ep, - unsigned char dest_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - unsigned short start_id, unsigned char max_attribute_ids, - zb_zcl_global_discover_attr_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_discover_attr_req()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "discover_attribute_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dest_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "discover_attributes", - g_variant_new("(qyyqqy)", - addr16, dest_ep, zcl_frame_ctl, cluster_id, start_id, max_attribute_ids), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'discover_attributes' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_discover_cmds_gen(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, - unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_discover_attr_gen()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "discover_commands_generated_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_GENERATED_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dst_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_DISCOVER_COMMANDS_GENERATED_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "discover_commands_generated", - g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, cluster_id, - start_command_id, max_command_ids), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'discover_commands_received' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_discover_cmds_recv(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, - unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_discover_cmds_recv()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "discover_commands_received_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_RECEIVED_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dst_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_DISCOVER_COMMANDS_RECEIVED_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "discover_commands_received", - g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, cluster_id, - start_command_id, max_command_ids), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'discover_commands_received' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_discover_attr_ext(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - unsigned short start_id, unsigned char max_attribute_ids, - zb_zcl_global_discover_attr_extended_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - zb_event_global_default_rsp_s *global_req = NULL; -#endif - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_discover_attr_ext()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_global_proxy); - sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, - ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "discover_attributes_extended_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_EXTENDED_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; -#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC - global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); - if (NULL == global_req) { - g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); - g_source_remove(container->tid); - container->tid = 0; - free(container); - ERR("calloc() Fail(%d)", errno); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - global_req->ep = dst_ep; - global_req->cluster_id = cluster_id; - global_req->command_id = ZB_ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID; - - container->global_cmd = global_req; - container->handle = handle; - - /* Register global request information into handle */ - _zbl_register_global_req(handle, container); -#endif - - variant = g_dbus_proxy_call_sync(zcl_global_proxy, "discover_attributes_extended", - g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, cluster_id, start_id, - max_attribute_ids), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'discover_attributes_extended' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_reset_alarm(nwk_addr addr16, unsigned char ep, unsigned char alarm_code, - unsigned short cluster_id) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(alarm_gproxy, "reset_alarm", - g_variant_new("(qyyq)", addr16, ep, alarm_code, cluster_id), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'reset_alarm' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_reset_all_alarm(nwk_addr addr16, unsigned char ep) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(alarm_gproxy, "reset_all_alarm", - g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'reset_all_alarm' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_get_alarm(nwk_addr addr16, unsigned char ep, zb_zcl_alarm_get_alarm_rsp cb, - void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_get_alarm()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(alarm_gproxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_ALARM_INTERFACE, "get_alarm_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_ALARM_GET_ALARM_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(alarm_gproxy, "get_alarm", - g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'get_alarm' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_reset_all_alarm_log(nwk_addr addr16, unsigned char ep) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(alarm_gproxy, "reset_alarm_log", - g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'reset_alarm_log' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_move_to_hue(nwk_addr addr16, unsigned char ep, - unsigned char hue, unsigned char direction, - unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_to_hue", - g_variant_new("(qyyyq)", addr16, ep, hue, direction, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_to_hue' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - - -int zbl_ccontrol_move_hue(nwk_addr addr16, unsigned char ep, - unsigned char move_mode, unsigned char rate) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_hue", - g_variant_new("(qyyy)", addr16, ep, move_mode, rate), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_hue' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_step_hue(nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, - unsigned char transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "step_hue", - g_variant_new("(qyyyy)", addr16, ep, step_mode, step_size, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'step_hue' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_move_to_saturation(nwk_addr addr16, unsigned char ep, - unsigned char saturation, unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_to_saturation", - g_variant_new("(qyyq)", addr16, ep, saturation, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_to_saturation' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_move_saturation(nwk_addr addr16, unsigned char ep, - unsigned char move_mode, unsigned char rate) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_saturation", - g_variant_new("(qyyy)", addr16, ep, move_mode, rate), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_saturation' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_step_saturation(nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, - unsigned char transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "step_saturation", - g_variant_new("(qyyyy)", addr16, ep, step_mode, step_size, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'step_saturation' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_move_to_hue_and_saturation(nwk_addr addr16, unsigned char ep, - unsigned char hue, unsigned char saturation, - unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_to_hue_and_saturation", - g_variant_new("(qyyyq)", addr16, ep, hue, saturation, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_to_hue_and_saturation' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_move_to_color(nwk_addr addr16, unsigned char ep, - unsigned short color_x, unsigned short color_y, - unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_to_color", - g_variant_new("(qyqqq)", addr16, ep, color_x, color_y, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_to_color' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_move_color(nwk_addr addr16, unsigned char ep, - unsigned short rate_x, unsigned short rate_y) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_color", - g_variant_new("(qyqq)", addr16, ep, rate_x, rate_y), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_color' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_step_color(nwk_addr addr16, unsigned char ep, - unsigned short step_x, unsigned short step_y, - unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "step_color", - g_variant_new("(qyqqq)", addr16, ep, step_x, step_y, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'step_color' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_ccontrol_move_to_color_temperature(nwk_addr addr16, unsigned char ep, - unsigned short color_temperature, - unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_color_temperature", - g_variant_new("(qyqq)", addr16, ep, color_temperature, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_color_temperature' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_reset_factory_default(nwk_addr addr16, unsigned char ep) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_basic_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_basic_proxy, "reset_factory_default", - g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'reset_factory_default' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_identify(nwk_addr addr16, unsigned char dst_ep, unsigned short identify_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_identify_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_identify_proxy, "identify", - g_variant_new("(qyq)", addr16, dst_ep, identify_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'identify' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_identify_query(nwk_addr addr16, unsigned char dst_ep, - zb_zcl_identify_query_cb cb, void *user_data) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - int sub_id, to; - zbl_req_cb_s *container; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_identify_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_identify_query()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_identify_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_IDENTIFY_INTERFACE, "query_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_IDENTIFY_QUERY_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_identify_proxy, "query", - g_variant_new("(qy)", addr16, dst_ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'query' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_add_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, - const char *group_name, zb_zcl_group_add_group_rsp cb, void *user_data) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - int sub_id, to; - zbl_req_cb_s *container; - - int j = 0; - GVariant *groupname_variant = NULL; - GVariantBuilder *groupname_builder = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_add_group()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_group_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_GROUP_INTERFACE, "add_group_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GROUP_ADD_GROUP_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - groupname_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - while (group_name[j] != '\0') { - g_variant_builder_add(groupname_builder, "(y)", (group_name[j])); - j++; - } - groupname_variant = g_variant_builder_end(groupname_builder); - g_variant_builder_unref(groupname_builder); - - variant = g_dbus_proxy_call_sync(zcl_group_proxy, "add_group", - g_variant_new("(qyq@a(y))", addr16, ep, group_id, groupname_variant), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'add_group' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_view_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, - zb_zcl_group_view_group_rsp cb, void *user_data) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - int sub_id, to; - zbl_req_cb_s *container; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_view_group()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_group_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_GROUP_INTERFACE, "view_group_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GROUP_VIEW_GROUP_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_group_proxy, "view_group", - g_variant_new("(qyq)", addr16, ep, group_id), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'view_group' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_group_get_group_membership(nwk_addr addr16, unsigned char ep, - unsigned char group_count, unsigned short *group_list, - zb_zcl_group_get_group_membership_rsp cb, void *user_data) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - int sub_id, to; - zbl_req_cb_s *container; - - int j = 0; - GVariant *grouplist_variant = NULL; - GVariantBuilder *grouplist_builder = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_group_get_group_membership()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_group_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_GROUP_INTERFACE, "get_group_membership_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, - container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - grouplist_builder = g_variant_builder_new(G_VARIANT_TYPE("aq")); - while (j < group_count) { - g_variant_builder_add(grouplist_builder, "q", group_list[j]); - j++; - } - grouplist_variant = g_variant_builder_end(grouplist_builder); - g_variant_builder_unref(grouplist_builder); - - variant = g_dbus_proxy_call_sync(zcl_group_proxy, "get_group_membership", - g_variant_new("(qyy@aq)", addr16, ep, group_count, grouplist_variant), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'get_group_membership' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_remove_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, - zb_zcl_group_remove_group_rsp cb, void *user_data) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - int sub_id, to; - zbl_req_cb_s *container; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_group_remove_group()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_group_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_GROUP_INTERFACE, "remove_group_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_GROUP_REMOVE_GROUP_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_group_proxy, "remove_group", g_variant_new("(qyq)", - addr16, ep, group_id), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'remove_group' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_remove_all_group(nwk_addr addr16, unsigned char ep) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_group_remove_all_group()"); - - variant = g_dbus_proxy_call_sync(zcl_group_proxy, "remove_all_group", - g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'remove_all_group' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_add_group_if_identifying(nwk_addr addr16, unsigned char ep, - unsigned short group_id, const char *group_name) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - int j = 0; - GVariant *groupname_variant = NULL; - GVariantBuilder *groupname_builder = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); - - groupname_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - while (group_name[j] != '\0') { - g_variant_builder_add(groupname_builder, "(y)", group_name[j]); - j++; - } - groupname_variant = g_variant_builder_end(groupname_builder); - g_variant_builder_unref(groupname_builder); - - variant = g_dbus_proxy_call_sync(zcl_group_proxy, "add_group_if_identifying", - g_variant_new("(qyq@a(y))", addr16, ep, group_id, groupname_variant), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'add_group_if_identifying' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_level_control_move_to_level(nwk_addr addr16, unsigned char ep, - unsigned char level, unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_level_control_move_to_level()"); - - variant = g_dbus_proxy_call_sync(level_control_gproxy, "move_to_level", - g_variant_new("(qyyq)", addr16, ep, level, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_to_level' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_level_control_move(nwk_addr addr16, unsigned char ep, - unsigned char move_mode, unsigned char rate) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_level_control_move()"); - - variant = g_dbus_proxy_call_sync(level_control_gproxy, "move", - g_variant_new("(qyyy)", addr16, ep, move_mode, rate), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_level_control_step(nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, - unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_level_control_step()"); - - variant = g_dbus_proxy_call_sync(level_control_gproxy, "step", - g_variant_new("(qyyyq)", addr16, ep, step_mode, step_size, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'step' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_level_control_stop(nwk_addr addr16, unsigned char ep) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_level_control_stop()"); - - variant = g_dbus_proxy_call_sync(level_control_gproxy, "stop", - g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'stop' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_level_control_move_to_level_with_on_off(nwk_addr addr16, - unsigned char ep, unsigned char level, unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_level_control_move_to_level_with_on_off()"); - - variant = g_dbus_proxy_call_sync(level_control_gproxy, "move_to_level_with_on_off", - g_variant_new("(qyyq)", addr16, ep, level, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_to_level_with_on_off' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_level_control_move_with_on_off(nwk_addr addr16, unsigned char ep, - unsigned char move_mode, unsigned char rate) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_level_control_move_with_on_off()"); - - variant = g_dbus_proxy_call_sync(level_control_gproxy, "move_with_on_off", - g_variant_new("(qyyy)", addr16, ep, move_mode, rate), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'move_with_on_off' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_level_control_step_with_on_off(nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, - unsigned short transition_time) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_level_control_step_with_on_off()"); - - variant = g_dbus_proxy_call_sync(level_control_gproxy, "step_with_on_off", - g_variant_new("(qyyyq)", addr16, ep, step_mode, step_size, transition_time), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'step_with_on_off' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_onoff_set(nwk_addr addr16, unsigned char ep, unsigned char on_off_type) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == on_off_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(on_off_gproxy, "set_on_off", - g_variant_new("(qyy)", addr16, ep, on_off_type), G_DBUS_CALL_FLAGS_NONE, - -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'set_on_off' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_zone_enroll_response(nwk_addr addr16, unsigned char dst_ep, - unsigned char enroll_response_code, unsigned char zone_id) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_ias_zone_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_ias_zone_proxy, "enroll_response", - g_variant_new("(qyyy)", addr16, dst_ep, enroll_response_code, zone_id), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'enroll_response' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_pollcontrol_check_in_response(nwk_addr addr16, unsigned char ep, - unsigned char start_fast_polling, unsigned short fast_poll_timeout) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_poll_control_proxy, "check_in_response", - g_variant_new("(qyyq)", addr16, ep, start_fast_polling, fast_poll_timeout), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'check_in_response' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_pollcontrol_fast_poll_stop(nwk_addr addr16, unsigned char ep) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_poll_control_proxy, "fast_poll_stop", - g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'fast_poll_stop' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_pollcontrol_set_long_poll_interval(nwk_addr addr16, unsigned char ep, - unsigned int new_long_poll_interval, zb_zcl_pollctrl_check_in cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_pollcontrol_set_long_poll_interval()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_poll_control_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_POLL_CONTROL_INTERFACE, "checkin_response", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_poll_control_proxy, "set_long_poll_interval", - g_variant_new("(qyu)", addr16, ep, new_long_poll_interval), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'set_long_poll_interval' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_pollcontrol_set_short_poll_interval(nwk_addr addr16, unsigned char ep, - unsigned int new_short_poll_interval, zb_zcl_pollctrl_check_in cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR); - - DBG("zbl_pollcontrol_set_short_poll_interval()"); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_poll_control_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_POLL_CONTROL_INTERFACE, "checkin_response", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_poll_control_proxy, "set_short_poll_interval", - g_variant_new("(qyu)", addr16, ep, new_short_poll_interval), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'set_short_poll_interval' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_add_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, - unsigned char scene_id, unsigned short transition_time, const char *scene_name, - unsigned short ext_field_len, const char *extension_field_sets, - zb_zcl_scene_add_scene_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - int j = 0; - int index = 0; - GVariant *scenename_variant = NULL; - GVariantBuilder *scenename_builder = NULL; - GVariant *extensionfieldSet_variant = NULL; - GVariantBuilder *extensionfieldSet_builder = NULL; - - DBG("zbl_add_scene()"); - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_scene_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_SCENE_INTERFACE, "add_scene_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_SCENE_ADD_SCENE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - scenename_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - while ('\0' != scene_name[j]) { - g_variant_builder_add(scenename_builder, "(y)", scene_name[j]); - j++; - } - scenename_variant = g_variant_builder_end(scenename_builder); - g_variant_builder_unref(scenename_builder); - - extensionfieldSet_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); - - while (index < ext_field_len) { - INFO("Ext contents 0x%02X", extension_field_sets[index]); - g_variant_builder_add(extensionfieldSet_builder, "(y)", extension_field_sets[index]); - index++; - } - extensionfieldSet_variant = g_variant_builder_end(extensionfieldSet_builder); - g_variant_builder_unref(extensionfieldSet_builder); - - variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "add_scene", - g_variant_new("(qyqyqq@a(y)@a(y))", addr16, ep, group_id, scene_id, transition_time, - ext_field_len, scenename_variant, extensionfieldSet_variant), G_DBUS_CALL_FLAGS_NONE, - to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'add_scene' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_view_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, - unsigned char scene_id, zb_zcl_scene_view_scene_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - DBG("zbl_scene_view_scene()"); - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_scene_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_SCENE_INTERFACE, "view_scene_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, - _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_SCENE_VIEW_SCENE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "view_scene", - g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), G_DBUS_CALL_FLAGS_NONE, - to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'view_scene' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_remove_scene(nwk_addr addr16, unsigned char ep, - unsigned short group_id, unsigned char scene_id, zb_zcl_scene_remove_scene_rsp cb, - void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - DBG("zbl_scene_remove_scene()"); - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_scene_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_SCENE_INTERFACE, "remove_scene_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_SCENE_REMOVE_SCENE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "remove_scene", - g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'remove_scene' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_remove_all_scene(nwk_addr addr16, unsigned char ep, - unsigned short group_id, zb_zcl_scene_remove_all_scene_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - DBG("zbl_scene_remove_all_scene()"); - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_scene_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_SCENE_INTERFACE, "remove_all_scene_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_SCENE_REMOVE_ALL_SCENE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "remove_all_scene", - g_variant_new("(qyq)", addr16, ep, group_id), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'remove_all_scene' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_store_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, - unsigned char scene_id, zb_zcl_scene_store_scene_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - DBG("zbl_scene_store_scene()"); - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_scene_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_SCENE_INTERFACE, "store_scene_rsp", ZIGBEE_CONTROL_OBJECT_PATH, - NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_SCENE_STORE_SCENE_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "store_scene", - g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'store_scene' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_recall_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, - unsigned char scene_id) -{ - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "recall_scene", - g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), G_DBUS_CALL_FLAGS_NONE, - -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'recall_scene' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_get_scene_membership(nwk_addr addr16, unsigned char ep, - unsigned short group_id, zb_zcl_scene_get_scene_membership_rsp cb, void *user_data) -{ - int sub_id, to; - zbl_req_cb_s *container; - - int result = ZIGBEE_ERROR_NONE; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - DBG("zbl_scene_get_scene_membership()"); - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); - - container = calloc(1, sizeof(zbl_req_cb_s)); - RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - - to = zbl_dbus_get_timeout(zcl_scene_proxy); - sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, - ZIGBEE_ZCL_SCENE_INTERFACE, "get_scene_membership_rsp", - ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, - _zbl_request_cleanup); - - if (0 == sub_id) { - ERR("g_dbus_connection_signal_subscribe() Fail"); - free(container); - return ZIGBEE_ERROR_IO_ERROR; - } - - container->cb = cb; - container->sid = sub_id; - container->cid = ZBL_ZCL_SCENE_GET_SCENE_MEMBERSHIP_REQ; - container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); - container->userdata = user_data; - - variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "get_scene_membership", - g_variant_new("(qyq)", addr16, ep, group_id), - G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get get_scene_membership [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_thermostat_adjust_setpoint(nwk_addr addr16, unsigned char ep, unsigned char mode, - unsigned char amount) -{ - int result = ZIGBEE_ERROR_IO_ERROR; - GVariant *variant = NULL; - GError *dbus_err = NULL; - - RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == thermostat_gproxy, ZIGBEE_ERROR_IO_ERROR); - - variant = g_dbus_proxy_call_sync(thermostat_gproxy, "setpoint_raise_lower", - g_variant_new("(qyyy)", addr16, ep, mode, amount), - G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); - - if (!variant) { - ERR("Failed to get 'setpoint_raise_lower' [%s]", dbus_err->message); - g_error_free(dbus_err); - return ZIGBEE_ERROR_IO_ERROR; - } - - g_variant_get(variant, "(i)", &result); - DBG("ret = [0x%x]", result); - g_variant_unref(variant); - - return result; -} - -int zbl_dbus_start(zigbee_h handle) -{ - FN_CALL; - - GError *error = NULL; - unsigned int id; - - if (gdbus_conn) { - zbl_ref_count++; - return ZIGBEE_ERROR_NONE; - } - - gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); - if (NULL == gdbus_conn) { - ERR("Couldn't connect to the System bus [%s]\n", error->message); - g_error_free(error); - return ZIGBEE_ERROR_IO_ERROR; - } - - id = g_signal_connect(gdbus_conn, "notify::g-name-owner", - G_CALLBACK(_zbl_dbus_name_owner_notify), handle); - if (0 == id) { - ERR("g_signal_connect() Fail\n"); - return ZIGBEE_ERROR_IO_ERROR; - } - - /* Phase 1. Subscribe signals */ - _zbl_dbus_subscribe_signal(handle); - - /* Phase 2. Make proxies */ - service_gproxy = _zbl_get_service_proxy(); - RETVM_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get service_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(service_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - on_off_gproxy = _zbl_get_on_off_proxy(); - RETVM_IF(NULL == on_off_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get on_off_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(on_off_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - door_lock_gproxy = _zbl_get_door_lock_proxy(); - RETVM_IF(NULL == door_lock_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get door_lock_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(door_lock_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - level_control_gproxy = _zbl_get_level_control_proxy(); - RETVM_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get level_control_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(level_control_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - thermostat_gproxy = _zbl_get_thermostat_proxy(); - RETVM_IF(NULL == thermostat_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get thermostat_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(thermostat_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - fan_control_gproxy = _zbl_get_fan_control_proxy(); - RETVM_IF(NULL == fan_control_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get fan_control_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(fan_control_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - alarm_gproxy = _zbl_get_alarm_proxy(); - RETVM_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get alarm_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(alarm_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - mfglib_gproxy = _zbl_get_mfglib_proxy(); - RETVM_IF(NULL == mfglib_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get mfglib_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(mfglib_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - zcl_global_proxy = _zbl_get_zcl_global_proxy(); - RETVM_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_global_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_global_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zdo_dev_proxy = _zbl_get_zdo_dev_proxy(); - RETVM_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zdo_dev_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zdo_dev_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zcl_basic_proxy = _zbl_get_basic_proxy(); - RETVM_IF(NULL == zcl_basic_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_basic_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_basic_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zcl_identify_proxy = _zbl_get_identify_proxy(); - RETVM_IF(NULL == zcl_identify_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_identify_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_identify_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zcl_ias_zone_proxy = _zbl_get_ias_zone_proxy(); - RETVM_IF(NULL == zcl_ias_zone_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_ias_zone_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_ias_zone_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zcl_poll_control_proxy = _zbl_get_poll_control_proxy(); - RETVM_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_poll_control_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_poll_control_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zcl_group_proxy = _zbl_get_group_proxy(); - RETVM_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_group_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_group_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zcl_scene_proxy = _zbl_get_scene_proxy(); - RETVM_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_scene_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_scene_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zdo_bind_proxy = _zbl_get_zdo_bind_proxy(); - RETVM_IF(NULL == zdo_bind_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zdo_bind_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zdo_bind_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - zcl_color_control_proxy = _zbl_get_color_control_proxy(); - RETVM_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_color_control_proxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_color_control_proxy), ZIGBEE_BROADCAST_TIMEOUT); - - custom_gproxy = _zbl_get_custom_gproxy(); - RETVM_IF(NULL == custom_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get custom_gproxy"); - g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(custom_gproxy), ZIGBEE_BROADCAST_TIMEOUT); - - zbl_ref_count++; - - return ZIGBEE_ERROR_NONE; -} - -void zbl_dbus_stop(zigbee_h handle) -{ - DBG("zbl_dbus_stop()"); - - if (0 >= zbl_ref_count) { - WARN("dbus does not initiaized\n"); - return; - } - - if (0 > --zbl_ref_count) { - DBG("all connections closed\n"); - zbl_ref_count = 0; - return; - } - - if (gdbus_conn) { - _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); - handle->dbus_sub_ids = NULL; - - g_object_unref(service_gproxy); - service_gproxy = NULL; - g_object_unref(on_off_gproxy); - on_off_gproxy = NULL; - g_object_unref(door_lock_gproxy); - door_lock_gproxy = NULL; - g_object_unref(level_control_gproxy); - level_control_gproxy = NULL; - g_object_unref(thermostat_gproxy); - thermostat_gproxy = NULL; - g_object_unref(alarm_gproxy); - alarm_gproxy = NULL; - g_object_unref(fan_control_gproxy); - fan_control_gproxy = NULL; - - g_object_unref(mfglib_gproxy); - mfglib_gproxy = NULL; - g_object_unref(zcl_global_proxy); - zcl_global_proxy = NULL; - g_object_unref(zcl_color_control_proxy); - zcl_color_control_proxy = NULL; - g_object_unref(custom_gproxy); - custom_gproxy = NULL; - - g_object_unref(gdbus_conn); - gdbus_conn = NULL; - - DBG("zbl_dbus_stop() finished"); - } -} - -GDBusConnection* zbl_dbus_get_object(void) -{ - return gdbus_conn; -} - -int zbl_dbus_get_timeout(GDBusProxy *proxy) -{ - gint timeout; - RETV_IF(NULL == gdbus_conn, ZIGBEE_BROADCAST_TIMEOUT); - timeout = g_dbus_proxy_get_default_timeout(proxy); - if (timeout <= 0) { - ERR("Invalid timeout (%d)", timeout); - return ZIGBEE_BROADCAST_TIMEOUT; - } - return timeout; -} - diff --git a/lib/zbl-dbus.h b/lib/zbl-dbus.h deleted file mode 100644 index c2886fe..0000000 --- a/lib/zbl-dbus.h +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ -#ifndef __TIZEN_NETWORK_ZIGBEE_LIBRARY_DBUS_H__ -#define __TIZEN_NETWORK_ZIGBEE_LIBRARY_DBUS_H__ - -#include - -#include -#include -#include - -int zbl_dbus_start(zigbee_h handle); -void zbl_dbus_stop(zigbee_h handle); -GDBusConnection* zbl_dbus_get_object(void); -int zbl_dbus_get_timeout(GDBusProxy *proxy); -int zbl_enable(zigbee_h handle, zb_enable_cb cb, void *user_data); -int zbl_set_event_cb(zigbee_h handle, zb_event_cb event_handler); -int zbl_disable(void); -int zbl_hw_reset(void); -int zbl_coex_start(unsigned char channel); -int zbl_coex_stop(void); -int zbl_get_network_info(ieee_addr addr64, nwk_addr *nodeid, nwk_addr *panid, - unsigned char *channel, unsigned char *tx_power); -int zbl_get_controller_mac_address(ieee_addr addr64); -int zbl_get_cluster_list(ieee_addr eui64, unsigned char endpoint, - unsigned char *in_cluster_count, unsigned short in_cluster_list[], - unsigned char *out_cluster_count, unsigned short out_cluster_list[]); -int zbl_get_endpoint_list(ieee_addr eui64, unsigned char *count, unsigned char list[]); -int zbl_get_all_device_info(zb_end_device_info_h **dev_list, unsigned char* num); -int zbl_form_network(zigbee_h handle, zb_form_network_cb cb, void *user_data); -int zbl_disable_network(zigbee_h handle, zb_disable_network_cb cb, void *user_data); -int zbl_leave_device(ieee_addr addr64, bool remove_children, bool rejoin); -int zbl_permit_join(unsigned char duration, bool broadcast); -int zbl_nwk_addr_req(zigbee_h handle, ieee_addr addr64, unsigned char request_type, - unsigned char start_idx, zb_zdo_addr_rsp cb, void *user_data); -int zbl_ieee_addr_req(zigbee_h handle, nwk_addr addr16, zb_zdo_addr_rsp cb, - void *user_data); -int zbl_active_ep(zigbee_h handle, nwk_addr addr16, zb_zdo_active_ep_rsp cb, - void *user_data); -int zbl_simple_desc_req(zigbee_h handle, nwk_addr addr16, unsigned char ep, - zb_zdo_simple_desc_rsp cb, void *user_data); -int zbl_match_desc_req(zigbee_h handle, nwk_addr addr16, - unsigned short profile_id, unsigned char num_in_clusters, - unsigned short *in_clusters, unsigned char num_out_clusters, - unsigned short *out_clusters, zb_zdo_match_desc_rsp cb, void *user_data); -int zbl_device_annce(zigbee_h handle, nwk_addr addr16, ieee_addr addr64, - unsigned char capability); -int zbl_node_desc_req(nwk_addr addr16, zb_zdo_node_desc_rsp cb, void *user_data); -int zbl_power_desc_req(nwk_addr addr16, zb_zdo_power_desc_rsp cb, void *user_data); -int zbl_complex_desc_req(nwk_addr addr16, zb_zdo_complex_desc_rsp cb, void *user_data); -int zbl_user_desc_req(nwk_addr addr16, zb_zdo_user_desc_rsp cb, void *user_data); -int zbl_bind_req(nwk_addr dst_addr16, ieee_addr src_addr64, - unsigned char src_ep, unsigned short cluster_id, ieee_addr dst_addr64, - unsigned char type, nwk_addr group_addr, unsigned char dst_ep, zb_zdo_bind_rsp cb, - void *user_data); -int zbl_unbind_req(nwk_addr dst_addr16, ieee_addr src_addr64, - unsigned char src_ep, unsigned short cluster_id, ieee_addr dst_addr64, - unsigned char type, nwk_addr group_addr, unsigned char dst_ep, - zb_zdo_unbind_rsp cb, void *user_data); -int zbl_mgmt_nwk_disc_req(nwk_addr addr16, unsigned int scan_channels, - unsigned char scan_duration, unsigned char scan_count, unsigned char start_idx, - zb_zdo_mgmt_nwk_disc_rsp cb, void *user_data); -int zbl_mgmt_nwk_update_req(unsigned int scan_channels, unsigned char scan_duration, - unsigned char scan_count, unsigned char nwk_update_id, nwk_addr nwk_manager_addr); -int zbl_mgmt_lqi_req(nwk_addr addr16, unsigned char start_idx, - zb_zdo_mgmt_lqi_rsp cb, void *user_data); -int zbl_mgmt_rtg_req(nwk_addr addr16, unsigned char start_idx, - zb_zdo_mgmt_rtg_rsp cb, void *user_data); -int zbl_mgmt_bind_req(nwk_addr addr16, unsigned char start_idx, - zb_zdo_mgmt_bind_rsp cb, void *user_data); -int zbl_mgmt_leave_device(ieee_addr addr64, unsigned char remove_children, - unsigned rejoin, zb_zdo_mgmt_leave_rsp cb, void *user_data); -int zbl_mgmt_permit_joining_req(nwk_addr addr16, unsigned char duration, - unsigned char tc_significance, zb_zdo_mgmt_permit_joining_rsp cb, void *user_data); - -/* Custom Commands */ -int zbl_aps_send(nwk_addr addr16, unsigned char aps_frame_ctl, unsigned char src_ep, - unsigned char dst_ep, unsigned short cluster_id, unsigned short profile_id, - unsigned char zcl_frame_ctl, unsigned short mfg_code, unsigned char cmd_id, - unsigned short payload_len, unsigned char *payload, zb_aps_send_rsp cb, void *user_data); -int zbl_zcl_send(nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned short cluster_id, unsigned char zcl_frame_ctl, unsigned char cmd, - unsigned short payload_len, unsigned char *payload, - zb_zcl_send_rsp cb, void *user_data); -int zbl_send_to_local(unsigned short length, unsigned char *data, - zb_send_to_local_rsp cb, void *user_data); - -/* ZCL Global Commands */ -int zbl_read_attr_req(zigbee_h handle, unsigned short addr16, unsigned char dest_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short *attribute_ids, - int attribute_ids_len, zb_zcl_global_rsp cb, void *user_data); -int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, write_attr_record_h *records, - int records_len, zb_zcl_global_rsp cb, void *user_data); -int zbl_wattr_undivided_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - write_attr_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data); -int zbl_wattr_req_no_rsp(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - write_attr_record_h *records, int records_len); -int zbl_configure_reporting(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, report_config_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data); -int zbl_read_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, - unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - read_report_config_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data); -int zbl_discover_attr_req(zigbee_h handle, unsigned short addr16, unsigned char src_ep, - unsigned char dest_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, - unsigned short start_id, unsigned char max_attribute_ids, - zb_zcl_global_discover_attr_rsp cb, void *user_data); -int zbl_discover_cmds_gen(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, - unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data); -int zbl_discover_cmds_recv(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, - unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data); -int zbl_discover_attr_ext(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short start_id, - unsigned char max_attribute_ids, zb_zcl_global_discover_attr_extended_rsp cb, - void *user_data); - -/* ZCL Alarm Cluster */ -int zbl_reset_alarm(nwk_addr addr16, unsigned char ep, unsigned char alarm_code, - unsigned short cluster_id); -int zbl_reset_all_alarm(nwk_addr addr16, unsigned char ep); -int zbl_get_alarm(nwk_addr addr16, unsigned char ep, zb_zcl_alarm_get_alarm_rsp cb, - void *user_data); -int zbl_reset_all_alarm_log(nwk_addr addr16, unsigned char ep); - -/* ZCL Color Control Cluster */ -int zbl_ccontrol_move_to_hue(nwk_addr addr16, unsigned char ep, - unsigned char hue, unsigned char direction, - unsigned short transition_time); -int zbl_ccontrol_move_hue(nwk_addr addr16, unsigned char ep, - unsigned char move_mode, unsigned char rate); -int zbl_ccontrol_step_hue(nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, - unsigned char transition_time); -int zbl_ccontrol_move_to_saturation(nwk_addr addr16, unsigned char ep, - unsigned char saturation, unsigned short transition_time); -int zbl_ccontrol_move_saturation(nwk_addr addr16, unsigned char ep, - unsigned char move_mode, unsigned char rate); -int zbl_ccontrol_step_saturation(nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, - unsigned char transition_time); -int zbl_ccontrol_move_to_hue_and_saturation(nwk_addr addr16, unsigned char ep, - unsigned char hue, unsigned char saturation, - unsigned short transition_time); -int zbl_ccontrol_move_to_color(nwk_addr addr16, unsigned char ep, - unsigned short color_x, unsigned short color_y, - unsigned short transition_time); -int zbl_ccontrol_move_color(nwk_addr addr16, unsigned char ep, - unsigned short rate_x, unsigned short rate_y); -int zbl_ccontrol_step_color(nwk_addr addr16, unsigned char ep, - unsigned short step_x, unsigned short step_y, - unsigned short transition_time); -int zbl_ccontrol_move_to_color_temperature(nwk_addr addr16, unsigned char ep, - unsigned short color_temperature, - unsigned short transition_time); - -/* ZCL Basic Cluster */ -int zbl_reset_factory_default(nwk_addr addr16, unsigned char ep); - -/* ZCL Identity Cluster */ -int zbl_identify(nwk_addr addr16, unsigned char dst_ep, unsigned short identify_time); -int zbl_identify_query(nwk_addr addr16, unsigned char dst_ep, - zb_zcl_identify_query_cb cb, void *user_data); - -/* ZCL Group Cluster */ -int zbl_add_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, - const char *group_name, zb_zcl_group_add_group_rsp cb, void *user_data); -int zbl_view_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, - zb_zcl_group_view_group_rsp cb, void *user_data); -int zbl_group_get_group_membership(nwk_addr addr16, unsigned char ep, - unsigned char group_count, unsigned short *group_list, - zb_zcl_group_get_group_membership_rsp cb, void *user_data); -int zbl_remove_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, - zb_zcl_group_remove_group_rsp cb, void *user_data); -int zbl_remove_all_group(nwk_addr addr16, unsigned char ep); -int zbl_add_group_if_identifying(nwk_addr addr16, unsigned char ep, - unsigned short group_id, const char *group_name); - -/* ZCL Level Control Cluster */ -int zbl_level_control_move_to_level(nwk_addr addr16, unsigned char ep, - unsigned char level, unsigned short transition_time); -int zbl_level_control_move(nwk_addr addr16, unsigned char ep, - unsigned char move_mode, unsigned char rate); -int zbl_level_control_step(nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, - unsigned short transition_time); -int zbl_level_control_stop(nwk_addr addr16, unsigned char ep); -int zbl_level_control_move_to_level_with_on_off(nwk_addr addr16, - unsigned char ep, unsigned char level, unsigned short transition_time); -int zbl_level_control_move_with_on_off(nwk_addr addr16, unsigned char ep, - unsigned char move_mode, unsigned char rate); -int zbl_level_control_step_with_on_off(nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, - unsigned short transition_time); - -/* ZCL On/Off Cluster */ -int zbl_onoff_set(nwk_addr addr16, unsigned char ep, unsigned char on_off_type); -int zbl_zone_enroll_response(nwk_addr addr16, unsigned char dst_ep, - unsigned char enroll_response_code, unsigned char zone_id); - -/* Poll-control Cluster */ -int zbl_pollcontrol_check_in_response(nwk_addr addr16, unsigned char ep, - unsigned char start_fast_polling, unsigned short fast_poll_timeout); -int zbl_pollcontrol_fast_poll_stop(nwk_addr addr16, unsigned char ep); -int zbl_pollcontrol_set_long_poll_interval(nwk_addr addr16, unsigned char ep, - unsigned int new_long_poll_interval, zb_zcl_pollctrl_check_in cb, void *user_data); -int zbl_pollcontrol_set_short_poll_interval(nwk_addr addr16, unsigned char ep, - unsigned int new_short_poll_interval, zb_zcl_pollctrl_check_in cb, void *user_data); - -/* Scene Cluster */ -int zbl_add_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, - unsigned char scene_id, unsigned short transition_time, const char *scene_name, - unsigned short ext_field_len, const char *extension_field_sets, - zb_zcl_scene_add_scene_rsp cb, void *user_data); -int zbl_view_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, - unsigned char scene_id, zb_zcl_scene_view_scene_rsp cb, void *user_data); -int zbl_remove_scene(nwk_addr addr16, unsigned char ep, - unsigned short group_id, unsigned char scene_id, zb_zcl_scene_remove_scene_rsp cb, - void *user_data); -int zbl_remove_all_scene(nwk_addr addr16, unsigned char ep, - unsigned short group_id, zb_zcl_scene_remove_all_scene_rsp cb, void *user_data); -int zbl_store_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, - unsigned char scene_id, zb_zcl_scene_store_scene_rsp cb, void *user_data); -int zbl_recall_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, - unsigned char scene_id); -int zbl_get_scene_membership(nwk_addr addr16, unsigned char ep, - unsigned short group_id, zb_zcl_scene_get_scene_membership_rsp cb, void *user_data); - -/* Thermostat Cluster */ -int zbl_thermostat_adjust_setpoint(nwk_addr addr16, unsigned char ep, unsigned char mode, - unsigned char amount); - -#endif /* __TIZEN_NETWORK_ZIGBEE_LIBRARY_DBUS_H__ */ diff --git a/lib/zbl-zcl-alarm.c b/lib/zbl-zcl-alarm.c deleted file mode 100644 index 0356f3a..0000000 --- a/lib/zbl-zcl-alarm.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_alarm_reset_alarm(zigbee_h handle, nwk_addr addr16, unsigned char ep, - unsigned char alarm_code, unsigned short cluster_id) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_reset_alarm(addr16, ep, alarm_code, cluster_id); - return ret; -} - -API int zb_zcl_alarm_reset_all_alarm(zigbee_h handle, nwk_addr addr16, - unsigned char ep) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_reset_all_alarm(addr16, ep); - return ret; -} - -API int zb_zcl_alarm_get_alarm(zigbee_h handle, nwk_addr addr16, unsigned char ep, - zb_zcl_alarm_get_alarm_rsp cb, void *user_data) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_get_alarm(addr16, ep, cb, user_data); - return ret; -} - -API int zb_zcl_alarm_reset_all_alarm_log(zigbee_h handle, nwk_addr addr16, - unsigned char ep) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_reset_all_alarm_log(addr16, ep); - return ret; -} diff --git a/lib/zbl-zcl-basic.c b/lib/zbl-zcl-basic.c deleted file mode 100644 index 8778a93..0000000 --- a/lib/zbl-zcl-basic.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_basic_reset_factory_default(zigbee_h handle, nwk_addr addr16, - unsigned char ep) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_reset_factory_default(addr16, ep); - return ret; -} diff --git a/lib/zbl-zcl-color-control.c b/lib/zbl-zcl-color-control.c deleted file mode 100644 index d73cc6b..0000000 --- a/lib/zbl-zcl-color-control.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_ccontrol_move_to_hue(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char hue, unsigned char direction, - unsigned short transition_time) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_move_to_hue(addr16, ep, hue, direction, transition_time); - return ret; -} - -API int zb_zcl_ccontrol_move_hue(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char move_mode, unsigned char rate) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_move_hue(addr16, ep, move_mode, rate); - return ret; -} - -API int zb_zcl_ccontrol_step_hue(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char step_mode, unsigned char step_size, - unsigned char transition_time) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_step_hue(addr16, ep, step_mode, step_size, transition_time); - return ret; -} - -API int zb_zcl_ccontrol_move_to_saturation(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned char saturation, - unsigned short transition_time) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_move_to_saturation(addr16, ep, saturation, transition_time); - return ret; -} - -API int zb_zcl_ccontrol_move_saturation(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char move_mode, unsigned char rate) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_move_saturation(addr16, ep, move_mode, rate); - return ret; -} - -API int zb_zcl_ccontrol_step_saturation(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char step_mode, unsigned char step_size, - unsigned char transition_time) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_step_saturation(addr16, ep, step_mode, step_size, transition_time); - return ret; -} - -API int zb_zcl_ccontrol_move_to_hue_and_saturation(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned char hue, unsigned char saturation, - unsigned short transition_time) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_move_to_hue_and_saturation(addr16, ep, hue, saturation, transition_time); - return ret; -} - -API int zb_zcl_ccontrol_move_to_color(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short color_x, unsigned short color_y, - unsigned short transition_time) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_move_to_color(addr16, ep, color_x, color_y, transition_time); - return ret; -} - -API int zb_zcl_ccontrol_move_color(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short rate_x, unsigned short rate_y) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_move_color(addr16, ep, rate_x, rate_y); - return ret; -} - -API int zb_zcl_ccontrol_step_color(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short step_x, unsigned short step_y, - unsigned short transition_time) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_step_color(addr16, ep, step_x, step_y, transition_time); - return ret; -} - -API int zb_zcl_ccontrol_move_to_color_temperature(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned short color_temperature, - unsigned short transition_time) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_ccontrol_move_to_color_temperature(addr16, ep, color_temperature, transition_time); - return ret; -} - diff --git a/lib/zbl-zcl-door-lock.c b/lib/zbl-zcl-door-lock.c deleted file mode 100644 index 81578b4..0000000 --- a/lib/zbl-zcl-door-lock.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -#ifdef ZB_SUPPORT_PRIORITY_5 - -API int zb_zcl_doorlock_lock(zigbee_h handle, nwk_addr addr16, unsigned char ep, - const char *pin_or_rfid_code, zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == pin_or_rfid_code, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_unlock(zigbee_h handle, nwk_addr addr16, unsigned char ep, - const char *pin_or_rfid_code, zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == pin_or_rfid_code, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_toggle(zigbee_h handle, nwk_addr addr16, unsigned char ep, - const char *pin_or_rfid_code, zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == pin_or_rfid_code, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_unlock_with_timeout(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short timeout, const char *pin_or_rfid_code, - zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == pin_or_rfid_code, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_get_log_record(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short log_index, - zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_set_pin_code(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, unsigned char user_status, - unsigned char user_type, const char *pin, zb_zcl_doorlock_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == pin, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_get_pin_code(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, zb_zcl_doorlock_get_pin_code_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_clear_pin_code(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, zb_zcl_doorlock_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_clear_all_pin_code(zigbee_h handle, nwk_addr addr16, - unsigned char ep, zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_set_user_status(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, unsigned char user_status, - zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_set_week_day_schedule(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char schedule_id, unsigned short user_id, - unsigned char days_mask, unsigned char start_hour, unsigned char start_minute, - unsigned char end_hour, unsigned char end_minute, zb_zcl_doorlock_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_get_week_day_schedule(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned char schedule_id, - unsigned short user_id, zb_zcl_doorlock_get_week_day_schedule_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_set_year_day_schedule(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned char schedule_id, - unsigned short user_id, unsigned int zigbee_local_start_time, - unsigned int zigbee_local_end_time, zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_get_year_day_schedule(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned char schedule_id, - unsigned short user_id, zb_zcl_doorlock_get_year_day_schedule_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_set_holiday_schedule(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char holiday_schedule_id, - unsigned int zigbee_local_start_time, unsigned int zigbee_local_end_time, - unsigned char operating_mode_during_holiday, zb_zcl_doorlock_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_get_holiday_schedule(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char holiday_schedule_id, - zb_zcl_doorlock_get_holiday_schedule_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_clear_holiday_schedule(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned char holiday_schedule_id, - zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_set_user_type(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, unsigned char user_type, - zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_get_user_type(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, zb_zcl_doorlock_get_user_type_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_set_rfid_code(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, unsigned char user_status, - unsigned char user_type, const char *rfid_code, - zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == rfid_code, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_get_rfid_code(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, zb_zcl_doorlock_get_rfid_code_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_clear_rfid_code(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short user_id, - zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_doorlock_clear_all_rfid_code(zigbee_h handle, nwk_addr addr16, - unsigned char ep, zb_zcl_doorlock_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -#endif /* ZB_SUPPORT_PRIORITY_5 */ diff --git a/lib/zbl-zcl-global-commands.c b/lib/zbl-zcl-global-commands.c deleted file mode 100644 index 0ea25e2..0000000 --- a/lib/zbl-zcl-global-commands.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" -#include "zb-utils.h" - -API int zb_zcl_global_read_attr(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, unsigned short *attribute_ids, int attribute_ids_len, - zb_zcl_global_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == attribute_ids, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == attribute_ids_len, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_read_attr_req(handle, addr16, dst_ep, zcl_frame_ctl, cluster_id, attribute_ids, - attribute_ids_len, cb, user_data); - return ret; -} - -API int zb_zcl_global_write_attr(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, write_attr_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_write_attr_req(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, records, records_len, cb, user_data); - return ret; -} - -API int zb_zcl_global_write_attr_undivided(zigbee_h handle, - nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, write_attr_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_wattr_undivided_req(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, records, records_len, cb, user_data); - return ret; -} - -API int zb_zcl_global_write_attr_no_rsp(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, write_attr_record_h *records, int records_len) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_wattr_req_no_rsp(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, records, records_len); - return ret; -} - -API int zb_zcl_global_config_report(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, report_config_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_configure_reporting(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, records, records_len, cb, user_data); - return ret; -} - -API int zb_zcl_global_read_config_report(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, read_report_config_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_read_configure_reporting(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, records, records_len, cb, user_data); - return ret; -} - -API int zb_zcl_global_discover_attr(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, unsigned short start_id, unsigned char max_attribute_ids, - zb_zcl_global_discover_attr_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_discover_attr_req(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, start_id, max_attribute_ids, cb, user_data); - return ret; -} - -API int zb_zcl_global_read_attr_structured(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, read_structured_attr_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ -#if (0 == ZIGBEE_SUPPORT_ORDERED_SEQUENCE_DATA) - return ZIGBEE_ERROR_NOT_SUPPORTED; -#endif - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_global_write_attr_structured(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, - unsigned short cluster_id, write_attr_structured_record_h *records, int records_len, - zb_zcl_global_rsp cb, void *user_data) -{ -#if (0 == ZIGBEE_SUPPORT_ORDERED_SEQUENCE_DATA) - return ZIGBEE_ERROR_NOT_SUPPORTED; -#endif - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_global_discover_cmds_received(zigbee_h handle, - nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, - unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_discover_cmds_recv(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, start_command_id, max_command_ids, cb, user_data); - return ret; -} - -API int zb_zcl_global_discover_cmds_generated(zigbee_h handle, - nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, - unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_discover_cmds_gen(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, start_command_id, max_command_ids, cb, user_data); - return ret; -} - -API int zb_zcl_global_discover_attr_extended(zigbee_h handle, - nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, - unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short start_id, - unsigned char max_attribute_ids, zb_zcl_global_discover_attr_extended_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_discover_attr_ext(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, - cluster_id, start_id, max_attribute_ids, cb, user_data); - return ret; -} diff --git a/lib/zbl-zcl-groups.c b/lib/zbl-zcl-groups.c deleted file mode 100644 index 0c6555a..0000000 --- a/lib/zbl-zcl-groups.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_group_add_group(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short group_id, char *group_name, - zb_zcl_group_add_group_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == group_name, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_add_group(addr16, ep, group_id, group_name, cb, user_data); - return ret; -} - -API int zb_zcl_group_view_group(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short group_id, zb_zcl_group_view_group_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_view_group(addr16, ep, group_id, cb, user_data); - return ret; -} - -API int zb_zcl_group_get_group_membership(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char group_count, unsigned short *group_list, - zb_zcl_group_get_group_membership_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == group_list, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_group_get_group_membership(addr16, ep, group_count, group_list, cb, user_data); - return ret; -} - -API int zb_zcl_group_remove_group(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short group_id, zb_zcl_group_remove_group_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_remove_group(addr16, ep, group_id, cb, user_data); - return ret; -} - -API int zb_zcl_group_remove_all_group(zigbee_h handle, nwk_addr addr16, - unsigned char ep) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_remove_all_group(addr16, ep); - return ret; -} - -API int zb_zcl_group_add_group_if_identifying(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short group_id, const char *group_name) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_add_group_if_identifying(addr16, ep, group_id, group_name); - return ret; -} diff --git a/lib/zbl-zcl-identify.c b/lib/zbl-zcl-identify.c deleted file mode 100644 index 0657805..0000000 --- a/lib/zbl-zcl-identify.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_identify(zigbee_h handle, nwk_addr addr16, unsigned char ep, - unsigned short identify_time) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_identify(addr16, ep, identify_time); - return ret; -} - -API int zb_zcl_identify_query(zigbee_h handle, nwk_addr addr16, unsigned char ep, - zb_zcl_identify_query_cb cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_identify_query(addr16, ep, cb, user_data); - return ret; -} diff --git a/lib/zbl-zcl-isa-zone.c b/lib/zbl-zcl-isa-zone.c deleted file mode 100644 index 2c7a14d..0000000 --- a/lib/zbl-zcl-isa-zone.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_zone_enroll_response(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char enroll_response_code, unsigned char zone_id) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_zone_enroll_response(addr16, ep, enroll_response_code, zone_id); - return ret; -} diff --git a/lib/zbl-zcl-level-control.c b/lib/zbl-zcl-level-control.c deleted file mode 100644 index 0fe98c1..0000000 --- a/lib/zbl-zcl-level-control.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_levelctrl_move_to_level(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char level, unsigned short transition_time) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_level_control_move_to_level(addr16, ep, level, transition_time); - return ret; -} - -API int zb_zcl_levelctrl_move(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char move_mode, unsigned char rate) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_level_control_move(addr16, ep, move_mode, rate); - return ret; -} - -API int zb_zcl_levelctrl_step(zigbee_h handle, nwk_addr addr16, unsigned char ep, - unsigned char step_mode, unsigned char step_size, unsigned short transition_time) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_level_control_step(addr16, ep, step_mode, step_size, transition_time); - return ret; -} - -API int zb_zcl_levelctrl_stop(zigbee_h handle, nwk_addr addr16, unsigned char ep) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_level_control_stop(addr16, ep); - return ret; -} - -API int zb_zcl_levelctrl_move_to_level_with_on_off(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char level, unsigned short transition_time) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_level_control_move_to_level_with_on_off(addr16, ep, level, transition_time); - return ret; -} - -API int zb_zcl_levelctrl_move_with_on_off(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char move_mode, unsigned char rate) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_level_control_move_with_on_off(addr16, ep, move_mode, rate); - return ret; -} - -API int zb_zcl_levelctrl_step_with_on_off(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char step_mode, unsigned char step_size, - unsigned short transition_time) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_level_control_step_with_on_off(addr16, ep, step_mode, step_size, transition_time); - return ret; -} - diff --git a/lib/zbl-zcl-on-off.c b/lib/zbl-zcl-on-off.c deleted file mode 100644 index 86d1008..0000000 --- a/lib/zbl-zcl-on-off.c +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_onoff_control(zigbee_h handle, nwk_addr addr16, unsigned char ep, - zb_zcl_onoff_e on_off_type) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_onoff_set(addr16, ep, on_off_type); - return ret; -} diff --git a/lib/zbl-zcl-poll-control.c b/lib/zbl-zcl-poll-control.c deleted file mode 100644 index fa3a836..0000000 --- a/lib/zbl-zcl-poll-control.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_pollctrl_check_in_response(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char start_fast_polling, - unsigned short fast_poll_timeout) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_pollcontrol_check_in_response(addr16, ep, start_fast_polling, - fast_poll_timeout); - return ret; -} - -API int zb_zcl_pollctrl_fast_poll_stop(zigbee_h handle, nwk_addr addr16, - unsigned char ep) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_pollcontrol_fast_poll_stop(addr16, ep); - return ret; -} - -API int zb_zcl_pollctrl_set_long_poll_interval(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned int new_long_poll_interval, - zb_zcl_pollctrl_check_in cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_pollcontrol_set_long_poll_interval(addr16, ep, new_long_poll_interval, - cb, user_data); - return ret; -} - -API int zb_zcl_pollctrl_set_short_poll_interval(zigbee_h handle, - nwk_addr addr16, unsigned char ep, unsigned int new_short_poll_interval, - zb_zcl_pollctrl_check_in cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_pollcontrol_set_short_poll_interval(addr16, ep, new_short_poll_interval, - cb, user_data); - return ret; -} diff --git a/lib/zbl-zcl-scenes.c b/lib/zbl-zcl-scenes.c deleted file mode 100644 index 7c48742..0000000 --- a/lib/zbl-zcl-scenes.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_scene_add_scene(zigbee_h handle, nwk_addr addr16, unsigned char ep, - unsigned short group_id, unsigned char scene_id, unsigned short transition_time, - const char *scene_name, unsigned short ext_field_len, - const char *extension_field_sets, zb_zcl_scene_add_scene_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == scene_name, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == extension_field_sets, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_add_scene(addr16, ep, group_id, scene_id, transition_time, scene_name, - ext_field_len, extension_field_sets, cb, user_data); - return ret; -} - -API int zb_zcl_scene_view_scene(zigbee_h handle, nwk_addr addr16, unsigned char ep, - unsigned short group_id, unsigned char scene_id, zb_zcl_scene_view_scene_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_view_scene(addr16, ep, group_id, scene_id, cb, user_data); - return ret; -} - -API int zb_zcl_scene_remove_scene(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short group_id, unsigned char scene_id, - zb_zcl_scene_remove_scene_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_remove_scene(addr16, ep, group_id, scene_id, cb, user_data); - return ret; -} - -API int zb_zcl_scene_remove_all_scene(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short group_id, zb_zcl_scene_remove_all_scene_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_remove_all_scene(addr16, ep, group_id, cb, user_data); - return ret; -} - -API int zb_zcl_scene_store_scene(zigbee_h handle, nwk_addr addr16, unsigned char ep, - unsigned short group_id, unsigned char scene_id, zb_zcl_scene_store_scene_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_store_scene(addr16, ep, group_id, scene_id, cb, user_data); - return ret; -} - -API int zb_zcl_scene_recall_scene(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short group_id, unsigned char scene_id) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_recall_scene(addr16, ep, group_id, scene_id); - return ret; -} - -API int zb_zcl_scene_get_scene_membership(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned short group_id, - zb_zcl_scene_get_scene_membership_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_get_scene_membership(addr16, ep, group_id, cb, user_data); - return ret; -} - diff --git a/lib/zbl-zcl-simple-metering.c b/lib/zbl-zcl-simple-metering.c deleted file mode 100644 index b5adaa1..0000000 --- a/lib/zbl-zcl-simple-metering.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_smetering_get_profile(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char interval_channel, unsigned char end_time, - unsigned char number_of_periods, zb_zcl_smetering_get_profile_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_smetering_request_mirror_rsp(zigbee_h handle, - nwk_addr addr16, unsigned char src_ep, unsigned short endpoint_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == src_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zcl_smetering_mirror_removed(zigbee_h handle, nwk_addr addr16, - unsigned char src_ep, unsigned short removed_endpoint_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == src_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - return ZIGBEE_ERROR_NONE; -} diff --git a/lib/zbl-zcl-thermostat.c b/lib/zbl-zcl-thermostat.c deleted file mode 100644 index 7b9c8ce..0000000 --- a/lib/zbl-zcl-thermostat.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zcl_thermostat_adjust_setpoint(zigbee_h handle, nwk_addr addr16, - unsigned char ep, unsigned char mode, unsigned char amount) -{ - int ret = ZIGBEE_ERROR_NONE; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(0x02 < mode, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - - ret = zbl_thermostat_adjust_setpoint(addr16, ep, mode, amount); - return ret; -} - diff --git a/lib/zbl-zcl.c b/lib/zbl-zcl.c deleted file mode 100644 index fcf8ac4..0000000 --- a/lib/zbl-zcl.c +++ /dev/null @@ -1,1558 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include - -#include "zbl.h" -#include "zb-log.h" -#include "zb-common.h" -#include "zcl/zb-zcl-type.h" - -API const char* zb_get_zcl_error_message(int id) -{ - const char* status_name = NULL; - - switch(id) { - case ZB_ZCL_SUCCESS: - status_name = "ZB_ZCL_SUCCESS"; - break; - case ZB_ZCL_FAILURE: - status_name = "ZB_ZCL_FAILURE"; - break; - case ZB_ZCL_NOT_AUTHORIZED: - status_name = "ZB_ZCL_NOT_AUTHORIZED"; - break; - case ZB_ZCL_RESERVED_FIELD_NOT_ZERO: - status_name = "ZB_ZCL_RESERVED_FIELD_NOT_ZERO"; - break; - case ZB_ZCL_MALFORMED_COMMAND: - status_name = "ZB_ZCL_MALFORMED_COMMAND"; - break; - case ZB_ZCL_UNSUP_CLUSTER_COMMAND: - status_name = "ZB_ZCL_UNSUP_CLUSTER_COMMAND"; - break; - case ZB_ZCL_UNSUP_GENERAL_COMMAND: - status_name = "ZB_ZCL_UNSUP_GENERAL_COMMAND"; - break; - case ZB_ZCL_UNSUP_MANUF_CLUSTER_COMMAND: - status_name = "ZB_ZCL_UNSUP_MANUF_CLUSTER_COMMAND"; - break; - case ZB_ZCL_UNSUP_MANUF_GENERAL_COMMAND: - status_name = "ZB_ZCL_UNSUP_MANUF_GENERAL_COMMAND"; - break; - case ZB_ZCL_INVALID_FIELD: - status_name = "ZB_ZCL_INVALID_FIELD"; - break; - case ZB_ZCL_UNSUPPORTED_ATTRIBUTE: - status_name = "ZB_ZCL_SUCCESS"; - break; - case ZB_ZCL_INVALID_VALUE: - status_name = "ZB_ZCL_INVALID_VALUE"; - break; - case ZB_ZCL_READ_ONLY: - status_name = "ZB_ZCL_READ_ONLY"; - break; - case ZB_ZCL_INSUFFICIENT_SPACE: - status_name = "ZB_ZCL_INSUFFICIENT_SPACE"; - break; - case ZB_ZCL_DUPLICATE_EXISTS: - status_name = "ZB_ZCL_INSUFFICIENT_SPACE"; - break; - case ZB_ZCL_NOT_FOUND: - status_name = "ZB_ZCL_NOT_FOUND"; - break; - case ZB_ZCL_UNREPORTABLE_ATTRIBUTE: - status_name = "ZB_ZCL_UNREPORTABLE_ATTRIBUTE"; - break; - case ZB_ZCL_INVALID_DATA_TYPE: - status_name = "ZB_ZCL_INVALID_DATA_TYPE"; - break; - case ZB_ZCL_INVALID_SELECTOR: - status_name = "ZB_ZCL_INVALID_SELECTOR"; - break; - case ZB_ZCL_WRITE_ONLY: - status_name = "ZB_ZCL_WRITE_ONLY"; - break; - case ZB_ZCL_INCONSISTENT_STARTUP_STATE: - status_name = "ZB_ZCL_INCONSISTENT_STARTUP_STATE"; - break; - case ZB_ZCL_DEFINED_OUT_OF_BAND: - status_name = "ZB_ZCL_DEFINED_OUT_OF_BAND"; - break; - case ZB_ZCL_INCONSISTENT: - status_name = "ZB_ZCL_INCONSISTENT"; - break; - case ZB_ZCL_ACTION_DENIED: - status_name = "ZB_ZCL_ACTION_DENIED"; - break; - case ZB_ZCL_TIMEOUT: - status_name = "ZB_ZCL_TIMEOUT"; - break; - case ZB_ZCL_ABORT: - status_name = "ZB_ZCL_ABORT"; - break; - case ZB_ZCL_INVALID_IMAGE: - status_name = "ZB_ZCL_INVALID_IMAGE"; - break; - case ZB_ZCL_WAIT_FOR_DATA: - status_name = "ZB_ZCL_WAIT_FOR_DATA"; - break; - case ZB_ZCL_NO_IMAGE_AVAILABLE: - status_name = "ZB_ZCL_NO_IMAGE_AVAILABLE"; - break; - case ZB_ZCL_REQUIRE_MORE_IMAGE: - status_name = "ZB_ZCL_REQUIRE_MORE_IMAGE"; - break; - default: - status_name = "ZB_ZCL_UNDEFINED"; - break; - } - - return status_name; -} - -API const char* zb_get_cluster_name(int id) -{ - const char* clust_name = NULL; - - switch (id) { - case ZB_ZCL_BASIC_CLUSTER_ID: - clust_name = "ZB_ZCL_BASIC"; - break; - case ZB_ZCL_POWER_CONFIG_CLUSTER_ID: - clust_name = "ZB_ZCL_POWER_CONFIG"; - break; - case ZB_ZCL_DEVICE_TEMP_CLUSTER_ID: - clust_name = "ZB_ZCL_DEVICE_TEMP"; - break; - case ZB_ZCL_IDENTIFY_CLUSTER_ID: - clust_name = "ZB_ZCL_IDENTIFY"; - break; - case ZB_ZCL_GROUPS_CLUSTER_ID: - clust_name = "ZB_ZCL_GROUPS"; - break; - case ZB_ZCL_SCENES_CLUSTER_ID: - clust_name = "ZB_ZCL_SCENES"; - break; - case ZB_ZCL_ON_OFF_CLUSTER_ID: - clust_name = "ZB_ZCL_ON_OFF"; - break; - case ZB_ZCL_ON_OFF_SWITCH_CONFIG_CLUSTER_ID: - clust_name = "ZB_ZCL_ON_OFF_SWITCH_CONFIG"; - break; - case ZB_ZCL_LEVEL_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_LEVEL_CONTROL"; - break; - case ZB_ZCL_ALARM_CLUSTER_ID: - clust_name = "ZB_ZCL_ALARM"; - break; - case ZB_ZCL_TIME_CLUSTER_ID: - clust_name = "ZB_ZCL_TIME"; - break; - case ZB_ZCL_RSSI_LOCATION_CLUSTER_ID: - clust_name = "ZB_ZCL_RSSI_LOCATION"; - break; - case ZB_ZCL_BINARY_INPUT_BASIC_CLUSTER_ID: - clust_name = "ZB_ZCL_BINARY_INPUT_BASIC"; - break; - case ZB_ZCL_COMMISSIONING_CLUSTER_ID: - clust_name = "ZB_ZCL_COMMISSIONING"; - break; - case ZB_ZCL_PARTITION_CLUSTER_ID: - clust_name = "ZB_ZCL_PARTITION"; - break; - case ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID: - clust_name = "ZB_ZCL_OTA_BOOTLOAD"; - break; - case ZB_ZCL_POWER_PROFILE_CLUSTER_ID: - clust_name = "ZB_ZCL_POWER_PROFILE"; - break; - case ZB_ZCL_APPLIANCE_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_APPLIANCE_CONTROL"; - break; - case ZB_ZCL_POLL_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_POLL_CONTROL"; - break; - case ZB_ZCL_SHADE_CONFIG_CLUSTER_ID: - clust_name = "ZB_ZCL_SHADE_CONFIG"; - break; - case ZB_ZCL_DOOR_LOCK_CLUSTER_ID: - clust_name = "ZB_ZCL_DOOR_LOCK"; - break; - case ZB_ZCL_WINDOW_COVERING_CLUSTER_ID: - clust_name = "ZB_ZCL_WINDOW_COVERING"; - break; - case ZB_ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_PUMP_CONFIG_CONTROL"; - break; - case ZB_ZCL_THERMOSTAT_CLUSTER_ID: - clust_name = "ZB_ZCL_THERMOSTAT"; - break; - case ZB_ZCL_FAN_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_FAN_CONTROL"; - break; - case ZB_ZCL_DEHUMID_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_DEHUMID_CONTROL"; - break; - case ZB_ZCL_THERMOSTAT_UI_CONFIG_CLUSTER_ID: - clust_name = "ZB_ZCL_THERMOSTAT_UI_CONFIG"; - break; - case ZB_ZCL_COLOR_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_COLOR_CONTROL"; - break; - case ZB_ZCL_BALLAST_CONFIGURATION_CLUSTER_ID: - clust_name = "ZB_ZCL_BALLAST_CONFIGURATION"; - break; - case ZB_ZCL_ILLUM_MEASUREMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_ILLUM_MEASUREMENT"; - break; - case ZB_ZCL_ILLUM_LEVEL_SENSING_CLUSTER_ID: - clust_name = "ZB_ZCL_ILLUM_LEVEL_SENSING"; - break; - case ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_TEMP_MEASUREMENT"; - break; - case ZB_ZCL_PRESSURE_MEASUREMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_PRESSURE_MEASUREMENT"; - break; - case ZB_ZCL_FLOW_MEASUREMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_FLOW_MEASUREMENT"; - break; - case ZB_ZCL_RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_RELATIVE_HUMIDITY_MEASUREMENT"; - break; - case ZB_ZCL_OCCUPANCY_SENSING_CLUSTER_ID: - clust_name = "ZB_ZCL_OCCUPANCY_SENSING"; - break; - case ZB_ZCL_IAS_ZONE_CLUSTER_ID: - clust_name = "ZB_ZCL_IAS_ZONE"; - break; - case ZB_ZCL_IAS_ACE_CLUSTER_ID: - clust_name = "ZB_ZCL_IAS_ACE"; - break; - case ZB_ZCL_IAS_WD_CLUSTER_ID: - clust_name = "ZB_ZCL_IAS_WD"; - break; - case ZB_ZCL_GENERIC_TUNNEL_CLUSTER_ID: - clust_name = "ZB_ZCL_GENERIC_TUNNEL"; - break; - case ZB_ZCL_BACNET_PROTOCOL_TUNNEL_CLUSTER_ID: - clust_name = "ZB_ZCL_BACNET_PROTOCOL_TUNNEL"; - break; - case ZB_ZCL_11073_PROTOCOL_TUNNEL_CLUSTER_ID: - clust_name = "ZB_ZCL_11073_PROTOCOL_TUNNEL"; - break; - case ZB_ZCL_ISO7816_PROTOCOL_TUNNEL_CLUSTER_ID: - clust_name = "ZB_ZCL_ISO7816_PROTOCOL_TUNNEL"; - break; - case ZB_ZCL_PRICE_CLUSTER_ID: - clust_name = "ZB_ZCL_PRICE"; - break; - case ZB_ZCL_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_DEMAND_RESPONSE_LOAD_CONTROL"; - break; - case ZB_ZCL_SIMPLE_METERING_CLUSTER_ID: - clust_name = "ZB_ZCL_SIMPLE_METERING"; - break; - case ZB_ZCL_MESSAGING_CLUSTER_ID: - clust_name = "ZB_ZCL_MESSAGING"; - break; - case ZB_ZCL_TUNNELING_CLUSTER_ID: - clust_name = "ZB_ZCL_TUNNELING"; - break; - case ZB_ZCL_PREPAYMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_PREPAYMENT"; - break; - case ZB_ZCL_ENERGY_MANAGEMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_ENERGY_MANAGEMENT"; - break; - case ZB_ZCL_TOU_CALENDAR_CLUSTER_ID: - clust_name = "ZB_ZCL_TOU_CALENDAR"; - break; - case ZB_ZCL_DEVICE_MANAGEMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_DEVICE_MANAGEMENT8"; - break; - case ZB_ZCL_EVENTS_CLUSTER_ID: - clust_name = "ZB_ZCL_EVENTS"; - break; - case ZB_ZCL_MDU_PAIRING_CLUSTER_ID: - clust_name = "ZB_ZCL_MDU_PAIRING"; - break; - case ZB_ZCL_KEY_ESTABLISHMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_KEY_ESTABLISHMENT"; - break; - case ZB_ZCL_INFORMATION_CLUSTER_ID: - clust_name = "ZB_ZCL_INFORMATION"; - break; - case ZB_ZCL_DATA_SHARING_CLUSTER_ID: - clust_name = "ZB_ZCL_DATA_SHARING"; - break; - case ZB_ZCL_GAMING_CLUSTER_ID: - clust_name = "ZB_ZCL_GAMING"; - break; - case ZB_ZCL_DATA_RATE_CONTROL_CLUSTER_ID: - clust_name = "ZB_ZCL_DATA_RATE_CONTROL"; - break; - case ZB_ZCL_VOICE_OVER_ZIGBEE_CLUSTER_ID: - clust_name = "ZB_ZCL_VOICE_OVER_ZIGBEE"; - break; - case ZB_ZCL_CHATTING_CLUSTER_ID: - clust_name = "ZB_ZCL_CHATTING"; - break; - case ZB_ZCL_PAYMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_PAYMENT"; - break; - case ZB_ZCL_BILLING_CLUSTER_ID: - clust_name = "ZB_ZCL_BILLING"; - break; - case ZB_ZCL_APPLIANCE_IDENTIFICATION_CLUSTER_ID: - clust_name = "ZB_ZCL_APPLIANCE_IDENTIFICATION"; - break; - case ZB_ZCL_METER_IDENTIFICATION_CLUSTER_ID: - clust_name = "ZB_ZCL_DATA_RATE_CONTROL"; - break; - case ZB_ZCL_APPLIANCE_EVENTS_AND_ALERT_CLUSTER_ID: - clust_name = "ZB_ZCL_APPLIANCE_EVENTS_AND_ALERT"; - break; - case ZB_ZCL_APPLIANCE_STATISTICS_CLUSTER_ID: - clust_name = "ZB_ZCL_APPLIANCE_STATISTICS"; - break; - case ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID: - clust_name = "ZB_ZCL_ELECTRICAL_MEASUREMENT"; - break; - case ZB_ZCL_DIAGNOSTICS_CLUSTER_ID: - clust_name = "ZB_ZCL_DIAGNOSTICS"; - break; - case ZB_ZCL_ZLL_COMMISSIONING_CLUSTER_ID: - clust_name = "ZB_ZCL_ZLL_COMMISSIONING0"; - break; - default: - clust_name = "UNDEFINED_CLUSTER"; - break; - } - - return clust_name; -} - -typedef struct _attr_type_size { - unsigned char type; - unsigned char size; -} AttrTypeSize; - -static AttrTypeSize attribute_sizes[] = { - {ZB_ZCL_NO_DATA_ATTRIBUTE_TYPE, 0}, - {ZB_ZCL_8_BIT_DATA, 1}, - {ZB_ZCL_16_BIT_DATA, 2}, - {ZB_ZCL_24_BIT_DATA, 3}, - {ZB_ZCL_32_BIT_DATA, 4}, - {ZB_ZCL_40_BIT_DATA, 5}, - {ZB_ZCL_48_BIT_DATA, 6}, - {ZB_ZCL_56_BIT_DATA, 7}, - {ZB_ZCL_64_BIT_DATA, 8}, - {ZB_ZCL_BOOLEAN, 1}, - {ZB_ZCL_8_BIT_BITMAP, 1}, - {ZB_ZCL_16_BIT_BITMAP, 2}, - {ZB_ZCL_24_BIT_BITMAP, 3}, - {ZB_ZCL_32_BIT_BITMAP, 4}, - {ZB_ZCL_40_BIT_BITMAP, 5}, - {ZB_ZCL_48_BIT_BITMAP, 6}, - {ZB_ZCL_56_BIT_BITMAP, 7}, - {ZB_ZCL_64_BIT_BITMAP, 8}, - {ZB_ZCL_UNSIGNED_8_BIT_INTEGER, 1}, - {ZB_ZCL_UNSIGNED_16_BIT_INTEGER, 2}, - {ZB_ZCL_UNSIGNED_24_BIT_INTEGER, 3}, - {ZB_ZCL_UNSIGNED_32_BIT_INTEGER, 4}, - {ZB_ZCL_UNSIGNED_40_BIT_INTEGER, 5}, - {ZB_ZCL_UNSIGNED_48_BIT_INTEGER, 6}, - {ZB_ZCL_UNSIGNED_56_BIT_INTEGER, 7}, - {ZB_ZCL_UNSIGNED_64_BIT_INTEGER, 8}, - {ZB_ZCL_SIGNED_8_BIT_INTEGER, 1}, - {ZB_ZCL_SIGNED_16_BIT_INTEGER, 2}, - {ZB_ZCL_SIGNED_24_BIT_INTEGER, 3}, - {ZB_ZCL_SIGNED_32_BIT_INTEGER, 4}, - {ZB_ZCL_SIGNED_40_BIT_INTEGER, 5}, - {ZB_ZCL_SIGNED_48_BIT_INTEGER, 6}, - {ZB_ZCL_SIGNED_56_BIT_INTEGER, 7}, - {ZB_ZCL_SIGNED_64_BIT_INTEGER, 8}, - {ZB_ZCL_8_BIT_ENUMERATION, 1}, - {ZB_ZCL_16_BIT_ENUMERATION, 2}, - {ZB_ZCL_SEMI_PRECISION, 2}, - {ZB_ZCL_SINGLE_PRECISION, 4}, - {ZB_ZCL_DOUBLE_PRECISION, 8}, - {ZB_ZCL_TIME_OF_DAY, 4}, - {ZB_ZCL_DATE, 4}, - {ZB_ZCL_UTC_TIME, 4}, - {ZB_ZCL_CLUSTER_ID, 2}, - {ZB_ZCL_ATTRIBUTE_ID, 2}, - {ZB_ZCL_BACNET_OID, 4}, - {ZB_ZCL_IEEE_ADDRESS, 8}, - {ZB_ZCL_128_BIT_SECURITY_KEY, 16}, -}; - -static unsigned char analog_discrete_thresholds[] = { - 0x07, DATA_TYPE_NONE, - 0x1F, DATA_TYPE_DISCRETE, - 0x2F, DATA_TYPE_ANALOG, - 0x37, DATA_TYPE_DISCRETE, - 0x3F, DATA_TYPE_ANALOG, - 0x57, DATA_TYPE_DISCRETE, - 0xDF, DATA_TYPE_NONE, - 0xE7, DATA_TYPE_ANALOG, - 0xFF, DATA_TYPE_NONE -}; - -API int zb_get_analog_or_discret(unsigned char type) -{ - int index = 0; - - while (analog_discrete_thresholds[index] < type) - index += 2; - - return analog_discrete_thresholds[index+1]; -} - -API int zb_get_data_size(unsigned char type) -{ - int i; - int count = (int)(sizeof(attribute_sizes) / 2); - for (i = 0; i < count; i++) { - if (attribute_sizes[i].type == type) - return attribute_sizes[i].size; - } - return -1; -} - -API int zb_create_read_attr_status_record(read_attr_status_record_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - read_attr_status_record_h simple = calloc(1, sizeof(struct read_attribute_status_record_s)); - RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = simple; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_read_attr_status_record(read_attr_status_record_h handle) -{ - RET_IF(NULL == handle); - if (handle->value) - free(handle->value); - free(handle); -} - -API int zb_get_id_from_read_attr_status_record(read_attr_status_record_h handle, - unsigned short* id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); - *id = handle->id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_id_to_read_attr_status_record(read_attr_status_record_h handle, - unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_status_from_read_attr_status_record(read_attr_status_record_h handle, - unsigned char* status) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER); - *status = handle->status; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_status_to_read_attr_status_record(read_attr_status_record_h handle, - unsigned char status) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->status = status; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_type_from_read_attr_status_record(read_attr_status_record_h handle, - unsigned char *type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); - *type = handle->type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_type_to_read_attr_status_record(read_attr_status_record_h handle, - unsigned char type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->type = type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_value_from_read_attr_status_record(read_attr_status_record_h handle, - unsigned char type, zb_value_h value) -{ - int len = -1; - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_NO_DATA); - - len = zb_get_data_size(type); - if (0 < len) { - memcpy(value->val, handle->value, len); - value->size = len; - value->type = type; - } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) { - if (value->str) { - if (value->str->v) - free(value->str->v); - free(value->str); - } - value->str = calloc(1, sizeof(struct attribute_str_s)); - RETV_IF(NULL == value->str, ZIGBEE_ERROR_OUT_OF_MEMORY); - value->str->n = *handle->value; - /* The first 1 byte indicate invalid or length of string */ - if (0xff == value->str->n) { - free(value->str); - return ZIGBEE_ERROR_NO_DATA; - } - value->str->v = calloc(value->str->n+1, 1); - if (NULL == value->str->v) { - free(value->str); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - memcpy(value->str->v, handle->value+sizeof(value->str->n), value->str->n); - - value->type = type; - value->size = value->str->n; - } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) { - if (value->wstr) { - if (value->wstr->v) - free(value->wstr->v); - free(value->wstr); - } - value->wstr = calloc(1, sizeof(struct attribute_wstr_s)); - RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY); - value->wstr->n = *(handle->value+1) << 8 | *handle->value; - /* The first 2 byte indicate invalid or length of string */ - if (0xffff == value->wstr->n) { - free(value->wstr); - return ZIGBEE_ERROR_NO_DATA; - } - value->wstr->v = calloc(value->wstr->n+1, 1); - if (NULL == value->wstr->v) { - free(value->wstr); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - memcpy(value->wstr->v, handle->value+sizeof(value->wstr->n), value->wstr->n); - - value->type = type; - value->size = value->wstr->n; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_value_to_read_attr_status_record(read_attr_status_record_h handle, - unsigned char type, zb_value_h value) -{ - int len = -1; - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - - if (handle->value) - free(handle->value); - - len = zb_get_data_size(type); - if (0 < len) { - handle->value = calloc(len, sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - memcpy(handle->value, value->val, len); - } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) { - RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA); - handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - handle->value[0] = value->str->n; - memcpy(handle->value + sizeof(value->str->n), - value->str->v+sizeof(value->str->n), value->str->n); - } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) { - RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA); - handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - handle->value[0] = value->wstr->n & 0xff; - handle->value[1] = (value->wstr->n >> 8) & 0xff ; - memcpy(handle->value + sizeof(value->wstr->n), - value->wstr->v+sizeof(value->wstr->n), value->wstr->n); - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_create_value(zb_value_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - zb_value_h simple = calloc(1, sizeof(struct zb_value_s)); - RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = simple; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_value(zb_value_h handle) -{ - RET_IF(NULL == handle); - if (handle->str) { - if (handle->str->v) - free(handle->str->v); - free(handle->str); - } - if (handle->wstr) { - if (handle->wstr->v) - free(handle->wstr->v); - free(handle->wstr); - } - free(handle); -} - -API int zb_set_value(zb_value_h handle, unsigned char type, unsigned char *value, - int count) -{ - int len = -1; - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - - len = zb_get_data_size(type); - if (0 < len) { - memcpy(handle->val, value, len); - handle->size = len; - handle->type = type; - } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) { - if (handle->str) { - if (handle->str->v) - free(handle->str->v); - free(handle->str); - } - /* string size exception case */ - RETV_IF(0xff - 1 < handle->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->str = malloc(sizeof(struct attribute_str_s)); - RETV_IF(NULL == handle->str, ZIGBEE_ERROR_OUT_OF_MEMORY); - handle->str->n = count; - /* The first 1 byte indicate invalid or length of string */ - handle->str->v = calloc(sizeof(unsigned char), handle->str->n + sizeof(handle->str->n)); - RETV_IF(NULL == handle->str->v, ZIGBEE_ERROR_OUT_OF_MEMORY); - memcpy(handle->str->v, value+sizeof(handle->str->n), handle->str->n); - - handle->type = type; - handle->size = count; - } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) { - if (handle->wstr) { - if (handle->wstr->v) - free(handle->wstr->v); - free(handle->wstr); - } - /* 2 byte string size exception case */ - RETV_IF(0xffff - 1 < handle->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->wstr = malloc(sizeof(struct attribute_wstr_s)); - RETV_IF(NULL == handle->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY); - handle->wstr->n = count; - /* The first 2 byte indicate invalid or length of string */ - handle->wstr->v = calloc(sizeof(unsigned char), handle->wstr->n + sizeof(handle->wstr->n)); - RETV_IF(NULL == handle->wstr->v, ZIGBEE_ERROR_OUT_OF_MEMORY); - memcpy(handle->wstr->v, value+sizeof(handle->wstr->n), handle->wstr->n); - - handle->type = type; - handle->size = count; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_value(zb_value_h handle, unsigned char *type, unsigned char **value, - int *count) -{ - int len = -1; - unsigned char *s = NULL; - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - - len = zb_get_data_size(handle->type); - if (0 < len) { - s = calloc(handle->size + 1 , sizeof(char)); - memcpy(s, handle->val, len); - *count = len; - } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { - RETV_IF(NULL == handle->str, ZIGBEE_ERROR_NO_DATA); - s = calloc(sizeof(unsigned char), handle->str->n); - RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY); - memcpy(s, handle->str->v+sizeof(handle->str->n), handle->str->n); - *count = handle->str->n; - } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { - RETV_IF(NULL == handle->wstr, ZIGBEE_ERROR_NO_DATA); - s = calloc(sizeof(unsigned char), handle->wstr->n); - RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY); - memcpy(s, handle->wstr->v+sizeof(handle->wstr->n), handle->wstr->n); - *count = handle->wstr->n; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - *type = handle->type; - *value = s; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_create_discover_attr_info(discover_attr_info_record_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - discover_attr_info_record_h simple = calloc(1, - sizeof(struct discover_attribute_info_record_s)); - RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = simple; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_discover_attr_info(discover_attr_info_record_h handle) -{ - free(handle); -} - -API int zb_get_id_from_discover_attr_info( - discover_attr_info_record_h handle, - unsigned short *id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); - *id = handle->id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_id_to_discover_attr_info( - discover_attr_info_record_h handle, - unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_type_from_discover_attr_info( - discover_attr_info_record_h handle, - unsigned char *type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); - *type = handle->type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_type_to_discover_attr_info( - discover_attr_info_record_h handle, - unsigned char type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->type = type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_create_write_attr_record( - write_attr_record_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - write_attr_record_h t = calloc(1, sizeof(struct write_attribute_record_s)); - RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = t; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_write_attr_record(write_attr_record_h handle) -{ - RET_IF(NULL == handle); - if (handle->value) - free(handle->value); - free(handle); -} - -API int zb_set_id_to_write_attr_record(write_attr_record_h handle, - unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_type_to_write_attr_record(write_attr_record_h handle, - unsigned char type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->type = type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_buf_to_write_attr_record(write_attr_record_h handle, - unsigned char type, unsigned char *value, int count) -{ - int len = -1; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - - if (handle->value) - free(handle->value); - - len = zb_get_data_size(type); - if (0 < len) { - handle->value = calloc(count + 1 , sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - memcpy(handle->value, value, count); - } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) { - handle->value = calloc(count + sizeof(unsigned char) + 1, sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - /* The first 1 byte indicate invalid or length of string */ - handle->value[0] = count & 0xff; - memcpy(handle->value + sizeof(unsigned char), value + sizeof(unsigned char), count); - } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) { - handle->value = calloc(count + sizeof(unsigned short) + 1, sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - /* The first 2 byte indicate invalid or length of string */ - handle->value[0] = count & 0xff; - handle->value[1] = (count >> 8) & 0xff ; - memcpy(handle->value + sizeof(unsigned short), value + sizeof(unsigned short), count); - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_value_to_write_attr_record(write_attr_record_h handle, zb_value_h value) -{ - int len = -1; - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - - if (handle->value) - free(handle->value); - - len = zb_get_data_size(value->type); - if (0 < len) { - handle->value = calloc(value->size + 1 , sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - memcpy(handle->value, value->val, value->size); - handle->type = value->type; - } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { - RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA); - /* 1 byte string size exception case */ - RETV_IF(0xff - 1 < value->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - /* The first 1 byte indicate invalid or length of string */ - handle->value[0] = value->str->n & 0xff; - memcpy(handle->value + sizeof(value->str->n), - value->str->v + sizeof(value->str->n), value->str->n); - } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) { - RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA); - /* 2 byte string size exception case */ - RETV_IF(0xffff - 1 < value->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - /* The first 2 byte indicate invalid or length of string */ - handle->value[0] = value->wstr->n & 0xff; - handle->value[1] = (value->wstr->n >> 8) & 0xff ; - memcpy(handle->value + sizeof(value->wstr->n), - value->wstr->v + sizeof(value->wstr->n), value->wstr->n); - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_create_write_attr_status(write_attr_status_record_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - write_attr_status_record_h simple = calloc(1, - sizeof(struct write_attribute_status_record_s)); - RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = simple; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_write_attr_status(write_attr_status_record_h handle) -{ - free(handle); -} - -API int zb_get_status_from_write_attr_status(write_attr_status_record_h handle, - unsigned char *status) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER); - *status = handle->status; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_status_to_write_attr_status(write_attr_status_record_h handle, - unsigned char status) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->status = status; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_id_from_write_attr_status(write_attr_status_record_h handle, - unsigned short *id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); - *id = handle->id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_id_to_write_attr_status(write_attr_status_record_h handle, - unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_create_report_config_record(report_config_record_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - report_config_record_h t; - t = calloc(1, sizeof(struct reporting_configuration_record_s)); - RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = t; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_report_config_record(report_config_record_h handle) -{ - RET_IF(NULL == handle); - if (handle->change) - free(handle->change); - free(handle); -} - -API int zb_get_dir_from_report_config_record(report_config_record_h handle, - unsigned char *dir) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER); - *dir = handle->dir; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_dir_to_report_config_record(report_config_record_h handle, - unsigned char dir) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - if (dir == ZB_ZCL_CLIENT_TO_SERVER) - handle->dir = 0x00 ; - else - handle->dir = 0x01; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_id_from_report_config_record(report_config_record_h handle, - unsigned short *id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); - *id = handle->id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_id_to_report_config_record(report_config_record_h handle, - unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id ; - return ZIGBEE_ERROR_NONE; -} - - -API int zb_get_type_from_report_config_record(report_config_record_h handle, - unsigned char *type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); - *type = handle->type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_type_to_report_config_record(report_config_record_h handle, - unsigned char type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->type = type; - return ZIGBEE_ERROR_NONE; -} - - -API int zb_get_min_i_from_report_config_record(report_config_record_h handle, - unsigned short *min_i) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == min_i, ZIGBEE_ERROR_INVALID_PARAMETER); - *min_i = handle->min_i; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_min_i_to_report_config_record(report_config_record_h handle, - unsigned short min_i) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->min_i = min_i; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_max_i_from_report_config_record(report_config_record_h handle, - unsigned short *max_i) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == max_i, ZIGBEE_ERROR_INVALID_PARAMETER); - *max_i = handle->max_i; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_max_i_to_report_config_record(report_config_record_h handle, - unsigned short max_i) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->max_i = max_i; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_timeout_from_report_config_record(report_config_record_h handle, - unsigned short *to) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == to, ZIGBEE_ERROR_INVALID_PARAMETER); - *to = handle->to; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_timeout_to_report_config_record(report_config_record_h handle, - unsigned short to) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->to = to; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_change_from_report_config_record1(report_config_record_h handle, - zb_value_h value) -{ - int len = -1; - int data_type = DATA_TYPE_NONE; - - NOT_USED(data_type); - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA); - - len = zb_get_data_size(handle->type); - data_type = zb_get_analog_or_discret(handle->type); - if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { - memcpy(value->val, handle->change, len); - value->type = handle->type; - value->size = len; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_change_to_report_config_record1(report_config_record_h handle, - zb_value_h value) -{ - int len = -1; - int data_type = DATA_TYPE_NONE; - - NOT_USED(data_type); - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - - if (handle->change) - free(handle->change); - - len = zb_get_data_size(value->type); - data_type = zb_get_analog_or_discret(value->type); - if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { - handle->change = calloc(len + 1, sizeof(char)); - RETVM_IF(NULL == handle->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - memcpy(handle->change, value->val, len); - handle->type = value->type; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_change_from_report_config_record2(report_config_record_h handle, - unsigned char *type, unsigned char **value, int *size) -{ - int len = -1; - int data_type = DATA_TYPE_NONE; - unsigned char *t = NULL; - - NOT_USED(data_type); - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA); - - len = zb_get_data_size(handle->type); - data_type = zb_get_analog_or_discret(handle->type); - if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { - t = calloc(len + 1, sizeof(char)); - RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - memcpy(t, handle->change, len); - *value = t; - *type = handle->type; - *size = len; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} -API int zb_set_change_to_report_config_record2( - report_config_record_h handle, unsigned char type, unsigned char *value) -{ - int len = -1; - int data_type = DATA_TYPE_NONE; - - NOT_USED(data_type); - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - if (handle->change) - free(handle->change); - - len = zb_get_data_size(type); - data_type = zb_get_analog_or_discret(type); - - if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { - handle->change = calloc(len + 1, sizeof(unsigned char)); - RETVM_IF(NULL == handle->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - memcpy(handle->change, value, len); - handle->type = type; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_change_from_report_config_record3(report_config_record_h handle, - unsigned char *type, unsigned char *value, int *size) -{ - int len = -1; - int data_type = DATA_TYPE_NONE; - - NOT_USED(data_type); - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA); - - len = zb_get_data_size(handle->type); - data_type = zb_get_analog_or_discret(handle->type); - if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { - memcpy(value, handle->change, len); - *type = handle->type; - *size = len; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_create_read_report_config_record(read_report_config_record_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - read_report_config_record_h t = - calloc(1, sizeof(struct read_reporting_configuration_record_s)); - RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = t; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_read_report_config_record(read_report_config_record_h handle) -{ - free(handle); -} - -API int zb_set_dir_to_read_report_config_record(read_report_config_record_h handle, - unsigned char dir) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - if (dir == ZB_ZCL_CLIENT_TO_SERVER) - handle->dir = 0x00; - else - handle->dir = 0x01; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_dir_from_read_report_config_record(read_report_config_record_h handle, - unsigned char *dir) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - *dir = handle->dir; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_id_to_read_report_config_record(read_report_config_record_h handle, - unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_id_from_read_report_config_record(read_report_config_record_h handle, - unsigned short *id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - *id = handle->id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_create_report_config_response_record( - report_config_response_record_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - report_config_response_record_h t = - calloc(1, sizeof(struct reporting_configuration_response_record_s)); - RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = t; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_report_config_response_record( - report_config_response_record_h handle) -{ - free(handle); -} - -API int zb_get_status_from_report_config_response_record( - report_config_response_record_h handle, unsigned char *status) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER); - *status = handle->status; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_status_to_report_config_response_record( - report_config_response_record_h handle, unsigned char status) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->status = status; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_dir_from_report_config_response_record( - report_config_response_record_h handle, unsigned char *dir) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER); - *dir = handle->dir; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_dir_to_report_config_response_record( - report_config_response_record_h handle, unsigned char dir) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->dir = handle->dir; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_id_from_report_config_response_record( - report_config_response_record_h handle, unsigned short *id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); - *id = handle->id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_id_to_report_config_response_record( - report_config_response_record_h handle, unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_create_attr_report(attr_report_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - attr_report_h t = calloc(1, sizeof(struct attribute_report_s)); - RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = t; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_attr_report(attr_report_h handle) -{ - if (handle) { - if (handle->value) - free(handle->value); - free(handle); - } -} - -API int zb_get_id_from_attr_report(attr_report_h handle, unsigned short *id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); - *id = handle->id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_id_to_attr_report(attr_report_h handle, unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_type_from_attr_report(attr_report_h handle, unsigned char *type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); - *type = handle->type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_type_to_attr_report(attr_report_h handle, unsigned char type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->type = type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_value_from_attr_report(attr_report_h handle, zb_value_h value) -{ - int len = -1; - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_NO_DATA); - - len = zb_get_data_size(handle->type); - if (0 < len) { - memcpy(value->val, handle->value, len); - value->size = len; - value->type = handle->type; - } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { - if (value->str) { - if (value->str->v) - free(value->str->v); - free(value->str); - } - value->str = calloc(1, sizeof(struct attribute_str_s)); - RETV_IF(NULL == value->str, ZIGBEE_ERROR_OUT_OF_MEMORY); - value->str->n = *handle->value; - /* The first 1 byte indicate invalid or length of string */ - if (0xff == value->str->n) { - free(value->str); - return ZIGBEE_ERROR_NO_DATA; - } - value->str->v = calloc(value->str->n+1, 1); - if (NULL == value->str->v) { - free(value->str); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - memcpy(value->str->v, handle->value+sizeof(value->str->n), value->str->n); - - value->type = handle->type; - value->size = value->str->n; - } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) { - if (value->wstr) { - if (value->wstr->v) - free(value->wstr->v); - free(value->wstr); - } - value->wstr = calloc(1, sizeof(struct attribute_wstr_s)); - RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY); - value->wstr->n = *(handle->value+1) << 8 | *handle->value; - /* The first 2 byte indicate invalid or length of string */ - if (0xffff == value->wstr->n) { - free(value->wstr); - return ZIGBEE_ERROR_NO_DATA; - } - value->wstr->v = calloc(value->wstr->n+1, 1); - if (NULL == value->wstr->v) { - free(value->wstr); - return ZIGBEE_ERROR_OUT_OF_MEMORY; - } - memcpy(value->wstr->v, handle->value+sizeof(value->wstr->n), value->wstr->n); - - value->type = handle->type; - value->size = value->wstr->n; - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_value_to_attr_report(attr_report_h handle, zb_value_h value) -{ - int len = -1; - - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); - - if (handle->value) - free(handle->value); - - len = zb_get_data_size(value->type); - if (0 < len) { - handle->value = calloc(value->size + 1 , sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - memcpy(handle->value, value->val, value->size); - handle->type = value->type; - } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { - RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA); - handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - /* The first 1 byte indicate invalid or length of string */ - handle->value[0] = value->str->n & 0xff; - memcpy(handle->value + sizeof(value->str->n), - value->str->v + sizeof(value->str->n), value->str->n); - } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) { - RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA); - handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char)); - RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); - /* The first 2 byte indicate invalid or length of string */ - handle->value[0] = value->wstr->n & 0xff; - handle->value[1] = (value->wstr->n >> 8) & 0xff ; - memcpy(handle->value + sizeof(value->wstr->n), - value->wstr->v + sizeof(value->wstr->n), value->wstr->n); - } else - return ZIGBEE_ERROR_NOT_SUPPORTED; - - return ZIGBEE_ERROR_NONE; -} - - -/** - * @brief Figure 2.33 Format of the Selector Field - * - * @since_tizen 3.0 - */ -struct selector_s { - unsigned char indicator; /**< number of index */ - unsigned short *index; /**< index list */ -}; - -/** - * @brief stcuture for reading attribute - * - * @since_tizen 3.0 - */ -struct read_structured_attribute_record_s { - unsigned short id; /**< attribute identifier */ - struct selector_s *selector; /**< selector format */ -}; - -/** - * @brief Figure 2.11 Format of the Write Attribute Record Field - * - * @since_tizen 3.0 - */ -struct write_attribute_structured_status_record_s { - unsigned char status; /**< status */ - unsigned short id; /**< identifier */ - struct selector_s selector; /**< selector */ -}; - -/** - * @brief Figure 2.32 Format of the Write Attribute Record Field - * - * @since_tizen 3.0 - */ -struct write_attribute_structured_record_s { - unsigned short id; /**< attribute identifier */ - struct selector_s selector; - unsigned char type; /**< attribute data type */ - unsigned char *value; /**< data value */; /**< attribute value */ -}; - -API int zb_create_extended_attr_info(extended_attr_info_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - extended_attr_info_h t = calloc(1, sizeof(struct extended_attribute_infomation_s)); - RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = t; - return ZIGBEE_ERROR_NONE; -} - -API void zb_destroy_extended_attr_info(extended_attr_info_h handle) -{ - free(handle); -} - -API int zb_get_id_from_extended_attr_info(extended_attr_info_h handle, - unsigned short *id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); - *id = handle->id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_id_to_extended_attr_info(extended_attr_info_h handle, - unsigned short id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->id = id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_type_from_extended_attr_info(extended_attr_info_h handle, - unsigned char *type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); - *type = handle->type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_type_to_extended_attr_info(extended_attr_info_h handle, - unsigned char type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->type = type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_acl_from_extended_attr_info(extended_attr_info_h handle, - unsigned char *acl) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == acl, ZIGBEE_ERROR_INVALID_PARAMETER); - *acl = handle->acl; - return ZIGBEE_ERROR_NONE; -} - -API int zb_set_acl_to_extended_attr_info(extended_attr_info_h handle, - unsigned char acl) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->acl = acl; - return ZIGBEE_ERROR_NONE; -} - diff --git a/lib/zbl-zdo-bind-mgr.c b/lib/zbl-zdo-bind-mgr.c deleted file mode 100644 index 147aa6d..0000000 --- a/lib/zbl-zdo-bind-mgr.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - -#include "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zdo_bind_req(zigbee_h handle, nwk_addr dst_addr16, - ieee_addr src_addr64, unsigned char src_ep, unsigned short cluster_id, - ieee_addr dst_addr64, unsigned char type, nwk_addr group_addr, - unsigned char dst_ep, zb_zdo_bind_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_bind_req(dst_addr16, src_addr64, src_ep, cluster_id, dst_addr64, type, - group_addr, dst_ep, cb, user_data); - return ret; -} - -API int zb_zdo_unbind_req(zigbee_h handle, nwk_addr dst_addr16, - ieee_addr src_addr64, unsigned char src_ep, unsigned short cluster_id, - ieee_addr dst_addr64, unsigned char type, nwk_addr group_addr, - unsigned char dst_ep, zb_zdo_unbind_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - ret = zbl_unbind_req(dst_addr16, src_addr64, src_ep, cluster_id, dst_addr64, type, - group_addr, dst_ep, cb, user_data); - return ret; -} diff --git a/lib/zbl-zdo-dev-disc.c b/lib/zbl-zdo-dev-disc.c deleted file mode 100644 index 64a0ebb..0000000 --- a/lib/zbl-zdo-dev-disc.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - -#include "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zdo_nwk_addr_req(zigbee_h handle, ieee_addr addr64, - unsigned char request_type, unsigned char start_idx, zb_zdo_addr_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 != request_type && 1 != request_type, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_nwk_addr_req(handle, addr64, request_type, start_idx, cb, - user_data); - return ret; -} - -API int zb_zdo_ieee_addr_req(zigbee_h handle, nwk_addr addr16, zb_zdo_addr_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_ieee_addr_req(handle, addr16, cb, user_data); - return ret; -} - -API int zb_zdo_active_ep(zigbee_h handle, nwk_addr addr16, zb_zdo_active_ep_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_active_ep(handle, addr16, cb, user_data); - return ret; -} - -API int zb_zdo_simple_desc_req(zigbee_h handle, nwk_addr addr16, unsigned char ep, - zb_zdo_simple_desc_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_simple_desc_req(handle, addr16, ep, cb, user_data); - return ret; -} - -#ifdef ZB_SUPPORT_PRIORITY_5 -API int zb_zdo_extended_simple_desc_req(zigbee_h handle, nwk_addr addr16, - unsigned char start_idx, zb_zdo_extended_simple_desc_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - return ZIGBEE_ERROR_NONE; -} -#endif /* ZB_SUPPORT_PRIORITY_5 */ - -API int zb_zdo_match_desc_req(zigbee_h handle, nwk_addr addr16, - unsigned short profile_id, unsigned char num_in_clusters, - unsigned short *in_clusters, unsigned char num_out_clusters, - unsigned short *out_clusters, zb_zdo_match_desc_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == num_in_clusters && 0 == num_out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_match_desc_req(handle, addr16, profile_id, num_in_clusters, - in_clusters, num_out_clusters, out_clusters, cb, user_data); - return ret; -} - -API int zb_zdo_node_desc_req(zigbee_h handle, nwk_addr addr16, - zb_zdo_node_desc_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_node_desc_req(addr16, cb, user_data); - return ret; -} - -API int zb_zdo_power_desc_req(zigbee_h handle, nwk_addr addr16, - zb_zdo_power_desc_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_power_desc_req(addr16, cb, user_data); - return ret; -} - -API int zb_zdo_complex_desc_req(zigbee_h handle, nwk_addr addr16, - zb_zdo_complex_desc_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_complex_desc_req(addr16, cb, user_data); - return ret; -} - -API int zb_zdo_user_desc_req(zigbee_h handle, nwk_addr addr16, - zb_zdo_user_desc_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_user_desc_req(addr16, cb, user_data); - return ret; -} - -API int zb_zdo_user_desc_set(zigbee_h handle, nwk_addr addr16, unsigned char len, - unsigned char *user_desc, zb_zdo_user_desc_conf cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == user_desc, ZIGBEE_ERROR_INVALID_PARAMETER); - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_device_annce(zigbee_h handle, nwk_addr addr16, ieee_addr addr64, - unsigned char capability) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - ret = zbl_device_annce(handle, addr16, addr64, capability); - return ret; -} - diff --git a/lib/zbl-zdo-nwk-mgr.c b/lib/zbl-zdo-nwk-mgr.c deleted file mode 100644 index dfd097b..0000000 --- a/lib/zbl-zdo-nwk-mgr.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - -#include "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -API int zb_zdo_mgmt_nwk_disc_req(zigbee_h handle, nwk_addr addr16, - unsigned int scan_channels, unsigned char scan_duration, unsigned char scan_count, - unsigned char start_idx, zb_zdo_mgmt_nwk_disc_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - ret = zbl_mgmt_nwk_disc_req(addr16, scan_channels, scan_duration, scan_count, - start_idx, cb, user_data); - return ret; -} - -API int zb_zdo_mgmt_lqi_req(zigbee_h handle, nwk_addr addr16, - unsigned char start_idx, zb_zdo_mgmt_lqi_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - ret = zbl_mgmt_lqi_req(addr16, start_idx, cb, user_data); - return ret; -} - -API int zb_zdo_mgmt_rtg_req(zigbee_h handle, nwk_addr addr16, - unsigned char start_idx, zb_zdo_mgmt_rtg_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - ret = zbl_mgmt_rtg_req(addr16, start_idx, cb, user_data); - return ret; -} - -API int zb_zdo_mgmt_bind_req(zigbee_h handle, nwk_addr addr16, - unsigned char start_idx, zb_zdo_mgmt_bind_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - ret = zbl_mgmt_bind_req(addr16, start_idx, cb, user_data); - return ret; -} - -API int zb_zdo_mgmt_leave_req(zigbee_h handle, ieee_addr addr64, - bool remove_children, bool rejoin, zb_zdo_mgmt_leave_rsp cb, - void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - ret = zbl_mgmt_leave_device(addr64, remove_children, rejoin, cb, user_data); - return ret; -} - -#ifdef ZB_SUPPORT_PRIORITY_5 -API int zb_zdo_mgmt_direct_join_req(zigbee_h handle, ieee_addr addr64, - unsigned char capability, zb_zdo_mgmt_direct_join_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - return ZIGBEE_ERROR_NONE; -} -#endif /* ZB_SUPPORT_PRIORITY_5 */ - -API int zb_zdo_mgmt_permit_joining_req(zigbee_h handle, nwk_addr addr16, - unsigned char duration, unsigned char tc_significance, - zb_zdo_mgmt_permit_joining_rsp cb, void *user_data) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - ret = zbl_mgmt_permit_joining_req(addr16, duration, tc_significance, cb, user_data); - return ret; -} - -#ifdef ZB_SUPPORT_PRIORITY_5 -API int zb_zdo_mgmt_cache_req(zigbee_h handle, nwk_addr addr16, - unsigned char start_idx, zb_zdo_mgmt_cache_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - return ZIGBEE_ERROR_NONE; -} -#endif /* ZB_SUPPORT_PRIORITY_5 */ - -API int zb_zdo_mgmt_nwk_update_req(zigbee_h handle, unsigned int scan_channels, - unsigned char scan_duration, unsigned char scan_count, unsigned char nwk_update_id, - nwk_addr nwk_manager_addr) -{ - int ret; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == nwk_manager_addr, ZIGBEE_ERROR_INVALID_ADDRESS); - ret = zbl_mgmt_nwk_update_req(scan_channels, scan_duration, scan_count, nwk_update_id, - nwk_manager_addr); - return ret; -} - diff --git a/lib/zbl-zdo-svc-disc.c b/lib/zbl-zdo-svc-disc.c deleted file mode 100644 index 6bb870b..0000000 --- a/lib/zbl-zdo-svc-disc.c +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 - -#include "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" - -#ifdef ZB_SUPPORT_PRIORITY_5 - -API int zb_zdo_system_server_discover_req(zigbee_h handle, - unsigned short server_mask, zb_zdo_system_server_discover_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_find_node_cache_req(zigbee_h handle, nwk_addr addr16, - ieee_addr addr64, zb_zdo_find_node_cache_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_discovery_cache_req(zigbee_h handle, nwk_addr addr16, - ieee_addr addr64, zb_zdo_discovery_cache_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_discovery_store_req(zigbee_h handle, nwk_addr addr16, - ieee_addr addr64, unsigned char node_desc_size, unsigned char power_desc_size, - unsigned char active_ep_size, unsigned char simple_desc_count, - unsigned char *simple_desc_list, zb_zdo_discovery_store_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == simple_desc_list, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_node_desc_store_req(zigbee_h handle, nwk_addr addr16, - ieee_addr addr64, zb_zdo_node_descriptor_h nodedsc, zb_zdo_node_desc_store_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_power_desc_store_req(zigbee_h handle, nwk_addr addr16, - ieee_addr addr64, zb_zdo_node_power_descriptor_h powerdsc, - zb_zdo_power_desc_store_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_active_ep_store_req(zigbee_h handle, nwk_addr addr16, - ieee_addr addr64, unsigned char active_ep_count, unsigned char *ep_list, - zb_zdo_active_ep_store_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == ep_list, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_simple_desc_store_req(zigbee_h handle, nwk_addr addr16, - ieee_addr addr64, zb_zdo_simple_desc_h simpledsc, zb_zdo_simple_desc_store_rsp cb, - void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - - return ZIGBEE_ERROR_NONE; -} - -API int zb_zdo_remove_node_cache_req(zigbee_h handle, nwk_addr addr16, - ieee_addr addr64, zb_zdo_remove_node_cache_rsp cb, void *user_data) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); - RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); - - return ZIGBEE_ERROR_NONE; -} - -#endif /* ZB_SUPPORT_PRIORITY_5 */ - diff --git a/lib/zbl-zdo.c b/lib/zbl-zdo.c deleted file mode 100644 index 924d55e..0000000 --- a/lib/zbl-zdo.c +++ /dev/null @@ -1,1072 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 -#include -#include -#include - -#include "zbl.h" -#include "zb-log.h" -#include "zbl-dbus.h" -#include "zb-common.h" - -#define CASE_TO_STR(x) case x: return #x; - -API const char* zb_zdo_get_error_message(int id) -{ - switch(id) { - CASE_TO_STR(ZB_ZDP_SUCCESS) - CASE_TO_STR(ZB_ZDP_INV_REQUESTTYPE) - CASE_TO_STR(ZB_ZDP_DEVICE_NOT_FOUND) - CASE_TO_STR(ZB_ZDP_INVALID_EP) - CASE_TO_STR(ZB_ZDP_NOT_ACTIVE) - CASE_TO_STR(ZB_ZDP_NOT_SUPPORTED) - CASE_TO_STR(ZB_ZDP_TIMEOUT) - CASE_TO_STR(ZB_ZDP_NO_MATCH) - CASE_TO_STR(ZB_ZDP_NO_ENTRY) - CASE_TO_STR(ZB_ZDP_NO_DESCRIPTOR) - CASE_TO_STR(ZB_ZDP_INSUFFICIENT_SPACE) - CASE_TO_STR(ZB_ZDP_NOT_PERMITED) - CASE_TO_STR(ZB_ZDP_TABLE_FULL) - CASE_TO_STR(ZB_ZDP_NOT_AUTHORIZED) - CASE_TO_STR(ZB_ZDP_DEVICE_BINDING_TABLE_FULL) - default: - return "ZB_ZDP_UNKNOWN"; - } -} - -API const char* zb_get_profile_id_string(int profile_id) -{ - switch(profile_id) { - CASE_TO_STR(ZB_PROFILE_HOME_AUTOMATION) - default: - return "ZB_UNKNOWN_PROFILE"; - } -} - -API const char* zb_get_device_id_string(int device_id) -{ - switch (device_id) { - /* General devices */ - CASE_TO_STR(ZB_HA_ON_OFF_SWITCH) - CASE_TO_STR(ZB_HA_LEVEL_CONTROL_SWITCH) - CASE_TO_STR(ZB_HA_ON_OFF_OUTPUT) - CASE_TO_STR(ZB_HA_LEVEL_CONTROLLABLE_OUTPUT) - CASE_TO_STR(ZB_HA_SCENE_SELECOTOR) - CASE_TO_STR(ZB_HA_CONFIGURATION_TOOL) - CASE_TO_STR(ZB_HA_REMOTE_CONTROL) - CASE_TO_STR(ZB_HA_COMBINED_INTERFACE) - CASE_TO_STR(ZB_HA_RANGE_EXTENDER) - CASE_TO_STR(ZB_HA_MAINS_POWER_OUTLET) - CASE_TO_STR(ZB_HA_DOOR_LOCK) - CASE_TO_STR(ZB_HA_DOOR_LOCK_CONTROLLER) - CASE_TO_STR(ZB_HA_SIMPLE_SENSOR) - CASE_TO_STR(ZB_HA_CONSUMPTION_AWARENESS_DEVICE) - CASE_TO_STR(ZB_HA_HOME_GATEWAY) - CASE_TO_STR(ZB_HA_SMART_PLUG) - CASE_TO_STR(ZB_HA_WHITE_GOODS) - CASE_TO_STR(ZB_HA_METER_INTERFACE) - /* Lighting devices */ - CASE_TO_STR(ZB_HA_ON_OFF_LIGHT) - CASE_TO_STR(ZB_HA_DIMMABLE_LIGHT) - CASE_TO_STR(ZB_HA_COLOR_DIMMABLE_LIGHT) - CASE_TO_STR(ZB_HA_ON_OFF_LIGHT_SWITCH) - CASE_TO_STR(ZB_HA_DIMMER_SWITCH) - CASE_TO_STR(ZB_HA_COLOR_DIMMER_SWITCH) - CASE_TO_STR(ZB_HA_LIGHT_SENSOR) - CASE_TO_STR(ZB_HA_OCUPANCY_SENSOR) - /* Closures devices */ - CASE_TO_STR(ZB_HA_SHADE) - CASE_TO_STR(ZB_HA_SHADE_CONTROLLER) - CASE_TO_STR(ZB_HA_WINDOW_COVERING_DEVICE) - CASE_TO_STR(ZB_HA_WINDOW_COVERING_CONTROLLER) - /* HVAC devices */ - CASE_TO_STR(ZB_HA_HEATING_COLLING_UNIT) - CASE_TO_STR(ZB_HA_THERMOSTAT) - CASE_TO_STR(ZB_HA_TEMPERATURE_SENSOR) - CASE_TO_STR(ZB_HA_PUMP) - CASE_TO_STR(ZB_HA_PUMP_CONTROLLER) - CASE_TO_STR(ZB_HA_PRESSURE_SENSOR) - CASE_TO_STR(ZB_HA_FLOW_SENSOR) - CASE_TO_STR(ZB_HA_MINI_SPLIT_AC) - /* Intruder Alarms system */ - CASE_TO_STR(ZB_HA_ISA_CONTROL_AND_INDICATING_EQUIPMENT) - CASE_TO_STR(ZB_HA_ISA_ANCILLARY_CONTROL_EQUIPMENT) - CASE_TO_STR(ZB_HA_ISA_ZONE) - default: - return "ZB_HA_UNKNOWN_DEVICE"; - } -} - -API int zb_simple_desc_create(zb_zdo_simple_desc_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - zb_zdo_simple_desc_h desc = calloc(1, sizeof(struct zb_zdo_simple_desc_s)); - RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = desc; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_copy(zb_zdo_simple_desc_h src, zb_zdo_simple_desc_h dst) -{ - RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(dst, src, sizeof(struct zb_zdo_simple_desc_s)); - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_destroy(zb_zdo_simple_desc_h handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - free(handle); - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_get_ep(zb_zdo_simple_desc_h handle, unsigned char *ep) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == ep, ZIGBEE_ERROR_INVALID_PARAMETER); - *ep = handle->ep; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_set_ep(zb_zdo_simple_desc_h handle, unsigned char ep) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->ep = ep; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_get_profile_id(zb_zdo_simple_desc_h handle, - unsigned short *profile_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == profile_id, ZIGBEE_ERROR_INVALID_PARAMETER); - *profile_id = handle->profile_id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_set_profile_id(zb_zdo_simple_desc_h handle, - unsigned short profile_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->profile_id = profile_id; - return ZIGBEE_ERROR_NONE; -} - - -API int zb_simple_desc_get_device_id(zb_zdo_simple_desc_h handle, - unsigned short *device_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == device_id, ZIGBEE_ERROR_INVALID_PARAMETER); - *device_id = handle->device_id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_set_device_id(zb_zdo_simple_desc_h handle, - unsigned short device_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->device_id = device_id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_get_device_ver(zb_zdo_simple_desc_h handle, - unsigned short *device_ver) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == device_ver, ZIGBEE_ERROR_INVALID_PARAMETER); - *device_ver = handle->device_ver; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_set_device_ver(zb_zdo_simple_desc_h handle, - unsigned short device_ver) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->device_ver = device_ver; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_get_num_of_in_clusters(zb_zdo_simple_desc_h handle, - unsigned char *num_of_in_clusters) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == num_of_in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - *num_of_in_clusters = handle->num_of_in_clusters; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_set_num_of_in_clusters(zb_zdo_simple_desc_h handle, - unsigned char num_of_in_clusters) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->num_of_in_clusters = num_of_in_clusters; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_get_num_of_out_clusters(zb_zdo_simple_desc_h handle, - unsigned char *num_of_out_clusters) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == num_of_out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - *num_of_out_clusters = handle->num_of_out_clusters; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_set_num_of_out_clusters(zb_zdo_simple_desc_h handle, - unsigned char num_of_out_clusters) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->num_of_out_clusters = num_of_out_clusters; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_get_in_clusters(zb_zdo_simple_desc_h handle, - unsigned short **in_clusters) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - *in_clusters = handle->in_clusters; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_set_in_clusters(zb_zdo_simple_desc_h handle, - unsigned short *in_clusters, int num) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(num < 1 || num > MAX_ENDPOINT_CLUSTERS, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(handle->in_clusters, in_clusters, 2 * num); - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_get_out_clusters(zb_zdo_simple_desc_h handle, - unsigned short **out_clusters) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - *out_clusters = handle->out_clusters; - return ZIGBEE_ERROR_NONE; -} - -API int zb_simple_desc_set_out_clusters(zb_zdo_simple_desc_h handle, - unsigned short *out_clusters, int num) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(num < 1 || num > MAX_ENDPOINT_CLUSTERS, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(handle->out_clusters, out_clusters, 2 * num); - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_all_device_list(zigbee_h handle, int *count, zb_end_device_info_h **list) -{ - int ret; - unsigned char cnt; - RETV_IF(NULL == count, ZIGBEE_ERROR_INVALID_PARAMETER); - ret = zbl_get_all_device_info(list, &cnt); - *count = cnt; - return ret; -} - -API int zb_get_endpoint_list(zigbee_h handle, ieee_addr addr64, unsigned char *count, - unsigned char *ep_list) -{ - int ret; - unsigned char cnt = 0; - - RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == count, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == ep_list, ZIGBEE_ERROR_INVALID_PARAMETER); - - ret = zbl_get_endpoint_list(addr64, &cnt, ep_list); - *count = cnt; - return ret; -} - -API int zb_get_cluster_list(zigbee_h handle, ieee_addr addr64, unsigned char ep, - unsigned char *in_cluster_count, unsigned short *in_cluster_list, - unsigned char *out_cluster_count, unsigned short *out_cluster_list) -{ - int ret; - unsigned char in_cnt = 0; - unsigned char out_cnt = 0; - - RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == in_cluster_count, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == in_cluster_list, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == out_cluster_count, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == out_cluster_list, ZIGBEE_ERROR_INVALID_PARAMETER); - - ret = zbl_get_cluster_list(addr64, ep, &in_cnt, in_cluster_list, - &out_cnt, out_cluster_list); - *in_cluster_count = in_cnt; - *out_cluster_count = out_cnt; - - return ret; -} - -API int zb_devices_info_foreach_end_device(zb_end_device_info_h *list, - zb_end_device_cb cb, void *user_data) -{ - int index = 0; - GList *cur = NULL; - struct zb_end_device_info_s *real = NULL; - - RETV_IF(NULL == list, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); - - cur = (GList *)list; - while (cur) { - GList *next = cur->next; - real = cur->data; - if (ZIGBEE_FUNC_STOP == cb(index, (zb_end_device_info_h)real->list, user_data)) - break; - index++; - cur = next; - } - - return ZIGBEE_ERROR_NONE; - -} - -API int zb_get_network_address(zb_end_device_info_h handle, nwk_addr *addr16) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); - *addr16 = handle->addr16; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_ieee_address(zb_end_device_info_h handle, ieee_addr addr64) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(addr64, handle->addr64, sizeof(ieee_addr)); - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_num_of_ep(zb_end_device_info_h handle, unsigned char *count) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == count, ZIGBEE_ERROR_INVALID_PARAMETER); - *count = handle->num_of_ep; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_ep_list(zb_end_device_info_h handle, unsigned char *ep_list) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == ep_list, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(ep_list, handle->ep, handle->num_of_ep); - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_mac_capabiity(zb_end_device_info_h handle, unsigned char *capability) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == capability, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == handle->capability, ZIGBEE_ERROR_NO_DATA); - *capability = handle->capability; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_alternative_pan_coordinator(zb_end_device_info_h handle, - unsigned char *can_do_it) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == can_do_it, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == handle->capability, ZIGBEE_ERROR_NO_DATA); - *can_do_it = handle->capability & ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR ? 1 : 0; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_device_id(zb_end_device_info_h handle, unsigned char ep, - unsigned short *device_id) -{ - int i; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == device_id, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->desc, ZIGBEE_ERROR_NO_DATA); - for (i = 0; i < handle->num_of_ep; i++) { - RETV_IF(NULL == handle->desc[i], ZIGBEE_ERROR_NO_DATA); - if (handle->desc[i]->ep == ep) { - *device_id = handle->desc[i]->device_id; - return ZIGBEE_ERROR_NONE; - } - } - return ZIGBEE_ERROR_NO_DATA; -} - -API int zb_get_profile_id(zb_end_device_info_h handle, unsigned char ep, - unsigned short *profile_id) -{ - int i; - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == profile_id, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->desc, ZIGBEE_ERROR_NO_DATA); - for (i = 0; i < handle->num_of_ep; i++) { - RETV_IF(NULL == handle->desc[i], ZIGBEE_ERROR_NO_DATA); - if (handle->desc[i]->ep == ep) { - *profile_id = handle->desc[i]->profile_id; - return ZIGBEE_ERROR_NONE; - } - } - return ZIGBEE_ERROR_NO_DATA; -} - -API int zb_get_power_source(zb_end_device_info_h handle, unsigned char *power_src) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == power_src, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == handle->capability, ZIGBEE_ERROR_NO_DATA); - *power_src = handle->capability & ZB_ZDP_POWER_SOURCE ? 1 : 0; - return ZIGBEE_ERROR_NONE; -} - -API int zb_get_security_capabilty(zb_end_device_info_h handle, - unsigned char *sec_capability) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == sec_capability, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0 == handle->capability, ZIGBEE_ERROR_NO_DATA); - *sec_capability = handle->capability & ZB_ZDP_SECURITY_CAPABILITY ? 1 : 0; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_create(zb_zdo_node_power_descriptor_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - zb_zdo_node_power_descriptor_h desc = - calloc(1, sizeof(struct zb_zdo_node_power_descriptor_s)); - RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = desc; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_copy(zb_zdo_node_power_descriptor_h src, - zb_zdo_node_power_descriptor_h dst) -{ - RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(dst, src, sizeof(struct zb_zdo_node_power_descriptor_s)); - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_destroy(zb_zdo_node_power_descriptor_h handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - free(handle); - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_get_current_power_mode( - zb_zdo_node_power_descriptor_h handle, - unsigned char* current_power_mode) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == current_power_mode, ZIGBEE_ERROR_INVALID_PARAMETER); - *current_power_mode = handle->current_power_mode; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_set_current_power_mode( - zb_zdo_node_power_descriptor_h handle, unsigned char current_power_mode) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0b11 < current_power_mode, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->current_power_mode = current_power_mode; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_get_available_power_sources( - zb_zdo_node_power_descriptor_h handle, unsigned char* available_power_sources) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == available_power_sources, ZIGBEE_ERROR_INVALID_PARAMETER); - *available_power_sources = handle->available_power_sources; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_set_available_power_sources( - zb_zdo_node_power_descriptor_h handle, unsigned char available_power_sources) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0b111 < available_power_sources, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->available_power_sources = available_power_sources; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_get_current_power_source( - zb_zdo_node_power_descriptor_h handle, unsigned char* current_power_source) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == current_power_source, ZIGBEE_ERROR_INVALID_PARAMETER); - *current_power_source = handle->current_power_source; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_set_current_power_source( - zb_zdo_node_power_descriptor_h handle, unsigned char current_power_source) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0b111 < current_power_source, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->current_power_source = current_power_source; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_get_current_power_source_level( - zb_zdo_node_power_descriptor_h handle, unsigned char* current_power_source_level) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == current_power_source_level, ZIGBEE_ERROR_INVALID_PARAMETER); - *current_power_source_level = handle->current_power_source_level; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_power_desc_set_current_power_source_level( - zb_zdo_node_power_descriptor_h handle, unsigned char current_power_source_level) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->current_power_source_level = current_power_source_level; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_create(zb_zdo_node_descriptor_h *handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - zb_zdo_node_descriptor_h desc = calloc(1, sizeof(struct zb_zdo_node_descriptor_s)); - RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); - *handle = desc; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_copy(zb_zdo_node_descriptor_h src, - zb_zdo_node_descriptor_h dst) -{ - RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(dst, src, sizeof(struct zb_zdo_node_descriptor_s)); - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_destroy(zb_zdo_node_descriptor_h handle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - free(handle); - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_logical_type(zb_zdo_node_descriptor_h handle, - unsigned char* logical_type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == logical_type, ZIGBEE_ERROR_INVALID_PARAMETER); - *logical_type = handle->logical_type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_logical_type(zb_zdo_node_descriptor_h handle, - unsigned char logical_type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0b11 < logical_type, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->logical_type = logical_type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_complex_desciptor_available( - zb_zdo_node_descriptor_h handle, unsigned char* complex_desciptor_available) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == complex_desciptor_available, ZIGBEE_ERROR_INVALID_PARAMETER); - *complex_desciptor_available = handle->complex_desciptor_available; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_complex_descriptor_available( - zb_zdo_node_descriptor_h handle, unsigned char complex_desciptor_available) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0x01 < complex_desciptor_available, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->complex_desciptor_available = complex_desciptor_available; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_user_descriptor_available( - zb_zdo_node_descriptor_h handle, unsigned char* user_descriptor_available) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == user_descriptor_available, ZIGBEE_ERROR_INVALID_PARAMETER); - *user_descriptor_available = handle->user_descriptor_available; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_user_descriptor_available( - zb_zdo_node_descriptor_h handle, unsigned char user_descriptor_available) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0x01 < user_descriptor_available, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->user_descriptor_available = user_descriptor_available; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_aps_flags(zb_zdo_node_descriptor_h handle, - unsigned char* aps_flags) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == aps_flags, ZIGBEE_ERROR_INVALID_PARAMETER); - *aps_flags = handle->aps_flags; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_aps_flags(zb_zdo_node_descriptor_h handle, - unsigned char aps_flags) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0b111 < aps_flags, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->aps_flags = aps_flags; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_frequency_band(zb_zdo_node_descriptor_h handle, - unsigned char* frequency_band) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == frequency_band, ZIGBEE_ERROR_INVALID_PARAMETER); - *frequency_band = handle->frequency_band; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_frequency_band(zb_zdo_node_descriptor_h handle, - unsigned char frequency_band) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0b1111 < frequency_band, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->frequency_band = frequency_band; - return ZIGBEE_ERROR_NONE; -} - - -API int zb_node_desc_get_mac_capability_flags(zb_zdo_node_descriptor_h handle, - unsigned char* mac_capability_flags) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == mac_capability_flags, ZIGBEE_ERROR_INVALID_PARAMETER); - *mac_capability_flags = handle->mac_capability_flags; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_mac_capability_flags(zb_zdo_node_descriptor_h handle, - unsigned char mac_capability_flags) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->mac_capability_flags = mac_capability_flags; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_manufacturer_code(zb_zdo_node_descriptor_h handle, - unsigned short* manufacturer_code) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == manufacturer_code, ZIGBEE_ERROR_INVALID_PARAMETER); - *manufacturer_code = handle->manufacturer_code; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_manufacturer_code(zb_zdo_node_descriptor_h handle, - unsigned short manufacturer_code) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - handle->manufacturer_code = manufacturer_code; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_maximum_buffer_size(zb_zdo_node_descriptor_h handle, - unsigned char* maximum_buffer_size) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == maximum_buffer_size, ZIGBEE_ERROR_INVALID_PARAMETER); - *maximum_buffer_size = handle->maximum_buffer_size; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_maximum_buffer_size(zb_zdo_node_descriptor_h handle, - unsigned char maximum_buffer_size) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0x7f < maximum_buffer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->maximum_buffer_size = maximum_buffer_size; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_maximum_incoming_transfer_size( - zb_zdo_node_descriptor_h handle, unsigned short* maximum_incoming_transfer_size) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == maximum_incoming_transfer_size, ZIGBEE_ERROR_INVALID_PARAMETER); - *maximum_incoming_transfer_size = handle->maximum_incoming_transfer_size; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_maximum_incoming_transfer_size( - zb_zdo_node_descriptor_h handle, unsigned short maximum_incoming_transfer_size) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0x7fff < maximum_incoming_transfer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->maximum_incoming_transfer_size = maximum_incoming_transfer_size; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_server_mask(zb_zdo_node_descriptor_h handle, - unsigned short* server_mask) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == server_mask, ZIGBEE_ERROR_INVALID_PARAMETER); - *server_mask = handle->server_mask; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_server_mask(zb_zdo_node_descriptor_h handle, - unsigned short server_mask) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0x7f < server_mask, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->server_mask = server_mask; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_maximum_outgoing_transfer_size( - zb_zdo_node_descriptor_h handle, unsigned short* maximum_outgoing_transfer_size) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == maximum_outgoing_transfer_size, ZIGBEE_ERROR_INVALID_PARAMETER); - *maximum_outgoing_transfer_size = handle->maximum_outgoing_transfer_size; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_maximum_outgoing_transfer_size( - zb_zdo_node_descriptor_h handle, unsigned short maximum_outgoing_transfer_size) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0x7fff < maximum_outgoing_transfer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->maximum_outgoing_transfer_size = maximum_outgoing_transfer_size; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_get_descriptor_capability_field( - zb_zdo_node_descriptor_h handle, unsigned short* descriptor_capability_field) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == descriptor_capability_field, ZIGBEE_ERROR_INVALID_PARAMETER); - *descriptor_capability_field = handle->descriptor_capability_field; - return ZIGBEE_ERROR_NONE; -} - -API int zb_node_desc_set_descriptor_capability_field( - zb_zdo_node_descriptor_h handle, unsigned short descriptor_capability_field) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(0x11 < descriptor_capability_field, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); - handle->descriptor_capability_field = descriptor_capability_field; - return ZIGBEE_ERROR_NONE; -} - -API int zb_network_list_record_get_extended_pan_id( - zb_zdo_network_list_record_h handle, ieee_addr extended_pan_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - extended_pan_id = handle->extended_pan_id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_network_list_record_get_logical_channel( - zb_zdo_network_list_record_h handle, unsigned char* logical_channel) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == logical_channel, ZIGBEE_ERROR_INVALID_PARAMETER); - *logical_channel = handle->logical_channel; - return ZIGBEE_ERROR_NONE; -} - -API int zb_network_list_record_get_zigbee_version( - zb_zdo_network_list_record_h handle, unsigned char* zigbee_version) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == zigbee_version, ZIGBEE_ERROR_INVALID_PARAMETER); - *zigbee_version = handle->zigbee_version; - return ZIGBEE_ERROR_NONE; -} - -API int zb_network_list_record_get_stack_profile( - zb_zdo_network_list_record_h handle, unsigned char* stack_profile) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == stack_profile, ZIGBEE_ERROR_INVALID_PARAMETER); - *stack_profile = handle->stack_profile; - return ZIGBEE_ERROR_NONE; -} - -API int zb_network_list_record_get_beacon_order( - zb_zdo_network_list_record_h handle, unsigned char* beacon_order) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == beacon_order, ZIGBEE_ERROR_INVALID_PARAMETER); - *beacon_order = handle->beacon_order; - return ZIGBEE_ERROR_NONE; -} - -API int zb_network_list_record_get_superframe_order( - zb_zdo_network_list_record_h handle, unsigned char* superframe_order) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == superframe_order, ZIGBEE_ERROR_INVALID_PARAMETER); - *superframe_order = handle->superframe_order; - return ZIGBEE_ERROR_NONE; -} - -API int zb_network_list_record_get_permit_joining( - zb_zdo_network_list_record_h handle, unsigned char* permit_joining) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == permit_joining, ZIGBEE_ERROR_INVALID_PARAMETER); - *permit_joining = handle->permit_joining; - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_extended_pan_id( - zb_zdo_neighbor_table_desc_h handle, ieee_addr extended_pan_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->extended_pan_id, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == extended_pan_id, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(extended_pan_id, handle->extended_pan_id, sizeof(ieee_addr)); - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_ieee_addr( - zb_zdo_neighbor_table_desc_h handle, ieee_addr addr64) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == handle->addr64, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(addr64, handle->addr64, sizeof(ieee_addr)); - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_nwk_addr( - zb_zdo_neighbor_table_desc_h handle, nwk_addr* addr16) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); - *addr16 = handle->addr16; - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_device_type( - zb_zdo_neighbor_table_desc_h handle, unsigned char* device_type) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == device_type, ZIGBEE_ERROR_INVALID_PARAMETER); - *device_type = handle->device_type; - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_rx_on_when_idle( - zb_zdo_neighbor_table_desc_h handle, unsigned char* rx_on_when_idle) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == rx_on_when_idle, ZIGBEE_ERROR_INVALID_PARAMETER); - *rx_on_when_idle = handle->rx_on_when_idle; - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_relationship( - zb_zdo_neighbor_table_desc_h handle, unsigned char* releationship) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == releationship, ZIGBEE_ERROR_INVALID_PARAMETER); - *releationship = handle->relationship; - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_permit_joining( - zb_zdo_neighbor_table_desc_h handle, unsigned char* permit_joining) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == permit_joining, ZIGBEE_ERROR_INVALID_PARAMETER); - *permit_joining = handle->permit_joining; - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_depth( - zb_zdo_neighbor_table_desc_h handle, unsigned char* depth) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == depth, ZIGBEE_ERROR_INVALID_PARAMETER); - *depth = handle->depth; - return ZIGBEE_ERROR_NONE; -} - -API int zb_neighbor_table_desc_get_lqi(zb_zdo_neighbor_table_desc_h handle, - unsigned char* lqi) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == lqi, ZIGBEE_ERROR_INVALID_PARAMETER); - *lqi = handle->lqi; - return ZIGBEE_ERROR_NONE; -} - -API int zb_routing_table_get_dst_addr(zb_zdo_routing_table_h handle, - nwk_addr* dst_addr) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == dst_addr, ZIGBEE_ERROR_INVALID_PARAMETER); - *dst_addr = handle->dst_addr; - return ZIGBEE_ERROR_NONE; -} - -API int zb_routing_table_get_dst_status(zb_zdo_routing_table_h handle, - unsigned char *status) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER); - *status = handle->status; - return ZIGBEE_ERROR_NONE; -} - -API int zb_routing_table_get_memory_constrained( - zb_zdo_routing_table_h handle, unsigned char *memory_constrained) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == memory_constrained, ZIGBEE_ERROR_INVALID_PARAMETER); - *memory_constrained = handle->memory_constrained; - return ZIGBEE_ERROR_NONE; -} - -API int zb_routing_table_get_many_to_one(zb_zdo_routing_table_h handle, - unsigned char *many_to_one) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == many_to_one, ZIGBEE_ERROR_INVALID_PARAMETER); - *many_to_one = handle->many_to_one; - return ZIGBEE_ERROR_NONE; -} - -API int zb_routing_table_get_route_record_required( - zb_zdo_routing_table_h handle, unsigned char *route_record_required) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == route_record_required, ZIGBEE_ERROR_INVALID_PARAMETER); - *route_record_required = handle->route_record_required; - return ZIGBEE_ERROR_NONE; -} - -API int zb_routing_table_get_next_hop_addr( - zb_zdo_routing_table_h handle, nwk_addr *next_hop_addr) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == next_hop_addr, ZIGBEE_ERROR_INVALID_PARAMETER); - *next_hop_addr = handle->next_hop_addr; - return ZIGBEE_ERROR_NONE; -} - -API int zb_binding_table_get_src_addr(zb_zdo_binding_table_h handle, - ieee_addr src_addr) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(src_addr, handle->src_addr64, sizeof(ieee_addr)); - return ZIGBEE_ERROR_NONE; -} - -API int zb_binding_table_get_src_ep(zb_zdo_binding_table_h handle, - unsigned char* src_ep) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == src_ep, ZIGBEE_ERROR_INVALID_PARAMETER); - *src_ep = handle->src_ep; - return ZIGBEE_ERROR_NONE; -} - -API int zb_binding_table_get_cluster_id(zb_zdo_binding_table_h handle, - unsigned short *cluster_id) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == cluster_id, ZIGBEE_ERROR_INVALID_PARAMETER); - *cluster_id = handle->cluster_id; - return ZIGBEE_ERROR_NONE; -} - -API int zb_binding_table_get_dst_addr_mode(zb_zdo_binding_table_h handle, - unsigned char* dst_addr_mode) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == dst_addr_mode, ZIGBEE_ERROR_INVALID_PARAMETER); - *dst_addr_mode = handle->dst_addr_mode; - return ZIGBEE_ERROR_NONE; -} - -API int zb_binding_table_get_dst_addr16(zb_zdo_binding_table_h handle, - nwk_addr* addr16) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); - *addr16 = handle->dst_addr16; - return ZIGBEE_ERROR_NONE; -} - -API int zb_binding_table_get_dst_addr64(zb_zdo_binding_table_h handle, - ieee_addr addr64) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); - memcpy(addr64, handle->dst_addr64, sizeof(ieee_addr)); - return ZIGBEE_ERROR_NONE; -} - -API int zb_binding_table_get_dst_ep(zb_zdo_binding_table_h handle, - unsigned char* dst_ep) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == dst_ep, ZIGBEE_ERROR_INVALID_PARAMETER); - *dst_ep = handle->dst_ep; - return ZIGBEE_ERROR_NONE; -} - -API int zb_discovery_cache_get_ieee_addr(zb_zdo_discovery_cache_h handle, - ieee_addr addr64) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - addr64 = handle->addr64; - return ZIGBEE_ERROR_NONE; -} - -API int zb_discovery_cache_get_nwk_addr(zb_zdo_discovery_cache_h handle, - nwk_addr* addr16) -{ - RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); - *addr16 = handle->addr16; - return ZIGBEE_ERROR_NONE; -} diff --git a/lib/zbl.c b/lib/zbl.c index 592ded9..8494fc8 100644 --- a/lib/zbl.c +++ b/lib/zbl.c @@ -22,7 +22,7 @@ #include #include "zbl.h" -#include "zbl-dbus.h" +#include "zbl_dbus.h" #include "zigbee.h" API int zb_create(zigbee_h *handle) diff --git a/lib/zbl_custom.c b/lib/zbl_custom.c new file mode 100644 index 0000000..15ead9f --- /dev/null +++ b/lib/zbl_custom.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 +#include +#include +#include + +#include "zbl.h" +#include "zbl_dbus.h" +#include "zigbee.h" + +API int zb_aps_send(zigbee_h handle, nwk_addr addr16, unsigned char aps_frame_ctl, + unsigned char src_ep, unsigned char dst_ep, unsigned short cluster_id, + unsigned short profile_id, unsigned char zcl_frame_ctl, unsigned short mfg_code, + unsigned char cmd_id, unsigned short payload_len, unsigned char *payload, + zb_aps_send_rsp cb, void *user_data) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + + ret = zbl_aps_send(addr16, aps_frame_ctl, src_ep, dst_ep, cluster_id, profile_id, + zcl_frame_ctl, mfg_code, cmd_id, payload_len, payload, cb, user_data); + DBG("zbl_aps_send()=0x%X", ret); + return ret; +} + +API int zb_zcl_send(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned short cluster_id, unsigned char zcl_frame_ctl, + unsigned char cmd, unsigned short payload_len, unsigned char *payload, + zb_zcl_send_rsp cb, void *user_data) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + + ret = zbl_zcl_send(addr16, src_ep, dst_ep, cluster_id, zcl_frame_ctl, + cmd, payload_len, payload, cb, user_data); + DBG("zbl_zcl_send()=0x%X", ret); + return ret; +} + +API int zb_send_to_local(zigbee_h handle, unsigned short length, unsigned char *data, + zb_send_to_local_rsp cb, void *user_data) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + + ret = zbl_send_to_local(length, data, cb, user_data); + DBG("zbl_send_to_local()=0x%X", ret); + return ret; +} diff --git a/lib/zbl_dbus.c b/lib/zbl_dbus.c new file mode 100644 index 0000000..1e9973f --- /dev/null +++ b/lib/zbl_dbus.c @@ -0,0 +1,7923 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "zbl.h" +#include "zbl_dbus.h" + +#define USE_ASYNC_DBUS_CALL + +static int zbl_ref_count; + +static GDBusConnection *gdbus_conn = NULL; +static GDBusProxy *service_gproxy = NULL; +static GDBusProxy *on_off_gproxy = NULL; +static GDBusProxy *door_lock_gproxy = NULL; +static GDBusProxy *level_control_gproxy = NULL; +static GDBusProxy *thermostat_gproxy = NULL; +static GDBusProxy *alarm_gproxy = NULL; +static GDBusProxy *fan_control_gproxy = NULL; +static GDBusProxy *mfglib_gproxy = NULL; +static GDBusProxy *zcl_global_proxy = NULL; +static GDBusProxy *zdo_dev_proxy = NULL; +static GDBusProxy *zcl_basic_proxy = NULL; +static GDBusProxy *zcl_identify_proxy = NULL; +static GDBusProxy *zcl_ias_zone_proxy = NULL; +static GDBusProxy *zcl_poll_control_proxy = NULL; +static GDBusProxy *zcl_group_proxy = NULL; +static GDBusProxy *zcl_scene_proxy = NULL; +static GDBusProxy *zdo_bind_proxy = NULL; +static GDBusProxy *zcl_color_control_proxy = NULL; +static GDBusProxy *custom_gproxy = NULL; + +/* command id */ +typedef enum { + /* Service */ + ZBL_SERVICE_FORM_NETWORK = 0, + ZBL_SERVICE_DISABLE_NETWORK, + /* ZDP except Bind */ + ZBL_ZDO_NWK_ADDR_REQ, + ZBL_ZDO_NWK_ADDR_EXT_REQ, + ZBL_ZDO_ACTIVE_EP_REQ, + ZBL_ZDO_SIMPLE_DESC_REQ, + ZBL_ZDO_MATCHED_DESCRIPTOR_REQ, + ZBL_ZDO_COMPLEX_DESC_REQ, + ZBL_ZDO_MGMT_BIND_REQ, + ZBL_ZDO_MGMT_LQI_REQ, + ZBL_ZDO_MGMT_RTG_REQ, + ZBL_ZDO_MGMT_NWK_DISC_REQ, + ZBL_ZDO_MGMT_PERMIT_JOIN_REQ, + ZBL_ZDO_MGMT_LEAVE_REQ, + ZBL_ZDO_NODE_DESC_REQ, + ZBL_ZDO_POWER_DESC_REQ, + ZBL_ZDO_USER_DESC_REQ, + ZBL_ZDO_USER_DESC_SET_REQ, + /* ZDP Bind */ + ZBL_ZDO_BIND_REQ, + ZBL_ZDO_UNBIND_REQ, + /* ZCL Global */ + ZBL_ZCL_GLOBAL_READ_ATTRIBUTE_REQ, + ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ, + ZBL_ZCL_GLOBAL_CONFIGURE_REPORTING_REQ, + ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_REQ, + ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_STRUCTURED_REQ, + ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_RECEIVED_REQ, + ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_GENERATED_REQ, + ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_EXTENDED_REQ, + ZBL_ZCL_GLOBAL_READ_CONFIGURE_REPORTING_REQ, + /* Custom */ + ZBL_CUSTOM_APS_SEND_REQ, + ZBL_CUSTOM_ZCL_SEND_REQ, + ZBL_CUSTOM_LOCAL_SEND_REQ, + /* ZCL Alarm */ + ZBL_ZCL_ALARM_GET_ALARM_REQ, + /* ZCL Doorlock */ + ZBL_ZCL_DOORLOCK_LOCK_STATE, + /* ZCL Fanmode */ + ZBL_ZCL_FANMODE_FAN_MODE_STATE, + /* ZCL Group */ + ZBL_ZCL_GROUP_ADD_GROUP_REQ, + ZBL_ZCL_GROUP_VIEW_GROUP_REQ, + ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ, + ZBL_ZCL_GROUP_REMOVE_GROUP_REQ, + /* ZCL Identify */ + ZBL_ZCL_IDENTIFY_QUERY_REQ, + /* ZCL On/Off */ + ZBL_ZCL_ON_OFF_GET_ON_OFF_STATE, + /* ZCL Pollcontrol */ + ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ, + /* ZCL Scene */ + ZBL_ZCL_SCENE_ADD_SCENE_REQ, + ZBL_ZCL_SCENE_VIEW_SCENE_REQ, + ZBL_ZCL_SCENE_REMOVE_SCENE_REQ, + ZBL_ZCL_SCENE_STORE_SCENE_REQ, + ZBL_ZCL_SCENE_REMOVE_ALL_SCENE_REQ, + ZBL_ZCL_SCENE_GET_SCENE_MEMBERSHIP_REQ, + /* ZCL Thermostat */ + ZBL_ZCL_THERMOSTAT_GET_LOCAL_TEMP, +} zbl_command_id_e; + +typedef struct { + bool found; + void *cb; + void *userdata; + unsigned int sid; + int tid; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + void *global_cmd; + void *handle; +#endif + zbl_command_id_e cid; +} zbl_req_cb_s; + +#define ZCL_REPORTING_DIRECTION_REPORTED 0x00 +#define ZCL_REPORTING_DIRECTION_RECEIVED 0x01 + +static GDBusProxy *_zbl_get_service_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == service_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_SERVICE_INTERFACE, + NULL, NULL); + } else + proxy = service_gproxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_on_off_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == on_off_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_ON_OFF_INTERFACE, NULL, NULL); + } else + proxy = on_off_gproxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_door_lock_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == door_lock_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_DOOR_LOCK_INTERFACE, NULL, NULL); + } else + proxy = door_lock_gproxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_level_control_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == level_control_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_LEVEL_CONTROL_INTERFACE, NULL, NULL); + } else + proxy = level_control_gproxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_thermostat_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == thermostat_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_THERMOSTAT_INTERFACE, NULL, NULL); + } else + proxy = thermostat_gproxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_alarm_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == alarm_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZCL_ALARM_INTERFACE, + NULL, NULL); + } else + proxy = alarm_gproxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_fan_control_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == fan_control_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_FAN_CONTROL_INTERFACE, NULL, NULL); + } else + proxy = fan_control_gproxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_mfglib_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == mfglib_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_MFGLIB_CONTROL_INTERFACE, NULL, NULL); + } else + proxy = mfglib_gproxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_zcl_global_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zcl_global_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, NULL, NULL); + } else + proxy = zcl_global_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_zdo_dev_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zdo_dev_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, NULL, NULL); + } else + proxy = zdo_dev_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_basic_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zcl_basic_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZCL_BASIC_INTERFACE, + NULL, NULL); + } else + proxy = zcl_basic_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_identify_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zcl_identify_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_IDENTIFY_INTERFACE, NULL, NULL); + } else + proxy = zcl_identify_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_ias_zone_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zcl_ias_zone_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_IAS_ZONE_INTERFACE, NULL, NULL); + } else + proxy = zcl_ias_zone_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_poll_control_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zcl_poll_control_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_POLL_CONTROL_INTERFACE, NULL, NULL); + } else + proxy = zcl_poll_control_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_group_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zcl_group_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZCL_GROUP_INTERFACE, + NULL, NULL); + } else + proxy = zcl_group_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_scene_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zcl_scene_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZCL_SCENE_INTERFACE, + NULL, NULL); + } else + proxy = zcl_scene_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_zdo_bind_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zdo_bind_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_ZDO_BIND_INTERFACE, + NULL, NULL); + } else + proxy = zdo_bind_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_color_control_proxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Connection Object is invalid"); + + if (NULL == zcl_color_control_proxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, + ZIGBEE_ZCL_COLOR_CONTROL_INTERFACE, NULL, NULL); + } else + proxy = zcl_color_control_proxy; + + return proxy; +} + +static GDBusProxy *_zbl_get_custom_gproxy(void) +{ + GDBusProxy *proxy = NULL; + RETVM_IF(NULL == gdbus_conn, NULL, "Custom Object is invalid"); + + if (NULL == custom_gproxy) { + proxy = g_dbus_proxy_new_sync(gdbus_conn, G_DBUS_PROXY_FLAGS_NONE, NULL, + ZIGBEE_SERVER_NAME, ZIGBEE_CONTROL_OBJECT_PATH, ZIGBEE_CUSTOM_INTERFACE, + NULL, NULL); + } else + proxy = custom_gproxy; + + return proxy; +} + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC +static gint _global_compare_func(gconstpointer a, gconstpointer b) +{ + const zbl_req_cb_s *left = (const zbl_req_cb_s*)a; + const zbl_req_cb_s *right = (const zbl_req_cb_s*)b; + zb_event_global_default_rsp_s *left_data = NULL; + zb_event_global_default_rsp_s *right_data = NULL; + + if (NULL == left || NULL == left->global_cmd) + return -1; + if (NULL == right || NULL == right->global_cmd) + return 1; + + left_data = left->global_cmd; + right_data = right->global_cmd; + + if (left_data->ep > right_data->ep) + return 1; + else if (left_data->ep < right_data->ep) + return -1; + + if (left_data->cluster_id > right_data->cluster_id) + return 1; + else if (left_data->cluster_id < right_data->cluster_id) + return -1; + + if (left_data->command_id > right_data->command_id) + return 1; + else if (left_data->command_id < right_data->command_id) + return -1; + + /* endpoint, cluster_id and command_id are equal */ + return 0; +} + +static void _zbl_register_global_req(zigbee_h handle, zbl_req_cb_s *container) +{ + GList *list = NULL; + GList *item = NULL; + + if (NULL == handle || NULL == container) + return; + + list = handle->global_cmd_req; + + /* Insert item if not exists */ + DBG("Insert global cmd info"); + if (list) { + item = g_list_find_custom(list, container, _global_compare_func); + if (NULL != item) + handle->global_cmd_req = g_list_append(list, container); + } else + handle->global_cmd_req = g_list_append(list, container); +} + +static void _zbl_deregister_global_req(zigbee_h handle, zbl_req_cb_s *container) +{ + GList *list = NULL; + GList *item = NULL; + + if (NULL == handle || NULL == container) + return; + + list = handle->global_cmd_req; + if (NULL == list) + return; + + /* Remove item if exists */ + DBG("Remove global cmd info"); + item = g_list_find_custom(list, container, _global_compare_func); + if (NULL != item) + handle->global_cmd_req = g_list_remove(list, container); +} + +static void _zbl_remove_global_req(zigbee_h handle, unsigned char ep, + unsigned short cluster_id, unsigned char command_id) +{ + GList *head = NULL; + GList *iter = NULL; + zbl_req_cb_s *ret = NULL; + + if (NULL == handle) + return; + + head = handle->global_cmd_req; + iter = head; + + while (NULL != iter) { + GList *next = iter->next; + zbl_req_cb_s *container = iter->data; + if (container && container->global_cmd) { + zb_event_global_default_rsp_s *data = container->global_cmd; + + if (data && data->ep == ep && data->cluster_id == cluster_id + && data->command_id == command_id) { + DBG(" Found: ep[%d] cluster_id[%X] command_id[%X] / sid[%d]", + ep, cluster_id, command_id, container->sid); + ret = container; + break; + } + } + iter = next; + } + + if (ret) { + if (ret->sid) + g_dbus_connection_signal_unsubscribe(gdbus_conn, ret->sid); + + if (ret->tid) { + g_source_remove(ret->tid); + DBG("tid=%d removed"); + ret->tid = 0; + } + + _zbl_deregister_global_req(handle, ret); + } + +} +#endif /* ZB_FEATURE_GLOBAL_RSP_SYNC */ + +static void _zbl_signal_handler(GDBusConnection *connection, + const gchar *sender_name, const gchar *object_path, const gchar *interface_name, + const gchar *signal_name, GVariant *parameters, gpointer user_data) +{ + zigbee_h container = (zigbee_h)user_data; + RETM_IF(NULL == container, "container is null"); + RETM_IF(NULL == container->event_handler, "event_handler is null"); + DBG("%s signal received", signal_name); + + if (g_strcmp0(signal_name, "service_enabled") == 0) { + gboolean enabled; + g_variant_get(parameters, "(b)", &enabled); + + zb_event_data_s ev; + ev.data.enable = calloc(1, sizeof(zb_event_enable_s)); + RETM_IF(NULL == ev.data.enable, "Failed to memory allocation !"); + + ev.data.enable->status = (unsigned char)enabled; + container->event_handler(0, NULL, ZB_ZDP_ENABLE_EVENT, ev); + free(ev.data.enable); + } else if (g_strcmp0(signal_name, "form_network_done") == 0) { + nwk_addr pan_id; + g_variant_get(parameters, "(q)", &pan_id); + + zb_event_data_s ev; + ev.data.form_network = calloc(1, sizeof(zb_event_form_network_s)); + RETM_IF(NULL == ev.data.form_network, "Failed to memory allocation !"); + + memcpy(&ev.data.form_network->pan_id, &pan_id, sizeof(nwk_addr)); + container->event_handler(pan_id, NULL, ZB_ZDP_FORM_NETWORK_DONE, ev); + free(ev.data.form_network); + } else if (g_strcmp0(signal_name, "child_joined") == 0) { + nwk_addr addr16; + ieee_addr addr64; + unsigned char count; + unsigned char ep[10]; + unsigned char value; + + int j = 0; + GVariantIter *iter1 = NULL; + GVariantIter *iter2 = NULL; + + g_variant_get(parameters, "(a(y)ya(y)q)", &iter1, &count, &iter2, &addr16); + while (g_variant_iter_loop(iter1, "(y)", &value)) { + addr64[j] = value; + j++; + } + if (NULL != iter1) + g_variant_iter_free(iter1); + + j = 0; + while (g_variant_iter_loop(iter2, "(y)", &value)) { + ep[j] = value; + j++; + } + if (NULL != iter2) + g_variant_iter_free(iter2); + + zb_event_data_s ev; + ev.data.join = calloc(1, sizeof(zb_event_join_s)); + RETM_IF(NULL == ev.data.join, "Failed to memory allocation !"); + + ev.data.join->count = count; + memcpy(ev.data.join->ep, ep, count); + container->event_handler(addr16, addr64, ZB_ZDP_JOIN_EVENT, ev); + free(ev.data.join); + } else if (g_strcmp0(signal_name, "child_rejoined") == 0) { + ieee_addr addr64; + unsigned char value; + + int j = 0; + GVariantIter *iter = NULL; + + g_variant_get(parameters, "(a(y))", &iter); + while (g_variant_iter_loop(iter, "(y)", &value)) { + addr64[j] = value; + j++; + } + if (NULL != iter) + g_variant_iter_free(iter); + + zb_event_data_s ev; + memset(&ev, 0, sizeof(zb_event_data_s)); + container->event_handler(0, addr64, ZB_ZDP_REJOIN_EVENT, ev); + } else if (g_strcmp0(signal_name, "child_left") == 0) { + int j = 0; + ieee_addr addr64; + GVariantIter *iter = NULL; + unsigned char value, status; + + g_variant_get(parameters, "(a(y)y)", &iter, &status); + while (g_variant_iter_loop(iter, "(y)", &value)) { + addr64[j] = value; + j++; + } + if (NULL != iter) + g_variant_iter_free(iter); + + zb_event_data_s ev; + ev.data.child_left = calloc(1, sizeof(zb_event_child_left_s)); + RETM_IF(NULL == ev.data.child_left, "Failed to memory allocation !"); + + ev.data.child_left->status = status; + container->event_handler(0, addr64, ZB_ZDP_CHILD_LEFT, ev); + free(ev.data.child_left); + } else if (g_strcmp0(signal_name, "leave_network_done") == 0) { + nwk_addr addr16; + g_variant_get(parameters, "(q)", &addr16); + + zb_event_data_s ev; + memset(&ev, 0, sizeof(zb_event_data_s)); + container->event_handler(addr16, NULL, ZB_ZDP_LEAVE_DONE_EVENT, ev); + } else if (!g_strcmp0(signal_name, "zcl_global_default_response")) { + nwk_addr addr16; + unsigned char ep; + unsigned short cluster_id; + unsigned char command_id; + unsigned char status; + + g_variant_get(parameters, "(qyqyy)", &addr16, &ep, &cluster_id, &command_id, &status); + + zb_event_data_s ev; + ev.data.global_default_rsp = calloc(1, sizeof(zb_event_global_default_rsp_s)); + RETM_IF(NULL == ev.data.global_default_rsp, "Failed to memory allocation !"); + + ev.data.global_default_rsp->ep = ep; + ev.data.global_default_rsp->cluster_id = cluster_id; + ev.data.global_default_rsp->command_id = command_id; + ev.data.global_default_rsp->status = status; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + /* If there is global request already, remove that. */ + if (0x00 != status) + _zbl_remove_global_req(container, ep, cluster_id, command_id); +#endif + + container->event_handler(addr16, NULL, ZB_ZCL_GLOBAL_DEFAULT_RSP_EVENT, ev); + free(ev.data.global_default_rsp); + } else if (!g_strcmp0(signal_name, "alarm_count")) { + unsigned short alarm_count; + g_variant_get(parameters, "(q)", &alarm_count); + + zb_event_data_s ev; + ev.data.alarm = calloc(1, sizeof(zb_event_alarm_s)); + RETM_IF(NULL == ev.data.alarm, "Failed to memory allocation !"); + + ev.data.alarm->count = alarm_count; + container->event_handler(0, NULL, ZB_ZCL_ALARM_EVENT, ev); + free(ev.data.alarm); + } else if (!g_strcmp0(signal_name, "report_attr_handler_rsp")) { + nwk_addr addr16; + unsigned char ep; + unsigned char value; + unsigned short attrData; + unsigned short cluster_id; + unsigned char dataType; + unsigned short data_size; + int dsizeIndex = 0; + char dSize[3] = {'\0', '\0'}; + int i = 0, j = 0, records_len; + GVariantIter *attr_iter = NULL; + GVariantIter *dataType_iter = NULL; + GVariantIter *data_iter = NULL; + + attr_report_h *records = NULL; + + g_variant_get(parameters, "(qyqaqayayi)", &addr16, &ep, + &cluster_id, &attr_iter, &dataType_iter, &data_iter, &records_len); + + records = calloc(records_len, sizeof(attr_report_h)); + RETM_IF(NULL == records, "calloc() Fail(%d)", errno); + for (j = 0; j < records_len; j++) { + records[j] = calloc(1, sizeof(struct attribute_report_s)); + if (NULL == records[j]) { + for (i = 0; i < j; i++) + free(records[i]); + free(records); + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + if (NULL != dataType_iter) + g_variant_iter_free(dataType_iter); + if (NULL != data_iter) + g_variant_iter_free(data_iter); + + ERR("calloc() Fail(%d)", errno); + return; + } + } + DBG("record_length %d", records_len); + + j = 0; + while (g_variant_iter_loop(attr_iter, "q", &attrData) + && g_variant_iter_loop(dataType_iter, "y", &dataType)) { + records[j]->id = attrData; + records[j]->type = dataType; + DBG("dataType 0x%02x", records[j]->type); + DBG("AttributeId 0x%04x", records[j]->id); + j++; + } + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + if (NULL != dataType_iter) + g_variant_iter_free(dataType_iter); + + j = 0; + while (j < records_len) { + switch (records[j]->type) { + /* String */ + case ZB_ZCL_OCTAT_STRING: + case ZB_ZCL_CHRACTER_STRING: + g_variant_iter_loop(data_iter, "y", &value); + data_size = value + 1; + records[j]->value = calloc(data_size, sizeof(unsigned char)); + if (NULL == records[j]->value) { + for (i = 0; i < j; i++) + free(records[i]->value); + for (i = 0; i < records_len; i++) + free(records[i]); + free(records); + ERR("calloc() Fail(%d)", errno); + return; + } + records[j]->value[dsizeIndex] = value; + dsizeIndex++; + for (i = dsizeIndex; i < data_size - 2; i++) { + g_variant_iter_loop(data_iter, "y", &value); + records[j]->value[i] = value; + } + if (NULL != data_iter) + g_variant_iter_free(data_iter); + break; + case ZB_ZCL_LONG_OCTAT_STRING: + case ZB_ZCL_LONG_CHRACTER_STRING: + g_variant_iter_loop(data_iter, "y", &value); + dSize[0] = value; + g_variant_iter_loop(data_iter, "y", &value); + dSize[1] = value; + data_size = dSize[1]; + data_size = (data_size << 8) | dSize[0]; + data_size += 2; + records[j]->value = calloc(data_size, sizeof(unsigned char)); + if (NULL == records[j]->value) { + for (i = 0; i < j; i++) + free(records[i]->value); + for (i = 0; i < records_len; i++) + free(records[i]); + free(records); + ERR("calloc() Fail(%d)", errno); + return; + } + records[j]->value[dsizeIndex] = dSize[dsizeIndex]; + dsizeIndex++; + records[j]->value[dsizeIndex] = dSize[dsizeIndex]; + dsizeIndex++; + for (i = dsizeIndex; i < data_size - 2; i++) { + g_variant_iter_loop(data_iter, "y", &value); + records[j]->value[i] = value; + } + if (NULL != data_iter) + g_variant_iter_free(data_iter); + break; + /* Array, set and bag */ + case ZB_ZCL_ARRAY: + case ZB_ZCL_SET: + case ZB_ZCL_BAG: + /* structure */ + case ZB_ZCL_STRUCTURE: + ERR("Not supported type = %d", records[i]->type); + continue; + default: + data_size = zb_get_data_size(records[j]->type); + records[j]->value = calloc(data_size, sizeof(unsigned char)); + if (NULL == records[j]->value) { + for (i = 0; i < j; i++) + free(records[i]->value); + for (i = 0; i < records_len; i++) + free(records[i]); + free(records); + ERR("calloc() Fail(%d)", errno); + return; + } + if (data_size != 0xFF) { + for (i = 0; i < data_size; i++) { + g_variant_iter_loop(data_iter, "y", &value); + records[j]->value[i] = value; + DBG("value[%d] 0x%02X", i, records[j]->value[i]); + } + } + if (NULL != data_iter) + g_variant_iter_free(data_iter); + } + DBG("DataType = 0x%02X Data Size = %d", records[j]->type, data_size); + j++; + } + + zb_event_data_s ev; + ev.data.global_attr_report = calloc(1, sizeof(zb_event_global_attr_report_s)); + if (NULL == ev.data.global_attr_report) { + ERR("Failed to memory allocation !"); + for (j = 0; j < records_len; j++) { + free(records[j]->value); + free(records[j]); + } + return; + } + + ev.data.global_attr_report->records = records; + ev.data.global_attr_report->count = records_len; + container->event_handler(addr16, NULL, ZB_ZCL_GLOBAL_ATTRIBUTE_REPORT_EVENT, ev); + for (j = 0; j < records_len; j++) { + free(records[j]->value); + free(records[j]); + } + free(records); + free(ev.data.global_attr_report); + } else if (!g_strcmp0(signal_name, "status_change_rpt")) { + zb_event_data_s ev; + nwk_addr addr16; + unsigned char src_ep; + unsigned char extended_status; + unsigned short zone_status; + unsigned short delay; + unsigned char zone_id; + g_variant_get(parameters, "(qyqyyq)", &addr16, &src_ep, &zone_status, + &extended_status, &zone_id, &delay); + if (0xff == zone_id) { + ev.data.ias_noti = calloc(1, sizeof(zb_event_ias_noti_s)); + RETM_IF(NULL == ev.data.ias_noti, "Failed to memory allocation !"); + + ev.data.ias_noti->src_ep = src_ep; + ev.data.ias_noti->zone_status = zone_status; + container->event_handler(addr16, NULL, + ZB_ZCL_IAS_ZONE_STATUS_CHANGE_NOTIFICATION_EVENT, ev); + + free(ev.data.ias_noti); + } else { + ev.data.ias_extended_noti = calloc(1, sizeof(zb_event_ias_extended_noti_s)); + RETM_IF(NULL == ev.data.ias_extended_noti, "Failed to memory allocation !"); + + ev.data.ias_extended_noti->src_ep = src_ep; + ev.data.ias_extended_noti->zone_status = zone_status; + ev.data.ias_extended_noti->extended_status = extended_status; + ev.data.ias_extended_noti->zone_id = zone_id; + ev.data.ias_extended_noti->delay = delay; + container->event_handler(addr16, NULL, + ZB_ZCL_IAS_ZONE_STATUS_CHANGE_EXTENDED_NOTIFICATION_EVENT, ev); + + free(ev.data.ias_extended_noti); + } + } else if (!g_strcmp0(signal_name, "enroll_request")) { + nwk_addr addr16; + unsigned char src_ep; + unsigned short zone_type; + unsigned char mfg_code; + zb_event_data_s ev; + ev.data.ias_enroll_request = calloc(1, sizeof(zb_event_ias_enroll_request_s)); + RETM_IF(NULL == ev.data.ias_enroll_request, "Failed to memory allocation !"); + + g_variant_get(parameters, "(qyqy)", &addr16, &src_ep, &zone_type, &mfg_code); + ev.data.ias_enroll_request->src_ep = src_ep; + ev.data.ias_enroll_request->zone_type = zone_type; + ev.data.ias_enroll_request->mfg_code = mfg_code; + container->event_handler(addr16, NULL, ZB_ZCL_IAS_ZONE_ENROLL_REQUEST_EVENT, ev); + free(ev.data.ias_enroll_request); + } else + ERR("Can't handle this signal=%s", signal_name); + return; +} + +static void _zbl_dbus_unsubscribe_signal(GList *sub_ids) +{ + RET_IF(NULL == gdbus_conn); + RET_IF(NULL == sub_ids); + + while (sub_ids) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, GPOINTER_TO_UINT(sub_ids->data)); + sub_ids = g_list_remove(sub_ids, sub_ids->data); + } + g_list_free(sub_ids); +} + +static int _zbl_dbus_subscribe_signal(zigbee_h handle) +{ + unsigned int id; + + /* Section 1. Subscribe ZDO signal */ + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, + "service_enabled", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(service_enabled) Fail(%d)", errno); + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for service_enabled signal %d", id); + + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, + "child_joined", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(child_rejoined) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for child_joined signal %d", id); + + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, + "child_rejoined", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(child_rejoined) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for child_rejoined signal %d", id); + + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, + "child_left", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(child_left) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for child_left signal %d", id); + + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, + "leave_network_done", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(leave_network_done) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for leave_network_done signal %d", id); + + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_SERVICE_INTERFACE, + "form_network_done", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(form_network_done) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for form_network_done signal %d", id); + + /* Section 3. Subscribe ZCL global command */ + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "zcl_global_default_response", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, G_DBUS_CALL_FLAGS_NONE, + _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(zcl_global_default_response) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for zcl_global_default_response signal %d", id); + + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "report_attr_handler_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, G_DBUS_CALL_FLAGS_NONE, + _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(report_attr_handler_rsp) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for report_attr_handler_rsp signal %d", id); + + /* Section 2. Subscribe ZCL alarm cluster signal */ + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_ZCL_ALARM_INTERFACE, + "alarm_count", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(alarm_count) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for alarm_count signal %d", id); + + /* Section 3. Subscribe ZCL IAS cluster signal */ + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_ZCL_IAS_ZONE_INTERFACE, + "status_change_rpt", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(status_change_rpt) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for status_change_rpt signal %d", id); + + id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, ZIGBEE_ZCL_IAS_ZONE_INTERFACE, + "enroll_request", ZIGBEE_CONTROL_OBJECT_PATH, NULL, + G_DBUS_CALL_FLAGS_NONE, _zbl_signal_handler, handle, NULL); + if (0 == id) { + ERR("g_dbus_connection_signal_subscribe(enroll_request) Fail(%d)\n", errno); + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + return ZIGBEE_ERROR_IO_ERROR; + } + handle->dbus_sub_ids = g_list_append(handle->dbus_sub_ids, GUINT_TO_POINTER(id)); + DBG("subscribed for enroll_request signal %d", id); + + return ZIGBEE_ERROR_NONE; +} + +static void _zbl_dbus_name_owner_notify(GObject *object, GParamSpec *pspec, + gpointer *user_data) +{ + GDBusProxy *proxy = G_DBUS_PROXY(object); + gchar *name_owner = g_dbus_proxy_get_name_owner(proxy); + zigbee_h handle = (zigbee_h)user_data; + + if (name_owner) + return; + + zbl_dbus_stop(handle); +} + +static void _zbl_request_cleanup(gpointer data) +{ + zbl_req_cb_s *container = data; + RET_IF(NULL == container); + + if (container->tid) { + g_source_remove(container->tid); + DBG("tid=%d removed"); + container->tid = 0; + } + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + _zbl_deregister_global_req(container->handle, container); +#endif + + free(container); +} + +static gboolean _zbl_timeout_cb(gpointer p) +{ + zbl_req_cb_s *container = (zbl_req_cb_s *)p; + + RETVM_IF(NULL == gdbus_conn, G_SOURCE_REMOVE, "gdbus_conn is NULL"); + RETVM_IF(NULL == p, G_SOURCE_REMOVE, "container is NULL"); + RETVM_IF(NULL == container->cb, G_SOURCE_REMOVE, "cb is NULL"); + RETVM_IF(true == container->found, G_SOURCE_REMOVE, "cb was alreay handled"); + + switch (container->cid) { + /* Service */ + case ZBL_SERVICE_FORM_NETWORK: { + zb_form_network_cb cb = container->cb; + cb(0x0000, container->userdata); + } + break; + case ZBL_SERVICE_DISABLE_NETWORK: { + zb_disable_network_cb cb = container->cb; + cb(0x0000, container->userdata); + cb(ZB_ZDP_TIMEOUT, container->userdata); + } + break; + /* ZDP except Bind */ + case ZBL_ZDO_NWK_ADDR_REQ: { + zb_zdo_addr_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, NULL, 0, 0, 0, NULL, container->userdata); + } + break; + case ZBL_ZDO_NWK_ADDR_EXT_REQ: { + zb_zdo_addr_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, NULL, 0, 0, 0, NULL, container->userdata); + } + break; + case ZBL_ZDO_ACTIVE_EP_REQ: { + zb_zdo_active_ep_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, 0, 0, NULL, container->userdata); + } + break; + case ZBL_ZDO_SIMPLE_DESC_REQ: { + zb_zdo_simple_desc_rsp cb = container->cb; + cb(0, 0, NULL, container->userdata); + } + break; + case ZBL_ZDO_MATCHED_DESCRIPTOR_REQ: { + zb_zdo_match_desc_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, 0, 0, NULL, container->userdata); + } + break; + case ZBL_ZDO_COMPLEX_DESC_REQ: { + zb_zdo_complex_desc_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, 0, 0, NULL, container->userdata); + } + break; + case ZBL_ZDO_MGMT_BIND_REQ: { + zb_zdo_mgmt_bind_rsp cb = container->cb; + zb_zdo_binding_table_h *records = NULL; + + records = calloc(1, sizeof(zb_zdo_binding_table_h)); + if (records) + records[0] = calloc(1, sizeof(struct zb_zdo_binding_table_s)); + + cb(ZB_ZDP_TIMEOUT, 0, 0, 0, records, container->userdata); + + free(records[0]); + free(records); + } + break; + case ZBL_ZDO_MGMT_LQI_REQ: { + zb_zdo_mgmt_lqi_rsp cb = container->cb; + zb_zdo_neighbor_table_desc_h *records = NULL; + + records = calloc(1, sizeof(zb_zdo_neighbor_table_desc_h)); + if (records) + records[0] = calloc(1, sizeof(struct zb_zdo_neighbor_table_desc_s)); + + cb(ZB_ZDP_TIMEOUT, 0, 0, 0, records, container->userdata); + + free(records[0]); + free(records); + } + break; + case ZBL_ZDO_MGMT_RTG_REQ: { + zb_zdo_mgmt_rtg_rsp cb = container->cb; + zb_zdo_routing_table_h *records = NULL; + + records = calloc(1, sizeof(zb_zdo_routing_table_h)); + if (records) + records[0] = calloc(1, sizeof(struct zb_zdo_routing_table_s)); + + cb(ZB_ZDP_TIMEOUT, 0, 0, 0, records, container->userdata); + + free(records[0]); + free(records); + } + break; + case ZBL_ZDO_MGMT_NWK_DISC_REQ: { + zb_zdo_mgmt_nwk_disc_rsp cb = container->cb; + zb_zdo_network_list_record_h *records = NULL; + records = calloc(1, sizeof(zb_zdo_network_list_record_h)); + if (records) + records[0] = calloc(1, sizeof(struct zb_zdo_network_list_record_s)); + + cb(0, 0, 0, 0, records, container->userdata); + free(records[0]); + free(records); + } + break; + case ZBL_ZDO_MGMT_PERMIT_JOIN_REQ: { + zb_zdo_mgmt_permit_joining_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, container->userdata); + } + break; + case ZBL_ZDO_MGMT_LEAVE_REQ: { + zb_zdo_mgmt_leave_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, container->userdata); + } + break; + case ZBL_ZDO_NODE_DESC_REQ: { + zb_zdo_node_desc_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, 0, NULL, container->userdata); + } + break; + case ZBL_ZDO_POWER_DESC_REQ: { + zb_zdo_power_desc_rsp cb = container->cb; + cb(0, 0, NULL, container->userdata); + } + break; + case ZBL_ZDO_USER_DESC_REQ: { + zb_zdo_user_desc_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, 0, 0, NULL, container->userdata); + } + case ZBL_ZDO_USER_DESC_SET_REQ: { + zb_zdo_user_desc_conf cb = container->cb; + cb(ZB_ZDP_TIMEOUT, container->userdata); + } + break; + /* ZDP Bind */ + case ZBL_ZDO_BIND_REQ: { + zb_zdo_bind_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, container->userdata); + } + break; + case ZBL_ZDO_UNBIND_REQ: { + zb_zdo_unbind_rsp cb = container->cb; + cb(ZB_ZDP_TIMEOUT, container->userdata); + } + break; + /* Custom */ + case ZBL_CUSTOM_APS_SEND_REQ: { + zb_aps_send_rsp cb = container->cb; + cb(0, 0, 0, 0, 0, 0, NULL, container->userdata); + } break; + case ZBL_CUSTOM_ZCL_SEND_REQ: { + zb_zcl_send_rsp cb = container->cb; + cb(0, 0, 0, 0, 0, 0, NULL, container->userdata); + } + break; + case ZBL_CUSTOM_LOCAL_SEND_REQ: { + zb_send_to_local_rsp cb = container->cb; + cb(0, NULL, container->userdata); + } + break; + /* ZCL Global */ + case ZBL_ZCL_GLOBAL_READ_ATTRIBUTE_REQ: { + zb_zcl_global_rsp cb = container->cb; + cb(0, 0, 0, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ: { + zb_zcl_global_rsp cb = container->cb; + cb(0, 0, 0, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_GLOBAL_CONFIGURE_REPORTING_REQ: { + zb_zcl_global_rsp cb = container->cb; + cb(0, 0, 0, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_REQ: { + zb_zcl_global_discover_attr_rsp cb = container->cb; + cb(0, 0, 0, 0, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_STRUCTURED_REQ: { + zb_zcl_global_rsp cb = container->cb; + cb(0, 0, 0, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_RECEIVED_REQ: { + zb_zcl_global_discover_cmds_rsp cb = container->cb; + cb(0, 0, 0, 0, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_GENERATED_REQ: { + zb_zcl_global_discover_cmds_rsp cb = container->cb; + cb(0, 0, 0, 0, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_EXTENDED_REQ: { + zb_zcl_global_discover_attr_extended_rsp cb = container->cb; + cb(0, 0, 0, 0, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_GLOBAL_READ_CONFIGURE_REPORTING_REQ: { + zb_zcl_global_rsp cb = container->cb; + cb(0, 0, 0, NULL, 0, container->userdata); + } + break; + /* ZCL Alarm */ + case ZBL_ZCL_ALARM_GET_ALARM_REQ: { + zb_zcl_alarm_get_alarm_rsp cb = container->cb; + cb(ZB_ZCL_TIMEOUT, 0, ZB_ZCL_UNSUP_CLUSTER_COMMAND, 0, 0, 0, container->userdata); + } + break; + /* ZCL Doorlock */ + case ZBL_ZCL_DOORLOCK_LOCK_STATE: { + zb_form_network_cb cb = container->cb; + cb(0x0000, container->userdata); + } + break; + /* ZCL Fanmode */ + case ZBL_ZCL_FANMODE_FAN_MODE_STATE: { + zb_form_network_cb cb = container->cb; + cb(0x0000, container->userdata); + } + break; + /* ZCL Group */ + case ZBL_ZCL_GROUP_ADD_GROUP_REQ: { + zb_zcl_group_add_group_rsp cb = container->cb; + cb(0, 0, 0, 0, container->userdata); + } + break; + case ZBL_ZCL_GROUP_VIEW_GROUP_REQ: { + zb_zcl_group_view_group_rsp cb = container->cb; + cb(0, 0, 0, 0, NULL, container->userdata); + } + break; + case ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ: { + zb_zcl_group_get_group_membership_rsp cb = container->cb; + cb(0, 0, 0, 0, NULL, container->userdata); + } + break; + case ZBL_ZCL_GROUP_REMOVE_GROUP_REQ: { + zb_zcl_group_remove_group_rsp cb = container->cb; + cb(0, 0, 0, 0, container->userdata); + } + break; + /* ZCL Identify */ + case ZBL_ZCL_IDENTIFY_QUERY_REQ: { + zb_zcl_identify_query_cb cb = container->cb; + cb(0, 0, container->userdata); + } + break; + /* ZCL On/Off */ + case ZBL_ZCL_ON_OFF_GET_ON_OFF_STATE: { + zb_form_network_cb cb = container->cb; + cb(0x0000, container->userdata); + } + break; + /* ZCL Pollcontrol */ + case ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ: { + zb_zcl_pollctrl_check_in cb = container->cb; + cb(0, 0, container->userdata); + } + break; + /* ZCL Scene */ + case ZBL_ZCL_SCENE_ADD_SCENE_REQ: { + zb_zcl_scene_add_scene_rsp cb = container->cb; + cb(0, 0, 0, 0, 0, container->userdata); + } + break; + case ZBL_ZCL_SCENE_VIEW_SCENE_REQ: { + zb_zcl_scene_view_scene_rsp cb = container->cb; + cb(0, 0, 0, 0, 0, 0, NULL, NULL, 0, container->userdata); + } + break; + case ZBL_ZCL_SCENE_REMOVE_SCENE_REQ: { + zb_zcl_scene_remove_scene_rsp cb = container->cb; + cb(0, 0, 0, 0, 0, container->userdata); + } + break; + case ZBL_ZCL_SCENE_STORE_SCENE_REQ: { + zb_zcl_scene_store_scene_rsp cb = container->cb; + cb(0, 0, 0, 0, 0, container->userdata); + } + break; + case ZBL_ZCL_SCENE_REMOVE_ALL_SCENE_REQ: { + zb_zcl_scene_remove_all_scene_rsp cb = container->cb; + cb(0, 0, 0, 0, container->userdata); + } + break; + case ZBL_ZCL_SCENE_GET_SCENE_MEMBERSHIP_REQ: { + zb_zcl_scene_get_scene_membership_rsp cb = container->cb; + cb(0, 0, 0, 0, 0, 0, NULL, container->userdata); + } + break; + /* ZCL Thermostat */ + case ZBL_ZCL_THERMOSTAT_GET_LOCAL_TEMP: { + zb_form_network_cb cb = container->cb; + cb(0x0000, container->userdata); + } + break; + default: + ERR("Unhandled cid = %d", container->cid); + } + + container->tid = 0; + g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); + container->sid = 0; + + return G_SOURCE_REMOVE; +} + +static void _zbl_response_cb(GDBusConnection *connection, + const gchar *sender_name, const gchar *object_path, const gchar *interface_name, + const gchar *signal_name, GVariant *parameters, gpointer user_data) +{ + zbl_req_cb_s *container = user_data; + RETM_IF(NULL == container, "container is null"); + RETM_IF(NULL == container->cb, "cb is NULL"); + + container->found = true; + g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); + + switch (container->cid) { + /* Service */ + case ZBL_SERVICE_FORM_NETWORK: { + zb_form_network_cb cb = container->cb; + nwk_addr panid; + g_variant_get(parameters, "(q)", &panid); + cb(panid, container->userdata); + } + break; + case ZBL_SERVICE_DISABLE_NETWORK: { + zb_disable_network_cb cb = container->cb; + unsigned char ret = ZB_ZDP_SUCCESS; + g_variant_get(parameters, "(y)", &ret); + cb(ret, container->userdata); + } + break; + /* ZDP except Bind */ + case ZBL_ZDO_NWK_ADDR_REQ: { + zb_zdo_addr_rsp cb = container->cb; + + int j = 0; + nwk_addr addr16; + ieee_addr addr64; + unsigned char status; + unsigned char num; + unsigned char start_idx; + unsigned char value; + GVariantIter *mac_iter = NULL; + + g_variant_get(parameters, "(ya(y)qyy)", &status, &mac_iter, &addr16, &num, &start_idx); + while (g_variant_iter_loop(mac_iter, "(y)", &value)) { + addr64[j] = value; + j++; + } + + cb(status, addr64, addr16, num, start_idx, NULL, container->userdata); + if (NULL != mac_iter) + g_variant_iter_free(mac_iter); + } + break; + case ZBL_ZDO_NWK_ADDR_EXT_REQ: { + zb_zdo_addr_rsp cb = container->cb; + + int j = 0; + nwk_addr addr16; + ieee_addr addr64; + unsigned char status; + unsigned char num; + unsigned char start_idx; + unsigned char value; + GVariantIter *mac_iter = NULL; + GVariantIter *assoc_iter = NULL; + + g_variant_get(parameters, "(ya(y)qyyaq)", &status, &mac_iter, + &addr16, &num, &start_idx, &assoc_iter); + while (g_variant_iter_loop(mac_iter, "(y)", &value)) { + addr64[j] = value; + j++; + } + if (NULL != mac_iter) + g_variant_iter_free(mac_iter); + if (NULL != assoc_iter) + g_variant_iter_free(assoc_iter); + + cb(status, addr64, addr16, num, start_idx, NULL, container->userdata); + } + break; + case ZBL_ZDO_ACTIVE_EP_REQ: { + zb_zdo_active_ep_rsp cb = container->cb; + + int j = 0; + nwk_addr addr16; + unsigned char status; + unsigned char count; + unsigned char value; + GVariantIter *ep_iter = NULL; + unsigned char *ep_list; + + g_variant_get(parameters, "(yqa(y)y)", &status, &addr16, &ep_iter, &count); + ep_list = calloc(count+1, sizeof(unsigned char)); + RETM_IF(NULL == ep_list, "calloc() Fail(%d)", errno); + + while (g_variant_iter_loop(ep_iter, "(y)", &value)) { + ep_list[j] = value; + j++; + } + if (NULL != ep_iter) + g_variant_iter_free(ep_iter); + + cb(status, addr16, count, ep_list, container->userdata); + free(ep_list); + } + break; + case ZBL_ZDO_SIMPLE_DESC_REQ: { + zb_zdo_simple_desc_rsp cb = container->cb; + + int j = 0; + int count; + unsigned short addr16; + unsigned short value; + GVariantIter *in_iter = NULL; + GVariantIter *out_iter = NULL; + zb_zdo_simple_desc_h records; + + records = calloc(1, sizeof(struct zb_zdo_simple_desc_s)); + RETM_IF(NULL == records, "calloc() Fail(%d)", errno); + + container->found = true; + + g_variant_get(parameters, "(qiyyqqyyaqaq)", &addr16, &count, + &records->device_ver, + &records->ep, &records->profile_id, &records->device_id, + &records->num_of_in_clusters, &records->num_of_out_clusters, + &in_iter, &out_iter); +#if 0 + records->in_clusters = calloc(records->num_of_in_clusters, sizeof(unsigned short)); + if (NULL == records->in_clusters) { + ERR("calloc() Fail(%d)", errno); + if (NULL != in_iter) + g_variant_iter_free(in_iter); + if (NULL != out_iter) + g_variant_iter_free(out_iter); + return; + } + records->out_clusters = calloc(records->num_of_out_clusters, sizeof(unsigned short)); + if (NULL == records->out_clusters) { + ERR("calloc() Fail(%d)", errno); + free(records->in_clusters); + if (NULL != in_iter) + g_variant_iter_free(in_iter); + if (NULL != out_iter) + g_variant_iter_free(out_iter); + return; + } +#endif + while (g_variant_iter_loop(in_iter, "q", &value)) { + records->in_clusters[j] = value; + j++; + } + if (NULL != in_iter) + g_variant_iter_free(in_iter); + + j = 0; + while (g_variant_iter_loop(out_iter, "q", &value)) { + records->out_clusters[j] = value; + j++; + } + if (NULL != out_iter) + g_variant_iter_free(out_iter); + + DBG("addr16=0x%x, count=%d, records->ep=%d, records->device_id=0x%x", + addr16, count, records->ep, records->device_id); + for (j = 0; j < records->num_of_in_clusters; j++) + DBG("in_clusters[%d] = 0x%x", j, records->in_clusters[j]); + for (j = 0; j < records->num_of_out_clusters; j++) + DBG("out_clusters[%d] = 0x%x", j, records->out_clusters[j]); + + cb(addr16, count, records, container->userdata); +#if 0 + free(records->in_clusters); + free(records->out_clusters); +#endif + free(records); + } + break; + case ZBL_ZDO_MATCHED_DESCRIPTOR_REQ: { + zb_zdo_match_desc_rsp cb = container->cb; + + int j = 0; + int match_len; + nwk_addr addr16; + unsigned char value; + unsigned char status; + GVariantIter *ml_iter = NULL; + unsigned char *match_list = NULL; + g_variant_get(parameters, "(yqya(y))", &status, &addr16, &value, &ml_iter); + match_len = value; + + if (match_len > 0) { + match_list = calloc(match_len+1, sizeof(unsigned char)); + RETM_IF(NULL == match_list, "calloc() Fail(%d)", errno); + while (g_variant_iter_loop(ml_iter, "(y)", &value)) { + match_list[j] = value; + DBG("match_list[i]=%d", j, match_list[j]); + j++; + } + if (NULL != ml_iter) + g_variant_iter_free(ml_iter); + } + + DBG("Match count : [%d]", match_len); + DBG("Match list : [%p]", match_list); + + cb(status, addr16, match_len, match_list, container->userdata); + + if (match_list) + free(match_list); + } + break; + case ZBL_ZDO_NODE_DESC_REQ: { + zb_zdo_node_desc_rsp cb = container->cb; + + nwk_addr addr16; + unsigned char status; + zb_zdo_node_descriptor_h desc; + + desc = calloc(1, sizeof(struct zb_zdo_node_descriptor_s)); + RETM_IF(NULL == desc, "calloc() Fail(%d)", errno); + + container->found = true; + + g_variant_get(parameters, "(yqyyyyyyqyqqqy)", &status, &addr16, + &desc->logical_type, &desc->complex_desciptor_available, + &desc->user_descriptor_available, &desc->aps_flags, &desc->frequency_band, + &desc->mac_capability_flags, &desc->manufacturer_code, &desc->maximum_buffer_size, + &desc->maximum_incoming_transfer_size, &desc->server_mask, + &desc->maximum_outgoing_transfer_size, &desc->descriptor_capability_field); + + cb(status, addr16, desc, container->userdata); + free(desc); + } + break; + case ZBL_ZDO_POWER_DESC_REQ: { + zb_zdo_power_desc_rsp cb = container->cb; + + nwk_addr addr16; + unsigned char status; + zb_zdo_node_power_descriptor_h desc; + + desc = calloc(1, sizeof(struct zb_zdo_node_power_descriptor_s)); + RETM_IF(NULL == desc, "calloc() Fail(%d)", errno); + + g_variant_get(parameters, "(yqyyyy)", &status, &addr16, + &desc->current_power_mode, &desc->available_power_sources, + &desc->current_power_source, &desc->current_power_source_level); + + cb(status, addr16, desc, container->userdata); + free(desc); + } + break; + case ZBL_ZDO_COMPLEX_DESC_REQ: { + zb_zdo_complex_desc_rsp cb = container->cb; + + int length; + nwk_addr addr16; + unsigned char j = 0; + unsigned char value; + unsigned char status; + GVariantIter *comp_iter = NULL; + unsigned char *complex_desc = NULL; + + g_variant_get(parameters, "(yqya(y))", &status, &addr16, &length, &comp_iter); + if (length > 0) { + complex_desc = calloc(length, sizeof(char)); + if (NULL == complex_desc) { + if (NULL != comp_iter) + g_variant_iter_free(comp_iter); + ERR("calloc() Fail(%d)", errno); + return; + } + + while (g_variant_iter_loop(comp_iter, "(y)", &value)) { + complex_desc[j] = value; + j++; + } + if (NULL != comp_iter) + g_variant_iter_free(comp_iter); + } + + cb(status, addr16, length, complex_desc, container->userdata); + free(complex_desc); + } + break; + case ZBL_ZDO_USER_DESC_REQ: { + zb_zdo_user_desc_rsp cb = container->cb; + + int length; + nwk_addr addr16; + unsigned char j = 0; + unsigned char value; + unsigned char status; + GVariantIter *comp_iter = NULL; + unsigned char *complex_desc = NULL; + + g_variant_get(parameters, "(yqya(y))", &status, &addr16, &length, &comp_iter); + if (length > 0) { + complex_desc = calloc(length, sizeof(char)); + if (NULL == complex_desc) { + if (NULL != comp_iter) + g_variant_iter_free(comp_iter); + ERR("calloc() Fail(%d)", errno); + return; + } + while (g_variant_iter_loop(comp_iter, "(y)", &value)) { + complex_desc[j] = value; + j++; + } + if (NULL != comp_iter) + g_variant_iter_free(comp_iter); + } + + cb(status, addr16, length, complex_desc, container->userdata); + free(complex_desc); + } + case ZBL_ZDO_USER_DESC_SET_REQ: { + zb_zdo_user_desc_conf cb = container->cb; + unsigned char status; + g_variant_get(parameters, "(y)", &status); + cb(status, container->userdata); + } + break; + case ZBL_ZDO_MGMT_BIND_REQ: { + zb_zdo_mgmt_bind_rsp cb = container->cb; + + unsigned char status; + unsigned char value; + + int i = 0; + int j = 0; + unsigned char binding_table_enteries; + unsigned char binding_table_list_count; + unsigned char start_index; + unsigned short dst_addr16 = 0; + unsigned char dst_ep = 0; + + GVariantIter *mac_iter = NULL; + GVariantIter *rsp_iter = NULL; + GVariantIter *destep_iter = NULL; + zb_zdo_binding_table_h *records = NULL; + + g_variant_get(parameters, "(yyyya(ayyqyqayy))", &status, + &binding_table_enteries, &start_index, + &binding_table_list_count, &rsp_iter); + + if (binding_table_list_count > 0) { + records = calloc(binding_table_list_count, sizeof(zb_zdo_binding_table_h)); + RETM_IF(NULL == records, "calloc() Fail(%d)", errno); + for (i = 0; i < binding_table_list_count; i++) { + records[i] = calloc(binding_table_list_count, sizeof(struct zb_zdo_binding_table_s)); + if (NULL == records[i]) { + if (NULL != mac_iter) + g_variant_iter_free(mac_iter); + if (NULL != rsp_iter) + g_variant_iter_free(rsp_iter); + if (NULL != destep_iter) + g_variant_iter_free(destep_iter); + ERR("calloc() Fail(%d)", errno); + goto MGMT_NWK_BIND_REQ_OUT; + } + } + } + for (i = 0; i < binding_table_list_count; i++) { + g_variant_iter_loop(rsp_iter, "(ayyqyqayy)", &mac_iter, + &records[i]->src_ep, &records[i]->cluster_id, + &records[i]->dst_addr_mode, &dst_addr16, + &destep_iter, &dst_ep); + for (j = 0; j < 8; j++) { + g_variant_iter_loop(mac_iter, "y", &value); + records[i]->src_addr64[j] = value; + } + if (NULL != mac_iter) + g_variant_iter_free(mac_iter); + + if (0x03 == records[i]->dst_addr_mode) { + for (j = 0; j < 8; j++) { + g_variant_iter_loop(destep_iter, "y", &value); + records[i]->dst_addr64[j] = value; + } + records[i]->dst_ep = dst_ep; + DBG("Destination MAC Addr : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + records[i]->dst_addr64[7], records[i]->dst_addr64[6], + records[i]->dst_addr64[5], records[i]->dst_addr64[4], + records[i]->dst_addr64[3], records[i]->dst_addr64[2], + records[i]->dst_addr64[1], records[i]->dst_addr64[0]); + + } else if (0x01 == records[i]->dst_addr_mode) { + records[i]->dst_addr16 = dst_addr16; + } + if (NULL != destep_iter) + g_variant_iter_free(destep_iter); + } + if (NULL != rsp_iter) + g_variant_iter_free(rsp_iter); + + cb(status, binding_table_enteries, start_index, binding_table_list_count, + records, container->userdata); + +MGMT_NWK_BIND_REQ_OUT: + for (i = 0; i < binding_table_list_count; i++) { + if (records[i]) + free(records[i]); + } + free(records); + } + break; + case ZBL_ZDO_MGMT_LQI_REQ: { + zb_zdo_mgmt_lqi_rsp cb = container->cb; + + int i = 0; + int j = 0; + unsigned char value; + unsigned char status; + unsigned char start_index; + unsigned char neighbor_table_enteries; + unsigned char neighbor_table_list_count; + + GVariantIter *resp_iter = NULL; + GVariantIter *mac_iter = NULL; + GVariantIter *mac_iter1 = NULL; + zb_zdo_neighbor_table_desc_h *records = NULL; + + g_variant_get(parameters, "(yyyya(ayayyqyyyyy))", &status, &neighbor_table_enteries, + &start_index, &neighbor_table_list_count, &resp_iter); + + if (neighbor_table_list_count > 0) { + records = calloc(neighbor_table_list_count, sizeof(zb_zdo_neighbor_table_desc_h)); + RETM_IF(NULL == records, "calloc() Fail(%d)", errno); + for (i = 0; i < neighbor_table_list_count; i++) { + records[i] = calloc(1, sizeof(struct zb_zdo_neighbor_table_desc_s)); + if (NULL == records[i]) { + ERR("calloc() Fail(%d)", errno); + goto MGMT_LQI_REQ_OUT; + } + } + } + for (i = 0; i < neighbor_table_list_count; i++) { + g_variant_iter_loop(resp_iter, "(ayayyqyyyyy)", + &mac_iter, &mac_iter1, + &records[i]->device_type, &records[i]->addr16, + &records[i]->rx_on_when_idle, &records[i]->relationship, + &records[i]->permit_joining, &records[i]->depth, + &records[i]->lqi); + for (j = 0; j < 8; j++) { + g_variant_iter_loop(mac_iter, "y", &value); + records[i]->extended_pan_id[j] = value; + g_variant_iter_loop(mac_iter1, "y", &value); + records[i]->addr64[j] = value; + } + if (NULL != mac_iter) + g_variant_iter_free(mac_iter); + if (NULL != mac_iter1) + g_variant_iter_free(mac_iter1); + + DBG("ext PAN ID = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + records[i]->extended_pan_id[0], records[i]->extended_pan_id[1], + records[i]->extended_pan_id[2], records[i]->extended_pan_id[3], + records[i]->extended_pan_id[4], records[i]->extended_pan_id[5], + records[i]->extended_pan_id[6], records[i]->extended_pan_id[7]); + + DBG("IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + records[i]->addr64[0], records[i]->addr64[1], records[i]->addr64[2], records[i]->addr64[3], + records[i]->addr64[4], records[i]->addr64[5], records[i]->addr64[6], records[i]->addr64[7]); + } + if (NULL != resp_iter) + g_variant_iter_free(resp_iter); + + cb(status, neighbor_table_enteries, start_index, neighbor_table_list_count, + records, container->userdata); + +MGMT_LQI_REQ_OUT: + for (i = 0; i < neighbor_table_list_count; i++) { + if (records[i]) + free(records[i]); + } + free(records); + } + break; + case ZBL_ZDO_MGMT_RTG_REQ: { + zb_zdo_mgmt_rtg_rsp cb = container->cb; + + int i; + unsigned char status; + unsigned char start_index; + unsigned char routing_table_enteries; + unsigned char routing_table_list_count; + + GVariantIter *rsp_iter = NULL; + zb_zdo_routing_table_h *records = NULL; + + g_variant_get(parameters, "(yyyya(qyyyyq))", &status, &routing_table_enteries, + &start_index, &routing_table_list_count, &rsp_iter); + + if (routing_table_list_count > 0) { + records = calloc(routing_table_list_count, sizeof(zb_zdo_routing_table_h)); + RETM_IF(NULL == records, "calloc() Fail(%d)", errno); + for (i = 0; i < routing_table_list_count; i++) { + records[i] = calloc(1, sizeof(struct zb_zdo_routing_table_s)); + if (NULL == records[i]) { + ERR("calloc() Fail(%d)", errno); + goto MGMT_NWK_RTG_REQ_OUT; + } + } + } + + for (i = 0; i < routing_table_list_count; i++) { + g_variant_iter_loop(rsp_iter, "(qyyyyq)", &records[i]->dst_addr, + &records[i]->status, &records[i]->memory_constrained, + &records[i]->route_record_required, + &records[i]->many_to_one, &records[i]->next_hop_addr); + } + if (NULL != rsp_iter) + g_variant_iter_free(rsp_iter); + + cb(status, routing_table_enteries, start_index, routing_table_list_count, + records, container->userdata); + +MGMT_NWK_RTG_REQ_OUT: + for (i = 0; i < routing_table_list_count; i++) { + if (records[i]) + free(records[i]); + } + free(records); + } + break; + case ZBL_ZDO_MGMT_NWK_DISC_REQ: { + zb_zdo_mgmt_nwk_disc_rsp cb = container->cb; + int i = 0; + int j = 0; + unsigned char value; + unsigned char status = 0; + unsigned char nwk_count = 0; + unsigned char start_index = 0; + unsigned char nwk_list_count = 0; + + GVariantIter *mac_iter = NULL; + GVariantIter *resp_iter = NULL; + + DBG("_zbl_mgmt_nwk_disc_req_cb()"); + + g_variant_get(parameters, "(yyyya(ayyyyyyy))", &status, &nwk_count, + &start_index, &nwk_list_count, &resp_iter); + + zb_zdo_network_list_record_h *records = NULL; + + if (!status) { + if (nwk_list_count > 0) { + records = calloc(nwk_list_count, sizeof(zb_zdo_network_list_record_h)); + RETM_IF(NULL == records, "calloc() Fail(%d)", errno); + for (i = 0; i < nwk_list_count; i++) { + records[i] = calloc(1, sizeof(struct zb_zdo_network_list_record_s)); + if (NULL == records[i]) { + ERR("calloc() Fail(%d)", errno); + goto MGMT_NWK_DISC_REQ_OUT; + } + } + } + for (i = 0; i < nwk_list_count; i++) { + g_variant_iter_loop(resp_iter, "(ayyyyyyy)", &mac_iter, &records[i]->logical_channel, + &records[i]->stack_profile, &records[i]->zigbee_version, &records[i]->beacon_order, + &records[i]->superframe_order, &records[i]->permit_joining); + for (j = 0; j < 8; j++) { + g_variant_iter_loop(mac_iter, "y", &value); + records[i]->extended_pan_id[j] = value; + } + if (NULL != mac_iter) + g_variant_iter_free(mac_iter); + } + if (NULL != resp_iter) + g_variant_iter_free(resp_iter); + } + + cb(status, nwk_count, start_index, nwk_list_count, records, container->userdata); + +MGMT_NWK_DISC_REQ_OUT: + for (i = 0; i < nwk_list_count; i++) { + if (records[i]) + free(records[i]); + } + free(records); + } + break; + case ZBL_ZDO_MGMT_PERMIT_JOIN_REQ: { + zb_zdo_mgmt_permit_joining_rsp cb = container->cb; + unsigned char status; + g_variant_get(parameters, "(y)", &status); + cb(status, container->userdata); + } + break; + case ZBL_ZDO_MGMT_LEAVE_REQ: { + zb_zdo_mgmt_leave_rsp cb = container->cb; + unsigned char status; + g_variant_get(parameters, "(y)", &status); + cb(status, container->userdata); + } + break; + /* ZDP Bind */ + case ZBL_ZDO_BIND_REQ: { + zb_zdo_bind_rsp cb = container->cb; + unsigned char status; + g_variant_get(parameters, "(y)", &status); + cb(status, container->userdata); + } + break; + case ZBL_ZDO_UNBIND_REQ: { + zb_zdo_unbind_rsp cb = container->cb; + unsigned char status; + g_variant_get(parameters, "(y)", &status); + cb(status, container->userdata); + } + break; + /* Custom */ + case ZBL_CUSTOM_APS_SEND_REQ: { + zb_aps_send_rsp cb = container->cb; + + unsigned short addr16; + unsigned char src_ep; + unsigned char dst_ep; + unsigned short cluster_id; + unsigned short profile_id; + unsigned short payload_len = 0; + unsigned char *payload = NULL; + + unsigned char value; + GVariantIter *payload_iter = NULL; + int i = 0; + + g_variant_get(parameters, "(qyyqqqa(y))", &addr16, &src_ep, &dst_ep, + &cluster_id, &profile_id, &payload_len, &payload_iter); + + if (payload_len > 0) { + payload = calloc(payload_len+1, sizeof(unsigned char)); + while (g_variant_iter_loop(payload_iter, "(y)", &value)) + payload[i++] = value; + + if (NULL != payload_iter) + g_variant_iter_free(payload_iter); + } + + cb(addr16, src_ep, dst_ep, cluster_id, profile_id, payload_len, payload, + container->userdata); + + free(payload); + } + break; + case ZBL_CUSTOM_ZCL_SEND_REQ: { + zb_zcl_send_rsp cb = container->cb; + + unsigned short addr16; + unsigned char src_ep; + unsigned char dst_ep; + unsigned short cluster_id; + unsigned short profile_id; + unsigned short payload_len = 0; + unsigned char *payload = NULL; + + unsigned char value; + GVariantIter *payload_iter = NULL; + int i = 0; + + g_variant_get(parameters, "(qyyqqqa(y))", &addr16, &src_ep, &dst_ep, + &cluster_id, &profile_id, &payload_len, &payload_iter); + + if (payload_len > 0) { + payload = calloc(payload_len + 1, sizeof(unsigned char)); + while (g_variant_iter_loop(payload_iter, "(y)", &value)) + payload[i++] = value; + + if (NULL != payload_iter) + g_variant_iter_free(payload_iter); + } + + cb(addr16, src_ep, dst_ep, cluster_id, profile_id, payload_len, payload, + container->userdata); + + free(payload); + } + break; + case ZBL_CUSTOM_LOCAL_SEND_REQ: { + zb_send_to_local_rsp cb = container->cb; + + unsigned char *data = NULL; + unsigned short length = 0; + unsigned char value; + GVariantIter *payload_iter = NULL; + int i = 0; + + g_variant_get(parameters, "(qa(y))", &length, &payload_iter); + + if (length > 0) { + data = calloc(length, sizeof(unsigned char)); + while (g_variant_iter_loop(payload_iter, "(y)", &value)) + data[i++] = value; + + if (NULL != payload_iter) + g_variant_iter_free(payload_iter); + } + + cb(length, data, container->userdata); + + free(data); + } + break; + /* ZCL Global */ + case ZBL_ZCL_GLOBAL_READ_ATTRIBUTE_REQ: { + zb_zcl_global_rsp cb = container->cb; + + int j = 0; + int isString; + unsigned char value; + + nwk_addr addr16; + unsigned char ep; + unsigned short attr_id; + unsigned short cluster_id; + unsigned char status; + unsigned char type; + unsigned short records_len; + unsigned char attr_value[128]; + + GVariantIter *iter = NULL; + read_attr_status_record_h records; + zb_global_record_data_s *data; + + data = calloc(1, sizeof(zb_global_record_data_s)); + records = calloc(1, sizeof(struct read_attribute_status_record_s)); + if (!records || !data) { + ERR("calloc() Fail(%d)", errno); + goto GLOBAL_READ_ATTRIBUTE_REQ_OUT; + } + + g_variant_get(parameters, "(qya(y)qqyyqi)", + &addr16, &ep, &iter, &attr_id, &cluster_id, &status, &type, &records_len, &isString); + if (!isString) { + while (g_variant_iter_loop(iter, "(y)", &value)) { + attr_value[j] = value; + DBG("attr_value[%d] = 0x%02X", j, value); + j++; + } + if (NULL != iter) + g_variant_iter_free(iter); + } else { + while (g_variant_iter_loop(iter, "(y)", &value)) { + if (j == 0) + records_len = value; + attr_value[j] = value; + DBG("attr_value[%d] = 0x%02X", j, value); + j++; + } + if (NULL != iter) + g_variant_iter_free(iter); + } + + records->id = attr_id; + records->status = status; + records->type = type; + records->value = attr_value; + data->type = ZB_GLOBAL_READ_ATTR; + data->record.read_attr = &records; + data->records_len = records_len; + + cb(addr16, ep, cluster_id, data, records_len, container->userdata); + +GLOBAL_READ_ATTRIBUTE_REQ_OUT: + if (records) + free(records); + if (data) + free(data); + } + break; + case ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ: { + zb_zcl_global_rsp cb = container->cb; + + int i = 0; + nwk_addr addr16; + unsigned char ep; + unsigned short cluster_id; + unsigned short attribute_id; + int records_len; + unsigned char value; + + GVariantIter *stat_iter = NULL; + GVariantIter *attr_iter = NULL; + write_attr_status_record_h records; + zb_global_record_data_s *data; + + g_variant_get(parameters, "(qya(y)aqqi)", + &addr16, &ep, &stat_iter, &attr_iter, &cluster_id, &records_len); + + records = calloc(records_len, sizeof(struct write_attribute_status_record_s)); + data = calloc(1, sizeof(zb_global_record_data_s)); + if (!records || !data) { + if (NULL != stat_iter) + g_variant_iter_free(stat_iter); + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + ERR("calloc() Fail(%d)", errno); + goto GLOBAL_WRITE_ATTRIBUTE_REQ_OUT; + } + + while (g_variant_iter_loop(stat_iter, "(y)", &value)) { + records[i].status = value; + i++; + } + if (NULL != stat_iter) + g_variant_iter_free(stat_iter); + + i = 0; + while (g_variant_iter_loop(attr_iter, "q", &attribute_id)) { + records[i].id = attribute_id; + DBG("Attribute Id 0x%04X", attribute_id); + i++; + } + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + + data->type = ZB_GLOBAL_WRITE_ATTR; + data->record.write_attr = &records; + data->records_len = records_len; + + cb(addr16, ep, cluster_id, data, records_len, container->userdata); + +GLOBAL_WRITE_ATTRIBUTE_REQ_OUT: + free(records); + free(data); + } + break; + case ZBL_ZCL_GLOBAL_CONFIGURE_REPORTING_REQ: { + zb_zcl_global_rsp cb = container->cb; + nwk_addr addr16; + unsigned char ep; + unsigned short cluster_id; + unsigned short attIdVal; + unsigned char value; + int j = 0, l = 0, k = 0, rec_len; + GVariantIter *stat_iter = NULL; + GVariantIter *attr_iter = NULL; + GVariantIter *dir_iter = NULL; + report_config_response_record_h records; + zb_global_record_data_s *data; + + g_variant_get(parameters, "(a(y)aqa(y)qiqy)", + &stat_iter, &attr_iter, &dir_iter, &cluster_id, &rec_len, &addr16, &ep); + + records = calloc(rec_len, sizeof(struct reporting_configuration_response_record_s)); + data = calloc(1, sizeof(zb_global_record_data_s)); + if (!data || !records) { + if (NULL != stat_iter) + g_variant_iter_free(stat_iter); + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + if (NULL != dir_iter) + g_variant_iter_free(dir_iter); + ERR("calloc() Fail(%d)", errno); + goto GLOBAL_CONFIGURE_REPORTING_REQ_OUT; + } + + while (g_variant_iter_loop(stat_iter, "(y)", &value)) { + DBG("Value 0x%02X", value); + records[j].status = value; + j++; + } + if (NULL != stat_iter) + g_variant_iter_free(stat_iter); + + while (g_variant_iter_loop(attr_iter, "q", &attIdVal)) { + if (records[l].status != ZB_ZCL_SUCCESS) + records[l].id = attIdVal; + l++; + } + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + + while (g_variant_iter_loop(dir_iter, "(y)", &value)) { + if (records[k].status != ZB_ZCL_SUCCESS) + records[k].dir = value; + k++; + } + if (NULL != dir_iter) + g_variant_iter_free(dir_iter); + + data->type = ZB_GLOBAL_CONFIG_REPORT; + data->record.report_config_rsp = &records; + data->records_len = rec_len; + + cb(addr16, ep, cluster_id, data, rec_len, container->userdata); + +GLOBAL_CONFIGURE_REPORTING_REQ_OUT: + free(records); + free(data); + } + break; + case ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_REQ: { + zb_zcl_global_discover_attr_rsp cb = container->cb; + nwk_addr addr16; + unsigned char ep; + discover_attr_info_record_h *records; + + int records_len; + unsigned short cluster_id; + unsigned short attribute_id; + unsigned char value; + int j = 0, l = 0; + int discovery_complete; + GVariantIter *stat_iter = NULL; + GVariantIter *attr_iter = NULL; + + g_variant_get(parameters, "(qya(y)aqqii)", &addr16, &ep, &stat_iter, + &attr_iter, &cluster_id, &records_len, &discovery_complete); + records = calloc(records_len, sizeof(discover_attr_info_record_h)); + RETM_IF(NULL == records, "calloc() Fail(%d)", errno); + for (j = 0; j < records_len; j++) { + records[j] = calloc(1, sizeof(struct discover_attribute_info_record_s)); + if (NULL == records[j]) { + ERR("calloc() Fail(%d)", errno); + for (l = 0; l < j; l++) + free(records[l]); + free(records); + if (NULL != stat_iter) + g_variant_iter_free(stat_iter); + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + return; + } + } + + j = 0; + while (g_variant_iter_loop(stat_iter, "(y)", &value)) { + records[j]->type = value; + DBG("Attribute Type 0x%02X", value); + j++; + } + if (NULL != stat_iter) + g_variant_iter_free(stat_iter); + + while (g_variant_iter_loop(attr_iter, "q", &attribute_id)) { + records[l]->id = attribute_id; + DBG("Attribute Id 0x%04X", attribute_id); + l++; + } + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + + cb(addr16, ep, cluster_id, discovery_complete, records, records_len, + container->userdata); + + for (j = 0; j < records_len; j++) + free(records[j]); + free(records); + } + break; + case ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_STRUCTURED_REQ: { + zb_zcl_global_rsp cb = container->cb; + cb(0, 0, 0, NULL, 0, container->userdata); + } + break; + /* GLOBAL_DISCOVER_COMMAND_RECEIVED and GLOBAL_DISCOVER_COMMAND_GENERATED should be handled as same way */ + case ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_RECEIVED_REQ: + case ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_GENERATED_REQ: { + zb_zcl_global_discover_cmds_rsp cb = container->cb; + + nwk_addr addr16; + unsigned char ep; + + int j = 0; + char value; + unsigned short cluster_id; + unsigned short cmd_len; + unsigned char *cmd_data; + unsigned char discoveryComplete; + GVariantIter *cmd_iter = NULL; + + g_variant_get(parameters, "(a(y)qqqyy)", &cmd_iter, &cluster_id, &cmd_len, + &addr16, &ep, &discoveryComplete); + + cmd_data = calloc(cmd_len+1, sizeof(char)); + if (NULL == cmd_data) { + ERR("calloc() Fail(%d)", errno); + if (NULL != cmd_iter) + g_variant_iter_free(cmd_iter); + return; + } + + while (g_variant_iter_loop(cmd_iter, "(y)", &value)) { + DBG("Value 0x%02X", value); + cmd_data[j] = value; + j++; + } + if (NULL != cmd_iter) + g_variant_iter_free(cmd_iter); + + cb(addr16, ep, cluster_id, discoveryComplete, cmd_data, cmd_len, container->userdata); + free(cmd_data); + } + break; + case ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_EXTENDED_REQ: { + zb_zcl_global_discover_attr_extended_rsp cb = container->cb; + nwk_addr addr16; + unsigned char ep; + + int i = 0; + int j = 0; + unsigned short cluster_id; + unsigned char t_value; + unsigned char ac_value; + + unsigned short rec_len; + unsigned short attr_data; + unsigned char discoveryComplete; + GVariantIter *attr_iter = NULL; + GVariantIter *type_iter = NULL; + GVariantIter *ac_iter = NULL; + extended_attr_info_h *records; + + DBG("Will get the value now"); + + g_variant_get(parameters, "(aqa(y)a(y)qqqyy)", &attr_iter, &type_iter, &ac_iter, + &cluster_id, &rec_len, &addr16, &ep, &discoveryComplete); + + DBG("records length 0x%04X", rec_len); + + records = calloc(rec_len, sizeof(extended_attr_info_h)); + RETM_IF(NULL == records, "calloc() Fail(%d)", errno); + for (j = 0; j < rec_len; j++) { + records[j] = calloc(1, sizeof(struct extended_attribute_infomation_s)); + if (NULL == records[j]) { + for (i = 0; i < j; i++) + free(records[i]); + free(records); + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + if (NULL != type_iter) + g_variant_iter_free(type_iter); + if (NULL != ac_iter) + g_variant_iter_free(ac_iter); + + ERR("calloc() Fail(%d)", errno); + return; + } + } + + j = 0; + while (g_variant_iter_loop(attr_iter, "q", &attr_data) + && g_variant_iter_loop(type_iter, "(y)", &t_value) + && g_variant_iter_loop(ac_iter, "(y)", &ac_value)) { + DBG("attrData 0x%04X", attr_data); + DBG("t_value 0x%02X", t_value); + DBG("ac_value 0x%02X", ac_value); + records[j]->id = attr_data; + records[j]->type = t_value; + records[j]->acl = ac_value; + j++; + } + if (NULL != attr_iter) + g_variant_iter_free(attr_iter); + if (NULL != type_iter) + g_variant_iter_free(type_iter); + if (NULL != ac_iter) + g_variant_iter_free(ac_iter); + + cb(addr16, ep, cluster_id, discoveryComplete, records, rec_len, container->userdata); + + for (j = 0; j < rec_len; j++) + free(records[j]); + free(records); + } + break; + case ZBL_ZCL_GLOBAL_READ_CONFIGURE_REPORTING_REQ: { + zb_zcl_global_rsp cb = container->cb; + nwk_addr addr16; + unsigned char ep; + unsigned short cluster_id; + + int i = 0; + int j = 0; + char value; + unsigned char *status = NULL; + unsigned char *data_size = NULL; + unsigned char *change = NULL; + unsigned short record_length; + GVariantIter *resp_iter = NULL; + GVariantIter *data_iter = NULL; + + report_config_record_h *records = NULL; + zb_global_record_data_s *data = NULL; + + g_variant_get(parameters, "(qyqqa(yyqyqqayq))", + &addr16, &ep, &cluster_id, &record_length, &resp_iter); + + records = calloc(record_length, sizeof(report_config_record_h)); + for (i = 0; i < record_length; i++) { + records[i] = calloc(1, sizeof(struct reporting_configuration_record_s)); + if (NULL == records[i]) { + ERR("calloc() Fail(%d)", errno); + goto GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT; + } + } + data = calloc(1, sizeof(zb_global_record_data_s)); + if (!data || !records) { + ERR("calloc() Fail(%d)", errno); + goto GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT; + } + + DBG("record_length %d", record_length); + status = calloc(record_length, sizeof(unsigned char)); + data_size = calloc(record_length, sizeof(unsigned char)); + if (!status || !data_size) { + ERR("Couldn't allocate the memory (%s)", errno); + goto GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT; + } + + for (i = 0; i < record_length; i++) { + g_variant_iter_loop(resp_iter, "(yyqyqqayq)", &status[i], &records[i]->dir, + &records[i]->id, &records[i]->type, &records[i]->max_i, &records[i]->min_i, + &data_iter, &records[i]->to); + if (records[i]->dir != ZCL_REPORTING_DIRECTION_REPORTED && + (zb_get_analog_or_discret(records[i]->type) == DATA_TYPE_ANALOG)) { + data_size[i] = zb_get_data_size(records[j]->type); + j = 0; + if (data_size[i] != 0xff) { + change = calloc(data_size[i]+1, sizeof(unsigned char)); + if (!change) { + ERR("calloc() Fail(%d)", errno); + records[i]->change = NULL; + if (NULL != data_iter) + g_variant_iter_free(data_iter); + continue; + } + while (g_variant_iter_loop(data_iter, "y", &value)) { + change[j] = value; + j++; + } + if (NULL != data_iter) + g_variant_iter_free(data_iter); + records[i]->change = change; + } else + records[i]->change = NULL; + } else + records[i]->change = NULL; + } + if (NULL != resp_iter) + g_variant_iter_free(resp_iter); + + data->type = ZB_GLOBAL_READ_REPORT_CONFIG; + data->record.report_config = records; + data->records_len = record_length; + + cb(addr16, ep, cluster_id, data, record_length, container->userdata); + +GLOBAL_READ_CONFIGURE_REPORTING_REQ_OUT: + free(data_size); + free(status); + for (i = 0; i < record_length; i++) + free(records[i]); + free(records); + free(data); + } + break; + /* ZCL Alarm */ + case ZBL_ZCL_ALARM_GET_ALARM_REQ: { + zb_zcl_alarm_get_alarm_rsp cb = container->cb; + + nwk_addr addr16 = 0; + unsigned char ep = 0; + unsigned char status = 0; + unsigned char alarm_code = 0; + unsigned short cluster_id = 0; + unsigned int time_stamp = 0; + + g_variant_get(parameters, "(qyyyqu)", &addr16, &ep, &status, &alarm_code, + &cluster_id, &time_stamp); + cb(addr16, ep, status, alarm_code, cluster_id, time_stamp, container->userdata); + } + break; + /* ZCL Doorlock */ + case ZBL_ZCL_DOORLOCK_LOCK_STATE: { + ERR("Unhandled cid = %d", container->cid); + } + break; + /* ZCL Fanmode */ + case ZBL_ZCL_FANMODE_FAN_MODE_STATE: { + ERR("Unhandled cid = %d", container->cid); + } + break; + /* ZCL Group */ + case ZBL_ZCL_GROUP_ADD_GROUP_REQ: { + zb_zcl_group_add_group_rsp cb = container->cb; + + nwk_addr addr16; + unsigned char ep; + unsigned char status; + unsigned short group_id; + + g_variant_get(parameters, "(qyyq)", &addr16, &ep, &status, &group_id); + cb(addr16, ep, status, group_id, container->userdata); + } + break; + case ZBL_ZCL_GROUP_VIEW_GROUP_REQ: { + zb_zcl_group_view_group_rsp cb = container->cb; + + int j = 0; + nwk_addr addr16; + unsigned char ep; + unsigned char value; + unsigned char status; + unsigned short group_id; + char *group_name = NULL; + GVariantIter *grpNameiter = NULL; + + g_variant_get(parameters, "(qyyqay)", &addr16, &ep, &status, &group_id, &grpNameiter); + g_variant_iter_loop(grpNameiter, "y", &value); + /* first byte indicates the length of the string */ + if ((value - '0') > 0) { + DBG("Value %d ", (value - '0')); + group_name = calloc((value - '0') + 1, sizeof(char)); + if (NULL == group_name) { + if (NULL != grpNameiter) + g_variant_iter_free(grpNameiter); + ERR("calloc() Fail(%d)", errno); + goto GROUP_VIEW_GROUP_REQ_OUT; + } + group_name[j] = value; + j++; + while (g_variant_iter_loop(grpNameiter, "y", &value) && (j <= (value - '0'))) { + group_name[j] = value; + DBG("Name %c", group_name[j]); + j++; + } + if (NULL != grpNameiter) + g_variant_iter_free(grpNameiter); + } else { + group_name = calloc(1, sizeof(char)); + if (NULL == group_name) { + if (NULL != grpNameiter) + g_variant_iter_free(grpNameiter); + ERR("calloc() Fail(%d)", errno); + goto GROUP_VIEW_GROUP_REQ_OUT; + } + group_name[j] = value; + j++; + group_name[j] = '\0'; + j++; + } + + DBG("GroupName = %s", group_name); + cb(addr16, ep, status, group_id, group_name, container->userdata); +GROUP_VIEW_GROUP_REQ_OUT: + free(group_name); + } + break; + case ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ: { + zb_zcl_group_get_group_membership_rsp cb = container->cb; + + int j = 0; + nwk_addr addr16; + unsigned char ep; + unsigned short gl_value; + unsigned char capacity; + unsigned char group_count; + unsigned short *grouplist = NULL; + GVariantIter *grpListiter = NULL; + + g_variant_get(parameters, "(qyyyaq)", &addr16, &ep, &capacity, &group_count, &grpListiter); + + if (group_count > 0) { + grouplist = calloc(group_count+1, sizeof(unsigned short)); + if (NULL == grouplist) { + if (NULL != grpListiter) + g_variant_iter_free(grpListiter); + ERR("calloc() Fail(%d)", errno); + return; + } + RETM_IF(NULL == grouplist, "calloc() Fail(%d)", errno); + + while (g_variant_iter_loop(grpListiter, "q", &gl_value)) { + grouplist[j] = gl_value; + j++; + } + if (NULL != grpListiter) + g_variant_iter_free(grpListiter); + } + + cb(addr16, ep, capacity, group_count, grouplist, container->userdata); + + free(grouplist); + } + break; + case ZBL_ZCL_GROUP_REMOVE_GROUP_REQ: { + zb_zcl_group_remove_group_rsp cb = container->cb; + + nwk_addr addr16; + unsigned char ep; + unsigned char status; + unsigned short group_id; + + g_variant_get(parameters, "(qyyq)", &addr16, &ep, &status, &group_id); + + cb(addr16, ep, status, group_id, container->userdata); + } + break; + /* ZCL Identify */ + case ZBL_ZCL_IDENTIFY_QUERY_REQ: { + zb_zcl_identify_query_cb cb = container->cb; + + nwk_addr addr16 = 0; + unsigned short identify_time = 0; + g_variant_get(parameters, "(qq)", &addr16, &identify_time); + + cb(addr16, identify_time, container->userdata); + } + break; + /* ZCL On/Off */ + case ZBL_ZCL_ON_OFF_GET_ON_OFF_STATE: { + ERR("Unhandled cid = %d", container->cid); + } + break; + /* ZCL Pollcontrol */ + case ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ: { + zb_zcl_pollctrl_check_in cb = container->cb; + + nwk_addr addr16 = 0; + unsigned char ep = 0; + + g_variant_get(parameters, "(qy)", &addr16, &ep); + cb(addr16, ep, container->userdata); + } + break; + /* ZCL Scene */ + case ZBL_ZCL_SCENE_ADD_SCENE_REQ: { + zb_zcl_scene_add_scene_rsp cb = container->cb; + + nwk_addr addr16 = 0; + unsigned char ep; + unsigned char status; + unsigned short group_id; + unsigned char scene_id; + + g_variant_get(parameters, "(qyyqy)", &addr16, &ep, &status, &group_id, &scene_id); + cb(addr16, ep, status, group_id, scene_id, container->userdata); + } + break; + case ZBL_ZCL_SCENE_VIEW_SCENE_REQ: { + zb_zcl_scene_view_scene_rsp cb = container->cb; + + int j = 0; + int len; + nwk_addr addr16 = 0; + unsigned char ep; + unsigned char status; + unsigned short group_id; + unsigned char scene_id; + unsigned short transition_time = 0; + unsigned char value; + unsigned short ext_len = 0; + char *scene_name = NULL; + char *extendedFieldSets = NULL; + GVariantIter *sceneNameIter = NULL; + GVariantIter *extendedSetIter = NULL; + + g_variant_get(parameters, "(qyyqyqa(y)ya(y))", &addr16, &ep, &status, &group_id, &scene_id, + &transition_time, &sceneNameIter, &ext_len, &extendedSetIter); + + g_variant_iter_loop(sceneNameIter, "(y)", &value); + + /** first byte indicates the length of the string */ + len = value -'0'; + if (0 < len) { + scene_name = calloc(len + 1, sizeof(char)); + if (NULL == scene_name) { + ERR("calloc() Fail(%d)", errno); + goto SCENE_VIEW_SCENE_REQ_OUT; + } + scene_name[j] = value; + j++; + while (g_variant_iter_loop(sceneNameIter, "(y)", &value)) { + scene_name[j] = value; + j++; + } + } else { + scene_name = calloc(1 + 1, sizeof(char)); + if (NULL == scene_name) { + ERR("calloc() Fail(%d)", errno); + goto SCENE_VIEW_SCENE_REQ_OUT; + } + scene_name[j] = value; + } + + j = 0; + if (0 < ext_len) { + extendedFieldSets = calloc(ext_len + 1, sizeof(char)); + if (NULL == extendedFieldSets) { + ERR("calloc() Fail(%d)", errno); + goto SCENE_VIEW_SCENE_REQ_OUT; + } + while (g_variant_iter_loop(extendedSetIter, "(y)", &value)) { + extendedFieldSets[j] = value; + j++; + } + } + + cb(addr16, ep, status, group_id, scene_id, transition_time, scene_name, + extendedFieldSets, ext_len, container->userdata); + +SCENE_VIEW_SCENE_REQ_OUT: + free(scene_name); + free(extendedFieldSets); + } + break; + case ZBL_ZCL_SCENE_REMOVE_SCENE_REQ: { + zb_zcl_scene_remove_scene_rsp cb = container->cb; + + nwk_addr addr16 = 0; + unsigned char ep; + unsigned char status; + unsigned short group_id; + unsigned char scene_id; + + g_variant_get(parameters, "(qyyqy)", &addr16, &ep, &status, &group_id, &scene_id); + cb(addr16, ep, status, group_id, scene_id, container->userdata); + } + break; + case ZBL_ZCL_SCENE_STORE_SCENE_REQ: { + zb_zcl_scene_store_scene_rsp cb = container->cb; + + nwk_addr addr16 = 0; + unsigned char ep; + unsigned char status; + unsigned short group_id; + unsigned char scene_id; + + g_variant_get(parameters, "(qyyqy)", &addr16, &ep, &status, &group_id, &scene_id); + cb(addr16, ep, status, group_id, scene_id, container->userdata); + } + break; + case ZBL_ZCL_SCENE_REMOVE_ALL_SCENE_REQ: { + zb_zcl_scene_remove_all_scene_rsp cb = container->cb; + + nwk_addr addr16 = 0; + unsigned char ep; + unsigned char status; + unsigned short group_id; + + g_variant_get(parameters, "(qyyq)", &addr16, &ep, &status, &group_id); + cb(addr16, ep, status, group_id, container->userdata); + } + break; + case ZBL_ZCL_SCENE_GET_SCENE_MEMBERSHIP_REQ: { + zb_zcl_scene_get_scene_membership_rsp cb = container->cb; + + int j = 0; + nwk_addr addr16 = 0; + unsigned char ep; + unsigned char status; + unsigned short group_id; + unsigned char capacity; + unsigned char value; + unsigned char scene_count = 0; + unsigned char *scene_list = NULL; + GVariantIter *sceneListIter = NULL; + + g_variant_get(parameters, "(qyyyqya(y))", &addr16, &ep, &status, &capacity, &group_id, + &scene_count, &sceneListIter); + + if (0 < scene_count) { + scene_list = calloc(scene_count+1, sizeof(char)); + if (NULL == scene_list) { + ERR("calloc() Fail(%d)", errno); + goto SCENE_GET_SCENE_MEMBERSHIP_REQ_OUT; + } + while (g_variant_iter_loop(sceneListIter, "(y)", &value)) { + scene_list[j] = value; + DBG("Scene_List 0x%02X", scene_list[j]); + j++; + } + } + + cb(addr16, ep, status, capacity, group_id, scene_count, scene_list, container->userdata); +SCENE_GET_SCENE_MEMBERSHIP_REQ_OUT: + free(scene_list); + } + break; + /* ZCL Thermostat */ + case ZBL_ZCL_THERMOSTAT_GET_LOCAL_TEMP: { + ERR("Unhandled cid = %d", container->cid); + } + break; + default: + ERR("Unhandled cid = %d", container->cid); + } +} + +int zbl_set_event_cb(zigbee_h handle, zb_event_cb event_handler) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->event_handler = event_handler; + return ZIGBEE_ERROR_NONE; +} + +static gboolean _zbl_timeout_enable(gpointer p) +{ + zbl_req_cb_s *container = NULL; + zb_enable_cb cb = NULL; + + DBG("zb_enable_cb()"); + + RETVM_IF(NULL == gdbus_conn, G_SOURCE_REMOVE, "gdbus_conn is NULL"); + container = p; + RETVM_IF(NULL == container, G_SOURCE_REMOVE, "cb_container is NULL"); + cb = container->cb; + + if (false == container->found && container->cb) + cb(ZB_ZDP_NOT_SUPPORTED, container->userdata); + + container->tid = 0; + + g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); + DBG("container->sid=%d unsubscribed"); + container->sid = 0; + + return G_SOURCE_REMOVE; +} + +static void _zbl_enable_cb(GDBusConnection *connection, + const gchar *sender_name, const gchar *object_path, const gchar *interface_name, + const gchar *signal_name, GVariant *parameters, gpointer user_data) +{ + zbl_req_cb_s *container = user_data; + zb_enable_cb cb = container->cb; + + unsigned char ret = ZB_ZDP_SUCCESS; + gboolean value = TRUE; + + container->found = true; + + DBG("_zbl_enable_cb"); + + g_variant_get(parameters, "(b)", &value); + if (!value) + ret = ZB_ZDP_UNKNOWN; + + if (cb) + cb(ret, container->userdata); + + if (container->sid) + g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); +} + + +int zbl_enable(zigbee_h handle, zb_enable_cb cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + + DBG("zbl_enable()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = ZIGBEE_BROADCAST_TIMEOUT; + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_MANAGER_INTERFACE, "zigbee_state", ZIGBEE_DBUS_OBJPATH, + NULL, G_DBUS_SIGNAL_FLAGS_NONE, + _zbl_enable_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_enable, container); + container->userdata = user_data; + + g_dbus_connection_call(gdbus_conn, + ZIGBEE_MANAGER_INTERFACE, + ZIGBEE_DBUS_OBJPATH, + ZIGBEE_MANAGER_INTERFACE, + "enable", + NULL, NULL, + G_DBUS_CALL_FLAGS_NONE, + to, NULL, + NULL, NULL); + + return ZIGBEE_ERROR_NONE; +} + +int zbl_disable(void) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_disable()"); + + variant = g_dbus_connection_call_sync(gdbus_conn, + ZIGBEE_SERVER_NAME, + ZIGBEE_DBUS_OBJPATH, + ZIGBEE_MANAGER_INTERFACE, + "disable", + NULL, NULL, + G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'disable' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_hw_reset(void) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(service_gproxy, "zb_hw_reset", NULL, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'zb_hw_reset' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_get_network_info(ieee_addr addr64, nwk_addr *nodeid, nwk_addr *panid, + unsigned char *channel, unsigned char *tx_power) +{ + GVariant *variant = NULL; + GVariantIter *iter = NULL; + GError *dbus_err = NULL; + int result = ZIGBEE_ERROR_NONE; + + nwk_addr _nodeid; + nwk_addr _panid; + unsigned char _radio_channel; + unsigned char _radio_tx_power; + unsigned char value; + int i = 0; + + DBG("zbl_get_network_info()"); + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(service_gproxy, "get_network_info", + NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to 'get_network_info' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(ia(y)qqyy)", &result, &iter, + &_nodeid, &_panid, &_radio_channel, &_radio_tx_power); + + /* Get EUI */ + i = 0; + while (g_variant_iter_loop(iter, "(y)", &value)) { + addr64[i] = value; + i++; + } + + DBG(" Result: [%X]", result); + DBG(" EUI(%d) : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", i, + addr64[0], addr64[1], addr64[2], addr64[3], + addr64[4], addr64[5], addr64[6], addr64[7]); + DBG(" nodeID [0x%04X]", _nodeid); + DBG(" PanID [0x%04X]", _panid); + DBG(" Channel [%d] Tx Power [%d]", _radio_channel, _radio_tx_power); + + if (nodeid) + *nodeid = _nodeid; + if (panid) + *panid = _panid; + if (channel) + *channel = _radio_channel; + if (tx_power) + *tx_power = _radio_tx_power; + + if (iter) + g_variant_iter_free(iter); + g_variant_unref(variant); + + return result; +} + +int zbl_get_controller_mac_address(ieee_addr addr64) +{ + GVariant *variant = NULL; + GVariantIter *iter = NULL; + GError *dbus_err = NULL; + + char value; + int j = 0; + int result = ZIGBEE_ERROR_NONE; + + DBG("zbl_get_controller_mac_address()"); + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(service_gproxy, "get_mac", + NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get_mac [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + g_variant_get(variant, "(ia(y))", &result, &iter); + + while (g_variant_iter_loop(iter, "(y)", &value)) { + addr64[j] = value; + j++; + } + + DBG("IEEE ADDR 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X, Ret=%d ", + addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], + addr64[6], addr64[7], result); + + if (iter) + g_variant_iter_free(iter); + g_variant_unref(variant); + + return result; +} + +int zbl_get_cluster_list(ieee_addr eui64, unsigned char endpoint, + unsigned char *in_cluster_count, unsigned short in_cluster_list[], + unsigned char *out_cluster_count, unsigned short out_cluster_list[]) +{ + GVariant *variant = NULL; + GVariantBuilder *mac_builder = NULL; + GVariant *mac_variant = NULL; + GVariantIter *in_cluster_iter = NULL; + GVariantIter *out_cluster_iter = NULL; + GError *dbus_err = NULL; + unsigned short cluster = 0; + int i = 0; + int result = 0; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + g_variant_builder_add(mac_builder, "(y)", eui64[7]); + g_variant_builder_add(mac_builder, "(y)", eui64[6]); + g_variant_builder_add(mac_builder, "(y)", eui64[5]); + g_variant_builder_add(mac_builder, "(y)", eui64[4]); + g_variant_builder_add(mac_builder, "(y)", eui64[3]); + g_variant_builder_add(mac_builder, "(y)", eui64[2]); + g_variant_builder_add(mac_builder, "(y)", eui64[1]); + g_variant_builder_add(mac_builder, "(y)", eui64[0]); + mac_variant = g_variant_builder_end(mac_builder); + g_variant_builder_unref(mac_builder); + + variant = g_dbus_proxy_call_sync(service_gproxy, "get_cluster_list", + g_variant_new("(@a(y)y)", mac_variant, endpoint), G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &dbus_err); + + if (variant) { + g_variant_get(variant, "(iaqaq)", &result, &in_cluster_iter, &out_cluster_iter); + DBG("ret = [0x%x]", result); + + /* In clusters */ + while (g_variant_iter_loop(in_cluster_iter, "q", &cluster)) { + DBG("In Cluster 0x%04X", cluster); + in_cluster_list[i++] = cluster; + } + *in_cluster_count = i; + if (0 == i) + ERR("No In Clusters for Endpoint %0X", endpoint); + + /* Out clusters */ + i = 0; + while (g_variant_iter_loop(out_cluster_iter, "q", &cluster)) { + DBG("Out Cluster 0x%04X", cluster); + out_cluster_list[i++] = cluster; + } + *out_cluster_count = i; + if (0 == i) + ERR("No Out Clusters for Endpoint %0X", endpoint); + + if (NULL != in_cluster_iter) + g_variant_iter_free(in_cluster_iter); + if (NULL != out_cluster_iter) + g_variant_iter_free(out_cluster_iter); + g_variant_unref(variant); + } else { + ERR("No In/Out Clusters for Endpoint %0X [%s]", endpoint, dbus_err->message); + g_error_free(dbus_err); + *in_cluster_count = 0; + *out_cluster_count = 0; + } + + return ZIGBEE_ERROR_NONE; +} + +int zbl_get_endpoint_list(ieee_addr eui64, unsigned char *count, unsigned char list[]) +{ + GVariant *variant = NULL; + GVariantBuilder *mac_builder = NULL; + GVariant *mac_variant = NULL; + GVariantIter *iter = NULL; + GError *dbus_err = NULL; + unsigned char endpoint; + int i = 0; + int result = ZIGBEE_ERROR_NONE; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + g_variant_builder_add(mac_builder, "(y)", eui64[7]); + g_variant_builder_add(mac_builder, "(y)", eui64[6]); + g_variant_builder_add(mac_builder, "(y)", eui64[5]); + g_variant_builder_add(mac_builder, "(y)", eui64[4]); + g_variant_builder_add(mac_builder, "(y)", eui64[3]); + g_variant_builder_add(mac_builder, "(y)", eui64[2]); + g_variant_builder_add(mac_builder, "(y)", eui64[1]); + g_variant_builder_add(mac_builder, "(y)", eui64[0]); + mac_variant = g_variant_builder_end(mac_builder); + g_variant_builder_unref(mac_builder); + + variant = g_dbus_proxy_call_sync(service_gproxy, "get_endpoint_list", + g_variant_new("(@a(y))", mac_variant), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (variant) { + g_variant_get(variant, "(ia(y))", &result, &iter); + DBG("ret = [0x%x]", result); + + while (g_variant_iter_loop(iter, "(y)", &endpoint)) { + DBG("Endpoint 0x%X", endpoint); + list[i++] = endpoint; + } + if (i > 0) { + *count = i; + DBG("Endpoint Count %d", i); + } else { + ERR("No Endpoints"); + *count = 0; + } + if (NULL != iter) + g_variant_iter_free(iter); + g_variant_unref(variant); + + } else { + ERR("NULL Variant"); + ERR("No Endpoints"); + ERR("[%s]", dbus_err->message); + g_error_free(dbus_err); + *count = 0; + } + + return ZIGBEE_ERROR_NONE; +} + +int zbl_api_get_node_type(ieee_addr eui64, unsigned char *node_type) +{ + GVariant *variant = NULL; + GVariantBuilder *mac_builder = NULL; + int result = ZIGBEE_ERROR_NONE; + GVariant *mac_variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + g_variant_builder_add(mac_builder, "(y)", eui64[7]); + g_variant_builder_add(mac_builder, "(y)", eui64[6]); + g_variant_builder_add(mac_builder, "(y)", eui64[5]); + g_variant_builder_add(mac_builder, "(y)", eui64[4]); + g_variant_builder_add(mac_builder, "(y)", eui64[3]); + g_variant_builder_add(mac_builder, "(y)", eui64[2]); + g_variant_builder_add(mac_builder, "(y)", eui64[1]); + g_variant_builder_add(mac_builder, "(y)", eui64[0]); + mac_variant = g_variant_builder_end(mac_builder); + g_variant_builder_unref(mac_builder); + + variant = g_dbus_proxy_call_sync(service_gproxy, "get_node_type", + g_variant_new("(@a(y))", mac_variant), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'get_node_type' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_get_all_device_info(zb_end_device_info_h **dev_list, unsigned char* num) +{ + int i = 0; + int j = 0; + int k = 0; + struct zb_end_device_info_s **list; + GVariant *variant = NULL; + GVariantIter *iter = NULL; + GVariantIter *mac_iter = NULL; + GVariantIter *endpoint_iter = NULL; + GError *dbus_err = NULL; + int result = 0; + unsigned short node_id; + unsigned char node_type; + unsigned char node_mac_address[8] = {0x00}; + unsigned char endpoint_cnt = 0; + unsigned char value; + unsigned char value_endpoint; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + /* check the format string when there are no input args */ + variant = g_dbus_proxy_call_sync(service_gproxy, "get_device_info", + NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (variant) { + g_variant_get(variant, "(ia(qyayyay))", &result, &iter); + DBG("ret = [0x%x]", result); + + list = calloc(MAX_DEVICE_LIST+1, sizeof(zb_end_device_info_h)); + RETV_IF(NULL == list, ZIGBEE_ERROR_OUT_OF_MEMORY); + for (i = 0; i < MAX_DEVICE_LIST && list; i++) { + list[i] = calloc(1, sizeof(struct zb_end_device_info_s)); + if (NULL == list[i]) { + for (j = 0; j < i; j++) + free(list[j]); + free(list); + g_variant_unref(variant); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + } + + i = 0; + while (g_variant_iter_loop(iter, "(qyayyay)", &node_id, &node_type, &mac_iter, + &endpoint_cnt, &endpoint_iter)) { + j = 0; + k = 0; + /* Get Network Address */ + list[i]->addr16 = node_id; + DBG("Node ID: 0x%04X", node_id); + /* Get Node Type */ + list[i]->node_type = node_type; + DBG("Node Type : 0x%02X", node_type); + /* Get End-Point count */ + list[i]->num_of_ep = endpoint_cnt; + DBG("Endpoint Count: 0x%X", endpoint_cnt); + /* Get End-Point list */ + list[i]->num_of_ep = endpoint_cnt; + while (g_variant_iter_loop(endpoint_iter, "y", &value_endpoint)) { + list[i]->ep[k] = value_endpoint; + DBG("Endpoint : %d", value_endpoint); + k++; + } + /* Get IEEE address */ + while (g_variant_iter_loop(mac_iter, "y", &value)) { + node_mac_address[j] = value; + j++; + } + memcpy(list[i]->addr64, node_mac_address, sizeof(ieee_addr)); + DBG("Node MAC Addr : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + node_mac_address[0], node_mac_address[1], node_mac_address[2], + node_mac_address[3], node_mac_address[4], node_mac_address[5], + node_mac_address[6], node_mac_address[7]); + i++; + + } + if (0 == i) + ERR("No attached nodes"); + + *num = i; + *dev_list = list; + if (NULL != iter) + g_variant_iter_free(iter); + g_variant_unref(variant); + } else { + ERR("NULL Variant [%s]", dbus_err->message); + ERR("No attached nodes"); + g_error_free(dbus_err); + *num = 0; + } + + return ZIGBEE_ERROR_NONE; +} + +int zbl_coex_start(unsigned char channel) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(service_gproxy, "coex_start", g_variant_new("(y)", channel), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'coex_start' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_coex_stop(void) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + DBG("zbl_coex_stop()"); + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(service_gproxy, "coex_stop", NULL, + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'coex_stop' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_form_network(zigbee_h handle, zb_form_network_cb cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(service_gproxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_SERVICE_INTERFACE, "form_network_done", ZIGBEE_SERVICE_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_SERVICE_FORM_NETWORK; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(service_gproxy, "form_network", NULL, + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'form_network' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_disable_network(zigbee_h handle, zb_disable_network_cb cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_disable_network()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(service_gproxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_SERVICE_INTERFACE, "disable_network_done", ZIGBEE_SERVICE_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_SERVICE_DISABLE_NETWORK; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(service_gproxy, "leave_network", NULL, + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'leave_network' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_leave_device(ieee_addr addr64, bool remove_children, bool rejoin) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + GVariantBuilder *mac_builder = NULL; + GVariant* mac_variant = NULL; + unsigned char _remove_children = (remove_children) ? 1 : 0; + unsigned char _rejoin = (rejoin) ? 1 : 0; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("IEEE Address = %X:%X:%X:%X:%X:%X:%X:%X", + addr64[0], addr64[1], addr64[2], addr64[3], + addr64[4], addr64[5], addr64[6], addr64[7]); + + mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + g_variant_builder_add(mac_builder, "(y)", addr64[7]); + g_variant_builder_add(mac_builder, "(y)", addr64[6]); + g_variant_builder_add(mac_builder, "(y)", addr64[5]); + g_variant_builder_add(mac_builder, "(y)", addr64[4]); + g_variant_builder_add(mac_builder, "(y)", addr64[3]); + g_variant_builder_add(mac_builder, "(y)", addr64[2]); + g_variant_builder_add(mac_builder, "(y)", addr64[1]); + g_variant_builder_add(mac_builder, "(y)", addr64[0]); + mac_variant = g_variant_builder_end(mac_builder); + g_variant_builder_unref(mac_builder); + + variant = g_dbus_proxy_call_sync(service_gproxy, "leave_request", + g_variant_new("(@a(y)yy)", mac_variant, _remove_children, _rejoin), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'leave_request' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_permit_join(unsigned char duration, bool broadcast) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(service_gproxy, "permit_join", + g_variant_new("(ib)", duration, broadcast), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'permit_join' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_nwk_addr_req(zigbee_h handle, ieee_addr addr64, unsigned char request_type, + unsigned char start_idx, zb_zdo_addr_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + GVariantBuilder *mac_builder = NULL; + GVariant* mac_variant = NULL; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG(" zbl_nwk_addr_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "nwk_addr_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_NWK_ADDR_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + g_variant_builder_add(mac_builder, "(y)", addr64[7]); + g_variant_builder_add(mac_builder, "(y)", addr64[6]); + g_variant_builder_add(mac_builder, "(y)", addr64[5]); + g_variant_builder_add(mac_builder, "(y)", addr64[4]); + g_variant_builder_add(mac_builder, "(y)", addr64[3]); + g_variant_builder_add(mac_builder, "(y)", addr64[2]); + g_variant_builder_add(mac_builder, "(y)", addr64[1]); + g_variant_builder_add(mac_builder, "(y)", addr64[0]); + mac_variant = g_variant_builder_end(mac_builder); + g_variant_builder_unref(mac_builder); + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "nwk_addr_req", + g_variant_new("(@a(y)yy)", mac_variant, request_type, start_idx), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'nwk_addr_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ieee_addr_req(zigbee_h handle, nwk_addr addr16, zb_zdo_addr_rsp cb, + void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_ieee_addr_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "nwk_addr_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_NWK_ADDR_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "ieee_addr_req", g_variant_new("(q)", addr16), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'ieee_addr_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_active_ep(zigbee_h handle, nwk_addr addr16, zb_zdo_active_ep_rsp cb, + void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_active_ep()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "active_ep_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_ACTIVE_EP_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "active_ep_req", + g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'active_ep_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_simple_desc_req(zigbee_h handle, nwk_addr addr16, unsigned char ep, + zb_zdo_simple_desc_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_simple_desc_req() : [%X]", addr16); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "simple_desc_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_SIMPLE_DESC_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "simple_desc_req", + g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'simple_desc_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +#ifdef ZB_SUPPORT_PRIORITY_5 +int zbl_extended_simple_desc_req(zigbee_h handle, nwk_addr addr16, + unsigned char start_idx, zb_zdo_extended_simple_desc_rsp cb, void *user_data) +{ + return ZIGBEE_ERROR_NOT_SUPPORTED; +} +#endif /* ZB_SUPPORT_PRIORITY_5 */ + +int zbl_match_desc_req(zigbee_h handle, nwk_addr addr16, + unsigned short profile_id, unsigned char num_in_clusters, + unsigned short *in_clusters, unsigned char num_out_clusters, + unsigned short *out_clusters, zb_zdo_match_desc_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + int i; + GVariantBuilder *incl_builder = NULL; + GVariant* incl_variant = NULL; + GVariantBuilder *outcl_builder = NULL; + GVariant* outcl_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_match_desc_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "matched_descriptor_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_MATCHED_DESCRIPTOR_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + incl_builder = g_variant_builder_new(G_VARIANT_TYPE("aq")); + for (i = 0; i < num_in_clusters; i++) + g_variant_builder_add(incl_builder, "q", in_clusters[i]); + + outcl_builder = g_variant_builder_new(G_VARIANT_TYPE("aq")); + for (i = 0; i < num_out_clusters; i++) + g_variant_builder_add(outcl_builder, "q", out_clusters[i]); + + incl_variant = g_variant_builder_end(incl_builder); + outcl_variant = g_variant_builder_end(outcl_builder); + g_variant_builder_unref(incl_builder); + g_variant_builder_unref(outcl_builder); + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "matched_descriptor_req", + g_variant_new("(qqy@aqy@aq)", addr16, profile_id, num_in_clusters, + incl_variant, num_out_clusters, outcl_variant), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'matched_descriptor_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_node_desc_req(nwk_addr addr16, zb_zdo_node_desc_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_node_desc_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "node_desc_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_NODE_DESC_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "node_desc_req", + g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'node_desc_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_power_desc_req(nwk_addr addr16, zb_zdo_power_desc_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "power_desc_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_POWER_DESC_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "power_desc_req", + g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'power_desc_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_complex_desc_req(nwk_addr addr16, zb_zdo_complex_desc_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "complex_desc_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_COMPLEX_DESC_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "complex_desc_req", + g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'complex_desc_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_user_desc_req(nwk_addr addr16, zb_zdo_user_desc_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "user_desc_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_USER_DESC_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "user_desc_req", + g_variant_new("(q)", addr16), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'user_desc_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +#define MAX_USER_DESC_SIZE 0x10 +#define USER_DESC_COMMAND_SIZE 20 + +int zbl_user_desc_set(zigbee_h handle, nwk_addr addr16, unsigned char len, + unsigned char *user_desc, zb_zdo_user_desc_conf cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + unsigned char j = 0x00; + GVariantBuilder *user_desc_builder = NULL; + GVariant *user_desc_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + RETVM_IF(len > MAX_USER_DESC_SIZE || len < 0x00, ZIGBEE_ERROR_INVALID_PARAMETER, + "invalid length=%d", len); + RETVM_IF(NULL == user_data, ZIGBEE_ERROR_INVALID_PARAMETER, "invalid data"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "user_desc_confirm", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_USER_DESC_SET_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + user_desc_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + for (j = 0; j < len; j++) + g_variant_builder_add(user_desc_builder, "(y)", user_desc[j]); + + user_desc_variant = g_variant_builder_end(user_desc_builder); + g_variant_builder_unref(user_desc_builder); + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "user_desc_set_req", + g_variant_new("(qy@a(y))", addr16, len, user_desc_variant), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'user_desc_set_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_device_annce(zigbee_h handle, nwk_addr addr16, ieee_addr addr64, + unsigned char capability) +{ + int result = ZIGBEE_ERROR_NONE; + GError *dbus_err = NULL; + GVariant *variant = NULL; + + GVariantBuilder *mac_builder = NULL; + GVariant* mac_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + g_variant_builder_add(mac_builder, "(y)", addr64[7]); + g_variant_builder_add(mac_builder, "(y)", addr64[6]); + g_variant_builder_add(mac_builder, "(y)", addr64[5]); + g_variant_builder_add(mac_builder, "(y)", addr64[4]); + g_variant_builder_add(mac_builder, "(y)", addr64[3]); + g_variant_builder_add(mac_builder, "(y)", addr64[2]); + g_variant_builder_add(mac_builder, "(y)", addr64[1]); + g_variant_builder_add(mac_builder, "(y)", addr64[0]); + mac_variant = g_variant_builder_end(mac_builder); + g_variant_builder_unref(mac_builder); + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "device_announce", + g_variant_new("(q@a(y)y)", addr16, mac_variant, capability), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'device_announce' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_bind_req(nwk_addr dst_addr16, ieee_addr src_addr64, + unsigned char src_ep, unsigned short cluster_id, ieee_addr dst_addr64, + unsigned char type, nwk_addr group_addr, unsigned char dst_ep, + zb_zdo_bind_rsp cb, void *user_data) +{ + int i; + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GError *dbus_err = NULL; + GVariant *variant = NULL; + + GVariantBuilder *src_addr64_builder = NULL; + GVariant* src_addr64_variant = NULL; + GVariantBuilder *dst_addr64_builder = NULL; + GVariant* dst_addr64_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_bind_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_zdo_bind_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_bind_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_BIND_INTERFACE, "bind_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_BIND_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + src_addr64_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + + if (src_addr64) { + for (i = sizeof(ieee_addr) - 1 ; i >= 0; i--) + g_variant_builder_add(src_addr64_builder, "(y)", src_addr64[i]); + } + src_addr64_variant = g_variant_builder_end(src_addr64_builder); + g_variant_builder_unref(src_addr64_builder); + + dst_addr64_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + if (dst_addr64) { + for (i = sizeof(ieee_addr) - 1 ; i >= 0; i--) + g_variant_builder_add(dst_addr64_builder, "(y)", dst_addr64[i]); + } + dst_addr64_variant = g_variant_builder_end(dst_addr64_builder); + g_variant_builder_unref(dst_addr64_builder); + + variant = g_dbus_proxy_call_sync(zdo_bind_proxy, "bind_req", + g_variant_new("(q@a(y)yq@a(y)yqy)", dst_addr16, src_addr64_variant, src_ep, + cluster_id, dst_addr64_variant, type, group_addr, dst_ep), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'bind_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_unbind_req(nwk_addr dst_addr16, + ieee_addr src_addr64, unsigned char src_ep, unsigned short cluster_id, + ieee_addr dst_addr64, unsigned char type, nwk_addr group_addr, + unsigned char dst_ep, zb_zdo_unbind_rsp cb, void *user_data) +{ + int i; + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GError *dbus_err = NULL; + GVariant *variant = NULL; + + GVariantBuilder *src_addr64_builder = NULL; + GVariant* src_addr64_variant = NULL; + GVariantBuilder *dst_addr64_builder = NULL; + GVariant* dst_addr64_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_bind_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_zdo_unbind_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_bind_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_BIND_INTERFACE, "unbind_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_UNBIND_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + src_addr64_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + if (src_addr64) { + for (i = sizeof(ieee_addr) - 1 ; i >= 0; i--) + g_variant_builder_add(src_addr64_builder, "(y)", src_addr64[i]); + } + src_addr64_variant = g_variant_builder_end(src_addr64_builder); + g_variant_builder_unref(src_addr64_builder); + + dst_addr64_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + if (dst_addr64) { + for (i = sizeof(ieee_addr) - 1 ; i >= 0; i--) + g_variant_builder_add(dst_addr64_builder, "(y)", dst_addr64[i]); + } + dst_addr64_variant = g_variant_builder_end(dst_addr64_builder); + g_variant_builder_unref(dst_addr64_builder); + + variant = g_dbus_proxy_call_sync(zdo_bind_proxy, "unbind_req", + g_variant_new("(q@a(y)yq@a(y)yqy)", dst_addr16, src_addr64_variant, src_ep, + cluster_id, dst_addr64_variant, type, group_addr, dst_ep), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'unbind_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_mgmt_nwk_disc_req(nwk_addr addr16, unsigned int scan_channels, + unsigned char scan_duration, unsigned char scan_count, unsigned char start_idx, + zb_zdo_mgmt_nwk_disc_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_mgmt_nwk_disc_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_nwk_disc_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, + container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_MGMT_NWK_DISC_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_nwk_disc_req", + g_variant_new("(quyqy)", addr16, scan_channels, scan_duration, scan_count, start_idx), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'mgmt_nwk_disc_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_mgmt_nwk_update_req(unsigned int scan_channels, unsigned char scan_duration, + unsigned char scan_count, unsigned char nwk_update_id, nwk_addr nwk_manager_addr) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_mgmt_nwk_update_req()"); + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_nwk_update_req", + g_variant_new("(quyyy)", nwk_manager_addr, scan_channels, scan_duration, + scan_count, nwk_update_id), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'mgmt_nwk_update_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_mgmt_lqi_req(nwk_addr addr16, unsigned char start_idx, + zb_zdo_mgmt_lqi_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_mgmt_lqi_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_lqi_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_MGMT_LQI_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_lqi_req", + g_variant_new("(qy)", addr16, start_idx), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'mgmt_lqi_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_mgmt_rtg_req(nwk_addr addr16, unsigned char start_idx, + zb_zdo_mgmt_rtg_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_mgmt_rtg_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_rtg_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_MGMT_RTG_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_rtg_req", + g_variant_new("(qy)", addr16, start_idx), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'mgmt_rtg_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_mgmt_bind_req(nwk_addr addr16, unsigned char start_idx, + zb_zdo_mgmt_bind_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_mgmt_bind_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_bind_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_MGMT_BIND_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_bind_req", + g_variant_new("(qy)", addr16, start_idx), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'mgmt_bind_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_mgmt_leave_device(ieee_addr addr64, unsigned char remove_children, + unsigned rejoin, zb_zdo_mgmt_leave_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + GVariantBuilder *mac_builder = NULL; + GVariant* mac_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_leave_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_MGMT_LEAVE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + mac_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + g_variant_builder_add(mac_builder, "(y)", addr64[7]); + g_variant_builder_add(mac_builder, "(y)", addr64[6]); + g_variant_builder_add(mac_builder, "(y)", addr64[5]); + g_variant_builder_add(mac_builder, "(y)", addr64[4]); + g_variant_builder_add(mac_builder, "(y)", addr64[3]); + g_variant_builder_add(mac_builder, "(y)", addr64[2]); + g_variant_builder_add(mac_builder, "(y)", addr64[1]); + g_variant_builder_add(mac_builder, "(y)", addr64[0]); + mac_variant = g_variant_builder_end(mac_builder); + g_variant_builder_unref(mac_builder); + + variant = g_dbus_proxy_call_sync(service_gproxy, "leave_request", + g_variant_new("(@a(y)yy)", mac_variant, remove_children, rejoin), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'leave_request' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_mgmt_permit_joining_req(nwk_addr addr16, unsigned char duration, + unsigned char tc_significance, zb_zdo_mgmt_permit_joining_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zdo_dev_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZDO_DEV_CONTROL_INTERFACE, "mgmt_permit_join_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, + container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZDO_MGMT_PERMIT_JOIN_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zdo_dev_proxy, "mgmt_permit_join_req", + g_variant_new("(qyy)", addr16, duration, tc_significance), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'mgmt_permit_join_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_aps_send(nwk_addr addr16, unsigned char aps_frame_ctl, unsigned char src_ep, + unsigned char dst_ep, unsigned short cluster_id, unsigned short profile_id, + unsigned char zcl_frame_ctl, unsigned short mfg_code, unsigned char cmd_id, + unsigned short payload_len, unsigned char *payload, zb_aps_send_rsp cb, void *user_data) +{ + int sub_id, to, i; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + GVariantBuilder *payload_builder = NULL; + GVariant *payload_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == custom_gproxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(custom_gproxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_CUSTOM_INTERFACE, "aps_send_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_CUSTOM_APS_SEND_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + payload_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + if (payload_len > 0) { + for (i = payload_len - 1; i >= 0 ; i--) + g_variant_builder_add(payload_builder, "(y)", payload[i]); + } + payload_variant = g_variant_builder_end(payload_builder); + g_variant_builder_unref(payload_builder); + + variant = g_dbus_proxy_call_sync(custom_gproxy, "aps_send", + g_variant_new("(qyyyqqyqyq@a(y))", addr16, aps_frame_ctl, src_ep, dst_ep, cluster_id, + profile_id, zcl_frame_ctl, mfg_code, cmd_id, payload_len, payload_variant), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'aps_send' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_zcl_send(nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned short cluster_id, unsigned char zcl_frame_ctl, unsigned char cmd, + unsigned short payload_len, unsigned char *payload, + zb_zcl_send_rsp cb, void *user_data) +{ + int sub_id, to, i; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + GVariantBuilder *payload_builder = NULL; + GVariant *payload_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == custom_gproxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(custom_gproxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_CUSTOM_INTERFACE, "zcl_send_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_CUSTOM_ZCL_SEND_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + payload_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + if (payload_len > 0) { + for (i = payload_len - 1; i >= 0 ; i--) + g_variant_builder_add(payload_builder, "(y)", payload[i]); + } + payload_variant = g_variant_builder_end(payload_builder); + g_variant_builder_unref(payload_builder); + + variant = g_dbus_proxy_call_sync(custom_gproxy, "zcl_send", + g_variant_new("(qyyqyyq@a(y))", addr16, src_ep, dst_ep, cluster_id, zcl_frame_ctl, + cmd, payload_len, payload_variant), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'zcl_send' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_send_to_local(unsigned short length, unsigned char *data, + zb_send_to_local_rsp cb, void *user_data) +{ + int sub_id, to, i; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + GVariantBuilder *payload_builder = NULL; + GVariant *payload_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == custom_gproxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(custom_gproxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_CUSTOM_INTERFACE, "send_to_local_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_CUSTOM_LOCAL_SEND_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + payload_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + if (length > 0) { + for (i = length - 1; i >= 0 ; i--) + g_variant_builder_add(payload_builder, "(y)", data[i]); + } + payload_variant = g_variant_builder_end(payload_builder); + g_variant_builder_unref(payload_builder); + + variant = g_dbus_proxy_call_sync(custom_gproxy, "send_to_local", + g_variant_new("(q@a(y))", length, payload_variant), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'send_to_local' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_read_attr_req(zigbee_h handle, unsigned short addr16, unsigned char dest_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short *attribute_ids, + int attribute_ids_len, zb_zcl_global_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + int i = 0; + unsigned char *t; + GVariant *attr_variant = NULL; + GVariantBuilder *attr_builder = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_read_attr_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "read_attributes_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_READ_ATTRIBUTE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dest_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_READ_ATTRIBUTES_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + t = (unsigned char *)attribute_ids; + attr_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + for (i = 0; i < attribute_ids_len*sizeof(unsigned short); i++) + g_variant_builder_add(attr_builder, "(y)", t[i]); + attr_variant = g_variant_builder_end(attr_builder); + g_variant_builder_unref(attr_builder); + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "read_attributes_req", + g_variant_new("(@a(y)iqqyy)", attr_variant, attribute_ids_len, + addr16, cluster_id, zcl_frame_ctl, dest_ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'read_attributes_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, write_attr_record_h *records, + int records_len, zb_zcl_global_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_write_attr_req()"); + + GVariantBuilder *rec_builder = NULL; + GVariant *rec_variant = NULL; + + int i = 0; + int j = 0; + + char dSize[3] = {'\0', '\0'}; + int writeAttributeIndex = 0; + int size_of_allo = 0; + + unsigned char *isString = NULL; + unsigned short *dataSize = NULL; + unsigned char *writeAttribute = NULL; + + isString = calloc(records_len + 1, sizeof(unsigned char)); + RETVM_IF(NULL == isString, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + dataSize = calloc(records_len + 1, sizeof(unsigned short)); + if (NULL == dataSize) { + ERR("calloc() Fail(%d)", errno); + free(isString); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + + DBG("Records Length %d", records_len); + + while (j < records_len) { + dataSize[j] = zb_get_data_size((*records)[j].type); + if (0xff != dataSize[j]) { + isString[j] = 0; + size_of_allo = size_of_allo + (dataSize[j] + 3); + } else { + if ((*records)[j].value) { + if ((*records)[j].type == ZB_ZCL_CHRACTER_STRING + || (*records)[j].type == ZB_ZCL_OCTAT_STRING) { + isString[j] = 1; + dataSize[j] = (*records)[j].value[0]; + size_of_allo = size_of_allo + (dataSize[j] + 3 + 1); + } else if ((*records)[j].type == ZB_ZCL_LONG_OCTAT_STRING + || (*records)[j].type == ZB_ZCL_LONG_CHRACTER_STRING) { + isString[j] = 2; + dSize[0] = (*records)[j].value[0]; + dSize[1] = (*records)[j].value[1]; + dataSize[j] = dSize[1]; + dataSize[j] = (dataSize[j] << 8) | dSize[0]; + size_of_allo = size_of_allo + (dataSize[j] + 3 + 2); + } + } else + ERR("Data is not present"); + } + j++; + } + DBG("size_of_allo Length %d", size_of_allo); + + writeAttribute = calloc(size_of_allo + 1, sizeof(unsigned char)); + if (NULL == writeAttribute) { + ERR("Couldn't Allocate Memory"); + free(isString); + free(dataSize); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + + j = 0; + while (j < records_len && writeAttributeIndex < size_of_allo) { + writeAttribute[writeAttributeIndex++] = ((*records)[j].id) & 0xff; + writeAttribute[writeAttributeIndex++] = (((*records)[j].id) >> 8) & 0xff; + writeAttribute[writeAttributeIndex++] = (*records)[j].type; + for (i = 0; i < (dataSize[j] + isString[j]); i++) { + writeAttribute[writeAttributeIndex++] = (*records)[j].value[i]; + DBG("0x%02X", (*records)[j].value[i]); + } + j++; + } + + rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + DBG(" "); + for (i = 0; i < writeAttributeIndex ; i++) { + DBG("0x%02X", writeAttribute[i]); + g_variant_builder_add(rec_builder, "(y)", writeAttribute[i]); + } + + rec_variant = g_variant_builder_end(rec_builder); + g_variant_builder_unref(rec_builder); + + container = calloc(1, sizeof(zbl_req_cb_s)); + if (NULL == container) { + ERR("calloc() Fail(%d)", errno); + free(isString); + free(dataSize); + free(writeAttribute); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "write_attributes_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, + container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(isString); + free(dataSize); + free(container); + free(writeAttribute); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + free(isString); + free(dataSize); + free(writeAttribute); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dst_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_WRITE_ATTRIBUTES_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "write_attributes_req", + g_variant_new("(@a(y)iqqyyy)", rec_variant, writeAttributeIndex, addr16, + cluster_id, zcl_frame_ctl, src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, + to, NULL, &dbus_err); + + free(isString); + free(dataSize); + free(writeAttribute); + + if (!variant) { + ERR("Failed to get 'write_attributes_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_wattr_undivided_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + write_attr_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_wattr_undivided_req()"); + + GVariantBuilder *rec_builder = NULL; + GVariant *rec_variant = NULL; + + int i = 0; + int j = 0; + + char dSize[3] = {'\0', '\0'}; + int writeAttributeIndex = 0; + int size_of_allo = 0; + + unsigned char *isString = NULL; + unsigned short *dataSize = NULL; + unsigned char *writeAttribute = NULL; + + isString = calloc(records_len + 1, sizeof(unsigned char)); + RETVM_IF(NULL == isString, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + dataSize = calloc(records_len + 1, sizeof(unsigned short)); + if (NULL == dataSize) { + ERR("calloc() Fail(%d)", errno); + free(isString); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + + DBG("Records Length %d", records_len); + + while (j < records_len) { + dataSize[j] = zb_get_data_size((*records)[j].type); + if (0xff != dataSize[j]) { + isString[j] = 0; + size_of_allo = size_of_allo + (dataSize[j] + 3); + } else { + if ((*records)[j].value) { + if ((*records)[j].type == ZB_ZCL_CHRACTER_STRING + || (*records)[j].type == ZB_ZCL_OCTAT_STRING) { + isString[j] = 1; + dataSize[j] = (*records)[j].value[0]; + size_of_allo = size_of_allo + (dataSize[j] + 3 + 1); + } else if ((*records)[j].type == ZB_ZCL_LONG_OCTAT_STRING + || (*records)[j].type == ZB_ZCL_LONG_CHRACTER_STRING) { + isString[j] = 2; + dSize[0] = (*records)[j].value[0]; + dSize[1] = (*records)[j].value[1]; + dataSize[j] = dSize[1]; + dataSize[j] = (dataSize[j] << 8) | dSize[0]; + size_of_allo = size_of_allo + (dataSize[j] + 3 + 2); + } + } else + ERR("Data is not present"); + } + j++; + } + DBG("size_of_allo Length %d", size_of_allo); + + writeAttribute = calloc(size_of_allo + 1, sizeof(unsigned char)); + if (NULL == writeAttribute) { + ERR("Couldn't Allocate Memory"); + free(isString); + free(dataSize); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + + j = 0; + while (j < records_len && writeAttributeIndex < size_of_allo) { + writeAttribute[writeAttributeIndex++] = ((*records)[j].id) & 0xff; + writeAttribute[writeAttributeIndex++] = (((*records)[j].id) >> 8) & 0xff; + writeAttribute[writeAttributeIndex++] = (*records)[j].type; + for (i = 0; i < (dataSize[j] + isString[j]); i++) { + writeAttribute[writeAttributeIndex++] = (*records)[j].value[i]; + DBG("0x%02X", (*records)[j].value[i]); + } + j++; + } + + rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + DBG(" "); + for (i = 0; i < writeAttributeIndex ; i++) { + DBG("0x%02X", writeAttribute[i]); + g_variant_builder_add(rec_builder, "(y)", writeAttribute[i]); + } + + rec_variant = g_variant_builder_end(rec_builder); + g_variant_builder_unref(rec_builder); + + container = calloc(1, sizeof(zbl_req_cb_s)); + if (NULL == container) { + ERR("calloc() Fail(%d)", errno); + free(isString); + free(dataSize); + free(writeAttribute); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "write_attributes_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, + container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(isString); + free(dataSize); + free(container); + free(writeAttribute); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_WRITE_ATTRIBUTE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + free(isString); + free(dataSize); + free(writeAttribute); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dst_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_WRITE_ATTRIBUTES_UNDIVIDED_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "write_attributes_undivided_req", + g_variant_new("(@a(y)iqqyyy)", rec_variant, writeAttributeIndex, addr16, + cluster_id, zcl_frame_ctl, src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, + to, NULL, &dbus_err); + + free(isString); + free(dataSize); + free(writeAttribute); + + if (!variant) { + ERR("Failed to get 'write_attributes_undivided_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_wattr_req_no_rsp(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + write_attr_record_h *records, int records_len) +{ + int result = ZIGBEE_ERROR_NONE; + GError *dbus_err = NULL; + GVariant *variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_wattr_req_no_rsp()"); + + GVariantBuilder *rec_builder = NULL; + GVariant *rec_variant = NULL; + + int i = 0; + int j = 0; + + char dSize[3] = {'\0', '\0'}; + int writeAttributeIndex = 0; + int size_of_allo = 0; + + unsigned char *isString = NULL; + unsigned short *dataSize = NULL; + unsigned char *writeAttribute = NULL; + + isString = calloc(records_len + 1, sizeof(unsigned char)); + RETVM_IF(NULL == isString, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + dataSize = calloc(records_len + 1, sizeof(unsigned short)); + if (NULL == dataSize) { + ERR("calloc() Fail(%d)", errno); + free(isString); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + + DBG("Records Length %d", records_len); + + while (j < records_len) { + dataSize[j] = zb_get_data_size((*records)[j].type); + if (0xff != dataSize[j]) { + isString[j] = 0; + size_of_allo = size_of_allo + (dataSize[j] + 3); + } else { + if ((*records)[j].value) { + if ((*records)[j].type == ZB_ZCL_CHRACTER_STRING + || (*records)[j].type == ZB_ZCL_OCTAT_STRING) { + isString[j] = 1; + dataSize[j] = (*records)[j].value[0]; + size_of_allo = size_of_allo + (dataSize[j] + 3 + 1); + } else if ((*records)[j].type == ZB_ZCL_LONG_OCTAT_STRING + || (*records)[j].type == ZB_ZCL_LONG_CHRACTER_STRING) { + isString[j] = 2; + dSize[0] = (*records)[j].value[0]; + dSize[1] = (*records)[j].value[1]; + dataSize[j] = dSize[1]; + dataSize[j] = (dataSize[j] << 8) | dSize[0]; + size_of_allo = size_of_allo + (dataSize[j] + 3 + 2); + } + } else + ERR("Data is not present"); + } + j++; + } + DBG("size_of_allo Length %d", size_of_allo); + + writeAttribute = calloc(size_of_allo + 1, sizeof(unsigned char)); + if (NULL == writeAttribute) { + ERR("Couldn't Allocate Memory"); + free(isString); + free(dataSize); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + + j = 0; + while (j < records_len && writeAttributeIndex < size_of_allo) { + writeAttribute[writeAttributeIndex++] = ((*records)[j].id) & 0xff; + writeAttribute[writeAttributeIndex++] = (((*records)[j].id) >> 8) & 0xff; + writeAttribute[writeAttributeIndex++] = (*records)[j].type; + for (i = 0; i < (dataSize[j] + isString[j]); i++) { + writeAttribute[writeAttributeIndex++] = (*records)[j].value[i]; + DBG("0x%02X", (*records)[j].value[i]); + } + j++; + } + + rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + DBG(" "); + for (i = 0; i < writeAttributeIndex ; i++) { + DBG("0x%02X", writeAttribute[i]); + g_variant_builder_add(rec_builder, "(y)", writeAttribute[i]); + } + + rec_variant = g_variant_builder_end(rec_builder); + g_variant_builder_unref(rec_builder); + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "write_attributes_no_resp", + g_variant_new("(@a(y)iqqyyy)", rec_variant, writeAttributeIndex, addr16, + cluster_id, zcl_frame_ctl, src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &dbus_err); + + free(isString); + free(dataSize); + free(writeAttribute); + + if (!variant) { + ERR("Failed to get 'write_attributes_no_rep' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + report_config_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + int i = 0; + int j = 0; + int len = 0; + int count = 0; + + GVariantBuilder *rec_builder = NULL; + GVariant *rec_variant = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_configure_reporting()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "configure_reporting_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, + container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_CONFIGURE_REPORTING_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dst_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_CONFIGURE_REPORTING_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + for (i = 0; i < records_len; i++) { + g_variant_builder_add(rec_builder, "(y)", (*records)[i].dir); + DBG("dir = 0x%02X", (*records)[i].dir); + count += sizeof((*records)[i].dir); + g_variant_builder_add(rec_builder, "(y)", (*records)[i].id & 0xff); + g_variant_builder_add(rec_builder, "(y)", ((*records)[i].id >> 8) & 0xff); + DBG("id = 0x%04X", (*records)[i].id); + count += sizeof((*records)[i].id); + g_variant_builder_add(rec_builder, "(y)", (*records)[i].type); + count += sizeof((*records)[i].type); + DBG("type = 0x%04X", (*records)[i].type); + g_variant_builder_add(rec_builder, "(y)", (*records)[i].min_i & 0xff); + g_variant_builder_add(rec_builder, "(y)", ((*records)[i].min_i >> 8) & 0xff); + DBG("min_i = 0x%04X", (*records)[i].min_i); + count += sizeof((*records)[i].min_i); + g_variant_builder_add(rec_builder, "(y)", (*records)[i].max_i & 0xff); + g_variant_builder_add(rec_builder, "(y)", ((*records)[i].max_i >> 8) & 0xff); + DBG("max_i = 0x%04X", (*records)[i].max_i); + count += sizeof((*records)[i].max_i); + + len = zb_get_data_size((*records)[i].type); + count += len; + DBG("change length = %d", len); + DBG("payload length = %d", count); + + for (j = 0; j < len && (*records)[i].change+j; j++) { + DBG("records[%d]->value[%d] = %d", i, j, (*records)[i].change[j]); + g_variant_builder_add(rec_builder, "(y)", (*records)[i].change[j]); + } + + } + rec_variant = g_variant_builder_end(rec_builder); + g_variant_builder_unref(rec_builder); + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "configure_reporting_req", + g_variant_new("(@a(y)qqqyyy)", rec_variant, count, addr16, cluster_id, + zcl_frame_ctl, src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'configure_reporting_req' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_read_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + read_report_config_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + int i = 0; + int j = 0; + int size_of_allo = 0; + unsigned short idx = 0; + GVariantBuilder *rec_builder = NULL; + GVariant *rec_variant = NULL; + unsigned char *read_attributes; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_read_configure_reporting()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "read_configure_reporting_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, + container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_READ_CONFIGURE_REPORTING_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dst_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_READ_REPORTING_CONFIGURATION_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + DBG("Records Length %d", records_len); + /** + * According to zcl spec + * Memory needed for the read_reporting_configured_frame. + * 1 byte(direction) + 2 bytes(AttributeId) + * = 3 bytes/variable + */ + while (j < records_len) { + size_of_allo = size_of_allo + 3; + j++; + } + DBG("size_of_allo Length %d", size_of_allo); + + read_attributes = calloc(size_of_allo, sizeof(unsigned char)); + if (NULL == read_attributes) { + ERR("Couldn't Allocate Memory"); + g_dbus_connection_signal_unsubscribe(gdbus_conn, container->sid); + g_source_remove(container->tid); + container->tid = 0; + free(container); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + j = 0; + while (j < records_len && idx < size_of_allo) { + read_attributes[idx++] = (*records)[j].dir; + read_attributes[idx++] = (*records)[j].id & 0xff; + read_attributes[idx++] = (*records)[j].id >> 8 & 0xff; + DBG("Id copied \n"); + j++; + } + + rec_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + + for (i = 0; i < idx ; i++) { + DBG("0x%02X", read_attributes[i]); + g_variant_builder_add(rec_builder, "(y)", read_attributes[i]); + } + + rec_variant = g_variant_builder_end(rec_builder); + g_variant_builder_unref(rec_builder); + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "read_configure_reporting", + g_variant_new("(@a(y)qqqyyy)", rec_variant, idx, addr16, cluster_id, zcl_frame_ctl, + src_ep, dst_ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + free(read_attributes); + + if (!variant) { + ERR("Failed to get 'read_configure_reporting' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_discover_attr_req(zigbee_h handle, unsigned short addr16, unsigned char src_ep, + unsigned char dest_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + unsigned short start_id, unsigned char max_attribute_ids, + zb_zcl_global_discover_attr_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_discover_attr_req()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "discover_attribute_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dest_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "discover_attributes", + g_variant_new("(qyyqqy)", + addr16, dest_ep, zcl_frame_ctl, cluster_id, start_id, max_attribute_ids), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'discover_attributes' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_discover_cmds_gen(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, + unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_discover_attr_gen()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "discover_commands_generated_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_GENERATED_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dst_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_DISCOVER_COMMANDS_GENERATED_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "discover_commands_generated", + g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, cluster_id, + start_command_id, max_command_ids), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'discover_commands_received' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_discover_cmds_recv(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, + unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_discover_cmds_recv()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "discover_commands_received_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_DISCOVER_COMMAND_RECEIVED_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dst_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_DISCOVER_COMMANDS_RECEIVED_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "discover_commands_received", + g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, cluster_id, + start_command_id, max_command_ids), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'discover_commands_received' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_discover_attr_ext(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + unsigned short start_id, unsigned char max_attribute_ids, + zb_zcl_global_discover_attr_extended_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + zb_event_global_default_rsp_s *global_req = NULL; +#endif + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_discover_attr_ext()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_global_proxy); + sub_id = g_dbus_connection_signal_subscribe(gdbus_conn, NULL, + ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE, "discover_attributes_extended_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GLOBAL_DISCOVER_ATTRIBUTE_EXTENDED_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; +#ifdef ZB_FEATURE_GLOBAL_RSP_SYNC + global_req = calloc(1, sizeof(zb_event_global_default_rsp_s)); + if (NULL == global_req) { + g_dbus_connection_signal_unsubscribe(gdbus_conn, sub_id); + g_source_remove(container->tid); + container->tid = 0; + free(container); + ERR("calloc() Fail(%d)", errno); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + global_req->ep = dst_ep; + global_req->cluster_id = cluster_id; + global_req->command_id = ZB_ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID; + + container->global_cmd = global_req; + container->handle = handle; + + /* Register global request information into handle */ + _zbl_register_global_req(handle, container); +#endif + + variant = g_dbus_proxy_call_sync(zcl_global_proxy, "discover_attributes_extended", + g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, cluster_id, start_id, + max_attribute_ids), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'discover_attributes_extended' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_reset_alarm(nwk_addr addr16, unsigned char ep, unsigned char alarm_code, + unsigned short cluster_id) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(alarm_gproxy, "reset_alarm", + g_variant_new("(qyyq)", addr16, ep, alarm_code, cluster_id), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'reset_alarm' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_reset_all_alarm(nwk_addr addr16, unsigned char ep) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(alarm_gproxy, "reset_all_alarm", + g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'reset_all_alarm' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_get_alarm(nwk_addr addr16, unsigned char ep, zb_zcl_alarm_get_alarm_rsp cb, + void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_get_alarm()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(alarm_gproxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_ALARM_INTERFACE, "get_alarm_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_ALARM_GET_ALARM_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(alarm_gproxy, "get_alarm", + g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'get_alarm' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_reset_all_alarm_log(nwk_addr addr16, unsigned char ep) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(alarm_gproxy, "reset_alarm_log", + g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'reset_alarm_log' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_move_to_hue(nwk_addr addr16, unsigned char ep, + unsigned char hue, unsigned char direction, + unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_to_hue", + g_variant_new("(qyyyq)", addr16, ep, hue, direction, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_to_hue' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + + +int zbl_ccontrol_move_hue(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_hue", + g_variant_new("(qyyy)", addr16, ep, move_mode, rate), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_hue' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_step_hue(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned char transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "step_hue", + g_variant_new("(qyyyy)", addr16, ep, step_mode, step_size, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'step_hue' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_move_to_saturation(nwk_addr addr16, unsigned char ep, + unsigned char saturation, unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_to_saturation", + g_variant_new("(qyyq)", addr16, ep, saturation, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_to_saturation' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_move_saturation(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_saturation", + g_variant_new("(qyyy)", addr16, ep, move_mode, rate), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_saturation' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_step_saturation(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned char transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "step_saturation", + g_variant_new("(qyyyy)", addr16, ep, step_mode, step_size, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'step_saturation' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_move_to_hue_and_saturation(nwk_addr addr16, unsigned char ep, + unsigned char hue, unsigned char saturation, + unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_to_hue_and_saturation", + g_variant_new("(qyyyq)", addr16, ep, hue, saturation, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_to_hue_and_saturation' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_move_to_color(nwk_addr addr16, unsigned char ep, + unsigned short color_x, unsigned short color_y, + unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_to_color", + g_variant_new("(qyqqq)", addr16, ep, color_x, color_y, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_to_color' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_move_color(nwk_addr addr16, unsigned char ep, + unsigned short rate_x, unsigned short rate_y) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_color", + g_variant_new("(qyqq)", addr16, ep, rate_x, rate_y), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_color' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_step_color(nwk_addr addr16, unsigned char ep, + unsigned short step_x, unsigned short step_y, + unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "step_color", + g_variant_new("(qyqqq)", addr16, ep, step_x, step_y, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'step_color' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_ccontrol_move_to_color_temperature(nwk_addr addr16, unsigned char ep, + unsigned short color_temperature, + unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_color_control_proxy, "move_color_temperature", + g_variant_new("(qyqq)", addr16, ep, color_temperature, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_color_temperature' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_reset_factory_default(nwk_addr addr16, unsigned char ep) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_basic_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_basic_proxy, "reset_factory_default", + g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'reset_factory_default' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_identify(nwk_addr addr16, unsigned char dst_ep, unsigned short identify_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_identify_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_identify_proxy, "identify", + g_variant_new("(qyq)", addr16, dst_ep, identify_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'identify' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_identify_query(nwk_addr addr16, unsigned char dst_ep, + zb_zcl_identify_query_cb cb, void *user_data) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + int sub_id, to; + zbl_req_cb_s *container; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_identify_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_identify_query()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_identify_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_IDENTIFY_INTERFACE, "query_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_IDENTIFY_QUERY_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_identify_proxy, "query", + g_variant_new("(qy)", addr16, dst_ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'query' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_add_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, + const char *group_name, zb_zcl_group_add_group_rsp cb, void *user_data) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + int sub_id, to; + zbl_req_cb_s *container; + + int j = 0; + GVariant *groupname_variant = NULL; + GVariantBuilder *groupname_builder = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_add_group()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_group_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_GROUP_INTERFACE, "add_group_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GROUP_ADD_GROUP_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + groupname_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + while (group_name[j] != '\0') { + g_variant_builder_add(groupname_builder, "(y)", (group_name[j])); + j++; + } + groupname_variant = g_variant_builder_end(groupname_builder); + g_variant_builder_unref(groupname_builder); + + variant = g_dbus_proxy_call_sync(zcl_group_proxy, "add_group", + g_variant_new("(qyq@a(y))", addr16, ep, group_id, groupname_variant), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'add_group' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_view_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, + zb_zcl_group_view_group_rsp cb, void *user_data) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + int sub_id, to; + zbl_req_cb_s *container; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_view_group()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_group_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_GROUP_INTERFACE, "view_group_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GROUP_VIEW_GROUP_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_group_proxy, "view_group", + g_variant_new("(qyq)", addr16, ep, group_id), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'view_group' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_group_get_group_membership(nwk_addr addr16, unsigned char ep, + unsigned char group_count, unsigned short *group_list, + zb_zcl_group_get_group_membership_rsp cb, void *user_data) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + int sub_id, to; + zbl_req_cb_s *container; + + int j = 0; + GVariant *grouplist_variant = NULL; + GVariantBuilder *grouplist_builder = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_group_get_group_membership()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_group_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_GROUP_INTERFACE, "get_group_membership_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, + container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GROUP_GET_GROUP_MEMBERSHIP_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + grouplist_builder = g_variant_builder_new(G_VARIANT_TYPE("aq")); + while (j < group_count) { + g_variant_builder_add(grouplist_builder, "q", group_list[j]); + j++; + } + grouplist_variant = g_variant_builder_end(grouplist_builder); + g_variant_builder_unref(grouplist_builder); + + variant = g_dbus_proxy_call_sync(zcl_group_proxy, "get_group_membership", + g_variant_new("(qyy@aq)", addr16, ep, group_count, grouplist_variant), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'get_group_membership' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_remove_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, + zb_zcl_group_remove_group_rsp cb, void *user_data) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + int sub_id, to; + zbl_req_cb_s *container; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_group_remove_group()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_group_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_GROUP_INTERFACE, "remove_group_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_GROUP_REMOVE_GROUP_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_group_proxy, "remove_group", g_variant_new("(qyq)", + addr16, ep, group_id), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'remove_group' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_remove_all_group(nwk_addr addr16, unsigned char ep) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_group_remove_all_group()"); + + variant = g_dbus_proxy_call_sync(zcl_group_proxy, "remove_all_group", + g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'remove_all_group' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_add_group_if_identifying(nwk_addr addr16, unsigned char ep, + unsigned short group_id, const char *group_name) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + int j = 0; + GVariant *groupname_variant = NULL; + GVariantBuilder *groupname_builder = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR); + + groupname_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + while (group_name[j] != '\0') { + g_variant_builder_add(groupname_builder, "(y)", group_name[j]); + j++; + } + groupname_variant = g_variant_builder_end(groupname_builder); + g_variant_builder_unref(groupname_builder); + + variant = g_dbus_proxy_call_sync(zcl_group_proxy, "add_group_if_identifying", + g_variant_new("(qyq@a(y))", addr16, ep, group_id, groupname_variant), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'add_group_if_identifying' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_level_control_move_to_level(nwk_addr addr16, unsigned char ep, + unsigned char level, unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_level_control_move_to_level()"); + + variant = g_dbus_proxy_call_sync(level_control_gproxy, "move_to_level", + g_variant_new("(qyyq)", addr16, ep, level, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_to_level' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_level_control_move(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_level_control_move()"); + + variant = g_dbus_proxy_call_sync(level_control_gproxy, "move", + g_variant_new("(qyyy)", addr16, ep, move_mode, rate), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_level_control_step(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_level_control_step()"); + + variant = g_dbus_proxy_call_sync(level_control_gproxy, "step", + g_variant_new("(qyyyq)", addr16, ep, step_mode, step_size, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'step' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_level_control_stop(nwk_addr addr16, unsigned char ep) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_level_control_stop()"); + + variant = g_dbus_proxy_call_sync(level_control_gproxy, "stop", + g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'stop' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_level_control_move_to_level_with_on_off(nwk_addr addr16, + unsigned char ep, unsigned char level, unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_level_control_move_to_level_with_on_off()"); + + variant = g_dbus_proxy_call_sync(level_control_gproxy, "move_to_level_with_on_off", + g_variant_new("(qyyq)", addr16, ep, level, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_to_level_with_on_off' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_level_control_move_with_on_off(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_level_control_move_with_on_off()"); + + variant = g_dbus_proxy_call_sync(level_control_gproxy, "move_with_on_off", + g_variant_new("(qyyy)", addr16, ep, move_mode, rate), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'move_with_on_off' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_level_control_step_with_on_off(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned short transition_time) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_level_control_step_with_on_off()"); + + variant = g_dbus_proxy_call_sync(level_control_gproxy, "step_with_on_off", + g_variant_new("(qyyyq)", addr16, ep, step_mode, step_size, transition_time), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'step_with_on_off' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_onoff_set(nwk_addr addr16, unsigned char ep, unsigned char on_off_type) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == on_off_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(on_off_gproxy, "set_on_off", + g_variant_new("(qyy)", addr16, ep, on_off_type), G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'set_on_off' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_zone_enroll_response(nwk_addr addr16, unsigned char dst_ep, + unsigned char enroll_response_code, unsigned char zone_id) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_ias_zone_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_ias_zone_proxy, "enroll_response", + g_variant_new("(qyyy)", addr16, dst_ep, enroll_response_code, zone_id), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'enroll_response' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_pollcontrol_check_in_response(nwk_addr addr16, unsigned char ep, + unsigned char start_fast_polling, unsigned short fast_poll_timeout) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_poll_control_proxy, "check_in_response", + g_variant_new("(qyyq)", addr16, ep, start_fast_polling, fast_poll_timeout), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'check_in_response' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_pollcontrol_fast_poll_stop(nwk_addr addr16, unsigned char ep) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_poll_control_proxy, "fast_poll_stop", + g_variant_new("(qy)", addr16, ep), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'fast_poll_stop' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_pollcontrol_set_long_poll_interval(nwk_addr addr16, unsigned char ep, + unsigned int new_long_poll_interval, zb_zcl_pollctrl_check_in cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_pollcontrol_set_long_poll_interval()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_poll_control_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_POLL_CONTROL_INTERFACE, "checkin_response", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_poll_control_proxy, "set_long_poll_interval", + g_variant_new("(qyu)", addr16, ep, new_long_poll_interval), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'set_long_poll_interval' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_pollcontrol_set_short_poll_interval(nwk_addr addr16, unsigned char ep, + unsigned int new_short_poll_interval, zb_zcl_pollctrl_check_in cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR); + + DBG("zbl_pollcontrol_set_short_poll_interval()"); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_poll_control_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_POLL_CONTROL_INTERFACE, "checkin_response", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_POLLCONTROL_SET_POLL_INTERVAL_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_poll_control_proxy, "set_short_poll_interval", + g_variant_new("(qyu)", addr16, ep, new_short_poll_interval), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'set_short_poll_interval' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_add_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, + unsigned char scene_id, unsigned short transition_time, const char *scene_name, + unsigned short ext_field_len, const char *extension_field_sets, + zb_zcl_scene_add_scene_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + int j = 0; + int index = 0; + GVariant *scenename_variant = NULL; + GVariantBuilder *scenename_builder = NULL; + GVariant *extensionfieldSet_variant = NULL; + GVariantBuilder *extensionfieldSet_builder = NULL; + + DBG("zbl_add_scene()"); + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_scene_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_SCENE_INTERFACE, "add_scene_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_SCENE_ADD_SCENE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + scenename_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + while ('\0' != scene_name[j]) { + g_variant_builder_add(scenename_builder, "(y)", scene_name[j]); + j++; + } + scenename_variant = g_variant_builder_end(scenename_builder); + g_variant_builder_unref(scenename_builder); + + extensionfieldSet_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); + + while (index < ext_field_len) { + INFO("Ext contents 0x%02X", extension_field_sets[index]); + g_variant_builder_add(extensionfieldSet_builder, "(y)", extension_field_sets[index]); + index++; + } + extensionfieldSet_variant = g_variant_builder_end(extensionfieldSet_builder); + g_variant_builder_unref(extensionfieldSet_builder); + + variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "add_scene", + g_variant_new("(qyqyqq@a(y)@a(y))", addr16, ep, group_id, scene_id, transition_time, + ext_field_len, scenename_variant, extensionfieldSet_variant), G_DBUS_CALL_FLAGS_NONE, + to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'add_scene' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_view_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, + unsigned char scene_id, zb_zcl_scene_view_scene_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + DBG("zbl_scene_view_scene()"); + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_scene_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_SCENE_INTERFACE, "view_scene_rsp", ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, + _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_SCENE_VIEW_SCENE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "view_scene", + g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), G_DBUS_CALL_FLAGS_NONE, + to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'view_scene' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_remove_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id, zb_zcl_scene_remove_scene_rsp cb, + void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + DBG("zbl_scene_remove_scene()"); + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_scene_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_SCENE_INTERFACE, "remove_scene_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_SCENE_REMOVE_SCENE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "remove_scene", + g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'remove_scene' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_remove_all_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id, zb_zcl_scene_remove_all_scene_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + DBG("zbl_scene_remove_all_scene()"); + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_scene_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_SCENE_INTERFACE, "remove_all_scene_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_SCENE_REMOVE_ALL_SCENE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "remove_all_scene", + g_variant_new("(qyq)", addr16, ep, group_id), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'remove_all_scene' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_store_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, + unsigned char scene_id, zb_zcl_scene_store_scene_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + DBG("zbl_scene_store_scene()"); + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_scene_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_SCENE_INTERFACE, "store_scene_rsp", ZIGBEE_CONTROL_OBJECT_PATH, + NULL, 0, _zbl_response_cb, container, _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_SCENE_STORE_SCENE_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "store_scene", + g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'store_scene' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_recall_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, + unsigned char scene_id) +{ + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "recall_scene", + g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), G_DBUS_CALL_FLAGS_NONE, + -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'recall_scene' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_get_scene_membership(nwk_addr addr16, unsigned char ep, + unsigned short group_id, zb_zcl_scene_get_scene_membership_rsp cb, void *user_data) +{ + int sub_id, to; + zbl_req_cb_s *container; + + int result = ZIGBEE_ERROR_NONE; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + DBG("zbl_scene_get_scene_membership()"); + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR); + + container = calloc(1, sizeof(zbl_req_cb_s)); + RETVM_IF(NULL == container, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + + to = zbl_dbus_get_timeout(zcl_scene_proxy); + sub_id = g_dbus_connection_signal_subscribe((GDBusConnection*)gdbus_conn, NULL, + ZIGBEE_ZCL_SCENE_INTERFACE, "get_scene_membership_rsp", + ZIGBEE_CONTROL_OBJECT_PATH, NULL, 0, _zbl_response_cb, container, + _zbl_request_cleanup); + + if (0 == sub_id) { + ERR("g_dbus_connection_signal_subscribe() Fail"); + free(container); + return ZIGBEE_ERROR_IO_ERROR; + } + + container->cb = cb; + container->sid = sub_id; + container->cid = ZBL_ZCL_SCENE_GET_SCENE_MEMBERSHIP_REQ; + container->tid = g_timeout_add_seconds(to, _zbl_timeout_cb, container); + container->userdata = user_data; + + variant = g_dbus_proxy_call_sync(zcl_scene_proxy, "get_scene_membership", + g_variant_new("(qyq)", addr16, ep, group_id), + G_DBUS_CALL_FLAGS_NONE, to, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get get_scene_membership [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_thermostat_adjust_setpoint(nwk_addr addr16, unsigned char ep, unsigned char mode, + unsigned char amount) +{ + int result = ZIGBEE_ERROR_IO_ERROR; + GVariant *variant = NULL; + GError *dbus_err = NULL; + + RETV_IF(NULL == gdbus_conn, ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == thermostat_gproxy, ZIGBEE_ERROR_IO_ERROR); + + variant = g_dbus_proxy_call_sync(thermostat_gproxy, "setpoint_raise_lower", + g_variant_new("(qyyy)", addr16, ep, mode, amount), + G_DBUS_CALL_FLAGS_NONE, -1, NULL, &dbus_err); + + if (!variant) { + ERR("Failed to get 'setpoint_raise_lower' [%s]", dbus_err->message); + g_error_free(dbus_err); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_variant_get(variant, "(i)", &result); + DBG("ret = [0x%x]", result); + g_variant_unref(variant); + + return result; +} + +int zbl_dbus_start(zigbee_h handle) +{ + FN_CALL; + + GError *error = NULL; + unsigned int id; + + if (gdbus_conn) { + zbl_ref_count++; + return ZIGBEE_ERROR_NONE; + } + + gdbus_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); + if (NULL == gdbus_conn) { + ERR("Couldn't connect to the System bus [%s]\n", error->message); + g_error_free(error); + return ZIGBEE_ERROR_IO_ERROR; + } + + id = g_signal_connect(gdbus_conn, "notify::g-name-owner", + G_CALLBACK(_zbl_dbus_name_owner_notify), handle); + if (0 == id) { + ERR("g_signal_connect() Fail\n"); + return ZIGBEE_ERROR_IO_ERROR; + } + + /* Phase 1. Subscribe signals */ + _zbl_dbus_subscribe_signal(handle); + + /* Phase 2. Make proxies */ + service_gproxy = _zbl_get_service_proxy(); + RETVM_IF(NULL == service_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get service_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(service_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + on_off_gproxy = _zbl_get_on_off_proxy(); + RETVM_IF(NULL == on_off_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get on_off_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(on_off_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + door_lock_gproxy = _zbl_get_door_lock_proxy(); + RETVM_IF(NULL == door_lock_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get door_lock_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(door_lock_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + level_control_gproxy = _zbl_get_level_control_proxy(); + RETVM_IF(NULL == level_control_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get level_control_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(level_control_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + thermostat_gproxy = _zbl_get_thermostat_proxy(); + RETVM_IF(NULL == thermostat_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get thermostat_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(thermostat_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + fan_control_gproxy = _zbl_get_fan_control_proxy(); + RETVM_IF(NULL == fan_control_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get fan_control_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(fan_control_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + alarm_gproxy = _zbl_get_alarm_proxy(); + RETVM_IF(NULL == alarm_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get alarm_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(alarm_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + mfglib_gproxy = _zbl_get_mfglib_proxy(); + RETVM_IF(NULL == mfglib_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get mfglib_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(mfglib_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + zcl_global_proxy = _zbl_get_zcl_global_proxy(); + RETVM_IF(NULL == zcl_global_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_global_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_global_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zdo_dev_proxy = _zbl_get_zdo_dev_proxy(); + RETVM_IF(NULL == zdo_dev_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zdo_dev_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zdo_dev_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zcl_basic_proxy = _zbl_get_basic_proxy(); + RETVM_IF(NULL == zcl_basic_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_basic_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_basic_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zcl_identify_proxy = _zbl_get_identify_proxy(); + RETVM_IF(NULL == zcl_identify_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_identify_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_identify_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zcl_ias_zone_proxy = _zbl_get_ias_zone_proxy(); + RETVM_IF(NULL == zcl_ias_zone_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_ias_zone_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_ias_zone_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zcl_poll_control_proxy = _zbl_get_poll_control_proxy(); + RETVM_IF(NULL == zcl_poll_control_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_poll_control_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_poll_control_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zcl_group_proxy = _zbl_get_group_proxy(); + RETVM_IF(NULL == zcl_group_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_group_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_group_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zcl_scene_proxy = _zbl_get_scene_proxy(); + RETVM_IF(NULL == zcl_scene_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_scene_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_scene_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zdo_bind_proxy = _zbl_get_zdo_bind_proxy(); + RETVM_IF(NULL == zdo_bind_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zdo_bind_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zdo_bind_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + zcl_color_control_proxy = _zbl_get_color_control_proxy(); + RETVM_IF(NULL == zcl_color_control_proxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get zcl_color_control_proxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(zcl_color_control_proxy), ZIGBEE_BROADCAST_TIMEOUT); + + custom_gproxy = _zbl_get_custom_gproxy(); + RETVM_IF(NULL == custom_gproxy, ZIGBEE_ERROR_IO_ERROR, "Couldn't get custom_gproxy"); + g_dbus_proxy_set_default_timeout(G_DBUS_PROXY(custom_gproxy), ZIGBEE_BROADCAST_TIMEOUT); + + zbl_ref_count++; + + return ZIGBEE_ERROR_NONE; +} + +void zbl_dbus_stop(zigbee_h handle) +{ + DBG("zbl_dbus_stop()"); + + if (0 >= zbl_ref_count) { + WARN("dbus does not initiaized\n"); + return; + } + + if (0 > --zbl_ref_count) { + DBG("all connections closed\n"); + zbl_ref_count = 0; + return; + } + + if (gdbus_conn) { + _zbl_dbus_unsubscribe_signal(handle->dbus_sub_ids); + handle->dbus_sub_ids = NULL; + + g_object_unref(service_gproxy); + service_gproxy = NULL; + g_object_unref(on_off_gproxy); + on_off_gproxy = NULL; + g_object_unref(door_lock_gproxy); + door_lock_gproxy = NULL; + g_object_unref(level_control_gproxy); + level_control_gproxy = NULL; + g_object_unref(thermostat_gproxy); + thermostat_gproxy = NULL; + g_object_unref(alarm_gproxy); + alarm_gproxy = NULL; + g_object_unref(fan_control_gproxy); + fan_control_gproxy = NULL; + + g_object_unref(mfglib_gproxy); + mfglib_gproxy = NULL; + g_object_unref(zcl_global_proxy); + zcl_global_proxy = NULL; + g_object_unref(zcl_color_control_proxy); + zcl_color_control_proxy = NULL; + g_object_unref(custom_gproxy); + custom_gproxy = NULL; + + g_object_unref(gdbus_conn); + gdbus_conn = NULL; + + DBG("zbl_dbus_stop() finished"); + } +} + +GDBusConnection* zbl_dbus_get_object(void) +{ + return gdbus_conn; +} + +int zbl_dbus_get_timeout(GDBusProxy *proxy) +{ + gint timeout; + RETV_IF(NULL == gdbus_conn, ZIGBEE_BROADCAST_TIMEOUT); + timeout = g_dbus_proxy_get_default_timeout(proxy); + if (timeout <= 0) { + ERR("Invalid timeout (%d)", timeout); + return ZIGBEE_BROADCAST_TIMEOUT; + } + return timeout; +} + diff --git a/lib/zbl_dbus.h b/lib/zbl_dbus.h new file mode 100644 index 0000000..f2d8634 --- /dev/null +++ b/lib/zbl_dbus.h @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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. + */ +#ifndef __TIZEN_NETWORK_ZIGBEE_LIBRARY_DBUS_H__ +#define __TIZEN_NETWORK_ZIGBEE_LIBRARY_DBUS_H__ + +#include + +#include +#include +#include + +int zbl_dbus_start(zigbee_h handle); +void zbl_dbus_stop(zigbee_h handle); +GDBusConnection* zbl_dbus_get_object(void); +int zbl_dbus_get_timeout(GDBusProxy *proxy); +int zbl_enable(zigbee_h handle, zb_enable_cb cb, void *user_data); +int zbl_set_event_cb(zigbee_h handle, zb_event_cb event_handler); +int zbl_disable(void); +int zbl_hw_reset(void); +int zbl_coex_start(unsigned char channel); +int zbl_coex_stop(void); +int zbl_get_network_info(ieee_addr addr64, nwk_addr *nodeid, nwk_addr *panid, + unsigned char *channel, unsigned char *tx_power); +int zbl_get_controller_mac_address(ieee_addr addr64); +int zbl_get_cluster_list(ieee_addr eui64, unsigned char endpoint, + unsigned char *in_cluster_count, unsigned short in_cluster_list[], + unsigned char *out_cluster_count, unsigned short out_cluster_list[]); +int zbl_get_endpoint_list(ieee_addr eui64, unsigned char *count, unsigned char list[]); +int zbl_get_all_device_info(zb_end_device_info_h **dev_list, unsigned char* num); +int zbl_form_network(zigbee_h handle, zb_form_network_cb cb, void *user_data); +int zbl_disable_network(zigbee_h handle, zb_disable_network_cb cb, void *user_data); +int zbl_leave_device(ieee_addr addr64, bool remove_children, bool rejoin); +int zbl_permit_join(unsigned char duration, bool broadcast); +int zbl_nwk_addr_req(zigbee_h handle, ieee_addr addr64, unsigned char request_type, + unsigned char start_idx, zb_zdo_addr_rsp cb, void *user_data); +int zbl_ieee_addr_req(zigbee_h handle, nwk_addr addr16, zb_zdo_addr_rsp cb, + void *user_data); +int zbl_active_ep(zigbee_h handle, nwk_addr addr16, zb_zdo_active_ep_rsp cb, + void *user_data); +int zbl_simple_desc_req(zigbee_h handle, nwk_addr addr16, unsigned char ep, + zb_zdo_simple_desc_rsp cb, void *user_data); +int zbl_match_desc_req(zigbee_h handle, nwk_addr addr16, + unsigned short profile_id, unsigned char num_in_clusters, + unsigned short *in_clusters, unsigned char num_out_clusters, + unsigned short *out_clusters, zb_zdo_match_desc_rsp cb, void *user_data); +int zbl_device_annce(zigbee_h handle, nwk_addr addr16, ieee_addr addr64, + unsigned char capability); +int zbl_node_desc_req(nwk_addr addr16, zb_zdo_node_desc_rsp cb, void *user_data); +int zbl_power_desc_req(nwk_addr addr16, zb_zdo_power_desc_rsp cb, void *user_data); +int zbl_complex_desc_req(nwk_addr addr16, zb_zdo_complex_desc_rsp cb, void *user_data); +int zbl_user_desc_req(nwk_addr addr16, zb_zdo_user_desc_rsp cb, void *user_data); +int zbl_bind_req(nwk_addr dst_addr16, ieee_addr src_addr64, + unsigned char src_ep, unsigned short cluster_id, ieee_addr dst_addr64, + unsigned char type, nwk_addr group_addr, unsigned char dst_ep, zb_zdo_bind_rsp cb, + void *user_data); +int zbl_unbind_req(nwk_addr dst_addr16, ieee_addr src_addr64, + unsigned char src_ep, unsigned short cluster_id, ieee_addr dst_addr64, + unsigned char type, nwk_addr group_addr, unsigned char dst_ep, + zb_zdo_unbind_rsp cb, void *user_data); +int zbl_mgmt_nwk_disc_req(nwk_addr addr16, unsigned int scan_channels, + unsigned char scan_duration, unsigned char scan_count, unsigned char start_idx, + zb_zdo_mgmt_nwk_disc_rsp cb, void *user_data); +int zbl_mgmt_nwk_update_req(unsigned int scan_channels, unsigned char scan_duration, + unsigned char scan_count, unsigned char nwk_update_id, nwk_addr nwk_manager_addr); +int zbl_mgmt_lqi_req(nwk_addr addr16, unsigned char start_idx, + zb_zdo_mgmt_lqi_rsp cb, void *user_data); +int zbl_mgmt_rtg_req(nwk_addr addr16, unsigned char start_idx, + zb_zdo_mgmt_rtg_rsp cb, void *user_data); +int zbl_mgmt_bind_req(nwk_addr addr16, unsigned char start_idx, + zb_zdo_mgmt_bind_rsp cb, void *user_data); +int zbl_mgmt_leave_device(ieee_addr addr64, unsigned char remove_children, + unsigned rejoin, zb_zdo_mgmt_leave_rsp cb, void *user_data); +int zbl_mgmt_permit_joining_req(nwk_addr addr16, unsigned char duration, + unsigned char tc_significance, zb_zdo_mgmt_permit_joining_rsp cb, void *user_data); + +/* Custom Commands */ +int zbl_aps_send(nwk_addr addr16, unsigned char aps_frame_ctl, unsigned char src_ep, + unsigned char dst_ep, unsigned short cluster_id, unsigned short profile_id, + unsigned char zcl_frame_ctl, unsigned short mfg_code, unsigned char cmd_id, + unsigned short payload_len, unsigned char *payload, zb_aps_send_rsp cb, void *user_data); +int zbl_zcl_send(nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned short cluster_id, unsigned char zcl_frame_ctl, unsigned char cmd, + unsigned short payload_len, unsigned char *payload, + zb_zcl_send_rsp cb, void *user_data); +int zbl_send_to_local(unsigned short length, unsigned char *data, + zb_send_to_local_rsp cb, void *user_data); + +/* ZCL Global Commands */ +int zbl_read_attr_req(zigbee_h handle, unsigned short addr16, unsigned char dest_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short *attribute_ids, + int attribute_ids_len, zb_zcl_global_rsp cb, void *user_data); +int zbl_write_attr_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, write_attr_record_h *records, + int records_len, zb_zcl_global_rsp cb, void *user_data); +int zbl_wattr_undivided_req(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + write_attr_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data); +int zbl_wattr_req_no_rsp(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + write_attr_record_h *records, int records_len); +int zbl_configure_reporting(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, report_config_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data); +int zbl_read_configure_reporting(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, + unsigned char dst_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + read_report_config_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data); +int zbl_discover_attr_req(zigbee_h handle, unsigned short addr16, unsigned char src_ep, + unsigned char dest_ep, unsigned char zcl_frame_ctl, unsigned short cluster_id, + unsigned short start_id, unsigned char max_attribute_ids, + zb_zcl_global_discover_attr_rsp cb, void *user_data); +int zbl_discover_cmds_gen(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, + unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data); +int zbl_discover_cmds_recv(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, + unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data); +int zbl_discover_attr_ext(zigbee_h handle, nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short start_id, + unsigned char max_attribute_ids, zb_zcl_global_discover_attr_extended_rsp cb, + void *user_data); + +/* ZCL Alarm Cluster */ +int zbl_reset_alarm(nwk_addr addr16, unsigned char ep, unsigned char alarm_code, + unsigned short cluster_id); +int zbl_reset_all_alarm(nwk_addr addr16, unsigned char ep); +int zbl_get_alarm(nwk_addr addr16, unsigned char ep, zb_zcl_alarm_get_alarm_rsp cb, + void *user_data); +int zbl_reset_all_alarm_log(nwk_addr addr16, unsigned char ep); + +/* ZCL Color Control Cluster */ +int zbl_ccontrol_move_to_hue(nwk_addr addr16, unsigned char ep, + unsigned char hue, unsigned char direction, + unsigned short transition_time); +int zbl_ccontrol_move_hue(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate); +int zbl_ccontrol_step_hue(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned char transition_time); +int zbl_ccontrol_move_to_saturation(nwk_addr addr16, unsigned char ep, + unsigned char saturation, unsigned short transition_time); +int zbl_ccontrol_move_saturation(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate); +int zbl_ccontrol_step_saturation(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned char transition_time); +int zbl_ccontrol_move_to_hue_and_saturation(nwk_addr addr16, unsigned char ep, + unsigned char hue, unsigned char saturation, + unsigned short transition_time); +int zbl_ccontrol_move_to_color(nwk_addr addr16, unsigned char ep, + unsigned short color_x, unsigned short color_y, + unsigned short transition_time); +int zbl_ccontrol_move_color(nwk_addr addr16, unsigned char ep, + unsigned short rate_x, unsigned short rate_y); +int zbl_ccontrol_step_color(nwk_addr addr16, unsigned char ep, + unsigned short step_x, unsigned short step_y, + unsigned short transition_time); +int zbl_ccontrol_move_to_color_temperature(nwk_addr addr16, unsigned char ep, + unsigned short color_temperature, + unsigned short transition_time); + +/* ZCL Basic Cluster */ +int zbl_reset_factory_default(nwk_addr addr16, unsigned char ep); + +/* ZCL Identity Cluster */ +int zbl_identify(nwk_addr addr16, unsigned char dst_ep, unsigned short identify_time); +int zbl_identify_query(nwk_addr addr16, unsigned char dst_ep, + zb_zcl_identify_query_cb cb, void *user_data); + +/* ZCL Group Cluster */ +int zbl_add_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, + const char *group_name, zb_zcl_group_add_group_rsp cb, void *user_data); +int zbl_view_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, + zb_zcl_group_view_group_rsp cb, void *user_data); +int zbl_group_get_group_membership(nwk_addr addr16, unsigned char ep, + unsigned char group_count, unsigned short *group_list, + zb_zcl_group_get_group_membership_rsp cb, void *user_data); +int zbl_remove_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, + zb_zcl_group_remove_group_rsp cb, void *user_data); +int zbl_remove_all_group(nwk_addr addr16, unsigned char ep); +int zbl_add_group_if_identifying(nwk_addr addr16, unsigned char ep, + unsigned short group_id, const char *group_name); + +/* ZCL Level Control Cluster */ +int zbl_level_control_move_to_level(nwk_addr addr16, unsigned char ep, + unsigned char level, unsigned short transition_time); +int zbl_level_control_move(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate); +int zbl_level_control_step(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned short transition_time); +int zbl_level_control_stop(nwk_addr addr16, unsigned char ep); +int zbl_level_control_move_to_level_with_on_off(nwk_addr addr16, + unsigned char ep, unsigned char level, unsigned short transition_time); +int zbl_level_control_move_with_on_off(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate); +int zbl_level_control_step_with_on_off(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned short transition_time); + +/* ZCL On/Off Cluster */ +int zbl_onoff_set(nwk_addr addr16, unsigned char ep, unsigned char on_off_type); +int zbl_zone_enroll_response(nwk_addr addr16, unsigned char dst_ep, + unsigned char enroll_response_code, unsigned char zone_id); + +/* Poll-control Cluster */ +int zbl_pollcontrol_check_in_response(nwk_addr addr16, unsigned char ep, + unsigned char start_fast_polling, unsigned short fast_poll_timeout); +int zbl_pollcontrol_fast_poll_stop(nwk_addr addr16, unsigned char ep); +int zbl_pollcontrol_set_long_poll_interval(nwk_addr addr16, unsigned char ep, + unsigned int new_long_poll_interval, zb_zcl_pollctrl_check_in cb, void *user_data); +int zbl_pollcontrol_set_short_poll_interval(nwk_addr addr16, unsigned char ep, + unsigned int new_short_poll_interval, zb_zcl_pollctrl_check_in cb, void *user_data); + +/* Scene Cluster */ +int zbl_add_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, + unsigned char scene_id, unsigned short transition_time, const char *scene_name, + unsigned short ext_field_len, const char *extension_field_sets, + zb_zcl_scene_add_scene_rsp cb, void *user_data); +int zbl_view_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, + unsigned char scene_id, zb_zcl_scene_view_scene_rsp cb, void *user_data); +int zbl_remove_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id, zb_zcl_scene_remove_scene_rsp cb, + void *user_data); +int zbl_remove_all_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id, zb_zcl_scene_remove_all_scene_rsp cb, void *user_data); +int zbl_store_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, + unsigned char scene_id, zb_zcl_scene_store_scene_rsp cb, void *user_data); +int zbl_recall_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, + unsigned char scene_id); +int zbl_get_scene_membership(nwk_addr addr16, unsigned char ep, + unsigned short group_id, zb_zcl_scene_get_scene_membership_rsp cb, void *user_data); + +/* Thermostat Cluster */ +int zbl_thermostat_adjust_setpoint(nwk_addr addr16, unsigned char ep, unsigned char mode, + unsigned char amount); + +#endif /* __TIZEN_NETWORK_ZIGBEE_LIBRARY_DBUS_H__ */ diff --git a/lib/zbl_zcl.c b/lib/zbl_zcl.c new file mode 100644 index 0000000..5bcfcae --- /dev/null +++ b/lib/zbl_zcl.c @@ -0,0 +1,1558 @@ +#include +#include +#include + +#include +#include +#include +#include + +#include "zbl.h" +#include "zb-log.h" +#include "zb-common.h" +#include "zcl/zb_zcl_type.h" + +API const char* zb_get_zcl_error_message(int id) +{ + const char* status_name = NULL; + + switch(id) { + case ZB_ZCL_SUCCESS: + status_name = "ZB_ZCL_SUCCESS"; + break; + case ZB_ZCL_FAILURE: + status_name = "ZB_ZCL_FAILURE"; + break; + case ZB_ZCL_NOT_AUTHORIZED: + status_name = "ZB_ZCL_NOT_AUTHORIZED"; + break; + case ZB_ZCL_RESERVED_FIELD_NOT_ZERO: + status_name = "ZB_ZCL_RESERVED_FIELD_NOT_ZERO"; + break; + case ZB_ZCL_MALFORMED_COMMAND: + status_name = "ZB_ZCL_MALFORMED_COMMAND"; + break; + case ZB_ZCL_UNSUP_CLUSTER_COMMAND: + status_name = "ZB_ZCL_UNSUP_CLUSTER_COMMAND"; + break; + case ZB_ZCL_UNSUP_GENERAL_COMMAND: + status_name = "ZB_ZCL_UNSUP_GENERAL_COMMAND"; + break; + case ZB_ZCL_UNSUP_MANUF_CLUSTER_COMMAND: + status_name = "ZB_ZCL_UNSUP_MANUF_CLUSTER_COMMAND"; + break; + case ZB_ZCL_UNSUP_MANUF_GENERAL_COMMAND: + status_name = "ZB_ZCL_UNSUP_MANUF_GENERAL_COMMAND"; + break; + case ZB_ZCL_INVALID_FIELD: + status_name = "ZB_ZCL_INVALID_FIELD"; + break; + case ZB_ZCL_UNSUPPORTED_ATTRIBUTE: + status_name = "ZB_ZCL_SUCCESS"; + break; + case ZB_ZCL_INVALID_VALUE: + status_name = "ZB_ZCL_INVALID_VALUE"; + break; + case ZB_ZCL_READ_ONLY: + status_name = "ZB_ZCL_READ_ONLY"; + break; + case ZB_ZCL_INSUFFICIENT_SPACE: + status_name = "ZB_ZCL_INSUFFICIENT_SPACE"; + break; + case ZB_ZCL_DUPLICATE_EXISTS: + status_name = "ZB_ZCL_INSUFFICIENT_SPACE"; + break; + case ZB_ZCL_NOT_FOUND: + status_name = "ZB_ZCL_NOT_FOUND"; + break; + case ZB_ZCL_UNREPORTABLE_ATTRIBUTE: + status_name = "ZB_ZCL_UNREPORTABLE_ATTRIBUTE"; + break; + case ZB_ZCL_INVALID_DATA_TYPE: + status_name = "ZB_ZCL_INVALID_DATA_TYPE"; + break; + case ZB_ZCL_INVALID_SELECTOR: + status_name = "ZB_ZCL_INVALID_SELECTOR"; + break; + case ZB_ZCL_WRITE_ONLY: + status_name = "ZB_ZCL_WRITE_ONLY"; + break; + case ZB_ZCL_INCONSISTENT_STARTUP_STATE: + status_name = "ZB_ZCL_INCONSISTENT_STARTUP_STATE"; + break; + case ZB_ZCL_DEFINED_OUT_OF_BAND: + status_name = "ZB_ZCL_DEFINED_OUT_OF_BAND"; + break; + case ZB_ZCL_INCONSISTENT: + status_name = "ZB_ZCL_INCONSISTENT"; + break; + case ZB_ZCL_ACTION_DENIED: + status_name = "ZB_ZCL_ACTION_DENIED"; + break; + case ZB_ZCL_TIMEOUT: + status_name = "ZB_ZCL_TIMEOUT"; + break; + case ZB_ZCL_ABORT: + status_name = "ZB_ZCL_ABORT"; + break; + case ZB_ZCL_INVALID_IMAGE: + status_name = "ZB_ZCL_INVALID_IMAGE"; + break; + case ZB_ZCL_WAIT_FOR_DATA: + status_name = "ZB_ZCL_WAIT_FOR_DATA"; + break; + case ZB_ZCL_NO_IMAGE_AVAILABLE: + status_name = "ZB_ZCL_NO_IMAGE_AVAILABLE"; + break; + case ZB_ZCL_REQUIRE_MORE_IMAGE: + status_name = "ZB_ZCL_REQUIRE_MORE_IMAGE"; + break; + default: + status_name = "ZB_ZCL_UNDEFINED"; + break; + } + + return status_name; +} + +API const char* zb_get_cluster_name(int id) +{ + const char* clust_name = NULL; + + switch (id) { + case ZB_ZCL_BASIC_CLUSTER_ID: + clust_name = "ZB_ZCL_BASIC"; + break; + case ZB_ZCL_POWER_CONFIG_CLUSTER_ID: + clust_name = "ZB_ZCL_POWER_CONFIG"; + break; + case ZB_ZCL_DEVICE_TEMP_CLUSTER_ID: + clust_name = "ZB_ZCL_DEVICE_TEMP"; + break; + case ZB_ZCL_IDENTIFY_CLUSTER_ID: + clust_name = "ZB_ZCL_IDENTIFY"; + break; + case ZB_ZCL_GROUPS_CLUSTER_ID: + clust_name = "ZB_ZCL_GROUPS"; + break; + case ZB_ZCL_SCENES_CLUSTER_ID: + clust_name = "ZB_ZCL_SCENES"; + break; + case ZB_ZCL_ON_OFF_CLUSTER_ID: + clust_name = "ZB_ZCL_ON_OFF"; + break; + case ZB_ZCL_ON_OFF_SWITCH_CONFIG_CLUSTER_ID: + clust_name = "ZB_ZCL_ON_OFF_SWITCH_CONFIG"; + break; + case ZB_ZCL_LEVEL_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_LEVEL_CONTROL"; + break; + case ZB_ZCL_ALARM_CLUSTER_ID: + clust_name = "ZB_ZCL_ALARM"; + break; + case ZB_ZCL_TIME_CLUSTER_ID: + clust_name = "ZB_ZCL_TIME"; + break; + case ZB_ZCL_RSSI_LOCATION_CLUSTER_ID: + clust_name = "ZB_ZCL_RSSI_LOCATION"; + break; + case ZB_ZCL_BINARY_INPUT_BASIC_CLUSTER_ID: + clust_name = "ZB_ZCL_BINARY_INPUT_BASIC"; + break; + case ZB_ZCL_COMMISSIONING_CLUSTER_ID: + clust_name = "ZB_ZCL_COMMISSIONING"; + break; + case ZB_ZCL_PARTITION_CLUSTER_ID: + clust_name = "ZB_ZCL_PARTITION"; + break; + case ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID: + clust_name = "ZB_ZCL_OTA_BOOTLOAD"; + break; + case ZB_ZCL_POWER_PROFILE_CLUSTER_ID: + clust_name = "ZB_ZCL_POWER_PROFILE"; + break; + case ZB_ZCL_APPLIANCE_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_APPLIANCE_CONTROL"; + break; + case ZB_ZCL_POLL_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_POLL_CONTROL"; + break; + case ZB_ZCL_SHADE_CONFIG_CLUSTER_ID: + clust_name = "ZB_ZCL_SHADE_CONFIG"; + break; + case ZB_ZCL_DOOR_LOCK_CLUSTER_ID: + clust_name = "ZB_ZCL_DOOR_LOCK"; + break; + case ZB_ZCL_WINDOW_COVERING_CLUSTER_ID: + clust_name = "ZB_ZCL_WINDOW_COVERING"; + break; + case ZB_ZCL_PUMP_CONFIG_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_PUMP_CONFIG_CONTROL"; + break; + case ZB_ZCL_THERMOSTAT_CLUSTER_ID: + clust_name = "ZB_ZCL_THERMOSTAT"; + break; + case ZB_ZCL_FAN_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_FAN_CONTROL"; + break; + case ZB_ZCL_DEHUMID_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_DEHUMID_CONTROL"; + break; + case ZB_ZCL_THERMOSTAT_UI_CONFIG_CLUSTER_ID: + clust_name = "ZB_ZCL_THERMOSTAT_UI_CONFIG"; + break; + case ZB_ZCL_COLOR_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_COLOR_CONTROL"; + break; + case ZB_ZCL_BALLAST_CONFIGURATION_CLUSTER_ID: + clust_name = "ZB_ZCL_BALLAST_CONFIGURATION"; + break; + case ZB_ZCL_ILLUM_MEASUREMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_ILLUM_MEASUREMENT"; + break; + case ZB_ZCL_ILLUM_LEVEL_SENSING_CLUSTER_ID: + clust_name = "ZB_ZCL_ILLUM_LEVEL_SENSING"; + break; + case ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_TEMP_MEASUREMENT"; + break; + case ZB_ZCL_PRESSURE_MEASUREMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_PRESSURE_MEASUREMENT"; + break; + case ZB_ZCL_FLOW_MEASUREMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_FLOW_MEASUREMENT"; + break; + case ZB_ZCL_RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_RELATIVE_HUMIDITY_MEASUREMENT"; + break; + case ZB_ZCL_OCCUPANCY_SENSING_CLUSTER_ID: + clust_name = "ZB_ZCL_OCCUPANCY_SENSING"; + break; + case ZB_ZCL_IAS_ZONE_CLUSTER_ID: + clust_name = "ZB_ZCL_IAS_ZONE"; + break; + case ZB_ZCL_IAS_ACE_CLUSTER_ID: + clust_name = "ZB_ZCL_IAS_ACE"; + break; + case ZB_ZCL_IAS_WD_CLUSTER_ID: + clust_name = "ZB_ZCL_IAS_WD"; + break; + case ZB_ZCL_GENERIC_TUNNEL_CLUSTER_ID: + clust_name = "ZB_ZCL_GENERIC_TUNNEL"; + break; + case ZB_ZCL_BACNET_PROTOCOL_TUNNEL_CLUSTER_ID: + clust_name = "ZB_ZCL_BACNET_PROTOCOL_TUNNEL"; + break; + case ZB_ZCL_11073_PROTOCOL_TUNNEL_CLUSTER_ID: + clust_name = "ZB_ZCL_11073_PROTOCOL_TUNNEL"; + break; + case ZB_ZCL_ISO7816_PROTOCOL_TUNNEL_CLUSTER_ID: + clust_name = "ZB_ZCL_ISO7816_PROTOCOL_TUNNEL"; + break; + case ZB_ZCL_PRICE_CLUSTER_ID: + clust_name = "ZB_ZCL_PRICE"; + break; + case ZB_ZCL_DEMAND_RESPONSE_LOAD_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_DEMAND_RESPONSE_LOAD_CONTROL"; + break; + case ZB_ZCL_SIMPLE_METERING_CLUSTER_ID: + clust_name = "ZB_ZCL_SIMPLE_METERING"; + break; + case ZB_ZCL_MESSAGING_CLUSTER_ID: + clust_name = "ZB_ZCL_MESSAGING"; + break; + case ZB_ZCL_TUNNELING_CLUSTER_ID: + clust_name = "ZB_ZCL_TUNNELING"; + break; + case ZB_ZCL_PREPAYMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_PREPAYMENT"; + break; + case ZB_ZCL_ENERGY_MANAGEMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_ENERGY_MANAGEMENT"; + break; + case ZB_ZCL_TOU_CALENDAR_CLUSTER_ID: + clust_name = "ZB_ZCL_TOU_CALENDAR"; + break; + case ZB_ZCL_DEVICE_MANAGEMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_DEVICE_MANAGEMENT8"; + break; + case ZB_ZCL_EVENTS_CLUSTER_ID: + clust_name = "ZB_ZCL_EVENTS"; + break; + case ZB_ZCL_MDU_PAIRING_CLUSTER_ID: + clust_name = "ZB_ZCL_MDU_PAIRING"; + break; + case ZB_ZCL_KEY_ESTABLISHMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_KEY_ESTABLISHMENT"; + break; + case ZB_ZCL_INFORMATION_CLUSTER_ID: + clust_name = "ZB_ZCL_INFORMATION"; + break; + case ZB_ZCL_DATA_SHARING_CLUSTER_ID: + clust_name = "ZB_ZCL_DATA_SHARING"; + break; + case ZB_ZCL_GAMING_CLUSTER_ID: + clust_name = "ZB_ZCL_GAMING"; + break; + case ZB_ZCL_DATA_RATE_CONTROL_CLUSTER_ID: + clust_name = "ZB_ZCL_DATA_RATE_CONTROL"; + break; + case ZB_ZCL_VOICE_OVER_ZIGBEE_CLUSTER_ID: + clust_name = "ZB_ZCL_VOICE_OVER_ZIGBEE"; + break; + case ZB_ZCL_CHATTING_CLUSTER_ID: + clust_name = "ZB_ZCL_CHATTING"; + break; + case ZB_ZCL_PAYMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_PAYMENT"; + break; + case ZB_ZCL_BILLING_CLUSTER_ID: + clust_name = "ZB_ZCL_BILLING"; + break; + case ZB_ZCL_APPLIANCE_IDENTIFICATION_CLUSTER_ID: + clust_name = "ZB_ZCL_APPLIANCE_IDENTIFICATION"; + break; + case ZB_ZCL_METER_IDENTIFICATION_CLUSTER_ID: + clust_name = "ZB_ZCL_DATA_RATE_CONTROL"; + break; + case ZB_ZCL_APPLIANCE_EVENTS_AND_ALERT_CLUSTER_ID: + clust_name = "ZB_ZCL_APPLIANCE_EVENTS_AND_ALERT"; + break; + case ZB_ZCL_APPLIANCE_STATISTICS_CLUSTER_ID: + clust_name = "ZB_ZCL_APPLIANCE_STATISTICS"; + break; + case ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID: + clust_name = "ZB_ZCL_ELECTRICAL_MEASUREMENT"; + break; + case ZB_ZCL_DIAGNOSTICS_CLUSTER_ID: + clust_name = "ZB_ZCL_DIAGNOSTICS"; + break; + case ZB_ZCL_ZLL_COMMISSIONING_CLUSTER_ID: + clust_name = "ZB_ZCL_ZLL_COMMISSIONING0"; + break; + default: + clust_name = "UNDEFINED_CLUSTER"; + break; + } + + return clust_name; +} + +typedef struct _attr_type_size { + unsigned char type; + unsigned char size; +} AttrTypeSize; + +static AttrTypeSize attribute_sizes[] = { + {ZB_ZCL_NO_DATA_ATTRIBUTE_TYPE, 0}, + {ZB_ZCL_8_BIT_DATA, 1}, + {ZB_ZCL_16_BIT_DATA, 2}, + {ZB_ZCL_24_BIT_DATA, 3}, + {ZB_ZCL_32_BIT_DATA, 4}, + {ZB_ZCL_40_BIT_DATA, 5}, + {ZB_ZCL_48_BIT_DATA, 6}, + {ZB_ZCL_56_BIT_DATA, 7}, + {ZB_ZCL_64_BIT_DATA, 8}, + {ZB_ZCL_BOOLEAN, 1}, + {ZB_ZCL_8_BIT_BITMAP, 1}, + {ZB_ZCL_16_BIT_BITMAP, 2}, + {ZB_ZCL_24_BIT_BITMAP, 3}, + {ZB_ZCL_32_BIT_BITMAP, 4}, + {ZB_ZCL_40_BIT_BITMAP, 5}, + {ZB_ZCL_48_BIT_BITMAP, 6}, + {ZB_ZCL_56_BIT_BITMAP, 7}, + {ZB_ZCL_64_BIT_BITMAP, 8}, + {ZB_ZCL_UNSIGNED_8_BIT_INTEGER, 1}, + {ZB_ZCL_UNSIGNED_16_BIT_INTEGER, 2}, + {ZB_ZCL_UNSIGNED_24_BIT_INTEGER, 3}, + {ZB_ZCL_UNSIGNED_32_BIT_INTEGER, 4}, + {ZB_ZCL_UNSIGNED_40_BIT_INTEGER, 5}, + {ZB_ZCL_UNSIGNED_48_BIT_INTEGER, 6}, + {ZB_ZCL_UNSIGNED_56_BIT_INTEGER, 7}, + {ZB_ZCL_UNSIGNED_64_BIT_INTEGER, 8}, + {ZB_ZCL_SIGNED_8_BIT_INTEGER, 1}, + {ZB_ZCL_SIGNED_16_BIT_INTEGER, 2}, + {ZB_ZCL_SIGNED_24_BIT_INTEGER, 3}, + {ZB_ZCL_SIGNED_32_BIT_INTEGER, 4}, + {ZB_ZCL_SIGNED_40_BIT_INTEGER, 5}, + {ZB_ZCL_SIGNED_48_BIT_INTEGER, 6}, + {ZB_ZCL_SIGNED_56_BIT_INTEGER, 7}, + {ZB_ZCL_SIGNED_64_BIT_INTEGER, 8}, + {ZB_ZCL_8_BIT_ENUMERATION, 1}, + {ZB_ZCL_16_BIT_ENUMERATION, 2}, + {ZB_ZCL_SEMI_PRECISION, 2}, + {ZB_ZCL_SINGLE_PRECISION, 4}, + {ZB_ZCL_DOUBLE_PRECISION, 8}, + {ZB_ZCL_TIME_OF_DAY, 4}, + {ZB_ZCL_DATE, 4}, + {ZB_ZCL_UTC_TIME, 4}, + {ZB_ZCL_CLUSTER_ID, 2}, + {ZB_ZCL_ATTRIBUTE_ID, 2}, + {ZB_ZCL_BACNET_OID, 4}, + {ZB_ZCL_IEEE_ADDRESS, 8}, + {ZB_ZCL_128_BIT_SECURITY_KEY, 16}, +}; + +static unsigned char analog_discrete_thresholds[] = { + 0x07, DATA_TYPE_NONE, + 0x1F, DATA_TYPE_DISCRETE, + 0x2F, DATA_TYPE_ANALOG, + 0x37, DATA_TYPE_DISCRETE, + 0x3F, DATA_TYPE_ANALOG, + 0x57, DATA_TYPE_DISCRETE, + 0xDF, DATA_TYPE_NONE, + 0xE7, DATA_TYPE_ANALOG, + 0xFF, DATA_TYPE_NONE +}; + +API int zb_get_analog_or_discret(unsigned char type) +{ + int index = 0; + + while (analog_discrete_thresholds[index] < type) + index += 2; + + return analog_discrete_thresholds[index+1]; +} + +API int zb_get_data_size(unsigned char type) +{ + int i; + int count = (int)(sizeof(attribute_sizes) / 2); + for (i = 0; i < count; i++) { + if (attribute_sizes[i].type == type) + return attribute_sizes[i].size; + } + return -1; +} + +API int zb_create_read_attr_status_record(read_attr_status_record_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + read_attr_status_record_h simple = calloc(1, sizeof(struct read_attribute_status_record_s)); + RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = simple; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_read_attr_status_record(read_attr_status_record_h handle) +{ + RET_IF(NULL == handle); + if (handle->value) + free(handle->value); + free(handle); +} + +API int zb_get_id_from_read_attr_status_record(read_attr_status_record_h handle, + unsigned short* id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); + *id = handle->id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_id_to_read_attr_status_record(read_attr_status_record_h handle, + unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_status_from_read_attr_status_record(read_attr_status_record_h handle, + unsigned char* status) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER); + *status = handle->status; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_status_to_read_attr_status_record(read_attr_status_record_h handle, + unsigned char status) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->status = status; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_type_from_read_attr_status_record(read_attr_status_record_h handle, + unsigned char *type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); + *type = handle->type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_type_to_read_attr_status_record(read_attr_status_record_h handle, + unsigned char type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->type = type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_value_from_read_attr_status_record(read_attr_status_record_h handle, + unsigned char type, zb_value_h value) +{ + int len = -1; + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_NO_DATA); + + len = zb_get_data_size(type); + if (0 < len) { + memcpy(value->val, handle->value, len); + value->size = len; + value->type = type; + } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) { + if (value->str) { + if (value->str->v) + free(value->str->v); + free(value->str); + } + value->str = calloc(1, sizeof(struct attribute_str_s)); + RETV_IF(NULL == value->str, ZIGBEE_ERROR_OUT_OF_MEMORY); + value->str->n = *handle->value; + /* The first 1 byte indicate invalid or length of string */ + if (0xff == value->str->n) { + free(value->str); + return ZIGBEE_ERROR_NO_DATA; + } + value->str->v = calloc(value->str->n+1, 1); + if (NULL == value->str->v) { + free(value->str); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + memcpy(value->str->v, handle->value+sizeof(value->str->n), value->str->n); + + value->type = type; + value->size = value->str->n; + } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) { + if (value->wstr) { + if (value->wstr->v) + free(value->wstr->v); + free(value->wstr); + } + value->wstr = calloc(1, sizeof(struct attribute_wstr_s)); + RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY); + value->wstr->n = *(handle->value+1) << 8 | *handle->value; + /* The first 2 byte indicate invalid or length of string */ + if (0xffff == value->wstr->n) { + free(value->wstr); + return ZIGBEE_ERROR_NO_DATA; + } + value->wstr->v = calloc(value->wstr->n+1, 1); + if (NULL == value->wstr->v) { + free(value->wstr); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + memcpy(value->wstr->v, handle->value+sizeof(value->wstr->n), value->wstr->n); + + value->type = type; + value->size = value->wstr->n; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_value_to_read_attr_status_record(read_attr_status_record_h handle, + unsigned char type, zb_value_h value) +{ + int len = -1; + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + + if (handle->value) + free(handle->value); + + len = zb_get_data_size(type); + if (0 < len) { + handle->value = calloc(len, sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + memcpy(handle->value, value->val, len); + } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) { + RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA); + handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + handle->value[0] = value->str->n; + memcpy(handle->value + sizeof(value->str->n), + value->str->v+sizeof(value->str->n), value->str->n); + } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) { + RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA); + handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + handle->value[0] = value->wstr->n & 0xff; + handle->value[1] = (value->wstr->n >> 8) & 0xff ; + memcpy(handle->value + sizeof(value->wstr->n), + value->wstr->v+sizeof(value->wstr->n), value->wstr->n); + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_create_value(zb_value_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + zb_value_h simple = calloc(1, sizeof(struct zb_value_s)); + RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = simple; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_value(zb_value_h handle) +{ + RET_IF(NULL == handle); + if (handle->str) { + if (handle->str->v) + free(handle->str->v); + free(handle->str); + } + if (handle->wstr) { + if (handle->wstr->v) + free(handle->wstr->v); + free(handle->wstr); + } + free(handle); +} + +API int zb_set_value(zb_value_h handle, unsigned char type, unsigned char *value, + int count) +{ + int len = -1; + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + + len = zb_get_data_size(type); + if (0 < len) { + memcpy(handle->val, value, len); + handle->size = len; + handle->type = type; + } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) { + if (handle->str) { + if (handle->str->v) + free(handle->str->v); + free(handle->str); + } + /* string size exception case */ + RETV_IF(0xff - 1 < handle->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->str = malloc(sizeof(struct attribute_str_s)); + RETV_IF(NULL == handle->str, ZIGBEE_ERROR_OUT_OF_MEMORY); + handle->str->n = count; + /* The first 1 byte indicate invalid or length of string */ + handle->str->v = calloc(sizeof(unsigned char), handle->str->n + sizeof(handle->str->n)); + RETV_IF(NULL == handle->str->v, ZIGBEE_ERROR_OUT_OF_MEMORY); + memcpy(handle->str->v, value+sizeof(handle->str->n), handle->str->n); + + handle->type = type; + handle->size = count; + } else if (ZB_ZCL_LONG_OCTAT_STRING == type || ZB_ZCL_LONG_CHRACTER_STRING == type) { + if (handle->wstr) { + if (handle->wstr->v) + free(handle->wstr->v); + free(handle->wstr); + } + /* 2 byte string size exception case */ + RETV_IF(0xffff - 1 < handle->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->wstr = malloc(sizeof(struct attribute_wstr_s)); + RETV_IF(NULL == handle->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY); + handle->wstr->n = count; + /* The first 2 byte indicate invalid or length of string */ + handle->wstr->v = calloc(sizeof(unsigned char), handle->wstr->n + sizeof(handle->wstr->n)); + RETV_IF(NULL == handle->wstr->v, ZIGBEE_ERROR_OUT_OF_MEMORY); + memcpy(handle->wstr->v, value+sizeof(handle->wstr->n), handle->wstr->n); + + handle->type = type; + handle->size = count; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_value(zb_value_h handle, unsigned char *type, unsigned char **value, + int *count) +{ + int len = -1; + unsigned char *s = NULL; + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + + len = zb_get_data_size(handle->type); + if (0 < len) { + s = calloc(handle->size + 1 , sizeof(char)); + memcpy(s, handle->val, len); + *count = len; + } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { + RETV_IF(NULL == handle->str, ZIGBEE_ERROR_NO_DATA); + s = calloc(sizeof(unsigned char), handle->str->n); + RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY); + memcpy(s, handle->str->v+sizeof(handle->str->n), handle->str->n); + *count = handle->str->n; + } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { + RETV_IF(NULL == handle->wstr, ZIGBEE_ERROR_NO_DATA); + s = calloc(sizeof(unsigned char), handle->wstr->n); + RETV_IF(NULL == s, ZIGBEE_ERROR_OUT_OF_MEMORY); + memcpy(s, handle->wstr->v+sizeof(handle->wstr->n), handle->wstr->n); + *count = handle->wstr->n; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + *type = handle->type; + *value = s; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_create_discover_attr_info(discover_attr_info_record_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + discover_attr_info_record_h simple = calloc(1, + sizeof(struct discover_attribute_info_record_s)); + RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = simple; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_discover_attr_info(discover_attr_info_record_h handle) +{ + free(handle); +} + +API int zb_get_id_from_discover_attr_info( + discover_attr_info_record_h handle, + unsigned short *id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); + *id = handle->id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_id_to_discover_attr_info( + discover_attr_info_record_h handle, + unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_type_from_discover_attr_info( + discover_attr_info_record_h handle, + unsigned char *type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); + *type = handle->type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_type_to_discover_attr_info( + discover_attr_info_record_h handle, + unsigned char type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->type = type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_create_write_attr_record( + write_attr_record_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + write_attr_record_h t = calloc(1, sizeof(struct write_attribute_record_s)); + RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = t; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_write_attr_record(write_attr_record_h handle) +{ + RET_IF(NULL == handle); + if (handle->value) + free(handle->value); + free(handle); +} + +API int zb_set_id_to_write_attr_record(write_attr_record_h handle, + unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_type_to_write_attr_record(write_attr_record_h handle, + unsigned char type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->type = type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_buf_to_write_attr_record(write_attr_record_h handle, + unsigned char type, unsigned char *value, int count) +{ + int len = -1; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + + if (handle->value) + free(handle->value); + + len = zb_get_data_size(type); + if (0 < len) { + handle->value = calloc(count + 1 , sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + memcpy(handle->value, value, count); + } else if (ZB_ZCL_OCTAT_STRING == type || ZB_ZCL_CHRACTER_STRING == type) { + handle->value = calloc(count + sizeof(unsigned char) + 1, sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + /* The first 1 byte indicate invalid or length of string */ + handle->value[0] = count & 0xff; + memcpy(handle->value + sizeof(unsigned char), value + sizeof(unsigned char), count); + } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) { + handle->value = calloc(count + sizeof(unsigned short) + 1, sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + /* The first 2 byte indicate invalid or length of string */ + handle->value[0] = count & 0xff; + handle->value[1] = (count >> 8) & 0xff ; + memcpy(handle->value + sizeof(unsigned short), value + sizeof(unsigned short), count); + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_value_to_write_attr_record(write_attr_record_h handle, zb_value_h value) +{ + int len = -1; + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + + if (handle->value) + free(handle->value); + + len = zb_get_data_size(value->type); + if (0 < len) { + handle->value = calloc(value->size + 1 , sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + memcpy(handle->value, value->val, value->size); + handle->type = value->type; + } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { + RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA); + /* 1 byte string size exception case */ + RETV_IF(0xff - 1 < value->str->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + /* The first 1 byte indicate invalid or length of string */ + handle->value[0] = value->str->n & 0xff; + memcpy(handle->value + sizeof(value->str->n), + value->str->v + sizeof(value->str->n), value->str->n); + } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) { + RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA); + /* 2 byte string size exception case */ + RETV_IF(0xffff - 1 < value->wstr->n, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + /* The first 2 byte indicate invalid or length of string */ + handle->value[0] = value->wstr->n & 0xff; + handle->value[1] = (value->wstr->n >> 8) & 0xff ; + memcpy(handle->value + sizeof(value->wstr->n), + value->wstr->v + sizeof(value->wstr->n), value->wstr->n); + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_create_write_attr_status(write_attr_status_record_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + write_attr_status_record_h simple = calloc(1, + sizeof(struct write_attribute_status_record_s)); + RETVM_IF(NULL == simple, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = simple; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_write_attr_status(write_attr_status_record_h handle) +{ + free(handle); +} + +API int zb_get_status_from_write_attr_status(write_attr_status_record_h handle, + unsigned char *status) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER); + *status = handle->status; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_status_to_write_attr_status(write_attr_status_record_h handle, + unsigned char status) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->status = status; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_id_from_write_attr_status(write_attr_status_record_h handle, + unsigned short *id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); + *id = handle->id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_id_to_write_attr_status(write_attr_status_record_h handle, + unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_create_report_config_record(report_config_record_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + report_config_record_h t; + t = calloc(1, sizeof(struct reporting_configuration_record_s)); + RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = t; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_report_config_record(report_config_record_h handle) +{ + RET_IF(NULL == handle); + if (handle->change) + free(handle->change); + free(handle); +} + +API int zb_get_dir_from_report_config_record(report_config_record_h handle, + unsigned char *dir) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER); + *dir = handle->dir; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_dir_to_report_config_record(report_config_record_h handle, + unsigned char dir) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + if (dir == ZB_ZCL_CLIENT_TO_SERVER) + handle->dir = 0x00 ; + else + handle->dir = 0x01; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_id_from_report_config_record(report_config_record_h handle, + unsigned short *id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); + *id = handle->id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_id_to_report_config_record(report_config_record_h handle, + unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id ; + return ZIGBEE_ERROR_NONE; +} + + +API int zb_get_type_from_report_config_record(report_config_record_h handle, + unsigned char *type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); + *type = handle->type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_type_to_report_config_record(report_config_record_h handle, + unsigned char type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->type = type; + return ZIGBEE_ERROR_NONE; +} + + +API int zb_get_min_i_from_report_config_record(report_config_record_h handle, + unsigned short *min_i) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == min_i, ZIGBEE_ERROR_INVALID_PARAMETER); + *min_i = handle->min_i; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_min_i_to_report_config_record(report_config_record_h handle, + unsigned short min_i) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->min_i = min_i; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_max_i_from_report_config_record(report_config_record_h handle, + unsigned short *max_i) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == max_i, ZIGBEE_ERROR_INVALID_PARAMETER); + *max_i = handle->max_i; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_max_i_to_report_config_record(report_config_record_h handle, + unsigned short max_i) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->max_i = max_i; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_timeout_from_report_config_record(report_config_record_h handle, + unsigned short *to) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == to, ZIGBEE_ERROR_INVALID_PARAMETER); + *to = handle->to; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_timeout_to_report_config_record(report_config_record_h handle, + unsigned short to) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->to = to; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_change_from_report_config_record1(report_config_record_h handle, + zb_value_h value) +{ + int len = -1; + int data_type = DATA_TYPE_NONE; + + NOT_USED(data_type); + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA); + + len = zb_get_data_size(handle->type); + data_type = zb_get_analog_or_discret(handle->type); + if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { + memcpy(value->val, handle->change, len); + value->type = handle->type; + value->size = len; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_change_to_report_config_record1(report_config_record_h handle, + zb_value_h value) +{ + int len = -1; + int data_type = DATA_TYPE_NONE; + + NOT_USED(data_type); + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + + if (handle->change) + free(handle->change); + + len = zb_get_data_size(value->type); + data_type = zb_get_analog_or_discret(value->type); + if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { + handle->change = calloc(len + 1, sizeof(char)); + RETVM_IF(NULL == handle->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + memcpy(handle->change, value->val, len); + handle->type = value->type; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_change_from_report_config_record2(report_config_record_h handle, + unsigned char *type, unsigned char **value, int *size) +{ + int len = -1; + int data_type = DATA_TYPE_NONE; + unsigned char *t = NULL; + + NOT_USED(data_type); + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA); + + len = zb_get_data_size(handle->type); + data_type = zb_get_analog_or_discret(handle->type); + if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { + t = calloc(len + 1, sizeof(char)); + RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + memcpy(t, handle->change, len); + *value = t; + *type = handle->type; + *size = len; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} +API int zb_set_change_to_report_config_record2( + report_config_record_h handle, unsigned char type, unsigned char *value) +{ + int len = -1; + int data_type = DATA_TYPE_NONE; + + NOT_USED(data_type); + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + if (handle->change) + free(handle->change); + + len = zb_get_data_size(type); + data_type = zb_get_analog_or_discret(type); + + if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { + handle->change = calloc(len + 1, sizeof(unsigned char)); + RETVM_IF(NULL == handle->change, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + memcpy(handle->change, value, len); + handle->type = type; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_change_from_report_config_record3(report_config_record_h handle, + unsigned char *type, unsigned char *value, int *size) +{ + int len = -1; + int data_type = DATA_TYPE_NONE; + + NOT_USED(data_type); + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->change, ZIGBEE_ERROR_NO_DATA); + + len = zb_get_data_size(handle->type); + data_type = zb_get_analog_or_discret(handle->type); + if (0 < len /* && DATA_TYPE_ANALOG == data_type */) { + memcpy(value, handle->change, len); + *type = handle->type; + *size = len; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_create_read_report_config_record(read_report_config_record_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + read_report_config_record_h t = + calloc(1, sizeof(struct read_reporting_configuration_record_s)); + RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = t; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_read_report_config_record(read_report_config_record_h handle) +{ + free(handle); +} + +API int zb_set_dir_to_read_report_config_record(read_report_config_record_h handle, + unsigned char dir) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + if (dir == ZB_ZCL_CLIENT_TO_SERVER) + handle->dir = 0x00; + else + handle->dir = 0x01; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_dir_from_read_report_config_record(read_report_config_record_h handle, + unsigned char *dir) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + *dir = handle->dir; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_id_to_read_report_config_record(read_report_config_record_h handle, + unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_id_from_read_report_config_record(read_report_config_record_h handle, + unsigned short *id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + *id = handle->id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_create_report_config_response_record( + report_config_response_record_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + report_config_response_record_h t = + calloc(1, sizeof(struct reporting_configuration_response_record_s)); + RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = t; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_report_config_response_record( + report_config_response_record_h handle) +{ + free(handle); +} + +API int zb_get_status_from_report_config_response_record( + report_config_response_record_h handle, unsigned char *status) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER); + *status = handle->status; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_status_to_report_config_response_record( + report_config_response_record_h handle, unsigned char status) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->status = status; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_dir_from_report_config_response_record( + report_config_response_record_h handle, unsigned char *dir) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dir, ZIGBEE_ERROR_INVALID_PARAMETER); + *dir = handle->dir; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_dir_to_report_config_response_record( + report_config_response_record_h handle, unsigned char dir) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->dir = handle->dir; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_id_from_report_config_response_record( + report_config_response_record_h handle, unsigned short *id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); + *id = handle->id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_id_to_report_config_response_record( + report_config_response_record_h handle, unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_create_attr_report(attr_report_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + attr_report_h t = calloc(1, sizeof(struct attribute_report_s)); + RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = t; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_attr_report(attr_report_h handle) +{ + if (handle) { + if (handle->value) + free(handle->value); + free(handle); + } +} + +API int zb_get_id_from_attr_report(attr_report_h handle, unsigned short *id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); + *id = handle->id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_id_to_attr_report(attr_report_h handle, unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_type_from_attr_report(attr_report_h handle, unsigned char *type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); + *type = handle->type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_type_to_attr_report(attr_report_h handle, unsigned char type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->type = type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_value_from_attr_report(attr_report_h handle, zb_value_h value) +{ + int len = -1; + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_NO_DATA); + + len = zb_get_data_size(handle->type); + if (0 < len) { + memcpy(value->val, handle->value, len); + value->size = len; + value->type = handle->type; + } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { + if (value->str) { + if (value->str->v) + free(value->str->v); + free(value->str); + } + value->str = calloc(1, sizeof(struct attribute_str_s)); + RETV_IF(NULL == value->str, ZIGBEE_ERROR_OUT_OF_MEMORY); + value->str->n = *handle->value; + /* The first 1 byte indicate invalid or length of string */ + if (0xff == value->str->n) { + free(value->str); + return ZIGBEE_ERROR_NO_DATA; + } + value->str->v = calloc(value->str->n+1, 1); + if (NULL == value->str->v) { + free(value->str); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + memcpy(value->str->v, handle->value+sizeof(value->str->n), value->str->n); + + value->type = handle->type; + value->size = value->str->n; + } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) { + if (value->wstr) { + if (value->wstr->v) + free(value->wstr->v); + free(value->wstr); + } + value->wstr = calloc(1, sizeof(struct attribute_wstr_s)); + RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_OUT_OF_MEMORY); + value->wstr->n = *(handle->value+1) << 8 | *handle->value; + /* The first 2 byte indicate invalid or length of string */ + if (0xffff == value->wstr->n) { + free(value->wstr); + return ZIGBEE_ERROR_NO_DATA; + } + value->wstr->v = calloc(value->wstr->n+1, 1); + if (NULL == value->wstr->v) { + free(value->wstr); + return ZIGBEE_ERROR_OUT_OF_MEMORY; + } + memcpy(value->wstr->v, handle->value+sizeof(value->wstr->n), value->wstr->n); + + value->type = handle->type; + value->size = value->wstr->n; + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_value_to_attr_report(attr_report_h handle, zb_value_h value) +{ + int len = -1; + + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == value, ZIGBEE_ERROR_INVALID_PARAMETER); + + if (handle->value) + free(handle->value); + + len = zb_get_data_size(value->type); + if (0 < len) { + handle->value = calloc(value->size + 1 , sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + memcpy(handle->value, value->val, value->size); + handle->type = value->type; + } else if (ZB_ZCL_OCTAT_STRING == handle->type || ZB_ZCL_CHRACTER_STRING == handle->type) { + RETV_IF(NULL == value->str, ZIGBEE_ERROR_NO_DATA); + handle->value = calloc(value->str->n + sizeof(value->str->n), sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + /* The first 1 byte indicate invalid or length of string */ + handle->value[0] = value->str->n & 0xff; + memcpy(handle->value + sizeof(value->str->n), + value->str->v + sizeof(value->str->n), value->str->n); + } else if (ZB_ZCL_LONG_OCTAT_STRING == handle->type || ZB_ZCL_LONG_CHRACTER_STRING == handle->type) { + RETV_IF(NULL == value->wstr, ZIGBEE_ERROR_NO_DATA); + handle->value = calloc(value->wstr->n + sizeof(value->wstr->n), sizeof(char)); + RETV_IF(NULL == handle->value, ZIGBEE_ERROR_OUT_OF_MEMORY); + /* The first 2 byte indicate invalid or length of string */ + handle->value[0] = value->wstr->n & 0xff; + handle->value[1] = (value->wstr->n >> 8) & 0xff ; + memcpy(handle->value + sizeof(value->wstr->n), + value->wstr->v + sizeof(value->wstr->n), value->wstr->n); + } else + return ZIGBEE_ERROR_NOT_SUPPORTED; + + return ZIGBEE_ERROR_NONE; +} + + +/** + * @brief Format of the Selector Field + * + * @since_tizen 4.0 + */ +struct selector_s { + unsigned char indicator; /**< number of index */ + unsigned short *index; /**< index list */ +}; + +/** + * @brief Stcuture for reading attribute + * + * @since_tizen 4.0 + */ +struct read_structured_attribute_record_s { + unsigned short id; /**< attribute identifier */ + struct selector_s *selector; /**< selector format */ +}; + +/** + * @brief Format of the Write Attribute Record Field + * + * @since_tizen 4.0 + */ +struct write_attribute_structured_status_record_s { + unsigned char status; /**< status */ + unsigned short id; /**< identifier */ + struct selector_s selector; /**< selector */ +}; + +/** + * @brief Format of the Write Attribute Record Field + * + * @since_tizen 4.0 + */ +struct write_attribute_structured_record_s { + unsigned short id; /**< attribute identifier */ + struct selector_s selector; + unsigned char type; /**< attribute data type */ + unsigned char *value; /**< data value */; /**< attribute value */ +}; + +API int zb_create_extended_attr_info(extended_attr_info_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + extended_attr_info_h t = calloc(1, sizeof(struct extended_attribute_infomation_s)); + RETVM_IF(NULL == t, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = t; + return ZIGBEE_ERROR_NONE; +} + +API void zb_destroy_extended_attr_info(extended_attr_info_h handle) +{ + free(handle); +} + +API int zb_get_id_from_extended_attr_info(extended_attr_info_h handle, + unsigned short *id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, ZIGBEE_ERROR_INVALID_PARAMETER); + *id = handle->id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_id_to_extended_attr_info(extended_attr_info_h handle, + unsigned short id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->id = id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_type_from_extended_attr_info(extended_attr_info_h handle, + unsigned char *type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == type, ZIGBEE_ERROR_INVALID_PARAMETER); + *type = handle->type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_type_to_extended_attr_info(extended_attr_info_h handle, + unsigned char type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->type = type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_acl_from_extended_attr_info(extended_attr_info_h handle, + unsigned char *acl) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == acl, ZIGBEE_ERROR_INVALID_PARAMETER); + *acl = handle->acl; + return ZIGBEE_ERROR_NONE; +} + +API int zb_set_acl_to_extended_attr_info(extended_attr_info_h handle, + unsigned char acl) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->acl = acl; + return ZIGBEE_ERROR_NONE; +} + diff --git a/lib/zbl_zcl_alarm.c b/lib/zbl_zcl_alarm.c new file mode 100644 index 0000000..ac6c1a6 --- /dev/null +++ b/lib/zbl_zcl_alarm.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_alarm_reset_alarm(zigbee_h handle, nwk_addr addr16, unsigned char ep, + unsigned char alarm_code, unsigned short cluster_id) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_reset_alarm(addr16, ep, alarm_code, cluster_id); + return ret; +} + +API int zb_zcl_alarm_reset_all_alarm(zigbee_h handle, nwk_addr addr16, + unsigned char ep) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_reset_all_alarm(addr16, ep); + return ret; +} + +API int zb_zcl_alarm_get_alarm(zigbee_h handle, nwk_addr addr16, unsigned char ep, + zb_zcl_alarm_get_alarm_rsp cb, void *user_data) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_get_alarm(addr16, ep, cb, user_data); + return ret; +} + +API int zb_zcl_alarm_reset_all_alarm_log(zigbee_h handle, nwk_addr addr16, + unsigned char ep) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_reset_all_alarm_log(addr16, ep); + return ret; +} diff --git a/lib/zbl_zcl_basic.c b/lib/zbl_zcl_basic.c new file mode 100644 index 0000000..a56607e --- /dev/null +++ b/lib/zbl_zcl_basic.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_basic_reset_factory_default(zigbee_h handle, nwk_addr addr16, + unsigned char ep) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_reset_factory_default(addr16, ep); + return ret; +} diff --git a/lib/zbl_zcl_color_control.c b/lib/zbl_zcl_color_control.c new file mode 100644 index 0000000..027a748 --- /dev/null +++ b/lib/zbl_zcl_color_control.c @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_ccontrol_move_to_hue(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char hue, unsigned char direction, + unsigned short transition_time) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_move_to_hue(addr16, ep, hue, direction, transition_time); + return ret; +} + +API int zb_zcl_ccontrol_move_hue(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char move_mode, unsigned char rate) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_move_hue(addr16, ep, move_mode, rate); + return ret; +} + +API int zb_zcl_ccontrol_step_hue(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char step_mode, unsigned char step_size, + unsigned char transition_time) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_step_hue(addr16, ep, step_mode, step_size, transition_time); + return ret; +} + +API int zb_zcl_ccontrol_move_to_saturation(zigbee_h handle, + nwk_addr addr16, unsigned char ep, unsigned char saturation, + unsigned short transition_time) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_move_to_saturation(addr16, ep, saturation, transition_time); + return ret; +} + +API int zb_zcl_ccontrol_move_saturation(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char move_mode, unsigned char rate) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_move_saturation(addr16, ep, move_mode, rate); + return ret; +} + +API int zb_zcl_ccontrol_step_saturation(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char step_mode, unsigned char step_size, + unsigned char transition_time) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_step_saturation(addr16, ep, step_mode, step_size, transition_time); + return ret; +} + +API int zb_zcl_ccontrol_move_to_hue_and_saturation(zigbee_h handle, + nwk_addr addr16, unsigned char ep, unsigned char hue, unsigned char saturation, + unsigned short transition_time) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_move_to_hue_and_saturation(addr16, ep, hue, saturation, transition_time); + return ret; +} + +API int zb_zcl_ccontrol_move_to_color(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short color_x, unsigned short color_y, + unsigned short transition_time) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_move_to_color(addr16, ep, color_x, color_y, transition_time); + return ret; +} + +API int zb_zcl_ccontrol_move_color(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short rate_x, unsigned short rate_y) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_move_color(addr16, ep, rate_x, rate_y); + return ret; +} + +API int zb_zcl_ccontrol_step_color(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short step_x, unsigned short step_y, + unsigned short transition_time) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_step_color(addr16, ep, step_x, step_y, transition_time); + return ret; +} + +API int zb_zcl_ccontrol_move_to_color_temperature(zigbee_h handle, + nwk_addr addr16, unsigned char ep, unsigned short color_temperature, + unsigned short transition_time) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_ccontrol_move_to_color_temperature(addr16, ep, color_temperature, transition_time); + return ret; +} + diff --git a/lib/zbl_zcl_global_commands.c b/lib/zbl_zcl_global_commands.c new file mode 100644 index 0000000..bb9b103 --- /dev/null +++ b/lib/zbl_zcl_global_commands.c @@ -0,0 +1,221 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" +#include "zb-utils.h" + +API int zb_zcl_global_read_attr(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, unsigned short *attribute_ids, int attribute_ids_len, + zb_zcl_global_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == attribute_ids, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == attribute_ids_len, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_read_attr_req(handle, addr16, dst_ep, zcl_frame_ctl, cluster_id, attribute_ids, + attribute_ids_len, cb, user_data); + return ret; +} + +API int zb_zcl_global_write_attr(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, write_attr_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_write_attr_req(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, records, records_len, cb, user_data); + return ret; +} + +API int zb_zcl_global_write_attr_undivided(zigbee_h handle, + nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, write_attr_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_wattr_undivided_req(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, records, records_len, cb, user_data); + return ret; +} + +API int zb_zcl_global_write_attr_no_rsp(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, write_attr_record_h *records, int records_len) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_wattr_req_no_rsp(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, records, records_len); + return ret; +} + +API int zb_zcl_global_config_report(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, report_config_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_configure_reporting(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, records, records_len, cb, user_data); + return ret; +} + +API int zb_zcl_global_read_config_report(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, read_report_config_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_read_configure_reporting(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, records, records_len, cb, user_data); + return ret; +} + +API int zb_zcl_global_discover_attr(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, unsigned short start_id, unsigned char max_attribute_ids, + zb_zcl_global_discover_attr_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_discover_attr_req(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, start_id, max_attribute_ids, cb, user_data); + return ret; +} + +API int zb_zcl_global_read_attr_structured(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, read_structured_attr_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ +#if (0 == ZIGBEE_SUPPORT_ORDERED_SEQUENCE_DATA) + return ZIGBEE_ERROR_NOT_SUPPORTED; +#endif + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); + + return ZIGBEE_ERROR_NONE; +} + +API int zb_zcl_global_write_attr_structured(zigbee_h handle, nwk_addr addr16, + unsigned char src_ep, unsigned char dst_ep, unsigned char zcl_frame_ctl, + unsigned short cluster_id, write_attr_structured_record_h *records, int records_len, + zb_zcl_global_rsp cb, void *user_data) +{ +#if (0 == ZIGBEE_SUPPORT_ORDERED_SEQUENCE_DATA) + return ZIGBEE_ERROR_NOT_SUPPORTED; +#endif + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == records, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == records_len, ZIGBEE_ERROR_INVALID_PARAMETER); + + return ZIGBEE_ERROR_NONE; +} + +API int zb_zcl_global_discover_cmds_received(zigbee_h handle, + nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, + unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_discover_cmds_recv(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, start_command_id, max_command_ids, cb, user_data); + return ret; +} + +API int zb_zcl_global_discover_cmds_generated(zigbee_h handle, + nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned char start_command_id, + unsigned char max_command_ids, zb_zcl_global_discover_cmds_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_discover_cmds_gen(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, start_command_id, max_command_ids, cb, user_data); + return ret; +} + +API int zb_zcl_global_discover_attr_extended(zigbee_h handle, + nwk_addr addr16, unsigned char src_ep, unsigned char dst_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short start_id, + unsigned char max_attribute_ids, zb_zcl_global_discover_attr_extended_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_discover_attr_ext(handle, addr16, src_ep, dst_ep, zcl_frame_ctl, + cluster_id, start_id, max_attribute_ids, cb, user_data); + return ret; +} diff --git a/lib/zbl_zcl_groups.c b/lib/zbl_zcl_groups.c new file mode 100644 index 0000000..ae00aeb --- /dev/null +++ b/lib/zbl_zcl_groups.c @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_group_add_group(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short group_id, char *group_name, + zb_zcl_group_add_group_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == group_name, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_add_group(addr16, ep, group_id, group_name, cb, user_data); + return ret; +} + +API int zb_zcl_group_view_group(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short group_id, zb_zcl_group_view_group_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_view_group(addr16, ep, group_id, cb, user_data); + return ret; +} + +API int zb_zcl_group_get_group_membership(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char group_count, unsigned short *group_list, + zb_zcl_group_get_group_membership_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == group_list, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_group_get_group_membership(addr16, ep, group_count, group_list, cb, user_data); + return ret; +} + +API int zb_zcl_group_remove_group(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short group_id, zb_zcl_group_remove_group_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_remove_group(addr16, ep, group_id, cb, user_data); + return ret; +} + +API int zb_zcl_group_remove_all_group(zigbee_h handle, nwk_addr addr16, + unsigned char ep) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_remove_all_group(addr16, ep); + return ret; +} + +API int zb_zcl_group_add_group_if_identifying(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short group_id, const char *group_name) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_add_group_if_identifying(addr16, ep, group_id, group_name); + return ret; +} diff --git a/lib/zbl_zcl_identify.c b/lib/zbl_zcl_identify.c new file mode 100644 index 0000000..1246ba3 --- /dev/null +++ b/lib/zbl_zcl_identify.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_identify(zigbee_h handle, nwk_addr addr16, unsigned char ep, + unsigned short identify_time) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_identify(addr16, ep, identify_time); + return ret; +} + +API int zb_zcl_identify_query(zigbee_h handle, nwk_addr addr16, unsigned char ep, + zb_zcl_identify_query_cb cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_identify_query(addr16, ep, cb, user_data); + return ret; +} diff --git a/lib/zbl_zcl_isa_zone.c b/lib/zbl_zcl_isa_zone.c new file mode 100644 index 0000000..fcc8dc2 --- /dev/null +++ b/lib/zbl_zcl_isa_zone.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_zone_enroll_response(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char enroll_response_code, unsigned char zone_id) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_zone_enroll_response(addr16, ep, enroll_response_code, zone_id); + return ret; +} diff --git a/lib/zbl_zcl_level_control.c b/lib/zbl_zcl_level_control.c new file mode 100644 index 0000000..80e031c --- /dev/null +++ b/lib/zbl_zcl_level_control.c @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_levelctrl_move_to_level(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char level, unsigned short transition_time) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_level_control_move_to_level(addr16, ep, level, transition_time); + return ret; +} + +API int zb_zcl_levelctrl_move(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char move_mode, unsigned char rate) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_level_control_move(addr16, ep, move_mode, rate); + return ret; +} + +API int zb_zcl_levelctrl_step(zigbee_h handle, nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, unsigned short transition_time) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_level_control_step(addr16, ep, step_mode, step_size, transition_time); + return ret; +} + +API int zb_zcl_levelctrl_stop(zigbee_h handle, nwk_addr addr16, unsigned char ep) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_level_control_stop(addr16, ep); + return ret; +} + +API int zb_zcl_levelctrl_move_to_level_with_on_off(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char level, unsigned short transition_time) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_level_control_move_to_level_with_on_off(addr16, ep, level, transition_time); + return ret; +} + +API int zb_zcl_levelctrl_move_with_on_off(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char move_mode, unsigned char rate) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_level_control_move_with_on_off(addr16, ep, move_mode, rate); + return ret; +} + +API int zb_zcl_levelctrl_step_with_on_off(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char step_mode, unsigned char step_size, + unsigned short transition_time) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_level_control_step_with_on_off(addr16, ep, step_mode, step_size, transition_time); + return ret; +} + diff --git a/lib/zbl_zcl_on_off.c b/lib/zbl_zcl_on_off.c new file mode 100644 index 0000000..9c13857 --- /dev/null +++ b/lib/zbl_zcl_on_off.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_onoff_control(zigbee_h handle, nwk_addr addr16, unsigned char ep, + zb_zcl_onoff_e on_off_type) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_onoff_set(addr16, ep, on_off_type); + return ret; +} diff --git a/lib/zbl_zcl_poll_control.c b/lib/zbl_zcl_poll_control.c new file mode 100644 index 0000000..20afba6 --- /dev/null +++ b/lib/zbl_zcl_poll_control.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_pollctrl_check_in_response(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char start_fast_polling, + unsigned short fast_poll_timeout) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_pollcontrol_check_in_response(addr16, ep, start_fast_polling, + fast_poll_timeout); + return ret; +} + +API int zb_zcl_pollctrl_fast_poll_stop(zigbee_h handle, nwk_addr addr16, + unsigned char ep) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_pollcontrol_fast_poll_stop(addr16, ep); + return ret; +} + +API int zb_zcl_pollctrl_set_long_poll_interval(zigbee_h handle, + nwk_addr addr16, unsigned char ep, unsigned int new_long_poll_interval, + zb_zcl_pollctrl_check_in cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_pollcontrol_set_long_poll_interval(addr16, ep, new_long_poll_interval, + cb, user_data); + return ret; +} + +API int zb_zcl_pollctrl_set_short_poll_interval(zigbee_h handle, + nwk_addr addr16, unsigned char ep, unsigned int new_short_poll_interval, + zb_zcl_pollctrl_check_in cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_pollcontrol_set_short_poll_interval(addr16, ep, new_short_poll_interval, + cb, user_data); + return ret; +} diff --git a/lib/zbl_zcl_scenes.c b/lib/zbl_zcl_scenes.c new file mode 100644 index 0000000..c9c2d4f --- /dev/null +++ b/lib/zbl_zcl_scenes.c @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_scene_add_scene(zigbee_h handle, nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id, unsigned short transition_time, + const char *scene_name, unsigned short ext_field_len, + const char *extension_field_sets, zb_zcl_scene_add_scene_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == scene_name, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == extension_field_sets, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_add_scene(addr16, ep, group_id, scene_id, transition_time, scene_name, + ext_field_len, extension_field_sets, cb, user_data); + return ret; +} + +API int zb_zcl_scene_view_scene(zigbee_h handle, nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id, zb_zcl_scene_view_scene_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_view_scene(addr16, ep, group_id, scene_id, cb, user_data); + return ret; +} + +API int zb_zcl_scene_remove_scene(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short group_id, unsigned char scene_id, + zb_zcl_scene_remove_scene_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_remove_scene(addr16, ep, group_id, scene_id, cb, user_data); + return ret; +} + +API int zb_zcl_scene_remove_all_scene(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short group_id, zb_zcl_scene_remove_all_scene_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_remove_all_scene(addr16, ep, group_id, cb, user_data); + return ret; +} + +API int zb_zcl_scene_store_scene(zigbee_h handle, nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id, zb_zcl_scene_store_scene_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_store_scene(addr16, ep, group_id, scene_id, cb, user_data); + return ret; +} + +API int zb_zcl_scene_recall_scene(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short group_id, unsigned char scene_id) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_recall_scene(addr16, ep, group_id, scene_id); + return ret; +} + +API int zb_zcl_scene_get_scene_membership(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned short group_id, + zb_zcl_scene_get_scene_membership_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_get_scene_membership(addr16, ep, group_id, cb, user_data); + return ret; +} + diff --git a/lib/zbl_zcl_thermostat.c b/lib/zbl_zcl_thermostat.c new file mode 100644 index 0000000..e3c558c --- /dev/null +++ b/lib/zbl_zcl_thermostat.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zcl_thermostat_adjust_setpoint(zigbee_h handle, nwk_addr addr16, + unsigned char ep, unsigned char mode, unsigned char amount) +{ + int ret = ZIGBEE_ERROR_NONE; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(0x02 < mode, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + + ret = zbl_thermostat_adjust_setpoint(addr16, ep, mode, amount); + return ret; +} + diff --git a/lib/zbl_zdo.c b/lib/zbl_zdo.c new file mode 100644 index 0000000..e13eed1 --- /dev/null +++ b/lib/zbl_zdo.c @@ -0,0 +1,1072 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 +#include +#include +#include + +#include "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" +#include "zb-common.h" + +#define CASE_TO_STR(x) case x: return #x; + +API const char* zb_zdo_get_error_message(int id) +{ + switch(id) { + CASE_TO_STR(ZB_ZDP_SUCCESS) + CASE_TO_STR(ZB_ZDP_INV_REQUESTTYPE) + CASE_TO_STR(ZB_ZDP_DEVICE_NOT_FOUND) + CASE_TO_STR(ZB_ZDP_INVALID_EP) + CASE_TO_STR(ZB_ZDP_NOT_ACTIVE) + CASE_TO_STR(ZB_ZDP_NOT_SUPPORTED) + CASE_TO_STR(ZB_ZDP_TIMEOUT) + CASE_TO_STR(ZB_ZDP_NO_MATCH) + CASE_TO_STR(ZB_ZDP_NO_ENTRY) + CASE_TO_STR(ZB_ZDP_NO_DESCRIPTOR) + CASE_TO_STR(ZB_ZDP_INSUFFICIENT_SPACE) + CASE_TO_STR(ZB_ZDP_NOT_PERMITED) + CASE_TO_STR(ZB_ZDP_TABLE_FULL) + CASE_TO_STR(ZB_ZDP_NOT_AUTHORIZED) + CASE_TO_STR(ZB_ZDP_DEVICE_BINDING_TABLE_FULL) + default: + return "ZB_ZDP_UNKNOWN"; + } +} + +API const char* zb_get_profile_id_string(int profile_id) +{ + switch(profile_id) { + CASE_TO_STR(ZB_PROFILE_HOME_AUTOMATION) + default: + return "ZB_UNKNOWN_PROFILE"; + } +} + +API const char* zb_get_device_id_string(int device_id) +{ + switch (device_id) { + /* General devices */ + CASE_TO_STR(ZB_HA_ON_OFF_SWITCH) + CASE_TO_STR(ZB_HA_LEVEL_CONTROL_SWITCH) + CASE_TO_STR(ZB_HA_ON_OFF_OUTPUT) + CASE_TO_STR(ZB_HA_LEVEL_CONTROLLABLE_OUTPUT) + CASE_TO_STR(ZB_HA_SCENE_SELECOTOR) + CASE_TO_STR(ZB_HA_CONFIGURATION_TOOL) + CASE_TO_STR(ZB_HA_REMOTE_CONTROL) + CASE_TO_STR(ZB_HA_COMBINED_INTERFACE) + CASE_TO_STR(ZB_HA_RANGE_EXTENDER) + CASE_TO_STR(ZB_HA_MAINS_POWER_OUTLET) + CASE_TO_STR(ZB_HA_DOOR_LOCK) + CASE_TO_STR(ZB_HA_DOOR_LOCK_CONTROLLER) + CASE_TO_STR(ZB_HA_SIMPLE_SENSOR) + CASE_TO_STR(ZB_HA_CONSUMPTION_AWARENESS_DEVICE) + CASE_TO_STR(ZB_HA_HOME_GATEWAY) + CASE_TO_STR(ZB_HA_SMART_PLUG) + CASE_TO_STR(ZB_HA_WHITE_GOODS) + CASE_TO_STR(ZB_HA_METER_INTERFACE) + /* Lighting devices */ + CASE_TO_STR(ZB_HA_ON_OFF_LIGHT) + CASE_TO_STR(ZB_HA_DIMMABLE_LIGHT) + CASE_TO_STR(ZB_HA_COLOR_DIMMABLE_LIGHT) + CASE_TO_STR(ZB_HA_ON_OFF_LIGHT_SWITCH) + CASE_TO_STR(ZB_HA_DIMMER_SWITCH) + CASE_TO_STR(ZB_HA_COLOR_DIMMER_SWITCH) + CASE_TO_STR(ZB_HA_LIGHT_SENSOR) + CASE_TO_STR(ZB_HA_OCUPANCY_SENSOR) + /* Closures devices */ + CASE_TO_STR(ZB_HA_SHADE) + CASE_TO_STR(ZB_HA_SHADE_CONTROLLER) + CASE_TO_STR(ZB_HA_WINDOW_COVERING_DEVICE) + CASE_TO_STR(ZB_HA_WINDOW_COVERING_CONTROLLER) + /* HVAC devices */ + CASE_TO_STR(ZB_HA_HEATING_COOLLING_UNIT) + CASE_TO_STR(ZB_HA_THERMOSTAT) + CASE_TO_STR(ZB_HA_TEMPERATURE_SENSOR) + CASE_TO_STR(ZB_HA_PUMP) + CASE_TO_STR(ZB_HA_PUMP_CONTROLLER) + CASE_TO_STR(ZB_HA_PRESSURE_SENSOR) + CASE_TO_STR(ZB_HA_FLOW_SENSOR) + CASE_TO_STR(ZB_HA_MINI_SPLIT_AC) + /* Intruder Alarms system */ + CASE_TO_STR(ZB_HA_ISA_CONTROL_AND_INDICATING_EQUIPMENT) + CASE_TO_STR(ZB_HA_ISA_ANCILLARY_CONTROL_EQUIPMENT) + CASE_TO_STR(ZB_HA_ISA_ZONE) + default: + return "ZB_HA_UNKNOWN_DEVICE"; + } +} + +API int zb_simple_desc_create(zb_zdo_simple_desc_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + zb_zdo_simple_desc_h desc = calloc(1, sizeof(struct zb_zdo_simple_desc_s)); + RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = desc; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_copy(zb_zdo_simple_desc_h src, zb_zdo_simple_desc_h dst) +{ + RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(dst, src, sizeof(struct zb_zdo_simple_desc_s)); + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_destroy(zb_zdo_simple_desc_h handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + free(handle); + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_get_ep(zb_zdo_simple_desc_h handle, unsigned char *ep) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == ep, ZIGBEE_ERROR_INVALID_PARAMETER); + *ep = handle->ep; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_set_ep(zb_zdo_simple_desc_h handle, unsigned char ep) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->ep = ep; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_get_profile_id(zb_zdo_simple_desc_h handle, + unsigned short *profile_id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == profile_id, ZIGBEE_ERROR_INVALID_PARAMETER); + *profile_id = handle->profile_id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_set_profile_id(zb_zdo_simple_desc_h handle, + unsigned short profile_id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->profile_id = profile_id; + return ZIGBEE_ERROR_NONE; +} + + +API int zb_simple_desc_get_device_id(zb_zdo_simple_desc_h handle, + unsigned short *device_id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == device_id, ZIGBEE_ERROR_INVALID_PARAMETER); + *device_id = handle->device_id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_set_device_id(zb_zdo_simple_desc_h handle, + unsigned short device_id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->device_id = device_id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_get_device_ver(zb_zdo_simple_desc_h handle, + unsigned short *device_ver) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == device_ver, ZIGBEE_ERROR_INVALID_PARAMETER); + *device_ver = handle->device_ver; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_set_device_ver(zb_zdo_simple_desc_h handle, + unsigned short device_ver) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->device_ver = device_ver; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_get_num_of_in_clusters(zb_zdo_simple_desc_h handle, + unsigned char *num_of_in_clusters) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == num_of_in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + *num_of_in_clusters = handle->num_of_in_clusters; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_set_num_of_in_clusters(zb_zdo_simple_desc_h handle, + unsigned char num_of_in_clusters) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->num_of_in_clusters = num_of_in_clusters; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_get_num_of_out_clusters(zb_zdo_simple_desc_h handle, + unsigned char *num_of_out_clusters) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == num_of_out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + *num_of_out_clusters = handle->num_of_out_clusters; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_set_num_of_out_clusters(zb_zdo_simple_desc_h handle, + unsigned char num_of_out_clusters) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->num_of_out_clusters = num_of_out_clusters; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_get_in_clusters(zb_zdo_simple_desc_h handle, + unsigned short **in_clusters) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + *in_clusters = handle->in_clusters; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_set_in_clusters(zb_zdo_simple_desc_h handle, + unsigned short *in_clusters, int num) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(num < 1 || num > MAX_ENDPOINT_CLUSTERS, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(handle->in_clusters, in_clusters, 2 * num); + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_get_out_clusters(zb_zdo_simple_desc_h handle, + unsigned short **out_clusters) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + *out_clusters = handle->out_clusters; + return ZIGBEE_ERROR_NONE; +} + +API int zb_simple_desc_set_out_clusters(zb_zdo_simple_desc_h handle, + unsigned short *out_clusters, int num) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(num < 1 || num > MAX_ENDPOINT_CLUSTERS, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(handle->out_clusters, out_clusters, 2 * num); + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_all_device_list(zigbee_h handle, int *count, zb_end_device_info_h **list) +{ + int ret; + unsigned char cnt; + RETV_IF(NULL == count, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_get_all_device_info(list, &cnt); + *count = cnt; + return ret; +} + +API int zb_get_endpoint_list(zigbee_h handle, ieee_addr addr64, unsigned char *count, + unsigned char *ep_list) +{ + int ret; + unsigned char cnt = 0; + + RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == count, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == ep_list, ZIGBEE_ERROR_INVALID_PARAMETER); + + ret = zbl_get_endpoint_list(addr64, &cnt, ep_list); + *count = cnt; + return ret; +} + +API int zb_get_cluster_list(zigbee_h handle, ieee_addr addr64, unsigned char ep, + unsigned char *in_cluster_count, unsigned short *in_cluster_list, + unsigned char *out_cluster_count, unsigned short *out_cluster_list) +{ + int ret; + unsigned char in_cnt = 0; + unsigned char out_cnt = 0; + + RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == in_cluster_count, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == in_cluster_list, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == out_cluster_count, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == out_cluster_list, ZIGBEE_ERROR_INVALID_PARAMETER); + + ret = zbl_get_cluster_list(addr64, ep, &in_cnt, in_cluster_list, + &out_cnt, out_cluster_list); + *in_cluster_count = in_cnt; + *out_cluster_count = out_cnt; + + return ret; +} + +API int zb_devices_info_foreach_end_device(zb_end_device_info_h *list, + zb_end_device_cb cb, void *user_data) +{ + int index = 0; + GList *cur = NULL; + struct zb_end_device_info_s *real = NULL; + + RETV_IF(NULL == list, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + + cur = (GList *)list; + while (cur) { + GList *next = cur->next; + real = cur->data; + if (ZIGBEE_FUNC_STOP == cb(index, (zb_end_device_info_h)real->list, user_data)) + break; + index++; + cur = next; + } + + return ZIGBEE_ERROR_NONE; + +} + +API int zb_get_network_address(zb_end_device_info_h handle, nwk_addr *addr16) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); + *addr16 = handle->addr16; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_ieee_address(zb_end_device_info_h handle, ieee_addr addr64) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(addr64, handle->addr64, sizeof(ieee_addr)); + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_num_of_ep(zb_end_device_info_h handle, unsigned char *count) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == count, ZIGBEE_ERROR_INVALID_PARAMETER); + *count = handle->num_of_ep; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_ep_list(zb_end_device_info_h handle, unsigned char *ep_list) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == ep_list, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(ep_list, handle->ep, handle->num_of_ep); + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_mac_capabiity(zb_end_device_info_h handle, unsigned char *capability) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == capability, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == handle->capability, ZIGBEE_ERROR_NO_DATA); + *capability = handle->capability; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_alternative_pan_coordinator(zb_end_device_info_h handle, + unsigned char *can_do_it) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == can_do_it, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == handle->capability, ZIGBEE_ERROR_NO_DATA); + *can_do_it = handle->capability & ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR ? 1 : 0; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_device_id(zb_end_device_info_h handle, unsigned char ep, + unsigned short *device_id) +{ + int i; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == device_id, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->desc, ZIGBEE_ERROR_NO_DATA); + for (i = 0; i < handle->num_of_ep; i++) { + RETV_IF(NULL == handle->desc[i], ZIGBEE_ERROR_NO_DATA); + if (handle->desc[i]->ep == ep) { + *device_id = handle->desc[i]->device_id; + return ZIGBEE_ERROR_NONE; + } + } + return ZIGBEE_ERROR_NO_DATA; +} + +API int zb_get_profile_id(zb_end_device_info_h handle, unsigned char ep, + unsigned short *profile_id) +{ + int i; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == profile_id, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->desc, ZIGBEE_ERROR_NO_DATA); + for (i = 0; i < handle->num_of_ep; i++) { + RETV_IF(NULL == handle->desc[i], ZIGBEE_ERROR_NO_DATA); + if (handle->desc[i]->ep == ep) { + *profile_id = handle->desc[i]->profile_id; + return ZIGBEE_ERROR_NONE; + } + } + return ZIGBEE_ERROR_NO_DATA; +} + +API int zb_get_power_source(zb_end_device_info_h handle, unsigned char *power_src) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == power_src, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == handle->capability, ZIGBEE_ERROR_NO_DATA); + *power_src = handle->capability & ZB_ZDP_POWER_SOURCE ? 1 : 0; + return ZIGBEE_ERROR_NONE; +} + +API int zb_get_security_capabilty(zb_end_device_info_h handle, + unsigned char *sec_capability) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == sec_capability, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == handle->capability, ZIGBEE_ERROR_NO_DATA); + *sec_capability = handle->capability & ZB_ZDP_SECURITY_CAPABILITY ? 1 : 0; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_create(zb_zdo_node_power_descriptor_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + zb_zdo_node_power_descriptor_h desc = + calloc(1, sizeof(struct zb_zdo_node_power_descriptor_s)); + RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = desc; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_copy(zb_zdo_node_power_descriptor_h src, + zb_zdo_node_power_descriptor_h dst) +{ + RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(dst, src, sizeof(struct zb_zdo_node_power_descriptor_s)); + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_destroy(zb_zdo_node_power_descriptor_h handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + free(handle); + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_get_current_power_mode( + zb_zdo_node_power_descriptor_h handle, + unsigned char* current_power_mode) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == current_power_mode, ZIGBEE_ERROR_INVALID_PARAMETER); + *current_power_mode = handle->current_power_mode; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_set_current_power_mode( + zb_zdo_node_power_descriptor_h handle, unsigned char current_power_mode) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0b11 < current_power_mode, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->current_power_mode = current_power_mode; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_get_available_power_sources( + zb_zdo_node_power_descriptor_h handle, unsigned char* available_power_sources) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == available_power_sources, ZIGBEE_ERROR_INVALID_PARAMETER); + *available_power_sources = handle->available_power_sources; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_set_available_power_sources( + zb_zdo_node_power_descriptor_h handle, unsigned char available_power_sources) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0b111 < available_power_sources, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->available_power_sources = available_power_sources; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_get_current_power_source( + zb_zdo_node_power_descriptor_h handle, unsigned char* current_power_source) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == current_power_source, ZIGBEE_ERROR_INVALID_PARAMETER); + *current_power_source = handle->current_power_source; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_set_current_power_source( + zb_zdo_node_power_descriptor_h handle, unsigned char current_power_source) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0b111 < current_power_source, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->current_power_source = current_power_source; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_get_current_power_source_level( + zb_zdo_node_power_descriptor_h handle, unsigned char* current_power_source_level) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == current_power_source_level, ZIGBEE_ERROR_INVALID_PARAMETER); + *current_power_source_level = handle->current_power_source_level; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_power_desc_set_current_power_source_level( + zb_zdo_node_power_descriptor_h handle, unsigned char current_power_source_level) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->current_power_source_level = current_power_source_level; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_create(zb_zdo_node_descriptor_h *handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + zb_zdo_node_descriptor_h desc = calloc(1, sizeof(struct zb_zdo_node_descriptor_s)); + RETVM_IF(NULL == desc, ZIGBEE_ERROR_OUT_OF_MEMORY, "calloc() Fail(%d)", errno); + *handle = desc; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_copy(zb_zdo_node_descriptor_h src, + zb_zdo_node_descriptor_h dst) +{ + RETV_IF(NULL == src, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dst, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(dst, src, sizeof(struct zb_zdo_node_descriptor_s)); + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_destroy(zb_zdo_node_descriptor_h handle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + free(handle); + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_logical_type(zb_zdo_node_descriptor_h handle, + unsigned char* logical_type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == logical_type, ZIGBEE_ERROR_INVALID_PARAMETER); + *logical_type = handle->logical_type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_logical_type(zb_zdo_node_descriptor_h handle, + unsigned char logical_type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0b11 < logical_type, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->logical_type = logical_type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_complex_desciptor_available( + zb_zdo_node_descriptor_h handle, unsigned char* complex_desciptor_available) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == complex_desciptor_available, ZIGBEE_ERROR_INVALID_PARAMETER); + *complex_desciptor_available = handle->complex_desciptor_available; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_complex_descriptor_available( + zb_zdo_node_descriptor_h handle, unsigned char complex_desciptor_available) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0x01 < complex_desciptor_available, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->complex_desciptor_available = complex_desciptor_available; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_user_descriptor_available( + zb_zdo_node_descriptor_h handle, unsigned char* user_descriptor_available) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == user_descriptor_available, ZIGBEE_ERROR_INVALID_PARAMETER); + *user_descriptor_available = handle->user_descriptor_available; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_user_descriptor_available( + zb_zdo_node_descriptor_h handle, unsigned char user_descriptor_available) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0x01 < user_descriptor_available, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->user_descriptor_available = user_descriptor_available; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_aps_flags(zb_zdo_node_descriptor_h handle, + unsigned char* aps_flags) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == aps_flags, ZIGBEE_ERROR_INVALID_PARAMETER); + *aps_flags = handle->aps_flags; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_aps_flags(zb_zdo_node_descriptor_h handle, + unsigned char aps_flags) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0b111 < aps_flags, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->aps_flags = aps_flags; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_frequency_band(zb_zdo_node_descriptor_h handle, + unsigned char* frequency_band) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == frequency_band, ZIGBEE_ERROR_INVALID_PARAMETER); + *frequency_band = handle->frequency_band; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_frequency_band(zb_zdo_node_descriptor_h handle, + unsigned char frequency_band) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0b1111 < frequency_band, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->frequency_band = frequency_band; + return ZIGBEE_ERROR_NONE; +} + + +API int zb_node_desc_get_mac_capability_flags(zb_zdo_node_descriptor_h handle, + unsigned char* mac_capability_flags) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == mac_capability_flags, ZIGBEE_ERROR_INVALID_PARAMETER); + *mac_capability_flags = handle->mac_capability_flags; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_mac_capability_flags(zb_zdo_node_descriptor_h handle, + unsigned char mac_capability_flags) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->mac_capability_flags = mac_capability_flags; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_manufacturer_code(zb_zdo_node_descriptor_h handle, + unsigned short* manufacturer_code) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == manufacturer_code, ZIGBEE_ERROR_INVALID_PARAMETER); + *manufacturer_code = handle->manufacturer_code; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_manufacturer_code(zb_zdo_node_descriptor_h handle, + unsigned short manufacturer_code) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + handle->manufacturer_code = manufacturer_code; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_maximum_buffer_size(zb_zdo_node_descriptor_h handle, + unsigned char* maximum_buffer_size) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == maximum_buffer_size, ZIGBEE_ERROR_INVALID_PARAMETER); + *maximum_buffer_size = handle->maximum_buffer_size; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_maximum_buffer_size(zb_zdo_node_descriptor_h handle, + unsigned char maximum_buffer_size) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0x7f < maximum_buffer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->maximum_buffer_size = maximum_buffer_size; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_maximum_incoming_transfer_size( + zb_zdo_node_descriptor_h handle, unsigned short* maximum_incoming_transfer_size) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == maximum_incoming_transfer_size, ZIGBEE_ERROR_INVALID_PARAMETER); + *maximum_incoming_transfer_size = handle->maximum_incoming_transfer_size; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_maximum_incoming_transfer_size( + zb_zdo_node_descriptor_h handle, unsigned short maximum_incoming_transfer_size) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0x7fff < maximum_incoming_transfer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->maximum_incoming_transfer_size = maximum_incoming_transfer_size; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_server_mask(zb_zdo_node_descriptor_h handle, + unsigned short* server_mask) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == server_mask, ZIGBEE_ERROR_INVALID_PARAMETER); + *server_mask = handle->server_mask; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_server_mask(zb_zdo_node_descriptor_h handle, + unsigned short server_mask) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0x7f < server_mask, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->server_mask = server_mask; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_maximum_outgoing_transfer_size( + zb_zdo_node_descriptor_h handle, unsigned short* maximum_outgoing_transfer_size) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == maximum_outgoing_transfer_size, ZIGBEE_ERROR_INVALID_PARAMETER); + *maximum_outgoing_transfer_size = handle->maximum_outgoing_transfer_size; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_maximum_outgoing_transfer_size( + zb_zdo_node_descriptor_h handle, unsigned short maximum_outgoing_transfer_size) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0x7fff < maximum_outgoing_transfer_size, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->maximum_outgoing_transfer_size = maximum_outgoing_transfer_size; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_get_descriptor_capability_field( + zb_zdo_node_descriptor_h handle, unsigned short* descriptor_capability_field) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == descriptor_capability_field, ZIGBEE_ERROR_INVALID_PARAMETER); + *descriptor_capability_field = handle->descriptor_capability_field; + return ZIGBEE_ERROR_NONE; +} + +API int zb_node_desc_set_descriptor_capability_field( + zb_zdo_node_descriptor_h handle, unsigned short descriptor_capability_field) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0x11 < descriptor_capability_field, ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE); + handle->descriptor_capability_field = descriptor_capability_field; + return ZIGBEE_ERROR_NONE; +} + +API int zb_network_list_record_get_extended_pan_id( + zb_zdo_network_list_record_h handle, ieee_addr extended_pan_id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + extended_pan_id = handle->extended_pan_id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_network_list_record_get_logical_channel( + zb_zdo_network_list_record_h handle, unsigned char* logical_channel) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == logical_channel, ZIGBEE_ERROR_INVALID_PARAMETER); + *logical_channel = handle->logical_channel; + return ZIGBEE_ERROR_NONE; +} + +API int zb_network_list_record_get_zigbee_version( + zb_zdo_network_list_record_h handle, unsigned char* zigbee_version) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zigbee_version, ZIGBEE_ERROR_INVALID_PARAMETER); + *zigbee_version = handle->zigbee_version; + return ZIGBEE_ERROR_NONE; +} + +API int zb_network_list_record_get_stack_profile( + zb_zdo_network_list_record_h handle, unsigned char* stack_profile) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == stack_profile, ZIGBEE_ERROR_INVALID_PARAMETER); + *stack_profile = handle->stack_profile; + return ZIGBEE_ERROR_NONE; +} + +API int zb_network_list_record_get_beacon_order( + zb_zdo_network_list_record_h handle, unsigned char* beacon_order) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == beacon_order, ZIGBEE_ERROR_INVALID_PARAMETER); + *beacon_order = handle->beacon_order; + return ZIGBEE_ERROR_NONE; +} + +API int zb_network_list_record_get_superframe_order( + zb_zdo_network_list_record_h handle, unsigned char* superframe_order) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == superframe_order, ZIGBEE_ERROR_INVALID_PARAMETER); + *superframe_order = handle->superframe_order; + return ZIGBEE_ERROR_NONE; +} + +API int zb_network_list_record_get_permit_joining( + zb_zdo_network_list_record_h handle, unsigned char* permit_joining) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == permit_joining, ZIGBEE_ERROR_INVALID_PARAMETER); + *permit_joining = handle->permit_joining; + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_extended_pan_id( + zb_zdo_neighbor_table_desc_h handle, ieee_addr extended_pan_id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->extended_pan_id, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == extended_pan_id, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(extended_pan_id, handle->extended_pan_id, sizeof(ieee_addr)); + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_ieee_addr( + zb_zdo_neighbor_table_desc_h handle, ieee_addr addr64) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == handle->addr64, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(addr64, handle->addr64, sizeof(ieee_addr)); + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_nwk_addr( + zb_zdo_neighbor_table_desc_h handle, nwk_addr* addr16) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); + *addr16 = handle->addr16; + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_device_type( + zb_zdo_neighbor_table_desc_h handle, unsigned char* device_type) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == device_type, ZIGBEE_ERROR_INVALID_PARAMETER); + *device_type = handle->device_type; + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_rx_on_when_idle( + zb_zdo_neighbor_table_desc_h handle, unsigned char* rx_on_when_idle) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == rx_on_when_idle, ZIGBEE_ERROR_INVALID_PARAMETER); + *rx_on_when_idle = handle->rx_on_when_idle; + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_relationship( + zb_zdo_neighbor_table_desc_h handle, unsigned char* releationship) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == releationship, ZIGBEE_ERROR_INVALID_PARAMETER); + *releationship = handle->relationship; + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_permit_joining( + zb_zdo_neighbor_table_desc_h handle, unsigned char* permit_joining) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == permit_joining, ZIGBEE_ERROR_INVALID_PARAMETER); + *permit_joining = handle->permit_joining; + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_depth( + zb_zdo_neighbor_table_desc_h handle, unsigned char* depth) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == depth, ZIGBEE_ERROR_INVALID_PARAMETER); + *depth = handle->depth; + return ZIGBEE_ERROR_NONE; +} + +API int zb_neighbor_table_desc_get_lqi(zb_zdo_neighbor_table_desc_h handle, + unsigned char* lqi) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == lqi, ZIGBEE_ERROR_INVALID_PARAMETER); + *lqi = handle->lqi; + return ZIGBEE_ERROR_NONE; +} + +API int zb_routing_table_get_dst_addr(zb_zdo_routing_table_h handle, + nwk_addr* dst_addr) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dst_addr, ZIGBEE_ERROR_INVALID_PARAMETER); + *dst_addr = handle->dst_addr; + return ZIGBEE_ERROR_NONE; +} + +API int zb_routing_table_get_dst_status(zb_zdo_routing_table_h handle, + unsigned char *status) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == status, ZIGBEE_ERROR_INVALID_PARAMETER); + *status = handle->status; + return ZIGBEE_ERROR_NONE; +} + +API int zb_routing_table_get_memory_constrained( + zb_zdo_routing_table_h handle, unsigned char *memory_constrained) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == memory_constrained, ZIGBEE_ERROR_INVALID_PARAMETER); + *memory_constrained = handle->memory_constrained; + return ZIGBEE_ERROR_NONE; +} + +API int zb_routing_table_get_many_to_one(zb_zdo_routing_table_h handle, + unsigned char *many_to_one) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == many_to_one, ZIGBEE_ERROR_INVALID_PARAMETER); + *many_to_one = handle->many_to_one; + return ZIGBEE_ERROR_NONE; +} + +API int zb_routing_table_get_route_record_required( + zb_zdo_routing_table_h handle, unsigned char *route_record_required) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == route_record_required, ZIGBEE_ERROR_INVALID_PARAMETER); + *route_record_required = handle->route_record_required; + return ZIGBEE_ERROR_NONE; +} + +API int zb_routing_table_get_next_hop_addr( + zb_zdo_routing_table_h handle, nwk_addr *next_hop_addr) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == next_hop_addr, ZIGBEE_ERROR_INVALID_PARAMETER); + *next_hop_addr = handle->next_hop_addr; + return ZIGBEE_ERROR_NONE; +} + +API int zb_binding_table_get_src_addr(zb_zdo_binding_table_h handle, + ieee_addr src_addr) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(src_addr, handle->src_addr64, sizeof(ieee_addr)); + return ZIGBEE_ERROR_NONE; +} + +API int zb_binding_table_get_src_ep(zb_zdo_binding_table_h handle, + unsigned char* src_ep) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == src_ep, ZIGBEE_ERROR_INVALID_PARAMETER); + *src_ep = handle->src_ep; + return ZIGBEE_ERROR_NONE; +} + +API int zb_binding_table_get_cluster_id(zb_zdo_binding_table_h handle, + unsigned short *cluster_id) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == cluster_id, ZIGBEE_ERROR_INVALID_PARAMETER); + *cluster_id = handle->cluster_id; + return ZIGBEE_ERROR_NONE; +} + +API int zb_binding_table_get_dst_addr_mode(zb_zdo_binding_table_h handle, + unsigned char* dst_addr_mode) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dst_addr_mode, ZIGBEE_ERROR_INVALID_PARAMETER); + *dst_addr_mode = handle->dst_addr_mode; + return ZIGBEE_ERROR_NONE; +} + +API int zb_binding_table_get_dst_addr16(zb_zdo_binding_table_h handle, + nwk_addr* addr16) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); + *addr16 = handle->dst_addr16; + return ZIGBEE_ERROR_NONE; +} + +API int zb_binding_table_get_dst_addr64(zb_zdo_binding_table_h handle, + ieee_addr addr64) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); + memcpy(addr64, handle->dst_addr64, sizeof(ieee_addr)); + return ZIGBEE_ERROR_NONE; +} + +API int zb_binding_table_get_dst_ep(zb_zdo_binding_table_h handle, + unsigned char* dst_ep) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == dst_ep, ZIGBEE_ERROR_INVALID_PARAMETER); + *dst_ep = handle->dst_ep; + return ZIGBEE_ERROR_NONE; +} + +API int zb_discovery_cache_get_ieee_addr(zb_zdo_discovery_cache_h handle, + ieee_addr addr64) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + addr64 = handle->addr64; + return ZIGBEE_ERROR_NONE; +} + +API int zb_discovery_cache_get_nwk_addr(zb_zdo_discovery_cache_h handle, + nwk_addr* addr16) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == addr16, ZIGBEE_ERROR_INVALID_PARAMETER); + *addr16 = handle->addr16; + return ZIGBEE_ERROR_NONE; +} diff --git a/lib/zbl_zdo_bind_mgr.c b/lib/zbl_zdo_bind_mgr.c new file mode 100644 index 0000000..22e9363 --- /dev/null +++ b/lib/zbl_zdo_bind_mgr.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +#include "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zdo_bind_req(zigbee_h handle, nwk_addr dst_addr16, + ieee_addr src_addr64, unsigned char src_ep, unsigned short cluster_id, + ieee_addr dst_addr64, unsigned char type, nwk_addr group_addr, + unsigned char dst_ep, zb_zdo_bind_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_bind_req(dst_addr16, src_addr64, src_ep, cluster_id, dst_addr64, type, + group_addr, dst_ep, cb, user_data); + return ret; +} + +API int zb_zdo_unbind_req(zigbee_h handle, nwk_addr dst_addr16, + ieee_addr src_addr64, unsigned char src_ep, unsigned short cluster_id, + ieee_addr dst_addr64, unsigned char type, nwk_addr group_addr, + unsigned char dst_ep, zb_zdo_unbind_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == src_ep || 0 == dst_ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + ret = zbl_unbind_req(dst_addr16, src_addr64, src_ep, cluster_id, dst_addr64, type, + group_addr, dst_ep, cb, user_data); + return ret; +} diff --git a/lib/zbl_zdo_dev_disc.c b/lib/zbl_zdo_dev_disc.c new file mode 100644 index 0000000..f7f8c18 --- /dev/null +++ b/lib/zbl_zdo_dev_disc.c @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +#include "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zdo_nwk_addr_req(zigbee_h handle, ieee_addr addr64, + unsigned char request_type, unsigned char start_idx, zb_zdo_addr_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == addr64, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 != request_type && 1 != request_type, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_nwk_addr_req(handle, addr64, request_type, start_idx, cb, + user_data); + return ret; +} + +API int zb_zdo_ieee_addr_req(zigbee_h handle, nwk_addr addr16, zb_zdo_addr_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_ieee_addr_req(handle, addr16, cb, user_data); + return ret; +} + +API int zb_zdo_active_ep(zigbee_h handle, nwk_addr addr16, zb_zdo_active_ep_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_active_ep(handle, addr16, cb, user_data); + return ret; +} + +API int zb_zdo_simple_desc_req(zigbee_h handle, nwk_addr addr16, unsigned char ep, + zb_zdo_simple_desc_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == ep, ZIGBEE_ERROR_INVALID_ENDPOINT); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_simple_desc_req(handle, addr16, ep, cb, user_data); + return ret; +} + +#ifdef ZB_SUPPORT_PRIORITY_5 +API int zb_zdo_extended_simple_desc_req(zigbee_h handle, nwk_addr addr16, + unsigned char start_idx, zb_zdo_extended_simple_desc_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + return ZIGBEE_ERROR_NONE; +} +#endif /* ZB_SUPPORT_PRIORITY_5 */ + +API int zb_zdo_match_desc_req(zigbee_h handle, nwk_addr addr16, + unsigned short profile_id, unsigned char num_in_clusters, + unsigned short *in_clusters, unsigned char num_out_clusters, + unsigned short *out_clusters, zb_zdo_match_desc_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == in_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(0 == num_in_clusters && 0 == num_out_clusters, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_match_desc_req(handle, addr16, profile_id, num_in_clusters, + in_clusters, num_out_clusters, out_clusters, cb, user_data); + return ret; +} + +API int zb_zdo_node_desc_req(zigbee_h handle, nwk_addr addr16, + zb_zdo_node_desc_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_node_desc_req(addr16, cb, user_data); + return ret; +} + +API int zb_zdo_power_desc_req(zigbee_h handle, nwk_addr addr16, + zb_zdo_power_desc_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_power_desc_req(addr16, cb, user_data); + return ret; +} + +API int zb_zdo_complex_desc_req(zigbee_h handle, nwk_addr addr16, + zb_zdo_complex_desc_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_complex_desc_req(addr16, cb, user_data); + return ret; +} + +API int zb_zdo_user_desc_req(zigbee_h handle, nwk_addr addr16, + zb_zdo_user_desc_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == cb, ZIGBEE_ERROR_INVALID_PARAMETER); + ret = zbl_user_desc_req(addr16, cb, user_data); + return ret; +} + +API int zb_zdo_user_desc_set(zigbee_h handle, nwk_addr addr16, unsigned char len, + unsigned char *user_desc, zb_zdo_user_desc_conf cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == user_desc, ZIGBEE_ERROR_INVALID_PARAMETER); + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_device_annce(zigbee_h handle, nwk_addr addr16, ieee_addr addr64, + unsigned char capability) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + ret = zbl_device_annce(handle, addr16, addr64, capability); + return ret; +} + diff --git a/lib/zbl_zdo_nwk_mgr.c b/lib/zbl_zdo_nwk_mgr.c new file mode 100644 index 0000000..8252b1f --- /dev/null +++ b/lib/zbl_zdo_nwk_mgr.c @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +#include "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +API int zb_zdo_mgmt_nwk_disc_req(zigbee_h handle, nwk_addr addr16, + unsigned int scan_channels, unsigned char scan_duration, unsigned char scan_count, + unsigned char start_idx, zb_zdo_mgmt_nwk_disc_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + ret = zbl_mgmt_nwk_disc_req(addr16, scan_channels, scan_duration, scan_count, + start_idx, cb, user_data); + return ret; +} + +API int zb_zdo_mgmt_lqi_req(zigbee_h handle, nwk_addr addr16, + unsigned char start_idx, zb_zdo_mgmt_lqi_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + ret = zbl_mgmt_lqi_req(addr16, start_idx, cb, user_data); + return ret; +} + +API int zb_zdo_mgmt_rtg_req(zigbee_h handle, nwk_addr addr16, + unsigned char start_idx, zb_zdo_mgmt_rtg_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + ret = zbl_mgmt_rtg_req(addr16, start_idx, cb, user_data); + return ret; +} + +API int zb_zdo_mgmt_bind_req(zigbee_h handle, nwk_addr addr16, + unsigned char start_idx, zb_zdo_mgmt_bind_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + ret = zbl_mgmt_bind_req(addr16, start_idx, cb, user_data); + return ret; +} + +API int zb_zdo_mgmt_leave_req(zigbee_h handle, ieee_addr addr64, + bool remove_children, bool rejoin, zb_zdo_mgmt_leave_rsp cb, + void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + ret = zbl_mgmt_leave_device(addr64, remove_children, rejoin, cb, user_data); + return ret; +} + +#ifdef ZB_SUPPORT_PRIORITY_5 +API int zb_zdo_mgmt_direct_join_req(zigbee_h handle, ieee_addr addr64, + unsigned char capability, zb_zdo_mgmt_direct_join_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + return ZIGBEE_ERROR_NONE; +} +#endif /* ZB_SUPPORT_PRIORITY_5 */ + +API int zb_zdo_mgmt_permit_joining_req(zigbee_h handle, nwk_addr addr16, + unsigned char duration, unsigned char tc_significance, + zb_zdo_mgmt_permit_joining_rsp cb, void *user_data) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + ret = zbl_mgmt_permit_joining_req(addr16, duration, tc_significance, cb, user_data); + return ret; +} + +#ifdef ZB_SUPPORT_PRIORITY_5 +API int zb_zdo_mgmt_cache_req(zigbee_h handle, nwk_addr addr16, + unsigned char start_idx, zb_zdo_mgmt_cache_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + return ZIGBEE_ERROR_NONE; +} +#endif /* ZB_SUPPORT_PRIORITY_5 */ + +API int zb_zdo_mgmt_nwk_update_req(zigbee_h handle, unsigned int scan_channels, + unsigned char scan_duration, unsigned char scan_count, unsigned char nwk_update_id, + nwk_addr nwk_manager_addr) +{ + int ret; + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == nwk_manager_addr, ZIGBEE_ERROR_INVALID_ADDRESS); + ret = zbl_mgmt_nwk_update_req(scan_channels, scan_duration, scan_count, nwk_update_id, + nwk_manager_addr); + return ret; +} + diff --git a/lib/zbl_zdo_svc_disc.c b/lib/zbl_zdo_svc_disc.c new file mode 100644 index 0000000..5d6f1d1 --- /dev/null +++ b/lib/zbl_zdo_svc_disc.c @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 + +#include "zbl.h" +#include "zb-log.h" +#include "zbl_dbus.h" + +#ifdef ZB_SUPPORT_PRIORITY_5 + +API int zb_zdo_system_server_discover_req(zigbee_h handle, + unsigned short server_mask, zb_zdo_system_server_discover_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_find_node_cache_req(zigbee_h handle, nwk_addr addr16, + ieee_addr addr64, zb_zdo_find_node_cache_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_discovery_cache_req(zigbee_h handle, nwk_addr addr16, + ieee_addr addr64, zb_zdo_discovery_cache_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_discovery_store_req(zigbee_h handle, nwk_addr addr16, + ieee_addr addr64, unsigned char node_desc_size, unsigned char power_desc_size, + unsigned char active_ep_size, unsigned char simple_desc_count, + unsigned char *simple_desc_list, zb_zdo_discovery_store_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == simple_desc_list, ZIGBEE_ERROR_INVALID_PARAMETER); + + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_node_desc_store_req(zigbee_h handle, nwk_addr addr16, + ieee_addr addr64, zb_zdo_node_descriptor_h nodedsc, zb_zdo_node_desc_store_rsp cb, + void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_power_desc_store_req(zigbee_h handle, nwk_addr addr16, + ieee_addr addr64, zb_zdo_node_power_descriptor_h powerdsc, + zb_zdo_power_desc_store_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_active_ep_store_req(zigbee_h handle, nwk_addr addr16, + ieee_addr addr64, unsigned char active_ep_count, unsigned char *ep_list, + zb_zdo_active_ep_store_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == ep_list, ZIGBEE_ERROR_INVALID_PARAMETER); + + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_simple_desc_store_req(zigbee_h handle, nwk_addr addr16, + ieee_addr addr64, zb_zdo_simple_desc_h simpledsc, zb_zdo_simple_desc_store_rsp cb, + void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + + return ZIGBEE_ERROR_NONE; +} + +API int zb_zdo_remove_node_cache_req(zigbee_h handle, nwk_addr addr16, + ieee_addr addr64, zb_zdo_remove_node_cache_rsp cb, void *user_data) +{ + RETV_IF(NULL == handle, ZIGBEE_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == zbl_dbus_get_object(), ZIGBEE_ERROR_IO_ERROR); + RETV_IF(0 == addr16 || 0 == addr64, ZIGBEE_ERROR_INVALID_ADDRESS); + + return ZIGBEE_ERROR_NONE; +} + +#endif /* ZB_SUPPORT_PRIORITY_5 */ + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 85ca9c1..3d8f69e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,21 +22,21 @@ SET(NEW_SOURCES main.c menu.c custom.c - zcl-cluster-alarm.c - zcl-cluster-basic.c - zcl-cluster-colorctrl.c - zcl-cluster-group.c - zcl-cluster-identity.c - zcl-cluster-ias-zone.c - zcl-cluster-levelctrl.c - zcl-cluster-onoff.c - zcl-cluster-pollctrl.c - zcl-cluster-scene.c - zcl-cluster-thermostat.c - zcl-global-cmd.c - zdo-binding.c - zdo-device.c - zdo-network.c + zcl_cluster_alarm.c + zcl_cluster_basic.c + zcl_cluster_colorctrl.c + zcl_cluster_group.c + zcl_cluster_identity.c + zcl_cluster_ias_zone.c + zcl_cluster_levelctrl.c + zcl_cluster_onoff.c + zcl_cluster_pollctrl.c + zcl_cluster_scene.c + zcl_cluster_thermostat.c + zcl_global_cmd.c + zdo_binding.c + zdo_device.c + zdo_network.c ) #aux_source_directory(. sources) diff --git a/test/test-zigbee.c b/test/test-zigbee.c deleted file mode 100644 index f0c3ab1..0000000 --- a/test/test-zigbee.c +++ /dev/null @@ -1,2365 +0,0 @@ -/* - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * - * 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 -#include -#include -#include - -#include -#include - -#include - -#define RESET_COLOR "\e[m" -#define MAKE_RED "\e[31m" -#define MAKE_GREEN "\e[32m" - -#define __FUNC_ENTER__ printf("%s() entering...\n", __func__) -#define __FUNC_EXIT__ printf("%s() leaving...\n", __func__) - -#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] -#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" - -zigbee_h handle; - -nwk_addr panid = 0x615F; -ieee_addr co_addr64 = { 0xD0, 0x52, 0xA8, 0xA9, 0x8F, 0xB7, 0x00, 0x01 }; - -nwk_addr st_addr16 = 0x708B; -/* ST Motion Sensor */ -/*ieee_addr st_addr64 = {0x00, 0x0D, 0x6F, 0x00, 0x0B ,0x19, 0x58, 0xF8};*/ -/* ST New Open/Close Sensor */ -/*ieee_addr st_addr64 ={0x24, 0xFD, 0x5B, 0x00, 0x01, 0x01, 0x86, 0xB6 };*/ -/* ST Old Open/Close Sensor */ -ieee_addr st_addr64 = { 0x00, 0x0D, 0x6F, 0x00, 0x04, 0x2B, 0xBE, 0x14 }; - -nwk_addr sj_addr16 = 0x4756; -ieee_addr sj_addr64 = { 0x24, 0xFD, 0x5B, 0x00, 0x01, 0x01, 0x86, 0xB6 }; - -nwk_addr simul_addr16 = 0x1D1A; -ieee_addr simul_addr64 = { 0x00, 0x12, 0x4B, 0x00, 0x02, 0xF2, 0x58, 0x5B }; -/*ieee_addr sj_addr64 = { 0x24, 0xFD, 0x5B, 0x00, 0x01, 0x01, 0x86, 0xAF };*/ - -typedef struct simple_desc { - unsigned char ep; /**< Endpoint ID */ - unsigned short profile_id; /**< Profile ID */ - unsigned short device_id; /**< Device ID */ - unsigned char device_ver; /**< Device Version */ - unsigned char num_of_in_clusters; /**< Number of In-Cluster */ - unsigned char num_of_out_clusters; /**< Number of Out-Cluster */ - unsigned short in_clusters[32]; /**< In-Cluster list */ - unsigned short out_clusters[32]; /**< Out-Cluster list */ -} simple_desc_s; - -simple_desc_s st_ep1, st_ep2, st_ep3, st_ep4, sj_ep1, simul_ep1; - -#if 0 -static const char *test_zigbee_convert_error_to_string(int err_type) -{ - switch (err_type) { - case ZIGBEE_ERROR_NONE: - return "NONE"; - case ZIGBEE_ERROR_INVALID_PARAMETER: - return "INVALID_PARAMETER"; - case ZIGBEE_ERROR_IO_ERROR: - return "DBUS_ERROR"; - case ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE: - return "PARAMETER OUT OF RANGE"; - case ZIGBEE_ERROR_INVALID_ENDPOINT: - return "INVALIED_ENDPOINT"; - case ZIGBEE_ERROR_INVALID_ADDRESS: - return "INVALID_ADDRESS"; - case ZIGBEE_ERROR_OUT_OF_MEMORY: - return "OUT_OF_MEMORY"; - } - return "UNKNOWN"; -} -#endif -/* test command */ -enum { - CMD_QUIT, - CMD_INITIALIZE, - CMD_ENABLE, - CMD_GET_NETWORK_INFO, - CMD_GET_COORDINATOR_MAC_ADDR, - CMD_GET_END_DEVICE_LIST, - CMD_DISABLE, - CMD_RESET, - CMD_COEX_START, - CMD_COEX_STOP, - CMD_FORM_NETWORK, - CMD_DISABLE_NETWORK, - CMD_LEAVE_NODE, - CMD_PERMIT_JOIN, - CMD_NWK_ADDR_REQ, - CMD_IEEE_ADDR_REQ, - CMD_ACTIVE_EP_REQ, - CMD_SIMPLE_DESC_REQ, - CMD_EXTENDED_SIMPLE_DESC_REQ, - CMD_MATCHED_DESC_REQ, - CMD_NODE_DESC_REQ, - CMD_POWER_DESC_REQ, - CMD_COMPLEX_DESC_REQ, - CMD_USER_DESC_REQ, - CMD_USER_DESC_SET_REQ, - CMD_DEVICE_ANNCE, - CMD_BIND_REQ, - CMD_UNBIND_REQ, - CMD_MGMT_NWK_DISC_REQ, - CMD_MGMT_NWK_UPDATE_REQ, - CMD_MGMT_LQI_REQ, - CMD_MGMT_RTG_REQ, - CMD_MGMT_BIND_REQ, - CMD_MGMT_LEAVE_REQ, - CMD_MGMT_PERMIT_JOINING_REQ, - CMD_READ_ATTRIBUTES_REQ, - CMD_WRITE_ATTRIBUTES_REQ, - CMD_WRITE_ATTRIBUTES_UNDEVIDEDED_REQ, - CMD_WRITE_ATTRIBUTES_NO_RSP_REQ, - CMD_CONFIGURE_REPORTING_REQ, - CMD_READ_CONFIGURE_REPORTING, - CMD_DISCOVER_ATTRIBUTES, - CMD_READ_ATTRIBUTES_STRUCTURED, - CMD_WRITE_ATTRIBUTES_STRUCTURED, - CMD_DISCOVER_COMMANDS_RECEIVED, - CMD_DISCOVER_COMMANDS_GENERATED, - CMD_DISCOVER_ATTRIBUTES_EXTENDED, - CMD_ALARM_RESET_ALARM, - CMD_ALARM_RESET_ALL_ALARM, - CMD_ALARM_GET_ALARM, - CMD_ALARM_RESET_ALL_ALARM_LOG, - CMD_IDENTITY, - CMD_IDENTITY_QUERY, - CMD_ADD_GROUP, - CMD_VIEW_GROUP, - CMD_GET_GROUP_MEMBERSHIP, - CMD_REMOVE_GROUP, - CMD_REMOVE_ALL_GROUP, - CMD_ADD_GROUP_IF_IDENTIFY, - CMD_ADD_SCENE, - CMD_VIEW_SCENE, - CMD_GET_SCENE_MEMBERSHIP, - CMD_REMOVE_SCENE, - CMD_REMOVE_ALL_SCENE, - CMD_STORE_SCENE, - CMD_RECALL_SCENE, - CMD_ON_OFF_CLUSTER_ON, - CMD_ON_OFF_CLUSTER_OFF, - CMD_ON_OFF_CLUSTER_TOGGLE, - CMD_POLLCONTROL_CHECKIN_RESPONSE, - CMD_POLLCONTROL_FAST_POLL_STOP, - CMD_POLLCONTROL_SET_LONG_POLL_INTERVAL, - CMD_POLLCONTROL_SET_SHORT_POLL_INTERVAL, - /*CMD_SIMPLE_DESCRIPTION_GET_SET,*/ - CMD_LEVELCONTROL_MOVE_TO_LEVEL, - CMD_LEVELCONTROL_MOVE, - CMD_LEVELCONTROL_STEP, - CMD_LEVELCONTROL_STOP, - CMD_LEVELCONTROL_MOVE_WITH_ONOFF, - CMD_LEVELCONTROL_MOVE_TO_LEVEL_WITH_ONOFF, - CMD_LEVELCONTROL_STEP_WITH_ONOFF, - CMD_THERMOSTAT_ADJUST_SETPOINT, - CMD_COLORCONTROL_MOVE_TO_HUE, - CMD_COLORCONTROL_MOVE_HUE, - CMD_COLORCONTROL_STEP_HUE, - CMD_COLORCONTROL_MOVE_TO_SATURATION, - CMD_COLORCONTROL_MOVE_SATURATION, - CMD_COLORCONTROL_STEP_SATURATION, - CMD_COLORCONTROL_MOVE_TO_HUE_AND_SATURATION, - CMD_COLORCONTROL_MOVE_TO_COLOR, - CMD_COLORCONTROL_MOVE_COLOR, - CMD_COLORCONTROL_STEP_COLOR, - CMD_COLORCONTROL_MOVE_COLOR_TEMPERATURE, - CMD_FULL_MENU, - CMD_INVALID = 255, -}; - -typedef struct { - int cmd; - char *menu_str; -} menu_str_t; - -menu_str_t g_menu_str[] = { - {CMD_QUIT, "CMD_QUIT"}, - {CMD_INITIALIZE, "CMD_INITIALIZE"}, - {CMD_ENABLE, "CMD_ENABLE"}, - {CMD_GET_NETWORK_INFO, "CMD_GET_NETWORK_INFO"}, - {CMD_GET_COORDINATOR_MAC_ADDR, "CMD_GET_COORDINATOR_MAC_ADDR"}, - {CMD_GET_END_DEVICE_LIST, "CMD_GET_END_DEVICE_LIST"}, - {CMD_DISABLE, "CMD_DISABLE"}, - {CMD_RESET, "CMD_RESET"}, - {CMD_COEX_START, "CMD_COEX_START"}, - {CMD_COEX_STOP, "CMD_COEX_STOP"}, - {CMD_FORM_NETWORK, "CMD_FORM_NETWORK"}, - {CMD_DISABLE_NETWORK, "CMD_DISABLE_NETWORK"}, - {CMD_LEAVE_NODE, "CMD_LEAVE_NODE"}, - {CMD_PERMIT_JOIN, "CMD_PERMIT_JOIN"}, - {CMD_NWK_ADDR_REQ, "CMD_NWK_ADDR_REQ"}, - {CMD_IEEE_ADDR_REQ, "CMD_IEEE_ADDR_REQ"}, - {CMD_ACTIVE_EP_REQ, "CMD_ACTIVE_EP_REQ"}, - {CMD_SIMPLE_DESC_REQ, "CMD_SIMPLE_DESC_REQ"}, - {CMD_EXTENDED_SIMPLE_DESC_REQ, "CMD_EXTENDED_SIMPLE_DESC_REQ"}, - {CMD_MATCHED_DESC_REQ, "CMD_MATCHED_DESC_REQ"}, - {CMD_NODE_DESC_REQ, "CMD_NODE_DESC_REQ"}, - {CMD_POWER_DESC_REQ, "CMD_POWER_DESC_REQ"}, - {CMD_COMPLEX_DESC_REQ, "CMD_COMPLEX_DESC_REQ"}, - {CMD_USER_DESC_REQ, "CMD_USER_DESC_REQ"}, - {CMD_USER_DESC_SET_REQ, "CMD_USER_DESC_SET_REQ"}, - {CMD_DEVICE_ANNCE, "CMD_DEVICE_ANNCE"}, - {CMD_BIND_REQ, "CMD_BIND_REQ"}, - {CMD_UNBIND_REQ, "CMD_UNBIND_REQ"}, - {CMD_MGMT_NWK_DISC_REQ, "CMD_MGMT_NWK_DISC_REQ"}, - {CMD_MGMT_NWK_UPDATE_REQ, "CMD_MGMT_NWK_UPDATE_REQ"}, - {CMD_MGMT_LQI_REQ, "CMD_MGMT_LQI_REQ"}, - {CMD_MGMT_RTG_REQ, "CMD_MGMT_RTG_REQ"}, - {CMD_MGMT_BIND_REQ, "CMD_MGMT_BIND_REQ"}, - {CMD_MGMT_LEAVE_REQ, "CMD_MGMT_LEAVE_REQ"}, - {CMD_MGMT_PERMIT_JOINING_REQ, "CMD_MGMT_PERMIT_JOINING_REQ"}, - {CMD_READ_ATTRIBUTES_REQ, "CMD_READ_ATTRIBUTES_REQ"}, - {CMD_WRITE_ATTRIBUTES_REQ, "CMD_WRITE_ATTRIBUTES_REQ"}, - {CMD_WRITE_ATTRIBUTES_UNDEVIDEDED_REQ, "CMD_WRITE_ATTRIBUTES_UNDEVIDEDED_REQ"}, - {CMD_WRITE_ATTRIBUTES_NO_RSP_REQ, "CMD_WRITE_ATTRIBUTES_NO_RSP_REQ"}, - {CMD_CONFIGURE_REPORTING_REQ, "CMD_CONFIGURE_REPORTING_REQ"}, - {CMD_READ_CONFIGURE_REPORTING, "CMD_READ_CONFIGURE_REPORTING"}, - {CMD_DISCOVER_ATTRIBUTES, "CMD_DISCOVER_ATTRIBUTES"}, - {CMD_READ_ATTRIBUTES_STRUCTURED, "CMD_READ_ATTRIBUTES_STRUCTURED"}, - {CMD_WRITE_ATTRIBUTES_STRUCTURED, "CMD_WRITE_ATTRIBUTES_STRUCTURED"}, - {CMD_DISCOVER_COMMANDS_RECEIVED, "CMD_DISCOVER_COMMANDS_RECEIVED"}, - {CMD_DISCOVER_COMMANDS_GENERATED, "CMD_DISCOVER_COMMANDS_GENERATED"}, - {CMD_DISCOVER_ATTRIBUTES_EXTENDED, "CMD_DISCOVER_ATTRIBUTES_EXTENDED"}, - {CMD_ALARM_RESET_ALARM, "CMD_ALARM_RESET_ALARM"}, - {CMD_ALARM_RESET_ALL_ALARM, "CMD_ALARM_RESET_ALL_ALARM"}, - {CMD_ALARM_GET_ALARM, "CMD_ALARM_GET_ALARM"}, - {CMD_ALARM_RESET_ALL_ALARM_LOG, "CMD_ALARM_RESET_ALL_ALARM_LOG"}, - {CMD_IDENTITY, "CMD_IDENTITY"}, - {CMD_IDENTITY_QUERY, "CMD_IDENTITY_QUERY"}, - {CMD_ADD_GROUP, "CMD_ADD_GROUP"}, - {CMD_VIEW_GROUP, "CMD_VIEW_GROUP"}, - {CMD_GET_GROUP_MEMBERSHIP, "CMD_GET_GROUP_MEMBERSHIP"}, - {CMD_REMOVE_GROUP, "CMD_REMOVE_GROUP"}, - {CMD_REMOVE_ALL_GROUP, "CMD_REMOVE_ALL_GROUP"}, - {CMD_ADD_GROUP_IF_IDENTIFY, "CMD_ADD_GROUP_IF_IDENTIFY"}, - {CMD_ADD_SCENE, "CMD_ADD_SCENE"}, - {CMD_VIEW_SCENE, "CMD_VIEW_SCENE"}, - {CMD_GET_SCENE_MEMBERSHIP, "CMD_GET_SCENE_MEMBERSHIP"}, - {CMD_REMOVE_SCENE, "CMD_REMOVE_SCENE"}, - {CMD_REMOVE_ALL_SCENE, "CMD_REMOVE_ALL_SCENE"}, - {CMD_STORE_SCENE, "CMD_STORE_SCENE"}, - {CMD_RECALL_SCENE, "CMD_RECALL_SCENE"}, - {CMD_ON_OFF_CLUSTER_ON, "CMD_ON_OFF_CLUSTER_ON"}, - {CMD_ON_OFF_CLUSTER_OFF, "CMD_ON_OFF_CLUSTER_OFF"}, - {CMD_ON_OFF_CLUSTER_TOGGLE, "CMD_ON_OFF_CLUSTER_TOGGLE"}, - {CMD_POLLCONTROL_CHECKIN_RESPONSE, "CMD_POLLCONTROL_CHECKIN_RESPONSE"}, - {CMD_POLLCONTROL_FAST_POLL_STOP, "CMD_POLLCONTROL_FAST_POLL_STOP"}, - {CMD_POLLCONTROL_SET_LONG_POLL_INTERVAL, "CMD_POLLCONTROL_SET_LONG_POLL_INTERVAL"}, - {CMD_POLLCONTROL_SET_SHORT_POLL_INTERVAL, "CMD_POLLCONTROL_SET_SHORT_POLL_INTERVAL"}, - /*{ CMD_SIMPLE_DESCRIPTION_GET_SET, "CMD_SIMPLE_DESCRIPTION_GET_SET" },*/ - {CMD_LEVELCONTROL_MOVE_TO_LEVEL, "CMD_LEVELCONTROL_MOVE_TO_LEVEL"}, - {CMD_LEVELCONTROL_MOVE, "CMD_LEVELCONTROL_MOVE"}, - {CMD_LEVELCONTROL_STEP, "CMD_LEVELCONTROL_STEP"}, - {CMD_LEVELCONTROL_STOP, "CMD_LEVELCONTROL_STOP"}, - {CMD_LEVELCONTROL_MOVE_WITH_ONOFF, "CMD_LEVELCONTROL_MOVE_WITH_ONOFF"}, - {CMD_LEVELCONTROL_MOVE_TO_LEVEL_WITH_ONOFF, "CMD_LEVELCONTROL_MOVE_TO_LEVEL_WITH_ONOFF"}, - {CMD_LEVELCONTROL_STEP_WITH_ONOFF, "CMD_LEVELCONTROL_STEP_WITH_ONOFF"}, - {CMD_THERMOSTAT_ADJUST_SETPOINT, "CMD_THERMOSTAT_ADJUST_SETPOINT"}, - {CMD_COLORCONTROL_MOVE_TO_HUE, "CMD_COLORCONTROL_MOVE_TO_HUE"}, - {CMD_COLORCONTROL_MOVE_HUE, "CMD_COLORCONTROL_MOVE_HUE"}, - {CMD_COLORCONTROL_STEP_HUE, "CMD_COLORCONTROL_STEP_HUE"}, - {CMD_COLORCONTROL_MOVE_TO_SATURATION, "CMD_COLORCONTROL_MOVE_TO_SATURATION"}, - {CMD_COLORCONTROL_MOVE_SATURATION, "CMD_COLORCONTROL_MOVE_SATURATION"}, - {CMD_COLORCONTROL_STEP_SATURATION, "CMD_COLORCONTROL_STEP_SATURATION"}, - {CMD_COLORCONTROL_MOVE_TO_HUE_AND_SATURATION, "CMD_COLORCONTROL_MOVE_TO_HUE_AND_SATURATION"}, - {CMD_COLORCONTROL_MOVE_TO_COLOR, "CMD_COLORCONTROL_MOVE_TO_COLOR"}, - {CMD_COLORCONTROL_MOVE_COLOR, "CMD_COLORCONTROL_MOVE_COLOR"}, - {CMD_COLORCONTROL_STEP_COLOR, "CMD_COLORCONTROL_STEP_COLOR"}, - {CMD_COLORCONTROL_MOVE_COLOR_TEMPERATURE, "CMD_COLORCONTROL_MOVE_COLOR_TEMPERATURE"}, - {CMD_FULL_MENU, "CMD_FULL_MENU"}, - {-1, NULL}, -}; - -struct appdata { - GMainLoop *main_loop; - int peer_count; -}; - -struct appdata *g_test_appdata; - -struct appdata *get_appdata() -{ - return g_test_appdata; -} - -void set_appdata(struct appdata *p) -{ - g_test_appdata = p; -} - -static inline void prt_help(const char *cmd) -{ - printf("%s -t [dest ID]\n", cmd); - printf(" -u [my ID]\n"); - printf(" -p [passwd]\n"); - printf(" -a [alias]\n"); -} - -#if 0 -static int get_param(int argc, char **argv, struct appdata *ad) -{ - printf("Parsing argument...\n"); - int opt; - while ((opt = getopt(argc, argv, "t:u:p:a:")) != -1) { - printf("Parsing argument...:%c\n", opt); - switch (opt) { - case 't': - default: - prt_help(argv[0]); - return -1; - } - } - - printf("Argument: \n"); - - return 0; -} -#endif -void usage() -{ - printf("Call Test Program\n"); - printf(" %d: quit\n", CMD_QUIT); - printf(" %d: Full menu\n", CMD_FULL_MENU); -} - -char *cmd_transform(char *str) -{ - int i, j; - int len; - static char static_buffer[255]; - - if (str == NULL) - return ""; - - len = strlen(str); - if (len == 0) - return ""; - - /* remove "CMD_" */ - /* lower char */ - /* replance "_" to space */ - for (i = 0, j = 4; i < len; i++, j++) { - if (str[j] >= 'A' && str[j] <= 'Z') - static_buffer[i] = str[j] + 'a' - 'A'; - else if (str[j] == '_') - static_buffer[i] = ' '; - else - static_buffer[i] = str[j]; - } - static_buffer[j] = '\0'; - - return static_buffer; -} - -void usage_full() -{ - int i; - printf("Call Test Program\n"); - - for (i = 0; g_menu_str[i].cmd != -1; i++) { - if (i % 4 == 0) - printf("\n"); - printf(" %02d: %-32s \n", g_menu_str[i].cmd, cmd_transform(g_menu_str[i].menu_str)); - - } - printf("\n"); -} - -int is_digit(const char *str) -{ - int len; - int i; - - if (str == NULL) - return -1; - - if (strlen(str) == 0) - return -1; - - len = strlen(str); - for (i = 0; i < len; i++) { - if (str[i] < '0' || str[i] > '9') - return -2; - } - - return 0; -} - -static void zigbee_enable_cb(unsigned char ret, void *user_data) -{ - printf("enable result received = 0x%02X\n", ret); -} - -static void zigbee_form_network_done_cb(nwk_addr panid, void *user_data) -{ - printf("form_network_done received PANID = 0x%04X\n", panid); -} - -static void zigbee_disable_network_done_cb(unsigned char ret, void *user_data) -{ - printf("disable_network result received = 0x%02X\n", ret); -} - -static void zigbee_event_cb(nwk_addr addr16, ieee_addr addr64, zb_event_e e, zb_event_data_s ev) -{ - unsigned char status, count, ep, command_id; - unsigned short cluster_id; - printf("event received = 0x%02X\n", e); - - switch (e) { - case ZB_ZDP_ENABLE_EVENT: - { - status = ev.data.enable->status; - printf("service enabled = %d\n", status); - break; - } - case ZB_ZDP_FORM_NETWORK_DONE: - { - printf("form network done\n"); - break; - } - case ZB_ZDP_JOIN_EVENT: - { - count = ev.data.join->count; - printf("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X joined\n", - addr64[0], addr64[1], addr64[2], addr64[3], - addr64[4], addr64[5], addr64[6], addr64[7]); - printf("end-point count=%d\n", count); - break; - } - case ZB_ZDP_REJOIN_EVENT: - { - printf("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X rejoined\n", - addr64[0], addr64[1], addr64[2], addr64[3], - addr64[4], addr64[5], addr64[6], addr64[7]); - break; - } - case ZB_ZDP_CHILD_LEFT: - { - printf("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X left\n", - addr64[0], addr64[1], addr64[2], addr64[3], - addr64[4], addr64[5], addr64[6], addr64[7]); - break; - } - case ZB_ZDP_LEAVE_DONE_EVENT: - { - printf("%04X leave done\n", addr16); - break; - } - case ZB_ZDP_UPDATED_NETWORK_NOTIFICATION_EVENT: - { - printf("Update network notification received\n"); - break; - } - case ZB_ZDP_BIND_RSP_EVENT: - { - /* zb_parse_bind_rsp(ev, &status); */ - /* printf("binding %04X, result=%0X\n", addr16, status); */ - printf("Not implemented"); - break; - } - case ZB_ZDP_UNBIND_RSP_EVENT: - { - /* zb_parse_unbind_rsp(ev, &status); */ - /* printf("unbinding %04X, result=%0X\n", addr16, status); */ - printf("Not implemented"); - break; - } - case ZB_ZCL_GLOBAL_DEFAULT_RSP_EVENT: - { - ep = ev.data.global_default_rsp->ep; - cluster_id = ev.data.global_default_rsp->cluster_id; - command_id = ev.data.global_default_rsp->command_id; - status = ev.data.global_default_rsp->status; - - printf("addr16 = %04X\n", addr16); - printf("endpoint=%02X\n", ep); - printf("cluster_id=%04X\n", cluster_id); - printf("command_id=%02X\n", command_id); - printf("status=%02X\n", status); - break; - } - case ZB_ZCL_GLOBAL_ATTRIBUTE_REPORT_EVENT: - { - int i, j, count, rec_len; - int ret; - unsigned char *buf = NULL; - unsigned short id; - unsigned char type; - attr_report_h *t; - zb_value_h value; - - t = ev.data.global_attr_report->records; - rec_len = ev.data.global_attr_report->count; - printf("Global Attribute Report Event Received from = 0x%04X record_len=%d\n", - addr16, rec_len); - for (j = 0; j < rec_len; j++) { - zb_get_id_from_attr_report(t[j], &id); - printf("id = %04X\n", id); - zb_get_type_from_attr_report(t[j], &type); - printf("type = %02X\n", type); - zb_create_value(&value); - zb_get_value_from_attr_report(t[j], value); - ret = zb_get_value(value, &type, &buf, &count); - if (ZIGBEE_ERROR_NONE == ret) { - for (i = 0; i < count; i++) - printf("%02X ", buf[i]); - } - printf("\n"); - if (buf) { - free(buf); - buf = NULL; - } - zb_destroy_value(value); - } - break; - } - case ZB_ZCL_ALARM_EVENT: - { - printf("Alarm Event Received\n"); - break; - } - case ZB_ZCL_IAS_ZONE_ENROLL_REQUEST_EVENT: - { - /*nwk_addr addr16;*/ - unsigned short zone_type; - unsigned char ep, mfg_code; - printf("IAS Zone Request Received\n"); - - ep = ev.data.ias_enroll_request->src_ep; - zone_type = ev.data.ias_enroll_request->zone_type; - mfg_code = ev.data.ias_enroll_request->mfg_code; - - /*printf("Network Address from 0x%04X\n", addr16);*/ - printf("End-Point from 0x%02X\n", ep); - printf("Zone Type = 0x%04X\n", zone_type); - printf("Manufacturer Code = 0x%02X\n", mfg_code); - zb_zcl_zone_enroll_response(handle, addr16, ep, ZB_ZCL_IAS_ZONE_ENROLL_SUCCESS, - 0x0001); - break; - } - case ZB_ZCL_IAS_ZONE_STATUS_CHANGE_NOTIFICATION_EVENT: - { - unsigned short zone_status; - - zone_status = ev.data.ias_noti->zone_status; - ep = ev.data.ias_noti->src_ep; - printf("addr16 = %04X\n", addr16); - printf("endpoint = %02X\n", ep); - printf("zone_status = %04X\n", zone_status); - break; - } - case ZB_ZCL_IAS_ZONE_STATUS_CHANGE_EXTENDED_NOTIFICATION_EVENT: - { - unsigned short zone_status, zone_id, delay; - unsigned char extended_status; - - ep = ev.data.ias_extended_noti->src_ep; - zone_status = ev.data.ias_extended_noti->zone_status; - extended_status = ev.data.ias_extended_noti->extended_status; - zone_id = ev.data.ias_extended_noti->zone_id; - delay = ev.data.ias_extended_noti->delay; - - printf("addr16 = %04X\n", addr16); - printf("endpoint = %02X\n", ep); - printf("zone_status = %04X\n", zone_status); - printf("extended_status = %02X\n", extended_status); - printf("zone_id = %04X\n", zone_id); - printf("delay = %04X\n", delay); - - /* Closed or not alarmed */ - if (0x01 == (zone_status & 0x01)) - zb_zcl_onoff_control(handle, sj_addr16, 1, ZB_ZCL_OFF); - /* Opened or alarmed */ - else if (0x00 == (zone_status & 0x01)) - zb_zcl_onoff_control(handle, sj_addr16, 1, ZB_ZCL_ON); - break; - } - case ZB_ZCL_LEVEL_CONTROL_CURRENT_LEVEL_ATTRIBUTE_REPORT_EVENT: - break; - case ZB_ZCL_COLOR_CONTROL_CURRENT_X_ATTRIBUTE_REPORT_EVENT: - break; - case ZB_ZCL_COLOR_CONTROL_CURRENT_Y_ATTRIBUTE_REPORT_EVENT: - break; - case ZB_ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_REPORT_EVENT: - break; - case ZB_ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_REPORT_EVENT: - break; - case ZB_ZCL_COLOR_CONTROL_CURRENT_TEMPERATURE_ATTRIBUTE_REPORT_EVENT: - break; - case ZB_ZCL_DOOR_LOCK_OPERATIONAL_NOTIFICATION_EVENT: - break; - case ZB_ZCL_DOOR_LOCK_PROGRAMING_NOTIFICATION_EVENT: - break; - case ZB_ZCL_SIMPLE_METERING_REMOVE_MIRROR_EVENT: - break; - case ZB_ZCL_SIMPLE_METERING_REQUEST_MIRROR_EVENT: - break; - } -} - -#if 0 -static int zigbee_simple_description_get_set() -{ - unsigned char param_u8; - unsigned short param_u16; - int ret = ZIGBEE_ERROR_NONE; - zb_zdo_simple_desc_h handle, handle1; - unsigned short clusters[MAX_ENDPOINT_CLUSTERS] = { 0, }; - - ret = zb_simple_desc_create(&handle); - if (ZIGBEE_ERROR_NONE != ret) { - printf("zb_simple_desc_create() Fail(%d)\n", ret); - return ret; - } - - param_u8 = 1; - ret = zb_simple_desc_set_ep(handle, param_u8); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_set_ep() Fail(%d)\n", ret); - - ret = zb_simple_desc_get_ep(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_ep() Fail(%d)\n", ret); - printf("ep = %d\n", param_u8); - - ret = zb_simple_desc_set_profile_id(handle, ZB_HA_PROFILE_ID); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_set_profile_id() Fail(%d)\n", ret); - - ret = zb_simple_desc_get_profile_id(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_profile_id() Fail(%d)\n", ret); - printf("profile_id = 0x%x\n", param_u16); - - ret = zb_simple_desc_set_device_id(handle, ZB_HA_ISA_ZONE); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_set_device_id() Fail(%d)\n", ret); - - ret = zb_simple_desc_get_device_id(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_device_id() Fail(%d)\n", ret); - printf("device_id = 0x%x\n", param_u16); - - ret = zb_simple_desc_set_device_ver(handle, 0x0001); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_set_device_ver() Fail(%d)\n", ret); - - ret = zb_simple_desc_get_device_ver(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_device_ver() Fail(%d)\n", ret); - printf("device_ver = %d\n", param_u16); - - ret = zb_simple_desc_set_num_of_in_clusters(handle, 6); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_set_num_of_in_clusters() Fail(%d)\n", ret); - - ret = zb_simple_desc_get_num_of_in_clusters(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_num_of_in_clusters() Fail(%d)\n", ret); - printf("num_of_in_cluster = %d\n", param_u8); - - /* In clusters : 0000 0003 0004 0005 0006 0B04 0B05 */ - clusters[0] = ZB_ZCL_BASIC_CLUSTER_ID; - clusters[1] = ZB_ZCL_GROUPS_CLUSTER_ID; - clusters[2] = ZB_ZCL_SCENES_CLUSTER_ID; - clusters[3] = ZB_ZCL_ON_OFF_CLUSTER_ID; - clusters[4] = ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID; - clusters[5] = ZB_ZCL_DIAGNOSTICS_CLUSTER_ID; - ret = zb_simple_desc_set_in_clusters(handle, clusters, param_u16); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_set_in_clusters() Fail(%d)\n", ret); - - memset(clusters, 0, sizeof(clusters)); - ret = zb_simple_desc_get_in_clusters(handle, (unsigned short **)&clusters); - if (ZIGBEE_ERROR_NONE != ret && clusters[1] != ZB_ZCL_GROUPS_CLUSTER_ID && - clusters[5] != ZB_ZCL_DIAGNOSTICS_CLUSTER_ID) { - printf("zb_simple_desc_set_num_of_out_clusters() Fail(%d)\n", ret); - } - - ret = zb_simple_desc_set_num_of_out_clusters(handle, 1); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_set_num_of_out_clusters() Fail(%d)\n", ret); - - ret = zb_simple_desc_get_num_of_out_clusters(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_num_of_out_clusters() Fail(%d)\n", ret); - printf("num_of_out_cluster = %d\n", param_u8); - - /* Out cluster : 0019 */ - clusters[0] = ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID; - ret = zb_simple_desc_set_out_clusters(handle, clusters, param_u8); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_set_out_clusters() Fail(%d)\n", ret); - - memset(clusters, 0, sizeof(clusters)); - ret = zb_simple_desc_get_out_clusters(handle, (unsigned short **)&clusters); - if (ZIGBEE_ERROR_NONE != ret && clusters[0] != ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID) - printf("zb_simple_desc_set_num_of_out_clusters() Fail(%d)\n", ret); - - ret = zb_simple_desc_create(&handle1); - if (ZIGBEE_ERROR_NONE != ret) { - printf("zb_simple_desc_create()-1 Fail(%d)\n", ret); - return ret; - } - - ret = zb_simple_desc_copy(handle, handle); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_copy() Fail(%d)\n", ret); - - ret = zb_simple_desc_destroy(handle); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_destroy() Fail(%d)\n", ret); - - ret = zb_simple_desc_destroy(handle1); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_destroy() Fail(%d)\n", ret); - - return ret; -} -#endif - -static void zigbee_addr_rsp(unsigned char status, ieee_addr addr64, nwk_addr addr16, - unsigned char num_of_assoc_dev, unsigned char start_idx, unsigned short - *assoc_dev_addr_list, void *user_data) -{ - printf("status = %02X\n", status); - if (addr64) { - printf("IEEE Address : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], - addr64[6], addr64[7]); - } else - printf("IEEE Address : 00:00:00:00:00:00:00:00:\n"); - printf("Network Address : %04X\n", addr16); - printf("Number of Associated Device : %d\n", num_of_assoc_dev); - printf("Start Index : %d\n", start_idx); -} - -static void zigbee_active_ep_rsp(unsigned char status, nwk_addr addr16, - unsigned char count, unsigned char *ep_list, void *user_data) -{ - printf("status = %02X\n", status); -} - -static void zigbee_simple_desc_rsp(nwk_addr addr16, unsigned char len, - const zb_zdo_simple_desc_h handle, void *user_data) -{ - int ret; - unsigned char param_u8; - unsigned short param_u16; - unsigned short *in_clusters; - unsigned short *out_clusters; - - ret = zb_simple_desc_get_ep(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_ep() Fail(%X)\n", ret); - else - printf("ep = %d\n", param_u8); - - ret = zb_simple_desc_get_profile_id(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_profile_id() Fail(%X)\n", ret); - else - printf("profile_id = 0x%x\n", param_u16); - - ret = zb_simple_desc_get_device_id(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_device_id() Fail(%X)\n", ret); - else - printf("device_id = 0x%x\n", param_u16); - - ret = zb_simple_desc_get_device_ver(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_device_ver() Fail(%X)\n", ret); - else - printf("device_ver = %d\n", param_u16); - - ret = zb_simple_desc_get_num_of_in_clusters(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_num_of_in_clusters() Fail(%X)\n", ret); - else - printf("num_of_in_cluster = %d\n", param_u8); - - ret = zb_simple_desc_get_in_clusters(handle, &in_clusters); - if (ZIGBEE_ERROR_NONE != ret) { - printf("zb_simple_desc_get_in_clusters() Fail(%X)\n", ret); - } else { - printf("%04X %04X %04X %04X %04X %04X %04X\n", - in_clusters[0], in_clusters[1], in_clusters[2], in_clusters[3], - in_clusters[4], in_clusters[5], in_clusters[6]); - } - - ret = zb_simple_desc_get_num_of_out_clusters(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_num_of_out_clusters() Fail(%X)\n", ret); - else - printf("num_of_out_cluster = %d\n", param_u8); - - ret = zb_simple_desc_get_out_clusters(handle, &out_clusters); - if (ZIGBEE_ERROR_NONE != ret) - printf("zb_simple_desc_get_out_clusters() Fail(%X)\n", ret); - else - printf("%04X \n", out_clusters[0]); -} - -static void zigbee_match_desc_rsp(unsigned char status, nwk_addr addr16, - unsigned char match_length, unsigned char *match_list, void *user_data) -{ - unsigned char i; - printf("nwk_addr = %04X status = %02X match_length = %d\n", addr16, status, match_length); - for (i = 0; i < match_length; i++) - printf("match_list[%d]=%02x\n", i, (unsigned int)match_list[i]); -} - -static void zigbee_zdo_node_desc_rsp(unsigned char status, nwk_addr addr16, - const zb_zdo_node_descriptor_h desc, void *user_data) -{ - unsigned char logical_type; - unsigned char complex_desciptor_available; - unsigned char user_descriptor_available; - unsigned char aps_flags; - unsigned char frequency_band; - unsigned char mac_capability_flags; - unsigned short manufacturer_code; - unsigned char maximum_buffer_size; - unsigned short maximum_incoming_transfer_size; - unsigned short server_mask; - unsigned short maximum_outgoing_transfer_size; - unsigned short descriptor_capability_field; - - printf("nwk_addr = %04X status = %02X\n", addr16, status); - zb_node_desc_get_logical_type(desc, &logical_type); - printf("logical_type = %02X\n", logical_type); - zb_node_desc_get_complex_desciptor_available(desc, &complex_desciptor_available); - printf("complex_desciptor_available = %02X\n", complex_desciptor_available); - zb_node_desc_get_user_descriptor_available(desc, &user_descriptor_available); - printf("complex_desciptor_available = %02X\n", complex_desciptor_available); - zb_node_desc_get_aps_flags(desc, &aps_flags); - printf("aps_flags = %02X\n", aps_flags); - zb_node_desc_get_frequency_band(desc, &frequency_band); - printf("frequency_band = %02X\n", frequency_band); - zb_node_desc_get_mac_capability_flags(desc, &mac_capability_flags); - printf("mac_capability_flags = %02X\n", mac_capability_flags); - zb_node_desc_get_manufacturer_code(desc, &manufacturer_code); - printf("manufacturer_code = %04X\n", manufacturer_code); - zb_node_desc_get_maximum_buffer_size(desc, &maximum_buffer_size); - printf("maximum_buffer_size = %02X\n", maximum_buffer_size); - zb_node_desc_get_maximum_incoming_transfer_size(desc, &maximum_incoming_transfer_size); - printf("maximum_incoming_transfer_size = %04X\n", maximum_incoming_transfer_size); - zb_node_desc_get_server_mask(desc, &server_mask); - printf("server_mask = %04X\n", server_mask); - zb_node_desc_get_maximum_outgoing_transfer_size(desc, &maximum_outgoing_transfer_size); - printf("maximum_outgoing_transfer_size = %04X\n", maximum_outgoing_transfer_size); - zb_node_desc_get_descriptor_capability_field(desc, &descriptor_capability_field); - printf("descriptor_capability_field = %04X\n", descriptor_capability_field); -} - -static void zigbee_zdo_power_desc_rsp(unsigned char status, nwk_addr addr16, - const zb_zdo_node_power_descriptor_h power_desc, void *user_data) -{ - unsigned char current_power_mode; - unsigned char available_power_source; - unsigned char current_power_source; - unsigned char current_power_source_lv; - printf("status = %02X\n", status); - zb_node_power_desc_get_current_power_mode(power_desc, ¤t_power_mode); - printf("current_power_mode = %02X\n", current_power_mode); - zb_node_power_desc_get_available_power_sources(power_desc, &available_power_source); - printf("available_power_source = %02X\n", available_power_source); - zb_node_power_desc_get_current_power_source(power_desc, ¤t_power_source); - printf("current_power_source = %02X\n", current_power_source); - zb_node_power_desc_get_current_power_source_level(power_desc, ¤t_power_source_lv); - printf("current_power_source_level = %02X\n", current_power_source_lv); -} - -static void zigbee_zdo_complex_desc_rsp(unsigned char status, nwk_addr addr16, - unsigned char length, unsigned char *complex_desc, void *user_data) -{ - printf("status = %02X length = %d\n", status, length); -} - -static void zigbee_zdo_user_desc_conf(unsigned char status, void *user_data) -{ - printf("status = %02X\n", status); -} - -static void zigbee_zdo_mgmt_lqi_rsp(unsigned char status, - unsigned char neighbor_table_entries, unsigned char start_idx, - unsigned char neighbor_table_list_count, - const zb_zdo_neighbor_table_desc_h *neighbor_table_list, void *user_data) -{ - int i; - ieee_addr extended_pan_id; - ieee_addr addr64; - nwk_addr addr16; - unsigned char device_type; - unsigned char rx_on_when_idle; - unsigned char releationship; - unsigned char permit_joining; - unsigned char depth; - unsigned char lqi; - printf("status = %02X start_idx=%d count=%d\n", status, start_idx, neighbor_table_list_count); - for (i = start_idx; i < neighbor_table_list_count; i++) { - zb_neighbor_table_desc_get_extended_pan_id(neighbor_table_list[i], extended_pan_id); - printf("ext PAN ID = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - extended_pan_id[0], extended_pan_id[1], extended_pan_id[2], extended_pan_id[3], - extended_pan_id[4], extended_pan_id[5], extended_pan_id[6], extended_pan_id[7]); - zb_neighbor_table_desc_get_ieee_addr(neighbor_table_list[i], addr64); - printf("IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); - zb_neighbor_table_desc_get_nwk_addr(neighbor_table_list[i], &addr16); - printf("Network address = 0x%04X\n", addr16); - zb_neighbor_table_desc_get_device_type(neighbor_table_list[i], &device_type); - printf("Device Type = %02X\n", device_type); - zb_neighbor_table_desc_get_rx_on_when_idle(neighbor_table_list[i], &rx_on_when_idle); - printf("Rx on idle = %02X\n", rx_on_when_idle); - zb_neighbor_table_desc_get_relationship(neighbor_table_list[i], &releationship); - printf("Relationship = %02X\n", releationship); - zb_neighbor_table_desc_get_permit_joining(neighbor_table_list[i], &permit_joining); - printf("Permit Joining = %02X\n", permit_joining); - zb_neighbor_table_desc_get_depth(neighbor_table_list[i], &depth); - printf("Depth = %02X\n", depth); - zb_neighbor_table_desc_get_lqi(neighbor_table_list[i], &lqi); - printf("LQI = %02X\n", lqi); - } -} - -static void zigbee_zdo_mgmt_rtg_rsp(unsigned char status, - unsigned char routing_table_entries, unsigned char start_idx, - unsigned char routing_table_list_count, - const zb_zdo_routing_table_h *routing_table_list, void *user_data) -{ - int i; - nwk_addr dst_addr; - unsigned char mode; - unsigned char memory_constrained; - unsigned char many_to_one; - unsigned char route_record_required; - nwk_addr next_hop_addr; - printf("status = %02X routing_table_entries=%d start_idx=%d count=%d\n", - status, routing_table_entries, start_idx, routing_table_list_count); - for (i = start_idx; i < routing_table_list_count; i++) { - zb_routing_table_get_dst_addr(routing_table_list[i], &dst_addr); - printf("[%d] Destination address = 0x%04X\n", i, dst_addr); - zb_routing_table_get_dst_status(routing_table_list[i], &mode); - printf("[%d] Status = 0x%02X\n", i, mode); - zb_routing_table_get_memory_constrained(routing_table_list[i], &memory_constrained); - printf("[%d] memory_constrained = 0x%02X\n", i, memory_constrained); - zb_routing_table_get_many_to_one(routing_table_list[i], &many_to_one); - printf("[%d] many_to_one = 0x%02X\n", i, many_to_one); - zb_routing_table_get_route_record_required(routing_table_list[i], &route_record_required); - printf("[%d] route_record_required = 0x%02X\n", i, route_record_required); - zb_routing_table_get_next_hop_addr(routing_table_list[i], &next_hop_addr); - printf("[%d] next_hop_addr = 0x%04X\n", i, next_hop_addr); - printf("\n"); - } -} - -static bool zigbee_binding_table_cb(int index, zb_zdo_binding_table_h child, - void *user_data) -{ - nwk_addr addr16; - ieee_addr addr64; - unsigned short cluster_id; - unsigned char src_ep, dst_ep, dst_addr_mode; - - printf("Binding Table Index = %d\n", index); - - zb_binding_table_get_src_addr(child, addr64); - printf("Src IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); - zb_binding_table_get_src_ep(child, &src_ep); - printf("Src End-Point = %02X\n", src_ep); - zb_binding_table_get_cluster_id(child, &cluster_id); - printf("Cluster ID = %04X\n", cluster_id); - zb_binding_table_get_dst_addr_mode(child, &dst_addr_mode); - printf("Dst Address Mode = %02X\n", dst_addr_mode); - zb_binding_table_get_dst_addr16(child, &addr16); - printf("Dst Network address = %04X\n", addr16); - memset(addr64, 0, sizeof(ieee_addr)); - zb_binding_table_get_dst_addr64(child, addr64); - printf("Dst IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); - zb_binding_table_get_dst_ep(child, &dst_ep); - printf("Dst End-Point = %02X\n", src_ep); - - return true; -} - -static void zigbee_zdo_mgmt_bind_rsp(unsigned char status, unsigned char entries, - unsigned char start_idx, unsigned char binding_table_list_count, const zb_zdo_binding_table_h *list, - void *user_data) -{ - int i; - nwk_addr addr16; - ieee_addr addr64; - unsigned short cluster_id; - unsigned char src_ep, dst_ep, dst_addr_mode; - - printf("status = %02X start_idx = %d number of records = %d\n", status, start_idx, - binding_table_list_count); - - for (i = 0; i < binding_table_list_count; i++) { - zb_binding_table_get_src_addr(list[i], addr64); - printf("Src IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); - zb_binding_table_get_src_ep(list[i], &src_ep); - printf("Src End-Point = %02X\n", src_ep); - zb_binding_table_get_cluster_id(list[i], &cluster_id); - printf("Cluster ID = %04X\n", cluster_id); - zb_binding_table_get_dst_addr_mode(list[i], &dst_addr_mode); - printf("Dst Address Mode = %02X\n", dst_addr_mode); - zb_binding_table_get_dst_addr16(list[i], &addr16); - printf("Dst Network address = %04X\n", addr16); - memset(addr64, 0, sizeof(ieee_addr)); - zb_binding_table_get_dst_addr64(list[i], addr64); - printf("Dst IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); - zb_binding_table_get_dst_ep(list[i], &dst_ep); - printf("Dst End-Point = %02X\n\n", src_ep); - } -} - -static void zigbee_zcl_global_read_attributes_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, - int records_len, void *user_data) -{ - int count; - unsigned short id; - unsigned char type; - unsigned char status; - unsigned char *buf = NULL; - zb_value_h value = NULL; - read_attr_status_record_h *records; - - if (NULL == records_info || ZB_GLOBAL_READ_ATTR != records_info->type - || NULL == records_info->record.read_attr) { - printf("Invalid records info"); - return; - } - records = records_info->record.read_attr; - - zb_create_value(&value); - printf("Cluster ID : 0x%04x\n", cluster_id); - printf("Node ID : 0x%04X\n", addr16); - printf("End-Point : 0x%02X\n", ep); - printf("Msg length %d\n", records_len); - - if (records && *records) { - zb_get_id_from_read_attr_status_record(*records, &id); - printf("Attribute ID : 0x%04X\n", id); - } - if (records && *records) { - zb_get_type_from_read_attr_status_record(*records, &type); - printf("Type : 0x%02X\n", type); - } - if (records && *records) { - zb_get_status_from_read_attr_status_record(*records, &status); - printf("Status : 0x%02X\n", status); - } - if (records && *records) { - zb_get_value_from_read_attr_status_record(*records, type, value); - if (value) { - zb_get_value(value, &type, &buf, &count); - if (buf) { - printf("value[0] = 0x%02x\n", buf[0]); - free(buf); - } - zb_destroy_value(value); - } - } -} - -static void zigbee_zcl_global_write_attributes_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, - int records_len, void *user_data) -{ - unsigned short id; - unsigned char status; - zb_value_h value = NULL; - write_attr_status_record_h *records; - - if (NULL == records_info || ZB_GLOBAL_WRITE_ATTR != records_info->type - || NULL == records_info->record.write_attr) { - printf("Invalid records info"); - return; - } - records = records_info->record.write_attr; - - zb_create_value(&value); - printf("Cluster ID : 0x%04X\n", cluster_id); - printf("Node ID : 0x%04X\n", addr16); - printf("End-Point : 0x%02X\n", ep); - printf("Msg length %d\n", records_len); - if (records) { - zb_get_id_from_write_attr_status(*records, &id); - printf("AttributeId 0x%04X\n", id); - } - if (records) { - zb_get_status_from_write_attr_status(*records, &status); - printf("status 0x%02X\n", status); - } - zb_destroy_value(value); -} - -static void zigbee_zcl_global_configure_reporting_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, - int records_len, void *user_data) -{ - int i; - unsigned char status; - report_config_response_record_h *records; - - if (NULL == records_info || ZB_GLOBAL_CONFIG_REPORT != records_info->type - || NULL == records_info->record.report_config_rsp) { - printf("Invalid records info"); - return; - } - records = records_info->record.report_config_rsp; - - printf("records_len=%d\n", records_len); - for (i = 0; i < records_len; i++) { - zb_get_status_from_report_config_response_record(records[i], &status); - printf("[%d] status = 0x%02X\n", i, status); - } -} - -static void zigbee_zcl_global_discover_attributes_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, - discover_attr_info_record_h * records, int records_len, void *user_data) -{ - int i; - unsigned char type; - unsigned short id; - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Cluster ID = 0x%02X\n", cluster_id); - printf("discovery_complete = %d\n", discovery_complete); - for (i = 0; i < records_len; i++) { - zb_get_type_from_discover_attr_info(records[i], &type); - printf("[%d] type = 0x%02X\n", i, type); - zb_get_id_from_discover_attr_info(records[i], &id); - printf("[%d] id = 0x%04X\n", i, id); - } -} - -static void zigbee_zcl_global_discover_cmds_received_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, - unsigned char *command_ids, int command_ids_len, void *user_data) -{ - int i; - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point =0x%02X\n", ep); - printf("Cluster ID = 0x%02X\n", cluster_id); - printf("discovery_complete = %d\n", discovery_complete); - for (i = 0; i < command_ids_len; i++) - printf("command_id[%d] = 0x%02X\n", i, command_ids[i]); -} - -static void zigbee_zcl_global_discover_cmds_generated_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, - unsigned char *command_ids, int command_ids_len, void *user_data) -{ - int i; - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Cluster ID = 0x%02X\n", cluster_id); - printf("discovery_complete = %d\n", discovery_complete); - for (i = 0; i < command_ids_len; i++) - printf("command_id[%d] = 0x%02X\n", i, command_ids[i]); -} - -static void zigbee_zcl_global_discover_attr_extended_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, - extended_attr_info_h *records, unsigned short records_len, void *user_data) -{ - int i; - unsigned char type; - unsigned short id; - unsigned char acl; - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Cluster ID = 0x%02X\n", cluster_id); - printf("discovery_complete = %d\n", discovery_complete); - for (i = 0; i < records_len; i++) { - zb_get_id_from_extended_attr_info(records[i], &id); - printf("[%d] id = 0x%02X\n", i, id); - zb_get_type_from_extended_attr_info(records[i], &type); - printf("[%d] type = 0x%04X\n", i, type); - zb_get_acl_from_extended_attr_info(records[i], &acl); - printf("[%d] acl = 0x%04X\n", i, acl); - } -} - -static void zigbee_zdo_bind_unbind_rsp(unsigned char status, void *user_data) -{ - printf("status = 0x%02X\n", status); -} - -static void zigbee_zdo_mgmt_nwk_disc_rsp(unsigned char status, - unsigned char network_count, unsigned char start_idx, unsigned char network_list_count, - const zb_zdo_network_list_record_h *records, void *user_data) -{ - int i = 0; - ieee_addr extended_pan_id; - unsigned char logical_channel; - unsigned char stack_profile; - unsigned char zigbee_version; - unsigned char beacon_order; - unsigned char superframe_order; - unsigned char permit_joining; - - printf("Status 0x%02X\n", status); - if (!status) { - printf("network_count 0x%02X\n", network_count); - printf("start_idx 0x%02X\n", start_idx); - printf("network_list_count 0x%02X\n", network_list_count); - for (i = 0; i < network_list_count; i++) { - zb_network_list_record_get_extended_pan_id(records[i], extended_pan_id); - printf("Extended PanId %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - extended_pan_id[7], extended_pan_id[6], - extended_pan_id[5], extended_pan_id[4], - extended_pan_id[3], extended_pan_id[2], - extended_pan_id[1], extended_pan_id[0]); - zb_network_list_record_get_logical_channel(records[i], &logical_channel); - printf("Logical Channel 0x%02X\n", logical_channel); - zb_network_list_record_get_stack_profile(records[i], &stack_profile); - printf("stack_profile 0x%02X\n", stack_profile); - zb_network_list_record_get_zigbee_version(records[i], &zigbee_version); - printf("zigbee_version 0x%02X\n", zigbee_version); - zb_network_list_record_get_beacon_order(records[i], &beacon_order); - printf("Beacon_order 0x%02X\n", beacon_order); - zb_network_list_record_get_superframe_order(records[i], &superframe_order); - printf("Superframe_order 0x%02X\n", superframe_order); - zb_network_list_record_get_permit_joining(records[i], &permit_joining); - printf("Permit joining 0x%02X\n", permit_joining); - } - } else { - printf("Unsuccessful Nwk discovery\n"); - } -} -static void zigbee_zdo_mgmt_leave_rsp(unsigned char status, void *user_data) -{ - printf("status = 0x%02X\n", status); -} - -static void zigbee_zdo_mgmt_permit_joining_rsp(unsigned char status, void *user_data) -{ - printf("status = 0x%02X\n", status); -} - -static void zigbee_zcl_global_read_reporting_configuration_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, - int records_len, void *user_data) -{ - zb_value_h val; - int i = 0; - int j = 0; - int count; - unsigned char type, *buf; - unsigned short id, max_i, min_i; - report_config_record_h *records; - - if (NULL == records_info || ZB_GLOBAL_READ_REPORT_CONFIG != records_info->type - || NULL == records_info->record.report_config) { - printf("Invalid records info"); - return; - } - - records = records_info->record.report_config; - - printf("cluster_id 0x%04X\n", cluster_id); - printf("nodeId 0x%04X\n", addr16); - printf("endpoint 0x%02X\n", ep); - printf("Msg length %d\n", records_len); - - while (i < records_len) { - printf("records[%d] 0x%08X\n", i, id); - zb_get_id_from_report_config_record(records[i], &id); - printf("AttributeId 0x%04X\n", id); - zb_get_type_from_report_config_record(records[i], &type); - /*if ((zb_get_analog_or_discret(type) == DATA_TYPE_ANALOG)) {*/ - printf("type 0x%02X\n", type); - zb_get_max_i_from_report_config_record(records[i], &max_i); - printf("Max Interval 0x%04X\n", max_i); - zb_get_min_i_from_report_config_record(records[i], &min_i); - printf("Min Interval 0x%04X\n", min_i); - zb_create_value(&val); - zb_get_change_from_report_config_record1(records[i], val); - zb_get_value(val, &type, &buf, &count); - for (j = 0; j < count; j++) - printf("value[j] = 0x%02x\n", buf[j]); - printf("\n"); - free(buf); - zb_destroy_value(val); - /* - } else { - printf("Unsuccessful Attempt\n"); - } - */ - i++; - } -} - -static void zigbee_zcl_alarm_get_alarm_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned char alarm_code, unsigned short cluster_id, - unsigned int time_stamp, void *user_data) -{ - printf("Network Address = 0x%04X status = 0x%02X\n", addr16, status); - printf("End-Point = 0x%02X\n", ep); - printf("alarm_code = 0x%02X\n", alarm_code); - printf("cluster_id = 0x%04X\n", cluster_id); - printf("time_stamp = 0x%08X\n", time_stamp); -} - -static void zigbee_zcl_poll_control_check_in(nwk_addr addr16, unsigned char ep, - void *user_data) -{ - printf("Network Address = 0x%04X End-Point = 0x%02X\n", addr16, ep); -} - -static void zigbee_zcl_identify_query_cb(nwk_addr addr16, unsigned short identify_time, - void *user_data) -{ - printf("Network Address = 0x%04X\n", addr16); - printf("identify_time = %d\n", identify_time); -} - -static void zigbee_zcl_group_add_group_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, void *user_data) -{ - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Group ID = 0x%04X\n", group_id); -} - -static void zigbee_zcl_group_view_group_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, const char *group_name, void *user_data) -{ - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Group ID = 0x%04X\n", group_id); - printf("Group Name = %s\n", group_name); -} - -static void zigbee_zcl_group_get_group_membership_rsp(nwk_addr addr16, - unsigned char ep, unsigned char capacity, unsigned char group_count, - unsigned short *group_list, void *user_data) -{ - int i; - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("capacity = 0x%02X\n", capacity); - for (i = 0; i < group_count; i++) - printf("[%d] group_list=%04X\n", i, group_list[i]); -} - -static void zigbee_zcl_group_remove_group_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, void *user_data) -{ - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Group ID = 0x%04X\n", group_id); -} - -static void zigbee_zcl_scene_add_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) -{ - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Group ID = 0x%04X\n", group_id); - printf("Scene ID = 0x%02X\n", scene_id); -} - -static void zigbee_zcl_scene_view_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, unsigned char scene_id, - unsigned short transition_time, const char *scene_name, const char *extension_field_set, - unsigned short ext_len, void *user_data) -{ - int i; - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Group ID = 0x%04X\n", group_id); - printf("Scene ID = 0x%02X\n", scene_id); - printf("Transition Time = 0x%04X\n", transition_time); - printf("Scene Name = %s\n", scene_name); - for (i = 0; i < ext_len; i++) - printf("extension_field_set[%d] = 0x%02X\n", i, extension_field_set[i]); -} - -static void zigbee_zcl_scene_remove_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) -{ - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Group ID = 0x%04X\n", group_id); - printf("Scene ID = 0x%02X\n", scene_id); -} - -static void zigbee_zcl_scene_remove_all_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, void *user_data) -{ - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Group ID = 0x%04X\n", group_id); -} - -static void zigbee_zcl_scene_store_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) -{ - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Group ID = 0x%04X\n", group_id); - printf("Scene ID = 0x%02X\n", scene_id); -} - -static void zigbee_zcl_scene_get_scene_membership_rsp(nwk_addr addr16, - unsigned char ep, unsigned char status, unsigned char capacity, unsigned short group_id, - unsigned char scene_count, unsigned char *scene_list, void *user_data) -{ - int i; - printf("Network Address = 0x%04X\n", addr16); - printf("End-Point = 0x%02X\n", ep); - printf("Status = 0x%02X\n", status); - printf("Capacity = 0x%02X\n", capacity); - printf("Group ID = 0x%02X\n", group_id); - for (i = 0; i < scene_count && ZB_ZCL_SUCCESS == status; i++) - printf("scene_list[%d] = 0x%02X\n", i, scene_list[i]); -} - -void process_input(const char *input, gpointer user_data) -{ - /* Samjin power outlet EP1 */ - sj_ep1.ep = 1; - sj_ep1.profile_id = 0x0104; - sj_ep1.device_id = 0x0002; - sj_ep1.num_of_in_clusters = 8; - sj_ep1.num_of_out_clusters = 1; - /* In clusters : 0000 0003 0004 0005 0006 0009 0B04 0B05 */ - sj_ep1.in_clusters[0] = ZB_ZCL_BASIC_CLUSTER_ID; - sj_ep1.in_clusters[1] = ZB_ZCL_IDENTIFY_CLUSTER_ID; - sj_ep1.in_clusters[2] = ZB_ZCL_GROUPS_CLUSTER_ID; - sj_ep1.in_clusters[3] = ZB_ZCL_SCENES_CLUSTER_ID; - sj_ep1.in_clusters[4] = ZB_ZCL_ON_OFF_CLUSTER_ID; - sj_ep1.in_clusters[5] = ZB_ZCL_ALARM_CLUSTER_ID; - sj_ep1.in_clusters[6] = ZB_ZCL_DIAGNOSTICS_CLUSTER_ID; - /* Out clusters : 0019 */ - unsigned short sj_out_clusters[] = { ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID }; - - /* SmartThings open/close sensor EP1 */ - st_ep1.ep = 1; - st_ep1.profile_id = 0x0104; - st_ep1.device_id = 0x0402; - st_ep1.num_of_in_clusters = 7; - st_ep1.num_of_out_clusters = 1; - st_ep1.in_clusters[0] = ZB_ZCL_BASIC_CLUSTER_ID; - st_ep1.in_clusters[1] = ZB_ZCL_POWER_CONFIG_CLUSTER_ID; - st_ep1.in_clusters[2] = ZB_ZCL_IDENTIFY_CLUSTER_ID; - st_ep1.in_clusters[3] = ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID; - st_ep1.in_clusters[4] = ZB_ZCL_IAS_ZONE_CLUSTER_ID; - st_ep1.in_clusters[5] = ZB_ZCL_POLL_CONTROL_CLUSTER_ID; - st_ep1.in_clusters[6] = ZB_ZCL_DIAGNOSTICS_CLUSTER_ID; - st_ep1.out_clusters[0] = ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID; - - /* SmartThings open/close sensor EP2 */ - st_ep2.ep = 2; - st_ep2.profile_id = 0xC2DF; - st_ep2.device_id = 0x000C; - st_ep2.num_of_in_clusters = 4; - st_ep2.num_of_out_clusters = 1; - st_ep2.in_clusters[0] = ZB_ZCL_BASIC_CLUSTER_ID; - st_ep2.in_clusters[1] = ZB_ZCL_IDENTIFY_CLUSTER_ID; - st_ep2.in_clusters[2] = ZB_ZCL_SCENES_CLUSTER_ID; - st_ep2.in_clusters[3] = 0xFC0F; - st_ep2.out_clusters[0] = ZB_ZCL_IDENTIFY_CLUSTER_ID; - - /* SmartThings Motion Sensor EP1 */ - st_ep3.ep = 1; - st_ep3.profile_id = 0x0104; - st_ep3.device_id = 0x0402; - st_ep3.num_of_in_clusters = 7; - st_ep3.num_of_out_clusters = 1; - st_ep3.in_clusters[0] = ZB_ZCL_BASIC_CLUSTER_ID; - st_ep3.in_clusters[1] = ZB_ZCL_POWER_CONFIG_CLUSTER_ID; - st_ep3.in_clusters[2] = ZB_ZCL_IDENTIFY_CLUSTER_ID; - st_ep3.in_clusters[3] = ZB_ZCL_POLL_CONTROL_CLUSTER_ID; - st_ep3.in_clusters[4] = ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID; - st_ep3.in_clusters[5] = ZB_ZCL_IAS_ZONE_CLUSTER_ID; - st_ep3.in_clusters[6] = ZB_ZCL_DIAGNOSTICS_CLUSTER_ID; - st_ep3.out_clusters[0] = ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID; - - /* SmartThings Motion Sensor EP2 */ - st_ep4.ep = 2; - st_ep4.profile_id = 0xC2DF; - st_ep4.device_id = 0x0107; - st_ep4.num_of_in_clusters = 5; - st_ep4.num_of_out_clusters = 1; - st_ep4.in_clusters[0] = ZB_ZCL_BASIC_CLUSTER_ID; - st_ep4.in_clusters[1] = ZB_ZCL_POWER_CONFIG_CLUSTER_ID; - st_ep4.in_clusters[2] = ZB_ZCL_IDENTIFY_CLUSTER_ID; - st_ep4.in_clusters[3] = ZB_ZCL_DIAGNOSTICS_CLUSTER_ID; - st_ep4.in_clusters[4] = 0xFC46; - st_ep4.out_clusters[0] = ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID; - - /* Things Simulator */ - simul_ep1.ep = 1; - simul_ep1.profile_id = 0x0104; - simul_ep1.device_id = 0xffff; - simul_ep1.num_of_in_clusters = 7; - simul_ep1.num_of_out_clusters = 1; - simul_ep1.in_clusters[0] = ZB_ZCL_BASIC_CLUSTER_ID; - simul_ep1.in_clusters[1] = ZB_ZCL_IDENTIFY_CLUSTER_ID; - simul_ep1.in_clusters[2] = ZB_ZCL_GROUPS_CLUSTER_ID; - simul_ep1.in_clusters[3] = ZB_ZCL_SCENES_CLUSTER_ID; - simul_ep1.in_clusters[4] = ZB_ZCL_ON_OFF_CLUSTER_ID; - simul_ep1.in_clusters[5] = ZB_ZCL_LEVEL_CONTROL_CLUSTER_ID; - simul_ep1.in_clusters[6] = ZB_ZCL_DIAGNOSTICS_CLUSTER_ID; - /*simul_ep1.in_clusters[7] = ZB_ZCL_SIMPLE_METERING_CLUSTER_ID;*/ - simul_ep1.out_clusters[0] = ZB_ZCL_TIME_CLUSTER_ID; - /*simul_ep1.out_clusters[1] = ZB_ZCL_OTA_BOOTLOAD_CLUSTER_ID;*/ - - - struct appdata *ad = (struct appdata *)user_data; - int ret = -1; - int cmd = strtol(input, NULL, 0); - if (is_digit(input) < 0 || strlen(input) == 0 || errno == ERANGE || errno == EINVAL) - cmd = CMD_INVALID; - - printf("cmd=[%d]\n", cmd); - - switch (cmd) { - case CMD_QUIT: - printf("Bye\n"); - g_main_loop_quit(ad->main_loop); - break; - case CMD_INITIALIZE: - handle = NULL; - ret = zb_create(&handle); - printf("zb_create ret=[0x%x]\n", (int)handle); - break; - case CMD_ENABLE: - ret = zb_enable(handle, zigbee_event_cb); - printf("zb_enable ret=[0x%x]\n", ret); - break; - case CMD_GET_NETWORK_INFO: - { - nwk_addr nodeid; - nwk_addr panid; - unsigned char channel; - unsigned char tx_power; - - ret = zb_get_network_info(handle, co_addr64, &nodeid, &panid, &channel, &tx_power); - printf("zb_get_network_info ret=[0x%02X]\n", (int)ret); - printf(" IEEE ADDR : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - co_addr64[0], co_addr64[1], co_addr64[2], - co_addr64[3], co_addr64[4], co_addr64[5], - co_addr64[6], co_addr64[7]); - printf(" nodeID [0x%02X]\n", nodeid); - printf(" PanID [0x%02X]\n", panid); - printf(" Channel [%d] Tx Power [%d]\n", channel, tx_power); - break; - } - case CMD_GET_COORDINATOR_MAC_ADDR: - ret = zb_get_controller_mac_address(handle, co_addr64); - printf("zb_get_controller_mac_address ret=[0x%02X]\n", (int)ret); - printf("IEEE ADDR 0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X:0x%02X\n", - co_addr64[0], co_addr64[1], co_addr64[2], co_addr64[3], - co_addr64[4], co_addr64[5], co_addr64[6], co_addr64[7]); - break; - case CMD_GET_END_DEVICE_LIST: - { - int i, j; - int count; - nwk_addr addr16; - ieee_addr addr64; - unsigned char num_of_ep; - unsigned char ep_list[10]; - zb_end_device_info_h *list = NULL; - ret = zb_get_all_device_list(handle, &count, &list); - for (i = 0; i < count && list; i++) { - zb_get_network_address(list[i], &addr16); - printf("network address = 0x%02X\n", addr16); - - zb_get_ieee_address((list)[i], addr64); - printf("ieee address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], - addr64[6], addr64[7]); - - if (!strncmp((char *)sj_addr64, (char *)addr64, sizeof(addr64))) { - sj_addr16 = addr16; - printf("Samjin Power Outlet Find!!\n"); - } - if (!strncmp((char *)st_addr64, (char *)addr64, sizeof(addr64))) { - st_addr16 = addr16; - printf("ST Open/Close Sensor Find!!\n"); - } - - zb_get_num_of_ep((list)[i], &num_of_ep); - printf("number of end-points = 0x%04X\n", num_of_ep); - - memset(ep_list, 0, sizeof(ep_list)); - zb_get_ep_list((list)[i], ep_list); - for (j = 0; j < num_of_ep; j++) - printf("%04x ", ep_list[j]); - printf("\n"); - } - zb_device_list_free(list); - - break; - } - case CMD_DISABLE: - ret = zb_disable(handle); - printf("zb_disable ret=[0x%x]\n", ret); - break; - case CMD_RESET: - ret = zb_hw_reset(handle); - printf("zb_hw_reset ret=[0x%x]\n", ret); - break; - case CMD_COEX_START: - ret = zb_coex_start(handle, 11); - printf("zb_coex_start ret=[0x%x]\n", ret); - break; - case CMD_COEX_STOP: - ret = zb_coex_stop(handle); - printf("zb_coex_stop ret=[0x%x]\n", ret); - break; - case CMD_FORM_NETWORK: - ret = zb_form_network(handle, zigbee_form_network_done_cb, NULL); - printf("zb_form_network ret=[0x%x]\n", ret); - break; - case CMD_DISABLE_NETWORK: - ret = zb_disable_network(handle, zigbee_disable_network_done_cb, NULL); - printf("zb_disable_network ret=[0x%x]\n", ret); - break; - case CMD_LEAVE_NODE: - ret = zb_leave_device(handle, st_addr64, true, false); - printf("zb_leave_device ret=[0x%x]\n", ret); - ret = zb_leave_device(handle, sj_addr64, true, false); - printf("zb_leave_device ret=[0x%x]\n", ret); - break; - case CMD_PERMIT_JOIN: - ret = zb_permit_join(handle, 90); - printf("zb_permit_join ret=[0x%x]\n", ret); - break; - case CMD_NWK_ADDR_REQ: - ret = zb_zdo_nwk_addr_req(handle, st_addr64, 0x00, 0x00, - zigbee_addr_rsp, NULL); - ret = zb_zdo_nwk_addr_req(handle, sj_addr64, 0x00, 0x00, - zigbee_addr_rsp, NULL); - break; - case CMD_IEEE_ADDR_REQ: - ret = zb_zdo_ieee_addr_req(handle, st_addr16, zigbee_addr_rsp, NULL); - ret = zb_zdo_ieee_addr_req(handle, sj_addr16, zigbee_addr_rsp, NULL); - break; - case CMD_ACTIVE_EP_REQ: - ret = zb_zdo_active_ep(handle, st_addr16, zigbee_active_ep_rsp, NULL); - ret = zb_zdo_active_ep(handle, sj_addr16, zigbee_active_ep_rsp, NULL); - break; - case CMD_SIMPLE_DESC_REQ: - case CMD_EXTENDED_SIMPLE_DESC_REQ: - ret = zb_zdo_simple_desc_req(handle, simul_addr16, 1, zigbee_simple_desc_rsp, NULL); - /*ret = zb_zdo_simple_desc_req(handle, st_addr16, 1, zigbee_simple_desc_rsp, NULL);*/ - /*ret = zb_zdo_simple_desc_req(handle, sj_addr16, 1, zigbee_simple_desc_rsp, NULL);*/ - break; - case CMD_MATCHED_DESC_REQ: - /* for ST open/close sensor */ - ret = zb_zdo_match_desc_req(handle, st_addr16, st_ep1.profile_id, - st_ep1.num_of_in_clusters, st_ep1.in_clusters, st_ep1.num_of_out_clusters, - st_ep1.out_clusters, zigbee_match_desc_rsp, user_data); - /* for SJ power outlet */ - ret = zb_zdo_match_desc_req(handle, sj_addr16, sj_ep1.profile_id, - sj_ep1.num_of_in_clusters, sj_ep1.in_clusters, sj_ep1.num_of_out_clusters, - sj_ep1.out_clusters, zigbee_match_desc_rsp, user_data); - break; - case CMD_POWER_DESC_REQ: - ret = zb_zdo_power_desc_req(handle, sj_addr16, zigbee_zdo_power_desc_rsp, NULL); - break; - case CMD_COMPLEX_DESC_REQ: - ret = zb_zdo_complex_desc_req(handle, sj_addr16, zigbee_zdo_complex_desc_rsp, NULL); - break; - case CMD_USER_DESC_REQ: - ret = zb_zdo_user_desc_req(handle, sj_addr16, zigbee_zdo_complex_desc_rsp, NULL); - break; - case CMD_USER_DESC_SET_REQ: - ret = zb_zdo_user_desc_set(handle, sj_addr16, 4, (unsigned char*)"test", - zigbee_zdo_user_desc_conf, NULL); - break; - case CMD_NODE_DESC_REQ: - /*zb_zdo_node_desc_req(handle, st_addr16, zigbee_zdo_node_desc_rsp, NULL);*/ - zb_zdo_node_desc_req(handle, sj_addr16, zigbee_zdo_node_desc_rsp, NULL); - break; - case CMD_DEVICE_ANNCE: - ret = zb_zdo_device_annce(handle, st_addr16, st_addr64, - ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR | ZB_ZDP_DEVICE_TYPE | ZB_ZDP_POWER_SOURCE | - ZB_ZDP_RECEIVER_ON_WHEN_IDLE | ZB_ZDP_ALLOCATE_ADDRESS); - break; - case CMD_BIND_REQ: - /* Samjin Power Outlet */ -#if 0 - ret = zb_zdo_bind_req(handle, sj_addr16, sj_addr64, 1, ZB_ZCL_DIAGNOSTICS_CLUSTER_ID, - co_addr64, ZB_UNICAST_BINDING, 0x0004, 1, zigbee_zdo_bind_unbind_rsp, NULL); -#endif - ret = zb_zdo_bind_req(handle, sj_addr16, sj_addr64, 1, ZB_ZCL_ON_OFF_CLUSTER_ID, - co_addr64, ZB_UNICAST_BINDING, 0x0004, 1, zigbee_zdo_bind_unbind_rsp, NULL); -#if 0 - /* For ST Open/Close Sensor */ - ret = zb_zdo_bind_req(handle, st_addr16, st_addr64, 1, ZB_ZCL_IAS_ZONE_CLUSTER_ID, - co_addr64, ZB_UNICAST_BINDING, panid, 1, zigbee_zdo_bind_unbind_rsp, NULL); -#endif - break; - case CMD_UNBIND_REQ: - ret = zb_zdo_unbind_req(handle, sj_addr16, co_addr64, 1, ZB_ZCL_ON_OFF_CLUSTER_ID, - sj_addr64, ZB_UNICAST_BINDING, panid, 1, zigbee_zdo_bind_unbind_rsp, NULL); - break; - case CMD_MGMT_NWK_DISC_REQ: - { - unsigned int scan_channels = ZB_802_15_4_CHANNELS_MASK; - ret = zb_zdo_mgmt_nwk_disc_req(handle, sj_addr16, scan_channels, 5, 4, 0, - zigbee_zdo_mgmt_nwk_disc_rsp, NULL); - break; - } - case CMD_MGMT_NWK_UPDATE_REQ: - { - unsigned int scan_channels = ZB_802_15_4_CHANNELS_MASK; - unsigned char nwk_update_id = 0x00; - ret = zb_zdo_mgmt_nwk_update_req(handle, scan_channels, 5, 4, nwk_update_id, sj_addr16); - break; - } - case CMD_MGMT_LQI_REQ: - ret = zb_zdo_mgmt_lqi_req(handle, sj_addr16, 0, zigbee_zdo_mgmt_lqi_rsp, NULL); - /*ret = zb_zdo_mgmt_lqi_req(handle, st_addr16, 0, zigbee_zdo_mgmt_lqi_rsp, NULL);*/ - break; - case CMD_MGMT_RTG_REQ: - ret = zb_zdo_mgmt_rtg_req(handle, sj_addr16, 0, zigbee_zdo_mgmt_rtg_rsp, NULL); - /*ret = zb_zdo_mgmt_rtg_req(handle, st_addr16, 0, zigbee_zdo_mgmt_rtg_rsp, NULL);*/ - break; - case CMD_MGMT_BIND_REQ: - ret = zb_zdo_mgmt_bind_req(handle, sj_addr16, 0, zigbee_zdo_mgmt_bind_rsp, NULL); - /*ret = zb_zdo_mgmt_bind_req(handle, st_addr16, 0, zigbee_zdo_mgmt_bind_rsp, NULL);*/ - break; - case CMD_MGMT_LEAVE_REQ: - ret = zb_zdo_mgmt_leave_req(handle, sj_addr64, true, true, zigbee_zdo_mgmt_leave_rsp, NULL); - break; - case CMD_MGMT_PERMIT_JOINING_REQ: - ret = zb_zdo_mgmt_permit_joining_req(handle, sj_addr16, 90, 0, - zigbee_zdo_mgmt_permit_joining_rsp, NULL); - break; - case CMD_READ_ATTRIBUTES_REQ: - { - /* For SmartThings open/close sensor */ - unsigned short st_cluster_id = ZB_ZCL_IAS_ZONE_CLUSTER_ID; - unsigned short st_attribute_id[] = { ZB_ZCL_ZONE_STATE_ATTRIBUTE_ID, - ZB_ZCL_ZONE_TYPE_ATTRIBUTE_ID, - ZB_ZCL_ZONE_STATUS_ATTRIBUTE_ID, - ZB_ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID, - ZB_ZCL_ZONE_ID_ATTRIBUTE_ID - }; -#if 1 - int st_len_of_attr = sizeof(st_attribute_id) / sizeof(st_attribute_id[0]); - /* Reading zone state attribute */ - ret = zb_zcl_global_read_attr(handle, st_addr16, 1, st_ep1.ep, - -1, st_cluster_id, st_attribute_id, st_len_of_attr, - zigbee_zcl_global_read_attributes_rsp, NULL); -#endif - /* For Samjin power outlet */ - /* Reading attributs in on/off cluster */ - unsigned short sj_cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; - unsigned short sj_attribute_id[] = { ZB_ZCL_ON_OFF_ATTRIBUTE_ID, - ZB_ZCL_GLOBAL_SCENE_CONTROL_ATTRIBUTE_ID, - ZB_ZCL_ON_TIME_ATTRIBUTE_ID, - ZB_ZCL_OFF_WAIT_TIME_ATTRIBUTE_ID - }; - int sj_len_of_attr = sizeof(sj_attribute_id) / sizeof(sj_attribute_id[0]); - - ret = zb_zcl_global_read_attr(handle, sj_addr16, 1, sj_ep1.ep, - -1, sj_cluster_id, sj_attribute_id, sj_len_of_attr, - zigbee_zcl_global_read_attributes_rsp, NULL); -#if 1 - /* Reading active power report in electrical measurement cluster */ - sj_cluster_id = ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID; - sj_attribute_id[0] = ZB_ZCL_ACTIVE_POWER_ATTRIBUTE_ID; - sj_len_of_attr = 1; - - ret = zb_zcl_global_read_attr(handle, sj_addr16, 1, sj_ep1.ep, - -1, sj_cluster_id, sj_attribute_id, sj_len_of_attr, - zigbee_zcl_global_read_attributes_rsp, NULL); -#endif - break; - } - case CMD_WRITE_ATTRIBUTES_REQ: - { - unsigned char value[] = { 0x02, 0x01}; - /* Samjin Power Outlet */ - write_attr_record_h attr; - zb_create_write_attr_record(&attr); - zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); - zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); - zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, value, - zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); - ret = zb_zcl_global_write_attr(handle, sj_addr16, 1, sj_ep1.ep, ZB_ZCL_FC_DEFAULT, - ZB_ZCL_IDENTIFY_CLUSTER_ID, &attr, 1, - zigbee_zcl_global_write_attributes_rsp, NULL); - zb_destroy_write_attr_record(attr); - break; - } - case CMD_WRITE_ATTRIBUTES_UNDEVIDEDED_REQ: - { - unsigned char value[] = { 0x02, 0x01}; - /* Samjin Power Outlet */ - write_attr_record_h attr; - zb_create_write_attr_record(&attr); - zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); - zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); - zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, value, - zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); - ret = zb_zcl_global_write_attr_undivided(handle, sj_addr16, 1, - sj_ep1.ep, ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, &attr, 1, - zigbee_zcl_global_write_attributes_rsp, NULL); - zb_destroy_write_attr_record(attr); - break; - } - case CMD_WRITE_ATTRIBUTES_NO_RSP_REQ: - { - unsigned char value[] = { 0x02, 0x01}; - /* Samjin Power Outlet */ - write_attr_record_h attr; - zb_create_write_attr_record(&attr); - zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); - zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); - zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, value, - zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); - ret = zb_zcl_global_write_attr_no_rsp(handle, sj_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, &attr, 1); - zb_destroy_write_attr_record(attr); - break; - } - case CMD_CONFIGURE_REPORTING_REQ: - { - /* Samjin Power Outlet */ - unsigned char val1 = 0; - report_config_record_h config, config1; - zb_create_report_config_record(&config); - zb_set_dir_to_report_config_record(config, ZB_ZCL_CLIENT_TO_SERVER); - zb_set_id_to_report_config_record(config, ZB_ZCL_ON_OFF_ATTRIBUTE_ID); - zb_set_type_to_report_config_record(config, ZB_ZCL_BOOLEAN); - zb_set_min_i_to_report_config_record(config, 0x01); - zb_set_max_i_to_report_config_record(config, 0x1000); - zb_set_change_to_report_config_record2(config, ZB_ZCL_BOOLEAN, &val1); - /*zb_set_timeout_to_report_config_record(config, 10);*/ - ret = zb_zcl_global_config_report(handle, sj_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_ON_OFF_CLUSTER_ID, &config, 1, - zigbee_zcl_global_configure_reporting_rsp, NULL); - zb_destroy_report_config_record(config); -#if 1 - /* ST Open/Close Sensor */ - unsigned short val2 = 0x007f; - zb_create_report_config_record(&config1); - zb_set_dir_to_report_config_record(config1, ZB_ZCL_CLIENT_TO_SERVER); - zb_set_id_to_report_config_record(config1, ZB_ZCL_ZONE_STATE_ATTRIBUTE_ID); - zb_set_type_to_report_config_record(config1, ZB_ZCL_SIGNED_16_BIT_INTEGER); - zb_set_min_i_to_report_config_record(config1, 0); - zb_set_max_i_to_report_config_record(config1, 60); - zb_set_change_to_report_config_record2(config1, ZB_ZCL_SIGNED_16_BIT_INTEGER, &val2); - zb_set_timeout_to_report_config_record(config1, 60); - ret = zb_zcl_global_config_report(handle, st_addr16, 1, st_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID, &config1, 1, - zigbee_zcl_global_configure_reporting_rsp, NULL); - zb_destroy_report_config_record(config1); -#endif - break; - } - case CMD_READ_CONFIGURE_REPORTING: - { - read_report_config_record_h read_report_conf; - zb_create_read_report_config_record(&read_report_conf); - zb_set_dir_to_read_report_config_record(read_report_conf, ZB_ZCL_CLIENT_TO_SERVER); - zb_set_id_to_read_report_config_record(read_report_conf, ZB_ZCL_ON_OFF_ATTRIBUTE_ID); - - /* Samjin Power Outlet */ - zb_zcl_global_read_config_report(handle, sj_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_ON_OFF_CLUSTER_ID, &read_report_conf, 1, - zigbee_zcl_global_read_reporting_configuration_rsp, NULL); - zb_destroy_read_report_config_record(read_report_conf); - break; - } - case CMD_DISCOVER_ATTRIBUTES: - { - /* For ST Open/Close Sensor */ - ret = zb_zcl_global_discover_attr(handle, st_addr16, 1, st_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, - 2, zigbee_zcl_global_discover_attributes_rsp, NULL); - /* For SJ Power Outlet */ - ret = zb_zcl_global_discover_attr(handle, sj_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_ON_OFF_CLUSTER_ID, ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, - zigbee_zcl_global_discover_attributes_rsp, NULL); - break; - } - case CMD_READ_ATTRIBUTES_STRUCTURED: - break; - case CMD_WRITE_ATTRIBUTES_STRUCTURED: - break; - case CMD_DISCOVER_COMMANDS_RECEIVED: - { - ret = zb_zcl_global_discover_cmds_received(handle, sj_addr16, 1, sj_ep1.ep, - ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_ON_OFF_CLUSTER_ID, - ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, zigbee_zcl_global_discover_cmds_received_rsp, NULL); - break; - } - case CMD_DISCOVER_COMMANDS_GENERATED: - { - ret = zb_zcl_global_discover_cmds_generated(handle, sj_addr16, 1, sj_ep1.ep, - ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_GROUPS_CLUSTER_ID, 0x00, 4, - zigbee_zcl_global_discover_cmds_generated_rsp, NULL); - break; - } - case CMD_DISCOVER_ATTRIBUTES_EXTENDED: - { - ret = zb_zcl_global_discover_attr_extended(handle, sj_addr16, 1, sj_ep1.ep, - ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_ON_OFF_CLUSTER_ID, ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, - zigbee_zcl_global_discover_attr_extended_rsp, NULL); - break; - } - case CMD_ALARM_RESET_ALARM: - ret = zb_zcl_alarm_reset_alarm(handle, simul_addr16, 1, 0x01, ZB_ZCL_ON_OFF_CLUSTER_ID); - break; - case CMD_ALARM_RESET_ALL_ALARM: - ret = zb_zcl_alarm_reset_all_alarm(handle, simul_addr16, 1); - break; - case CMD_ALARM_GET_ALARM: - ret = zb_zcl_alarm_get_alarm(handle, simul_addr16, 1, - zigbee_zcl_alarm_get_alarm_rsp, NULL); - break; - case CMD_ALARM_RESET_ALL_ALARM_LOG: - ret = zb_zcl_alarm_reset_all_alarm_log(handle, simul_addr16, 1); - break; - case CMD_IDENTITY: - ret = zb_zcl_identify(handle, sj_addr16, sj_ep1.ep, 10); - break; - case CMD_IDENTITY_QUERY: - ret = zb_zcl_identify_query(handle, sj_addr16, sj_ep1.ep, - zigbee_zcl_identify_query_cb, NULL); - break; -#if 0 - case CMD_SIMPLE_DESCRIPTION_GET_SET: - ret = zigbee_simple_description_get_set(); - printf("zigbee_simple_description_get_set() ret=[%d]\n", ret); - break; -#endif - case CMD_ON_OFF_CLUSTER_ON: - ret = zb_zcl_onoff_control(handle, sj_addr16, sj_ep1.ep, ZB_ZCL_ON); - break; - case CMD_ON_OFF_CLUSTER_OFF: - ret = zb_zcl_onoff_control(handle, sj_addr16, sj_ep1.ep, ZB_ZCL_OFF); - break; - case CMD_ON_OFF_CLUSTER_TOGGLE: - ret = zb_zcl_onoff_control(handle, sj_addr16, sj_ep1.ep, ZB_ZCL_TOGGLE); - break; - case CMD_ADD_GROUP: - { - char group_name[8] = "6grpone"; - unsigned short group_id = 0x0002; - ret = zb_zcl_group_add_group(handle, sj_addr16, sj_ep1.ep, group_id, group_name, - zigbee_zcl_group_add_group_rsp, NULL); - break; - } - case CMD_VIEW_GROUP: - { - unsigned short group_id = 0x0002; - ret = zb_zcl_group_view_group(handle, sj_addr16, sj_ep1.ep, group_id, - zigbee_zcl_group_view_group_rsp, NULL); - break; - } - case CMD_GET_GROUP_MEMBERSHIP: - { - unsigned short group_list[2] = { 0x0001, 0x0002}; - ret = zb_zcl_group_get_group_membership(handle, sj_addr16, sj_ep1.ep, 2, - group_list, zigbee_zcl_group_get_group_membership_rsp, NULL); - break; - } - case CMD_REMOVE_GROUP: - { - unsigned short group_id = 0x0002; - ret = zb_zcl_group_remove_group(handle, sj_addr16, sj_ep1.ep, group_id, - zigbee_zcl_group_remove_group_rsp, NULL); - break; - } - case CMD_REMOVE_ALL_GROUP: - { - char group_name[8] = "6grpone"; - unsigned short group_id = 0x0002; - ret = zb_zcl_group_remove_all_group(handle, sj_addr16, sj_ep1.ep); - break; - } - case CMD_ADD_GROUP_IF_IDENTIFY: - { - char group_name[8] = "6grpone"; - unsigned short group_id = 0x0002; - ret = zb_zcl_group_add_group_if_identifying(handle, sj_addr16, sj_ep1.ep, - group_id, group_name); - break; - } - case CMD_ADD_SCENE: - { - char scene_name[8] = "6scnone"; - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - unsigned short trans_time = 0x0000; - const char ext_field_set[] = {0x00, 0x06, 0x01, 0x00}; - unsigned short ext_len = sizeof(ext_field_set)/sizeof(ext_field_set[0]); - ret = zb_zcl_scene_add_scene(handle, sj_addr16, sj_ep1.ep, group_id, scene_id, - trans_time, scene_name, ext_len, ext_field_set, zigbee_zcl_scene_add_scene_rsp, NULL); - break; - } - case CMD_VIEW_SCENE: - { - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - ret = zb_zcl_scene_view_scene(handle, sj_addr16, sj_ep1.ep, group_id, scene_id, - zigbee_zcl_scene_view_scene_rsp, NULL); - break; - } - case CMD_GET_SCENE_MEMBERSHIP: - { - unsigned short group_id = 0x0002; - ret = zb_zcl_scene_get_scene_membership(handle, sj_addr16, sj_ep1.ep, group_id, - zigbee_zcl_scene_get_scene_membership_rsp, NULL); - break; - } - case CMD_REMOVE_SCENE: - { - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - ret = zb_zcl_scene_remove_scene(handle, sj_addr16, sj_ep1.ep, group_id, scene_id, - zigbee_zcl_scene_remove_scene_rsp, NULL); - break; - } - case CMD_REMOVE_ALL_SCENE: - { - unsigned short group_id = 0x0002; - ret = zb_zcl_scene_remove_all_scene(handle, sj_addr16, sj_ep1.ep, group_id, - zigbee_zcl_scene_remove_all_scene_rsp, NULL); - break; - } - case CMD_STORE_SCENE: - { - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - ret = zb_zcl_scene_store_scene(handle, sj_addr16, sj_ep1.ep, group_id, scene_id, - zigbee_zcl_scene_store_scene_rsp, NULL); - break; - } - case CMD_RECALL_SCENE: - { - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - ret = zb_zcl_scene_recall_scene(handle, sj_addr16, sj_ep1.ep, group_id, scene_id); - break; - } - case CMD_POLLCONTROL_CHECKIN_RESPONSE: - ret = zb_zcl_pollctrl_check_in_response(handle, sj_addr16, sj_ep1.ep, 10, 100); - break; - case CMD_POLLCONTROL_FAST_POLL_STOP: - ret = zb_zcl_pollctrl_fast_poll_stop(handle, sj_addr16, sj_ep1.ep); - break; - case CMD_POLLCONTROL_SET_LONG_POLL_INTERVAL: - ret = zb_zcl_pollctrl_set_long_poll_interval(handle, sj_addr16, sj_ep1.ep, - 200, zigbee_zcl_poll_control_check_in, NULL); - break; - case CMD_POLLCONTROL_SET_SHORT_POLL_INTERVAL: - ret = zb_zcl_pollctrl_set_long_poll_interval(handle, sj_addr16, sj_ep1.ep, - 5, zigbee_zcl_poll_control_check_in, NULL); - break; - case CMD_LEVELCONTROL_MOVE_TO_LEVEL: - { - unsigned char level = 100; - unsigned short transition_time = 10; - ret = zb_zcl_levelctrl_move_to_level(handle, simul_addr16, simul_ep1.ep, - level, transition_time); - printf("zb_zcl_levelctrl_move_to_level ret=[0x%x]\n", ret); - break; - } - case CMD_LEVELCONTROL_MOVE: - { - unsigned char move_mode = 0x00; /* Up */ - unsigned char rate = 0xFF; - ret = zb_zcl_levelctrl_move(handle, simul_addr16, simul_ep1.ep, move_mode, rate); - printf("zb_zcl_levelctrl_move ret=[0x%x]\n", ret); - break; - } - case CMD_LEVELCONTROL_STEP: - { - unsigned char step_mode = 0x00; /* Up */ - unsigned char step_size = 0x10; - unsigned short transition_time = 10; - ret = zb_zcl_levelctrl_step(handle, simul_addr16, simul_ep1.ep, - step_mode, step_size, transition_time); - printf("zb_zcl_levelctrl_step ret=[0x%x]\n", ret); - break; - } - case CMD_LEVELCONTROL_STOP: - ret = zb_zcl_levelctrl_stop(handle, simul_addr16, simul_ep1.ep); - break; - case CMD_LEVELCONTROL_MOVE_WITH_ONOFF: - { - unsigned char move_mode = 0x00; /* Up */ - unsigned char rate = 10; - ret = zb_zcl_levelctrl_move_with_on_off(handle, simul_addr16, simul_ep1.ep, - move_mode, rate); - printf("zb_zcl_levelctrl_move_with_on_off ret=[0x%x]\n", ret); - break; - } - case CMD_LEVELCONTROL_MOVE_TO_LEVEL_WITH_ONOFF: - { - unsigned char level = 100; - unsigned short transition_time = 10; - ret = zb_zcl_levelctrl_move_to_level_with_on_off(handle, simul_addr16, simul_ep1.ep, - level, transition_time); - printf("zb_zcl_levelctrl_move_to_level_with_on_off ret=[0x%x]\n", ret); - break; - } - case CMD_LEVELCONTROL_STEP_WITH_ONOFF: - { - unsigned char step_mode = 0x00; /* Up */ - unsigned char step_size = 0x10; - unsigned short transition_time = 10; - ret = zb_zcl_levelctrl_step_with_on_off(handle, simul_addr16, simul_ep1.ep, - step_mode, step_size, transition_time); - printf("zb_zcl_levelctrl_step_with_on_off ret=[0x%x]\n", ret); - break; - } - case CMD_THERMOSTAT_ADJUST_SETPOINT: - { - unsigned char mode = 0x00; /* HEAT_MODE */ - unsigned char amount = 0x01; - ret = zb_zcl_thermostat_adjust_setpoint(handle, simul_addr16, simul_ep1.ep, - mode, amount); - printf("zb_zcl_thermostat_adjust_setpoint ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_MOVE_TO_HUE: - { - unsigned char move_hue = 0x20; - unsigned char COLOR_DIRECTION_SHORTEST = 0x00; - unsigned short trans_time16 = 0x00C8; - - ret = zb_zcl_ccontrol_move_to_hue(handle, simul_addr16, simul_ep1.ep, - move_hue, COLOR_DIRECTION_SHORTEST, trans_time16); - printf("zb_zcl_ccontrol_move_to_hue ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_MOVE_HUE: - { - unsigned char COLOR_MOVE_MODE_DOWN = 0x03; - unsigned char color_rate = 2; - - ret = zb_zcl_ccontrol_move_hue(handle, simul_addr16, simul_ep1.ep, - COLOR_MOVE_MODE_DOWN, color_rate); - printf("zb_zcl_ccontrol_move_hue ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_STEP_HUE: - { - unsigned char COLOR_STEP_MODE_DOWN = 0x03; - unsigned char step_size = 0x20; - unsigned char trans_time8 = 0x0A; - - ret = zb_zcl_ccontrol_step_hue(handle, simul_addr16, simul_ep1.ep, - COLOR_STEP_MODE_DOWN, step_size, trans_time8); - printf("zb_zcl_ccontrol_step_hue ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_MOVE_TO_SATURATION: - { - unsigned char saturation = 0x0A; - unsigned short trans_time16 = 0x00C8; - - ret = zb_zcl_ccontrol_move_to_saturation(handle, simul_addr16, simul_ep1.ep, - saturation, trans_time16); - printf("zb_zcl_ccontrol_move_to_saturation ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_MOVE_SATURATION: - { - unsigned char COLOR_MOVE_MODE_DOWN = 0x03; - unsigned char color_rate = 2; - - ret = zb_zcl_ccontrol_move_saturation(handle, simul_addr16, simul_ep1.ep, - COLOR_MOVE_MODE_DOWN, color_rate); - printf("zb_zcl_ccontrol_move_saturation ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_STEP_SATURATION: - { - unsigned char COLOR_STEP_MODE_DOWN = 0x03; - unsigned char step_size = 0x20; - unsigned char trans_time8 = 0x0A; - - ret = zb_zcl_ccontrol_step_saturation(handle, simul_addr16, simul_ep1.ep, - COLOR_STEP_MODE_DOWN, step_size, trans_time8); - printf("zb_zcl_ccontrol_step_saturation ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_MOVE_TO_HUE_AND_SATURATION: - { - unsigned char move_hue = 0x20; - unsigned char saturation = 0x0A; - unsigned short trans_time16 = 0x00C8; - - ret = zb_zcl_ccontrol_move_to_hue_and_saturation(handle, simul_addr16, simul_ep1.ep, - move_hue, saturation, trans_time16); - printf("zb_zcl_ccontrol_move_to_hue_and_saturation ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_MOVE_TO_COLOR: - { - unsigned short color_x = 0x280A; - unsigned short color_y = 0x2710; - unsigned short trans_time16 = 0x00C8; - - ret = zb_zcl_ccontrol_move_to_color(handle, simul_addr16, simul_ep1.ep, - color_x, color_y, trans_time16); - printf("zb_zcl_ccontrol_move_to_color ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_MOVE_COLOR: - { - unsigned short rate_x = 0x0002; - unsigned short rate_y = 0x0002; - - ret = zb_zcl_ccontrol_move_color(handle, simul_addr16, simul_ep1.ep, - rate_x, rate_y); - printf("zb_zcl_ccontrol_move_color ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_STEP_COLOR: - { - unsigned short step_x = 0x3961; - unsigned short step_y = 0x396D; - unsigned short trans_time16 = 0x00C8; - - ret = zb_zcl_ccontrol_step_color(handle, simul_addr16, simul_ep1.ep, - step_x, step_y, trans_time16); - printf("zb_zcl_ccontrol_step_color ret=[0x%x]\n", ret); - break; - } - case CMD_COLORCONTROL_MOVE_COLOR_TEMPERATURE: - { - unsigned char color_temp = 0x78; - unsigned short trans_time16 = 0x00C8; - - ret = zb_zcl_ccontrol_move_to_color_temperature(handle, simul_addr16, simul_ep1.ep, - color_temp, trans_time16); - printf("zb_zcl_ccontrol_move_to_color_temperature ret=[0x%x]\n", ret); - break; - } - default: - usage_full(); - break; - } -} - -static gboolean test_terminal_read_std_input(GIOChannel * source, - GIOCondition condition, gpointer user_data) -{ - int fd = 0; - - static char buf[1024]; - static char errbuf[1024]; - int n; - - errno = 0; - n = read(fd, buf, 1024); - - buf[n - 1] = '\0'; /* remove new line... */ - if (n == 0) { - printf("Error: read() from stdin returns 0.\n"); - } else if (n < 0) { - strerror_r(errno, errbuf, strlen(errbuf)); - printf("input: read, err=%s\n", errbuf); - } else { - printf("\n\n"); - /* printf("Read [%d]bytes data: [%s]\n", n, buf); */ - /* printf("Processing it ---------------------\n", n, buf); */ - } - - process_input(buf, user_data); - - return TRUE; -} - -int main(int argc, char **argv) -{ - GMainLoop *main_loop; - struct appdata *ad = NULL; - -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif -#if !GLIB_CHECK_VERSION(2, 31, 0) - g_thread_init(NULL); -#endif - - main_loop = g_main_loop_new(NULL, FALSE); - ad = (struct appdata *)malloc(sizeof(struct appdata)); - ad->main_loop = main_loop; - ad->peer_count = 0; - set_appdata(ad); -#if 0 - int r = get_param(argc, argv, ad); - if (r) - return -1; -#endif - - /* Get destination network address into simul_addr - * : Network address of simulator is changed for each thing item. */ - if (argc == 2) { - simul_addr16 = (nwk_addr)strtol(argv[1], NULL, 16); - printf("Network Address : [0x%X]\n\n", simul_addr16); - } - - int std_input_fd = 0; - GIOChannel *gio2 = g_io_channel_unix_new(std_input_fd); - g_io_add_watch(gio2, G_IO_IN, (GIOFunc) test_terminal_read_std_input, ad); - g_io_channel_unref(gio2); - - usage_full(); - - g_main_loop_run(main_loop); - g_main_loop_unref(main_loop); - - return 0; -} diff --git a/test/test-zigbee.h b/test/test-zigbee.h deleted file mode 100644 index dfb7c46..0000000 --- a/test/test-zigbee.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - -#ifndef __TIZEN_NETWORK_ZIGBEE_UNIT_TEST_H__ -#define __TIZEN_NETWORK_ZIGBEE_UNIT_TEST_H__ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* TEST_NETWORK_ZIGBEE_UNIT_TEST_H__ */ diff --git a/test/zcl-cluster-alarm.c b/test/zcl-cluster-alarm.c deleted file mode 100644 index 180eefd..0000000 --- a/test/zcl-cluster-alarm.c +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; - -static char data_alarm_code[MENU_DATA_SIZE + 1] = "1"; - -static void zigbee_zcl_alarm_get_alarm_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned char alarm_code, unsigned short cluster_id, - unsigned int time_stamp, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_alarm_get_alarm_rsp()"); - - msg(" Network Address = 0x%04X status = 0x%02X", addr16, status); - msg(" End-Point = 0x%02X", ep); - msg(" alarm_code = 0x%02X", alarm_code); - msg(" cluster_id = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - msg(" time_stamp = 0x%08X", time_stamp); -} - -static int run_alarm_reset_alarm(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char alarm_code = 0x01; - - if (strlen(data_alarm_code)) - alarm_code = (unsigned char)strtol(data_alarm_code, NULL, 10); - - ret = zb_zcl_alarm_reset_alarm(handle, dest_addr16, 1, alarm_code, - ZB_ZCL_ON_OFF_CLUSTER_ID); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_alarm_reset_alarm(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_alarm_reset_alarm() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_alarm_reset_all_alarm(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_alarm_reset_all_alarm(handle, dest_addr16, 1); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_alarm_reset_all_alarm(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_alarm_reset_all_alarm() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_alarm_get_alarm(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_alarm_get_alarm(handle, dest_addr16, 1, - zigbee_zcl_alarm_get_alarm_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_alarm_get_alarm(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_alarm_get_alarm() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_alarm_reset_all_alarm_log(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_alarm_reset_all_alarm_log(handle, dest_addr16, 1); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_alarm_reset_all_alarm_log(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_alarm_reset_all_alarm_log() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_alarm_code[] = { - { "1", "Alarm code", NULL, NULL, data_alarm_code }, - { "2", "Run", NULL, run_alarm_reset_alarm, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_alarm[] = { - { "1", "zb_zcl_alarm_reset_alarm", - _menu_alarm_code, NULL, NULL }, - { "2", "zb_zcl_alarm_reset_all_alarm", - NULL, run_alarm_reset_all_alarm, NULL }, - { "3", "zb_zcl_alarm_get_alarm", - NULL, run_alarm_get_alarm, NULL }, - { "4", "zb_zcl_alarm_reset_all_alarm_log", - NULL, run_alarm_reset_all_alarm_log, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-basic.c b/test/zcl-cluster-basic.c deleted file mode 100644 index 49943d4..0000000 --- a/test/zcl-cluster-basic.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s st_ep1; - -static int run_reset_factory_default(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_basic_reset_factory_default(handle, dest_addr16, st_ep1.ep); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_basic_reset_factory_default(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_basic_reset_factory_default() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_reset_factory_default[] = { - { "1", "Run", NULL, run_reset_factory_default, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_basic[] = { - { "1", "zb_zcl_basic_reset_factory_default", - _menu_reset_factory_default, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-colorctrl.c b/test/zcl-cluster-colorctrl.c deleted file mode 100644 index a56e4a5..0000000 --- a/test/zcl-cluster-colorctrl.c +++ /dev/null @@ -1,442 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s huebulb_ep1; - -static char data_hue[MENU_DATA_SIZE + 1] = "32"; -static char data_rate[MENU_DATA_SIZE + 1] = "2"; -static char data_trans_time16[MENU_DATA_SIZE + 1] = "200"; -static char data_trans_time8[MENU_DATA_SIZE + 1] = "10"; -static char data_direction[MENU_DATA_SIZE + 1] = "0"; -static char data_move_mode[MENU_DATA_SIZE + 1] = "3"; -static char data_step_mode[MENU_DATA_SIZE + 1] = "3"; -static char data_step_size[MENU_DATA_SIZE + 1] = "32"; -static char data_saturation[MENU_DATA_SIZE + 1] = "10"; -static char data_color_x[MENU_DATA_SIZE + 1] = "10250"; -static char data_color_y[MENU_DATA_SIZE + 1] = "10000"; -static char data_rate_x[MENU_DATA_SIZE + 1] = "2"; -static char data_rate_y[MENU_DATA_SIZE + 1] = "2"; -static char data_step_x[MENU_DATA_SIZE + 1] = "14689"; -static char data_step_y[MENU_DATA_SIZE + 1] = "14701"; -static char data_color_temperature[MENU_DATA_SIZE + 1] = "120"; - -static int run_move_to_hue(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char move_hue = 0x20; - unsigned char direction = 0x00; /* Shortest distance */ - unsigned short trans_time16 = 0x00C8; - - if (strlen(data_hue)) - move_hue = (unsigned char)strtol(data_hue, NULL, 10); - if (strlen(data_direction)) - direction = (unsigned char)strtol(data_direction, NULL, 10); - if (strlen(data_trans_time16)) - trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); - - ret = zb_zcl_ccontrol_move_to_hue(handle, dest_addr16, huebulb_ep1.ep, - move_hue, direction, trans_time16); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_move_to_hue(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_move_to_hue() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_hue(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char move_mode = 0x03; /* Down */ - unsigned char color_rate = 2; - - if (strlen(data_move_mode)) - move_mode = (unsigned char)strtol(data_move_mode, NULL, 10); - if (strlen(data_rate)) - color_rate = (unsigned char)strtol(data_rate, NULL, 10); - - ret = zb_zcl_ccontrol_move_hue(handle, dest_addr16, huebulb_ep1.ep, - move_mode, color_rate); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_move_hue(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_move_hue() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_step_hue(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char step_mode = 0x03; /* Down */ - unsigned char step_size = 0x20; - unsigned char trans_time8 = 0x0A; - - if (strlen(data_step_mode)) - step_mode = (unsigned char)strtol(data_step_mode, NULL, 10); - if (strlen(data_step_size)) - step_size = (unsigned char)strtol(data_step_size, NULL, 10); - if (strlen(data_trans_time8)) - trans_time8 = (unsigned char)strtol(data_trans_time8, NULL, 10); - - ret = zb_zcl_ccontrol_step_hue(handle, dest_addr16, huebulb_ep1.ep, - step_mode, step_size, trans_time8); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_step_hue(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_step_hue() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_to_saturation(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char saturation = 0x0A; - unsigned short trans_time16 = 0x00C8; - - if (strlen(data_saturation)) - saturation = (unsigned char)strtol(data_saturation, NULL, 10); - if (strlen(data_trans_time16)) - trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); - - ret = zb_zcl_ccontrol_move_to_saturation(handle, dest_addr16, huebulb_ep1.ep, - saturation, trans_time16); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_move_to_saturation(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_move_to_saturation() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_saturation(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char move_mode = 0x03; /* Down */ - unsigned char color_rate = 2; - - if (strlen(data_move_mode)) - move_mode = (unsigned char)strtol(data_move_mode, NULL, 10); - if (strlen(data_rate)) - color_rate = (unsigned char)strtol(data_rate, NULL, 10); - - ret = zb_zcl_ccontrol_move_saturation(handle, dest_addr16, huebulb_ep1.ep, - move_mode, color_rate); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_move_saturation(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_move_saturation() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_step_saturation(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char step_mode = 0x03; /* Down */ - unsigned char step_size = 0x20; - unsigned char trans_time8 = 0x0A; - - if (strlen(data_step_mode)) - step_mode = (unsigned char)strtol(data_step_mode, NULL, 10); - if (strlen(data_step_size)) - step_size = (unsigned char)strtol(data_step_size, NULL, 10); - if (strlen(data_trans_time8)) - trans_time8 = (unsigned char)strtol(data_trans_time8, NULL, 10); - - ret = zb_zcl_ccontrol_step_saturation(handle, dest_addr16, huebulb_ep1.ep, - step_mode, step_size, trans_time8); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_step_saturation(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_step_saturation() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_to_hue_and_saturation(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char move_hue = 0x20; - unsigned char saturation = 0x0A; - unsigned short trans_time16 = 0x00C8; - - if (strlen(data_hue)) - move_hue = (unsigned char)strtol(data_hue, NULL, 10); - if (strlen(data_saturation)) - saturation = (unsigned char)strtol(data_saturation, NULL, 10); - if (strlen(data_trans_time16)) - trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); - - ret = zb_zcl_ccontrol_move_to_hue_and_saturation(handle, dest_addr16, - huebulb_ep1.ep, move_hue, saturation, trans_time16); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_move_to_hue_and_saturation(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_move_to_hue_and_saturation() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_to_color(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short color_x = 0x280A; - unsigned short color_y = 0x2710; - unsigned short trans_time16 = 0x00C8; - - if (strlen(data_color_x)) - color_x = (unsigned short)strtol(data_color_x, NULL, 10); - if (strlen(data_color_y)) - color_y = (unsigned short)strtol(data_color_y, NULL, 10); - if (strlen(data_trans_time16)) - trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); - - ret = zb_zcl_ccontrol_move_to_color(handle, dest_addr16, huebulb_ep1.ep, - color_x, color_y, trans_time16); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_move_to_color(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_move_to_color() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_color(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short rate_x = 0x0002; - unsigned short rate_y = 0x0002; - - if (strlen(data_rate_x)) - rate_x = (unsigned short)strtol(data_rate_x, NULL, 10); - if (strlen(data_rate_y)) - rate_y = (unsigned short)strtol(data_rate_y, NULL, 10); - - ret = zb_zcl_ccontrol_move_color(handle, dest_addr16, huebulb_ep1.ep, - rate_x, rate_y); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_move_color(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_move_color() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_step_color(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short step_x = 0x3961; - unsigned short step_y = 0x396D; - unsigned short trans_time16 = 0x00C8; - - if (strlen(data_step_x)) - step_x = (unsigned short)strtol(data_step_x, NULL, 10); - if (strlen(data_step_y)) - step_y = (unsigned short)strtol(data_step_y, NULL, 10); - if (strlen(data_trans_time16)) - trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); - - ret = zb_zcl_ccontrol_step_color(handle, dest_addr16, huebulb_ep1.ep, - step_x, step_y, trans_time16); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_step_color(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_step_color() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_to_color_temperature(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char color_temp = 0x78; - unsigned short trans_time16 = 0x00C8; - - if (strlen(data_color_temperature)) - color_temp = (unsigned short)strtol(data_color_temperature, NULL, 10); - if (strlen(data_trans_time16)) - trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); - - ret = zb_zcl_ccontrol_move_to_color_temperature(handle, dest_addr16, - huebulb_ep1.ep, color_temp, trans_time16); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_ccontrol_move_to_color_temperature(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_ccontrol_move_to_color_temperature() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_move_to_hue[] = { - { "1", "Hue", NULL, NULL, data_hue }, - { "2", "Direction", NULL, NULL, data_direction }, - { "3", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, - { "4", "Run", NULL, run_move_to_hue, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_hue[] = { - { "1", "Move mode", NULL, NULL, data_move_mode }, - { "2", "Rate", NULL, NULL, data_rate }, - { "3", "Run", NULL, run_move_hue, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_step_hue[] = { - { "1", "Step mode", NULL, NULL, data_step_mode }, - { "2", "Step size", NULL, NULL, data_step_size }, - { "3", "Transition time (1 byte)", NULL, NULL, data_trans_time8 }, - { "4", "Run", NULL, run_step_hue, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_to_saturation[] = { - { "1", "Saturation", NULL, NULL, data_saturation }, - { "2", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, - { "3", "Run", NULL, run_move_to_saturation, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_saturation[] = { - { "1", "Move mode", NULL, NULL, data_move_mode }, - { "2", "Rate", NULL, NULL, data_rate }, - { "3", "Run", NULL, run_move_saturation, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_step_saturation[] = { - { "1", "Step mode", NULL, NULL, data_step_mode }, - { "2", "Step size", NULL, NULL, data_step_size }, - { "3", "Transition time (1 byte)", NULL, NULL, data_trans_time8 }, - { "4", "Run", NULL, run_step_saturation, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_to_hue_and_saturation[] = { - { "1", "Hue", NULL, NULL, data_hue }, - { "2", "Saturation", NULL, NULL, data_saturation }, - { "3", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, - { "4", "Run", NULL, run_move_to_hue_and_saturation, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_to_color[] = { - { "1", "Color X", NULL, NULL, data_color_x }, - { "2", "Color Y", NULL, NULL, data_color_y }, - { "3", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, - { "4", "Run", NULL, run_move_to_color, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_color[] = { - { "1", "Rate X", NULL, NULL, data_rate_x }, - { "2", "Rate Y", NULL, NULL, data_rate_y }, - { "3", "Run", NULL, run_move_color, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_step_color[] = { - { "1", "Step X", NULL, NULL, data_step_x }, - { "2", "Step Y", NULL, NULL, data_step_y }, - { "3", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, - { "4", "Run", NULL, run_step_color, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_to_color_temperature[] = { - { "1", "Color Temperature", NULL, NULL, data_color_temperature }, - { "2", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, - { "3", "Run", NULL, run_move_to_color_temperature, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_colorctrl[] = { - { "1", "zb_zcl_ccontrol_move_to_hue", - _menu_move_to_hue, NULL, NULL }, - { "2", "zb_zcl_ccontrol_move_hue", - _menu_move_hue, NULL, NULL }, - { "3", "zb_zcl_ccontrol_step_hue", - _menu_step_hue, NULL, NULL }, - { "4", "zb_zcl_ccontrol_move_to_saturation", - _menu_move_to_saturation, NULL, NULL }, - { "5", "zb_zcl_ccontrol_move_saturation", - _menu_move_saturation, NULL, NULL }, - { "6", "zb_zcl_ccontrol_step_saturation", - _menu_step_saturation, NULL, NULL }, - { "7", "zb_zcl_ccontrol_move_to_hue_and_saturation", - _menu_move_to_hue_and_saturation, NULL, NULL }, - { "8", "zb_zcl_ccontrol_move_to_color", - _menu_move_to_color, NULL, NULL }, - { "9", "zb_zcl_ccontrol_move_color", - _menu_move_color, NULL, NULL }, - { "10", "zb_zcl_ccontrol_step_color", - _menu_step_color, NULL, NULL }, - { "11", "zb_zcl_ccontrol_move_to_color_temperature", - _menu_move_to_color_temperature, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-group.c b/test/zcl-cluster-group.c deleted file mode 100644 index 18728b7..0000000 --- a/test/zcl-cluster-group.c +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s sj_ep1; - -static char data_group_name[MENU_DATA_SIZE + 1] = "6grpone"; -static char data_group_id[MENU_DATA_SIZE + 1] = "2"; - -static void zigbee_zcl_group_add_group_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_group_add_group_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Group ID = 0x%04X", group_id); -} - -static void zigbee_zcl_group_view_group_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, const char *group_name, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_group_view_group_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Group ID = 0x%04X", group_id); - msg(" Group Name = %s", group_name); -} - -static void zigbee_zcl_group_get_group_membership_rsp(nwk_addr addr16, - unsigned char ep, unsigned char capacity, unsigned char group_count, - unsigned short *group_list, void *user_data) -{ - int i; - - msg(""); - msgp("zigbee_zcl_group_get_group_membership_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" capacity = 0x%02X", capacity); - for (i = 0; i < group_count; i++) - msg(" [%d] group_list = %04X", i, group_list[i]); -} - -static void zigbee_zcl_group_remove_group_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_group_remove_group_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Group ID = 0x%04X", group_id); -} - -static int run_group_add_group(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - - ret = zb_zcl_group_add_group(handle, dest_addr16, sj_ep1.ep, - group_id, data_group_name, zigbee_zcl_group_add_group_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_group_add_group(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_group_add_group() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_group_view_group(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - - ret = zb_zcl_group_view_group(handle, dest_addr16, sj_ep1.ep, - group_id, zigbee_zcl_group_view_group_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_group_view_group(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_group_view_group() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_group_get_group_membership(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_list[2] = { 0x0003, 0x0004 }; - unsigned char group_count = 2; - - ret = zb_zcl_group_get_group_membership(handle, dest_addr16, sj_ep1.ep, - group_count, group_list, - zigbee_zcl_group_get_group_membership_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_group_get_group_membership(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_group_get_group_membership() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_group_remove_group(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - - ret = zb_zcl_group_remove_group(handle, dest_addr16, sj_ep1.ep, - group_id, zigbee_zcl_group_remove_group_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_group_remove_group(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_group_remove_group() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_group_remove_all_group(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_group_remove_all_group(handle, dest_addr16, sj_ep1.ep); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_group_remove_all_group(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_group_remove_all_group() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_group_add_group_if_identifying(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - - ret = zb_zcl_group_add_group_if_identifying(handle, dest_addr16, sj_ep1.ep, - group_id, data_group_name); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_group_add_group_if_identifying(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_group_add_group_if_identifying() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_group_add_group[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Group name", NULL, NULL, data_group_name }, - { "3", "Run", NULL, run_group_add_group, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_group_view_group[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Run", NULL, run_group_view_group, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_group_get_group_membership[] = { - { "1", "Run", NULL, run_group_get_group_membership, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_group_remove_group[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Run", NULL, run_group_remove_group, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_group_remove_all_group[] = { - { "1", "Run", NULL, run_group_remove_all_group, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_group_add_group_if_identifying[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Group name", NULL, NULL, data_group_name }, - { "3", "Run", NULL, run_group_add_group_if_identifying, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_group[] = { - { "1", "zb_zcl_group_add_group", - _menu_group_add_group, NULL, NULL }, - { "2", "zb_zcl_group_view_group", - _menu_group_view_group, NULL, NULL }, - { "3", "zb_zcl_group_get_group_membership", - _menu_group_get_group_membership, NULL, NULL }, - { "4", "zb_zcl_group_remove_group", - _menu_group_remove_group, NULL, NULL }, - { "5", "zb_zcl_group_remove_all_group", - _menu_group_remove_all_group, NULL, NULL }, - { "6", "zb_zcl_group_add_group_if_identifying", - _menu_group_add_group_if_identifying, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-ias-zone.c b/test/zcl-cluster-ias-zone.c deleted file mode 100644 index c3570f9..0000000 --- a/test/zcl-cluster-ias-zone.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s sj_ep1; - -static char data_enroll_response_code[MENU_DATA_SIZE + 1] = "10"; -static char data_zone_id[MENU_DATA_SIZE + 1] = "77"; - -static int run_enroll_response(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char enroll_response_code = 10; - unsigned char zone_id = 10; - - if (strlen(data_enroll_response_code)) - enroll_response_code = (unsigned short)strtol(data_enroll_response_code, NULL, 10); - - if (strlen(data_zone_id)) - zone_id = (unsigned short)strtol(data_zone_id, NULL, 10); - - ret = zb_zcl_zone_enroll_response(handle, dest_addr16, sj_ep1.ep, - enroll_response_code, zone_id); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_zone_enroll_response(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_zone_enroll_response() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_enroll_response[] = { - { "1", "Enroll response time", NULL, NULL, data_enroll_response_code }, - { "2", "Zone ID", NULL, NULL, data_zone_id }, - { "3", "Run", NULL, run_enroll_response, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_ias_zone[] = { - { "1", "zb_zcl_enroll_response", _menu_enroll_response, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-identity.c b/test/zcl-cluster-identity.c deleted file mode 100644 index 437dbf1..0000000 --- a/test/zcl-cluster-identity.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s sj_ep1; - -static char data_identify_time[MENU_DATA_SIZE + 1] = "10"; - -static void zigbee_zcl_identify_query_cb(nwk_addr addr16, - unsigned short identify_time, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_identify_query_cb()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" identify_time = %d", identify_time); -} - -static int run_identify(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short identify_time = 10; - - if (strlen(data_identify_time)) - identify_time = (unsigned short)strtol(data_identify_time, NULL, 10); - - ret = zb_zcl_identify(handle, dest_addr16, sj_ep1.ep, identify_time); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_identify(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_identify() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_identify_query(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_identify_query(handle, dest_addr16, sj_ep1.ep, - zigbee_zcl_identify_query_cb, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_identify_query(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_identify_query() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_identify[] = { - { "1", "Identify time", NULL, NULL, data_identify_time }, - { "2", "Run", NULL, run_identify, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_identity[] = { - { "1", "zb_zcl_identify", _menu_identify, NULL, NULL }, - { "2", "zb_zcl_identify_query", NULL, run_identify_query, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-levelctrl.c b/test/zcl-cluster-levelctrl.c deleted file mode 100644 index 6d7a66d..0000000 --- a/test/zcl-cluster-levelctrl.c +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s dimmer_ep1; - -static char data_level[MENU_DATA_SIZE + 1] = "100"; -static char data_time[MENU_DATA_SIZE + 1] = "10"; -static char data_rate[MENU_DATA_SIZE + 1] = "255"; -static char data_move_mode[MENU_DATA_SIZE + 1] = "0"; -static char data_step_mode[MENU_DATA_SIZE + 1] = "0"; -static char data_step_size[MENU_DATA_SIZE + 1] = "16"; - -static int run_move_to_level(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char level = 100; - unsigned short transition_time = 10; - - if (strlen(data_level)) - level = (unsigned char)strtol(data_level, NULL, 10); - if (strlen(data_time)) - transition_time = (unsigned short)strtol(data_time, NULL, 10); - - ret = zb_zcl_levelctrl_move_to_level(handle, dest_addr16, dimmer_ep1.ep, - level, transition_time); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_levelctrl_move_to_level(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_levelctrl_move_to_level() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char move_mode = 0x00; - unsigned char rate = 0xFF; - - if (strlen(data_move_mode)) - move_mode = (unsigned char)strtol(data_move_mode, NULL, 10); - if (strlen(data_rate)) - rate = (unsigned char)strtol(data_rate, NULL, 10); - - ret = zb_zcl_levelctrl_move(handle, dest_addr16, dimmer_ep1.ep, - move_mode, rate); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_levelctrl_move(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_levelctrl_move() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_step(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char step_mode = 0x00; /* Up */ - unsigned char step_size = 0x10; - unsigned short transition_time = 10; - - if (strlen(data_step_mode)) - step_mode = (unsigned char)strtol(data_step_mode, NULL, 10); - if (strlen(data_step_size)) - step_size = (unsigned char)strtol(data_step_size, NULL, 10); - if (strlen(data_time)) - transition_time = (unsigned short)strtol(data_time, NULL, 10); - - ret = zb_zcl_levelctrl_step(handle, dest_addr16, dimmer_ep1.ep, - step_mode, step_size, transition_time); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_levelctrl_step(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_levelctrl_step() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_stop(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_levelctrl_stop(handle, dest_addr16, dimmer_ep1.ep); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_levelctrl_stop(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_levelctrl_stop() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_with_on_off(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char move_mode = 0x00; /* Up */ - unsigned char rate = 10; - - if (strlen(data_move_mode)) - move_mode = (unsigned char)strtol(data_move_mode, NULL, 10); - if (strlen(data_rate)) - rate = (unsigned char)strtol(data_rate, NULL, 10); - - ret = zb_zcl_levelctrl_move_with_on_off(handle, dest_addr16, dimmer_ep1.ep, - move_mode, rate); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_levelctrl_move_with_on_off(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_levelctrl_move_with_on_off() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_move_to_level_with_on_off(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char level = 100; - unsigned short transition_time = 10; - - if (strlen(data_level)) - level = (unsigned char)strtol(data_level, NULL, 10); - if (strlen(data_time)) - transition_time = (unsigned short)strtol(data_time, NULL, 10); - - ret = zb_zcl_levelctrl_move_to_level_with_on_off(handle, dest_addr16, - dimmer_ep1.ep, level, transition_time); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_levelctrl_move_to_level_with_on_off(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_levelctrl_move_to_level_with_on_off() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_step_with_on_off(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char step_mode = 0x00; /* Up */ - unsigned char step_size = 0x10; - unsigned short transition_time = 10; - - if (strlen(data_step_mode)) - step_mode = (unsigned char)strtol(data_step_mode, NULL, 10); - if (strlen(data_step_size)) - step_size = (unsigned char)strtol(data_step_size, NULL, 10); - if (strlen(data_time)) - transition_time = (unsigned short)strtol(data_time, NULL, 10); - - ret = zb_zcl_levelctrl_step_with_on_off(handle, dest_addr16, dimmer_ep1.ep, - step_mode, step_size, transition_time); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_levelctrl_step_with_on_off(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_levelctrl_step_with_on_off() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_move_to_level[] = { - { "1", "Level", NULL, NULL, data_level }, - { "2", "Transition Time", NULL, NULL, data_time }, - { "3", "Run", NULL, run_move_to_level, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move[] = { - { "1", "Move mode", NULL, NULL, data_move_mode }, - { "2", "Rate", NULL, NULL, data_rate }, - { "3", "Run", NULL, run_move, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_step[] = { - { "1", "Step mode", NULL, NULL, data_step_mode }, - { "2", "Step size", NULL, NULL, data_step_size }, - { "3", "Transition Time", NULL, NULL, data_time }, - { "4", "Run", NULL, run_step, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_stop[] = { - { "1", "Run", NULL, run_stop, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_with_onoff[] = { - { "1", "Move mode", NULL, NULL, data_move_mode }, - { "2", "Rate", NULL, NULL, data_rate }, - { "3", "Run", NULL, run_move_with_on_off, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_move_to_level_with_onoff[] = { - { "1", "Level", NULL, NULL, data_level }, - { "2", "Transition Time", NULL, NULL, data_time }, - { "3", "Run", NULL, run_move_to_level_with_on_off, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_step_with_onoff[] = { - { "1", "Step mode", NULL, NULL, data_step_mode }, - { "2", "Step size", NULL, NULL, data_step_size }, - { "3", "Transition Time", NULL, NULL, data_time }, - { "4", "Run", NULL, run_step_with_on_off, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_levelctrl[] = { - { "1", "zb_zcl_levelctrl_move_to_level", - _menu_move_to_level, NULL, NULL }, - { "2", "zb_zcl_levelctrl_move", _menu_move, NULL, NULL }, - { "3", "zb_zcl_levelctrl_step", _menu_step, NULL, NULL }, - { "4", "zb_zcl_levelctrl_stop", _menu_stop, NULL, NULL }, - { "5", "zb_zcl_levelctrl_move_with_on_off", - _menu_move_with_onoff, NULL, NULL }, - { "6", "zb_zcl_levelctrl_move_to_level_with_on_off", - _menu_move_to_level_with_onoff, NULL, NULL }, - { "7", "zb_zcl_levelctrl_step_with_on_off", - _menu_step_with_onoff, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-onoff.c b/test/zcl-cluster-onoff.c deleted file mode 100644 index 3bd254a..0000000 --- a/test/zcl-cluster-onoff.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s sj_ep1; - -static int run_on(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_onoff_control(handle, dest_addr16, sj_ep1.ep, ZB_ZCL_ON); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_onoff_control(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_onoff_control() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_off(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_onoff_control(handle, dest_addr16, sj_ep1.ep, ZB_ZCL_OFF); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_onoff_control(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_onoff_control() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_toggle(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_onoff_control(handle, dest_addr16, sj_ep1.ep, ZB_ZCL_TOGGLE); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_onoff_control(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_onoff_control() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data menu_zcl_cluster_onoff_control[] = { - { "1", "On", NULL, run_on, NULL }, - { "2", "Off", NULL, run_off, NULL }, - { "3", "Toggle", NULL, run_toggle, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_onoff[] = { - { "1", "zb_zcl_onoff_control", - menu_zcl_cluster_onoff_control, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-pollctrl.c b/test/zcl-cluster-pollctrl.c deleted file mode 100644 index 778575c..0000000 --- a/test/zcl-cluster-pollctrl.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s sj_ep1; - -static char data_poll_state[MENU_DATA_SIZE + 1] = "1"; -static char data_poll_timeout[MENU_DATA_SIZE + 1] = "100"; -static char data_long_interval[MENU_DATA_SIZE + 1] = "200"; -static char data_short_interval[MENU_DATA_SIZE + 1] = "5"; - -static void zigbee_zcl_poll_control_check_in(nwk_addr addr16, unsigned char ep, - void *user_data) -{ - msg(""); - msgp("zigbee_zcl_poll_control_check_in()"); - - msg(" Network Address = 0x%04X End-Point = 0x%02X", addr16, ep); -} - -static int run_check_in_response(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char start_fast_polling = 1; /* True */ - unsigned short fast_poll_timeout = 100; - - if (strncmp(data_poll_state, "0", MENU_DATA_SIZE) == 0) - start_fast_polling = 0; /* False */ - if (strlen(data_poll_timeout)) - fast_poll_timeout = (unsigned short)strtol(data_poll_timeout, NULL, 10); - - ret = zb_zcl_pollctrl_check_in_response(handle, dest_addr16, sj_ep1.ep, - start_fast_polling, fast_poll_timeout); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_pollctrl_check_in_response(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_pollctrl_check_in_response() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_fast_poll_stop(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zcl_pollctrl_fast_poll_stop(handle, dest_addr16, sj_ep1.ep); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_pollctrl_fast_poll_stop(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_pollctrl_fast_poll_stop() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_set_long_poll_interval(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned int long_poll_interval = 200; - - if (strlen(data_long_interval)) - long_poll_interval = (unsigned short)strtol(data_long_interval, NULL, 10); - - ret = zb_zcl_pollctrl_set_long_poll_interval(handle, dest_addr16, sj_ep1.ep, - long_poll_interval, zigbee_zcl_poll_control_check_in, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_pollctrl_set_long_poll_interval(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_pollctrl_set_long_poll_interval() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_set_short_poll_interval(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned int short_poll_interval = 5; - - if (strlen(data_short_interval)) - short_poll_interval = (unsigned short)strtol(data_short_interval, NULL, 10); - - ret = zb_zcl_pollctrl_set_short_poll_interval(handle, dest_addr16, sj_ep1.ep, - short_poll_interval, zigbee_zcl_poll_control_check_in, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_pollctrl_set_short_poll_interval(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_pollctrl_set_short_poll_interval() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_check_in_response[] = { - { "1", "Start Fast Polling", NULL, NULL, data_poll_state }, - { "2", "Fast poll timeout", NULL, NULL, data_poll_timeout }, - { "3", "Run", NULL, run_check_in_response, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_fast_poll_stop[] = { - { "1", "Run", NULL, run_fast_poll_stop, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_set_long_poll_interval[] = { - { "1", "Long poll interval", NULL, NULL, data_long_interval }, - { "2", "Run", NULL, run_set_long_poll_interval, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_set_short_poll_interval[] = { - { "1", "Short poll interval", NULL, NULL, data_short_interval }, - { "2", "Run", NULL, run_set_short_poll_interval, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_pollctrl[] = { - { "1", "zb_zcl_pollctrl_check_in_response", - _menu_check_in_response, NULL, NULL }, - { "2", "zb_zcl_pollctrl_fast_poll_stop", - _menu_fast_poll_stop, NULL, NULL }, - { "3", "zb_zcl_pollctrl_set_long_poll_interval", - _menu_set_long_poll_interval, NULL, NULL }, - { "4", "zb_zcl_pollctrl_set_short_poll_interval", - _menu_set_short_poll_interval, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-scene.c b/test/zcl-cluster-scene.c deleted file mode 100644 index 23a992f..0000000 --- a/test/zcl-cluster-scene.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s sj_ep1; - -static char data_group_id[MENU_DATA_SIZE + 1] = "2"; -static char data_scene_id[MENU_DATA_SIZE + 1] = "1"; -static char data_trans_time[MENU_DATA_SIZE + 1] = "0"; -static char data_scene_name[MENU_DATA_SIZE + 1] = "6scnone"; - -static void zigbee_zcl_scene_add_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_scene_add_scene_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Group ID = 0x%04X", group_id); - msg(" Scene ID = 0x%02X", scene_id); -} - -static void zigbee_zcl_scene_view_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, unsigned char scene_id, - unsigned short transition_time, const char *scene_name, - const char *extension_field_set, unsigned short ext_len, void *user_data) -{ - int i; - msg(""); - msgp("zigbee_zcl_scene_view_scene_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Group ID = 0x%04X", group_id); - msg(" Scene ID = 0x%02X", scene_id); - msg(" Transition Time = 0x%04X", transition_time); - msg(" Scene Name = %s\n", scene_name); - for (i = 0; i < ext_len; i++) - msg(" extension_field_set[%d] = 0x%02X", i, extension_field_set[i]); -} - -static void zigbee_zcl_scene_remove_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_scene_remove_scene_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Group ID = 0x%04X", group_id); - msg(" Scene ID = 0x%02X", scene_id); -} - -static void zigbee_zcl_scene_remove_all_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_scene_remove_all_scene_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Group ID = 0x%04X", group_id); -} - -static void zigbee_zcl_scene_store_scene_rsp(nwk_addr addr16, unsigned char ep, - unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) -{ - msg(""); - msgp("zigbee_zcl_scene_store_scene_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Group ID = 0x%04X", group_id); - msg(" Scene ID = 0x%02X", scene_id); -} - -static void zigbee_zcl_scene_get_scene_membership_rsp(nwk_addr addr16, - unsigned char ep, unsigned char status, unsigned char capacity, unsigned short group_id, - unsigned char scene_count, unsigned char *scene_list, void *user_data) -{ - int i; - - msg(""); - msgp("zigbee_zcl_scene_get_scene_membership_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - msg(" Capacity = 0x%02X", capacity); - msg(" Group ID = 0x%02X", group_id); - for (i = 0; i < scene_count && ZB_ZCL_SUCCESS == status; i++) - msg(" scene_list[%d] = 0x%02X", i, scene_list[i]); -} - -static int run_scene_add_scene(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - unsigned short trans_time = 0x0000; - const char ext_field_set[] = {0x00, 0x06, 0x01, 0x00}; - unsigned short ext_len = sizeof(ext_field_set) / sizeof(ext_field_set[0]); - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - if (strlen(data_scene_id)) - scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); - - ret = zb_zcl_scene_add_scene(handle, dest_addr16, - sj_ep1.ep, group_id, scene_id, trans_time, data_scene_name, - ext_len, ext_field_set, zigbee_zcl_scene_add_scene_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_scene_add_scene(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_scene_add_scene() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_scene_view_scene(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - if (strlen(data_scene_id)) - scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); - - ret = zb_zcl_scene_view_scene(handle, dest_addr16, sj_ep1.ep, group_id, - scene_id, zigbee_zcl_scene_view_scene_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_scene_view_scene(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_scene_view_scene() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_scene_get_scene_membership(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - - ret = zb_zcl_scene_get_scene_membership(handle, dest_addr16, sj_ep1.ep, - group_id, zigbee_zcl_scene_get_scene_membership_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_scene_get_scene_membership(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_scene_get_scene_membership() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_scene_remove_scene(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - if (strlen(data_scene_id)) - scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); - - ret = zb_zcl_scene_remove_scene(handle, dest_addr16, sj_ep1.ep, group_id, - scene_id, zigbee_zcl_scene_remove_scene_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_scene_remove_scene(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_scene_remove_scene() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_scene_remove_all_scene(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - - ret = zb_zcl_scene_remove_all_scene(handle, dest_addr16, sj_ep1.ep, group_id, - zigbee_zcl_scene_remove_all_scene_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_scene_remove_all_scene(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_scene_remove_all_scene() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_scene_store_scene(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - if (strlen(data_scene_id)) - scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); - - ret = zb_zcl_scene_store_scene(handle, dest_addr16, sj_ep1.ep, group_id, - scene_id, zigbee_zcl_scene_store_scene_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_scene_store_scene(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_scene_store_scene() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_scene_recall_scene(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short group_id = 0x0002; - unsigned char scene_id = 0x01; - - if (strlen(data_group_id)) - group_id = (unsigned short)strtol(data_group_id, NULL, 10); - if (strlen(data_scene_id)) - scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); - - ret = zb_zcl_scene_recall_scene(handle, dest_addr16, sj_ep1.ep, - group_id, scene_id); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_scene_recall_scene(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_scene_recall_scene() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_add_scene[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Scene ID", NULL, NULL, data_scene_id }, - { "3", "Transition time", NULL, NULL, data_trans_time }, - { "4", "Scene name", NULL, NULL, data_scene_name }, - { "5", "Run", NULL, run_scene_add_scene, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_view_scene[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Scene ID", NULL, NULL, data_scene_id }, - { "3", "Run", NULL, run_scene_view_scene, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_get_scene_membership[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Run", NULL, run_scene_get_scene_membership, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_remove_scene[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Scene ID", NULL, NULL, data_scene_id }, - { "3", "Run", NULL, run_scene_remove_scene, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_remove_all_scene[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Run", NULL, run_scene_remove_all_scene, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_store_scene[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Scene ID", NULL, NULL, data_scene_id }, - { "3", "Run", NULL, run_scene_store_scene, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_recall_scene[] = { - { "1", "Group ID", NULL, NULL, data_group_id }, - { "2", "Scene ID", NULL, NULL, data_scene_id }, - { "3", "Run", NULL, run_scene_recall_scene, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_scene[] = { - { "1", "zb_zcl_scene_add_scene", - _menu_add_scene, NULL, NULL }, - { "2", "zb_zcl_scene_view_scene", - _menu_view_scene, NULL, NULL }, - { "3", "zb_zcl_scene_get_scene_membership", - _menu_get_scene_membership, NULL, NULL }, - { "4", "zb_zcl_scene_remove_scene", - _menu_remove_scene, NULL, NULL }, - { "5", "zb_zcl_scene_remove_all_scene", - _menu_remove_all_scene, NULL, NULL }, - { "6", "zb_zcl_scene_store_scene", - _menu_store_scene, NULL, NULL }, - { "7", "zb_zcl_scene_recall_scene", - _menu_recall_scene, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-cluster-thermostat.c b/test/zcl-cluster-thermostat.c deleted file mode 100644 index 76a9c20..0000000 --- a/test/zcl-cluster-thermostat.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern simple_desc_s s_thermostat_ep1; - -static char data_mode[MENU_DATA_SIZE + 1] = "0"; -static char data_amount[MENU_DATA_SIZE + 1] = "1"; - -static int run_adjust_setpoint(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char mode = 0x00; /* HEAT_MODE */ - unsigned char amount = 0x01; - - if (strlen(data_mode)) - mode = (unsigned char)strtol(data_mode, NULL, 10); - if (strlen(data_amount)) - amount = (unsigned char)strtol(data_amount, NULL, 10); - - ret = zb_zcl_thermostat_adjust_setpoint(handle, dest_addr16, - s_thermostat_ep1.ep, mode, amount); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_thermostat_adjust_setpoint(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_thermostat_adjust_setpoint() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_adjust_setpoint[] = { - { "1", "Mode", NULL, NULL, data_mode }, - { "2", "Amount", NULL, NULL, data_amount }, - { "3", "Run", NULL, run_adjust_setpoint, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster_thermostat[] = { - { "1", "zb_zcl_thermostat_adjust_setpoint", - _menu_adjust_setpoint, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl-global-cmd.c b/test/zcl-global-cmd.c deleted file mode 100644 index 2e55b49..0000000 --- a/test/zcl-global-cmd.c +++ /dev/null @@ -1,721 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern struct menu_data menu_zcl_cluster_alarm[]; -extern struct menu_data menu_zcl_cluster_basic[]; -extern struct menu_data menu_zcl_cluster_colorctrl[]; -extern struct menu_data menu_zcl_cluster_group[]; -extern struct menu_data menu_zcl_cluster_identity[]; -extern struct menu_data menu_zcl_cluster_ias_zone[]; -extern struct menu_data menu_zcl_cluster_levelctrl[]; -extern struct menu_data menu_zcl_cluster_onoff[]; -extern struct menu_data menu_zcl_cluster_pollctrl[]; -extern struct menu_data menu_zcl_cluster_scene[]; -extern struct menu_data menu_zcl_cluster_thermostat[]; - -extern zigbee_h handle; - -extern nwk_addr panid; -extern ieee_addr co_addr64; - -extern ieee_addr st_addr64; -extern ieee_addr sj_addr64; - -extern nwk_addr dest_addr16; -extern ieee_addr dest_addr64; - -extern simple_desc_s st_ep1, st_ep2, st_ep3, st_ep4, sj_ep1, simul_ep1; - -static char r_data_cluster_id[MENU_DATA_SIZE + 1] = "6"; -static char r_data_attr_id[MENU_DATA_SIZE + 1] = "0"; -static char w_data_cluster_id[MENU_DATA_SIZE + 1] = "3"; -static char w_data_attr_id[MENU_DATA_SIZE + 1] = "0"; -static char w_data_attr_value[MENU_DATA_SIZE + 1] = "180"; -static char data_min_i[MENU_DATA_SIZE + 1] = "A"; -static char data_max_i[MENU_DATA_SIZE + 1] = "3C"; -static char data_timeout[MENU_DATA_SIZE + 1] = "10"; - -static void zigbee_zcl_global_read_attributes_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, - int records_len, void *user_data) -{ - int count; - unsigned short id; - unsigned char type; - unsigned char status; - unsigned char *buf = NULL; - zb_value_h value = NULL; - read_attr_status_record_h *records; - - msg(""); - msgp("zigbee_zcl_global_read_attributes_rsp()"); - - if (NULL == records_info || ZB_GLOBAL_READ_ATTR != records_info->type - || NULL == records_info->record.read_attr) { - msg("Invalid records info"); - msg("records_info : [%p]", records_info); - if (records_info) { - msg(" type: [%x]", records_info->type); - msg(" type: [%p]", records_info->record.read_attr); - } - return; - } - records = records_info->record.read_attr; - - zb_create_value(&value); - msg(" Cluster ID : 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - msg(" Node ID : 0x%04X", addr16); - msg(" End-Point : 0x%02X", ep); - msg(" Msg length %d", records_len); - - if (records && *records) { - zb_get_id_from_read_attr_status_record(*records, &id); - msg(" Attribute ID : 0x%04X", id); - } - if (records && *records) { - zb_get_type_from_read_attr_status_record(*records, &type); - msg(" Type : 0x%02X", type); - } - if (records && *records) { - zb_get_status_from_read_attr_status_record(*records, &status); - msg(" Status : 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - } - if (records && *records) { - zb_get_value_from_read_attr_status_record(*records, type, value); - if (value) { - zb_get_value(value, &type, &buf, &count); - if (buf) { - msg(" value[0] = 0x%02x", buf[0]); - free(buf); - } - zb_destroy_value(value); - } - } -} - -static void zigbee_zcl_global_write_attributes_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, - int records_len, void *user_data) -{ - unsigned short id = 0; - unsigned char status; - zb_value_h value = NULL; - write_attr_status_record_h *records; - - msg(""); - msgp("zigbee_zcl_global_write_attributes_rsp()"); - - if (NULL == records_info || ZB_GLOBAL_WRITE_ATTR != records_info->type - || NULL == records_info->record.write_attr) { - msg("Invalid records info"); - return; - } - records = records_info->record.write_attr; - - zb_create_value(&value); - msg(" Cluster ID : 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - msg(" Node ID : 0x%04X", addr16); - msg(" End-Point : 0x%02X", ep); - msg(" Msg length %d", records_len); - - if (records) { - if (ZIGBEE_ERROR_NONE == zb_get_id_from_write_attr_status(*records, &id)) - msg(" AttributeId : 0x%04X", id); - } - if (records) { - zb_get_status_from_write_attr_status(*records, &status); - msg(" status : 0x%02X (%s)", status, zb_get_zcl_error_message(status)); - } - zb_destroy_value(value); -} - -static void zigbee_zcl_global_configure_reporting_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, - int records_len, void *user_data) -{ - int i; - unsigned char status; - report_config_response_record_h *records; - - msg(""); - msgp("zigbee_zcl_global_configure_reporting_rsp()"); - - if (NULL == records_info || ZB_GLOBAL_CONFIG_REPORT != records_info->type - || NULL == records_info->record.report_config_rsp) { - msg("Invalid records info"); - return; - } - records = records_info->record.report_config_rsp; - - msg(" records_len=%d", records_len); - for (i = 0; i < records_len; i++) { - zb_get_status_from_report_config_response_record(records[i], &status); - msg(" [%d] status = 0x%02X (%s)", i, status, zb_get_zcl_error_message(status)); - } -} - -static void zigbee_zcl_global_read_reporting_configuration_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, - int records_len, void *user_data) -{ - zb_value_h val; - int i = 0; - int j = 0; - int count; - int ret; - unsigned char type, *buf = NULL; - unsigned short id, max_i, min_i; - report_config_record_h *records; - - msg(""); - msgp("zigbee_zcl_global_read_reporting_configuration_rsp()"); - - if (NULL == records_info || ZB_GLOBAL_READ_REPORT_CONFIG != records_info->type - || NULL == records_info->record.report_config) { - msg("Invalid records info"); - return; - } - - records = records_info->record.report_config; - msg(" cluster_id 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - msg(" nodeId 0x%04X", addr16); - msg(" endpoint 0x%02X", ep); - msg(" Msg length %d", records_len); - - while (i < records_len) { - msg(" records[%d] 0x%08X", i, id); - zb_get_id_from_report_config_record(records[i], &id); - msg(" AttributeId 0x%04X", id); - zb_get_type_from_report_config_record(records[i], &type); - /*if ((zb_get_analog_or_discret(type) == DATA_TYPE_ANALOG)) {*/ - msg(" type 0x%02X", type); - zb_get_max_i_from_report_config_record(records[i], &max_i); - msg(" Max Interval 0x%04X", max_i); - zb_get_min_i_from_report_config_record(records[i], &min_i); - msg(" Min Interval 0x%04X", min_i); - zb_create_value(&val); - zb_get_change_from_report_config_record1(records[i], val); - ret = zb_get_value(val, &type, &buf, &count); - if (ZIGBEE_ERROR_NONE == ret) { - for (j = 0; j < count; j++) - msg(" value[j] = 0x%02x", buf[j]); - } - - if (buf) { - free(buf); - buf = NULL; - } - - msg(""); - zb_destroy_value(val); - /* - } else { - msg("Unsuccessful Attempt\n"); - } - */ - i++; - } -} - -static void zigbee_zcl_global_discover_attributes_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, - discover_attr_info_record_h * records, int records_len, void *user_data) -{ - int i; - unsigned char type; - unsigned short id; - - msg(""); - msgp("zigbee_zcl_global_discover_attributes_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - msg(" discovery_complete = %d", discovery_complete); - - for (i = 0; i < records_len; i++) { - zb_get_type_from_discover_attr_info(records[i], &type); - msg(" [%d] type = 0x%02X", i, type); - zb_get_id_from_discover_attr_info(records[i], &id); - msg(" [%d] id = 0x%04X", i, id); - } -} - -static void zigbee_zcl_global_discover_cmds_received_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, - unsigned char *command_ids, int command_ids_len, void *user_data) -{ - int i; - - msg(""); - msgp("zigbee_zcl_global_discover_cmds_received_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - msg(" discovery_complete = %d", discovery_complete); - - for (i = 0; i < command_ids_len; i++) - msg(" command_id[%d] = 0x%02X", i, command_ids[i]); -} - -static void zigbee_zcl_global_discover_cmds_generated_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, - unsigned char *command_ids, int command_ids_len, void *user_data) -{ - int i; - - msg(""); - msgp("zigbee_zcl_global_discover_cmds_generated_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - msg(" discovery_complete = %d", discovery_complete); - - for (i = 0; i < command_ids_len; i++) - msg(" command_id[%d] = 0x%02X", i, command_ids[i]); -} - -static void zigbee_zcl_global_discover_attr_extended_rsp(nwk_addr addr16, - unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, - extended_attr_info_h *records, unsigned short records_len, void *user_data) -{ - int i; - unsigned char type; - unsigned short id; - unsigned char acl; - - msg(""); - msgp("zigbee_zcl_global_discover_attr_extended_rsp()"); - - msg(" Network Address = 0x%04X", addr16); - msg(" End-Point = 0x%02X", ep); - msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - msg(" discovery_complete = %d", discovery_complete); - - for (i = 0; i < records_len; i++) { - zb_get_id_from_extended_attr_info(records[i], &id); - msg(" [%d] id = 0x%02X", i, id); - zb_get_type_from_extended_attr_info(records[i], &type); - msg(" [%d] type = 0x%04X", i, type); - zb_get_acl_from_extended_attr_info(records[i], &acl); - msg(" [%d] acl = 0x%04X", i, acl); - } -} - -static int run_global_read_attr(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; -#if 0 - /* For SmartThings open/close sensor */ - unsigned short st_cluster_id = ZB_ZCL_IAS_ZONE_CLUSTER_ID; - unsigned short st_attribute_id[] = { - ZB_ZCL_ZONE_STATE_ATTRIBUTE_ID, - ZB_ZCL_ZONE_TYPE_ATTRIBUTE_ID, - ZB_ZCL_ZONE_STATUS_ATTRIBUTE_ID, - ZB_ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID, - ZB_ZCL_ZONE_ID_ATTRIBUTE_ID - }; - - int st_len_of_attr = sizeof(st_attribute_id) / sizeof(st_attribute_id[0]); - /* Reading zone state attribute */ - ret = zb_zcl_global_read_attr(handle, dest_addr16, 1, st_ep1.ep, - -1, st_cluster_id, st_attribute_id, st_len_of_attr, - zigbee_zcl_global_read_attributes_rsp, NULL); -#endif -#if 0 - /* Reading active power report in electrical measurement cluster */ - sj_cluster_id = ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID; - sj_attribute_id[0] = ZB_ZCL_ACTIVE_POWER_ATTRIBUTE_ID; - sj_len_of_attr = 1; - - ret = zb_zcl_global_read_attr(handle, dest_addr16, 1, sj_ep1.ep, - -1, sj_cluster_id, sj_attribute_id, sj_len_of_attr, - zigbee_zcl_global_read_attributes_rsp, NULL); -#endif - - unsigned short cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; - unsigned short attribute_id[] = { - ZB_ZCL_ON_OFF_ATTRIBUTE_ID - }; - int len_of_attr = sizeof(attribute_id) / sizeof(attribute_id[0]); - - if (strlen(r_data_cluster_id)) - cluster_id = (unsigned short)strtol(r_data_cluster_id, NULL, 16); - if (strlen(r_data_attr_id)) - attribute_id[0] = (unsigned short)strtol(r_data_attr_id, NULL, 16); - - ret = zb_zcl_global_read_attr(handle, dest_addr16, 1, 1, - ZB_ZCL_FC_DEFAULT, cluster_id, attribute_id, len_of_attr, - zigbee_zcl_global_read_attributes_rsp, NULL); - - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_read_attr(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_read_attr() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_write_attr(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - /* Samjin Power Outlet */ - write_attr_record_h attr; - - unsigned short cluster_id = ZB_ZCL_IDENTIFY_CLUSTER_ID; - unsigned short attribute_id = ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID; - unsigned short temp; - unsigned char attribute_value[] = {0,}; - - if (strlen(w_data_cluster_id)) - cluster_id = (unsigned short)strtol(w_data_cluster_id, NULL, 16); - if (strlen(w_data_attr_id)) - attribute_id = (unsigned short)strtol(w_data_attr_id, NULL, 16); - if (strlen(w_data_attr_value)) { - temp = (unsigned short)strtol(w_data_attr_value, NULL, 16); - memcpy(attribute_value, &temp, sizeof(unsigned short)); - } - - zb_create_write_attr_record(&attr); - //zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); - zb_set_id_to_write_attr_record(attr, attribute_id); - zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); - zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, attribute_value, - zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); - - ret = zb_zcl_global_write_attr(handle, dest_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, - cluster_id, &attr, 1, - zigbee_zcl_global_write_attributes_rsp, NULL); - zb_destroy_write_attr_record(attr); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_write_attr(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_write_attr() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_write_attr_undivided(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char value[] = { 0x02, 0x01}; - /* Samjin Power Outlet */ - write_attr_record_h attr; - - zb_create_write_attr_record(&attr); - zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); - zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); - zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, value, - zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); - ret = zb_zcl_global_write_attr_undivided(handle, dest_addr16, 1, - sj_ep1.ep, ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, &attr, 1, - zigbee_zcl_global_write_attributes_rsp, NULL); - zb_destroy_write_attr_record(attr); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_write_attr_undivided(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_write_attr_undivided() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_write_attr_no_rsp(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char value[] = { 0x02, 0x01}; - /* Samjin Power Outlet */ - write_attr_record_h attr; - - zb_create_write_attr_record(&attr); - zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); - zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); - zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, value, - zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); - ret = zb_zcl_global_write_attr_no_rsp(handle, dest_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, &attr, 1); - zb_destroy_write_attr_record(attr); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_write_attr_no_rsp(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_write_attr_no_rsp() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_config_report(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - /* Samjin Power Outlet */ - unsigned char val1 = 1; - report_config_record_h config; - unsigned short cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; - unsigned short attribute_id = ZB_ZCL_ON_OFF_ATTRIBUTE_ID; - unsigned short min_i; - unsigned short max_i; - unsigned short timeout; - - if (strlen(r_data_cluster_id)) - cluster_id = (unsigned short)strtol(r_data_cluster_id, NULL, 16); - if (strlen(r_data_attr_id)) - attribute_id = (unsigned short)strtol(r_data_attr_id, NULL, 16); - - if (strlen(data_min_i)) - min_i = (unsigned short)strtol(data_min_i, NULL, 16); - if (strlen(data_max_i)) - max_i = (unsigned short)strtol(data_max_i, NULL, 16); - if (strlen(data_timeout)) - timeout = (unsigned short)strtol(data_timeout, NULL, 10); - - zb_create_report_config_record(&config); - zb_set_dir_to_report_config_record(config, ZB_ZCL_CLIENT_TO_SERVER); - zb_set_id_to_report_config_record(config, attribute_id); - zb_set_type_to_report_config_record(config, ZB_ZCL_BOOLEAN); - zb_set_min_i_to_report_config_record(config, min_i); - zb_set_max_i_to_report_config_record(config, max_i); - zb_set_change_to_report_config_record2(config, ZB_ZCL_BOOLEAN, &val1); - zb_set_timeout_to_report_config_record(config, timeout); - - ret = zb_zcl_global_config_report(handle, dest_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, cluster_id, &config, 1, - zigbee_zcl_global_configure_reporting_rsp, NULL); - zb_destroy_report_config_record(config); -#if 0 - /* ST Open/Close Sensor */ - report_config_record_h config1; - unsigned short val2 = 0x007f; - - zb_create_report_config_record(&config1); - zb_set_dir_to_report_config_record(config1, ZB_ZCL_CLIENT_TO_SERVER); - zb_set_id_to_report_config_record(config1, ZB_ZCL_ZONE_STATE_ATTRIBUTE_ID); - zb_set_type_to_report_config_record(config1, ZB_ZCL_SIGNED_16_BIT_INTEGER); - zb_set_min_i_to_report_config_record(config1, 0); - zb_set_max_i_to_report_config_record(config1, 60); - zb_set_change_to_report_config_record(config1, ZB_ZCL_SIGNED_16_BIT_INTEGER, &val2); - zb_set_timeout_to_report_config_record(config1, 60); - ret = zb_zcl_global_config_report(handle, dest_addr16, 1, st_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID, &config1, 1, - zigbee_zcl_global_configure_reporting_rsp, NULL); - zb_destroy_report_config_record(config1); -#endif - - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_config_report(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_config_report() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_read_config_report(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - read_report_config_record_h read_report_conf; - - zb_create_read_report_config_record(&read_report_conf); - zb_set_dir_to_read_report_config_record(read_report_conf, ZB_ZCL_CLIENT_TO_SERVER); - zb_set_id_to_read_report_config_record(read_report_conf, ZB_ZCL_ON_OFF_ATTRIBUTE_ID); - - /* Samjin Power Outlet */ - ret = zb_zcl_global_read_config_report(handle, dest_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_ON_OFF_CLUSTER_ID, &read_report_conf, 1, - zigbee_zcl_global_read_reporting_configuration_rsp, NULL); - zb_destroy_read_report_config_record(read_report_conf); - - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_read_config_report(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_read_config_report() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_discover_attr(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; -#if 0 - /* For ST Open/Close Sensor */ - ret = zb_zcl_global_discover_attr(handle, dest_addr16, 1, st_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, - 2, zigbee_zcl_global_discover_attributes_rsp, NULL); -#endif - /* For SJ Power Outlet */ - ret = zb_zcl_global_discover_attr(handle, dest_addr16, 1, sj_ep1.ep, - ZB_ZCL_FC_DEFAULT, ZB_ZCL_ON_OFF_CLUSTER_ID, ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, - zigbee_zcl_global_discover_attributes_rsp, NULL); - - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_discover_attr(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_discover_attr() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_discover_cmds_received(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - ret = zb_zcl_global_discover_cmds_received(handle, dest_addr16, 1, sj_ep1.ep, - ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_ON_OFF_CLUSTER_ID, - ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, - zigbee_zcl_global_discover_cmds_received_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_discover_cmds_received(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_discover_cmds_received() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_discover_cmds_generated(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - ret = zb_zcl_global_discover_cmds_generated(handle, dest_addr16, 1, sj_ep1.ep, - ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_GROUPS_CLUSTER_ID, 0x00, 4, - zigbee_zcl_global_discover_cmds_generated_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_discover_cmds_generated(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_discover_cmds_generated() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_global_discover_attr_extended(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - ret = zb_zcl_global_discover_attr_extended(handle, dest_addr16, 1, sj_ep1.ep, - ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_ON_OFF_CLUSTER_ID, - ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, - zigbee_zcl_global_discover_attr_extended_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zcl_global_discover_attr_extended(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zcl_global_discover_attr_extended() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -struct menu_data menu_zcl_global_read_attr[] = { - { "1", "Cluster ID (Hex)", NULL, NULL, r_data_cluster_id }, - { "2", "Attribute ID (Hex)", NULL, NULL, r_data_attr_id }, - { "3", "run", NULL, run_global_read_attr, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_global_write_attr[] = { - { "1", "Cluster ID (Hex)", NULL, NULL, w_data_cluster_id }, - { "2", "Attribute ID (Hex)", NULL, NULL, w_data_attr_id }, - { "3", "Attribute Value (Hex)", NULL, NULL, w_data_attr_value }, - { "4", "run", NULL, run_global_write_attr, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_global_config_report[] = { - { "1", "Cluster ID (Hex)", NULL, NULL, r_data_cluster_id }, - { "2", "Attribute ID (Hex)", NULL, NULL, r_data_attr_id }, - { "3", "Min interval (Hex)", NULL, NULL, data_min_i }, - { "4", "Max interval (Hex)", NULL, NULL, data_max_i }, - { "5", "Timeout", NULL, NULL, data_timeout }, - { "6", "run", NULL, run_global_config_report, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_global[] = { - { "1", "zb_zcl_global_read_attr", - menu_zcl_global_read_attr, NULL, NULL }, - { "2", "zb_zcl_global_write_attr", - menu_zcl_global_write_attr, NULL, NULL }, - { "3", "zb_zcl_global_write_attr_undivided", - NULL, run_global_write_attr_undivided, NULL }, - { "4", "zb_zcl_global_write_attr_no_rsp", - NULL, run_global_write_attr_no_rsp, NULL }, - { "5", "zb_zcl_global_config_report", - menu_zcl_global_config_report, NULL, NULL }, - { "6", "zb_zcl_global_read_config_report", - NULL, run_global_read_config_report, NULL }, - { "7", "zb_zcl_global_discover_attr", - NULL, run_global_discover_attr, NULL }, - { "8", "zb_zcl_global_discover_cmds_received", - NULL, run_global_discover_cmds_received, NULL }, - { "9", "zb_zcl_global_discover_cmds_generated", - NULL, run_global_discover_cmds_generated, NULL }, - { "10", "zb_zcl_global_discover_attr_extended", - NULL, run_global_discover_attr_extended, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zcl_cluster[] = { - { "1", "Alarm Cluster", menu_zcl_cluster_alarm, NULL, NULL }, - { "2", "Basic Cluster", menu_zcl_cluster_basic, NULL, NULL }, - { "3", "Color Control Cluster", menu_zcl_cluster_colorctrl, NULL, NULL }, - { "4", "Group Cluster", menu_zcl_cluster_group, NULL, NULL }, - { "5", "IAS zone Cluster", menu_zcl_cluster_ias_zone, NULL, NULL }, - { "6", "Identity Cluster", menu_zcl_cluster_identity, NULL, NULL }, - { "7", "Level Control Cluster", menu_zcl_cluster_levelctrl, NULL, NULL }, - { "8", "On/Off Cluster", menu_zcl_cluster_onoff, NULL, NULL }, - { "9", "Poll Control Cluster", menu_zcl_cluster_pollctrl, NULL, NULL }, - { "10", "Scene Cluster", menu_zcl_cluster_scene, NULL, NULL }, - { "11", "Simple Metering Cluster", NULL, NULL, NULL }, - { "12", "Thermostat Cluster", menu_zcl_cluster_thermostat, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zcl_cluster_alarm.c b/test/zcl_cluster_alarm.c new file mode 100644 index 0000000..180eefd --- /dev/null +++ b/test/zcl_cluster_alarm.c @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; + +static char data_alarm_code[MENU_DATA_SIZE + 1] = "1"; + +static void zigbee_zcl_alarm_get_alarm_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned char alarm_code, unsigned short cluster_id, + unsigned int time_stamp, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_alarm_get_alarm_rsp()"); + + msg(" Network Address = 0x%04X status = 0x%02X", addr16, status); + msg(" End-Point = 0x%02X", ep); + msg(" alarm_code = 0x%02X", alarm_code); + msg(" cluster_id = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + msg(" time_stamp = 0x%08X", time_stamp); +} + +static int run_alarm_reset_alarm(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char alarm_code = 0x01; + + if (strlen(data_alarm_code)) + alarm_code = (unsigned char)strtol(data_alarm_code, NULL, 10); + + ret = zb_zcl_alarm_reset_alarm(handle, dest_addr16, 1, alarm_code, + ZB_ZCL_ON_OFF_CLUSTER_ID); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_alarm_reset_alarm(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_alarm_reset_alarm() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_alarm_reset_all_alarm(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_alarm_reset_all_alarm(handle, dest_addr16, 1); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_alarm_reset_all_alarm(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_alarm_reset_all_alarm() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_alarm_get_alarm(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_alarm_get_alarm(handle, dest_addr16, 1, + zigbee_zcl_alarm_get_alarm_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_alarm_get_alarm(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_alarm_get_alarm() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_alarm_reset_all_alarm_log(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_alarm_reset_all_alarm_log(handle, dest_addr16, 1); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_alarm_reset_all_alarm_log(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_alarm_reset_all_alarm_log() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_alarm_code[] = { + { "1", "Alarm code", NULL, NULL, data_alarm_code }, + { "2", "Run", NULL, run_alarm_reset_alarm, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_alarm[] = { + { "1", "zb_zcl_alarm_reset_alarm", + _menu_alarm_code, NULL, NULL }, + { "2", "zb_zcl_alarm_reset_all_alarm", + NULL, run_alarm_reset_all_alarm, NULL }, + { "3", "zb_zcl_alarm_get_alarm", + NULL, run_alarm_get_alarm, NULL }, + { "4", "zb_zcl_alarm_reset_all_alarm_log", + NULL, run_alarm_reset_all_alarm_log, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_basic.c b/test/zcl_cluster_basic.c new file mode 100644 index 0000000..49943d4 --- /dev/null +++ b/test/zcl_cluster_basic.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s st_ep1; + +static int run_reset_factory_default(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_basic_reset_factory_default(handle, dest_addr16, st_ep1.ep); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_basic_reset_factory_default(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_basic_reset_factory_default() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_reset_factory_default[] = { + { "1", "Run", NULL, run_reset_factory_default, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_basic[] = { + { "1", "zb_zcl_basic_reset_factory_default", + _menu_reset_factory_default, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_colorctrl.c b/test/zcl_cluster_colorctrl.c new file mode 100644 index 0000000..a56e4a5 --- /dev/null +++ b/test/zcl_cluster_colorctrl.c @@ -0,0 +1,442 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s huebulb_ep1; + +static char data_hue[MENU_DATA_SIZE + 1] = "32"; +static char data_rate[MENU_DATA_SIZE + 1] = "2"; +static char data_trans_time16[MENU_DATA_SIZE + 1] = "200"; +static char data_trans_time8[MENU_DATA_SIZE + 1] = "10"; +static char data_direction[MENU_DATA_SIZE + 1] = "0"; +static char data_move_mode[MENU_DATA_SIZE + 1] = "3"; +static char data_step_mode[MENU_DATA_SIZE + 1] = "3"; +static char data_step_size[MENU_DATA_SIZE + 1] = "32"; +static char data_saturation[MENU_DATA_SIZE + 1] = "10"; +static char data_color_x[MENU_DATA_SIZE + 1] = "10250"; +static char data_color_y[MENU_DATA_SIZE + 1] = "10000"; +static char data_rate_x[MENU_DATA_SIZE + 1] = "2"; +static char data_rate_y[MENU_DATA_SIZE + 1] = "2"; +static char data_step_x[MENU_DATA_SIZE + 1] = "14689"; +static char data_step_y[MENU_DATA_SIZE + 1] = "14701"; +static char data_color_temperature[MENU_DATA_SIZE + 1] = "120"; + +static int run_move_to_hue(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char move_hue = 0x20; + unsigned char direction = 0x00; /* Shortest distance */ + unsigned short trans_time16 = 0x00C8; + + if (strlen(data_hue)) + move_hue = (unsigned char)strtol(data_hue, NULL, 10); + if (strlen(data_direction)) + direction = (unsigned char)strtol(data_direction, NULL, 10); + if (strlen(data_trans_time16)) + trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); + + ret = zb_zcl_ccontrol_move_to_hue(handle, dest_addr16, huebulb_ep1.ep, + move_hue, direction, trans_time16); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_move_to_hue(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_move_to_hue() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_hue(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char move_mode = 0x03; /* Down */ + unsigned char color_rate = 2; + + if (strlen(data_move_mode)) + move_mode = (unsigned char)strtol(data_move_mode, NULL, 10); + if (strlen(data_rate)) + color_rate = (unsigned char)strtol(data_rate, NULL, 10); + + ret = zb_zcl_ccontrol_move_hue(handle, dest_addr16, huebulb_ep1.ep, + move_mode, color_rate); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_move_hue(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_move_hue() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_step_hue(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char step_mode = 0x03; /* Down */ + unsigned char step_size = 0x20; + unsigned char trans_time8 = 0x0A; + + if (strlen(data_step_mode)) + step_mode = (unsigned char)strtol(data_step_mode, NULL, 10); + if (strlen(data_step_size)) + step_size = (unsigned char)strtol(data_step_size, NULL, 10); + if (strlen(data_trans_time8)) + trans_time8 = (unsigned char)strtol(data_trans_time8, NULL, 10); + + ret = zb_zcl_ccontrol_step_hue(handle, dest_addr16, huebulb_ep1.ep, + step_mode, step_size, trans_time8); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_step_hue(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_step_hue() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_to_saturation(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char saturation = 0x0A; + unsigned short trans_time16 = 0x00C8; + + if (strlen(data_saturation)) + saturation = (unsigned char)strtol(data_saturation, NULL, 10); + if (strlen(data_trans_time16)) + trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); + + ret = zb_zcl_ccontrol_move_to_saturation(handle, dest_addr16, huebulb_ep1.ep, + saturation, trans_time16); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_move_to_saturation(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_move_to_saturation() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_saturation(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char move_mode = 0x03; /* Down */ + unsigned char color_rate = 2; + + if (strlen(data_move_mode)) + move_mode = (unsigned char)strtol(data_move_mode, NULL, 10); + if (strlen(data_rate)) + color_rate = (unsigned char)strtol(data_rate, NULL, 10); + + ret = zb_zcl_ccontrol_move_saturation(handle, dest_addr16, huebulb_ep1.ep, + move_mode, color_rate); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_move_saturation(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_move_saturation() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_step_saturation(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char step_mode = 0x03; /* Down */ + unsigned char step_size = 0x20; + unsigned char trans_time8 = 0x0A; + + if (strlen(data_step_mode)) + step_mode = (unsigned char)strtol(data_step_mode, NULL, 10); + if (strlen(data_step_size)) + step_size = (unsigned char)strtol(data_step_size, NULL, 10); + if (strlen(data_trans_time8)) + trans_time8 = (unsigned char)strtol(data_trans_time8, NULL, 10); + + ret = zb_zcl_ccontrol_step_saturation(handle, dest_addr16, huebulb_ep1.ep, + step_mode, step_size, trans_time8); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_step_saturation(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_step_saturation() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_to_hue_and_saturation(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char move_hue = 0x20; + unsigned char saturation = 0x0A; + unsigned short trans_time16 = 0x00C8; + + if (strlen(data_hue)) + move_hue = (unsigned char)strtol(data_hue, NULL, 10); + if (strlen(data_saturation)) + saturation = (unsigned char)strtol(data_saturation, NULL, 10); + if (strlen(data_trans_time16)) + trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); + + ret = zb_zcl_ccontrol_move_to_hue_and_saturation(handle, dest_addr16, + huebulb_ep1.ep, move_hue, saturation, trans_time16); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_move_to_hue_and_saturation(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_move_to_hue_and_saturation() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_to_color(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short color_x = 0x280A; + unsigned short color_y = 0x2710; + unsigned short trans_time16 = 0x00C8; + + if (strlen(data_color_x)) + color_x = (unsigned short)strtol(data_color_x, NULL, 10); + if (strlen(data_color_y)) + color_y = (unsigned short)strtol(data_color_y, NULL, 10); + if (strlen(data_trans_time16)) + trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); + + ret = zb_zcl_ccontrol_move_to_color(handle, dest_addr16, huebulb_ep1.ep, + color_x, color_y, trans_time16); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_move_to_color(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_move_to_color() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_color(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short rate_x = 0x0002; + unsigned short rate_y = 0x0002; + + if (strlen(data_rate_x)) + rate_x = (unsigned short)strtol(data_rate_x, NULL, 10); + if (strlen(data_rate_y)) + rate_y = (unsigned short)strtol(data_rate_y, NULL, 10); + + ret = zb_zcl_ccontrol_move_color(handle, dest_addr16, huebulb_ep1.ep, + rate_x, rate_y); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_move_color(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_move_color() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_step_color(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short step_x = 0x3961; + unsigned short step_y = 0x396D; + unsigned short trans_time16 = 0x00C8; + + if (strlen(data_step_x)) + step_x = (unsigned short)strtol(data_step_x, NULL, 10); + if (strlen(data_step_y)) + step_y = (unsigned short)strtol(data_step_y, NULL, 10); + if (strlen(data_trans_time16)) + trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); + + ret = zb_zcl_ccontrol_step_color(handle, dest_addr16, huebulb_ep1.ep, + step_x, step_y, trans_time16); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_step_color(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_step_color() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_to_color_temperature(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char color_temp = 0x78; + unsigned short trans_time16 = 0x00C8; + + if (strlen(data_color_temperature)) + color_temp = (unsigned short)strtol(data_color_temperature, NULL, 10); + if (strlen(data_trans_time16)) + trans_time16 = (unsigned short)strtol(data_trans_time16, NULL, 10); + + ret = zb_zcl_ccontrol_move_to_color_temperature(handle, dest_addr16, + huebulb_ep1.ep, color_temp, trans_time16); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_ccontrol_move_to_color_temperature(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_ccontrol_move_to_color_temperature() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_move_to_hue[] = { + { "1", "Hue", NULL, NULL, data_hue }, + { "2", "Direction", NULL, NULL, data_direction }, + { "3", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, + { "4", "Run", NULL, run_move_to_hue, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_hue[] = { + { "1", "Move mode", NULL, NULL, data_move_mode }, + { "2", "Rate", NULL, NULL, data_rate }, + { "3", "Run", NULL, run_move_hue, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_step_hue[] = { + { "1", "Step mode", NULL, NULL, data_step_mode }, + { "2", "Step size", NULL, NULL, data_step_size }, + { "3", "Transition time (1 byte)", NULL, NULL, data_trans_time8 }, + { "4", "Run", NULL, run_step_hue, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_to_saturation[] = { + { "1", "Saturation", NULL, NULL, data_saturation }, + { "2", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, + { "3", "Run", NULL, run_move_to_saturation, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_saturation[] = { + { "1", "Move mode", NULL, NULL, data_move_mode }, + { "2", "Rate", NULL, NULL, data_rate }, + { "3", "Run", NULL, run_move_saturation, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_step_saturation[] = { + { "1", "Step mode", NULL, NULL, data_step_mode }, + { "2", "Step size", NULL, NULL, data_step_size }, + { "3", "Transition time (1 byte)", NULL, NULL, data_trans_time8 }, + { "4", "Run", NULL, run_step_saturation, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_to_hue_and_saturation[] = { + { "1", "Hue", NULL, NULL, data_hue }, + { "2", "Saturation", NULL, NULL, data_saturation }, + { "3", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, + { "4", "Run", NULL, run_move_to_hue_and_saturation, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_to_color[] = { + { "1", "Color X", NULL, NULL, data_color_x }, + { "2", "Color Y", NULL, NULL, data_color_y }, + { "3", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, + { "4", "Run", NULL, run_move_to_color, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_color[] = { + { "1", "Rate X", NULL, NULL, data_rate_x }, + { "2", "Rate Y", NULL, NULL, data_rate_y }, + { "3", "Run", NULL, run_move_color, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_step_color[] = { + { "1", "Step X", NULL, NULL, data_step_x }, + { "2", "Step Y", NULL, NULL, data_step_y }, + { "3", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, + { "4", "Run", NULL, run_step_color, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_to_color_temperature[] = { + { "1", "Color Temperature", NULL, NULL, data_color_temperature }, + { "2", "Transition time (2 bytes)", NULL, NULL, data_trans_time16 }, + { "3", "Run", NULL, run_move_to_color_temperature, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_colorctrl[] = { + { "1", "zb_zcl_ccontrol_move_to_hue", + _menu_move_to_hue, NULL, NULL }, + { "2", "zb_zcl_ccontrol_move_hue", + _menu_move_hue, NULL, NULL }, + { "3", "zb_zcl_ccontrol_step_hue", + _menu_step_hue, NULL, NULL }, + { "4", "zb_zcl_ccontrol_move_to_saturation", + _menu_move_to_saturation, NULL, NULL }, + { "5", "zb_zcl_ccontrol_move_saturation", + _menu_move_saturation, NULL, NULL }, + { "6", "zb_zcl_ccontrol_step_saturation", + _menu_step_saturation, NULL, NULL }, + { "7", "zb_zcl_ccontrol_move_to_hue_and_saturation", + _menu_move_to_hue_and_saturation, NULL, NULL }, + { "8", "zb_zcl_ccontrol_move_to_color", + _menu_move_to_color, NULL, NULL }, + { "9", "zb_zcl_ccontrol_move_color", + _menu_move_color, NULL, NULL }, + { "10", "zb_zcl_ccontrol_step_color", + _menu_step_color, NULL, NULL }, + { "11", "zb_zcl_ccontrol_move_to_color_temperature", + _menu_move_to_color_temperature, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_group.c b/test/zcl_cluster_group.c new file mode 100644 index 0000000..18728b7 --- /dev/null +++ b/test/zcl_cluster_group.c @@ -0,0 +1,262 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s sj_ep1; + +static char data_group_name[MENU_DATA_SIZE + 1] = "6grpone"; +static char data_group_id[MENU_DATA_SIZE + 1] = "2"; + +static void zigbee_zcl_group_add_group_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned short group_id, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_group_add_group_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Group ID = 0x%04X", group_id); +} + +static void zigbee_zcl_group_view_group_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned short group_id, const char *group_name, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_group_view_group_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Group ID = 0x%04X", group_id); + msg(" Group Name = %s", group_name); +} + +static void zigbee_zcl_group_get_group_membership_rsp(nwk_addr addr16, + unsigned char ep, unsigned char capacity, unsigned char group_count, + unsigned short *group_list, void *user_data) +{ + int i; + + msg(""); + msgp("zigbee_zcl_group_get_group_membership_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" capacity = 0x%02X", capacity); + for (i = 0; i < group_count; i++) + msg(" [%d] group_list = %04X", i, group_list[i]); +} + +static void zigbee_zcl_group_remove_group_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned short group_id, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_group_remove_group_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Group ID = 0x%04X", group_id); +} + +static int run_group_add_group(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + + ret = zb_zcl_group_add_group(handle, dest_addr16, sj_ep1.ep, + group_id, data_group_name, zigbee_zcl_group_add_group_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_group_add_group(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_group_add_group() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_group_view_group(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + + ret = zb_zcl_group_view_group(handle, dest_addr16, sj_ep1.ep, + group_id, zigbee_zcl_group_view_group_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_group_view_group(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_group_view_group() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_group_get_group_membership(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_list[2] = { 0x0003, 0x0004 }; + unsigned char group_count = 2; + + ret = zb_zcl_group_get_group_membership(handle, dest_addr16, sj_ep1.ep, + group_count, group_list, + zigbee_zcl_group_get_group_membership_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_group_get_group_membership(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_group_get_group_membership() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_group_remove_group(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + + ret = zb_zcl_group_remove_group(handle, dest_addr16, sj_ep1.ep, + group_id, zigbee_zcl_group_remove_group_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_group_remove_group(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_group_remove_group() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_group_remove_all_group(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_group_remove_all_group(handle, dest_addr16, sj_ep1.ep); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_group_remove_all_group(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_group_remove_all_group() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_group_add_group_if_identifying(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + + ret = zb_zcl_group_add_group_if_identifying(handle, dest_addr16, sj_ep1.ep, + group_id, data_group_name); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_group_add_group_if_identifying(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_group_add_group_if_identifying() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_group_add_group[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Group name", NULL, NULL, data_group_name }, + { "3", "Run", NULL, run_group_add_group, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_group_view_group[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Run", NULL, run_group_view_group, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_group_get_group_membership[] = { + { "1", "Run", NULL, run_group_get_group_membership, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_group_remove_group[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Run", NULL, run_group_remove_group, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_group_remove_all_group[] = { + { "1", "Run", NULL, run_group_remove_all_group, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_group_add_group_if_identifying[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Group name", NULL, NULL, data_group_name }, + { "3", "Run", NULL, run_group_add_group_if_identifying, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_group[] = { + { "1", "zb_zcl_group_add_group", + _menu_group_add_group, NULL, NULL }, + { "2", "zb_zcl_group_view_group", + _menu_group_view_group, NULL, NULL }, + { "3", "zb_zcl_group_get_group_membership", + _menu_group_get_group_membership, NULL, NULL }, + { "4", "zb_zcl_group_remove_group", + _menu_group_remove_group, NULL, NULL }, + { "5", "zb_zcl_group_remove_all_group", + _menu_group_remove_all_group, NULL, NULL }, + { "6", "zb_zcl_group_add_group_if_identifying", + _menu_group_add_group_if_identifying, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_ias_zone.c b/test/zcl_cluster_ias_zone.c new file mode 100644 index 0000000..c3570f9 --- /dev/null +++ b/test/zcl_cluster_ias_zone.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s sj_ep1; + +static char data_enroll_response_code[MENU_DATA_SIZE + 1] = "10"; +static char data_zone_id[MENU_DATA_SIZE + 1] = "77"; + +static int run_enroll_response(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char enroll_response_code = 10; + unsigned char zone_id = 10; + + if (strlen(data_enroll_response_code)) + enroll_response_code = (unsigned short)strtol(data_enroll_response_code, NULL, 10); + + if (strlen(data_zone_id)) + zone_id = (unsigned short)strtol(data_zone_id, NULL, 10); + + ret = zb_zcl_zone_enroll_response(handle, dest_addr16, sj_ep1.ep, + enroll_response_code, zone_id); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_zone_enroll_response(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_zone_enroll_response() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_enroll_response[] = { + { "1", "Enroll response time", NULL, NULL, data_enroll_response_code }, + { "2", "Zone ID", NULL, NULL, data_zone_id }, + { "3", "Run", NULL, run_enroll_response, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_ias_zone[] = { + { "1", "zb_zcl_enroll_response", _menu_enroll_response, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_identity.c b/test/zcl_cluster_identity.c new file mode 100644 index 0000000..437dbf1 --- /dev/null +++ b/test/zcl_cluster_identity.c @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s sj_ep1; + +static char data_identify_time[MENU_DATA_SIZE + 1] = "10"; + +static void zigbee_zcl_identify_query_cb(nwk_addr addr16, + unsigned short identify_time, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_identify_query_cb()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" identify_time = %d", identify_time); +} + +static int run_identify(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short identify_time = 10; + + if (strlen(data_identify_time)) + identify_time = (unsigned short)strtol(data_identify_time, NULL, 10); + + ret = zb_zcl_identify(handle, dest_addr16, sj_ep1.ep, identify_time); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_identify(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_identify() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_identify_query(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_identify_query(handle, dest_addr16, sj_ep1.ep, + zigbee_zcl_identify_query_cb, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_identify_query(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_identify_query() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_identify[] = { + { "1", "Identify time", NULL, NULL, data_identify_time }, + { "2", "Run", NULL, run_identify, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_identity[] = { + { "1", "zb_zcl_identify", _menu_identify, NULL, NULL }, + { "2", "zb_zcl_identify_query", NULL, run_identify_query, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_levelctrl.c b/test/zcl_cluster_levelctrl.c new file mode 100644 index 0000000..6d7a66d --- /dev/null +++ b/test/zcl_cluster_levelctrl.c @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s dimmer_ep1; + +static char data_level[MENU_DATA_SIZE + 1] = "100"; +static char data_time[MENU_DATA_SIZE + 1] = "10"; +static char data_rate[MENU_DATA_SIZE + 1] = "255"; +static char data_move_mode[MENU_DATA_SIZE + 1] = "0"; +static char data_step_mode[MENU_DATA_SIZE + 1] = "0"; +static char data_step_size[MENU_DATA_SIZE + 1] = "16"; + +static int run_move_to_level(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char level = 100; + unsigned short transition_time = 10; + + if (strlen(data_level)) + level = (unsigned char)strtol(data_level, NULL, 10); + if (strlen(data_time)) + transition_time = (unsigned short)strtol(data_time, NULL, 10); + + ret = zb_zcl_levelctrl_move_to_level(handle, dest_addr16, dimmer_ep1.ep, + level, transition_time); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_levelctrl_move_to_level(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_levelctrl_move_to_level() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char move_mode = 0x00; + unsigned char rate = 0xFF; + + if (strlen(data_move_mode)) + move_mode = (unsigned char)strtol(data_move_mode, NULL, 10); + if (strlen(data_rate)) + rate = (unsigned char)strtol(data_rate, NULL, 10); + + ret = zb_zcl_levelctrl_move(handle, dest_addr16, dimmer_ep1.ep, + move_mode, rate); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_levelctrl_move(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_levelctrl_move() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_step(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char step_mode = 0x00; /* Up */ + unsigned char step_size = 0x10; + unsigned short transition_time = 10; + + if (strlen(data_step_mode)) + step_mode = (unsigned char)strtol(data_step_mode, NULL, 10); + if (strlen(data_step_size)) + step_size = (unsigned char)strtol(data_step_size, NULL, 10); + if (strlen(data_time)) + transition_time = (unsigned short)strtol(data_time, NULL, 10); + + ret = zb_zcl_levelctrl_step(handle, dest_addr16, dimmer_ep1.ep, + step_mode, step_size, transition_time); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_levelctrl_step(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_levelctrl_step() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_stop(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_levelctrl_stop(handle, dest_addr16, dimmer_ep1.ep); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_levelctrl_stop(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_levelctrl_stop() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_with_on_off(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char move_mode = 0x00; /* Up */ + unsigned char rate = 10; + + if (strlen(data_move_mode)) + move_mode = (unsigned char)strtol(data_move_mode, NULL, 10); + if (strlen(data_rate)) + rate = (unsigned char)strtol(data_rate, NULL, 10); + + ret = zb_zcl_levelctrl_move_with_on_off(handle, dest_addr16, dimmer_ep1.ep, + move_mode, rate); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_levelctrl_move_with_on_off(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_levelctrl_move_with_on_off() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_move_to_level_with_on_off(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char level = 100; + unsigned short transition_time = 10; + + if (strlen(data_level)) + level = (unsigned char)strtol(data_level, NULL, 10); + if (strlen(data_time)) + transition_time = (unsigned short)strtol(data_time, NULL, 10); + + ret = zb_zcl_levelctrl_move_to_level_with_on_off(handle, dest_addr16, + dimmer_ep1.ep, level, transition_time); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_levelctrl_move_to_level_with_on_off(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_levelctrl_move_to_level_with_on_off() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_step_with_on_off(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char step_mode = 0x00; /* Up */ + unsigned char step_size = 0x10; + unsigned short transition_time = 10; + + if (strlen(data_step_mode)) + step_mode = (unsigned char)strtol(data_step_mode, NULL, 10); + if (strlen(data_step_size)) + step_size = (unsigned char)strtol(data_step_size, NULL, 10); + if (strlen(data_time)) + transition_time = (unsigned short)strtol(data_time, NULL, 10); + + ret = zb_zcl_levelctrl_step_with_on_off(handle, dest_addr16, dimmer_ep1.ep, + step_mode, step_size, transition_time); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_levelctrl_step_with_on_off(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_levelctrl_step_with_on_off() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_move_to_level[] = { + { "1", "Level", NULL, NULL, data_level }, + { "2", "Transition Time", NULL, NULL, data_time }, + { "3", "Run", NULL, run_move_to_level, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move[] = { + { "1", "Move mode", NULL, NULL, data_move_mode }, + { "2", "Rate", NULL, NULL, data_rate }, + { "3", "Run", NULL, run_move, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_step[] = { + { "1", "Step mode", NULL, NULL, data_step_mode }, + { "2", "Step size", NULL, NULL, data_step_size }, + { "3", "Transition Time", NULL, NULL, data_time }, + { "4", "Run", NULL, run_step, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_stop[] = { + { "1", "Run", NULL, run_stop, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_with_onoff[] = { + { "1", "Move mode", NULL, NULL, data_move_mode }, + { "2", "Rate", NULL, NULL, data_rate }, + { "3", "Run", NULL, run_move_with_on_off, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_move_to_level_with_onoff[] = { + { "1", "Level", NULL, NULL, data_level }, + { "2", "Transition Time", NULL, NULL, data_time }, + { "3", "Run", NULL, run_move_to_level_with_on_off, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_step_with_onoff[] = { + { "1", "Step mode", NULL, NULL, data_step_mode }, + { "2", "Step size", NULL, NULL, data_step_size }, + { "3", "Transition Time", NULL, NULL, data_time }, + { "4", "Run", NULL, run_step_with_on_off, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_levelctrl[] = { + { "1", "zb_zcl_levelctrl_move_to_level", + _menu_move_to_level, NULL, NULL }, + { "2", "zb_zcl_levelctrl_move", _menu_move, NULL, NULL }, + { "3", "zb_zcl_levelctrl_step", _menu_step, NULL, NULL }, + { "4", "zb_zcl_levelctrl_stop", _menu_stop, NULL, NULL }, + { "5", "zb_zcl_levelctrl_move_with_on_off", + _menu_move_with_onoff, NULL, NULL }, + { "6", "zb_zcl_levelctrl_move_to_level_with_on_off", + _menu_move_to_level_with_onoff, NULL, NULL }, + { "7", "zb_zcl_levelctrl_step_with_on_off", + _menu_step_with_onoff, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_onoff.c b/test/zcl_cluster_onoff.c new file mode 100644 index 0000000..3bd254a --- /dev/null +++ b/test/zcl_cluster_onoff.c @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s sj_ep1; + +static int run_on(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_onoff_control(handle, dest_addr16, sj_ep1.ep, ZB_ZCL_ON); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_onoff_control(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_onoff_control() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_off(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_onoff_control(handle, dest_addr16, sj_ep1.ep, ZB_ZCL_OFF); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_onoff_control(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_onoff_control() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_toggle(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_onoff_control(handle, dest_addr16, sj_ep1.ep, ZB_ZCL_TOGGLE); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_onoff_control(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_onoff_control() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data menu_zcl_cluster_onoff_control[] = { + { "1", "On", NULL, run_on, NULL }, + { "2", "Off", NULL, run_off, NULL }, + { "3", "Toggle", NULL, run_toggle, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_onoff[] = { + { "1", "zb_zcl_onoff_control", + menu_zcl_cluster_onoff_control, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_pollctrl.c b/test/zcl_cluster_pollctrl.c new file mode 100644 index 0000000..778575c --- /dev/null +++ b/test/zcl_cluster_pollctrl.c @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s sj_ep1; + +static char data_poll_state[MENU_DATA_SIZE + 1] = "1"; +static char data_poll_timeout[MENU_DATA_SIZE + 1] = "100"; +static char data_long_interval[MENU_DATA_SIZE + 1] = "200"; +static char data_short_interval[MENU_DATA_SIZE + 1] = "5"; + +static void zigbee_zcl_poll_control_check_in(nwk_addr addr16, unsigned char ep, + void *user_data) +{ + msg(""); + msgp("zigbee_zcl_poll_control_check_in()"); + + msg(" Network Address = 0x%04X End-Point = 0x%02X", addr16, ep); +} + +static int run_check_in_response(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char start_fast_polling = 1; /* True */ + unsigned short fast_poll_timeout = 100; + + if (strncmp(data_poll_state, "0", MENU_DATA_SIZE) == 0) + start_fast_polling = 0; /* False */ + if (strlen(data_poll_timeout)) + fast_poll_timeout = (unsigned short)strtol(data_poll_timeout, NULL, 10); + + ret = zb_zcl_pollctrl_check_in_response(handle, dest_addr16, sj_ep1.ep, + start_fast_polling, fast_poll_timeout); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_pollctrl_check_in_response(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_pollctrl_check_in_response() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_fast_poll_stop(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zcl_pollctrl_fast_poll_stop(handle, dest_addr16, sj_ep1.ep); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_pollctrl_fast_poll_stop(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_pollctrl_fast_poll_stop() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_set_long_poll_interval(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned int long_poll_interval = 200; + + if (strlen(data_long_interval)) + long_poll_interval = (unsigned short)strtol(data_long_interval, NULL, 10); + + ret = zb_zcl_pollctrl_set_long_poll_interval(handle, dest_addr16, sj_ep1.ep, + long_poll_interval, zigbee_zcl_poll_control_check_in, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_pollctrl_set_long_poll_interval(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_pollctrl_set_long_poll_interval() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_set_short_poll_interval(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned int short_poll_interval = 5; + + if (strlen(data_short_interval)) + short_poll_interval = (unsigned short)strtol(data_short_interval, NULL, 10); + + ret = zb_zcl_pollctrl_set_short_poll_interval(handle, dest_addr16, sj_ep1.ep, + short_poll_interval, zigbee_zcl_poll_control_check_in, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_pollctrl_set_short_poll_interval(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_pollctrl_set_short_poll_interval() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_check_in_response[] = { + { "1", "Start Fast Polling", NULL, NULL, data_poll_state }, + { "2", "Fast poll timeout", NULL, NULL, data_poll_timeout }, + { "3", "Run", NULL, run_check_in_response, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_fast_poll_stop[] = { + { "1", "Run", NULL, run_fast_poll_stop, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_set_long_poll_interval[] = { + { "1", "Long poll interval", NULL, NULL, data_long_interval }, + { "2", "Run", NULL, run_set_long_poll_interval, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_set_short_poll_interval[] = { + { "1", "Short poll interval", NULL, NULL, data_short_interval }, + { "2", "Run", NULL, run_set_short_poll_interval, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_pollctrl[] = { + { "1", "zb_zcl_pollctrl_check_in_response", + _menu_check_in_response, NULL, NULL }, + { "2", "zb_zcl_pollctrl_fast_poll_stop", + _menu_fast_poll_stop, NULL, NULL }, + { "3", "zb_zcl_pollctrl_set_long_poll_interval", + _menu_set_long_poll_interval, NULL, NULL }, + { "4", "zb_zcl_pollctrl_set_short_poll_interval", + _menu_set_short_poll_interval, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_scene.c b/test/zcl_cluster_scene.c new file mode 100644 index 0000000..23a992f --- /dev/null +++ b/test/zcl_cluster_scene.c @@ -0,0 +1,361 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s sj_ep1; + +static char data_group_id[MENU_DATA_SIZE + 1] = "2"; +static char data_scene_id[MENU_DATA_SIZE + 1] = "1"; +static char data_trans_time[MENU_DATA_SIZE + 1] = "0"; +static char data_scene_name[MENU_DATA_SIZE + 1] = "6scnone"; + +static void zigbee_zcl_scene_add_scene_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_scene_add_scene_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Group ID = 0x%04X", group_id); + msg(" Scene ID = 0x%02X", scene_id); +} + +static void zigbee_zcl_scene_view_scene_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned short group_id, unsigned char scene_id, + unsigned short transition_time, const char *scene_name, + const char *extension_field_set, unsigned short ext_len, void *user_data) +{ + int i; + msg(""); + msgp("zigbee_zcl_scene_view_scene_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Group ID = 0x%04X", group_id); + msg(" Scene ID = 0x%02X", scene_id); + msg(" Transition Time = 0x%04X", transition_time); + msg(" Scene Name = %s\n", scene_name); + for (i = 0; i < ext_len; i++) + msg(" extension_field_set[%d] = 0x%02X", i, extension_field_set[i]); +} + +static void zigbee_zcl_scene_remove_scene_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_scene_remove_scene_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Group ID = 0x%04X", group_id); + msg(" Scene ID = 0x%02X", scene_id); +} + +static void zigbee_zcl_scene_remove_all_scene_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned short group_id, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_scene_remove_all_scene_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Group ID = 0x%04X", group_id); +} + +static void zigbee_zcl_scene_store_scene_rsp(nwk_addr addr16, unsigned char ep, + unsigned char status, unsigned short group_id, unsigned char scene_id, void *user_data) +{ + msg(""); + msgp("zigbee_zcl_scene_store_scene_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Group ID = 0x%04X", group_id); + msg(" Scene ID = 0x%02X", scene_id); +} + +static void zigbee_zcl_scene_get_scene_membership_rsp(nwk_addr addr16, + unsigned char ep, unsigned char status, unsigned char capacity, unsigned short group_id, + unsigned char scene_count, unsigned char *scene_list, void *user_data) +{ + int i; + + msg(""); + msgp("zigbee_zcl_scene_get_scene_membership_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Status = 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + msg(" Capacity = 0x%02X", capacity); + msg(" Group ID = 0x%02X", group_id); + for (i = 0; i < scene_count && ZB_ZCL_SUCCESS == status; i++) + msg(" scene_list[%d] = 0x%02X", i, scene_list[i]); +} + +static int run_scene_add_scene(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + unsigned char scene_id = 0x01; + unsigned short trans_time = 0x0000; + const char ext_field_set[] = {0x00, 0x06, 0x01, 0x00}; + unsigned short ext_len = sizeof(ext_field_set) / sizeof(ext_field_set[0]); + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + if (strlen(data_scene_id)) + scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); + + ret = zb_zcl_scene_add_scene(handle, dest_addr16, + sj_ep1.ep, group_id, scene_id, trans_time, data_scene_name, + ext_len, ext_field_set, zigbee_zcl_scene_add_scene_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_scene_add_scene(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_scene_add_scene() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_scene_view_scene(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + unsigned char scene_id = 0x01; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + if (strlen(data_scene_id)) + scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); + + ret = zb_zcl_scene_view_scene(handle, dest_addr16, sj_ep1.ep, group_id, + scene_id, zigbee_zcl_scene_view_scene_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_scene_view_scene(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_scene_view_scene() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_scene_get_scene_membership(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + + ret = zb_zcl_scene_get_scene_membership(handle, dest_addr16, sj_ep1.ep, + group_id, zigbee_zcl_scene_get_scene_membership_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_scene_get_scene_membership(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_scene_get_scene_membership() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_scene_remove_scene(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + unsigned char scene_id = 0x01; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + if (strlen(data_scene_id)) + scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); + + ret = zb_zcl_scene_remove_scene(handle, dest_addr16, sj_ep1.ep, group_id, + scene_id, zigbee_zcl_scene_remove_scene_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_scene_remove_scene(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_scene_remove_scene() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_scene_remove_all_scene(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + + ret = zb_zcl_scene_remove_all_scene(handle, dest_addr16, sj_ep1.ep, group_id, + zigbee_zcl_scene_remove_all_scene_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_scene_remove_all_scene(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_scene_remove_all_scene() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_scene_store_scene(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + unsigned char scene_id = 0x01; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + if (strlen(data_scene_id)) + scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); + + ret = zb_zcl_scene_store_scene(handle, dest_addr16, sj_ep1.ep, group_id, + scene_id, zigbee_zcl_scene_store_scene_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_scene_store_scene(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_scene_store_scene() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_scene_recall_scene(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short group_id = 0x0002; + unsigned char scene_id = 0x01; + + if (strlen(data_group_id)) + group_id = (unsigned short)strtol(data_group_id, NULL, 10); + if (strlen(data_scene_id)) + scene_id = (unsigned char)strtol(data_scene_id, NULL, 10); + + ret = zb_zcl_scene_recall_scene(handle, dest_addr16, sj_ep1.ep, + group_id, scene_id); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_scene_recall_scene(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_scene_recall_scene() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_add_scene[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Scene ID", NULL, NULL, data_scene_id }, + { "3", "Transition time", NULL, NULL, data_trans_time }, + { "4", "Scene name", NULL, NULL, data_scene_name }, + { "5", "Run", NULL, run_scene_add_scene, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_view_scene[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Scene ID", NULL, NULL, data_scene_id }, + { "3", "Run", NULL, run_scene_view_scene, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_get_scene_membership[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Run", NULL, run_scene_get_scene_membership, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_remove_scene[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Scene ID", NULL, NULL, data_scene_id }, + { "3", "Run", NULL, run_scene_remove_scene, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_remove_all_scene[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Run", NULL, run_scene_remove_all_scene, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_store_scene[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Scene ID", NULL, NULL, data_scene_id }, + { "3", "Run", NULL, run_scene_store_scene, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_recall_scene[] = { + { "1", "Group ID", NULL, NULL, data_group_id }, + { "2", "Scene ID", NULL, NULL, data_scene_id }, + { "3", "Run", NULL, run_scene_recall_scene, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_scene[] = { + { "1", "zb_zcl_scene_add_scene", + _menu_add_scene, NULL, NULL }, + { "2", "zb_zcl_scene_view_scene", + _menu_view_scene, NULL, NULL }, + { "3", "zb_zcl_scene_get_scene_membership", + _menu_get_scene_membership, NULL, NULL }, + { "4", "zb_zcl_scene_remove_scene", + _menu_remove_scene, NULL, NULL }, + { "5", "zb_zcl_scene_remove_all_scene", + _menu_remove_all_scene, NULL, NULL }, + { "6", "zb_zcl_scene_store_scene", + _menu_store_scene, NULL, NULL }, + { "7", "zb_zcl_scene_recall_scene", + _menu_recall_scene, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_cluster_thermostat.c b/test/zcl_cluster_thermostat.c new file mode 100644 index 0000000..76a9c20 --- /dev/null +++ b/test/zcl_cluster_thermostat.c @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern simple_desc_s s_thermostat_ep1; + +static char data_mode[MENU_DATA_SIZE + 1] = "0"; +static char data_amount[MENU_DATA_SIZE + 1] = "1"; + +static int run_adjust_setpoint(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char mode = 0x00; /* HEAT_MODE */ + unsigned char amount = 0x01; + + if (strlen(data_mode)) + mode = (unsigned char)strtol(data_mode, NULL, 10); + if (strlen(data_amount)) + amount = (unsigned char)strtol(data_amount, NULL, 10); + + ret = zb_zcl_thermostat_adjust_setpoint(handle, dest_addr16, + s_thermostat_ep1.ep, mode, amount); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_thermostat_adjust_setpoint(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_thermostat_adjust_setpoint() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_adjust_setpoint[] = { + { "1", "Mode", NULL, NULL, data_mode }, + { "2", "Amount", NULL, NULL, data_amount }, + { "3", "Run", NULL, run_adjust_setpoint, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster_thermostat[] = { + { "1", "zb_zcl_thermostat_adjust_setpoint", + _menu_adjust_setpoint, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zcl_global_cmd.c b/test/zcl_global_cmd.c new file mode 100644 index 0000000..2e55b49 --- /dev/null +++ b/test/zcl_global_cmd.c @@ -0,0 +1,721 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern struct menu_data menu_zcl_cluster_alarm[]; +extern struct menu_data menu_zcl_cluster_basic[]; +extern struct menu_data menu_zcl_cluster_colorctrl[]; +extern struct menu_data menu_zcl_cluster_group[]; +extern struct menu_data menu_zcl_cluster_identity[]; +extern struct menu_data menu_zcl_cluster_ias_zone[]; +extern struct menu_data menu_zcl_cluster_levelctrl[]; +extern struct menu_data menu_zcl_cluster_onoff[]; +extern struct menu_data menu_zcl_cluster_pollctrl[]; +extern struct menu_data menu_zcl_cluster_scene[]; +extern struct menu_data menu_zcl_cluster_thermostat[]; + +extern zigbee_h handle; + +extern nwk_addr panid; +extern ieee_addr co_addr64; + +extern ieee_addr st_addr64; +extern ieee_addr sj_addr64; + +extern nwk_addr dest_addr16; +extern ieee_addr dest_addr64; + +extern simple_desc_s st_ep1, st_ep2, st_ep3, st_ep4, sj_ep1, simul_ep1; + +static char r_data_cluster_id[MENU_DATA_SIZE + 1] = "6"; +static char r_data_attr_id[MENU_DATA_SIZE + 1] = "0"; +static char w_data_cluster_id[MENU_DATA_SIZE + 1] = "3"; +static char w_data_attr_id[MENU_DATA_SIZE + 1] = "0"; +static char w_data_attr_value[MENU_DATA_SIZE + 1] = "180"; +static char data_min_i[MENU_DATA_SIZE + 1] = "A"; +static char data_max_i[MENU_DATA_SIZE + 1] = "3C"; +static char data_timeout[MENU_DATA_SIZE + 1] = "10"; + +static void zigbee_zcl_global_read_attributes_rsp(nwk_addr addr16, + unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, + int records_len, void *user_data) +{ + int count; + unsigned short id; + unsigned char type; + unsigned char status; + unsigned char *buf = NULL; + zb_value_h value = NULL; + read_attr_status_record_h *records; + + msg(""); + msgp("zigbee_zcl_global_read_attributes_rsp()"); + + if (NULL == records_info || ZB_GLOBAL_READ_ATTR != records_info->type + || NULL == records_info->record.read_attr) { + msg("Invalid records info"); + msg("records_info : [%p]", records_info); + if (records_info) { + msg(" type: [%x]", records_info->type); + msg(" type: [%p]", records_info->record.read_attr); + } + return; + } + records = records_info->record.read_attr; + + zb_create_value(&value); + msg(" Cluster ID : 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + msg(" Node ID : 0x%04X", addr16); + msg(" End-Point : 0x%02X", ep); + msg(" Msg length %d", records_len); + + if (records && *records) { + zb_get_id_from_read_attr_status_record(*records, &id); + msg(" Attribute ID : 0x%04X", id); + } + if (records && *records) { + zb_get_type_from_read_attr_status_record(*records, &type); + msg(" Type : 0x%02X", type); + } + if (records && *records) { + zb_get_status_from_read_attr_status_record(*records, &status); + msg(" Status : 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + } + if (records && *records) { + zb_get_value_from_read_attr_status_record(*records, type, value); + if (value) { + zb_get_value(value, &type, &buf, &count); + if (buf) { + msg(" value[0] = 0x%02x", buf[0]); + free(buf); + } + zb_destroy_value(value); + } + } +} + +static void zigbee_zcl_global_write_attributes_rsp(nwk_addr addr16, + unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, + int records_len, void *user_data) +{ + unsigned short id = 0; + unsigned char status; + zb_value_h value = NULL; + write_attr_status_record_h *records; + + msg(""); + msgp("zigbee_zcl_global_write_attributes_rsp()"); + + if (NULL == records_info || ZB_GLOBAL_WRITE_ATTR != records_info->type + || NULL == records_info->record.write_attr) { + msg("Invalid records info"); + return; + } + records = records_info->record.write_attr; + + zb_create_value(&value); + msg(" Cluster ID : 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + msg(" Node ID : 0x%04X", addr16); + msg(" End-Point : 0x%02X", ep); + msg(" Msg length %d", records_len); + + if (records) { + if (ZIGBEE_ERROR_NONE == zb_get_id_from_write_attr_status(*records, &id)) + msg(" AttributeId : 0x%04X", id); + } + if (records) { + zb_get_status_from_write_attr_status(*records, &status); + msg(" status : 0x%02X (%s)", status, zb_get_zcl_error_message(status)); + } + zb_destroy_value(value); +} + +static void zigbee_zcl_global_configure_reporting_rsp(nwk_addr addr16, + unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, + int records_len, void *user_data) +{ + int i; + unsigned char status; + report_config_response_record_h *records; + + msg(""); + msgp("zigbee_zcl_global_configure_reporting_rsp()"); + + if (NULL == records_info || ZB_GLOBAL_CONFIG_REPORT != records_info->type + || NULL == records_info->record.report_config_rsp) { + msg("Invalid records info"); + return; + } + records = records_info->record.report_config_rsp; + + msg(" records_len=%d", records_len); + for (i = 0; i < records_len; i++) { + zb_get_status_from_report_config_response_record(records[i], &status); + msg(" [%d] status = 0x%02X (%s)", i, status, zb_get_zcl_error_message(status)); + } +} + +static void zigbee_zcl_global_read_reporting_configuration_rsp(nwk_addr addr16, + unsigned char ep, unsigned short cluster_id, zb_global_record_data_s *records_info, + int records_len, void *user_data) +{ + zb_value_h val; + int i = 0; + int j = 0; + int count; + int ret; + unsigned char type, *buf = NULL; + unsigned short id, max_i, min_i; + report_config_record_h *records; + + msg(""); + msgp("zigbee_zcl_global_read_reporting_configuration_rsp()"); + + if (NULL == records_info || ZB_GLOBAL_READ_REPORT_CONFIG != records_info->type + || NULL == records_info->record.report_config) { + msg("Invalid records info"); + return; + } + + records = records_info->record.report_config; + msg(" cluster_id 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + msg(" nodeId 0x%04X", addr16); + msg(" endpoint 0x%02X", ep); + msg(" Msg length %d", records_len); + + while (i < records_len) { + msg(" records[%d] 0x%08X", i, id); + zb_get_id_from_report_config_record(records[i], &id); + msg(" AttributeId 0x%04X", id); + zb_get_type_from_report_config_record(records[i], &type); + /*if ((zb_get_analog_or_discret(type) == DATA_TYPE_ANALOG)) {*/ + msg(" type 0x%02X", type); + zb_get_max_i_from_report_config_record(records[i], &max_i); + msg(" Max Interval 0x%04X", max_i); + zb_get_min_i_from_report_config_record(records[i], &min_i); + msg(" Min Interval 0x%04X", min_i); + zb_create_value(&val); + zb_get_change_from_report_config_record1(records[i], val); + ret = zb_get_value(val, &type, &buf, &count); + if (ZIGBEE_ERROR_NONE == ret) { + for (j = 0; j < count; j++) + msg(" value[j] = 0x%02x", buf[j]); + } + + if (buf) { + free(buf); + buf = NULL; + } + + msg(""); + zb_destroy_value(val); + /* + } else { + msg("Unsuccessful Attempt\n"); + } + */ + i++; + } +} + +static void zigbee_zcl_global_discover_attributes_rsp(nwk_addr addr16, + unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, + discover_attr_info_record_h * records, int records_len, void *user_data) +{ + int i; + unsigned char type; + unsigned short id; + + msg(""); + msgp("zigbee_zcl_global_discover_attributes_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + msg(" discovery_complete = %d", discovery_complete); + + for (i = 0; i < records_len; i++) { + zb_get_type_from_discover_attr_info(records[i], &type); + msg(" [%d] type = 0x%02X", i, type); + zb_get_id_from_discover_attr_info(records[i], &id); + msg(" [%d] id = 0x%04X", i, id); + } +} + +static void zigbee_zcl_global_discover_cmds_received_rsp(nwk_addr addr16, + unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, + unsigned char *command_ids, int command_ids_len, void *user_data) +{ + int i; + + msg(""); + msgp("zigbee_zcl_global_discover_cmds_received_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + msg(" discovery_complete = %d", discovery_complete); + + for (i = 0; i < command_ids_len; i++) + msg(" command_id[%d] = 0x%02X", i, command_ids[i]); +} + +static void zigbee_zcl_global_discover_cmds_generated_rsp(nwk_addr addr16, + unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, + unsigned char *command_ids, int command_ids_len, void *user_data) +{ + int i; + + msg(""); + msgp("zigbee_zcl_global_discover_cmds_generated_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + msg(" discovery_complete = %d", discovery_complete); + + for (i = 0; i < command_ids_len; i++) + msg(" command_id[%d] = 0x%02X", i, command_ids[i]); +} + +static void zigbee_zcl_global_discover_attr_extended_rsp(nwk_addr addr16, + unsigned char ep, unsigned short cluster_id, unsigned char discovery_complete, + extended_attr_info_h *records, unsigned short records_len, void *user_data) +{ + int i; + unsigned char type; + unsigned short id; + unsigned char acl; + + msg(""); + msgp("zigbee_zcl_global_discover_attr_extended_rsp()"); + + msg(" Network Address = 0x%04X", addr16); + msg(" End-Point = 0x%02X", ep); + msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + msg(" discovery_complete = %d", discovery_complete); + + for (i = 0; i < records_len; i++) { + zb_get_id_from_extended_attr_info(records[i], &id); + msg(" [%d] id = 0x%02X", i, id); + zb_get_type_from_extended_attr_info(records[i], &type); + msg(" [%d] type = 0x%04X", i, type); + zb_get_acl_from_extended_attr_info(records[i], &acl); + msg(" [%d] acl = 0x%04X", i, acl); + } +} + +static int run_global_read_attr(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; +#if 0 + /* For SmartThings open/close sensor */ + unsigned short st_cluster_id = ZB_ZCL_IAS_ZONE_CLUSTER_ID; + unsigned short st_attribute_id[] = { + ZB_ZCL_ZONE_STATE_ATTRIBUTE_ID, + ZB_ZCL_ZONE_TYPE_ATTRIBUTE_ID, + ZB_ZCL_ZONE_STATUS_ATTRIBUTE_ID, + ZB_ZCL_IAS_CIE_ADDRESS_ATTRIBUTE_ID, + ZB_ZCL_ZONE_ID_ATTRIBUTE_ID + }; + + int st_len_of_attr = sizeof(st_attribute_id) / sizeof(st_attribute_id[0]); + /* Reading zone state attribute */ + ret = zb_zcl_global_read_attr(handle, dest_addr16, 1, st_ep1.ep, + -1, st_cluster_id, st_attribute_id, st_len_of_attr, + zigbee_zcl_global_read_attributes_rsp, NULL); +#endif +#if 0 + /* Reading active power report in electrical measurement cluster */ + sj_cluster_id = ZB_ZCL_ELECTRICAL_MEASUREMENT_CLUSTER_ID; + sj_attribute_id[0] = ZB_ZCL_ACTIVE_POWER_ATTRIBUTE_ID; + sj_len_of_attr = 1; + + ret = zb_zcl_global_read_attr(handle, dest_addr16, 1, sj_ep1.ep, + -1, sj_cluster_id, sj_attribute_id, sj_len_of_attr, + zigbee_zcl_global_read_attributes_rsp, NULL); +#endif + + unsigned short cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; + unsigned short attribute_id[] = { + ZB_ZCL_ON_OFF_ATTRIBUTE_ID + }; + int len_of_attr = sizeof(attribute_id) / sizeof(attribute_id[0]); + + if (strlen(r_data_cluster_id)) + cluster_id = (unsigned short)strtol(r_data_cluster_id, NULL, 16); + if (strlen(r_data_attr_id)) + attribute_id[0] = (unsigned short)strtol(r_data_attr_id, NULL, 16); + + ret = zb_zcl_global_read_attr(handle, dest_addr16, 1, 1, + ZB_ZCL_FC_DEFAULT, cluster_id, attribute_id, len_of_attr, + zigbee_zcl_global_read_attributes_rsp, NULL); + + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_read_attr(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_read_attr() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_write_attr(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + /* Samjin Power Outlet */ + write_attr_record_h attr; + + unsigned short cluster_id = ZB_ZCL_IDENTIFY_CLUSTER_ID; + unsigned short attribute_id = ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID; + unsigned short temp; + unsigned char attribute_value[] = {0,}; + + if (strlen(w_data_cluster_id)) + cluster_id = (unsigned short)strtol(w_data_cluster_id, NULL, 16); + if (strlen(w_data_attr_id)) + attribute_id = (unsigned short)strtol(w_data_attr_id, NULL, 16); + if (strlen(w_data_attr_value)) { + temp = (unsigned short)strtol(w_data_attr_value, NULL, 16); + memcpy(attribute_value, &temp, sizeof(unsigned short)); + } + + zb_create_write_attr_record(&attr); + //zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); + zb_set_id_to_write_attr_record(attr, attribute_id); + zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); + zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, attribute_value, + zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); + + ret = zb_zcl_global_write_attr(handle, dest_addr16, 1, sj_ep1.ep, + ZB_ZCL_FC_DEFAULT, + cluster_id, &attr, 1, + zigbee_zcl_global_write_attributes_rsp, NULL); + zb_destroy_write_attr_record(attr); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_write_attr(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_write_attr() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_write_attr_undivided(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char value[] = { 0x02, 0x01}; + /* Samjin Power Outlet */ + write_attr_record_h attr; + + zb_create_write_attr_record(&attr); + zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); + zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); + zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, value, + zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); + ret = zb_zcl_global_write_attr_undivided(handle, dest_addr16, 1, + sj_ep1.ep, ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, &attr, 1, + zigbee_zcl_global_write_attributes_rsp, NULL); + zb_destroy_write_attr_record(attr); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_write_attr_undivided(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_write_attr_undivided() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_write_attr_no_rsp(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char value[] = { 0x02, 0x01}; + /* Samjin Power Outlet */ + write_attr_record_h attr; + + zb_create_write_attr_record(&attr); + zb_set_id_to_write_attr_record(attr, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID); + zb_set_type_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER); + zb_set_buf_to_write_attr_record(attr, ZB_ZCL_UNSIGNED_16_BIT_INTEGER, value, + zb_get_data_size(ZB_ZCL_UNSIGNED_16_BIT_INTEGER)); + ret = zb_zcl_global_write_attr_no_rsp(handle, dest_addr16, 1, sj_ep1.ep, + ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, &attr, 1); + zb_destroy_write_attr_record(attr); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_write_attr_no_rsp(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_write_attr_no_rsp() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_config_report(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + /* Samjin Power Outlet */ + unsigned char val1 = 1; + report_config_record_h config; + unsigned short cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; + unsigned short attribute_id = ZB_ZCL_ON_OFF_ATTRIBUTE_ID; + unsigned short min_i; + unsigned short max_i; + unsigned short timeout; + + if (strlen(r_data_cluster_id)) + cluster_id = (unsigned short)strtol(r_data_cluster_id, NULL, 16); + if (strlen(r_data_attr_id)) + attribute_id = (unsigned short)strtol(r_data_attr_id, NULL, 16); + + if (strlen(data_min_i)) + min_i = (unsigned short)strtol(data_min_i, NULL, 16); + if (strlen(data_max_i)) + max_i = (unsigned short)strtol(data_max_i, NULL, 16); + if (strlen(data_timeout)) + timeout = (unsigned short)strtol(data_timeout, NULL, 10); + + zb_create_report_config_record(&config); + zb_set_dir_to_report_config_record(config, ZB_ZCL_CLIENT_TO_SERVER); + zb_set_id_to_report_config_record(config, attribute_id); + zb_set_type_to_report_config_record(config, ZB_ZCL_BOOLEAN); + zb_set_min_i_to_report_config_record(config, min_i); + zb_set_max_i_to_report_config_record(config, max_i); + zb_set_change_to_report_config_record2(config, ZB_ZCL_BOOLEAN, &val1); + zb_set_timeout_to_report_config_record(config, timeout); + + ret = zb_zcl_global_config_report(handle, dest_addr16, 1, sj_ep1.ep, + ZB_ZCL_FC_DEFAULT, cluster_id, &config, 1, + zigbee_zcl_global_configure_reporting_rsp, NULL); + zb_destroy_report_config_record(config); +#if 0 + /* ST Open/Close Sensor */ + report_config_record_h config1; + unsigned short val2 = 0x007f; + + zb_create_report_config_record(&config1); + zb_set_dir_to_report_config_record(config1, ZB_ZCL_CLIENT_TO_SERVER); + zb_set_id_to_report_config_record(config1, ZB_ZCL_ZONE_STATE_ATTRIBUTE_ID); + zb_set_type_to_report_config_record(config1, ZB_ZCL_SIGNED_16_BIT_INTEGER); + zb_set_min_i_to_report_config_record(config1, 0); + zb_set_max_i_to_report_config_record(config1, 60); + zb_set_change_to_report_config_record(config1, ZB_ZCL_SIGNED_16_BIT_INTEGER, &val2); + zb_set_timeout_to_report_config_record(config1, 60); + ret = zb_zcl_global_config_report(handle, dest_addr16, 1, st_ep1.ep, + ZB_ZCL_FC_DEFAULT, ZB_ZCL_TEMP_MEASUREMENT_CLUSTER_ID, &config1, 1, + zigbee_zcl_global_configure_reporting_rsp, NULL); + zb_destroy_report_config_record(config1); +#endif + + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_config_report(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_config_report() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_read_config_report(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + read_report_config_record_h read_report_conf; + + zb_create_read_report_config_record(&read_report_conf); + zb_set_dir_to_read_report_config_record(read_report_conf, ZB_ZCL_CLIENT_TO_SERVER); + zb_set_id_to_read_report_config_record(read_report_conf, ZB_ZCL_ON_OFF_ATTRIBUTE_ID); + + /* Samjin Power Outlet */ + ret = zb_zcl_global_read_config_report(handle, dest_addr16, 1, sj_ep1.ep, + ZB_ZCL_FC_DEFAULT, ZB_ZCL_ON_OFF_CLUSTER_ID, &read_report_conf, 1, + zigbee_zcl_global_read_reporting_configuration_rsp, NULL); + zb_destroy_read_report_config_record(read_report_conf); + + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_read_config_report(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_read_config_report() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_discover_attr(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; +#if 0 + /* For ST Open/Close Sensor */ + ret = zb_zcl_global_discover_attr(handle, dest_addr16, 1, st_ep1.ep, + ZB_ZCL_FC_DEFAULT, ZB_ZCL_IDENTIFY_CLUSTER_ID, ZB_ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + 2, zigbee_zcl_global_discover_attributes_rsp, NULL); +#endif + /* For SJ Power Outlet */ + ret = zb_zcl_global_discover_attr(handle, dest_addr16, 1, sj_ep1.ep, + ZB_ZCL_FC_DEFAULT, ZB_ZCL_ON_OFF_CLUSTER_ID, ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, + zigbee_zcl_global_discover_attributes_rsp, NULL); + + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_discover_attr(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_discover_attr() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_discover_cmds_received(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + ret = zb_zcl_global_discover_cmds_received(handle, dest_addr16, 1, sj_ep1.ep, + ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_ON_OFF_CLUSTER_ID, + ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, + zigbee_zcl_global_discover_cmds_received_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_discover_cmds_received(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_discover_cmds_received() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_discover_cmds_generated(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + ret = zb_zcl_global_discover_cmds_generated(handle, dest_addr16, 1, sj_ep1.ep, + ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_GROUPS_CLUSTER_ID, 0x00, 4, + zigbee_zcl_global_discover_cmds_generated_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_discover_cmds_generated(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_discover_cmds_generated() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_global_discover_attr_extended(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + ret = zb_zcl_global_discover_attr_extended(handle, dest_addr16, 1, sj_ep1.ep, + ZB_ZCL_DISABLE_DEFAULT_RESPONSE, ZB_ZCL_ON_OFF_CLUSTER_ID, + ZB_ZCL_ON_OFF_ATTRIBUTE_ID, 5, + zigbee_zcl_global_discover_attr_extended_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zcl_global_discover_attr_extended(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zcl_global_discover_attr_extended() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +struct menu_data menu_zcl_global_read_attr[] = { + { "1", "Cluster ID (Hex)", NULL, NULL, r_data_cluster_id }, + { "2", "Attribute ID (Hex)", NULL, NULL, r_data_attr_id }, + { "3", "run", NULL, run_global_read_attr, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_global_write_attr[] = { + { "1", "Cluster ID (Hex)", NULL, NULL, w_data_cluster_id }, + { "2", "Attribute ID (Hex)", NULL, NULL, w_data_attr_id }, + { "3", "Attribute Value (Hex)", NULL, NULL, w_data_attr_value }, + { "4", "run", NULL, run_global_write_attr, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_global_config_report[] = { + { "1", "Cluster ID (Hex)", NULL, NULL, r_data_cluster_id }, + { "2", "Attribute ID (Hex)", NULL, NULL, r_data_attr_id }, + { "3", "Min interval (Hex)", NULL, NULL, data_min_i }, + { "4", "Max interval (Hex)", NULL, NULL, data_max_i }, + { "5", "Timeout", NULL, NULL, data_timeout }, + { "6", "run", NULL, run_global_config_report, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_global[] = { + { "1", "zb_zcl_global_read_attr", + menu_zcl_global_read_attr, NULL, NULL }, + { "2", "zb_zcl_global_write_attr", + menu_zcl_global_write_attr, NULL, NULL }, + { "3", "zb_zcl_global_write_attr_undivided", + NULL, run_global_write_attr_undivided, NULL }, + { "4", "zb_zcl_global_write_attr_no_rsp", + NULL, run_global_write_attr_no_rsp, NULL }, + { "5", "zb_zcl_global_config_report", + menu_zcl_global_config_report, NULL, NULL }, + { "6", "zb_zcl_global_read_config_report", + NULL, run_global_read_config_report, NULL }, + { "7", "zb_zcl_global_discover_attr", + NULL, run_global_discover_attr, NULL }, + { "8", "zb_zcl_global_discover_cmds_received", + NULL, run_global_discover_cmds_received, NULL }, + { "9", "zb_zcl_global_discover_cmds_generated", + NULL, run_global_discover_cmds_generated, NULL }, + { "10", "zb_zcl_global_discover_attr_extended", + NULL, run_global_discover_attr_extended, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zcl_cluster[] = { + { "1", "Alarm Cluster", menu_zcl_cluster_alarm, NULL, NULL }, + { "2", "Basic Cluster", menu_zcl_cluster_basic, NULL, NULL }, + { "3", "Color Control Cluster", menu_zcl_cluster_colorctrl, NULL, NULL }, + { "4", "Group Cluster", menu_zcl_cluster_group, NULL, NULL }, + { "5", "IAS zone Cluster", menu_zcl_cluster_ias_zone, NULL, NULL }, + { "6", "Identity Cluster", menu_zcl_cluster_identity, NULL, NULL }, + { "7", "Level Control Cluster", menu_zcl_cluster_levelctrl, NULL, NULL }, + { "8", "On/Off Cluster", menu_zcl_cluster_onoff, NULL, NULL }, + { "9", "Poll Control Cluster", menu_zcl_cluster_pollctrl, NULL, NULL }, + { "10", "Scene Cluster", menu_zcl_cluster_scene, NULL, NULL }, + { "11", "Simple Metering Cluster", NULL, NULL, NULL }, + { "12", "Thermostat Cluster", menu_zcl_cluster_thermostat, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zdo-binding.c b/test/zdo-binding.c deleted file mode 100644 index 0544bea..0000000 --- a/test/zdo-binding.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr panid; -extern ieee_addr co_addr64; - -extern ieee_addr st_addr64; -extern ieee_addr sj_addr64; - -extern nwk_addr dest_addr16; -extern ieee_addr dest_addr64; - -extern simple_desc_s sj_ep1; - -/* ZB_ZCL_ON_OFF_CLUSTER_ID */ -static char data_cluster_id[MENU_DATA_SIZE + 1] = "6"; - -static void zigbee_zdo_bind_unbind_rsp(unsigned char status, void *user_data) -{ - msg(""); - msgp("zigbee_zdo_bind_unbind_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); -} - -static int run_bind_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char src_ep = 1; - unsigned short cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; - - if (strlen(data_cluster_id)) - cluster_id = (unsigned short)strtol(data_cluster_id, NULL, 16); - -#if 0 - /* Samjin Power Outlet */ - ret = zb_zdo_bind_req(handle, sj_addr16, sj_addr64, 1, - ZB_ZCL_DIAGNOSTICS_CLUSTER_ID, co_addr64, - ZB_UNICAST_BINDING, 0x0004, 1, zigbee_zdo_bind_unbind_rsp, NULL); - /* For ST Open/Close Sensor */ - ret = zb_zdo_bind_req(handle, st_addr16, st_addr64, 1, - ZB_ZCL_IAS_ZONE_CLUSTER_ID, co_addr64, - ZB_UNICAST_BINDING, panid, 1, zigbee_zdo_bind_unbind_rsp, NULL); -#endif - - ret = zb_zdo_bind_req(handle, dest_addr16, sj_addr64, src_ep, cluster_id, - co_addr64, ZB_UNICAST_BINDING, 0x0004, sj_ep1.ep, - zigbee_zdo_bind_unbind_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_bind_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_bind_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_unbind_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned short cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; - - if (strlen(data_cluster_id)) - cluster_id = (unsigned short)strtol(data_cluster_id, NULL, 16); - - ret = zb_zdo_unbind_req(handle, dest_addr16, co_addr64, 1, cluster_id, - sj_addr64, ZB_UNICAST_BINDING, panid, 1, - zigbee_zdo_bind_unbind_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_unbind_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_unbind_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_bind[] = { - { "1", "Cluster ID (in hex)", NULL, NULL, data_cluster_id }, - { "2", "Run", NULL, run_bind_req, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_unbind[] = { - { "1", "Cluster ID (in hex)", NULL, NULL, data_cluster_id }, - { "2", "Run", NULL, run_unbind_req, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zdo_binding[] = { - { "1", "zb_zdo_bind_req", _menu_bind, NULL, NULL }, - { "2", "zb_zdo_unbind_req", _menu_unbind, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zdo-device.c b/test/zdo-device.c deleted file mode 100644 index b1c9f28..0000000 --- a/test/zdo-device.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern struct menu_data menu_zdo_network[]; -extern struct menu_data menu_zdo_binding[]; - -extern nwk_addr panid; -extern ieee_addr co_addr64; - -extern nwk_addr st_addr16; -extern ieee_addr st_addr64; - -extern nwk_addr sj_addr16; -extern ieee_addr sj_addr64; - -extern nwk_addr dest_addr16; -extern ieee_addr dest_addr64; - -extern simple_desc_s st_ep1, sj_ep1; - -static void zigbee_addr_rsp(unsigned char status, ieee_addr addr64, nwk_addr addr16, - unsigned char num_of_assoc_dev, unsigned char start_idx, unsigned short - *assoc_dev_addr_list, void *user_data) -{ - msg(""); - msgp("zb_zdo_addr_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); - if (addr64) { - msg("IEEE Address : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:", - addr64[0], addr64[1], addr64[2], addr64[3], - addr64[4], addr64[5], addr64[6], addr64[7]); - } else - msg("IEEE Address : 00:00:00:00:00:00:00:00:"); - msg("Network Address : 0x%04X", addr16); - msg("Number of Associated Device : %d", num_of_assoc_dev); - msg("Start Index : %d", start_idx); -} - -static void zigbee_active_ep_rsp(unsigned char status, nwk_addr addr16, - unsigned char count, unsigned char *ep_list, void *user_data) -{ - int i; - msg(""); - msg("count = 0x%02X", count); - for (i = 0; i < count; i++) - msg("EP = 0x%02X", ep_list[i]); - msgp("zb_zdo_active_ep_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); -} - -static void zigbee_simple_desc_rsp(nwk_addr addr16, unsigned char len, - const zb_zdo_simple_desc_h handle, void *user_data) -{ - int i, ret; - unsigned char param_u8; - unsigned short param_u16; - unsigned short *in_clusters; - unsigned short *out_clusters; - - msg(""); - msgp("zb_zdo_simple_desc_rsp()"); - - ret = zb_simple_desc_get_ep(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - msg("zb_simple_desc_get_ep() Fail(0x%X)", ret); - else - msg(" ep = %d", param_u8); - - ret = zb_simple_desc_get_profile_id(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - msg("zb_simple_desc_get_profile_id() Fail(0x%X)", ret); - else - msg(" profile_id = 0x%x (%s)", param_u16, zb_get_profile_id_string(param_u16)); - - ret = zb_simple_desc_get_device_id(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - msg("zb_simple_desc_get_device_id() Fail(0x%X)", ret); - else - msg(" device_id = 0x%x (%s)", param_u16, zb_get_device_id_string(param_u16)); - - ret = zb_simple_desc_get_device_ver(handle, ¶m_u16); - if (ZIGBEE_ERROR_NONE != ret) - msg("zb_simple_desc_get_device_ver() Fail(0x%X)", ret); - else - msg(" device_ver = %d", param_u16); - - ret = zb_simple_desc_get_num_of_in_clusters(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - msg("zb_simple_desc_get_num_of_in_clusters() Fail(0x%X)", ret); - else - msg(" num_of_in_cluster = %d", param_u8); - - ret = zb_simple_desc_get_in_clusters(handle, &in_clusters); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_simple_desc_get_in_clusters() Fail(0x%X)", ret); - } else { - for (i = 0; i < param_u8; i++) - msg(" %04X (%s)", in_clusters[i], zb_get_cluster_name(in_clusters[i])); - } - - ret = zb_simple_desc_get_num_of_out_clusters(handle, ¶m_u8); - if (ZIGBEE_ERROR_NONE != ret) - msg("zb_simple_desc_get_num_of_out_clusters() Fail(0x%X)", ret); - else - msg(" num_of_out_cluster = %d", param_u8); - - ret = zb_simple_desc_get_out_clusters(handle, &out_clusters); - if (ZIGBEE_ERROR_NONE != ret) - msg("zb_simple_desc_get_out_clusters() Fail(0x%X)", ret); - else { - for (i = 0; i < param_u8; i++) - msg(" %04X (%s)", out_clusters[i], zb_get_cluster_name(out_clusters[i])); - } -} - -static void zigbee_match_desc_rsp(unsigned char status, nwk_addr addr16, - unsigned char match_length, unsigned char *match_list, void *user_data) -{ - unsigned char i; - msg(""); - msgp("zb_zdo_match_desc_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); - - msg(" nwk_addr = 0x%04X status = 0x%02X match_length = %d", - addr16, status, match_length); - - for (i = 0; i < match_length; i++) - msg(" match_list[%d] = 0x%02x", i, (unsigned int)match_list[i]); -} - -static void zigbee_zdo_power_desc_rsp(unsigned char status, nwk_addr addr16, - const zb_zdo_node_power_descriptor_h power_desc, void *user_data) -{ - unsigned char current_power_mode; - unsigned char available_power_source; - unsigned char current_power_source; - unsigned char current_power_source_lv; - - msg(""); - msgp("zb_zdo_power_desc_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); - - zb_node_power_desc_get_current_power_mode(power_desc, ¤t_power_mode); - msg(" current_power_mode = %02X", current_power_mode); - zb_node_power_desc_get_available_power_sources(power_desc, &available_power_source); - msg(" available_power_source = %02X", available_power_source); - zb_node_power_desc_get_current_power_source(power_desc, ¤t_power_source); - msg(" current_power_source = %02X", current_power_source); - zb_node_power_desc_get_current_power_source_level(power_desc, ¤t_power_source_lv); - msg(" current_power_source_level = %02X", current_power_source_lv); -} - -static void zigbee_zdo_complex_desc_rsp(unsigned char status, nwk_addr addr16, - unsigned char length, unsigned char *complex_desc, void *user_data) -{ - msg(""); - msgp("zb_zdo_complex_desc_rsp() status = 0x%02X (%s) length = %d", - status, zb_zdo_get_error_message(status), length); -} - -static void zigbee_zdo_user_desc_rsp(unsigned char status, nwk_addr addr16, - unsigned char length, unsigned char *user_desc, void *user_data) -{ - msg(""); - msgp("zb_zdo_user_desc_rsp() status = 0x%02X (%s) length = %d", - status, zb_zdo_get_error_message(status), length); -} - -static void zigbee_zdo_user_desc_conf(unsigned char status, void *user_data) -{ - msg(""); - msgp("zb_zdo_user_desc_conf() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); -} - -static void zigbee_zdo_node_desc_rsp(unsigned char status, nwk_addr addr16, - const zb_zdo_node_descriptor_h desc, void *user_data) -{ - unsigned char logical_type; - unsigned char complex_desciptor_available; - unsigned char user_descriptor_available; - unsigned char aps_flags; - unsigned char frequency_band; - unsigned char mac_capability_flags; - unsigned short manufacturer_code; - unsigned char maximum_buffer_size; - unsigned short maximum_incoming_transfer_size; - unsigned short server_mask; - unsigned short maximum_outgoing_transfer_size; - unsigned short descriptor_capability_field; - - msg(""); - msgp("zb_zdo_node_desc_rsp()"); - msgp(" nwk_addr = 0x%04X status = 0x%02X (%s)", addr16, status, zb_zdo_get_error_message(status)); - - zb_node_desc_get_logical_type(desc, &logical_type); - msg(" logical_type = 0x%02X", logical_type); - zb_node_desc_get_complex_desciptor_available(desc, &complex_desciptor_available); - msg(" complex_desciptor_available = 0x%02X", complex_desciptor_available); - zb_node_desc_get_user_descriptor_available(desc, &user_descriptor_available); - msg(" complex_desciptor_available = 0x%02X", complex_desciptor_available); - zb_node_desc_get_aps_flags(desc, &aps_flags); - msg(" aps_flags = 0x%02X", aps_flags); - zb_node_desc_get_frequency_band(desc, &frequency_band); - msg(" frequency_band = 0x%02X", frequency_band); - zb_node_desc_get_mac_capability_flags(desc, &mac_capability_flags); - msg(" mac_capability_flags = 0x%02X", mac_capability_flags); - zb_node_desc_get_manufacturer_code(desc, &manufacturer_code); - msg(" manufacturer_code = 0x%04X", manufacturer_code); - zb_node_desc_get_maximum_buffer_size(desc, &maximum_buffer_size); - msg(" maximum_buffer_size = 0x%02X", maximum_buffer_size); - zb_node_desc_get_maximum_incoming_transfer_size(desc, &maximum_incoming_transfer_size); - msg(" maximum_incoming_transfer_size = 0x%04X", maximum_incoming_transfer_size); - zb_node_desc_get_server_mask(desc, &server_mask); - msg(" server_mask = 0x%04X", server_mask); - zb_node_desc_get_maximum_outgoing_transfer_size(desc, &maximum_outgoing_transfer_size); - msg(" maximum_outgoing_transfer_size = 0x%04X", maximum_outgoing_transfer_size); - zb_node_desc_get_descriptor_capability_field(desc, &descriptor_capability_field); - msg(" descriptor_capability_field = 0x%04X", descriptor_capability_field); -} - -static int run_nwk_addr_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - msg("IEEE Address : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:", - st_addr64[0], st_addr64[1], st_addr64[2], st_addr64[3], - st_addr64[4], st_addr64[5], st_addr64[6], st_addr64[7]); - - ret = zb_zdo_nwk_addr_req(handle, dest_addr64, 0x00, 0x00, - zigbee_addr_rsp, NULL); - if (ret != ZIGBEE_ERROR_NONE) { - msg("zb_zdo_nwk_addr_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_nwk_addr_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_ieee_addr_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_ieee_addr_req(handle, dest_addr16, zigbee_addr_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_ieee_addr_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_ieee_addr_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_active_ep(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_active_ep(handle, dest_addr16, zigbee_active_ep_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_active_ep(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_active_ep() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_simple_desc_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_simple_desc_req(handle, dest_addr16, 1, - zigbee_simple_desc_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_simple_desc_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_simple_desc_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_match_desc_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; -#if 0 - /* for ST open/close sensor */ - ret = zb_zdo_match_desc_req(handle, st_addr16, st_ep1.profile_id, - st_ep1.num_of_in_clusters, st_ep1.in_clusters, - st_ep1.num_of_out_clusters, st_ep1.out_clusters, - zigbee_match_desc_rsp, user_data); -#endif - /* for SJ power outlet */ - ret = zb_zdo_match_desc_req(handle, dest_addr16, sj_ep1.profile_id, - sj_ep1.num_of_in_clusters, sj_ep1.in_clusters, - sj_ep1.num_of_out_clusters, sj_ep1.out_clusters, - zigbee_match_desc_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_match_desc_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_match_desc_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_power_desc_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_power_desc_req(handle, dest_addr16, - zigbee_zdo_power_desc_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_power_desc_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_power_desc_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_complex_desc_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_complex_desc_req(handle, dest_addr16, - zigbee_zdo_complex_desc_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_complex_desc_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_complex_desc_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_user_desc_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_user_desc_req(handle, dest_addr16, - zigbee_zdo_user_desc_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_user_desc_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_user_desc_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_user_desc_set(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_user_desc_set(handle, dest_addr16, 4, (unsigned char*)"test", - zigbee_zdo_user_desc_conf, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_user_desc_set(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_user_desc_set() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_node_desc_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_node_desc_req(handle, dest_addr16, - zigbee_zdo_node_desc_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_node_desc_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_node_desc_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_device_annce(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - - ret = zb_zdo_device_annce(handle, st_addr16, st_addr64, - ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR | ZB_ZDP_DEVICE_TYPE - | ZB_ZDP_POWER_SOURCE | ZB_ZDP_RECEIVER_ON_WHEN_IDLE - | ZB_ZDP_ALLOCATE_ADDRESS); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_device_annce(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_device_annce() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -struct menu_data menu_zdo_device[] = { - { "1", "zb_zdo_nwk_addr_req", NULL, run_nwk_addr_req, NULL }, - { "2", "zb_zdo_ieee_addr_req", NULL, run_ieee_addr_req, NULL }, - { "3", "zb_zdo_active_ep", NULL, run_active_ep, NULL }, - { "4", "zb_zdo_simple_desc_req", NULL, run_simple_desc_req, NULL }, - { "5", "zb_zdo_match_desc_req", NULL, run_match_desc_req, NULL }, - { "6", "zb_zdo_power_desc_req", NULL, run_power_desc_req, NULL }, - { "7", "zb_zdo_complex_desc_req", NULL, run_complex_desc_req, NULL }, - { "8", "zb_zdo_user_desc_req", NULL, run_user_desc_req, NULL }, - { "9", "zb_zdo_user_desc_set", NULL, run_user_desc_set, NULL }, - { "10", "zb_zdo_node_desc_req", NULL, run_node_desc_req, NULL }, - { "11", "zb_zdo_device_annce", NULL, run_device_annce, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zdo-network.c b/test/zdo-network.c deleted file mode 100644 index 20f8d94..0000000 --- a/test/zdo-network.c +++ /dev/null @@ -1,450 +0,0 @@ -/* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. - * - * 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 -#include -#include -#include - -#include - -#include "main.h" -#include "menu.h" - -extern zigbee_h handle; - -extern nwk_addr dest_addr16; -extern ieee_addr dest_addr64; - -static char data_duration[MENU_DATA_SIZE + 1] = "5"; -static char data_count[MENU_DATA_SIZE + 1] = "4"; -static char data_start_idx[MENU_DATA_SIZE + 1] = "0"; -static char data_nwk_update_id[MENU_DATA_SIZE + 1] = "0"; -static char data_remove_children[MENU_DATA_SIZE + 1] = "1"; -static char data_rejoin[MENU_DATA_SIZE + 1] = "1"; -static char data_permit_duration[MENU_DATA_SIZE + 1] = "1"; -static char data_tc[MENU_DATA_SIZE + 1] = "1"; - -static void zigbee_zdo_mgmt_nwk_disc_rsp(unsigned char status, - unsigned char network_count, unsigned char start_idx, unsigned char network_list_count, - const zb_zdo_network_list_record_h *records, void *user_data) -{ - int i = 0; - ieee_addr extended_pan_id; - unsigned char logical_channel; - unsigned char stack_profile; - unsigned char zigbee_version; - unsigned char beacon_order; - unsigned char superframe_order; - unsigned char permit_joining; - - msg(""); - msgp("zb_zdo_mgmt_nwk_disc_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); - - if (!status) { - msg(" network_count 0x%02X", network_count); - msg(" start_idx 0x%02X", start_idx); - msg(" network_list_count 0x%02X", network_list_count); - for (i = 0; i < network_list_count; i++) { - zb_network_list_record_get_extended_pan_id(records[i], extended_pan_id); - msg(" Extended PanId %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - extended_pan_id[7], extended_pan_id[6], - extended_pan_id[5], extended_pan_id[4], - extended_pan_id[3], extended_pan_id[2], - extended_pan_id[1], extended_pan_id[0]); - zb_network_list_record_get_logical_channel(records[i], &logical_channel); - msg(" Logical Channel 0x%02X", logical_channel); - zb_network_list_record_get_stack_profile(records[i], &stack_profile); - msg(" stack_profile 0x%02X", stack_profile); - zb_network_list_record_get_zigbee_version(records[i], &zigbee_version); - msg(" zigbee_version 0x%02X", zigbee_version); - zb_network_list_record_get_beacon_order(records[i], &beacon_order); - msg(" Beacon_order 0x%02X", beacon_order); - zb_network_list_record_get_superframe_order(records[i], &superframe_order); - msg(" Superframe_order 0x%02X", superframe_order); - zb_network_list_record_get_permit_joining(records[i], &permit_joining); - msg(" Permit joining 0x%02X", permit_joining); - } - } else { - msg(" Unsuccessful Nwk discovery"); - } -} - -static void zigbee_zdo_mgmt_lqi_rsp(unsigned char status, - unsigned char neighbor_table_entries, unsigned char start_idx, - unsigned char neighbor_table_list_count, - const zb_zdo_neighbor_table_desc_h *neighbor_table_list, void *user_data) -{ - int i; - ieee_addr extended_pan_id; - ieee_addr addr64; - nwk_addr addr16; - unsigned char device_type; - unsigned char rx_on_when_idle; - unsigned char releationship; - unsigned char permit_joining; - unsigned char depth; - unsigned char lqi; - - msg(""); - msgp("zb_zdo_mgmt_lqi_rsp()"); - msgp(" status = 0x%02X (%s) start_idx=%d count=%d", status, - zb_zdo_get_error_message(status), start_idx, neighbor_table_list_count); - for (i = start_idx; i < neighbor_table_list_count; i++) { - zb_neighbor_table_desc_get_extended_pan_id(neighbor_table_list[i], extended_pan_id); - msg(" ext PAN ID = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - extended_pan_id[0], extended_pan_id[1], extended_pan_id[2], extended_pan_id[3], - extended_pan_id[4], extended_pan_id[5], extended_pan_id[6], extended_pan_id[7]); - zb_neighbor_table_desc_get_ieee_addr(neighbor_table_list[i], addr64); - msg(" IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); - zb_neighbor_table_desc_get_nwk_addr(neighbor_table_list[i], &addr16); - msg(" Network address = 0x%04X", addr16); - zb_neighbor_table_desc_get_device_type(neighbor_table_list[i], &device_type); - msg(" Device Type = 0x%02X", device_type); - zb_neighbor_table_desc_get_rx_on_when_idle(neighbor_table_list[i], &rx_on_when_idle); - msg(" Rx on idle = 0x%02X", rx_on_when_idle); - zb_neighbor_table_desc_get_relationship(neighbor_table_list[i], &releationship); - msg(" Relationship = 0x%02X", releationship); - zb_neighbor_table_desc_get_permit_joining(neighbor_table_list[i], &permit_joining); - msg(" Permit Joining = 0x%02X", permit_joining); - zb_neighbor_table_desc_get_depth(neighbor_table_list[i], &depth); - msg(" Depth = 0x%02X", depth); - zb_neighbor_table_desc_get_lqi(neighbor_table_list[i], &lqi); - msg(" LQI = 0x%02X", lqi); - } -} - -static void zigbee_zdo_mgmt_rtg_rsp(unsigned char status, - unsigned char routing_table_entries, unsigned char start_idx, - unsigned char routing_table_list_count, - const zb_zdo_routing_table_h *routing_table_list, void *user_data) -{ - int i; - nwk_addr dst_addr; - unsigned char mode; - unsigned char memory_constrained; - unsigned char many_to_one; - unsigned char route_record_required; - nwk_addr next_hop_addr; - - msg(""); - msgp("zb_zdo_mgmt_rtg_rsp()"); - msgp(" status = 0x%02X (%s) routing_table_entries=%d start_idx=%d count=%d", - status, zb_zdo_get_error_message(status), - routing_table_entries, start_idx, routing_table_list_count); - for (i = start_idx; i < routing_table_list_count; i++) { - zb_routing_table_get_dst_addr(routing_table_list[i], &dst_addr); - msg(" [%d] Destination address = 0x%04X", i, dst_addr); - zb_routing_table_get_dst_status(routing_table_list[i], &mode); - msg(" [%d] Status = 0x%02X", i, mode); - zb_routing_table_get_memory_constrained(routing_table_list[i], &memory_constrained); - msg(" [%d] memory_constrained = 0x%02X", i, memory_constrained); - zb_routing_table_get_many_to_one(routing_table_list[i], &many_to_one); - msg(" [%d] many_to_one = 0x%02X", i, many_to_one); - zb_routing_table_get_route_record_required(routing_table_list[i], &route_record_required); - msg(" [%d] route_record_required = 0x%02X", i, route_record_required); - zb_routing_table_get_next_hop_addr(routing_table_list[i], &next_hop_addr); - msg(" [%d] next_hop_addr = 0x%04X", i, next_hop_addr); - msg(""); - } -} - -static void zigbee_zdo_mgmt_bind_rsp(unsigned char status, unsigned char entries, - unsigned char start_idx, unsigned char binding_table_list_count, const zb_zdo_binding_table_h *list, - void *user_data) -{ - int i; - nwk_addr addr16; - ieee_addr addr64; - unsigned short cluster_id; - unsigned char src_ep, dst_ep, dst_addr_mode; - - msg(""); - msgp("zb_zdo_mgmt_bind_rsp()"); - msgp(" status = 0x%02X (%s) start_idx = %d number of records = %d", - status, zb_zdo_get_error_message(status), start_idx, binding_table_list_count); - - for (i = 0; i < binding_table_list_count; i++) { - zb_binding_table_get_src_addr(list[i], addr64); - msg(" Src IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); - zb_binding_table_get_src_ep(list[i], &src_ep); - msg(" Src End-Point = 0x%02X", src_ep); - zb_binding_table_get_cluster_id(list[i], &cluster_id); - msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); - zb_binding_table_get_dst_addr_mode(list[i], &dst_addr_mode); - msg(" Dst Address Mode = 0x%02X", dst_addr_mode); - zb_binding_table_get_dst_addr16(list[i], &addr16); - msg(" Dst Network address = 0x%04X", addr16); - memset(addr64, 0, sizeof(ieee_addr)); - zb_binding_table_get_dst_addr64(list[i], addr64); - msg(" Dst IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", - addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); - zb_binding_table_get_dst_ep(list[i], &dst_ep); - msg(" Dst End-Point = 0x%02X", src_ep); - msg(""); - } -} - -static void zigbee_zdo_mgmt_leave_rsp(unsigned char status, void *user_data) -{ - msg(""); - msgp("zb_zdo_mgmt_leave_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); -} - -static void zigbee_zdo_mgmt_permit_joining_rsp(unsigned char status, void *user_data) -{ - msg(""); - msgp("zb_zdo_mgmt_permit_joining_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); -} - -static int run_mgmt_nwk_disc_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned int scan_channels = ZB_802_15_4_CHANNELS_MASK; - unsigned char scan_duration = 5; - unsigned char scan_count = 4; - unsigned char start_idx = 0; - - if (strlen(data_duration)) - scan_duration = (unsigned char)strtol(data_duration, NULL, 10); - if (strlen(data_count)) - scan_count = (unsigned char)strtol(data_count, NULL, 10); - if (strlen(data_start_idx)) - start_idx = (unsigned char)strtol(data_start_idx, NULL, 10); - - ret = zb_zdo_mgmt_nwk_disc_req(handle, dest_addr16, scan_channels, - scan_duration, scan_count, start_idx, - zigbee_zdo_mgmt_nwk_disc_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_mgmt_nwk_disc_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_mgmt_nwk_disc_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_mgmt_nwk_update_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned int scan_channels = ZB_802_15_4_CHANNELS_MASK; - unsigned char nwk_update_id = 0x00; - unsigned char scan_duration = 5; - unsigned char scan_count = 4; - - if (strlen(data_duration)) - scan_duration = (unsigned char)strtol(data_duration, NULL, 10); - if (strlen(data_count)) - scan_count = (unsigned char)strtol(data_count, NULL, 10); - if (strlen(data_nwk_update_id)) - nwk_update_id = (unsigned char)strtol(data_nwk_update_id, NULL, 10); - - ret = zb_zdo_mgmt_nwk_update_req(handle, scan_channels, scan_duration, - scan_count, nwk_update_id, dest_addr16); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_mgmt_nwk_update_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_mgmt_nwk_update_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_mgmt_lqi_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char start_idx = 0; - - if (strlen(data_start_idx)) - start_idx = (unsigned char)strtol(data_start_idx, NULL, 10); - - ret = zb_zdo_mgmt_lqi_req(handle, dest_addr16, start_idx, - zigbee_zdo_mgmt_lqi_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_mgmt_lqi_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_mgmt_lqi_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_mgmt_rtg_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char start_idx = 0; - - if (strlen(data_start_idx)) - start_idx = (unsigned char)strtol(data_start_idx, NULL, 10); - - ret = zb_zdo_mgmt_rtg_req(handle, dest_addr16, start_idx, - zigbee_zdo_mgmt_rtg_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_mgmt_rtg_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_mgmt_rtg_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_mgmt_bind_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char start_idx = 0; - - if (strlen(data_start_idx)) - start_idx = (unsigned char)strtol(data_start_idx, NULL, 10); - - ret = zb_zdo_mgmt_bind_req(handle, dest_addr16, start_idx, - zigbee_zdo_mgmt_bind_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_mgmt_bind_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_mgmt_bind_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_mgmt_leave_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char var = 0; - bool remove_children = true; - bool rejoin = true; - - if (strlen(data_remove_children)) { - var = (unsigned char)strtol(data_remove_children, NULL, 10); - remove_children = (var == 0) ? false : true; - } - if (strlen(data_rejoin)) { - var = (unsigned char)strtol(data_rejoin, NULL, 10); - rejoin = (var == 0) ? false : true; - } - - ret = zb_zdo_mgmt_leave_req(handle, dest_addr64, remove_children, rejoin, - zigbee_zdo_mgmt_leave_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_mgmt_leave_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_mgmt_leave_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static int run_mgmt_permit_joining_req(MManager *mm, struct menu_data *menu) -{ - int ret = ZIGBEE_ERROR_NONE; - unsigned char permit_duration = 1; - unsigned char tc_significance = 1; - - if (strlen(data_permit_duration)) - permit_duration = (unsigned char)strtol(data_permit_duration, NULL, 10); - if (strlen(data_tc)) - tc_significance = (unsigned char)strtol(data_tc, NULL, 10); - - ret = zb_zdo_mgmt_permit_joining_req(handle, dest_addr16, - permit_duration, tc_significance, - zigbee_zdo_mgmt_permit_joining_rsp, NULL); - if (ZIGBEE_ERROR_NONE != ret) { - msg("zb_zdo_mgmt_permit_joining_req(0x%X) - FAILED!!!", ret); - return RET_FAILURE; - } - - msg(" - zb_zdo_mgmt_permit_joining_req() ret: [0x%X]", ret); - msg(""); - - return RET_SUCCESS; -} - -static struct menu_data _menu_nwk_disc[] = { - { "1", "Scan duration", NULL, NULL, data_duration }, - { "2", "Scan count", NULL, NULL, data_count }, - { "3", "Start index", NULL, NULL, data_start_idx }, - { "4", "Run", NULL, run_mgmt_nwk_disc_req, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_nwk_update[] = { - { "1", "Scan duration", NULL, NULL, data_duration }, - { "2", "Scan count", NULL, NULL, data_count }, - { "3", "Start index", NULL, NULL, data_start_idx }, - { "4", "Run", NULL, run_mgmt_nwk_update_req, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_lqi[] = { - { "1", "Start index", NULL, NULL, data_start_idx }, - { "2", "Run", NULL, run_mgmt_lqi_req, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_rtg[] = { - { "1", "Start index", NULL, NULL, data_start_idx }, - { "2", "Run", NULL, run_mgmt_rtg_req, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_bind[] = { - { "1", "Start index", NULL, NULL, data_start_idx }, - { "2", "Run", NULL, run_mgmt_bind_req, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_leave[] = { - { "1", "Remove children", NULL, NULL, data_remove_children }, - { "2", "Rejoin", NULL, NULL, data_rejoin }, - { "3", "Run", NULL, run_mgmt_leave_req, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data _menu_permit[] = { - { "1", "Permit duration", NULL, NULL, data_permit_duration }, - { "2", "TC significance", NULL, NULL, data_tc }, - { "3", "Run", NULL, run_mgmt_permit_joining_req, NULL }, - { NULL, NULL, }, -}; - -struct menu_data menu_zdo_network[] = { - { "1", "zb_zdo_mgmt_nwk_disc_req", _menu_nwk_disc, NULL, NULL }, - { "2", "zb_zdo_mgmt_nwk_update_req", _menu_nwk_update, NULL, NULL }, - { "3", "zb_zdo_mgmt_lqi_req", _menu_lqi, NULL, NULL }, - { "4", "zb_zdo_mgmt_rtg_req", _menu_rtg, NULL, NULL }, - { "5", "zb_zdo_mgmt_bind_req", _menu_bind, NULL, NULL }, - { "6", "zb_zdo_mgmt_leave_req", _menu_leave, NULL, NULL }, - { "7", "zb_zdo_mgmt_permit_joining_req", _menu_permit, NULL, NULL }, - { NULL, NULL, }, -}; diff --git a/test/zdo_binding.c b/test/zdo_binding.c new file mode 100644 index 0000000..0544bea --- /dev/null +++ b/test/zdo_binding.c @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr panid; +extern ieee_addr co_addr64; + +extern ieee_addr st_addr64; +extern ieee_addr sj_addr64; + +extern nwk_addr dest_addr16; +extern ieee_addr dest_addr64; + +extern simple_desc_s sj_ep1; + +/* ZB_ZCL_ON_OFF_CLUSTER_ID */ +static char data_cluster_id[MENU_DATA_SIZE + 1] = "6"; + +static void zigbee_zdo_bind_unbind_rsp(unsigned char status, void *user_data) +{ + msg(""); + msgp("zigbee_zdo_bind_unbind_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); +} + +static int run_bind_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char src_ep = 1; + unsigned short cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; + + if (strlen(data_cluster_id)) + cluster_id = (unsigned short)strtol(data_cluster_id, NULL, 16); + +#if 0 + /* Samjin Power Outlet */ + ret = zb_zdo_bind_req(handle, sj_addr16, sj_addr64, 1, + ZB_ZCL_DIAGNOSTICS_CLUSTER_ID, co_addr64, + ZB_UNICAST_BINDING, 0x0004, 1, zigbee_zdo_bind_unbind_rsp, NULL); + /* For ST Open/Close Sensor */ + ret = zb_zdo_bind_req(handle, st_addr16, st_addr64, 1, + ZB_ZCL_IAS_ZONE_CLUSTER_ID, co_addr64, + ZB_UNICAST_BINDING, panid, 1, zigbee_zdo_bind_unbind_rsp, NULL); +#endif + + ret = zb_zdo_bind_req(handle, dest_addr16, sj_addr64, src_ep, cluster_id, + co_addr64, ZB_UNICAST_BINDING, 0x0004, sj_ep1.ep, + zigbee_zdo_bind_unbind_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_bind_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_bind_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_unbind_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned short cluster_id = ZB_ZCL_ON_OFF_CLUSTER_ID; + + if (strlen(data_cluster_id)) + cluster_id = (unsigned short)strtol(data_cluster_id, NULL, 16); + + ret = zb_zdo_unbind_req(handle, dest_addr16, co_addr64, 1, cluster_id, + sj_addr64, ZB_UNICAST_BINDING, panid, 1, + zigbee_zdo_bind_unbind_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_unbind_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_unbind_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_bind[] = { + { "1", "Cluster ID (in hex)", NULL, NULL, data_cluster_id }, + { "2", "Run", NULL, run_bind_req, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_unbind[] = { + { "1", "Cluster ID (in hex)", NULL, NULL, data_cluster_id }, + { "2", "Run", NULL, run_unbind_req, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zdo_binding[] = { + { "1", "zb_zdo_bind_req", _menu_bind, NULL, NULL }, + { "2", "zb_zdo_unbind_req", _menu_unbind, NULL, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zdo_device.c b/test/zdo_device.c new file mode 100644 index 0000000..b1c9f28 --- /dev/null +++ b/test/zdo_device.c @@ -0,0 +1,459 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern struct menu_data menu_zdo_network[]; +extern struct menu_data menu_zdo_binding[]; + +extern nwk_addr panid; +extern ieee_addr co_addr64; + +extern nwk_addr st_addr16; +extern ieee_addr st_addr64; + +extern nwk_addr sj_addr16; +extern ieee_addr sj_addr64; + +extern nwk_addr dest_addr16; +extern ieee_addr dest_addr64; + +extern simple_desc_s st_ep1, sj_ep1; + +static void zigbee_addr_rsp(unsigned char status, ieee_addr addr64, nwk_addr addr16, + unsigned char num_of_assoc_dev, unsigned char start_idx, unsigned short + *assoc_dev_addr_list, void *user_data) +{ + msg(""); + msgp("zb_zdo_addr_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); + if (addr64) { + msg("IEEE Address : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:", + addr64[0], addr64[1], addr64[2], addr64[3], + addr64[4], addr64[5], addr64[6], addr64[7]); + } else + msg("IEEE Address : 00:00:00:00:00:00:00:00:"); + msg("Network Address : 0x%04X", addr16); + msg("Number of Associated Device : %d", num_of_assoc_dev); + msg("Start Index : %d", start_idx); +} + +static void zigbee_active_ep_rsp(unsigned char status, nwk_addr addr16, + unsigned char count, unsigned char *ep_list, void *user_data) +{ + int i; + msg(""); + msg("count = 0x%02X", count); + for (i = 0; i < count; i++) + msg("EP = 0x%02X", ep_list[i]); + msgp("zb_zdo_active_ep_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); +} + +static void zigbee_simple_desc_rsp(nwk_addr addr16, unsigned char len, + const zb_zdo_simple_desc_h handle, void *user_data) +{ + int i, ret; + unsigned char param_u8; + unsigned short param_u16; + unsigned short *in_clusters; + unsigned short *out_clusters; + + msg(""); + msgp("zb_zdo_simple_desc_rsp()"); + + ret = zb_simple_desc_get_ep(handle, ¶m_u8); + if (ZIGBEE_ERROR_NONE != ret) + msg("zb_simple_desc_get_ep() Fail(0x%X)", ret); + else + msg(" ep = %d", param_u8); + + ret = zb_simple_desc_get_profile_id(handle, ¶m_u16); + if (ZIGBEE_ERROR_NONE != ret) + msg("zb_simple_desc_get_profile_id() Fail(0x%X)", ret); + else + msg(" profile_id = 0x%x (%s)", param_u16, zb_get_profile_id_string(param_u16)); + + ret = zb_simple_desc_get_device_id(handle, ¶m_u16); + if (ZIGBEE_ERROR_NONE != ret) + msg("zb_simple_desc_get_device_id() Fail(0x%X)", ret); + else + msg(" device_id = 0x%x (%s)", param_u16, zb_get_device_id_string(param_u16)); + + ret = zb_simple_desc_get_device_ver(handle, ¶m_u16); + if (ZIGBEE_ERROR_NONE != ret) + msg("zb_simple_desc_get_device_ver() Fail(0x%X)", ret); + else + msg(" device_ver = %d", param_u16); + + ret = zb_simple_desc_get_num_of_in_clusters(handle, ¶m_u8); + if (ZIGBEE_ERROR_NONE != ret) + msg("zb_simple_desc_get_num_of_in_clusters() Fail(0x%X)", ret); + else + msg(" num_of_in_cluster = %d", param_u8); + + ret = zb_simple_desc_get_in_clusters(handle, &in_clusters); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_simple_desc_get_in_clusters() Fail(0x%X)", ret); + } else { + for (i = 0; i < param_u8; i++) + msg(" %04X (%s)", in_clusters[i], zb_get_cluster_name(in_clusters[i])); + } + + ret = zb_simple_desc_get_num_of_out_clusters(handle, ¶m_u8); + if (ZIGBEE_ERROR_NONE != ret) + msg("zb_simple_desc_get_num_of_out_clusters() Fail(0x%X)", ret); + else + msg(" num_of_out_cluster = %d", param_u8); + + ret = zb_simple_desc_get_out_clusters(handle, &out_clusters); + if (ZIGBEE_ERROR_NONE != ret) + msg("zb_simple_desc_get_out_clusters() Fail(0x%X)", ret); + else { + for (i = 0; i < param_u8; i++) + msg(" %04X (%s)", out_clusters[i], zb_get_cluster_name(out_clusters[i])); + } +} + +static void zigbee_match_desc_rsp(unsigned char status, nwk_addr addr16, + unsigned char match_length, unsigned char *match_list, void *user_data) +{ + unsigned char i; + msg(""); + msgp("zb_zdo_match_desc_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); + + msg(" nwk_addr = 0x%04X status = 0x%02X match_length = %d", + addr16, status, match_length); + + for (i = 0; i < match_length; i++) + msg(" match_list[%d] = 0x%02x", i, (unsigned int)match_list[i]); +} + +static void zigbee_zdo_power_desc_rsp(unsigned char status, nwk_addr addr16, + const zb_zdo_node_power_descriptor_h power_desc, void *user_data) +{ + unsigned char current_power_mode; + unsigned char available_power_source; + unsigned char current_power_source; + unsigned char current_power_source_lv; + + msg(""); + msgp("zb_zdo_power_desc_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); + + zb_node_power_desc_get_current_power_mode(power_desc, ¤t_power_mode); + msg(" current_power_mode = %02X", current_power_mode); + zb_node_power_desc_get_available_power_sources(power_desc, &available_power_source); + msg(" available_power_source = %02X", available_power_source); + zb_node_power_desc_get_current_power_source(power_desc, ¤t_power_source); + msg(" current_power_source = %02X", current_power_source); + zb_node_power_desc_get_current_power_source_level(power_desc, ¤t_power_source_lv); + msg(" current_power_source_level = %02X", current_power_source_lv); +} + +static void zigbee_zdo_complex_desc_rsp(unsigned char status, nwk_addr addr16, + unsigned char length, unsigned char *complex_desc, void *user_data) +{ + msg(""); + msgp("zb_zdo_complex_desc_rsp() status = 0x%02X (%s) length = %d", + status, zb_zdo_get_error_message(status), length); +} + +static void zigbee_zdo_user_desc_rsp(unsigned char status, nwk_addr addr16, + unsigned char length, unsigned char *user_desc, void *user_data) +{ + msg(""); + msgp("zb_zdo_user_desc_rsp() status = 0x%02X (%s) length = %d", + status, zb_zdo_get_error_message(status), length); +} + +static void zigbee_zdo_user_desc_conf(unsigned char status, void *user_data) +{ + msg(""); + msgp("zb_zdo_user_desc_conf() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); +} + +static void zigbee_zdo_node_desc_rsp(unsigned char status, nwk_addr addr16, + const zb_zdo_node_descriptor_h desc, void *user_data) +{ + unsigned char logical_type; + unsigned char complex_desciptor_available; + unsigned char user_descriptor_available; + unsigned char aps_flags; + unsigned char frequency_band; + unsigned char mac_capability_flags; + unsigned short manufacturer_code; + unsigned char maximum_buffer_size; + unsigned short maximum_incoming_transfer_size; + unsigned short server_mask; + unsigned short maximum_outgoing_transfer_size; + unsigned short descriptor_capability_field; + + msg(""); + msgp("zb_zdo_node_desc_rsp()"); + msgp(" nwk_addr = 0x%04X status = 0x%02X (%s)", addr16, status, zb_zdo_get_error_message(status)); + + zb_node_desc_get_logical_type(desc, &logical_type); + msg(" logical_type = 0x%02X", logical_type); + zb_node_desc_get_complex_desciptor_available(desc, &complex_desciptor_available); + msg(" complex_desciptor_available = 0x%02X", complex_desciptor_available); + zb_node_desc_get_user_descriptor_available(desc, &user_descriptor_available); + msg(" complex_desciptor_available = 0x%02X", complex_desciptor_available); + zb_node_desc_get_aps_flags(desc, &aps_flags); + msg(" aps_flags = 0x%02X", aps_flags); + zb_node_desc_get_frequency_band(desc, &frequency_band); + msg(" frequency_band = 0x%02X", frequency_band); + zb_node_desc_get_mac_capability_flags(desc, &mac_capability_flags); + msg(" mac_capability_flags = 0x%02X", mac_capability_flags); + zb_node_desc_get_manufacturer_code(desc, &manufacturer_code); + msg(" manufacturer_code = 0x%04X", manufacturer_code); + zb_node_desc_get_maximum_buffer_size(desc, &maximum_buffer_size); + msg(" maximum_buffer_size = 0x%02X", maximum_buffer_size); + zb_node_desc_get_maximum_incoming_transfer_size(desc, &maximum_incoming_transfer_size); + msg(" maximum_incoming_transfer_size = 0x%04X", maximum_incoming_transfer_size); + zb_node_desc_get_server_mask(desc, &server_mask); + msg(" server_mask = 0x%04X", server_mask); + zb_node_desc_get_maximum_outgoing_transfer_size(desc, &maximum_outgoing_transfer_size); + msg(" maximum_outgoing_transfer_size = 0x%04X", maximum_outgoing_transfer_size); + zb_node_desc_get_descriptor_capability_field(desc, &descriptor_capability_field); + msg(" descriptor_capability_field = 0x%04X", descriptor_capability_field); +} + +static int run_nwk_addr_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + msg("IEEE Address : %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:", + st_addr64[0], st_addr64[1], st_addr64[2], st_addr64[3], + st_addr64[4], st_addr64[5], st_addr64[6], st_addr64[7]); + + ret = zb_zdo_nwk_addr_req(handle, dest_addr64, 0x00, 0x00, + zigbee_addr_rsp, NULL); + if (ret != ZIGBEE_ERROR_NONE) { + msg("zb_zdo_nwk_addr_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_nwk_addr_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_ieee_addr_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_ieee_addr_req(handle, dest_addr16, zigbee_addr_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_ieee_addr_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_ieee_addr_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_active_ep(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_active_ep(handle, dest_addr16, zigbee_active_ep_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_active_ep(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_active_ep() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_simple_desc_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_simple_desc_req(handle, dest_addr16, 1, + zigbee_simple_desc_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_simple_desc_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_simple_desc_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_match_desc_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; +#if 0 + /* for ST open/close sensor */ + ret = zb_zdo_match_desc_req(handle, st_addr16, st_ep1.profile_id, + st_ep1.num_of_in_clusters, st_ep1.in_clusters, + st_ep1.num_of_out_clusters, st_ep1.out_clusters, + zigbee_match_desc_rsp, user_data); +#endif + /* for SJ power outlet */ + ret = zb_zdo_match_desc_req(handle, dest_addr16, sj_ep1.profile_id, + sj_ep1.num_of_in_clusters, sj_ep1.in_clusters, + sj_ep1.num_of_out_clusters, sj_ep1.out_clusters, + zigbee_match_desc_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_match_desc_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_match_desc_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_power_desc_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_power_desc_req(handle, dest_addr16, + zigbee_zdo_power_desc_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_power_desc_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_power_desc_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_complex_desc_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_complex_desc_req(handle, dest_addr16, + zigbee_zdo_complex_desc_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_complex_desc_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_complex_desc_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_user_desc_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_user_desc_req(handle, dest_addr16, + zigbee_zdo_user_desc_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_user_desc_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_user_desc_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_user_desc_set(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_user_desc_set(handle, dest_addr16, 4, (unsigned char*)"test", + zigbee_zdo_user_desc_conf, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_user_desc_set(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_user_desc_set() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_node_desc_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_node_desc_req(handle, dest_addr16, + zigbee_zdo_node_desc_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_node_desc_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_node_desc_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_device_annce(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + + ret = zb_zdo_device_annce(handle, st_addr16, st_addr64, + ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR | ZB_ZDP_DEVICE_TYPE + | ZB_ZDP_POWER_SOURCE | ZB_ZDP_RECEIVER_ON_WHEN_IDLE + | ZB_ZDP_ALLOCATE_ADDRESS); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_device_annce(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_device_annce() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +struct menu_data menu_zdo_device[] = { + { "1", "zb_zdo_nwk_addr_req", NULL, run_nwk_addr_req, NULL }, + { "2", "zb_zdo_ieee_addr_req", NULL, run_ieee_addr_req, NULL }, + { "3", "zb_zdo_active_ep", NULL, run_active_ep, NULL }, + { "4", "zb_zdo_simple_desc_req", NULL, run_simple_desc_req, NULL }, + { "5", "zb_zdo_match_desc_req", NULL, run_match_desc_req, NULL }, + { "6", "zb_zdo_power_desc_req", NULL, run_power_desc_req, NULL }, + { "7", "zb_zdo_complex_desc_req", NULL, run_complex_desc_req, NULL }, + { "8", "zb_zdo_user_desc_req", NULL, run_user_desc_req, NULL }, + { "9", "zb_zdo_user_desc_set", NULL, run_user_desc_set, NULL }, + { "10", "zb_zdo_node_desc_req", NULL, run_node_desc_req, NULL }, + { "11", "zb_zdo_device_annce", NULL, run_device_annce, NULL }, + { NULL, NULL, }, +}; diff --git a/test/zdo_network.c b/test/zdo_network.c new file mode 100644 index 0000000..20f8d94 --- /dev/null +++ b/test/zdo_network.c @@ -0,0 +1,450 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * 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 +#include +#include +#include + +#include + +#include "main.h" +#include "menu.h" + +extern zigbee_h handle; + +extern nwk_addr dest_addr16; +extern ieee_addr dest_addr64; + +static char data_duration[MENU_DATA_SIZE + 1] = "5"; +static char data_count[MENU_DATA_SIZE + 1] = "4"; +static char data_start_idx[MENU_DATA_SIZE + 1] = "0"; +static char data_nwk_update_id[MENU_DATA_SIZE + 1] = "0"; +static char data_remove_children[MENU_DATA_SIZE + 1] = "1"; +static char data_rejoin[MENU_DATA_SIZE + 1] = "1"; +static char data_permit_duration[MENU_DATA_SIZE + 1] = "1"; +static char data_tc[MENU_DATA_SIZE + 1] = "1"; + +static void zigbee_zdo_mgmt_nwk_disc_rsp(unsigned char status, + unsigned char network_count, unsigned char start_idx, unsigned char network_list_count, + const zb_zdo_network_list_record_h *records, void *user_data) +{ + int i = 0; + ieee_addr extended_pan_id; + unsigned char logical_channel; + unsigned char stack_profile; + unsigned char zigbee_version; + unsigned char beacon_order; + unsigned char superframe_order; + unsigned char permit_joining; + + msg(""); + msgp("zb_zdo_mgmt_nwk_disc_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); + + if (!status) { + msg(" network_count 0x%02X", network_count); + msg(" start_idx 0x%02X", start_idx); + msg(" network_list_count 0x%02X", network_list_count); + for (i = 0; i < network_list_count; i++) { + zb_network_list_record_get_extended_pan_id(records[i], extended_pan_id); + msg(" Extended PanId %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + extended_pan_id[7], extended_pan_id[6], + extended_pan_id[5], extended_pan_id[4], + extended_pan_id[3], extended_pan_id[2], + extended_pan_id[1], extended_pan_id[0]); + zb_network_list_record_get_logical_channel(records[i], &logical_channel); + msg(" Logical Channel 0x%02X", logical_channel); + zb_network_list_record_get_stack_profile(records[i], &stack_profile); + msg(" stack_profile 0x%02X", stack_profile); + zb_network_list_record_get_zigbee_version(records[i], &zigbee_version); + msg(" zigbee_version 0x%02X", zigbee_version); + zb_network_list_record_get_beacon_order(records[i], &beacon_order); + msg(" Beacon_order 0x%02X", beacon_order); + zb_network_list_record_get_superframe_order(records[i], &superframe_order); + msg(" Superframe_order 0x%02X", superframe_order); + zb_network_list_record_get_permit_joining(records[i], &permit_joining); + msg(" Permit joining 0x%02X", permit_joining); + } + } else { + msg(" Unsuccessful Nwk discovery"); + } +} + +static void zigbee_zdo_mgmt_lqi_rsp(unsigned char status, + unsigned char neighbor_table_entries, unsigned char start_idx, + unsigned char neighbor_table_list_count, + const zb_zdo_neighbor_table_desc_h *neighbor_table_list, void *user_data) +{ + int i; + ieee_addr extended_pan_id; + ieee_addr addr64; + nwk_addr addr16; + unsigned char device_type; + unsigned char rx_on_when_idle; + unsigned char releationship; + unsigned char permit_joining; + unsigned char depth; + unsigned char lqi; + + msg(""); + msgp("zb_zdo_mgmt_lqi_rsp()"); + msgp(" status = 0x%02X (%s) start_idx=%d count=%d", status, + zb_zdo_get_error_message(status), start_idx, neighbor_table_list_count); + for (i = start_idx; i < neighbor_table_list_count; i++) { + zb_neighbor_table_desc_get_extended_pan_id(neighbor_table_list[i], extended_pan_id); + msg(" ext PAN ID = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + extended_pan_id[0], extended_pan_id[1], extended_pan_id[2], extended_pan_id[3], + extended_pan_id[4], extended_pan_id[5], extended_pan_id[6], extended_pan_id[7]); + zb_neighbor_table_desc_get_ieee_addr(neighbor_table_list[i], addr64); + msg(" IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); + zb_neighbor_table_desc_get_nwk_addr(neighbor_table_list[i], &addr16); + msg(" Network address = 0x%04X", addr16); + zb_neighbor_table_desc_get_device_type(neighbor_table_list[i], &device_type); + msg(" Device Type = 0x%02X", device_type); + zb_neighbor_table_desc_get_rx_on_when_idle(neighbor_table_list[i], &rx_on_when_idle); + msg(" Rx on idle = 0x%02X", rx_on_when_idle); + zb_neighbor_table_desc_get_relationship(neighbor_table_list[i], &releationship); + msg(" Relationship = 0x%02X", releationship); + zb_neighbor_table_desc_get_permit_joining(neighbor_table_list[i], &permit_joining); + msg(" Permit Joining = 0x%02X", permit_joining); + zb_neighbor_table_desc_get_depth(neighbor_table_list[i], &depth); + msg(" Depth = 0x%02X", depth); + zb_neighbor_table_desc_get_lqi(neighbor_table_list[i], &lqi); + msg(" LQI = 0x%02X", lqi); + } +} + +static void zigbee_zdo_mgmt_rtg_rsp(unsigned char status, + unsigned char routing_table_entries, unsigned char start_idx, + unsigned char routing_table_list_count, + const zb_zdo_routing_table_h *routing_table_list, void *user_data) +{ + int i; + nwk_addr dst_addr; + unsigned char mode; + unsigned char memory_constrained; + unsigned char many_to_one; + unsigned char route_record_required; + nwk_addr next_hop_addr; + + msg(""); + msgp("zb_zdo_mgmt_rtg_rsp()"); + msgp(" status = 0x%02X (%s) routing_table_entries=%d start_idx=%d count=%d", + status, zb_zdo_get_error_message(status), + routing_table_entries, start_idx, routing_table_list_count); + for (i = start_idx; i < routing_table_list_count; i++) { + zb_routing_table_get_dst_addr(routing_table_list[i], &dst_addr); + msg(" [%d] Destination address = 0x%04X", i, dst_addr); + zb_routing_table_get_dst_status(routing_table_list[i], &mode); + msg(" [%d] Status = 0x%02X", i, mode); + zb_routing_table_get_memory_constrained(routing_table_list[i], &memory_constrained); + msg(" [%d] memory_constrained = 0x%02X", i, memory_constrained); + zb_routing_table_get_many_to_one(routing_table_list[i], &many_to_one); + msg(" [%d] many_to_one = 0x%02X", i, many_to_one); + zb_routing_table_get_route_record_required(routing_table_list[i], &route_record_required); + msg(" [%d] route_record_required = 0x%02X", i, route_record_required); + zb_routing_table_get_next_hop_addr(routing_table_list[i], &next_hop_addr); + msg(" [%d] next_hop_addr = 0x%04X", i, next_hop_addr); + msg(""); + } +} + +static void zigbee_zdo_mgmt_bind_rsp(unsigned char status, unsigned char entries, + unsigned char start_idx, unsigned char binding_table_list_count, const zb_zdo_binding_table_h *list, + void *user_data) +{ + int i; + nwk_addr addr16; + ieee_addr addr64; + unsigned short cluster_id; + unsigned char src_ep, dst_ep, dst_addr_mode; + + msg(""); + msgp("zb_zdo_mgmt_bind_rsp()"); + msgp(" status = 0x%02X (%s) start_idx = %d number of records = %d", + status, zb_zdo_get_error_message(status), start_idx, binding_table_list_count); + + for (i = 0; i < binding_table_list_count; i++) { + zb_binding_table_get_src_addr(list[i], addr64); + msg(" Src IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); + zb_binding_table_get_src_ep(list[i], &src_ep); + msg(" Src End-Point = 0x%02X", src_ep); + zb_binding_table_get_cluster_id(list[i], &cluster_id); + msg(" Cluster ID = 0x%04X (%s)", cluster_id, zb_get_cluster_name(cluster_id)); + zb_binding_table_get_dst_addr_mode(list[i], &dst_addr_mode); + msg(" Dst Address Mode = 0x%02X", dst_addr_mode); + zb_binding_table_get_dst_addr16(list[i], &addr16); + msg(" Dst Network address = 0x%04X", addr16); + memset(addr64, 0, sizeof(ieee_addr)); + zb_binding_table_get_dst_addr64(list[i], addr64); + msg(" Dst IEEE address = %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + addr64[0], addr64[1], addr64[2], addr64[3], addr64[4], addr64[5], addr64[6], addr64[7]); + zb_binding_table_get_dst_ep(list[i], &dst_ep); + msg(" Dst End-Point = 0x%02X", src_ep); + msg(""); + } +} + +static void zigbee_zdo_mgmt_leave_rsp(unsigned char status, void *user_data) +{ + msg(""); + msgp("zb_zdo_mgmt_leave_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); +} + +static void zigbee_zdo_mgmt_permit_joining_rsp(unsigned char status, void *user_data) +{ + msg(""); + msgp("zb_zdo_mgmt_permit_joining_rsp() status = 0x%02X (%s)", status, zb_zdo_get_error_message(status)); +} + +static int run_mgmt_nwk_disc_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned int scan_channels = ZB_802_15_4_CHANNELS_MASK; + unsigned char scan_duration = 5; + unsigned char scan_count = 4; + unsigned char start_idx = 0; + + if (strlen(data_duration)) + scan_duration = (unsigned char)strtol(data_duration, NULL, 10); + if (strlen(data_count)) + scan_count = (unsigned char)strtol(data_count, NULL, 10); + if (strlen(data_start_idx)) + start_idx = (unsigned char)strtol(data_start_idx, NULL, 10); + + ret = zb_zdo_mgmt_nwk_disc_req(handle, dest_addr16, scan_channels, + scan_duration, scan_count, start_idx, + zigbee_zdo_mgmt_nwk_disc_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_mgmt_nwk_disc_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_mgmt_nwk_disc_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_mgmt_nwk_update_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned int scan_channels = ZB_802_15_4_CHANNELS_MASK; + unsigned char nwk_update_id = 0x00; + unsigned char scan_duration = 5; + unsigned char scan_count = 4; + + if (strlen(data_duration)) + scan_duration = (unsigned char)strtol(data_duration, NULL, 10); + if (strlen(data_count)) + scan_count = (unsigned char)strtol(data_count, NULL, 10); + if (strlen(data_nwk_update_id)) + nwk_update_id = (unsigned char)strtol(data_nwk_update_id, NULL, 10); + + ret = zb_zdo_mgmt_nwk_update_req(handle, scan_channels, scan_duration, + scan_count, nwk_update_id, dest_addr16); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_mgmt_nwk_update_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_mgmt_nwk_update_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_mgmt_lqi_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char start_idx = 0; + + if (strlen(data_start_idx)) + start_idx = (unsigned char)strtol(data_start_idx, NULL, 10); + + ret = zb_zdo_mgmt_lqi_req(handle, dest_addr16, start_idx, + zigbee_zdo_mgmt_lqi_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_mgmt_lqi_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_mgmt_lqi_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_mgmt_rtg_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char start_idx = 0; + + if (strlen(data_start_idx)) + start_idx = (unsigned char)strtol(data_start_idx, NULL, 10); + + ret = zb_zdo_mgmt_rtg_req(handle, dest_addr16, start_idx, + zigbee_zdo_mgmt_rtg_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_mgmt_rtg_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_mgmt_rtg_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_mgmt_bind_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char start_idx = 0; + + if (strlen(data_start_idx)) + start_idx = (unsigned char)strtol(data_start_idx, NULL, 10); + + ret = zb_zdo_mgmt_bind_req(handle, dest_addr16, start_idx, + zigbee_zdo_mgmt_bind_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_mgmt_bind_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_mgmt_bind_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_mgmt_leave_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char var = 0; + bool remove_children = true; + bool rejoin = true; + + if (strlen(data_remove_children)) { + var = (unsigned char)strtol(data_remove_children, NULL, 10); + remove_children = (var == 0) ? false : true; + } + if (strlen(data_rejoin)) { + var = (unsigned char)strtol(data_rejoin, NULL, 10); + rejoin = (var == 0) ? false : true; + } + + ret = zb_zdo_mgmt_leave_req(handle, dest_addr64, remove_children, rejoin, + zigbee_zdo_mgmt_leave_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_mgmt_leave_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_mgmt_leave_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static int run_mgmt_permit_joining_req(MManager *mm, struct menu_data *menu) +{ + int ret = ZIGBEE_ERROR_NONE; + unsigned char permit_duration = 1; + unsigned char tc_significance = 1; + + if (strlen(data_permit_duration)) + permit_duration = (unsigned char)strtol(data_permit_duration, NULL, 10); + if (strlen(data_tc)) + tc_significance = (unsigned char)strtol(data_tc, NULL, 10); + + ret = zb_zdo_mgmt_permit_joining_req(handle, dest_addr16, + permit_duration, tc_significance, + zigbee_zdo_mgmt_permit_joining_rsp, NULL); + if (ZIGBEE_ERROR_NONE != ret) { + msg("zb_zdo_mgmt_permit_joining_req(0x%X) - FAILED!!!", ret); + return RET_FAILURE; + } + + msg(" - zb_zdo_mgmt_permit_joining_req() ret: [0x%X]", ret); + msg(""); + + return RET_SUCCESS; +} + +static struct menu_data _menu_nwk_disc[] = { + { "1", "Scan duration", NULL, NULL, data_duration }, + { "2", "Scan count", NULL, NULL, data_count }, + { "3", "Start index", NULL, NULL, data_start_idx }, + { "4", "Run", NULL, run_mgmt_nwk_disc_req, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_nwk_update[] = { + { "1", "Scan duration", NULL, NULL, data_duration }, + { "2", "Scan count", NULL, NULL, data_count }, + { "3", "Start index", NULL, NULL, data_start_idx }, + { "4", "Run", NULL, run_mgmt_nwk_update_req, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_lqi[] = { + { "1", "Start index", NULL, NULL, data_start_idx }, + { "2", "Run", NULL, run_mgmt_lqi_req, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_rtg[] = { + { "1", "Start index", NULL, NULL, data_start_idx }, + { "2", "Run", NULL, run_mgmt_rtg_req, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_bind[] = { + { "1", "Start index", NULL, NULL, data_start_idx }, + { "2", "Run", NULL, run_mgmt_bind_req, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_leave[] = { + { "1", "Remove children", NULL, NULL, data_remove_children }, + { "2", "Rejoin", NULL, NULL, data_rejoin }, + { "3", "Run", NULL, run_mgmt_leave_req, NULL }, + { NULL, NULL, }, +}; + +static struct menu_data _menu_permit[] = { + { "1", "Permit duration", NULL, NULL, data_permit_duration }, + { "2", "TC significance", NULL, NULL, data_tc }, + { "3", "Run", NULL, run_mgmt_permit_joining_req, NULL }, + { NULL, NULL, }, +}; + +struct menu_data menu_zdo_network[] = { + { "1", "zb_zdo_mgmt_nwk_disc_req", _menu_nwk_disc, NULL, NULL }, + { "2", "zb_zdo_mgmt_nwk_update_req", _menu_nwk_update, NULL, NULL }, + { "3", "zb_zdo_mgmt_lqi_req", _menu_lqi, NULL, NULL }, + { "4", "zb_zdo_mgmt_rtg_req", _menu_rtg, NULL, NULL }, + { "5", "zb_zdo_mgmt_bind_req", _menu_bind, NULL, NULL }, + { "6", "zb_zdo_mgmt_leave_req", _menu_leave, NULL, NULL }, + { "7", "zb_zdo_mgmt_permit_joining_req", _menu_permit, NULL, NULL }, + { NULL, NULL, }, +};