From 8c82e46f3061597ac601b8e7465a71946ea78188 Mon Sep 17 00:00:00 2001 From: saerome kim Date: Thu, 21 Sep 2017 13:55:26 +0900 Subject: [PATCH 01/16] [WGID-279204] Fix a potential memory leak problem Change-Id: I1c3a18844118890d8f062e828aba84a73ff2bbab Signed-off-by: saerome kim --- zigbee-daemon/zigbee-lib/src/zblib_plugin.c | 2 ++ zigbee-daemon/zigbee-lib/src/zblib_service.c | 1 + 2 files changed, 3 insertions(+) diff --git a/zigbee-daemon/zigbee-lib/src/zblib_plugin.c b/zigbee-daemon/zigbee-lib/src/zblib_plugin.c index d8ce3a9..48de467 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_plugin.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_plugin.c @@ -44,6 +44,8 @@ ZigBeePlugin *zblib_plugin_new(ZigBeeService *service, /* Allocate memory */ plugin = g_malloc0(sizeof(ZigBeePlugin)); + if (NULL == plugin) + return NULL; /* Update fields */ plugin->plugin_name = g_strdup(plugin_name); diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index 045b651..61b2025 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -424,6 +424,7 @@ gboolean zblib_service_load_plugins(ZigBeeService *service, const char *plugin_p /* Create new plug-in */ plugin = zblib_plugin_new(service, filename, descriptor, handle); if (G_UNLIKELY(NULL == plugin)) { + dlclose(handle); g_free(filename); continue; } -- 2.7.4 From 624d9040180a6d09ad43107374a8347ce4b43ac4 Mon Sep 17 00:00:00 2001 From: saerome kim Date: Wed, 27 Sep 2017 20:52:31 +0900 Subject: [PATCH 02/16] Fix coverity issues - add missing g_variant_unref() Change-Id: If81a4104a3891df655de280a90cfa9b7d5a410dc Signed-off-by: saerome kim --- .../src/zigbee_service_dbus_interface_service.c | 26 +++++++++-- ...bee_service_dbus_interface_zcl_global_control.c | 53 ++++++++++++++++------ ...zigbee_service_dbus_interface_zdo_dev_control.c | 26 +++++++---- 3 files changed, 78 insertions(+), 27 deletions(-) diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c index 3327890..75cc3d3 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c @@ -451,6 +451,9 @@ static void on_service_get_network_info_resp(ZigBeeServiceInterface *service_int payload->result, v_eui64, payload->node_id, payload->pan_id, payload->channel, payload->radio_tx_power); + if (v_eui64) + g_variant_unref(v_eui64); + g_free(cb_data); } @@ -784,6 +787,9 @@ static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface, zigbee_service_complete_get_mac(service_object, invocation, payload->result, v_eui64); + if (v_eui64) + g_variant_unref(v_eui64); + g_free(cb_data); } @@ -884,6 +890,9 @@ static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_inte zigbee_service_complete_get_device_info(service_object, invocation, payload->result, variant); + if (variant) + g_variant_unref(variant); + g_free(cb_data); } @@ -963,6 +972,9 @@ static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_in zigbee_service_complete_get_endpoint_list(service_object, invocation, payload->result, v_endpoints); + if (v_endpoints) + g_variant_unref(v_endpoints); + g_free(cb_data); } @@ -1062,6 +1074,11 @@ static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_int zigbee_service_complete_get_cluster_list(service_object, invocation, payload->result, v_in_clusters, v_out_clusters); + if (v_in_clusters) + g_variant_unref(v_in_clusters); + if (v_out_clusters) + g_variant_unref(v_out_clusters); + g_free(cb_data); } @@ -1266,14 +1283,14 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface * child_t->endpoints, child_t->endpoint_count, TRUE, NULL, NULL); if (NULL == v_eui64 || NULL == v_endpoints) { Z_LOGE("Failed to create variant!"); - if (v_eui64) - g_object_unref(v_eui64); - if (v_endpoints) - g_object_unref(v_endpoints); } else { zigbee_service_emit_child_joined(service_object, v_eui64, child_t->endpoint_count, v_endpoints, child_t->node_id); } + if (v_eui64) + g_variant_unref(v_eui64); + if (v_endpoints) + g_variant_unref(v_endpoints); } break; case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: { @@ -1299,6 +1316,7 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface * else { zigbee_service_emit_child_left(service_object, v_eui64, child_left_t->status); + g_variant_unref(v_eui64); } } break; diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c index 9c5a0e8..1478f0e 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c @@ -1455,16 +1455,16 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService TRUE, NULL, NULL); if (NULL == v_types || NULL == v_attrs) { Z_LOGE("Failed to create variant!"); - if (v_types) - g_variant_unref(v_types); - if (v_attrs) - g_variant_unref(v_attrs); } else { Z_LOGD("Discover attribute resp"); zigbee_zcl_global_control_emit_discover_attribute_rsp(global_control_object, attr_t->node_id, attr_t->src_ep, v_types, v_attrs, attr_t->cluster_id, attr_t->record_length, attr_t->discovery_completed); } + if (v_types) + g_variant_unref(v_types); + if (v_attrs) + g_variant_unref(v_attrs); break; } case ZBLIB_ZCL_GLOBAL_NOTI_WRITE_ATTR_STRUCTURED_RSP: { @@ -1518,6 +1518,12 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService v_status, v_attrs, v_indicator, v_index, attr_t->cluster_id, attr_t->record_length, attr_t->node_id, attr_t->src_ep); + if (v_status) + g_variant_unref(v_status); + if (v_attrs) + g_variant_unref(v_attrs); + if (v_indicator) + g_variant_unref(v_indicator); break; } case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_CMDS_RECEIVED_RSP: { @@ -1536,6 +1542,8 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService v_commands, attr_t->cluster_id, attr_t->list_count, attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed); } + if (v_commands) + g_variant_unref(v_commands); break; } case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_CMDS_GENERATED_RSP: { @@ -1554,6 +1562,8 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService v_commands, attr_t->cluster_id, attr_t->list_count, attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed); } + if (v_commands) + g_variant_unref(v_commands); break; } case ZBLIB_ZCL_GLOBAL_NOTI_DISCOVER_ATTR_EXT_RSP: { @@ -1572,12 +1582,6 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService attr_t->access_list, attr_t->list_count, TRUE, NULL, NULL); if (NULL == v_attrs_type || NULL == v_attrs || NULL == v_access) { Z_LOGE("Failed to create variant!"); - if (v_attrs_type) - g_variant_unref(v_attrs_type); - if (v_attrs) - g_variant_unref(v_attrs); - if (v_access) - g_variant_unref(v_access); } else { Z_LOGD("Discover attributes extended resp"); zigbee_zcl_global_control_emit_discover_attributes_extended_rsp( @@ -1586,6 +1590,12 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService attr_t->cluster_id, attr_t->list_count, attr_t->node_id, attr_t->src_ep, attr_t->discovery_completed); } + if (v_attrs_type) + g_variant_unref(v_attrs_type); + if (v_attrs) + g_variant_unref(v_attrs); + if (v_access) + g_variant_unref(v_access); break; } case ZBLIB_ZCL_GLOBAL_NOTI_DEFAULT_RSP: { @@ -1612,12 +1622,14 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService v_attrs = g_variant_new_from_data(G_VARIANT_TYPE("aq"), attr_t->attribute_list, (sizeof(gushort) * attr_t->list_count), TRUE, NULL, NULL); + if (NULL == v_attrs) { + Z_LOGE("Failed to create variant!"); + break; + } v_data_type = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"), attr_t->data_type_list, attr_t->list_count, TRUE, NULL, NULL); - if (NULL == v_data_type || NULL == v_attrs) { + if (NULL == v_data_type) { Z_LOGE("Failed to create variant!"); - if (v_data_type) - g_variant_unref(v_data_type); if (v_attrs) g_variant_unref(v_attrs); break; @@ -1626,8 +1638,10 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService values_builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)")); if (NULL == values_builder) { Z_LOGE("Failed to create variant builder!"); - g_variant_unref(v_data_type); - g_variant_unref(v_attrs); + if (v_attrs) + g_variant_unref(v_attrs); + if (v_data_type) + g_variant_unref(v_data_type); break; } for (i = 0; i < attr_t->list_count; i++) { @@ -1643,6 +1657,12 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService attr_t->node_id, attr_t->src_ep, attr_t->cluster_id, v_attrs, v_data_type, v_values, attr_t->list_count); + if (v_attrs) + g_variant_unref(v_attrs); + if (v_data_type) + g_variant_unref(v_data_type); + if (v_values) + g_variant_unref(v_values); break; } case ZBLIB_ZCL_GLOBAL_NOTI_READ_CONFIG_REPORT_RSP: { @@ -1693,6 +1713,9 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService zigbee_zcl_global_control_emit_read_configure_reporting_rsp( global_control_object, resp_t->node_id, resp_t->src_ep, resp_t->cluster_id, resp_t->record_count, v_entries); + + if (v_entries) + g_variant_unref(v_entries); break; } default: diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c index 6012740..564dd10 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c @@ -1591,16 +1591,16 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt (sizeof(gushort) * nwk_addr_t->associated_count), TRUE, NULL, NULL); if (NULL == v_eui64 || NULL == v_associated) { Z_LOGE("Failed to create variant!"); - if (v_eui64) - g_variant_unref(v_eui64); - if (v_associated) - g_variant_unref(v_associated); } else { Z_LOGD("nwk addr ext rsp : [0x%X]", nwk_addr_t->status); zigbee_zdo_dev_control_emit_nwk_addr_ext_rsp(dev_control_object, nwk_addr_t->status, v_eui64, nwk_addr_t->node_id, nwk_addr_t->associated_count, nwk_addr_t->start_index, v_associated); } + if (v_eui64) + g_variant_unref(v_eui64); + if (v_associated) + g_variant_unref(v_associated); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_ACTIVE_EP_RSP: { @@ -1617,6 +1617,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt active_t->status, active_t->node_id, v_ep_list, active_t->endpoint_count); } + if (v_ep_list) + g_variant_unref(v_ep_list); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_SIMPLE_DESC_RSP: { @@ -1633,10 +1635,6 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt TRUE, NULL, NULL); if (NULL == v_in_cluster || NULL == v_out_cluster) { Z_LOGE("Failed to create variant!"); - if (v_in_cluster) - g_variant_unref(v_in_cluster); - if (v_out_cluster) - g_variant_unref(v_out_cluster); } else { Z_LOGD("Simple descriptor rsp"); zigbee_zdo_dev_control_emit_simple_desc_rsp(dev_control_object, @@ -1645,6 +1643,10 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt desc_t->in_cluster_count, desc_t->out_cluster_count, v_in_cluster, v_out_cluster); } + if (v_in_cluster) + g_variant_unref(v_in_cluster); + if (v_out_cluster) + g_variant_unref(v_out_cluster); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_MATCHED_DESC_RSP: { @@ -1660,6 +1662,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt zigbee_zdo_dev_control_emit_matched_descriptor_rsp(dev_control_object, desc_t->status, desc_t->node_id, desc_t->list_count, v_match_list); } + if (v_match_list) + g_variant_unref(v_match_list); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_MGMT_BIND_RSP: { @@ -1718,6 +1722,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt desc_t->status, desc_t->table_entries, desc_t->start_index, desc_t->table_list_count, v_entries); + if (v_entries) + g_variant_unref(v_entries); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_MGMT_LQI_RSP: { @@ -1873,6 +1879,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt nwk_disc_t->status, nwk_disc_t->network_count, nwk_disc_t->start_index, nwk_disc_t->table_list_count, v_entries); + if (v_entries) + g_variant_unref(v_entries); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_NODE_DESC_RSP: { @@ -1932,6 +1940,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt zigbee_zdo_dev_control_emit_user_desc_rsp(dev_control_object, desc_t->status, desc_t->node_id, desc_t->list_count, v_desc_list); } + if (v_desc_list) + g_variant_unref(v_desc_list); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_USER_DESC_CONFIRM: { -- 2.7.4 From 5cfe7fe1a3a014fdb6e4ca0ed15f1e93ca162194 Mon Sep 17 00:00:00 2001 From: "jh8801.jung" Date: Fri, 29 Sep 2017 08:41:17 +0900 Subject: [PATCH 03/16] Fix Prevent issue WGID : 36901 Signed-off-by: jh8801.jung Change-Id: Ic7df65b8c9cab89453f6b814825ba3e6690278fa --- zigbee-daemon/zigbee-lib/src/zblib_service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index 045b651..c8c078b 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -457,7 +457,7 @@ gboolean zblib_service_initialize_plugins(ZigBeeService *service) /* If there is no initializer, it should have asynchronous one */ const ZblibPluginDescriptor_t *descriptor = zblib_plugin_get_descriptor(plugin); - if (NULL != descriptor->init_async) { + if (NULL != descriptor && NULL != descriptor->init_async) { /* Register async initializer */ struct _zblib_async_init_info *info = g_try_new0(struct _zblib_async_init_info, 1); -- 2.7.4 From 8ff258a30d12afd475d293032e2bcae822f64bd6 Mon Sep 17 00:00:00 2001 From: saerome kim Date: Tue, 10 Oct 2017 19:35:49 +0900 Subject: [PATCH 04/16] Fix resource leak problem : 32057, 28497, 41860, 22384, 26742 Change-Id: Ic8ef28d48f31a8b5b7594c4129068b31466056d0 Signed-off-by: saerome kim --- .../zigbee-interface/src/zigbee_service_dbus_interface_service.c | 2 ++ .../src/zigbee_service_dbus_interface_zcl_global_control.c | 8 ++++---- .../src/zigbee_service_dbus_interface_zdo_dev_control.c | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c index 75cc3d3..d04136d 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c @@ -1303,6 +1303,8 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface * Z_LOGE("Failed to create variant!"); else zigbee_service_emit_child_rejoined(service_object, v_eui64); + if (v_eui64) + g_variant_unref(v_eui64); } break; case ZBLIB_SERVICE_NOTI_CHILD_LEFT: { diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c index 1478f0e..5e8974a 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c @@ -1400,16 +1400,16 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService TRUE, NULL, NULL); if (NULL == v_values || NULL == v_attrs) { Z_LOGE("Failed to create variant!"); - if (v_values) - g_variant_unref(v_values); - if (v_attrs) - g_variant_unref(v_attrs); } else { Z_LOGD("Write attributes resp"); zigbee_zcl_global_control_emit_write_attributes_rsp(global_control_object, attr_t->node_id, attr_t->src_ep, v_values, v_attrs, attr_t->cluster_id, attr_t->record_length); } + if (v_values) + g_variant_unref(v_values); + if (v_attrs) + g_variant_unref(v_attrs); break; } case ZBLIB_ZCL_GLOBAL_NOTI_CONFIG_REPORT_RSP: { diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c index 564dd10..63782ba 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c @@ -1576,6 +1576,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt nwk_addr_t->status, v_eui64, nwk_addr_t->node_id, nwk_addr_t->associated_count, nwk_addr_t->start_index); } + if (v_eui64) + g_variant_unref(v_eui64); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_NWK_ADDR_EXT_RSP: { @@ -1879,6 +1881,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt nwk_disc_t->status, nwk_disc_t->network_count, nwk_disc_t->start_index, nwk_disc_t->table_list_count, v_entries); + if (entry_builder) + g_variant_builder_unref(entry_builder); if (v_entries) g_variant_unref(v_entries); break; @@ -1924,6 +1928,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt zigbee_zdo_dev_control_emit_complex_desc_rsp(dev_control_object, desc_t->status, desc_t->node_id, desc_t->list_count, v_desc_list); } + if (v_desc_list) + g_variant_unref(v_desc_list); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_USER_DESC_RSP: { -- 2.7.4 From 3244c574f8b5858734e5c02620aaa87ad270ceec Mon Sep 17 00:00:00 2001 From: saerome kim Date: Tue, 10 Oct 2017 19:39:10 +0900 Subject: [PATCH 05/16] Fix resource leak : 23614 This problem is caused by managing a number of operations to be processed asynchronously in the initialization list. If the initialization of a function that needs to be processed asynchronously fails, we did not free the previously added asynchronous functions. To solve this problem, we modified the asynchronous initialization function list to be deleted from the memory when the function creation to be processed asynchronously fails and when the plugin is unloaded. Change-Id: I66226faedb360d7c2f41fd35db516a63684e112d Signed-off-by: saerome kim --- zigbee-daemon/zigbee-lib/src/zblib_service.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index f512514..2bfb853 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -266,6 +266,22 @@ static void __zblib_service_remove_request_table_iter(gpointer key, zblib_request_free(service_interface, request_id); } +static void __zblib_service_remove_async_list(GSList *list_async) +{ + GSList *iter = NULL; + if (0 < g_slist_length(list_async)) { + iter = g_slist_nth(list_async, 0); + while (iter) { + if (iter) { + struct _zblib_async_init_info *async_plugin = + (struct _zblib_async_init_info *)(list_async->data); + list_async = g_slist_remove(list_async, async_plugin); + } + iter = g_slist_nth(list_async, 0); + } + } +} + ZigBeeService *zblib_service_new() { ZigBeeService *service; @@ -473,6 +489,7 @@ gboolean zblib_service_initialize_plugins(ZigBeeService *service) list_async = g_slist_append(list_async, info); } else { + __zblib_service_remove_async_list(list_async); Z_LOGE("Fatal : Failed to initialize plugin"); return FALSE; } @@ -517,10 +534,15 @@ gboolean zblib_service_initialize_async_plugins(ZigBeeService *service) gboolean zblib_service_unload_plugins(ZigBeeService *service) { - GSList *list; + GSList *list = NULL; + GSList *list_async = NULL; zblib_check_null_ret_error("service", service, FALSE); + /* Unload everyy async_plugin */ + list_async = __zblib_service_ref_async_initializer(service); + __zblib_service_remove_async_list(list_async); + list = zblib_service_ref_plugins(service); while (list != NULL) { ZigBeePlugin *plugin = list->data; -- 2.7.4 From ae38e4925577c62b0f1b86d20da26cad0add6a37 Mon Sep 17 00:00:00 2001 From: saerome kim Date: Mon, 16 Oct 2017 19:22:44 +0900 Subject: [PATCH 06/16] Synchronize tizen_4.0 and tizen branch. Change-Id: I071b18b641117db0392948688a2b26e2ea803b89 Signed-off-by: saerome kim --- packaging/zigbee-manager.spec | 2 +- zigbee-daemon.manifest | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index b9072ed..59e4d70 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -1,6 +1,6 @@ %define major 0 %define minor 1 -%define patchlevel 1 +%define patchlevel 2 %define CHECK_ZIGBEE_PRIVILEGE False Name: zigbee-manager diff --git a/zigbee-daemon.manifest b/zigbee-daemon.manifest index f5a44ec..97e8c31 100644 --- a/zigbee-daemon.manifest +++ b/zigbee-daemon.manifest @@ -1,5 +1,5 @@ - - - + + + -- 2.7.4 From 346a548c97507a2119d4e870744d254dbbb6ef3d Mon Sep 17 00:00:00 2001 From: "jh8801.jung" Date: Mon, 23 Oct 2017 15:29:37 +0900 Subject: [PATCH 07/16] Fix Coverity issue : 22384, 41860 Signed-off-by: jh8801.jung Change-Id: I77bab2aa1e4e36407f737c3586cba1c0c102dc65 (cherry picked from commit 2732a5dc69782534ec200cd69d88100d796bd6a5) --- .../src/zigbee_service_dbus_interface_zcl_global_control.c | 2 ++ .../src/zigbee_service_dbus_interface_zdo_dev_control.c | 10 ++++++++++ 2 files changed, 12 insertions(+) mode change 100644 => 100755 zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c mode change 100644 => 100755 zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c old mode 100644 new mode 100755 index 5e8974a..91973d5 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c @@ -1385,6 +1385,8 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService attr_t->cluster_id, attr_t->status, attr_t->type, attr_t->record_length, attr_t->is_string); } + if (v_values) + g_variant_unref(v_values); break; } case ZBLIB_ZCL_GLOBAL_NOTI_WRITE_ATTR_RSP: { diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c old mode 100644 new mode 100755 index 63782ba..30582dd --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c @@ -1724,6 +1724,8 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt desc_t->status, desc_t->table_entries, desc_t->start_index, desc_t->table_list_count, v_entries); + if (entry_builder) + g_variant_builder_unref(entry_builder); if (v_entries) g_variant_unref(v_entries); break; @@ -1786,6 +1788,10 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt desc_t->status, desc_t->table_entries, desc_t->start_index, desc_t->table_list_count, v_entries); + if (entry_builder) + g_variant_builder_unref(entry_builder); + if (v_entries) + g_variant_unref(v_entries); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_MGMT_RTG_RSP: { @@ -1817,6 +1823,10 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt desc_t->status, desc_t->table_entries, desc_t->start_index, desc_t->table_list_count, v_entries); + if (entry_builder) + g_variant_builder_unref(entry_builder); + if (v_entries) + g_variant_unref(v_entries); break; } case ZBLIB_ZDO_DEV_CONTROL_NOTI_MGMT_PERMIT_JOIN_RSP: { -- 2.7.4 From 308d35c61f8380c284ad5060f2a5181a16881b2c Mon Sep 17 00:00:00 2001 From: saerome kim Date: Wed, 15 Nov 2017 10:12:55 +0900 Subject: [PATCH 08/16] Remove 'warning: user network_fw does not exist - using root' warning Change-Id: I20aa404ab10e7c7daf53238ba559432c32f47002 Signed-off-by: saerome kim --- packaging/zigbee-manager.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 59e4d70..44ef413 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -18,6 +18,8 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(vconf) +# if image creater does not know 'network_fw' +Requires: security-config %description Description: ZigBee Daemon -- 2.7.4 From 9f1121732cfb3a77dafeeef8494737cc231d694b Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Mon, 19 Mar 2018 20:33:11 +0900 Subject: [PATCH 09/16] fis svace issue - WID 317087 Change-Id: I17af8ef3b970d511f80ad994ef164d0820524c31 Signed-off-by: saerome.kim --- .../zigbee-interface/src/zigbee_service_dbus_interface.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c index afab090..af19f9f 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c @@ -362,6 +362,8 @@ static void zigbee_on_name_acquired(GDBusConnection *connection, static void zigbee_on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) { + gboolean ret; + GError *error = NULL; ZigbeeObjectSkeleton *zigbee_object; ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data; ZigBeeService *service = NULL; @@ -413,9 +415,14 @@ static void zigbee_on_bus_acquired(GDBusConnection *connection, /* * Export 'manager' interface on ZigBee D-BUS */ - g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(custom_data->zigbee_mgr), - connection, ZIGBEE_DBUS_PATH, NULL); - + ret = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(custom_data->zigbee_mgr), + connection, ZIGBEE_DBUS_PATH, &error); + if (FALSE == ret) { + /* LCOV_EXCL_START */ + Z_LOGW("g_dbus_interface_skeleton_export() Fail(%s)", error->message); + g_error_free(error); + /* LCOV_EXCL_STOP */ + } /* * Exports all objects managed by 'manager' on Connection (connection) */ -- 2.7.4 From 94f9f9a0ca5f308b9640f5c2507a960e6a6fe802 Mon Sep 17 00:00:00 2001 From: Milind Murhekar Date: Wed, 23 May 2018 11:27:44 +0530 Subject: [PATCH 10/16] Add initial code for GTest Change-Id: I8c0ec43efe59fa82b3e14d320fa3c66f073158f7 Signed-off-by: Milind Murhekar --- CMakeLists.txt | 13 + packaging/zigbee-manager.spec | 14 + unittest/CMakeLists.txt | 32 + unittest/common.h | 47 + unittest/gdbus.cpp | 462 +++++++++ unittest/gdbus.h | 122 +++ unittest/unittest.cpp | 1024 +++++++++++++++++++ unittest/zbl.cpp | 2199 +++++++++++++++++++++++++++++++++++++++++ unittest/zbl.h | 222 +++++ zigbee-daemon/src/main.c | 12 + 10 files changed, 4147 insertions(+) create mode 100644 unittest/CMakeLists.txt create mode 100644 unittest/common.h create mode 100644 unittest/gdbus.cpp create mode 100644 unittest/gdbus.h create mode 100644 unittest/unittest.cpp create mode 100644 unittest/zbl.cpp create mode 100644 unittest/zbl.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e2078a..329ad66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,8 +13,13 @@ SET(zigbee_pkgs glib-2.0 dlog gio-2.0 gio-unix-2.0) pkg_check_modules(pkgs REQUIRED "${zigbee_pkgs}") +IF (BUILD_GTESTS) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic -Wall -Werror-implicit-function-declaration") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable -fvisibility=default -fprofile-arcs -ftest-coverage") +ELSE (BUILD_GTESTS) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wall -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align -Wcast-qual -Wno-array-bounds -Wno-empty-body -Wno-ignored-qualifiers -Wshadow -Wwrite-strings -Wswitch-default -Wno-unused-but-set-parameter -Wno-unused-but-set-variable") +ENDIF (BUILD_TESTS) ### Address-Space Layout Randomization ### SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE") @@ -25,5 +30,13 @@ ADD_DEFINITIONS("-DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" " ADD_DEFINITIONS("-DFEATURE_DLOG_DEBUG=1") ADD_DEFINITIONS("-DZIGBEE_DEFAULT_PLUGINS_PATH=\"/usr/lib/zigbee/plugins/\"") +IF(BUILD_GCOV) + ADD_DEFINITIONS(-DBUILD_GCOV) +ENDIF(BUILD_GCOV) + ### Build ### ADD_SUBDIRECTORY(zigbee-daemon) + +IF(BUILD_GTESTS) + ADD_SUBDIRECTORY(unittest) +ENDIF(BUILD_GTESTS) diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 44ef413..6a2b4c5 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -18,6 +18,11 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(vconf) + +%if 0%{?gtests:1} +BuildRequires: pkgconfig(gmock) +%endif + # if image creater does not know 'network_fw' Requires: security-config @@ -52,10 +57,16 @@ cp -a %{SOURCE2} . %endif %build +%if 0%{?gcov:1} +export LDFLAGS+=" -lgcov" +%endif + cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DVERSION=%{version} \ -DLIB_INSTALL_DIR=%{_libdir} \ -DUNIT_INSTALL_DIR=%{_unitdir} \ + -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \ + -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} make %{?_smp_mflags} @@ -88,6 +99,9 @@ cp %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/system.d/zigbee.conf %{_datadir}/dbus-1/system.d/zigbee.conf %endif %license LICENSE +%if 0%{?gtests:1} +%{_bindir}/gtest* +%endif %files -n zigbee-lib %defattr(644,system,system,-) diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt new file mode 100644 index 0000000..a32f713 --- /dev/null +++ b/unittest/CMakeLists.txt @@ -0,0 +1,32 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(gtest-zigbee-manager C CXX) + +SET(GTEST_TEST "gtest-zigbee-manager") +ADD_DEFINITIONS("-DUSE_DLOG") + +SET(REQUIRES_LIST ${REQUIRES_LIST} + glib-2.0 + gio-2.0 + gmock + dlog +) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(GTEST_TEST_PKG REQUIRED ${REQUIRES_LIST}) + +FOREACH(flag ${GTEST_TEST_PKG_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +FILE(GLOB GTEST_TEST_SRCS *.cpp) +SET(GTEST_TEST_SRCS ${GTEST_TEST_SRCS}) + +ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS}) +TARGET_LINK_LIBRARIES(${GTEST_TEST} ${GTEST_TEST_LDFLAGS} ${GTEST_TEST_PKG_LDFLAGS} -ldl -lgcov) + +INSTALL(TARGETS ${GTEST_TEST} RUNTIME DESTINATION bin) diff --git a/unittest/common.h b/unittest/common.h new file mode 100644 index 0000000..e2707a7 --- /dev/null +++ b/unittest/common.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 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 __COMMON_H__ +#define __COMMON_H__ + +#include + +#ifdef USE_DLOG +#include +#undef LOG_TAG +#define LOG_TAG "ZIGBEE_GTEST" +#define GLOGD(format, args...) LOGD(format, ##args) +#else +#define GLOGD(format, args...) +#endif + +#ifndef TIZEN_ERROR_ZIGBEE +#define TIZEN_ERROR_ZIGBEE -0x02F70000 +#endif + +typedef enum { + ZIGBEE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + ZIGBEE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE = TIZEN_ERROR_RESULT_OUT_OF_RANGE, /**< Out of range */ + 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_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + ZIGBEE_ERROR_INVALID_ENDPOINT = TIZEN_ERROR_ZIGBEE | 0x01, /**< Endpoint 0 is reserved for ZDP */ + ZIGBEE_ERROR_INVALID_ADDRESS = TIZEN_ERROR_ZIGBEE | 0x02, /**< Wrong address */ + ZIGBEE_ERROR_OPERATION_FAILED = TIZEN_ERROR_ZIGBEE | 0x03, /**< Operation failed */ +} zb_error_e; +#endif /* __COMMON_H__ */ diff --git a/unittest/gdbus.cpp b/unittest/gdbus.cpp new file mode 100644 index 0000000..81432df --- /dev/null +++ b/unittest/gdbus.cpp @@ -0,0 +1,462 @@ +/* + * Copyright (c) 2017 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 "zbl.h" + +GDbus::GDbus() +{ + this->m_pConnection = NULL; + this->m_pCancellable = NULL; + this->service_gproxy = NULL; + this->on_off_gproxy = NULL; + this->door_lock_gproxy = NULL; + this->level_control_gproxy = NULL; + this->thermostat_gproxy = NULL; + this->alarm_gproxy = NULL; + this->fan_control_gproxy = NULL; + + this->mfglib_gproxy = NULL; + this->zcl_global_proxy = NULL; + this->zdo_dev_proxy = NULL; + this->zcl_basic_proxy = NULL; + this->zcl_identify_proxy = NULL; + this->zcl_ias_zone_proxy = NULL; + this->zcl_poll_control_proxy = NULL; + this->zcl_group_proxy = NULL; + this->zcl_scene_proxy = NULL; + this->zdo_bind_proxy = NULL; + this->zcl_color_control_proxy = NULL; + this->custom_gproxy = NULL; +} + +GDbus::~GDbus() +{ + GDBusConnection *conn = this->m_pConnection; + GCancellable *cancel = this->m_pCancellable; + + if (cancel) { + g_cancellable_cancel(cancel); + g_object_unref(cancel); + cancel = NULL; + } + + if (conn) { + g_object_unref(this->service_gproxy); + this->service_gproxy = NULL; + g_object_unref(this->on_off_gproxy); + this->on_off_gproxy = NULL; + g_object_unref(this->door_lock_gproxy); + this->door_lock_gproxy = NULL; + g_object_unref(this->level_control_gproxy); + this->level_control_gproxy = NULL; + g_object_unref(this->thermostat_gproxy); + this->thermostat_gproxy = NULL; + g_object_unref(this->alarm_gproxy); + this->alarm_gproxy = NULL; + g_object_unref(this->fan_control_gproxy); + this->fan_control_gproxy = NULL; + + g_object_unref(this->mfglib_gproxy); + this->mfglib_gproxy = NULL; + g_object_unref(this->zcl_global_proxy); + this->zcl_global_proxy = NULL; + + g_object_unref(this->zdo_dev_proxy); + this->zdo_dev_proxy = NULL; + g_object_unref(this->zcl_basic_proxy); + this->zcl_basic_proxy = NULL; + g_object_unref(this->zcl_identify_proxy); + this->zcl_identify_proxy = NULL; + g_object_unref(this->zcl_ias_zone_proxy); + this->zcl_ias_zone_proxy = NULL; + g_object_unref(this->zcl_poll_control_proxy); + this->zcl_poll_control_proxy = NULL; + g_object_unref(this->zcl_group_proxy); + this->zcl_group_proxy = NULL; + g_object_unref(this->zcl_scene_proxy); + this->zcl_scene_proxy = NULL; + g_object_unref(this->zdo_bind_proxy); + this->zdo_bind_proxy = NULL; + + g_object_unref(this->zcl_color_control_proxy); + this->zcl_color_control_proxy = NULL; + g_object_unref(this->custom_gproxy); + this->custom_gproxy = NULL; + + g_object_unref(conn); + conn = NULL; + } +} + +zb_error_e GDbus::Create(void) +{ + GError *err = NULL; + GDBusConnection *gdbus_conn; + +#if !GLIB_CHECK_VERSION(2, 36, 0) + g_type_init(); +#endif + + this->m_pConnection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); + if (this->m_pConnection == NULL) { + if (err != NULL) { + GLOGD("Failed to connect to the D-BUS daemon [%s]", err->message); + g_error_free(err); + } + + return ZIGBEE_ERROR_OPERATION_FAILED; + } + + gdbus_conn = this->m_pConnection; + + this->service_gproxy = 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); + + this->on_off_gproxy = 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); + + this->door_lock_gproxy = 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); + + this->level_control_gproxy = 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); + + this->thermostat_gproxy = 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); + + this->alarm_gproxy = 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); + + this->fan_control_gproxy = 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); + + this->mfglib_gproxy = 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); + + this->zcl_global_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); + + this->zdo_dev_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); + + this->zcl_basic_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); + + this->zcl_identify_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); + + this->zcl_ias_zone_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); + + this->zcl_poll_control_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); + + this->zcl_group_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); + + this->zcl_scene_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); + + this->zdo_bind_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); + + this->zcl_color_control_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); + + this->custom_gproxy = 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); + + this->m_pCancellable = g_cancellable_new(); + + return ZIGBEE_ERROR_NONE; +} + +zb_error_e GDbus::Destroy(void) +{ + g_object_unref(this->service_gproxy); + this->service_gproxy = NULL; + g_object_unref(this->on_off_gproxy); + this->on_off_gproxy = NULL; + g_object_unref(this->door_lock_gproxy); + this->door_lock_gproxy = NULL; + g_object_unref(this->level_control_gproxy); + this->level_control_gproxy = NULL; + g_object_unref(this->thermostat_gproxy); + this->thermostat_gproxy = NULL; + g_object_unref(this->alarm_gproxy); + this->alarm_gproxy = NULL; + g_object_unref(this->fan_control_gproxy); + this->fan_control_gproxy = NULL; + + g_object_unref(this->mfglib_gproxy); + this->mfglib_gproxy = NULL; + g_object_unref(this->zcl_global_proxy); + this->zcl_global_proxy = NULL; + + g_object_unref(this->zdo_dev_proxy); + this->zdo_dev_proxy = NULL; + g_object_unref(this->zcl_basic_proxy); + this->zcl_basic_proxy = NULL; + g_object_unref(this->zcl_identify_proxy); + this->zcl_identify_proxy = NULL; + g_object_unref(this->zcl_ias_zone_proxy); + this->zcl_ias_zone_proxy = NULL; + g_object_unref(this->zcl_poll_control_proxy); + this->zcl_poll_control_proxy = NULL; + g_object_unref(this->zcl_group_proxy); + this->zcl_group_proxy = NULL; + g_object_unref(this->zcl_scene_proxy); + this->zcl_scene_proxy = NULL; + g_object_unref(this->zdo_bind_proxy); + this->zdo_bind_proxy = NULL; + g_object_unref(this->zcl_color_control_proxy); + this->zcl_color_control_proxy = NULL; + g_object_unref(this->custom_gproxy); + this->custom_gproxy = NULL; + + g_cancellable_cancel(this->m_pCancellable); + g_object_unref(this->m_pCancellable); + this->m_pCancellable = NULL; + + g_object_unref(this->m_pConnection); + this->m_pConnection = NULL; + + return ZIGBEE_ERROR_NONE; +} + +GDBusConnection *GDbus::GetConnection(void) +{ + return this->m_pConnection; +} + +GCancellable *GDbus::GetCancellable(void) +{ + return this->m_pCancellable; +} + +GDBusProxy *GDbus::get_proxy_type(gproxy_type_e type) +{ + GDBusProxy *proxy = NULL; + + switch (type) + { + case SERVICE_GPROXY: + proxy = this->service_gproxy; + break; + case ON_OFF_GPROXY: + proxy = this->on_off_gproxy; + break; + case DOOR_LOCK_GPROXY: + proxy = this->door_lock_gproxy; + break; + case LEVEL_CONTROL_GPROXY: + proxy = this->level_control_gproxy; + break; + case THERMOSTAT_GPROXY: + proxy = this->thermostat_gproxy; + break; + case ALARM_GPROXY: + proxy = this->alarm_gproxy; + break; + case FAN_CONTROL_GPROXY: + proxy = this->fan_control_gproxy; + break; + case MFGLIB_GPROXY: + proxy = this->mfglib_gproxy; + break; + case ZCL_GLOBAL_PROXY: + proxy = this->zcl_global_proxy; + break; + case ZDO_DEV_PROXY: + proxy = this->zdo_dev_proxy; + break; + case ZCL_BASIC_PROXY: + proxy = this->zcl_basic_proxy; + break; + case ZCL_IDENTIFY_PROXY: + proxy = this->zcl_identify_proxy; + break; + case ZCL_IAS_ZONE_PROXY: + proxy = this->zcl_ias_zone_proxy; + break; + case ZCL_POLL_CONTROL_PROXY: + proxy = this->zcl_poll_control_proxy; + break; + case ZCL_GROUP_PROXY: + proxy = this->zcl_group_proxy; + break; + case ZCL_SCENE_PROXY: + proxy = this->zcl_scene_proxy; + break; + case ZDO_BIND_PROXY: + proxy = this->zdo_bind_proxy; + break; + case ZCL_COLOR_CONTROL_PROXY: + proxy = this->zcl_color_control_proxy; + break; + case CUSTOM_GPROXY: + proxy = this->custom_gproxy; + break; + } + + return proxy; +} + +GVariant *GDbus::invoke_proxy_method(gproxy_type_e type, const char *method, GVariant *params, int *error) +{ + GError *dbus_error = NULL; + GVariant *reply = NULL; + GDBusConnection *connection = NULL; + GDBusProxy *proxy = NULL; + + connection = GetConnection(); + if (connection == NULL) { + GLOGD("GDBusconnection is NULL"); + *error = ZIGBEE_ERROR_IO_ERROR; + return reply; + } + + proxy = get_proxy_type(type); + if (proxy == NULL) { + GLOGD("GDBusProxy is NULL"); + *error = ZIGBEE_ERROR_IO_ERROR; + return reply; + } + + reply = g_dbus_proxy_call_sync(proxy, + method, + params, + G_DBUS_CALL_FLAGS_NONE, + ZIGBEE_BROADCAST_TIMEOUT, + GetCancellable(), + &dbus_error); + + if (reply == NULL) { + if (dbus_error != NULL) { + GLOGD("g_dbus_connection_call_sync() failed " + "error [%d: %s]", dbus_error->code, dbus_error->message); + if (strstr(dbus_error->message, "AccessDenied")) + *error = ZIGBEE_ERROR_PERMISSION_DENIED; + else + *error = ZIGBEE_ERROR_IO_ERROR; + g_error_free(dbus_error); + } else { + GLOGD("g_dbus_connection_call_sync() failed"); + *error = ZIGBEE_ERROR_OPERATION_FAILED; + } + return NULL; + } + + return reply; +} + +GVariant *GDbus::InvokeMethod(const char *dest, const char *path, + const char *iface_name, const char *method, GVariant *params, int *error) +{ + GError *dbus_error = NULL; + GVariant *reply = NULL; + GDBusConnection *connection = NULL; + + connection = GetConnection(); + if (connection == NULL) { + GLOGD("GDBusconnection is NULL"); + *error = ZIGBEE_ERROR_IO_ERROR; + return reply; + } + + reply = g_dbus_connection_call_sync(connection, + dest, + path, + iface_name, + method, + params, + NULL, + G_DBUS_CALL_FLAGS_NONE, + ZIGBEE_BROADCAST_TIMEOUT, + GetCancellable(), + &dbus_error); + + if (reply == NULL) { + if (dbus_error != NULL) { + GLOGD("g_dbus_connection_call_sync() failed " + "error [%d: %s]", dbus_error->code, dbus_error->message); + if (strstr(dbus_error->message, "AccessDenied")) + *error = ZIGBEE_ERROR_PERMISSION_DENIED; + else + *error = ZIGBEE_ERROR_IO_ERROR; + g_error_free(dbus_error); + } else { + GLOGD("g_dbus_connection_call_sync() failed"); + *error = ZIGBEE_ERROR_OPERATION_FAILED; + } + return NULL; + } + + return reply; +} + +zb_error_e GDbus::InvokeMethodNonblock(const char *dest, const char *path, + const char *iface_name, const char *method, GVariant *params, int timeout, + GAsyncReadyCallback notify_func, void *user_data) +{ + GDBusConnection *connection = NULL; + + connection = GetConnection(); + if (connection == NULL) { + GLOGD("GDBusconnection is NULL"); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_dbus_connection_call(connection, + dest, + path, + iface_name, + method, + params, + NULL, + G_DBUS_CALL_FLAGS_NONE, + timeout, + GetCancellable(), + (GAsyncReadyCallback) notify_func, + (gpointer)user_data); + + return ZIGBEE_ERROR_NONE; +} diff --git a/unittest/gdbus.h b/unittest/gdbus.h new file mode 100644 index 0000000..2c0775b --- /dev/null +++ b/unittest/gdbus.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017 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 __ZIGBEE_GDBUS_H__ +#define __ZIGBEE_GDBUS_H__ + +#include +#include "common.h" + +#define GMAINTIMEOUT 10000 +#define ZIGBEE_BROADCAST_TIMEOUT (9.5 + 2) * 1000 /**< default timeout for gdbus */ + + +#ifndef ZIGBEE_DBUS_INTERFACE +#define ZIGBEE_DBUS_INTERFACE "org.tizen.zigbee" +#endif + +#ifndef ZIGBEE_DBUS_OBJPATH +#define ZIGBEE_DBUS_OBJPATH "/org/tizen/zigbee" +#endif + +#define ZIGBEE_SERVER_NAME "org.tizen.zigbee" +#define ZIGBEE_CONTROL_OBJECT_PATH "/org/tizen/zigbee/control" + +#define ZIGBEE_MANAGER_INTERFACE "org.tizen.zigbee.manager" +#define ZIGBEE_SERVICE_INTERFACE "org.tizen.zigbee.service" +#define ZIGBEE_SERVICE_OBJECT_PATH "/org/tizen/zigbee/service" + +#define ZIGBEE_ZDO_DEV_CONTROL_INTERFACE "org.tizen.zigbee.zdo_dev_control" +#define ZIGBEE_ZDO_BIND_INTERFACE "org.tizen.zigbee.zdo_bind" +#define ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_global_control" +#define ZIGBEE_ZCL_ALARM_INTERFACE "org.tizen.zigbee.zcl_alarm" +#define ZIGBEE_ZCL_BASIC_INTERFACE "org.tizen.zigbee.zcl_basic" +#define ZIGBEE_ZCL_COLOR_CONTROL_INTERFACE "org.tizen.zigbee.zcl_color_control" +#define ZIGBEE_ZCL_ON_OFF_INTERFACE "org.tizen.zigbee.zcl_on_off" +#define ZIGBEE_ZCL_DOOR_LOCK_INTERFACE "org.tizen.zigbee.zcl_door_lock" +#define ZIGBEE_ZCL_GROUP_INTERFACE "org.tizen.zigbee.zcl_group" +#define ZIGBEE_ZCL_FAN_CONTROL_INTERFACE "org.tizen.zigbee.zcl_fan_control" +#define ZIGBEE_ZCL_IAS_ZONE_INTERFACE "org.tizen.zigbee.zcl_ias_zone" +#define ZIGBEE_ZCL_IDENTIFY_INTERFACE "org.tizen.zigbee.zcl_identify" +#define ZIGBEE_ZCL_LEVEL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_level_control" +#define ZIGBEE_ZCL_POLL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_poll_control" +#define ZIGBEE_ZCL_SCENE_INTERFACE "org.tizen.zigbee.zcl_scene" +#define ZIGBEE_ZCL_THERMOSTAT_INTERFACE "org.tizen.zigbee.zcl_thermostat" +#define ZIGBEE_CUSTOM_INTERFACE "org.tizen.zigbee.custom" +#define ZIGBEE_MFGLIB_CONTROL_INTERFACE "org.tizen.zigbee.mfglib_control" + +typedef enum { + SERVICE_GPROXY, + ON_OFF_GPROXY, + DOOR_LOCK_GPROXY, + LEVEL_CONTROL_GPROXY, + THERMOSTAT_GPROXY, + ALARM_GPROXY, + FAN_CONTROL_GPROXY, + MFGLIB_GPROXY, + ZCL_GLOBAL_PROXY, + ZDO_DEV_PROXY, + ZCL_BASIC_PROXY, + ZCL_IDENTIFY_PROXY, + ZCL_IAS_ZONE_PROXY, + ZCL_POLL_CONTROL_PROXY, + ZCL_GROUP_PROXY, + ZCL_SCENE_PROXY, + ZDO_BIND_PROXY, + ZCL_COLOR_CONTROL_PROXY, + CUSTOM_GPROXY, +} gproxy_type_e; + +class GDbus { + private: + GDBusConnection *m_pConnection; + GDBusProxy *service_gproxy; + GDBusProxy *on_off_gproxy; + GDBusProxy *door_lock_gproxy; + GDBusProxy *level_control_gproxy; + GDBusProxy *thermostat_gproxy; + GDBusProxy *alarm_gproxy; + GDBusProxy *fan_control_gproxy; + GDBusProxy *mfglib_gproxy; + GDBusProxy *zcl_global_proxy; + GDBusProxy *zdo_dev_proxy; + GDBusProxy *zcl_basic_proxy; + GDBusProxy *zcl_identify_proxy; + GDBusProxy *zcl_ias_zone_proxy; + GDBusProxy *zcl_poll_control_proxy; + GDBusProxy *zcl_group_proxy; + GDBusProxy *zcl_scene_proxy; + GDBusProxy *zdo_bind_proxy; + GDBusProxy *zcl_color_control_proxy; + GDBusProxy *custom_gproxy; + GCancellable *m_pCancellable; + GDBusProxy *get_proxy_type(gproxy_type_e type); + + public: + GDbus(); + ~GDbus(); + zb_error_e Create(void); + zb_error_e Destroy(void); + GDBusConnection *GetConnection(void); + GCancellable *GetCancellable(void); + + GVariant *invoke_proxy_method(gproxy_type_e type, const char *method, GVariant *params, int *error); + GVariant *InvokeMethod(const char *dest, const char *path, + const char *iface_name, const char *method, GVariant *params, int *error); + zb_error_e InvokeMethodNonblock(const char *dest, const char *path, + const char *iface_name, const char *method, GVariant *params, int timeout, + GAsyncReadyCallback notify_func, void *user_data); +}; +#endif /* __ZIGBEE_GDBUS_H__ */ diff --git a/unittest/unittest.cpp b/unittest/unittest.cpp new file mode 100644 index 0000000..16ae17a --- /dev/null +++ b/unittest/unittest.cpp @@ -0,0 +1,1024 @@ +/* + * Copyright (c) 2017 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 "zbl.h" + +using ::testing::InitGoogleTest; +using ::testing::Test; +using ::testing::TestCase; + +TEST(ZigbeeManager, Enable_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_enable(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, Disable_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_disable(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, IsEnable_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + bool state; + + ret = zb_mgr.zbl_is_enable(&state); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, Enable_p1) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_enable(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, HwReset_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_hw_reset(); + EXPECT_TRUE( (ZIGBEE_ERROR_NONE == ret) || (ZIGBEE_ERROR_IO_ERROR == ret) ); +} + +TEST(ZigbeeManager, GetNetworkInfo_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_get_network_info(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, GetControllerMacAddr_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char mac[8]; + + ret = zb_mgr.zbl_get_controller_mac_address(mac); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, GetClusterList_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char ep = 1; + ieee_addr dest_addr64 = { 0x00, 0x12, 0x4B, 0x00, + 0x02, 0xF2, 0x58, 0x5B }; + unsigned char in_count = 0; + unsigned char out_count = 0; + unsigned short in_cluster_list[MAX_ENDPOINT_CLUSTERS] = { 0 }; + unsigned short out_cluster_list[MAX_ENDPOINT_CLUSTERS] = { 0 }; + + ret = zb_mgr.zbl_get_cluster_list(dest_addr64, ep, &in_count, + in_cluster_list, &out_count, out_cluster_list); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, GetEndPointList_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + ieee_addr dest_addr64 = { 0x00, 0x12, 0x4B, 0x00, + 0x02, 0xF2, 0x58, 0x5B }; + unsigned char count = 0; + unsigned char ep_list[10] = { 0 }; + + ret = zb_mgr.zbl_get_endpoint_list(dest_addr64, &count, ep_list); + EXPECT_TRUE( (ZIGBEE_ERROR_NONE == ret) || (ZIGBEE_ERROR_NO_DATA == ret) ); +} + +TEST(ZigbeeManager, ApiGetNodeType_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + ieee_addr dest_addr64 = { 0x00, 0x12, 0x4B, 0x00, + 0x02, 0xF2, 0x58, 0x5B }; + + ret = zb_mgr.zbl_api_get_node_type(dest_addr64); + EXPECT_TRUE( (ZIGBEE_ERROR_NONE == ret) || (ZIGBEE_ERROR_NO_DATA == ret) ); +} + +TEST(ZigbeeManager, GetAllDeviceInfo_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_get_all_device_info(); + EXPECT_TRUE( (ZIGBEE_ERROR_NONE == ret) || (ZIGBEE_ERROR_NO_DATA == ret) ); +} + +TEST(ZigbeeManager, CoexStart_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char channel = 11; + + ret = zb_mgr.zbl_coex_start(channel); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CoexStop_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_coex_stop(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, FormNetwork_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_form_network(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, DisableNetwork_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_disable_network(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, LeaveDevice_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + ieee_addr dest_addr64 = { 0x00, 0x12, 0x4B, 0x00, + 0x02, 0xF2, 0x58, 0x5B }; + bool remove_children = true; + bool rejoin = false; + + ret = zb_mgr.zbl_leave_device(dest_addr64, remove_children, + rejoin); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, PermitJoin_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char timeout = 90; + bool broadcast = true; + + ret = zb_mgr.zbl_permit_join(timeout, broadcast); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, NwkAddrReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + ieee_addr dest_addr64 = { 0x00, 0x12, 0x4B, 0x00, + 0x02, 0xF2, 0x58, 0x5B }; + + ret = zb_mgr.zbl_nwk_addr_req(dest_addr64, 0x00, 0x00); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, IeeeAddrReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ieee_addr_req(dest_addr16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ActiveEp_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_active_ep(dest_addr16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, SimpleDescReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_simple_desc_req(dest_addr16, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, MatchDescReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + unsigned char in_num = 0; + unsigned char out_num = 0; + unsigned short in_clusters[MAX_ENDPOINT_CLUSTERS] = { 0 }; + unsigned short out_clusters[MAX_ENDPOINT_CLUSTERS] = { 0 }; + + ret = zb_mgr.zbl_match_desc_req(dest_addr16, 0x00, in_num, + in_clusters, out_num, out_clusters); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, NodeDescReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_node_desc_req(dest_addr16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, PowerDescReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_power_desc_req(dest_addr16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ComplexDescReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_complex_desc_req(dest_addr16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, UserDescReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_user_desc_req(dest_addr16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, UserDescSet_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_user_desc_set(dest_addr16, 4, (unsigned char *)"test"); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, DeviceAnnce_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr st_addr16 = 0x708B; + ieee_addr st_addr64 = { 0x00, 0x0D, 0x6F, 0x00, + 0x04, 0x2B, 0xBE, 0x14 }; + + ret = zb_mgr.zbl_device_annce(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); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, BindReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + ieee_addr sj_addr64 = { 0x24, 0xFD, 0x5B, 0x00, + 0x01, 0x01, 0x86, 0xB6 }; + ieee_addr co_addr64 = { 0xD0, 0x52, 0xA8, 0xA9, + 0x8F, 0xB7, 0x00, 0x01 }; + + ret = zb_mgr.zbl_bind_req(dest_addr16, sj_addr64, 1, 0x0006, + co_addr64, 0x03, 0x0004, 1); + + EXPECT_TRUE( (ZIGBEE_ERROR_NONE == ret) || (ZIGBEE_ERROR_NO_DATA == ret) ); +} + +TEST(ZigbeeManager, UbindReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + ieee_addr sj_addr64 = { 0x24, 0xFD, 0x5B, 0x00, + 0x01, 0x01, 0x86, 0xB6 }; + ieee_addr co_addr64 = { 0xD0, 0x52, 0xA8, 0xA9, + 0x8F, 0xB7, 0x00, 0x01 }; + + ret = zb_mgr.zbl_unbind_req(dest_addr16, sj_addr64, 1, 0x0006, + co_addr64, 0x03, 0x0004, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, MgmtNwkDiscReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + 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; + + ret = zb_mgr.zbl_mgmt_nwk_disc_req(dest_addr16, scan_channels, + scan_duration, scan_count, start_idx); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, MgmtNwkUpdateReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + 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; + + ret = zb_mgr.zbl_mgmt_nwk_update_req(dest_addr16, scan_channels, + scan_duration, scan_count, start_idx); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, MgmtLqiReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + unsigned char start_idx = 0; + + ret = zb_mgr.zbl_mgmt_lqi_req(dest_addr16, start_idx); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, MgmtRtgReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + unsigned char start_idx = 0; + + ret = zb_mgr.zbl_mgmt_rtg_req(dest_addr16, start_idx); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, MgmtBindReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + unsigned char start_idx = 0; + + ret = zb_mgr.zbl_mgmt_bind_req(dest_addr16, start_idx); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, MgmtLeaveDevice_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + bool remove_children = true; + bool rejoin = true; + ieee_addr dest_addr64 = { 0x00, 0x12, 0x4B, 0x00, + 0x02, 0xF2, 0x58, 0x5B }; + + ret = zb_mgr.zbl_mgmt_leave_device(dest_addr64, remove_children, rejoin); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, MgmtPermitJoiningReq_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char permit_duration = 1; + unsigned char tc_significance = 1; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_mgmt_permit_joining_req(dest_addr16, permit_duration, + tc_significance); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ApsSend_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char aps_frame_ctl = ZB_APS_DELIVERY_UNICAST | ZB_APS_NO_ACK_REQUEST; + unsigned char src_ep = 1; + unsigned char dst_ep = 1; + unsigned short cluster_id = 0xFC05; + unsigned short profile_id = 0xFC01; + unsigned char zcl_frame_ctl = ZB_ZCL_FC_GLOBALLY_USED | ZB_ZCL_CLIENT_TO_SERVER | + ZB_ZCL_FC_NOT_MANUFACTURER | ZB_ZCL_DISABLE_DEFAULT_RESPONSE; + unsigned short mfg_code = 0x110A; + unsigned char cmd_id = 0x01; + unsigned short payload_len = 4; + unsigned char payload[4] = { 0x00, 0x01, 0x02, 0x03 }; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_aps_send(dest_addr16, aps_frame_ctl, src_ep, dst_ep, cluster_id, + profile_id, zcl_frame_ctl, mfg_code, cmd_id, payload_len, payload); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ZclSend_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char src_ep = 2; + unsigned char dst_ep = 2; + unsigned short cluster_id = 0x0000; + unsigned char zcl_frame_ctl = ZB_ZCL_FC_GLOBALLY_USED | ZB_ZCL_CLIENT_TO_SERVER | + ZB_ZCL_FC_NOT_MANUFACTURER | ZB_ZCL_DISABLE_DEFAULT_RESPONSE; + unsigned char cmd = 0x0; + unsigned short payload_len = 4; + unsigned char payload[4] = { 0x00, 0x01, 0x02, 0x03 }; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_zcl_send(dest_addr16, src_ep, dst_ep, cluster_id, + zcl_frame_ctl, cmd, payload_len, payload); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, SendToLocal_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned short length = 4; + unsigned char data[4] = { 0x00, 0x01, 0x02, 0x03 }; + + ret = zb_mgr.zbl_send_to_local(length, data); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, DiscoverCmdsGen_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_discover_cmds_gen(dest_addr16, 1, 1, + ZB_ZCL_DISABLE_DEFAULT_RESPONSE, 0x0004, 0x00, 4); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, DiscoverAttrExt_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_discover_attr_ext(dest_addr16, 1, 1, + ZB_ZCL_DISABLE_DEFAULT_RESPONSE, 0x0006, 0x0000, 5); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ResetAlarm_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char alarm_code = 0x01; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_reset_alarm(dest_addr16, 1, alarm_code, + 0x0006); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, GetAlarm_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_get_alarm(dest_addr16, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ResetAllAlarmLog_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_reset_all_alarm_log(dest_addr16, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolMoveToHue_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char move_hue = 0x20; + unsigned char direction = 0x00; + unsigned short trans_time16 = 0x00C8; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_move_to_hue(dest_addr16, 1, move_hue, + direction, trans_time16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolMoveHue_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char move_mode = 0x03; + unsigned char color_rate = 2; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_move_hue(dest_addr16, 1, move_mode, + color_rate); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolStepHue_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char step_mode = 0x03; + unsigned char step_size = 0x20; + unsigned char trans_time8 = 0x0A; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_step_hue(dest_addr16, 1, step_mode, + step_size, trans_time8); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolMoveToSaturation_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char saturation = 0x0A; + unsigned char trans_time16 = 0x00C8; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_move_to_saturation(dest_addr16, 1, saturation, + trans_time16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolMoveSaturation_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char move_mode = 0x03; + unsigned char color_rate = 2; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_move_saturation(dest_addr16, 1, move_mode, + color_rate); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolStepSaturation_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char step_mode = 0x03; + unsigned char step_size = 0x20; + unsigned char trans_time8 = 0x0A; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_step_saturation(dest_addr16, 1, step_mode, + step_size, trans_time8); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolMoveToHueAndSaturation_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char move_hue = 0x20; + unsigned char saturation = 0x0A; + unsigned short trans_time16 = 0x00C8; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_move_to_hue_and_saturation(dest_addr16, 1, move_hue, + saturation, trans_time16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolMoveToColor_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned short color_x = 0x280A; + unsigned short color_y = 0x2710; + unsigned short trans_time16 = 0x00C8; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_move_to_color(dest_addr16, 1, color_x, + color_y, trans_time16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolMoveColor_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned short rate_x = 0x0002; + unsigned short rate_y = 0x0002; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_move_color(dest_addr16, 1, rate_x, + rate_y); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolStepColor_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned short step_x = 0x3961; + unsigned short step_y = 0x396D; + unsigned short trans_time16 = 0x00C8; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_step_color(dest_addr16, 1, step_x, + step_y, trans_time16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, CcontrolMoveToColorTemperature_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned char color_temp = 0x78; + unsigned short trans_time16 = 0x00C8; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_ccontrol_move_to_color_temperature(dest_addr16, 1, color_temp, + trans_time16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ResetFactoryDefault_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_reset_factory_default(dest_addr16, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, Identify_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + unsigned short identify_time = 10; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_identify(dest_addr16, 1, identify_time); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, Identify_query_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_identify_query(dest_addr16, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, AddGroup_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_add_group(dest_addr16, 1, 0x0002, "6grpone"); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ViewGroup_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_view_group(dest_addr16, 1, 0x0002); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, GetGroupMembership_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + unsigned short group_list[2] = { 0x0002, 0x0003 }; + + ret = zb_mgr.zbl_group_get_group_membership(dest_addr16, 1, + 2, group_list); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, RemoveGroup_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_remove_group(dest_addr16, 1, 0x0002); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, RemoveAllGroup_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_remove_all_group(dest_addr16, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, AddGroupIfIdentifying_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_add_group_if_identifying(dest_addr16, 1, 0x0002, + "6grpone"); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, LevelControlMoveToLevel_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + unsigned short trans_time16 = 0x00C8; + + ret = zb_mgr.zbl_level_control_move_to_level(dest_addr16, 1, 0x01, + trans_time16); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, LevelControlMove_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_level_control_move(dest_addr16, 1, 0x03, 2); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, LevelControlSetp_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_level_control_step(dest_addr16, 1, 0x03, 0x20, + 0x00C8); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, LevelControlStop_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_level_control_stop(dest_addr16, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, LevelControlMoveToLevelWithOnOff_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_level_control_move_to_level_with_on_off(dest_addr16, 1, 0x02, + 0x00C8); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, LevelControlMoveWithOnOff_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_level_control_move_with_on_off(dest_addr16, 1, 0x03, 2); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, LevelControlSetpWithOnOff_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_level_control_step_with_on_off(dest_addr16, 1, 0x03, 0x20, + 0x00C8); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, OnOffSet_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_onoff_set(dest_addr16, 1, 0x01); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ZoneEnrollResponse_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + unsigned char enroll_response_code = 10; + unsigned char zone_id = 10; + + ret = zb_mgr.zbl_zone_enroll_response(dest_addr16, 1, enroll_response_code, + zone_id); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, PollcontrolCheckinResponse_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_pollcontrol_check_in_response(dest_addr16, 1, 0x01, 0x00C8); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, PollcontrolFastPollStop_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_pollcontrol_fast_poll_stop(dest_addr16, 1); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, PollcontrolSetShortPollInterval_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_pollcontrol_set_short_poll_interval(dest_addr16, 1, 5); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, PollcontrolSetLongPollInterval_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_pollcontrol_set_long_poll_interval(dest_addr16, 1, 10); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, AddScene_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + const char ext_field_set[] = {0x00, 0x06, 0x01, 0x00}; + + ret = zb_mgr.zbl_add_scene(dest_addr16, 1, 0x0002, 0x01, 0x0000, + "6scnone", 4, ext_field_set); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ViewScene_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_view_scene(dest_addr16, 1, 0x0002, 0x01); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, RemoveScene_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_remove_scene(dest_addr16, 1, 0x0002, 0x01); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, RemoveAllScene_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_remove_all_scene(dest_addr16, 1, 0x0002); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, StoreScene_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_store_scene(dest_addr16, 1, 0x0002, 0x01); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, RecallScene_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_recall_scene(dest_addr16, 1, 0x0002, 0x01); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, GetSceneMembership_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + + ret = zb_mgr.zbl_get_scene_membership(dest_addr16, 1, 0x0002); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +TEST(ZigbeeManager, ThermostatAdjustSetpoint_p) +{ + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + nwk_addr dest_addr16 = 0x1D1A; + unsigned char mode = 0x00; + unsigned char amount = 0x01; + + ret = zb_mgr.zbl_thermostat_adjust_setpoint(dest_addr16, 1, mode, + amount); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +int main(int argc, char **argv) +{ + InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/unittest/zbl.cpp b/unittest/zbl.cpp new file mode 100644 index 0000000..63f2f25 --- /dev/null +++ b/unittest/zbl.cpp @@ -0,0 +1,2199 @@ +/* + * 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 "zbl.h" + +Zigbee::Zigbee(void) +{ + Create(); +} + +Zigbee::~Zigbee(void) +{ + Destroy(); +} + +int Zigbee::zbl_enable(void) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message; + + GLOGD("zbl_enable()"); + + message = InvokeMethod(ZIGBEE_MANAGER_INTERFACE, + ZIGBEE_DBUS_OBJPATH, + ZIGBEE_MANAGER_INTERFACE, + "enable", NULL, &error); + + if (message) + g_variant_unref(message); + + return error; +} + +int Zigbee::zbl_disable(void) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_disable()"); + + message = InvokeMethod(ZIGBEE_MANAGER_INTERFACE, + ZIGBEE_DBUS_OBJPATH, + ZIGBEE_MANAGER_INTERFACE, + "disable", NULL, &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = 0x%x", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_is_enable(bool* state) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_is_enable()"); + + message = InvokeMethod(ZIGBEE_MANAGER_INTERFACE, + ZIGBEE_DBUS_OBJPATH, + ZIGBEE_MANAGER_INTERFACE, + "get_zigbee_state", NULL, &error); + + if (message) { + g_variant_get(message, "(ib)", &error, state); + GLOGD("enable = %s", state ? "TRUE" : "FALSE"); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_hw_reset(void) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_hw_reset()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "zb_hw_reset", + NULL, + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_get_network_info(void) +{ + GVariant *message = NULL; + GVariantIter *iter = NULL; + int error = ZIGBEE_ERROR_NONE; + + nwk_addr _nodeid; + nwk_addr _panid; + unsigned char _radio_channel; + unsigned char _radio_tx_power; + + GLOGD("zbl_get_network_info()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "get_network_info", + NULL, + &error); + + if (message) { + g_variant_get(message, "(ia(y)qqyy)", &error, &iter, + &_nodeid, &_panid, &_radio_channel, &_radio_tx_power); + GLOGD("ret = [0x%x]", error); + g_variant_iter_free(iter); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_get_controller_mac_address(ieee_addr mac) +{ + GVariant *message = NULL; + GVariantIter *iter = NULL; + int error = ZIGBEE_ERROR_NONE; + int j = 0; + char value; + + GLOGD("zbl_get_controller_mac_address()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "get_mac", + NULL, + &error); + + if (message) { + g_variant_get(message, "(ia(y))", &error, &iter); + GLOGD("ret = [0x%x]", error); + + while (g_variant_iter_loop(iter, "(y)", &value)) + mac[j++] = value; + + g_variant_iter_free(iter); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::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 *message = NULL; + GVariantBuilder *mac_builder = NULL; + GVariant *mac_variant = NULL; + GVariantIter *in_cluster_iter = NULL; + GVariantIter *out_cluster_iter = NULL; + int error = ZIGBEE_ERROR_NONE; + + unsigned short cluster = 0; + int i = 0; + + GLOGD("zbl_get_cluster_list()"); + + 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); + + message = invoke_proxy_method(SERVICE_GPROXY, "get_cluster_list", + g_variant_new("(@a(y)y)", mac_variant, endpoint), + &error); + + if (message) { + g_variant_get(message, "(iaqaq)", &error, &in_cluster_iter, &out_cluster_iter); + GLOGD("ret = [0x%x]", error); + + /* In clusters */ + while (g_variant_iter_loop(in_cluster_iter, "q", &cluster)) + in_cluster_list[i++] = cluster; + + *in_cluster_count = i; + g_variant_iter_free(in_cluster_iter); + i = 0; + + /* Out clusters */ + while (g_variant_iter_loop(out_cluster_iter, "q", &cluster)) + out_cluster_list[i++] = cluster; + + *out_cluster_count = i; + g_variant_iter_free(out_cluster_iter); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_get_endpoint_list(ieee_addr eui64, unsigned char *count, + unsigned char list[]) +{ + GVariant *message = NULL; + GVariantBuilder *mac_builder = NULL; + GVariant *mac_variant = NULL; + GVariantIter *iter = NULL; + int error = ZIGBEE_ERROR_NONE; + + unsigned char endpoint; + int i = 0; + + GLOGD("zbl_get_endpoint_list()"); + + 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); + + message = invoke_proxy_method(SERVICE_GPROXY, "get_endpoint_list", + g_variant_new("(@a(y))", mac_variant), + &error); + + if (message) { + g_variant_get(message, "(ia(y))", &error, &iter); + GLOGD("ret = [0x%x]", error); + + while (g_variant_iter_loop(iter, "(y)", &endpoint)) + list[i++] = endpoint; + + *count = i; + g_variant_iter_free(iter); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_api_get_node_type(ieee_addr eui64) +{ + GVariant *message = NULL; + GVariantBuilder *mac_builder = NULL; + GVariant *mac_variant = NULL; + int error = ZIGBEE_ERROR_NONE; + unsigned char node_type; + + GLOGD("zbl_api_get_node_type()"); + + 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); + + message = invoke_proxy_method(SERVICE_GPROXY, "get_node_type", + g_variant_new("(@a(y))", mac_variant), + &error); + + if (message) { + g_variant_get(message, "(iy)", &error, &node_type); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_get_all_device_info(void) +{ + GVariant *message = NULL; + GVariantIter *iter = NULL; + int error = ZIGBEE_ERROR_NONE; + + GLOGD("zbl_get_all_device_info()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "get_device_info", NULL, &error); + + if (message) { + g_variant_get(message, "(ia(qyayyay))", &error, &iter); + GLOGD("ret = [0x%x]", error); + g_variant_iter_free(iter); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_coex_start(unsigned char channel) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_coex_start()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "coex_start", g_variant_new("(y)", channel), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_coex_stop(void) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_coex_stop()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "coex_stop", NULL, &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_form_network(void) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_form_network()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "form_network", NULL, &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_disable_network(void) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_disable_network()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "leave_network", NULL, &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_leave_device(ieee_addr addr64, bool remove_children, bool rejoin) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GVariantBuilder *mac_builder = NULL; + GVariant* mac_variant = NULL; + unsigned char _remove_children = (remove_children) ? 1 : 0; + unsigned char _rejoin = (rejoin) ? 1 : 0; + + GLOGD("zbl_leave_device()"); + + 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); + + message = invoke_proxy_method(SERVICE_GPROXY, "leave_request", + g_variant_new("(@a(y)yy)", mac_variant, _remove_children, _rejoin), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_permit_join(unsigned char duration, bool broadcast) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_permit_join()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "permit_join", + g_variant_new("(ib)", duration, broadcast), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_nwk_addr_req(ieee_addr addr64, unsigned char request_type, + unsigned char start_idx) +{ + GVariantBuilder *mac_builder = NULL; + GVariant* mac_variant = NULL; + + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD(" zbl_nwk_addr_req()"); + + 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); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "nwk_addr_req", + g_variant_new("(@a(y)yy)", mac_variant, request_type, start_idx), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ieee_addr_req(nwk_addr addr16) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ieee_addr_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "ieee_addr_req", + g_variant_new("(q)", addr16), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_active_ep(nwk_addr addr16) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_active_ep()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "active_ep_req", + g_variant_new("(q)", addr16), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_simple_desc_req(nwk_addr addr16, unsigned char ep) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_simple_desc_req() : [%X]", addr16); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "simple_desc_req", + g_variant_new("(qy)", addr16, ep), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_match_desc_req(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) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + int i; + GVariantBuilder *incl_builder = NULL; + GVariant* incl_variant = NULL; + GVariantBuilder *outcl_builder = NULL; + GVariant* outcl_variant = NULL; + + GLOGD("zbl_match_desc_req()"); + + 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); + + message = invoke_proxy_method(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), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_node_desc_req(nwk_addr addr16) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_node_desc_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "node_desc_req", + g_variant_new("(q)", addr16), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_power_desc_req(nwk_addr addr16) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_power_desc_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "power_desc_req", + g_variant_new("(q)", addr16), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_complex_desc_req(nwk_addr addr16) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_complex_desc_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "complex_desc_req", + g_variant_new("(q)", addr16), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_user_desc_req(nwk_addr addr16) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_user_desc_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "user_desc_req", + g_variant_new("(q)", addr16), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_user_desc_set(nwk_addr addr16, unsigned char len, + unsigned char *user_desc) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + unsigned char j = 0x00; + GVariantBuilder *user_desc_builder = NULL; + GVariant *user_desc_variant = NULL; + + GLOGD("zbl_user_desc_set()"); + + 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); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "user_desc_set_req", + g_variant_new("(qy@a(y))", addr16, len, user_desc_variant), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_device_annce(nwk_addr addr16, ieee_addr addr64, + unsigned char capability) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GVariantBuilder *mac_builder = NULL; + GVariant* mac_variant = NULL; + + GLOGD("zbl_device_annce()"); + + 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); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "device_announce", + g_variant_new("(q@a(y)y)", addr16, mac_variant, capability), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::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) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + int i; + GVariantBuilder *src_addr64_builder = NULL; + GVariant* src_addr64_variant = NULL; + GVariantBuilder *dst_addr64_builder = NULL; + GVariant* dst_addr64_variant = NULL; + + GLOGD("zbl_bind_req()"); + + 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); + + message = invoke_proxy_method(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), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::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) +{ + int i; + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GVariantBuilder *src_addr64_builder = NULL; + GVariant* src_addr64_variant = NULL; + GVariantBuilder *dst_addr64_builder = NULL; + GVariant* dst_addr64_variant = NULL; + + GLOGD("zbl_zdo_unbind_req()"); + + 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); + + message = invoke_proxy_method(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), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_mgmt_nwk_disc_req(nwk_addr addr16, unsigned int scan_channels, + unsigned char scan_duration, unsigned char scan_count, unsigned char start_idx) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_mgmt_nwk_disc_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "mgmt_nwk_disc_req", + g_variant_new("(quyqy)", + addr16, + scan_channels, + scan_duration, + scan_count, + start_idx), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::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 error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_mgmt_nwk_update_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "mgmt_nwk_update_req", + g_variant_new("(quyyy)", nwk_manager_addr, + scan_channels, scan_duration, + scan_count, nwk_update_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_mgmt_lqi_req(nwk_addr addr16, unsigned char start_idx) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_mgmt_lqi_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "mgmt_lqi_req", + g_variant_new("(qy)", addr16, start_idx), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_mgmt_rtg_req(nwk_addr addr16, unsigned char start_idx) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_mgmt_rtg_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "mgmt_rtg_req", + g_variant_new("(qy)", addr16, start_idx), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_mgmt_bind_req(nwk_addr addr16, unsigned char start_idx) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_mgmt_bind_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "mgmt_bind_req", + g_variant_new("(qy)", addr16, start_idx), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_mgmt_leave_device(ieee_addr addr64, unsigned char remove_children, + unsigned rejoin) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GVariantBuilder *mac_builder = NULL; + GVariant* mac_variant = NULL; + + 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); + + GLOGD("zbl_mgmt_leave_device()"); + + message = invoke_proxy_method(SERVICE_GPROXY, "leave_request", + g_variant_new("(@a(y)yy)", mac_variant, remove_children, rejoin), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_mgmt_permit_joining_req(nwk_addr addr16, unsigned char duration, + unsigned char tc_significance) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_mgmt_permit_joining_req()"); + + message = invoke_proxy_method(ZDO_DEV_PROXY, "mgmt_permit_join_req", + g_variant_new("(qyy)", addr16, duration, tc_significance), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::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) +{ + int i; + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GVariantBuilder *payload_builder = NULL; + GVariant *payload_variant = NULL; + + 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); + + GLOGD("zbl_aps_send()"); + + message = invoke_proxy_method(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), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::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) +{ + int i; + + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GVariantBuilder *payload_builder = NULL; + GVariant *payload_variant = NULL; + + GLOGD("zbl_zcl_send()"); + + 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); + + message = invoke_proxy_method(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), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_send_to_local(unsigned short length, unsigned char *data) +{ + int i; + + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_send_to_local()"); + + GVariantBuilder *payload_builder = NULL; + GVariant *payload_variant = NULL; + + 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); + + message = invoke_proxy_method(CUSTOM_GPROXY, "send_to_local", + g_variant_new("(q@a(y))", length, payload_variant), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_read_attr_req(unsigned short addr16, unsigned char dest_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short *attribute_ids, + int attribute_ids_len) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + int i = 0; + unsigned char *t; + GVariant *attr_variant = NULL; + GVariantBuilder *attr_builder = NULL; + + GLOGD("zbl_read_attr_req()"); + + 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); + + message = invoke_proxy_method(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), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_discover_attr_req(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) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_discover_attr_req()"); + + message = invoke_proxy_method(ZCL_GLOBAL_PROXY, "discover_attributes", + g_variant_new("(qyyqqy)", addr16, dest_ep, zcl_frame_ctl, + cluster_id, start_id, max_attribute_ids), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_discover_cmds_gen(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) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_discover_attr_gen()"); + + message = invoke_proxy_method(ZCL_GLOBAL_PROXY, "discover_commands_generated", + g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, + cluster_id, start_command_id, max_command_ids), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_discover_cmds_recv(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) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_discover_cmds_recv()"); + + message = invoke_proxy_method(ZCL_GLOBAL_PROXY, "discover_commands_received", + g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, + cluster_id, start_command_id, max_command_ids), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_discover_attr_ext(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) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_discover_attr_ext()"); + + message = invoke_proxy_method(ZCL_GLOBAL_PROXY, "discover_attributes_extended", + g_variant_new("(qyyqqy)", addr16, dst_ep, zcl_frame_ctl, cluster_id, start_id, + max_attribute_ids), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_reset_alarm(nwk_addr addr16, unsigned char ep, unsigned char alarm_code, + unsigned short cluster_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_reset_alarm()"); + + message = invoke_proxy_method(ALARM_GPROXY, "reset_alarm", + g_variant_new("(qyyq)", addr16, ep, alarm_code, cluster_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_get_alarm(nwk_addr addr16, unsigned char ep) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_get_alarm()"); + + message = invoke_proxy_method(ALARM_GPROXY, "get_alarm", + g_variant_new("(qy)", addr16, ep), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_reset_all_alarm_log(nwk_addr addr16, unsigned char ep) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + message = invoke_proxy_method(ALARM_GPROXY, "reset_alarm_log", + g_variant_new("(qy)", addr16, ep), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_move_to_hue(nwk_addr addr16, unsigned char ep, + unsigned char hue, unsigned char direction, + unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "move_to_hue", + g_variant_new("(qyyyq)", addr16, ep, hue, direction, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_move_hue(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "move_hue", + g_variant_new("(qyyy)", addr16, ep, move_mode, rate), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_step_hue(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned char transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "step_hue", + g_variant_new("(qyyyy)", addr16, ep, step_mode, step_size, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_move_to_saturation(nwk_addr addr16, unsigned char ep, + unsigned char saturation, unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ccontrol_move_to_saturation()"); + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "move_to_saturation", + g_variant_new("(qyyq)", addr16, ep, saturation, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_move_saturation(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ccontrol_move_saturation()"); + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "move_saturation", + g_variant_new("(qyyy)", addr16, ep, move_mode, rate), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_step_saturation(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned char transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ccontrol_step_saturation()"); + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "step_saturation", + g_variant_new("(qyyyy)", addr16, ep, step_mode, step_size, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_move_to_hue_and_saturation(nwk_addr addr16, unsigned char ep, + unsigned char hue, unsigned char saturation, + unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ccontrol_move_to_hue_and_saturation()"); + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "move_to_hue_and_saturation", + g_variant_new("(qyyyq)", addr16, ep, hue, saturation, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_move_to_color(nwk_addr addr16, unsigned char ep, + unsigned short color_x, unsigned short color_y, + unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ccontrol_move_to_color()"); + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "move_to_color", + g_variant_new("(qyqqq)", addr16, ep, color_x, color_y, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_move_color(nwk_addr addr16, unsigned char ep, + unsigned short rate_x, unsigned short rate_y) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ccontrol_move_color()"); + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "move_color", + g_variant_new("(qyqq)", addr16, ep, rate_x, rate_y), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_step_color(nwk_addr addr16, unsigned char ep, + unsigned short step_x, unsigned short step_y, + unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ccontrol_step_color()"); + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "step_color", + g_variant_new("(qyqqq)", addr16, ep, step_x, step_y, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_ccontrol_move_to_color_temperature(nwk_addr addr16, unsigned char ep, + unsigned short color_temperature, + unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_ccontrol_move_to_color_temperature()"); + + message = invoke_proxy_method(ZCL_COLOR_CONTROL_PROXY, "move_color_temperature", + g_variant_new("(qyqq)", addr16, ep, color_temperature, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_reset_factory_default(nwk_addr addr16, unsigned char ep) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_reset_factory_default()"); + + message = invoke_proxy_method(ZCL_BASIC_PROXY, "reset_factory_default", + g_variant_new("(qy)", addr16, ep), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_identify(nwk_addr addr16, unsigned char dst_ep, unsigned short identify_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_identify()"); + + message = invoke_proxy_method(ZCL_IDENTIFY_PROXY, "identify", + g_variant_new("(qyq)", addr16, dst_ep, identify_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_identify_query(nwk_addr addr16, unsigned char dst_ep) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_identify_query()"); + + message = invoke_proxy_method(ZCL_IDENTIFY_PROXY, "query", + g_variant_new("(qy)", addr16, dst_ep), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_add_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, + const char *group_name) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + int j = 0; + GVariant *groupname_variant = NULL; + GVariantBuilder *groupname_builder = NULL; + + GLOGD("zbl_add_group()"); + + 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); + + message = invoke_proxy_method(ZCL_GROUP_PROXY, "add_group", + g_variant_new("(qyq@a(y))", addr16, ep, group_id, groupname_variant), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_view_group(nwk_addr addr16, unsigned char ep, unsigned short group_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_view_group()"); + + message = invoke_proxy_method(ZCL_GROUP_PROXY, "view_group", + g_variant_new("(qyq)", addr16, ep, group_id), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_group_get_group_membership(nwk_addr addr16, unsigned char ep, + unsigned char group_count, unsigned short *group_list) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + int j = 0; + GVariant *grouplist_variant = NULL; + GVariantBuilder *grouplist_builder = NULL; + + GLOGD("zbl_group_get_group_membership()"); + + 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); + + message = invoke_proxy_method(ZCL_GROUP_PROXY, "get_group_membership", + g_variant_new("(qyy@aq)", addr16, ep, group_count, grouplist_variant), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_remove_group(nwk_addr addr16, unsigned char ep, unsigned short group_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_group_remove_group()"); + + message = invoke_proxy_method(ZCL_GROUP_PROXY, "remove_group", g_variant_new("(qyq)", + addr16, ep, group_id), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_remove_all_group(nwk_addr addr16, unsigned char ep) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_group_remove_all_group()"); + + message = invoke_proxy_method(ZCL_GROUP_PROXY, "remove_all_group", + g_variant_new("(qy)", addr16, ep), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_add_group_if_identifying(nwk_addr addr16, unsigned char ep, + unsigned short group_id, const char *group_name) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_add_group_if_identifying()"); + + int j = 0; + GVariant *groupname_variant = NULL; + GVariantBuilder *groupname_builder = NULL; + + 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); + + message = invoke_proxy_method(ZCL_GROUP_PROXY, "add_group_if_identifying", + g_variant_new("(qyq@a(y))", addr16, ep, group_id, groupname_variant), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_level_control_move_to_level(nwk_addr addr16, unsigned char ep, + unsigned char level, unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_level_control_move_to_level()"); + + message = invoke_proxy_method(LEVEL_CONTROL_GPROXY, "move_to_level", + g_variant_new("(qyyq)", addr16, ep, level, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_level_control_move(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_level_control_move()"); + + message = invoke_proxy_method(LEVEL_CONTROL_GPROXY, "move", + g_variant_new("(qyyy)", addr16, ep, move_mode, rate), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_level_control_step(nwk_addr addr16, unsigned char ep, + unsigned char step_mode, unsigned char step_size, + unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_level_control_step()"); + + message = invoke_proxy_method(LEVEL_CONTROL_GPROXY, "step", + g_variant_new("(qyyyq)", addr16, ep, step_mode, step_size, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_level_control_stop(nwk_addr addr16, unsigned char ep) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_level_control_stop()"); + + message = invoke_proxy_method(LEVEL_CONTROL_GPROXY, "stop", + g_variant_new("(qy)", addr16, ep), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_level_control_move_to_level_with_on_off(nwk_addr addr16, + unsigned char ep, unsigned char level, unsigned short transition_time) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_level_control_move_to_level_with_on_off()"); + + message = invoke_proxy_method(LEVEL_CONTROL_GPROXY, "move_to_level_with_on_off", + g_variant_new("(qyyq)", addr16, ep, level, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_level_control_move_with_on_off(nwk_addr addr16, unsigned char ep, + unsigned char move_mode, unsigned char rate) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_level_control_move_with_on_off()"); + + message = invoke_proxy_method(LEVEL_CONTROL_GPROXY, "move_with_on_off", + g_variant_new("(qyyy)", addr16, ep, move_mode, rate), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::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 error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_level_control_step_with_on_off()"); + + message = invoke_proxy_method(LEVEL_CONTROL_GPROXY, "step_with_on_off", + g_variant_new("(qyyyq)", addr16, ep, step_mode, step_size, transition_time), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_onoff_set(nwk_addr addr16, unsigned char ep, unsigned char on_off_type) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_onoff_set()"); + + message = invoke_proxy_method(ON_OFF_GPROXY, "set_on_off", + g_variant_new("(qyy)", addr16, ep, on_off_type), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_zone_enroll_response(nwk_addr addr16, unsigned char dst_ep, + unsigned char enroll_response_code, unsigned char zone_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_zone_enroll_response()"); + + message = invoke_proxy_method(ZCL_IAS_ZONE_PROXY, "enroll_response", + g_variant_new("(qyyy)", addr16, dst_ep, enroll_response_code, zone_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_pollcontrol_check_in_response(nwk_addr addr16, unsigned char ep, + unsigned char start_fast_polling, unsigned short fast_poll_timeout) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_pollcontrol_check_in_response()"); + + message = invoke_proxy_method(ZCL_POLL_CONTROL_PROXY, "check_in_response", + g_variant_new("(qyyq)", addr16, ep, start_fast_polling, fast_poll_timeout), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_pollcontrol_fast_poll_stop(nwk_addr addr16, unsigned char ep) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_pollcontrol_fast_poll_stop()"); + + message = invoke_proxy_method(ZCL_POLL_CONTROL_PROXY, "fast_poll_stop", + g_variant_new("(qy)", addr16, ep), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_pollcontrol_set_long_poll_interval(nwk_addr addr16, unsigned char ep, + unsigned int new_long_poll_interval) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_pollcontrol_set_long_poll_interval()"); + + message = invoke_proxy_method(ZCL_POLL_CONTROL_PROXY, "set_long_poll_interval", + g_variant_new("(qyu)", addr16, ep, new_long_poll_interval), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_pollcontrol_set_short_poll_interval(nwk_addr addr16, unsigned char ep, + unsigned int new_short_poll_interval) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_pollcontrol_set_short_poll_interval()"); + + message = invoke_proxy_method(ZCL_POLL_CONTROL_PROXY, "set_short_poll_interval", + g_variant_new("(qyu)", addr16, ep, new_short_poll_interval), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::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) + +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + int j = 0; + int index = 0; + GVariant *scenename_variant = NULL; + GVariantBuilder *scenename_builder = NULL; + GVariant *extensionfieldSet_variant = NULL; + GVariantBuilder *extensionfieldSet_builder = NULL; + + GLOGD("zbl_add_scene()"); + + 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) { + GLOGD("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); + + message = invoke_proxy_method(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), &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_view_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_scene_view_scene()"); + + message = invoke_proxy_method(ZCL_SCENE_PROXY, "view_scene", + g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_remove_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_scene_remove_scene()"); + + message = invoke_proxy_method(ZCL_SCENE_PROXY, "remove_scene", + g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_remove_all_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_scene_remove_all_scene()"); + + message = invoke_proxy_method(ZCL_SCENE_PROXY, "remove_all_scene", + g_variant_new("(qyq)", addr16, ep, group_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_store_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_scene_store_scene()"); + + message = invoke_proxy_method(ZCL_SCENE_PROXY, "store_scene", + g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_recall_scene(nwk_addr addr16, unsigned char ep, + unsigned short group_id, unsigned char scene_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_recall_scene()"); + + message = invoke_proxy_method(ZCL_SCENE_PROXY, "recall_scene", + g_variant_new("(qyqy)", addr16, ep, group_id, scene_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_get_scene_membership(nwk_addr addr16, unsigned char ep, + unsigned short group_id) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_scene_get_scene_membership()"); + + message = invoke_proxy_method(ZCL_SCENE_PROXY, "get_scene_membership", + g_variant_new("(qyq)", addr16, ep, group_id), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} + +int Zigbee::zbl_thermostat_adjust_setpoint(nwk_addr addr16, unsigned char ep, + unsigned char mode, unsigned char amount) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_thermostat_adjust_setpoint()"); + + message = invoke_proxy_method(THERMOSTAT_GPROXY, "setpoint_raise_lower", + g_variant_new("(qyyy)", addr16, ep, mode, amount), + &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = [0x%x]", error); + g_variant_unref(message); + } + + return error; +} diff --git a/unittest/zbl.h b/unittest/zbl.h new file mode 100644 index 0000000..baf8c12 --- /dev/null +++ b/unittest/zbl.h @@ -0,0 +1,222 @@ +/* + * Copyright (c) 2017 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 __ZIGBEE_MANAGER_H__ +#define __ZIGBEE_MANAGER_H__ + +#include +#include + +#include "gdbus.h" +#include "common.h" + +#define MAX_ENDPOINT_CLUSTERS 32 +#define ZB_802_15_4_CHANNELS_MASK 0x07FFF800UL + +typedef unsigned char ieee_addr[8]; +typedef unsigned short nwk_addr; +typedef unsigned char aes128_key[16]; + +typedef enum { + ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR = (1 << 0), + ZB_ZDP_DEVICE_TYPE = (1 << 1), + ZB_ZDP_POWER_SOURCE = (1 << 2), + ZB_ZDP_RECEIVER_ON_WHEN_IDLE = (1 << 3), + ZB_ZDP_SECURITY_CAPABILITY = (1 << 6), + ZB_ZDP_ALLOCATE_ADDRESS = (1 << 7), +} zb_zdo_mac_capability_field_e; + +typedef enum { + ZB_APS_NO_ACK_REQUEST = (0 << 6), + ZB_APS_ACK_REQUEST = (1 << 6), +} zb_aps_ack_request_e; + +typedef enum { + ZB_APS_DELIVERY_UNICAST = 0, + ZB_APS_DELIVERY_INDIRECT = 1, + ZB_APS_DELIVERY_BROADCAST = 2, + ZB_APS_DELIVERY_MULTICAST = 3, +} zb_aps_delivery_mode_e; + +typedef enum { + ZB_ZCL_FC_GLOBALLY_USED = (0 << 0), + ZB_APS_FC_CLUSTER_SPECIFIC = (1 << 0), +} zb_zcl_fc_type_e; + +typedef enum { + ZB_ZCL_CLIENT_TO_SERVER = (0 << 3), + ZB_ZCL_SERVER_TO_CLIENT = (1 << 3), +} zb_zcl_fc_direction_e; + +typedef enum { + ZB_ZCL_LEAVE_WELL_ALONE = (0 << 4), + ZB_ZCL_DISABLE_DEFAULT_RESPONSE = (1 << 4), +} zb_zcl_fc_disable_default_response_e; + +typedef enum { + ZB_ZCL_FC_NOT_MANUFACTURER = (0 << 2), + ZB_ZCL_FC_MANUFACTURER = (1 << 2), +} zb_zcl_fc_manufacturer_present_e; + +class Zigbee:public GDbus { + private: + public: + Zigbee(); + ~Zigbee(); + int zbl_enable(void); + int zbl_disable(void); + int zbl_is_enable(bool* state); + int zbl_hw_reset(void); + int zbl_coex_stop(void); + int zbl_form_network(void); + int zbl_disable_network(void); + int zbl_get_controller_mac_address(ieee_addr mac); + int zbl_get_network_info(void); + 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_api_get_node_type(ieee_addr eui64); + int zbl_get_all_device_info(void); + int zbl_coex_start(unsigned char channel); + 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(ieee_addr addr64, unsigned char request_type, unsigned char start_idx); + int zbl_ieee_addr_req(nwk_addr addr16); + int zbl_active_ep(nwk_addr addr16); + int zbl_simple_desc_req(nwk_addr addr16, unsigned char ep); + int zbl_match_desc_req(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); + int zbl_node_desc_req(nwk_addr addr16); + int zbl_power_desc_req(nwk_addr addr16); + int zbl_complex_desc_req(nwk_addr addr16); + int zbl_user_desc_req(nwk_addr addr16); + int zbl_user_desc_set(nwk_addr addr16, unsigned char len, unsigned char *user_desc); + int zbl_device_annce(nwk_addr addr16, ieee_addr addr64, unsigned char capability); + 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); + 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); + 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); + 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); + int zbl_mgmt_rtg_req(nwk_addr addr16, unsigned char start_idx); + int zbl_mgmt_bind_req(nwk_addr addr16, unsigned char start_idx); + int zbl_mgmt_leave_device(ieee_addr addr64, unsigned char remove_children, unsigned rejoin); + int zbl_mgmt_permit_joining_req(nwk_addr addr16, unsigned char duration, unsigned char tc_significance); + 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); + 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); + int zbl_send_to_local(unsigned short length, unsigned char *data); + int zbl_read_attr_req(unsigned short addr16, unsigned char dest_ep, + unsigned char zcl_frame_ctl, unsigned short cluster_id, unsigned short *attribute_ids, + int attribute_ids_len); + int zbl_discover_attr_req(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); + int zbl_discover_cmds_gen(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); + int zbl_discover_cmds_recv(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); + int zbl_discover_attr_ext(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); + int zbl_reset_alarm(nwk_addr addr16, unsigned char ep, unsigned char alarm_code, + unsigned short cluster_id); + int zbl_get_alarm(nwk_addr addr16, unsigned char ep); + int zbl_reset_all_alarm_log(nwk_addr addr16, unsigned char ep); + 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); + int zbl_reset_factory_default(nwk_addr addr16, unsigned char ep); + 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); + int zbl_add_group(nwk_addr addr16, unsigned char ep, unsigned short group_id, + const char *group_name); + int zbl_view_group(nwk_addr addr16, unsigned char ep, unsigned short group_id); + int zbl_group_get_group_membership(nwk_addr addr16, unsigned char ep, + unsigned char group_count, unsigned short *group_list); + int zbl_remove_group(nwk_addr addr16, unsigned char ep, unsigned short group_id); + 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); + 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); + 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); + 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); + int zbl_pollcontrol_set_short_poll_interval(nwk_addr addr16, unsigned char ep, + unsigned int new_short_poll_interval); + 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); + int zbl_view_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, unsigned char scene_id); + int zbl_remove_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, unsigned char scene_id); + int zbl_remove_all_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id); + int zbl_store_scene(nwk_addr addr16, unsigned char ep, unsigned short group_id, unsigned char scene_id); + 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); + int zbl_thermostat_adjust_setpoint(nwk_addr addr16, unsigned char ep, unsigned char mode, unsigned char amount); +}; +#endif /* __ZIGBEE_MANAGER_H__ */ diff --git a/zigbee-daemon/src/main.c b/zigbee-daemon/src/main.c index 78639c3..14439d3 100644 --- a/zigbee-daemon/src/main.c +++ b/zigbee-daemon/src/main.c @@ -34,6 +34,10 @@ /**< ZigBee Service */ ZigBeeService *zigbee_service; +#if (BUILD_GCOV != 0) +extern void __gcov_flush(void); +#endif + static gboolean _request_terminate(gpointer user_data) { NOTUSED(user_data); @@ -58,6 +62,10 @@ int main(int arg, char **argv) NOTUSED(arg); NOTUSED(argv); +#if (BUILD_GCOV != 0) + setenv("GCOV_PREFIX", "/tmp/", 1); +#endif + /* Create ZigBee service */ zigbee_service = service = zblib_service_new(); @@ -95,5 +103,9 @@ END: zblib_service_free(service); zigbee_service = NULL; +#if (BUILD_GCOV != 0) + __gcov_flush(); +#endif + return ret_code; } -- 2.7.4 From 743cabd1ac28eb19675c8d77b940ca4d15a5aacb Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Tue, 29 May 2018 19:51:58 +0900 Subject: [PATCH 11/16] Increase line & function coverage Sending dbus siganl is not included in line and function coverage, so add except uncovered lines. Change-Id: Id3f11ef6648f316ce2bfb42c89604c0a339b30e9 Signed-off-by: saerome.kim --- zigbee-daemon/src/main.c | 8 +++ .../src/zigbee_service_dbus_interface.c | 82 ++++++++++++++++++++-- .../src/zigbee_service_dbus_interface_custom.c | 4 ++ .../zigbee_service_dbus_interface_mfglib_control.c | 4 ++ .../src/zigbee_service_dbus_interface_service.c | 4 ++ .../src/zigbee_service_dbus_interface_zcl_alarm.c | 4 ++ .../src/zigbee_service_dbus_interface_zcl_basic.c | 4 ++ ...gbee_service_dbus_interface_zcl_color_control.c | 4 ++ .../zigbee_service_dbus_interface_zcl_door_lock.c | 4 ++ ...zigbee_service_dbus_interface_zcl_fan_control.c | 4 ++ ...bee_service_dbus_interface_zcl_global_control.c | 4 ++ .../src/zigbee_service_dbus_interface_zcl_group.c | 4 ++ .../zigbee_service_dbus_interface_zcl_ias_zone.c | 4 ++ .../zigbee_service_dbus_interface_zcl_identify.c | 4 ++ ...gbee_service_dbus_interface_zcl_level_control.c | 4 ++ .../src/zigbee_service_dbus_interface_zcl_on_off.c | 16 +++++ ...igbee_service_dbus_interface_zcl_poll_control.c | 4 ++ .../src/zigbee_service_dbus_interface_zcl_scene.c | 4 ++ .../zigbee_service_dbus_interface_zcl_thermostat.c | 4 ++ .../src/zigbee_service_dbus_interface_zdo_bind.c | 4 ++ ...zigbee_service_dbus_interface_zdo_dev_control.c | 4 ++ .../src/zigbee_service_interface.c | 6 ++ .../src/zigbee_service_interface_common.c | 2 + zigbee-daemon/zigbee-lib/include/zblib_common.h | 6 ++ .../zigbee-lib/src/drivers/zblib_driver_custom.c | 12 ++++ .../src/drivers/zblib_driver_mfglib_control.c | 10 +++ .../zigbee-lib/src/drivers/zblib_driver_service.c | 12 ++++ .../src/drivers/zblib_driver_zcl_alarm.c | 12 ++++ .../src/drivers/zblib_driver_zcl_basic.c | 12 ++++ .../src/drivers/zblib_driver_zcl_color_control.c | 12 ++++ .../src/drivers/zblib_driver_zcl_door_lock.c | 10 +++ .../src/drivers/zblib_driver_zcl_fan_control.c | 10 +++ .../src/drivers/zblib_driver_zcl_global_control.c | 12 ++++ .../src/drivers/zblib_driver_zcl_group.c | 13 +++- .../src/drivers/zblib_driver_zcl_ias_zone.c | 12 ++++ .../src/drivers/zblib_driver_zcl_identify.c | 12 ++++ .../src/drivers/zblib_driver_zcl_level_control.c | 12 ++++ .../src/drivers/zblib_driver_zcl_on_off.c | 12 ++++ .../src/drivers/zblib_driver_zcl_poll_control.c | 12 ++++ .../src/drivers/zblib_driver_zcl_scene.c | 12 ++++ .../src/drivers/zblib_driver_zcl_thermostat.c | 12 ++++ .../zigbee-lib/src/drivers/zblib_driver_zdo_bind.c | 12 ++++ .../src/drivers/zblib_driver_zdo_dev_control.c | 12 ++++ zigbee-daemon/zigbee-lib/src/zblib_driver.c | 6 ++ zigbee-daemon/zigbee-lib/src/zblib_log.c | 4 +- zigbee-daemon/zigbee-lib/src/zblib_plugin.c | 4 ++ zigbee-daemon/zigbee-lib/src/zblib_request.c | 6 +- zigbee-daemon/zigbee-lib/src/zblib_service.c | 50 +++++++++++-- .../zigbee-lib/src/zblib_service_interface.c | 2 + zigbee-daemon/zigbee-service/src/zigbee_service.c | 12 ++++ 50 files changed, 485 insertions(+), 14 deletions(-) mode change 100755 => 100644 zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c mode change 100755 => 100644 zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c diff --git a/zigbee-daemon/src/main.c b/zigbee-daemon/src/main.c index 14439d3..a09bd17 100644 --- a/zigbee-daemon/src/main.c +++ b/zigbee-daemon/src/main.c @@ -38,6 +38,7 @@ ZigBeeService *zigbee_service; extern void __gcov_flush(void); #endif +/* LCOV_EXCL_START */ static gboolean _request_terminate(gpointer user_data) { NOTUSED(user_data); @@ -46,6 +47,7 @@ static gboolean _request_terminate(gpointer user_data) return G_SOURCE_REMOVE; } +/* LCOV_EXCL_STOP */ int main(int arg, char **argv) { @@ -72,24 +74,30 @@ int main(int arg, char **argv) /* Initialize ZigBee service interface layer */ ret = zigbee_service_interface_init(service); if (G_UNLIKELY(FALSE == ret)) { + /* LCOV_EXCL_START */ Z_LOGE("zigbee_service_interface_init failed!"); goto END; + /* LCOV_EXCL_STOP */ } /* Initialize ZigBee service */ ret = zigbee_service_init(service); if (G_UNLIKELY(FALSE == ret)) { + /* LCOV_EXCL_START */ Z_LOGE("zigbee_service_init failed!"); /* Minimum mainloop time is required to notify the result */ g_timeout_add(100, _request_terminate, NULL); + /* LCOV_EXCL_STOP */ } /* Run ZigBee service */ Z_LOGI("service mainloop start"); ret = zblib_service_run(service); if (G_UNLIKELY(FALSE == ret)) { + /* LCOV_EXCL_START */ Z_LOGE("Run service failed!"); ret_code = EXIT_FAILURE; + /* LCOV_EXCL_STOP */ } END: diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c index af19f9f..b72c1e9 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c @@ -42,8 +42,10 @@ static void _notify_zigbee_state(ZigBeeServiceInterface *service_interface, ZigBeeService *service = zblib_service_interface_ref_service(service_interface); if (NULL == custom_data) { + /* LCOV_EXCL_START */ Z_LOGE("Unexpected invalid parameter !"); return; + /* LCOV_EXCL_STOP */ } if (result) { @@ -51,7 +53,7 @@ static void _notify_zigbee_state(ZigBeeServiceInterface *service_interface, zigbee_manager_emit_zigbee_state(custom_data->zigbee_mgr, result); } else { /* ZigBee state will be emitted on bus termination */ - zblib_service_exit(service); + zblib_service_exit(service); // LCOV_EXCL_LINE } } @@ -63,9 +65,11 @@ static gboolean on_manager_enable(ZigbeeManager *zigbee_mgr, ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface); if (NULL == custom_data) { + /* LCOV_EXCL_START */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); return TRUE; + /* LCOV_EXCL_STOP */ } zigbee_manager_complete_enable(zigbee_mgr, invocation); @@ -90,6 +94,7 @@ static gboolean on_manager_disable(ZigbeeManager *zigbee_mgr, return TRUE; } +/* LCOV_EXCL_START */ static gboolean on_manager_get_zigbee_state(ZigbeeManager *zigbee_mgr, GDBusMethodInvocation *invocation, gpointer user_data) { @@ -109,6 +114,7 @@ static gboolean on_manager_get_zigbee_state(ZigbeeManager *zigbee_mgr, return TRUE; } +/* LCOV_EXCL_STOP */ static void zigbee_service_dbus_interface_initialize_interfaces(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -180,8 +186,10 @@ static void zigbee_service_dbus_interface_noti_cb(ZigBeeServiceInterface *servic guint notification_id; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return; + /* LCOV_EXCL_STOP */ } /* Extract driver_type */ @@ -194,68 +202,90 @@ static void zigbee_service_dbus_interface_noti_cb(ZigBeeServiceInterface *servic switch (driver_type) { case ZBLIB_DRIVER_TYPE_ZCL_ALARM: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_alarm_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_CUSTOM: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_custom_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_DOOR_LOCK: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_door_lock_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_FAN_CONTROL: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_fan_control_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_LEVEL_CONTROL: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_level_control_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_mfglib_control_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_ON_OFF: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_on_off_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_SERVICE: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_service_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_THERMOSTAT: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_thermostat_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_BASIC: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_basic_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_GLOBAL_CONTROL: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_global_control_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; @@ -266,44 +296,58 @@ static void zigbee_service_dbus_interface_noti_cb(ZigBeeServiceInterface *servic break; case ZBLIB_DRIVER_TYPE_ZCL_IDENTIFY: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_identify_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_COLOR_CONTROL: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_color_control_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_GROUP: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_group_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_POLL_CONTROL: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_poll_control_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZCL_SCENE: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zcl_scene_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZDO_DEV_CONTROL: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zdo_dev_control_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; case ZBLIB_DRIVER_TYPE_ZDO_BIND: { + /* LCOV_EXCL_START */ zigbee_service_dbus_interface_zdo_bind_notification(service_interface, notification_id, noti_data, noti_data_len, noti_cb_data); + /* LCOV_EXCL_STOP */ } break; @@ -315,18 +359,19 @@ static void zigbee_service_dbus_interface_noti_cb(ZigBeeServiceInterface *servic Z_LOGD("Firmware update result : [%s]", ((*rsp) ? "Succeed" : "Failed")); _notify_zigbee_state(service_interface, *rsp); } else - Z_LOGE("Unhandled notification id: [%d]", notification_id); + Z_LOGE("Unhandled notification id: [%d]", notification_id); // LCOV_EXCL_LINE } break; case ZBLIB_DRIVER_TYPE_NONE: /* Fall through */ default: { - Z_LOGE("Unhandled driver type: [%d]", driver_type); + Z_LOGE("Unhandled driver type: [%d]", driver_type); // LCOV_EXCL_LINE } - break; + break; // LCOV_EXCL_LINE } } +/* LCOV_EXCL_START */ static void zigbee_on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data) { @@ -342,6 +387,7 @@ static void zigbee_on_name_lost(GDBusConnection *connection, /* Bus name is 'lost' */ custom_data->name_acquired = FALSE; } +/* LCOV_EXCL_STOP */ static void zigbee_on_name_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data) @@ -373,20 +419,26 @@ static void zigbee_on_bus_acquired(GDBusConnection *connection, Z_LOGI("'%s' - [BUS Acquired]", name); if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL!"); return; + /* LCOV_EXCL_STOP */ } service = zblib_service_interface_ref_service(service_interface); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("service is NULL!"); return; + /* LCOV_EXCL_STOP */ } custom_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface); if (NULL == custom_data) { + /* LCOV_EXCL_START */ Z_LOGE("D-BUS service interface custom_data is NULL!"); return; + /* LCOV_EXCL_STOP */ } /* @@ -436,8 +488,10 @@ static void zigbee_on_bus_acquired(GDBusConnection *connection, */ zigbee_object = g_hash_table_lookup(custom_data->objects, path); if (zigbee_object) { + /* LCOV_EXCL_START */ Z_LOGW("ZigBee D-BUS interface object already created (object: %p)", zigbee_object); goto OUT; + /* LCOV_EXCL_STOP */ } /* @@ -490,8 +544,10 @@ gboolean zigbee_service_dbus_interface_init(ZigBeeService *service) gboolean ret; if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("service is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } /* @@ -500,9 +556,11 @@ gboolean zigbee_service_dbus_interface_init(ZigBeeService *service) service_interface = zblib_service_interface_new(service, ZIGBEE_DBUS_SERVICE_INTERFACE_NAME); if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("Create D-BUS service interface failed!"); return FALSE; + /* LCOV_EXCL_STOP */ } /* @@ -511,9 +569,11 @@ gboolean zigbee_service_dbus_interface_init(ZigBeeService *service) ret = zblib_service_interface_set_noti_cb(service_interface, zigbee_service_dbus_interface_noti_cb, NULL); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("Set service interface notification callback failed!"); goto EXIT; + /* LCOV_EXCL_STOP */ } /* @@ -522,9 +582,11 @@ gboolean zigbee_service_dbus_interface_init(ZigBeeService *service) ret = zblib_service_add_service_interface(service, service_interface); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("Add D-BUS service interface failed!"); goto EXIT; + /* LCOV_EXCL_STOP */ } /* @@ -538,9 +600,11 @@ gboolean zigbee_service_dbus_interface_init(ZigBeeService *service) ret = zblib_service_interface_link_user_data(service_interface, interface_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("Link D-BUS service interface data failed!"); goto EXIT; + /* LCOV_EXCL_STOP */ } /* HASH table for maintaining 'objects' list */ @@ -570,6 +634,7 @@ gboolean zigbee_service_dbus_interface_init(ZigBeeService *service) return TRUE; EXIT: + /* LCOV_EXCL_START */ g_free(interface_data); /* @@ -587,6 +652,7 @@ EXIT: service_interface); return FALSE; + /* LCOV_EXCL_STOP */ } /**< Zigbee service dbus interface de-initialization */ @@ -597,23 +663,29 @@ void zigbee_service_dbus_interface_deinit(ZigBeeService *service) gboolean ret; if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("service is NULL"); return; + /* LCOV_EXCL_STOP */ } service_interface = zblib_service_ref_service_interface(service, ZIGBEE_DBUS_SERVICE_INTERFACE_NAME); if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("D-BUS service interface not found!"); return; + /* LCOV_EXCL_STOP */ } interface_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface); if (NULL == interface_data) { + /* LCOV_EXCL_START */ Z_LOGE("D-BUS interface data not found!"); goto EXIT; + /* LCOV_EXCL_STOP */ } /* Emit zigbee_state - disabled */ @@ -648,7 +720,7 @@ EXIT: ret = zblib_service_remove_service_interface(service, service_interface); if (FALSE == ret) - Z_LOGE("Remove service interface failed!"); + Z_LOGE("Remove service interface failed!"); // LCOV_EXCL_LINE /* * Free Service interface object diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_custom.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_custom.c index 3389215..ff08ffa 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_custom.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_custom.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_custom( ZigBeeServiceInterface *service_interface) { @@ -451,6 +452,7 @@ void zigbee_service_dbus_interface_custom_notification(ZigBeeServiceInterface *s /* ZigbeeCustom should be dereferenced */ g_object_unref(custom_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_custom_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -458,8 +460,10 @@ gboolean zigbee_service_dbus_interface_custom_init(ZigBeeServiceInterface *servi ZigbeeCustom *custom_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } custom_object = zigbee_custom_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_mfglib_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_mfglib_control.c index bf5becf..6078ff7 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_mfglib_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_mfglib_control.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void on_mfglib_control_start_resp(ZigBeeServiceInterface *service_interface, guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data) { @@ -1258,6 +1259,7 @@ void zigbee_service_dbus_interface_mfglib_control_notification(ZigBeeServiceInte NOT_USED(noti_data_len); NOT_USED(noti_cb_data); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_mfglib_control_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -1265,8 +1267,10 @@ gboolean zigbee_service_dbus_interface_mfglib_control_init(ZigBeeServiceInterfac ZigbeeMfglib_control *mfglib_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } mfglib_control_object = zigbee_mfglib_control_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c index d04136d..b647843 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_service(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; @@ -1336,6 +1337,7 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface * /* ZigbeeService should be dereferenced */ g_object_unref(service_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -1343,8 +1345,10 @@ gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *serv ZigbeeService *service_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } service_object = zigbee_service_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_alarm.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_alarm.c index 787a40c..1d46eb5 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_alarm.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_alarm.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_alarm(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; @@ -609,6 +610,7 @@ void zigbee_service_dbus_interface_zcl_alarm_notification(ZigBeeServiceInterface /* ZigbeeZcl_alarm should be dereferenced */ g_object_unref(alarm_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_alarm_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -616,8 +618,10 @@ gboolean zigbee_service_dbus_interface_zcl_alarm_init(ZigBeeServiceInterface *se ZigbeeZcl_alarm *alarm_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } alarm_object = zigbee_zcl_alarm_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_basic.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_basic.c index 2512877..39ab185 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_basic.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_basic.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_basic(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; @@ -153,6 +154,7 @@ void zigbee_service_dbus_interface_zcl_basic_notification(ZigBeeServiceInterface /* ZigbeeZcl_basic should be dereferenced */ g_object_unref(basic_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_basic_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -160,8 +162,10 @@ gboolean zigbee_service_dbus_interface_zcl_basic_init(ZigBeeServiceInterface *se ZigbeeZcl_basic *zclbasic_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zclbasic_control_object = zigbee_zcl_basic_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_color_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_color_control.c index 6a5b4a5..cfac230 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_color_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_color_control.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_color_control( ZigBeeServiceInterface *service_interface) { @@ -1050,6 +1051,7 @@ void zigbee_service_dbus_interface_zcl_color_control_notification(ZigBeeServiceI /* ZigbeeZcl_color_control should be dereferenced */ g_object_unref(color_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_color_control_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -1057,8 +1059,10 @@ gboolean zigbee_service_dbus_interface_zcl_color_control_init(ZigBeeServiceInter ZigbeeZcl_color_control *zcl_color_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zcl_color_object = zigbee_zcl_color_control_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_door_lock.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_door_lock.c index ee2d25b..662ff1c 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_door_lock.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_door_lock.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void on_door_lock_subscribe_lock_event_resp(ZigBeeServiceInterface *service_interface, guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data) { @@ -337,6 +338,7 @@ void zigbee_service_dbus_interface_zcl_door_lock_notification(ZigBeeServiceInter NOT_USED(noti_data_len); NOT_USED(noti_cb_data); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_door_lock_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -344,8 +346,10 @@ gboolean zigbee_service_dbus_interface_zcl_door_lock_init(ZigBeeServiceInterface ZigbeeZcl_door_lock *door_lock_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } door_lock_object = zigbee_zcl_door_lock_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_fan_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_fan_control.c index 3aea00a..486fe2e 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_fan_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_fan_control.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void on_fan_control_set_fan_mode_resp(ZigBeeServiceInterface *service_interface, guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data) { @@ -327,6 +328,7 @@ void zigbee_service_dbus_interface_zcl_fan_control_notification(ZigBeeServiceInt NOT_USED(noti_data_len); NOT_USED(noti_cb_data); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_fan_control_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -334,8 +336,10 @@ gboolean zigbee_service_dbus_interface_zcl_fan_control_init(ZigBeeServiceInterfa ZigbeeZcl_fan_control *fan_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } fan_control_object = zigbee_zcl_fan_control_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c old mode 100755 new mode 100644 index 91973d5..445d97c --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_global_control.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_global_control(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; @@ -1728,6 +1729,7 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService /* ZigbeeZcl_global_control should be dereferenced */ g_object_unref(global_control_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_global_control_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -1735,8 +1737,10 @@ gboolean zigbee_service_dbus_interface_zcl_global_control_init(ZigBeeServiceInte ZigbeeZcl_global_control *zclglobal_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zclglobal_control_object = zigbee_zcl_global_control_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_group.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_group.c index c449a5f..a13333e 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_group.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_group.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_group(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; @@ -668,6 +669,7 @@ void zigbee_service_dbus_interface_zcl_group_notification(ZigBeeServiceInterface /* ZigbeeZcl_group should be dereferenced */ g_object_unref(group_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_group_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -675,8 +677,10 @@ gboolean zigbee_service_dbus_interface_zcl_group_init(ZigBeeServiceInterface *se ZigbeeZcl_group *zcl_group_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zcl_group_object = zigbee_zcl_group_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_ias_zone.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_ias_zone.c index 5f67aee..e07be5a 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_ias_zone.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_ias_zone.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_ias_zone(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; @@ -176,6 +177,7 @@ void zigbee_service_dbus_interface_zcl_ias_zone_notification(ZigBeeServiceInterf /* ZigbeeZcl_ias_zone should be dereferenced */ g_object_unref(ias_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_ias_zone_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -183,8 +185,10 @@ gboolean zigbee_service_dbus_interface_zcl_ias_zone_init(ZigBeeServiceInterface ZigbeeZcl_ias_zone *zclias_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zclias_control_object = zigbee_zcl_ias_zone_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_identify.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_identify.c index b6e2d45..334802b 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_identify.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_identify.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_identify(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; @@ -246,6 +247,7 @@ void zigbee_service_dbus_interface_zcl_identify_notification(ZigBeeServiceInterf /* ZigbeeZcl_identify should be dereferenced */ g_object_unref(id_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_identify_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -253,8 +255,10 @@ gboolean zigbee_service_dbus_interface_zcl_identify_init(ZigBeeServiceInterface ZigbeeZcl_identify *zclidentify_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zclidentify_control_object = zigbee_zcl_identify_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_level_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_level_control.c index 22ba279..d7b4ea8 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_level_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_level_control.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_level_control( ZigBeeServiceInterface *service_interface) { @@ -685,6 +686,7 @@ void zigbee_service_dbus_interface_zcl_level_control_notification(ZigBeeServiceI /* ZigbeeZcl_level_control should be dereferenced */ g_object_unref(level_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_level_control_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -692,8 +694,10 @@ gboolean zigbee_service_dbus_interface_zcl_level_control_init(ZigBeeServiceInter ZigbeeZcl_level_control *level_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } level_control_object = zigbee_zcl_level_control_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_on_off.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_on_off.c index 396fed3..3772c82 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_on_off.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_on_off.c @@ -20,12 +20,15 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_on_off(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; ZigbeeCustomData_t *custom_data = NULL; ZigbeeZcl_on_off *on_off_object = NULL; + Z_LOGE("KSR 2"); + custom_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface); if (NULL == custom_data) { Z_LOGE("D-BUS service interface custom_data is NULL!"); @@ -56,6 +59,8 @@ static void on_on_off_set_on_off_resp(ZigBeeServiceInterface *service_interface, NOT_USED(service_interface); NOT_USED(request_id); + Z_LOGE("KSR 1"); + if (NULL == resp_data || 0 == resp_data_len) { Z_LOGE("resp_data is null"); g_free(cb_data); @@ -89,6 +94,8 @@ static gboolean on_on_off_set_on_off(ZigbeeZcl_on_off *on_off_object, memset(&req, 0x0, sizeof(ZigbeeZclOnOffSetOnOff_t)); + Z_LOGE("KSR 3"); + /* Update request structure */ req.node_id = node_id; req.endpoint = endpoint; @@ -141,6 +148,8 @@ static void on_on_off_get_on_off_state_resp(ZigBeeServiceInterface *service_inte NOT_USED(service_interface); NOT_USED(request_id); + Z_LOGE("KSR 4"); + if (NULL == resp_data || 0 == resp_data_len) { Z_LOGE("resp_data is null"); g_free(cb_data); @@ -171,6 +180,8 @@ static gboolean on_on_off_get_on_off_state(ZigbeeZcl_on_off *on_off_object, gboolean ret; + Z_LOGE("KSR 5"); + memset(&req, 0x0, sizeof(ZigbeeZclOnOffGetOnOffState_t)); /* Update request structure */ @@ -218,6 +229,8 @@ void zigbee_service_dbus_interface_zcl_on_off_notification(ZigBeeServiceInterfac zblib_check_null_ret("service_interface", service_interface); + Z_LOGE("KSR 6"); + if (NULL == noti_data || 0 == noti_data_len) { Z_LOGE("noti_data is NULL"); return; @@ -246,6 +259,7 @@ void zigbee_service_dbus_interface_zcl_on_off_notification(ZigBeeServiceInterfac /* ZigbeeZcl_on_off should be dereferenced */ g_object_unref(on_off_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_on_off_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -253,8 +267,10 @@ gboolean zigbee_service_dbus_interface_zcl_on_off_init(ZigBeeServiceInterface *s ZigbeeZcl_on_off *on_off_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } on_off_object = zigbee_zcl_on_off_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_poll_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_poll_control.c index f787200..9c822c9 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_poll_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_poll_control.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_poll_control( ZigBeeServiceInterface *service_interface) { @@ -419,6 +420,7 @@ void zigbee_service_dbus_interface_zcl_poll_control_notification(ZigBeeServiceIn /* ZigbeeZcl_poll_control should be dereferenced */ g_object_unref(poll_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_poll_control_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -426,8 +428,10 @@ gboolean zigbee_service_dbus_interface_zcl_poll_control_init(ZigBeeServiceInterf ZigbeeZcl_poll_control *zcl_poll_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zcl_poll_control_object = zigbee_zcl_poll_control_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_scene.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_scene.c index 655e1c7..549cbbc 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_scene.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_scene.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_scene( ZigBeeServiceInterface *service_interface) { @@ -794,6 +795,7 @@ void zigbee_service_dbus_interface_zcl_scene_notification(ZigBeeServiceInterface /* ZigbeeZcl_scene should be dereferenced */ g_object_unref(scene_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_scene_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -801,8 +803,10 @@ gboolean zigbee_service_dbus_interface_zcl_scene_init(ZigBeeServiceInterface *se ZigbeeZcl_scene *zcl_scene_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zcl_scene_object = zigbee_zcl_scene_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_thermostat.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_thermostat.c index 08a5b97..06351ec 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_thermostat.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zcl_thermostat.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zcl_thermostat( ZigBeeServiceInterface *service_interface) { @@ -548,6 +549,7 @@ void zigbee_service_dbus_interface_zcl_thermostat_notification(ZigBeeServiceInte g_object_unref(thermo_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zcl_thermostat_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -555,8 +557,10 @@ gboolean zigbee_service_dbus_interface_zcl_thermostat_init(ZigBeeServiceInterfac ZigbeeZcl_thermostat *thermostat_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } thermostat_object = zigbee_zcl_thermostat_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_bind.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_bind.c index 46e3fcd..e3a8c26 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_bind.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_bind.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zdo_bind( ZigBeeServiceInterface *service_interface) { @@ -304,6 +305,7 @@ void zigbee_service_dbus_interface_zdo_bind_notification(ZigBeeServiceInterface /* ZigbeeZdo_bind should be dereferenced */ g_object_unref(bind_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zdo_bind_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -311,8 +313,10 @@ gboolean zigbee_service_dbus_interface_zdo_bind_init(ZigBeeServiceInterface *ser ZigbeeZdo_bind *zdo_bind_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zdo_bind_object = zigbee_zdo_bind_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c old mode 100755 new mode 100644 index 30582dd..12da45a --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_zdo_dev_control.c @@ -20,6 +20,7 @@ #include +/* LCOV_EXCL_START */ static void *_service_interface_ref_zigbee_zdo_dev_control(ZigBeeServiceInterface *service_interface) { ZigbeeObjectSkeleton *zigbee_object = NULL; @@ -1976,6 +1977,7 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt /* ZigbeeZdo_dev_control should be dereferenced */ g_object_unref(dev_control_object); } +/* LCOV_EXCL_STOP */ gboolean zigbee_service_dbus_interface_zdo_dev_control_init(ZigBeeServiceInterface *service_interface, ZigbeeObjectSkeleton *zigbee_object) @@ -1983,8 +1985,10 @@ gboolean zigbee_service_dbus_interface_zdo_dev_control_init(ZigBeeServiceInterfa ZigbeeZdo_dev_control *zdodev_control_object; if (NULL == service_interface) { + /* LCOV_EXCL_START */ Z_LOGE("service_interface is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } zdodev_control_object = zigbee_zdo_dev_control_skeleton_new(); diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_interface.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_interface.c index 9f8c007..4e37323 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_interface.c @@ -34,15 +34,19 @@ gboolean zigbee_service_interface_init(ZigBeeService *service) gboolean ret; if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("service is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } /* Initialize dbus interface */ ret = zigbee_service_dbus_interface_init(service); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zigbee_service_dbus_interface_init failed!!!"); return FALSE; + /* LCOV_EXCL_STOP */ } return TRUE; @@ -52,8 +56,10 @@ gboolean zigbee_service_interface_init(ZigBeeService *service) void zigbee_service_interface_deinit(ZigBeeService *service) { if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("service is NULL"); return; + /* LCOV_EXCL_STOP */ } /* De-initialize dbus interface */ diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.c b/zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.c index ce4fe8f..1750354 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.c @@ -38,6 +38,7 @@ struct zigbee_service_interface_resp_cb_type { char user_data[0]; /* Additional user data base pointer */ }; +/* LCOV_EXCL_START */ ZigbeeServiceInterfaceRespCbData_t * zigbee_service_dbus_interface_create_resp_cb_data(void *interface_object, GDBusMethodInvocation *invocation, @@ -116,3 +117,4 @@ gboolean zigbee_service_dbus_interface_dispatch_request(ZigBeeServiceInterface * return TRUE; } +/* LCOV_EXCL_STOP */ diff --git a/zigbee-daemon/zigbee-lib/include/zblib_common.h b/zigbee-daemon/zigbee-lib/include/zblib_common.h index 0f46d98..9ef55e2 100644 --- a/zigbee-daemon/zigbee-lib/include/zblib_common.h +++ b/zigbee-daemon/zigbee-lib/include/zblib_common.h @@ -22,25 +22,31 @@ #include #define zblib_check_null_ret_error(name, value, error) do { \ + /* LCOV_EXCL_START */ \ if (G_UNLIKELY(NULL == (value))) { \ Z_LOGE("%s is NULL", name); \ return error; \ } \ + /* LCOV_EXCL_STOP */ \ } while (FALSE) #define zblib_check_null_ret(name, value) do { \ + /* LCOV_EXCL_START */ \ if (G_UNLIKELY(NULL == (value))) { \ Z_LOGE("%s is NULL", name); \ return; \ } \ + /* LCOV_EXCL_STOP */ \ } while (FALSE) #define zblib_check_null_free_and_ret(name, value, data) do { \ + /* LCOV_EXCL_START */ \ if (G_UNLIKELY(NULL == (value))) { \ Z_LOGE("%s is NULL", name); \ g_free(data); \ return; \ } \ + /* LCOV_EXCL_STOP */ \ } while (FALSE) #endif /* __ZIGBEE_LIB_COMMON_H__ */ diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_custom.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_custom.c index 0271352..72a5a48 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_custom.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_custom.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverCustomOps_t *ops; /**< Operations */ } ZblibDriverCustomPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_custom_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -87,6 +88,7 @@ static gboolean __zblib_driver_custom_dispatcher(ZigBeeDriver *driver, guint req return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_custom_free_hook(ZigBeeDriver *driver) { @@ -126,6 +128,7 @@ ZigBeeDriver *zblib_driver_custom_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -133,12 +136,14 @@ ZigBeeDriver *zblib_driver_custom_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -146,11 +151,13 @@ ZigBeeDriver *zblib_driver_custom_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_custom_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -158,11 +165,13 @@ ZigBeeDriver *zblib_driver_custom_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_custom_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -170,11 +179,13 @@ ZigBeeDriver *zblib_driver_custom_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_custom_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -182,3 +193,4 @@ void zblib_driver_custom_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_mfglib_control.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_mfglib_control.c index 95cf751..981dd43 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_mfglib_control.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_mfglib_control.c @@ -27,6 +27,7 @@ typedef struct { ZblibDriverMfglibControlOps_t *ops; /**< Operations */ } ZblibDriverMfglibControlPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_mfglib_control_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -198,6 +199,7 @@ static gboolean __zblib_driver_mfglib_control_dispatcher(ZigBeeDriver *driver, g return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_mfglib_control_free_hook(ZigBeeDriver *driver) { @@ -236,6 +238,7 @@ ZigBeeDriver *zblib_driver_mfglib_control_new(ZigBeePlugin *plugin, /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -243,11 +246,13 @@ ZigBeeDriver *zblib_driver_mfglib_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_mfglib_control_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -255,11 +260,13 @@ ZigBeeDriver *zblib_driver_mfglib_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_mfglib_control_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -267,11 +274,13 @@ ZigBeeDriver *zblib_driver_mfglib_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_mfglib_control_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -279,3 +288,4 @@ void zblib_driver_mfglib_control_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_service.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_service.c index 1659dc2..d5d2884 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_service.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_service.c @@ -29,6 +29,7 @@ typedef struct { ZblibDriverServiceOps_t *ops; /**< Operations */ } ZblibDriverServicePrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_service_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -176,6 +177,7 @@ static gboolean __zblib_driver_service_dispatcher(ZigBeeDriver *driver, guint re return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_service_free_hook(ZigBeeDriver *driver) { @@ -215,6 +217,7 @@ ZigBeeDriver *zblib_driver_service_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -222,12 +225,14 @@ ZigBeeDriver *zblib_driver_service_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -235,11 +240,13 @@ ZigBeeDriver *zblib_driver_service_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_service_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -247,11 +254,13 @@ ZigBeeDriver *zblib_driver_service_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_service_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -259,11 +268,13 @@ ZigBeeDriver *zblib_driver_service_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_START */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_service_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -271,3 +282,4 @@ void zblib_driver_service_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_alarm.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_alarm.c index e558666..66a0f7a 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_alarm.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_alarm.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclAlarmOps_t *ops; /**< Operations */ } ZblibDriverZclAlarmPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_alarm_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -111,6 +112,7 @@ static gboolean __zblib_driver_alarm_dispatcher(ZigBeeDriver *driver, guint requ return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_alarm_free_hook(ZigBeeDriver *driver) { @@ -150,6 +152,7 @@ ZigBeeDriver *zblib_driver_zcl_alarm_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -157,12 +160,14 @@ ZigBeeDriver *zblib_driver_zcl_alarm_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -170,11 +175,13 @@ ZigBeeDriver *zblib_driver_zcl_alarm_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_alarm_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -182,11 +189,13 @@ ZigBeeDriver *zblib_driver_zcl_alarm_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_alarm_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -194,11 +203,13 @@ ZigBeeDriver *zblib_driver_zcl_alarm_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_alarm_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -206,3 +217,4 @@ void zblib_driver_zcl_alarm_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_basic.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_basic.c index 1870773..7996a2e 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_basic.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_basic.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclBasicOps_t *ops; /**< Operations */ } ZblibDriverZclBasicPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_basic_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -71,6 +72,7 @@ static gboolean __zblib_driver_zcl_basic_dispatcher(ZigBeeDriver *driver, guint return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_basic_free_hook(ZigBeeDriver *driver) { @@ -110,6 +112,7 @@ ZigBeeDriver *zblib_driver_zcl_basic_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -117,12 +120,14 @@ ZigBeeDriver *zblib_driver_zcl_basic_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -130,11 +135,13 @@ ZigBeeDriver *zblib_driver_zcl_basic_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_basic_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -142,11 +149,13 @@ ZigBeeDriver *zblib_driver_zcl_basic_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_basic_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -154,11 +163,13 @@ ZigBeeDriver *zblib_driver_zcl_basic_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_basic_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -166,3 +177,4 @@ void zblib_driver_zcl_basic_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_color_control.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_color_control.c index 2350086..95fa953 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_color_control.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_color_control.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclColorControlOps_t *ops; /**< Operations */ } ZblibDriverZclColorControlPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_color_control_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -151,6 +152,7 @@ static gboolean __zblib_driver_zcl_color_control_dispatcher(ZigBeeDriver *driver return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_color_control_free_hook(ZigBeeDriver *driver) { @@ -190,6 +192,7 @@ ZigBeeDriver *zblib_driver_zcl_color_control_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -197,12 +200,14 @@ ZigBeeDriver *zblib_driver_zcl_color_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -210,11 +215,13 @@ ZigBeeDriver *zblib_driver_zcl_color_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_color_control_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -222,11 +229,13 @@ ZigBeeDriver *zblib_driver_zcl_color_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_color_control_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -234,11 +243,13 @@ ZigBeeDriver *zblib_driver_zcl_color_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_color_control_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -246,3 +257,4 @@ void zblib_driver_zcl_color_control_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_door_lock.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_door_lock.c index ce13d03..0daf28f 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_door_lock.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_door_lock.c @@ -27,6 +27,7 @@ typedef struct { ZblibDriverZclDoorLockOps_t *ops; /**< Operations */ } ZblibDriverZclDoorLockPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_door_lock_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -93,6 +94,7 @@ static gboolean __zblib_driver_zcl_door_lock_dispatcher(ZigBeeDriver *driver, gu return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_door_lock_free_hook(ZigBeeDriver *driver) { @@ -131,6 +133,7 @@ ZigBeeDriver *zblib_driver_zcl_door_lock_new(ZigBeePlugin *plugin, /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -138,11 +141,13 @@ ZigBeeDriver *zblib_driver_zcl_door_lock_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_door_lock_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -150,11 +155,13 @@ ZigBeeDriver *zblib_driver_zcl_door_lock_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_door_lock_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -162,11 +169,13 @@ ZigBeeDriver *zblib_driver_zcl_door_lock_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_door_lock_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -174,3 +183,4 @@ void zblib_driver_zcl_door_lock_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_fan_control.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_fan_control.c index 4db82dd..30cdcd8 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_fan_control.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_fan_control.c @@ -27,6 +27,7 @@ typedef struct { ZblibDriverZclFanControlOps_t *ops; /**< Operations */ } ZblibDriverZclFanControlPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_fan_control_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -94,6 +95,7 @@ static gboolean __zblib_driver_zcl_fan_control_dispatcher(ZigBeeDriver *driver, return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_fan_control_free_hook(ZigBeeDriver *driver) { @@ -132,6 +134,7 @@ ZigBeeDriver *zblib_driver_zcl_fan_control_new(ZigBeePlugin *plugin, /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -139,11 +142,13 @@ ZigBeeDriver *zblib_driver_zcl_fan_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_fan_control_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -151,11 +156,13 @@ ZigBeeDriver *zblib_driver_zcl_fan_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_fan_control_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -163,11 +170,13 @@ ZigBeeDriver *zblib_driver_zcl_fan_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_fan_control_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -175,3 +184,4 @@ void zblib_driver_zcl_fan_control_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_global_control.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_global_control.c index e4e186a..0f34d93 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_global_control.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_global_control.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclGlobalControlOps_t *ops; /**< Operations */ } ZblibDriverZclglobalControlPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_global_control_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -159,6 +160,7 @@ static gboolean __zblib_driver_zcl_global_control_dispatcher(ZigBeeDriver *drive return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_global_control_free_hook(ZigBeeDriver *driver) { @@ -198,6 +200,7 @@ ZigBeeDriver *zblib_driver_zcl_global_control_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -205,12 +208,14 @@ ZigBeeDriver *zblib_driver_zcl_global_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -218,11 +223,13 @@ ZigBeeDriver *zblib_driver_zcl_global_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_global_control_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -230,11 +237,13 @@ ZigBeeDriver *zblib_driver_zcl_global_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_global_control_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -242,11 +251,13 @@ ZigBeeDriver *zblib_driver_zcl_global_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_global_control_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -254,3 +265,4 @@ void zblib_driver_zcl_global_control_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_group.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_group.c index 5d6da34..50ed7aa 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_group.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_group.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclGroupOps_t *ops; /**< Operations */ } ZblibDriverZclGroupPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_group_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -111,6 +112,7 @@ static gboolean __zblib_driver_zcl_group_dispatcher(ZigBeeDriver *driver, guint return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_group_free_hook(ZigBeeDriver *driver) { @@ -150,6 +152,7 @@ ZigBeeDriver *zblib_driver_zcl_group_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -157,12 +160,14 @@ ZigBeeDriver *zblib_driver_zcl_group_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -170,11 +175,13 @@ ZigBeeDriver *zblib_driver_zcl_group_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_group_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -182,11 +189,13 @@ ZigBeeDriver *zblib_driver_zcl_group_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_group_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -194,11 +203,12 @@ ZigBeeDriver *zblib_driver_zcl_group_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } - +/* LCOV_EXCL_START */ void zblib_driver_zcl_group_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -206,3 +216,4 @@ void zblib_driver_zcl_group_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_ias_zone.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_ias_zone.c index 90f6cab..922d67b 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_ias_zone.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_ias_zone.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclIasZoneOps_t *ops; /**< Operations */ } ZblibDriverZclIasZonePrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_ias_zone_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -71,6 +72,7 @@ static gboolean __zblib_driver_zcl_ias_zone_dispatcher(ZigBeeDriver *driver, gui return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_ias_zone_free_hook(ZigBeeDriver *driver) { @@ -110,6 +112,7 @@ ZigBeeDriver *zblib_driver_zcl_ias_zone_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -117,12 +120,14 @@ ZigBeeDriver *zblib_driver_zcl_ias_zone_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -130,11 +135,13 @@ ZigBeeDriver *zblib_driver_zcl_ias_zone_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_ias_zone_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -142,11 +149,13 @@ ZigBeeDriver *zblib_driver_zcl_ias_zone_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_ias_zone_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -154,11 +163,13 @@ ZigBeeDriver *zblib_driver_zcl_ias_zone_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_ias_zone_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -166,3 +177,4 @@ void zblib_driver_zcl_ias_zone_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_identify.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_identify.c index 5013b11..9d3e0ab 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_identify.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_identify.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclIdentifyOps_t *ops; /**< Operations */ } ZblibDriverZclIdentifyPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_identify_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -79,6 +80,7 @@ static gboolean __zblib_driver_zcl_identify_dispatcher(ZigBeeDriver *driver, gui return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_identify_free_hook(ZigBeeDriver *driver) { @@ -118,6 +120,7 @@ ZigBeeDriver *zblib_driver_zcl_identify_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -125,12 +128,14 @@ ZigBeeDriver *zblib_driver_zcl_identify_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -138,11 +143,13 @@ ZigBeeDriver *zblib_driver_zcl_identify_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_identify_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -150,11 +157,13 @@ ZigBeeDriver *zblib_driver_zcl_identify_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_identify_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -162,11 +171,13 @@ ZigBeeDriver *zblib_driver_zcl_identify_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_identify_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -174,3 +185,4 @@ void zblib_driver_zcl_identify_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_level_control.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_level_control.c index 1369cac..32957bc 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_level_control.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_level_control.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclLevelControlOps_t *ops; /**< Operations */ } ZblibDriverZclLevelControlPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_level_control_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -119,6 +120,7 @@ static gboolean __zblib_driver_zcl_level_control_dispatcher(ZigBeeDriver *driver return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_level_control_free_hook(ZigBeeDriver *driver) { @@ -158,6 +160,7 @@ ZigBeeDriver *zblib_driver_zcl_level_control_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -165,12 +168,14 @@ ZigBeeDriver *zblib_driver_zcl_level_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -178,11 +183,13 @@ ZigBeeDriver *zblib_driver_zcl_level_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_level_control_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -190,11 +197,13 @@ ZigBeeDriver *zblib_driver_zcl_level_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_level_control_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -202,11 +211,13 @@ ZigBeeDriver *zblib_driver_zcl_level_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_level_control_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -214,3 +225,4 @@ void zblib_driver_zcl_level_control_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_on_off.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_on_off.c index d2098bd..4e0fb3a 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_on_off.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_on_off.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclOnOffOps_t *ops; /**< Operations */ } ZblibDriverZclOnOffPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_on_off_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -79,6 +80,7 @@ static gboolean __zblib_driver_zcl_on_off_dispatcher(ZigBeeDriver *driver, guint return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_on_off_free_hook(ZigBeeDriver *driver) { @@ -118,6 +120,7 @@ ZigBeeDriver *zblib_driver_zcl_on_off_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -125,12 +128,14 @@ ZigBeeDriver *zblib_driver_zcl_on_off_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -138,11 +143,13 @@ ZigBeeDriver *zblib_driver_zcl_on_off_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_on_off_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -150,11 +157,13 @@ ZigBeeDriver *zblib_driver_zcl_on_off_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_on_off_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -162,11 +171,13 @@ ZigBeeDriver *zblib_driver_zcl_on_off_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_on_off_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -174,3 +185,4 @@ void zblib_driver_zcl_on_off_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_poll_control.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_poll_control.c index 4d964bd..5f080e1 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_poll_control.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_poll_control.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclPollControlOps_t *ops; /**< Operations */ } ZblibDriverZclPollControlPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_poll_control_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -95,6 +96,7 @@ static gboolean __zblib_driver_zcl_poll_control_dispatcher(ZigBeeDriver *driver, return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_poll_control_free_hook(ZigBeeDriver *driver) { @@ -134,6 +136,7 @@ ZigBeeDriver *zblib_driver_zcl_poll_control_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -141,12 +144,14 @@ ZigBeeDriver *zblib_driver_zcl_poll_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -154,11 +159,13 @@ ZigBeeDriver *zblib_driver_zcl_poll_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_poll_control_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -166,11 +173,13 @@ ZigBeeDriver *zblib_driver_zcl_poll_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_poll_control_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -178,11 +187,13 @@ ZigBeeDriver *zblib_driver_zcl_poll_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_poll_control_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -190,3 +201,4 @@ void zblib_driver_zcl_poll_control_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_scene.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_scene.c index 254cac3..acfe5d4 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_scene.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_scene.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclSceneOps_t *ops; /**< Operations */ } ZblibDriverZclScenePrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_scene_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -119,6 +120,7 @@ static gboolean __zblib_driver_zcl_scene_dispatcher(ZigBeeDriver *driver, guint return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_scene_free_hook(ZigBeeDriver *driver) { @@ -158,6 +160,7 @@ ZigBeeDriver *zblib_driver_zcl_scene_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -165,12 +168,14 @@ ZigBeeDriver *zblib_driver_zcl_scene_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -178,11 +183,13 @@ ZigBeeDriver *zblib_driver_zcl_scene_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_scene_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -190,11 +197,13 @@ ZigBeeDriver *zblib_driver_zcl_scene_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_scene_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -202,11 +211,13 @@ ZigBeeDriver *zblib_driver_zcl_scene_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_scene_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -214,3 +225,4 @@ void zblib_driver_zcl_scene_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_thermostat.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_thermostat.c index 31f1060..2e53b60 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_thermostat.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zcl_thermostat.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZclThermostatOps_t *ops; /**< Operations */ } ZblibDriverZclThermostatPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zcl_thermostat_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -103,6 +104,7 @@ static gboolean __zblib_driver_zcl_thermostat_dispatcher(ZigBeeDriver *driver, g return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zcl_thermostat_free_hook(ZigBeeDriver *driver) { @@ -142,6 +144,7 @@ ZigBeeDriver *zblib_driver_zcl_thermostat_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -149,12 +152,14 @@ ZigBeeDriver *zblib_driver_zcl_thermostat_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -162,11 +167,13 @@ ZigBeeDriver *zblib_driver_zcl_thermostat_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zcl_thermostat_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -174,11 +181,13 @@ ZigBeeDriver *zblib_driver_zcl_thermostat_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zcl_thermostat_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -186,11 +195,13 @@ ZigBeeDriver *zblib_driver_zcl_thermostat_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zcl_thermostat_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -198,3 +209,4 @@ void zblib_driver_zcl_thermostat_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zdo_bind.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zdo_bind.c index c2f7385..325b1b4 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zdo_bind.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zdo_bind.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZdoBindOps_t *ops; /**< Operations */ } ZblibDriverZdoBindPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zdo_bind_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -79,6 +80,7 @@ static gboolean __zblib_driver_zdo_bind_dispatcher(ZigBeeDriver *driver, guint r return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zdo_bind_free_hook(ZigBeeDriver *driver) { @@ -118,6 +120,7 @@ ZigBeeDriver *zblib_driver_zdo_bind_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -125,12 +128,14 @@ ZigBeeDriver *zblib_driver_zdo_bind_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -138,11 +143,13 @@ ZigBeeDriver *zblib_driver_zdo_bind_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zdo_bind_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -150,11 +157,13 @@ ZigBeeDriver *zblib_driver_zdo_bind_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zdo_bind_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -162,11 +171,13 @@ ZigBeeDriver *zblib_driver_zdo_bind_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zdo_bind_free(ZigBeeDriver *driver) { if (NULL == driver) { @@ -177,3 +188,4 @@ void zblib_driver_zdo_bind_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zdo_dev_control.c b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zdo_dev_control.c index 93e56c9..6457377 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zdo_dev_control.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_zdo_dev_control.c @@ -28,6 +28,7 @@ typedef struct { ZblibDriverZdoDevControlOps_t *ops; /**< Operations */ } ZblibDriverZdoDevControlPrivData_t; +/* LCOV_EXCL_START */ static gboolean __zblib_driver_zdo_dev_control_dispatcher(ZigBeeDriver *driver, guint request_id) { ZigBeeService *service = NULL; @@ -199,6 +200,7 @@ static gboolean __zblib_driver_zdo_dev_control_dispatcher(ZigBeeDriver *driver, return ret; } +/* LCOV_EXCL_STOP */ static void __zblib_driver_zdo_dev_control_free_hook(ZigBeeDriver *driver) { @@ -238,6 +240,7 @@ ZigBeeDriver *zblib_driver_zdo_dev_control_new(ZigBeePlugin *plugin, /* Link service to driver */ service = zblib_plugin_ref_service(plugin); if (NULL == service) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_plugin_ref_service failed!"); /* Free allocated resources */ @@ -245,12 +248,14 @@ ZigBeeDriver *zblib_driver_zdo_dev_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } zblib_driver_link_service(driver, service); /* Link private data to driver */ ret = zblib_driver_link_object(driver, priv_data); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_link_object failed!"); /* Free allocated resources */ @@ -258,11 +263,13 @@ ZigBeeDriver *zblib_driver_zdo_dev_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set operations dispatcher function */ ret = zblib_driver_set_dispatcher(driver, __zblib_driver_zdo_dev_control_dispatcher); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_dispatcher failed!"); /* Free allocated resources */ @@ -270,11 +277,13 @@ ZigBeeDriver *zblib_driver_zdo_dev_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } /* Set free hook function */ ret = zblib_driver_set_free_hook(driver, __zblib_driver_zdo_dev_control_free_hook); if (FALSE == ret) { + /* LCOV_EXCL_START */ Z_LOGE("zblib_driver_set_free_hook failed!"); /* Free allocated resources */ @@ -282,11 +291,13 @@ ZigBeeDriver *zblib_driver_zdo_dev_control_new(ZigBeePlugin *plugin, g_free(driver); return NULL; + /* LCOV_EXCL_STOP */ } return driver; } +/* LCOV_EXCL_START */ void zblib_driver_zdo_dev_control_free(ZigBeeDriver *driver) { zblib_check_null_ret("driver", driver); @@ -294,3 +305,4 @@ void zblib_driver_zdo_dev_control_free(ZigBeeDriver *driver) /* Free driver */ zblib_driver_free(driver); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/zblib_driver.c b/zigbee-daemon/zigbee-lib/src/zblib_driver.c index e1d36cd..e2e8705 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_driver.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_driver.c @@ -70,12 +70,14 @@ void zblib_driver_free(ZigBeeDriver *driver) g_free(driver); } +/* LCOV_EXCL_START */ ZigBeeService *zblib_driver_ref_service(ZigBeeDriver *driver) { zblib_check_null_ret_error("driver", driver, NULL); return driver->service; } +/* LCOV_EXCL_STOP */ gboolean zblib_driver_link_service(ZigBeeDriver *driver, ZigBeeService *service) @@ -88,12 +90,14 @@ gboolean zblib_driver_link_service(ZigBeeDriver *driver, return TRUE; } +/* LCOV_EXCL_START */ ZigBeePlugin *zblib_driver_ref_plugin(ZigBeeDriver *driver) { zblib_check_null_ret_error("driver", driver, NULL); return driver->plugin; } +/* LCOV_EXCL_STOP */ gboolean zblib_driver_link_object(ZigBeeDriver *driver, gpointer object) @@ -140,6 +144,7 @@ ZblibDriverType_e zblib_driver_ref_driver_type(ZigBeeDriver *driver) return driver->driver_type; } +/* LCOV_EXCL_START */ gpointer zblib_driver_ref_request_data(ZigBeeDriver *driver, guint request_id) { @@ -201,3 +206,4 @@ void zblib_driver_send_notification(ZigBeeDriver *driver, zblib_plugin_send_notification(plugin, driver_noti_id, noti_data, noti_data_len); } +/* LCOV_EXCL_STOP */ \ No newline at end of file diff --git a/zigbee-daemon/zigbee-lib/src/zblib_log.c b/zigbee-daemon/zigbee-lib/src/zblib_log.c index 7585891..c120111 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_log.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_log.c @@ -58,13 +58,15 @@ void zblib_log(enum zblib_log_type type, enum zblib_log_priority priority, const int next = 0; FILE *fp = fopen("/proc/uptime", "r"); if (NULL == fp) { + /* LCOV_EXCL_START */ Z_LOGE("fopen() failed"); return; + /* LCOV_EXCL_STOP */ } if (fscanf(fp, "%f %f", &a, &b) != 1) next = snprintf(buf, BUFFER_SIZE, "[UPTIME] [Not Set] "); else - next = snprintf(buf, BUFFER_SIZE, "[UPTIME] %f ", a); + next = snprintf(buf, BUFFER_SIZE, "[UPTIME] %f ", a); // LCOV_EXCL_LINE fclose(fp); if (next < 0) return; diff --git a/zigbee-daemon/zigbee-lib/src/zblib_plugin.c b/zigbee-daemon/zigbee-lib/src/zblib_plugin.c index 48de467..5422fdf 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_plugin.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_plugin.c @@ -73,8 +73,10 @@ void zblib_plugin_free(ZigBeePlugin *plugin) if (NULL == driver) continue; + /* LCOV_EXCL_START */ zblib_driver_free(driver); list->data = NULL; + /* LCOV_EXCL_STOP */ } g_slist_free(plugin->driver_list); @@ -174,6 +176,7 @@ void zblib_plugin_unlink_driver(ZigBeePlugin *plugin, ZblibDriverType_e driver_t } } +/* LCOV_EXCL_START */ gboolean zblib_plugin_dispatch_request(ZigBeePlugin *plugin, guint request_id) { @@ -214,6 +217,7 @@ void zblib_plugin_send_response(ZigBeePlugin *plugin, zblib_service_send_response(service, request_id, resp_data, resp_data_len); } +/* LCOV_EXCL_STOP */ void zblib_plugin_send_notification(ZigBeePlugin *plugin, guint noti_id, gpointer noti_data, guint noti_data_len) diff --git a/zigbee-daemon/zigbee-lib/src/zblib_request.c b/zigbee-daemon/zigbee-lib/src/zblib_request.c index f23f3e5..c73206f 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_request.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_request.c @@ -59,7 +59,7 @@ static ZblibDriverType_e __zblib_request_get_driver_type(guint request_type) { ZblibDriverType_e driver_type; - driver_type = ((request_type & 0xFF000000) >> 24); + driver_type = ((request_type & 0xFF000000) >> 24); // LCOV_EXCL_LINE return driver_type; } @@ -68,11 +68,12 @@ static ZblibDriverType_e __zblib_request_get_ops_id(guint request_type) { guint ops_id; - ops_id = (request_type & 0x000000FF); + ops_id = (request_type & 0x000000FF); // LCOV_EXCL_LINE return ops_id; } +/* LCOV_EXCL_START */ static ZigBeeRequest *__zblib_request_ref_request_by_by_request_id(ZigBeeService *service, guint request_id) { @@ -4774,3 +4775,4 @@ guint zblib_request_get_ops_id(guint request_type) { return __zblib_request_get_ops_id(request_type); } +/* LCOV_EXCL_STOP */ diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index 2bfb853..3653a62 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -88,7 +88,7 @@ static void __on_zblib_init_async_finished(gboolean result, void *user_data) Z_LOGD("Plugin [%s] succeeded async init", plugin_name); info->is_initialized = TRUE; } else { - Z_LOGE("Plugin [%s] failed to init !", plugin_name); + Z_LOGE("Plugin [%s] failed to init !", plugin_name); // LCOV_EXCL_LINE } g_free(plugin_name); @@ -100,9 +100,11 @@ static void __on_zblib_init_async_finished(gboolean result, void *user_data) (struct _zblib_async_init_info *)(list_async->data); i++; if (G_UNLIKELY(NULL == in)) { + /* LCOV_EXCL_START */ Z_LOGE("Invalid parameter !"); list_async = g_slist_next(list_async); continue; + /* LCOV_EXCL_STOP */ } if (in->is_finished) @@ -124,8 +126,10 @@ static void __on_zblib_init_async_finished(gboolean result, void *user_data) ret = TRUE; } else { /* Some initializers are failed */ + /* LCOV_EXCL_START */ Z_LOGE("There are some failed plugin initializer !"); ret = FALSE; + /* LCOV_EXCL_STOP */ } /* Notify whether zigbee service is enabled or not */ zblib_plugin_send_notification(plugin, @@ -146,16 +150,20 @@ static void *__zblib_service_load_plugin(gchar *filename, /* Open .so */ handle = dlopen(filename, RTLD_LAZY); if (G_UNLIKELY(NULL == handle)) { + /* LCOV_EXCL_START */ Z_LOGE("dlopen() failed:[%s]", filename); return NULL; + /* LCOV_EXCL_STOP */ } /* Get symbol - "zigbee_plugin_descriptor" */ descriptor = dlsym(handle, "zigbee_plugin_descriptor"); if (G_UNLIKELY(NULL == descriptor)) { + /* LCOV_EXCL_START */ Z_LOGE("dlsym() failed:[%s]", "plugin_define_desc"); dlclose(handle); return NULL; + /* LCOV_EXCL_STOP */ } Z_LOGD("%s plugin", descriptor->name); @@ -176,9 +184,11 @@ static void *__zblib_service_load_plugin(gchar *filename, /* Load plug-in */ if (G_LIKELY(descriptor->load)) { if (G_UNLIKELY(FALSE == descriptor->load())) { + /* LCOV_EXCL_START */ Z_LOGW("load() failed... Skip this plugin!"); dlclose(handle); return NULL; + /* LCOV_EXCL_STOP */ } else { Z_LOGI("Plug-in (%s) loaded!", descriptor->name); } @@ -199,6 +209,7 @@ static gboolean __zblib_service_init_plugin(ZigBeePlugin *plugin) return FALSE; } + /* LCOV_EXCL_START */ if (G_UNLIKELY(FALSE == descriptor->init(plugin))) { char *plugin_name = zblib_plugin_get_plugin_name(plugin); if (G_UNLIKELY(NULL != plugin_name)) { @@ -207,6 +218,7 @@ static gboolean __zblib_service_init_plugin(ZigBeePlugin *plugin) } return FALSE; } + /* LCOV_EXCL_STOP */ return TRUE; } @@ -225,9 +237,11 @@ static gboolean __zblib_service_init_async_plugin(ZigBeePlugin *plugin, plugin_name = g_strdup("NONAME"); if (G_UNLIKELY(FALSE == descriptor->init_async(plugin, callback, user_data))) { + /* LCOV_EXCL_START */ Z_LOGE("plugin(%s) init failed!", plugin_name); g_free(plugin_name); return FALSE; + /* LCOV_EXCL_STOP */ } g_free(plugin_name); @@ -252,6 +266,7 @@ static gboolean __zblib_service_unload_plugin(ZigBeePlugin *plugin) return TRUE; } +/* LCOV_EXCL_START */ static void __zblib_service_remove_request_table_iter(gpointer key, gpointer value, gpointer user_data) { @@ -265,6 +280,7 @@ static void __zblib_service_remove_request_table_iter(gpointer key, Z_LOGD("Removing request id [%d]", request_id); zblib_request_free(service_interface, request_id); } +/* LCOV_EXCL_STOP */ static void __zblib_service_remove_async_list(GSList *list_async) { @@ -291,9 +307,11 @@ ZigBeeService *zblib_service_new() /* Create g-main loop */ service->main_loop = g_main_loop_new(NULL, FALSE); if (G_UNLIKELY(NULL == service->main_loop)) { + /* LCOV_EXCL_START */ Z_LOGE("g-main loop creation failed!!!"); g_free(service); return NULL; + /* LCOV_EXCL_STOP */ } /* Create request hash table */ @@ -315,6 +333,7 @@ void zblib_service_free(ZigBeeService *service) if (NULL == interface_objs) { Z_LOGE("interface_objs is NULL"); } else { + /* LCOV_EXCL_START */ while (interface_objs) { service_interface = (ZigBeeServiceInterface *)interface_objs->data; @@ -329,6 +348,7 @@ void zblib_service_free(ZigBeeService *service) g_hash_table_remove_all(service->request_table); g_hash_table_destroy(service->request_table); service->request_table = NULL; + /* LCOV_EXCL_STOP */ } } @@ -340,8 +360,10 @@ void zblib_service_free(ZigBeeService *service) /* Free plug-ins */ if (service->plugins) { + /* LCOV_EXCL_START */ g_slist_free(service->plugins); service->plugins = NULL; + /* LCOV_EXCL_STOP */ } /* Unref 'g-main loop' */ @@ -418,37 +440,43 @@ gboolean zblib_service_load_plugins(ZigBeeService *service, const char *plugin_p /* Open plug-in directory */ dir = g_dir_open(plugin_path, 0, NULL); if (G_UNLIKELY(dir == NULL)) { + /* LCOV_EXCL_START */ Z_LOGE("Directory open failed!"); return FALSE; + /* LCOV_EXCL_STOP */ } /* Scan through all libraries in plug-in directory */ while ((file = g_dir_read_name(dir)) != NULL) { if ((g_str_has_prefix(file, "lib") == TRUE) || (g_str_has_suffix(file, ".so") == FALSE)) - continue; + continue; // LCOV_EXCL_LINE filename = g_build_filename(plugin_path, file, NULL); /* Load plug-in */ handle = __zblib_service_load_plugin(filename, &descriptor); if (G_UNLIKELY(NULL == handle)) { + /* LCOV_EXCL_START */ g_free(filename); continue; + /* LCOV_EXCL_STOP */ } /* Create new plug-in */ plugin = zblib_plugin_new(service, filename, descriptor, handle); if (G_UNLIKELY(NULL == plugin)) { + /* LCOV_EXCL_START */ dlclose(handle); g_free(filename); continue; + /* LCOV_EXCL_STOP */ } /* Add new plug-in */ ret = zblib_service_add_plugin(service, plugin); if (G_UNLIKELY(FALSE == ret)) - zblib_plugin_free(plugin); + zblib_plugin_free(plugin); // LCOV_EXCL_LINE g_free(filename); } @@ -479,8 +507,10 @@ gboolean zblib_service_initialize_plugins(ZigBeeService *service) struct _zblib_async_init_info *info = g_try_new0(struct _zblib_async_init_info, 1); if (NULL == info) { + /* LCOV_EXCL_START */ Z_LOGE("Fatal : Failed to allocate memory"); return FALSE; + /* LCOV_EXCL_STOP */ } info->is_finished = FALSE; info->is_initialized = FALSE; @@ -489,9 +519,11 @@ gboolean zblib_service_initialize_plugins(ZigBeeService *service) list_async = g_slist_append(list_async, info); } else { + /* LCOV_EXCL_START */ __zblib_service_remove_async_list(list_async); Z_LOGE("Fatal : Failed to initialize plugin"); return FALSE; + /* LCOV_EXCL_STOP */ } } list = g_slist_next(list); @@ -516,15 +548,19 @@ gboolean zblib_service_initialize_async_plugins(ZigBeeService *service) (struct _zblib_async_init_info *)(list_async->data); if (G_UNLIKELY(NULL == info)) { + /* LCOV_EXCL_START */ Z_LOGE("Invalid parameter !"); list_async = g_slist_next(list_async); continue; + /* LCOV_EXCL_STOP */ } if (G_UNLIKELY(FALSE == __zblib_service_init_async_plugin( info->plugin, __on_zblib_init_async_finished, info))) { + /* LCOV_EXCL_START */ Z_LOGE("Fatal : Failed to initialize mandatory plugin"); return FALSE; + /* LCOV_EXCL_STOP */ } list_async = g_slist_next(list_async); } @@ -549,8 +585,10 @@ gboolean zblib_service_unload_plugins(ZigBeeService *service) /* Unload each plug-in */ if (G_UNLIKELY(FALSE == __zblib_service_unload_plugin(plugin))) { + /* LCOV_EXCL_START */ list = g_slist_next(list); continue; + /* LCOV_EXCL_STOP */ } list = g_slist_next(list); @@ -625,9 +663,9 @@ ZigBeeServiceInterface *zblib_service_ref_service_interface(ZigBeeService *servi service_interface = tmp_service_interface; break; } - g_free(object_name); + g_free(object_name); // LCOV_EXCL_LINE - list = g_slist_next(list); + list = g_slist_next(list); // LCOV_EXCL_LINE } if (NULL == service_interface) { @@ -641,6 +679,7 @@ ZigBeeServiceInterface *zblib_service_ref_service_interface(ZigBeeService *servi return service_interface; } +/* LCOV_EXCL_START */ GHashTable *zblib_service_ref_request_hash_table(ZigBeeService *service) { zblib_check_null_ret_error("service", service, NULL); @@ -698,6 +737,7 @@ void zblib_service_send_response(ZigBeeService *service, zblib_service_interface_send_response(service_interface, request_id, resp_data, resp_data_len); } +/* LCOV_EXCL_STOP */ void zblib_service_send_notification(ZigBeeService *service, guint noti_id, gpointer noti_data, guint noti_data_len) diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service_interface.c b/zigbee-daemon/zigbee-lib/src/zblib_service_interface.c index c28407d..927939c 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service_interface.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service_interface.c @@ -102,6 +102,7 @@ ZigBeeService *zblib_service_interface_ref_service(ZigBeeServiceInterface *servi return service_interface->service; } +/* LCOV_EXCL_START */ gint zblib_service_interface_new_request(ZigBeeServiceInterface *service_interface, ZblibDriverType_e driver_type, guint ops_id, gpointer request_data, guint request_data_len, @@ -181,6 +182,7 @@ void zblib_service_interface_send_response(ZigBeeServiceInterface *service_inter /* Free request */ zblib_request_free(service_interface, request_id); } +/* LCOV_EXCL_STOP */ gboolean zblib_service_interface_set_noti_cb(ZigBeeServiceInterface *service_interface, ZblibServiceInterfaceNotificationCb_t noti_cb, gpointer noti_cb_data) diff --git a/zigbee-daemon/zigbee-service/src/zigbee_service.c b/zigbee-daemon/zigbee-service/src/zigbee_service.c index b2a7284..b53f734 100644 --- a/zigbee-daemon/zigbee-service/src/zigbee_service.c +++ b/zigbee-daemon/zigbee-service/src/zigbee_service.c @@ -38,30 +38,38 @@ gboolean zigbee_service_init(ZigBeeService *service) const char *zigbee_plugin_path = ZIGBEE_DEFAULT_PLUGINS_PATH; if (service == NULL) { + /* LCOV_EXCL_START */ Z_LOGE("service is NULL"); return FALSE; + /* LCOV_EXCL_STOP */ } /* Load ZigBee plug-ins */ if (G_UNLIKELY(TRUE != zblib_service_load_plugins(service, zigbee_plugin_path))) { + /* LCOV_EXCL_START */ Z_LOGE("Load plug-ins failed!"); return FALSE; + /* LCOV_EXCL_STOP */ } Z_TIME_CHECK("Loading Plugins Complete"); /* Initialize ZigBee plug-ins */ if (G_UNLIKELY(TRUE != zblib_service_initialize_plugins(service))) { + /* LCOV_EXCL_START */ Z_LOGE("Initialize plug-ins failed!"); return FALSE; + /* LCOV_EXCL_STOP */ } Z_TIME_CHECK("Initializing Plugins Complete."); /* Initialize ZigBee plug-ins */ if (G_UNLIKELY(TRUE != zblib_service_initialize_async_plugins(service))) { + /* LCOV_EXCL_START */ Z_LOGE("Asynchronously initialize plug-ins failed!"); return FALSE; + /* LCOV_EXCL_STOP */ } Z_TIME_CHECK("Asynchronous initializer launched successfully. Starting Daemon"); @@ -73,14 +81,18 @@ gboolean zigbee_service_init(ZigBeeService *service) void zigbee_service_deinit(ZigBeeService *service) { if (service == NULL) { + /* LCOV_EXCL_START */ Z_LOGE("service is NULL"); return; + /* LCOV_EXCL_STOP */ } /* Unload ZigBee plug-ins */ if (G_UNLIKELY(TRUE != zblib_service_unload_plugins(service))) { + /* LCOV_EXCL_START */ Z_LOGE("Unload plug-ins failed!"); return; + /* LCOV_EXCL_STOP */ } Z_TIME_CHECK("Unload Plugins Complete"); -- 2.7.4 From 7b10aa51662b4bc92a1d31893f8379e2fe3cf67b Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Tue, 29 May 2018 19:57:36 +0900 Subject: [PATCH 12/16] Fixed a problem that error codes of zigbee-lib (which are usesd in pluings) did not match up zigbee-daemon uses. Change-Id: Ifd947a5f250d9f0e3ab63bec35894d89be50f6f2 Signed-off-by: saerome.kim --- zigbee-daemon/zigbee-lib/include/zblib_types.h | 72 ++++++++++++++++++++++---- 1 file changed, 61 insertions(+), 11 deletions(-) diff --git a/zigbee-daemon/zigbee-lib/include/zblib_types.h b/zigbee-daemon/zigbee-lib/include/zblib_types.h index 16c26a8..1073252 100644 --- a/zigbee-daemon/zigbee-lib/include/zblib_types.h +++ b/zigbee-daemon/zigbee-lib/include/zblib_types.h @@ -23,19 +23,69 @@ * For Responses * -------------------------------------------------------------------------------------*/ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef TIZEN_ERROR_NONE +#define TIZEN_ERROR_NONE 0 /**< Successful */ +#endif + +#ifndef TIZEN_ERROR_INVALID_PARAMETER +#define TIZEN_ERROR_INVALID_PARAMETER -EINVAL /**< Invalid function parameter */ +#endif + +#ifndef TIZEN_ERROR_RESULT_OUT_OF_RANGE +#define TIZEN_ERROR_RESULT_OUT_OF_RANGE -ERANGE /**< Math result not representable */ +#endif + +#ifndef TIZEN_ERROR_OUT_OF_MEMORY +#define TIZEN_ERROR_OUT_OF_MEMORY -ENOMEM /**< Out of memory */ +#endif + +#ifndef TIZEN_ERROR_IO_ERROR +#define TIZEN_ERROR_IO_ERROR -EIO /**< I/O error */ +#endif + +#ifndef TIZEN_ERROR_NO_DATA +#define TIZEN_ERROR_NO_DATA -ENODATA /**< No data available */ +#endif + +#ifndef TIZEN_ERROR_MIN_PLATFORM_ERROR +#define TIZEN_ERROR_MIN_PLATFORM_ERROR (-1073741824LL) /* = -2147483648 / 2 */ +#endif + +#ifndef TIZEN_ERROR_NOT_SUPPORTED +#define TIZEN_ERROR_NOT_SUPPORTED TIZEN_ERROR_MIN_PLATFORM_ERROR + 2 /**< Not supported */ +#endif + +#ifndef TIZEN_ERROR_PERMISSION_DENIED +#define TIZEN_ERROR_PERMISSION_DENIED -EACCES /**< Permission denied */ +#endif + +#ifndef TIZEN_ERROR_ZIGBEE +#define TIZEN_ERROR_ZIGBEE -0x02F70000 +#endif + /* Enumeration for zigbee library error code. */ typedef enum { - ZBLIB_ERROR_NONE = 0, /**< Successful */ - ZBLIB_ERROR_INVALID_PARAMETER, /**< parameter error */ - ZBLIB_ERROR_PARAMETER_OUT_OF_RANGE, /**< out of range error */ - ZBLIB_ERROR_INVALID_ENDPOINT, /**< endpoint 0 is reserved for ZDP */ - ZBLIB_ERROR_INVALID_ADDRESS, /**< wrong address */ - ZBLIB_ERROR_OUT_OF_MEMORY, /**< out of memory */ - ZBLIB_ERROR_INVALID_DATA, /**< Invalid data available */ - ZBLIB_ERROR_IO_ERROR, /**< DBus error */ - ZBLIB_ERROR_NO_DATA, /**< No data available */ - ZBLIB_ERROR_NOT_SUPPORTED, /**< not supported */ - ZBLIB_ERROR_UNKNOWN /**< Unknown error */ + ZBLIB_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + ZBLIB_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< parameter error */ + ZBLIB_ERROR_PARAMETER_OUT_OF_RANGE = TIZEN_ERROR_RESULT_OUT_OF_RANGE, /**< out of range error */ + ZBLIB_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< out of memory */ + ZBLIB_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< DBus error */ + ZBLIB_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */ + ZBLIB_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< not supported */ + ZBLIB_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + ZBLIB_ERROR_INVALID_ENDPOINT = TIZEN_ERROR_ZIGBEE | 0x01, /**< endpoint 0 is reserved for ZDP */ + ZBLIB_ERROR_INVALID_ADDRESS = TIZEN_ERROR_ZIGBEE | 0x01, /**< wrong address */ + ZIGBEE_ERROR_OPERATION_FAILED = TIZEN_ERROR_ZIGBEE | 0x03, /**< Invalid data available */ } zblib_error_e; +#ifdef __cplusplus +} +#endif + #endif /* __ZIGBEE_LIB_TYPES_H__ */ -- 2.7.4 From 3f58ba1109f4643d682e276b021da8ae8d83f768 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Tue, 26 Jun 2018 16:46:02 +0900 Subject: [PATCH 13/16] 1. Enable privlilege check routine Recently, Tizen dbus policy has been changed. If don't enable dbus priviliege check by config file, dbus commm. always fails (PERMISSION DENIED error will hanppen). 2. Changed the name of zigbee-daemon to zigbeed With renaming the daemon, change related settings as well. Change-Id: I64d6a6be3a6afd1f46edb1b90f3e552255653ae7 Signed-off-by: saerome.kim --- packaging/org.tizen.zigbee.service | 2 +- .../zigbee-manager.service | 2 +- packaging/zigbee-manager.spec | 42 ++++++++++++++-------- zigbee-daemon/CMakeLists.txt | 3 +- zigbee-daemon.manifest => zigbee-manager.manifest | 0 5 files changed, 30 insertions(+), 19 deletions(-) rename zigbee-daemon/resources/zigbee-daemon.service => packaging/zigbee-manager.service (87%) rename zigbee-daemon.manifest => zigbee-manager.manifest (100%) diff --git a/packaging/org.tizen.zigbee.service b/packaging/org.tizen.zigbee.service index 92a7f03..6177c62 100644 --- a/packaging/org.tizen.zigbee.service +++ b/packaging/org.tizen.zigbee.service @@ -4,4 +4,4 @@ Name=org.tizen.zigbee.manager Exec=/bin/false User=network_fw Group=network_fw -SystemdService=zigbee-daemon.service +SystemdService=zigbee-manager.service diff --git a/zigbee-daemon/resources/zigbee-daemon.service b/packaging/zigbee-manager.service similarity index 87% rename from zigbee-daemon/resources/zigbee-daemon.service rename to packaging/zigbee-manager.service index 8da1635..79490e1 100644 --- a/zigbee-daemon/resources/zigbee-daemon.service +++ b/packaging/zigbee-manager.service @@ -9,7 +9,7 @@ BusName=org.tizen.zigbee.manager User=network_fw Group=network_fw SmackProcessLabel=System -ExecStart=/usr/bin/zigbee-daemon +ExecStart=/usr/bin/zigbeed [Install] WantedBy=multi-user.target diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 6a2b4c5..b6e9346 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -1,17 +1,18 @@ %define major 0 %define minor 1 %define patchlevel 2 -%define CHECK_ZIGBEE_PRIVILEGE False +%define CHECK_ZIGBEE_PRIVILEGE True Name: zigbee-manager Version: %{major}.%{minor}.%{patchlevel} Release: 1 License: Apache-2.0 -Summary: ZigBee Daemon +Summary: ZigBee Manager Group: System/Network Source0: %{name}-%{version}.tar.gz -Source1: org.tizen.zigbee.service -Source2: zigbee.conf +Source1: zigbee-manager.service +Source2: org.tizen.zigbee.service +Source3: zigbee.conf BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(gio-2.0) @@ -25,9 +26,10 @@ BuildRequires: pkgconfig(gmock) # if image creater does not know 'network_fw' Requires: security-config +Requires: awk %description -Description: ZigBee Daemon +Description: ZigBee Manager %package -n zigbee-lib Summary: ZigBee library @@ -75,13 +77,20 @@ make %{?_smp_mflags} # Do not execute daemon on boot time #mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants -#ln -s %{_unitdir}/zigbee-daemon.service %{buildroot}%{_unitdir}/multi-user.target.wants/zigbee-daemon.service +#ln -s %{_unitdir}/zigbee-manager.service %{buildroot}%{_unitdir}/multi-user.target.wants/zigbee-manager.service +mkdir -p %{buildroot}%{_libdir}/systemd/system +cp %{SOURCE1} %{buildroot}%{_libdir}/systemd/system/zigbee-manager.service +%if "%{?_lib}" == "lib64" +mkdir -p %{buildroot}%{_unitdir} +cp %{SOURCE1} %{buildroot}%{_unitdir}/zigbee-manager.service +%endif mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -mkdir -p %{buildroot}%{_datadir}/dbus-1/system.d/ -cp %{SOURCE1} %{buildroot}%{_datadir}/dbus-1/system-services/org.tizen.zigbee.service +cp %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/system-services/org.tizen.zigbee.service + %if %{CHECK_ZIGBEE_PRIVILEGE} == "True" -cp %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/system.d/zigbee.conf +mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d +cp %{SOURCE3} %{buildroot}%{_sysconfdir}/dbus-1/system.d/zigbee.conf %endif %post -p /sbin/ldconfig @@ -89,14 +98,17 @@ cp %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/system.d/zigbee.conf %postun -p /sbin/ldconfig %files -%manifest zigbee-daemon.manifest +%manifest zigbee-manager.manifest %defattr(-,root,root,-) -%attr(755,network_fw,network_fw) %{_bindir}/zigbee-daemon -%{_unitdir}/zigbee-daemon.service -#%{_unitdir}/multi-user.target.wants/zigbee-daemon.service -%attr(644,root,root) %{_datadir}/dbus-1/system-services/* +%attr(755,network_fw,network_fw) %{_bindir}/zigbeed +%{_libdir}/systemd/system/zigbee-manager.service +%if "%{?_lib}" == "lib64" +%{_unitdir}/zigbee-manager.service +%endif +#%{_unitdir}/multi-user.target.wants/zigbee-manager.service +%{_datadir}/dbus-1/system-services/org.tizen.zigbee.service %if %{CHECK_ZIGBEE_PRIVILEGE} == "True" -%{_datadir}/dbus-1/system.d/zigbee.conf +%attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/zigbee.conf %endif %license LICENSE %if 0%{?gtests:1} diff --git a/zigbee-daemon/CMakeLists.txt b/zigbee-daemon/CMakeLists.txt index 0a44dbf..af9aedf 100644 --- a/zigbee-daemon/CMakeLists.txt +++ b/zigbee-daemon/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(zigbee-daemon C) +PROJECT(zigbeed C) MESSAGE(===================================================================) MESSAGE(Building...) @@ -103,4 +103,3 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} zigbee-service zigbee-interface ${pkgs_LDF ### Install files ### INSTALL(TARGETS zigbee-lib DESTINATION ${LIBDIR} COMPONENT Runtime) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/zigbee-daemon.service DESTINATION ${UNITDIR}) diff --git a/zigbee-daemon.manifest b/zigbee-manager.manifest similarity index 100% rename from zigbee-daemon.manifest rename to zigbee-manager.manifest -- 2.7.4 From c732484277528747be818c7060c31d6e0014fd85 Mon Sep 17 00:00:00 2001 From: Abhishek Sansanwal Date: Tue, 7 Aug 2018 14:25:31 +0530 Subject: [PATCH 14/16] Added Haltest for zigbee-manager Signed-off-by: Abhishek Sansanwal Change-Id: I59d59c6ae328b9b372d2ca106b90be0f9a67a884 --- CMakeLists.txt | 2 + haltest/CMakeLists.txt | 33 +++ haltest/common.h | 47 ++++ haltest/gdbus.cpp | 462 ++++++++++++++++++++++++++++++++++++++ haltest/gdbus.h | 122 ++++++++++ haltest/zbl.cpp | 71 ++++++ haltest/zbl.h | 81 +++++++ haltest/zigbee_manager_hal_tc.cpp | 114 ++++++++++ packaging/zigbee-manager.spec | 15 ++ 9 files changed, 947 insertions(+) create mode 100644 haltest/CMakeLists.txt create mode 100644 haltest/common.h create mode 100644 haltest/gdbus.cpp create mode 100644 haltest/gdbus.h create mode 100644 haltest/zbl.cpp create mode 100644 haltest/zbl.h create mode 100644 haltest/zigbee_manager_hal_tc.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 329ad66..24cdefa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,3 +40,5 @@ ADD_SUBDIRECTORY(zigbee-daemon) IF(BUILD_GTESTS) ADD_SUBDIRECTORY(unittest) ENDIF(BUILD_GTESTS) + +ADD_SUBDIRECTORY(haltest) diff --git a/haltest/CMakeLists.txt b/haltest/CMakeLists.txt new file mode 100644 index 0000000..2c081de --- /dev/null +++ b/haltest/CMakeLists.txt @@ -0,0 +1,33 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(gtest-haltest-zigbee-manager C CXX) + +SET(HALTEST "zigbee_manager_hal_tc") +ADD_DEFINITIONS("-DUSE_DLOG") + +SET(REQUIRES_LIST ${REQUIRES_LIST} + glib-2.0 + gio-2.0 + gmock + dlog + capi-system-info +) + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(HALTEST_PKG REQUIRED ${REQUIRES_LIST}) + +FOREACH(flag ${HALTEST_PKG_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +FILE(GLOB HALTEST_SRCS *.cpp) +SET(HALTEST_SRCS ${HALTEST_SRCS}) + +ADD_EXECUTABLE(${HALTEST} ${HALTEST_SRCS}) +TARGET_LINK_LIBRARIES(${HALTEST} ${HALTEST_LDFLAGS} ${HALTEST_PKG_LDFLAGS} -ldl -lgcov) + +INSTALL(TARGETS ${HALTEST} RUNTIME DESTINATION bin) diff --git a/haltest/common.h b/haltest/common.h new file mode 100644 index 0000000..e2707a7 --- /dev/null +++ b/haltest/common.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2017 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 __COMMON_H__ +#define __COMMON_H__ + +#include + +#ifdef USE_DLOG +#include +#undef LOG_TAG +#define LOG_TAG "ZIGBEE_GTEST" +#define GLOGD(format, args...) LOGD(format, ##args) +#else +#define GLOGD(format, args...) +#endif + +#ifndef TIZEN_ERROR_ZIGBEE +#define TIZEN_ERROR_ZIGBEE -0x02F70000 +#endif + +typedef enum { + ZIGBEE_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + ZIGBEE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + ZIGBEE_ERROR_PARAMETER_OUT_OF_RANGE = TIZEN_ERROR_RESULT_OUT_OF_RANGE, /**< Out of range */ + 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_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + ZIGBEE_ERROR_INVALID_ENDPOINT = TIZEN_ERROR_ZIGBEE | 0x01, /**< Endpoint 0 is reserved for ZDP */ + ZIGBEE_ERROR_INVALID_ADDRESS = TIZEN_ERROR_ZIGBEE | 0x02, /**< Wrong address */ + ZIGBEE_ERROR_OPERATION_FAILED = TIZEN_ERROR_ZIGBEE | 0x03, /**< Operation failed */ +} zb_error_e; +#endif /* __COMMON_H__ */ diff --git a/haltest/gdbus.cpp b/haltest/gdbus.cpp new file mode 100644 index 0000000..81432df --- /dev/null +++ b/haltest/gdbus.cpp @@ -0,0 +1,462 @@ +/* + * Copyright (c) 2017 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 "zbl.h" + +GDbus::GDbus() +{ + this->m_pConnection = NULL; + this->m_pCancellable = NULL; + this->service_gproxy = NULL; + this->on_off_gproxy = NULL; + this->door_lock_gproxy = NULL; + this->level_control_gproxy = NULL; + this->thermostat_gproxy = NULL; + this->alarm_gproxy = NULL; + this->fan_control_gproxy = NULL; + + this->mfglib_gproxy = NULL; + this->zcl_global_proxy = NULL; + this->zdo_dev_proxy = NULL; + this->zcl_basic_proxy = NULL; + this->zcl_identify_proxy = NULL; + this->zcl_ias_zone_proxy = NULL; + this->zcl_poll_control_proxy = NULL; + this->zcl_group_proxy = NULL; + this->zcl_scene_proxy = NULL; + this->zdo_bind_proxy = NULL; + this->zcl_color_control_proxy = NULL; + this->custom_gproxy = NULL; +} + +GDbus::~GDbus() +{ + GDBusConnection *conn = this->m_pConnection; + GCancellable *cancel = this->m_pCancellable; + + if (cancel) { + g_cancellable_cancel(cancel); + g_object_unref(cancel); + cancel = NULL; + } + + if (conn) { + g_object_unref(this->service_gproxy); + this->service_gproxy = NULL; + g_object_unref(this->on_off_gproxy); + this->on_off_gproxy = NULL; + g_object_unref(this->door_lock_gproxy); + this->door_lock_gproxy = NULL; + g_object_unref(this->level_control_gproxy); + this->level_control_gproxy = NULL; + g_object_unref(this->thermostat_gproxy); + this->thermostat_gproxy = NULL; + g_object_unref(this->alarm_gproxy); + this->alarm_gproxy = NULL; + g_object_unref(this->fan_control_gproxy); + this->fan_control_gproxy = NULL; + + g_object_unref(this->mfglib_gproxy); + this->mfglib_gproxy = NULL; + g_object_unref(this->zcl_global_proxy); + this->zcl_global_proxy = NULL; + + g_object_unref(this->zdo_dev_proxy); + this->zdo_dev_proxy = NULL; + g_object_unref(this->zcl_basic_proxy); + this->zcl_basic_proxy = NULL; + g_object_unref(this->zcl_identify_proxy); + this->zcl_identify_proxy = NULL; + g_object_unref(this->zcl_ias_zone_proxy); + this->zcl_ias_zone_proxy = NULL; + g_object_unref(this->zcl_poll_control_proxy); + this->zcl_poll_control_proxy = NULL; + g_object_unref(this->zcl_group_proxy); + this->zcl_group_proxy = NULL; + g_object_unref(this->zcl_scene_proxy); + this->zcl_scene_proxy = NULL; + g_object_unref(this->zdo_bind_proxy); + this->zdo_bind_proxy = NULL; + + g_object_unref(this->zcl_color_control_proxy); + this->zcl_color_control_proxy = NULL; + g_object_unref(this->custom_gproxy); + this->custom_gproxy = NULL; + + g_object_unref(conn); + conn = NULL; + } +} + +zb_error_e GDbus::Create(void) +{ + GError *err = NULL; + GDBusConnection *gdbus_conn; + +#if !GLIB_CHECK_VERSION(2, 36, 0) + g_type_init(); +#endif + + this->m_pConnection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); + if (this->m_pConnection == NULL) { + if (err != NULL) { + GLOGD("Failed to connect to the D-BUS daemon [%s]", err->message); + g_error_free(err); + } + + return ZIGBEE_ERROR_OPERATION_FAILED; + } + + gdbus_conn = this->m_pConnection; + + this->service_gproxy = 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); + + this->on_off_gproxy = 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); + + this->door_lock_gproxy = 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); + + this->level_control_gproxy = 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); + + this->thermostat_gproxy = 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); + + this->alarm_gproxy = 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); + + this->fan_control_gproxy = 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); + + this->mfglib_gproxy = 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); + + this->zcl_global_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); + + this->zdo_dev_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); + + this->zcl_basic_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); + + this->zcl_identify_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); + + this->zcl_ias_zone_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); + + this->zcl_poll_control_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); + + this->zcl_group_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); + + this->zcl_scene_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); + + this->zdo_bind_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); + + this->zcl_color_control_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); + + this->custom_gproxy = 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); + + this->m_pCancellable = g_cancellable_new(); + + return ZIGBEE_ERROR_NONE; +} + +zb_error_e GDbus::Destroy(void) +{ + g_object_unref(this->service_gproxy); + this->service_gproxy = NULL; + g_object_unref(this->on_off_gproxy); + this->on_off_gproxy = NULL; + g_object_unref(this->door_lock_gproxy); + this->door_lock_gproxy = NULL; + g_object_unref(this->level_control_gproxy); + this->level_control_gproxy = NULL; + g_object_unref(this->thermostat_gproxy); + this->thermostat_gproxy = NULL; + g_object_unref(this->alarm_gproxy); + this->alarm_gproxy = NULL; + g_object_unref(this->fan_control_gproxy); + this->fan_control_gproxy = NULL; + + g_object_unref(this->mfglib_gproxy); + this->mfglib_gproxy = NULL; + g_object_unref(this->zcl_global_proxy); + this->zcl_global_proxy = NULL; + + g_object_unref(this->zdo_dev_proxy); + this->zdo_dev_proxy = NULL; + g_object_unref(this->zcl_basic_proxy); + this->zcl_basic_proxy = NULL; + g_object_unref(this->zcl_identify_proxy); + this->zcl_identify_proxy = NULL; + g_object_unref(this->zcl_ias_zone_proxy); + this->zcl_ias_zone_proxy = NULL; + g_object_unref(this->zcl_poll_control_proxy); + this->zcl_poll_control_proxy = NULL; + g_object_unref(this->zcl_group_proxy); + this->zcl_group_proxy = NULL; + g_object_unref(this->zcl_scene_proxy); + this->zcl_scene_proxy = NULL; + g_object_unref(this->zdo_bind_proxy); + this->zdo_bind_proxy = NULL; + g_object_unref(this->zcl_color_control_proxy); + this->zcl_color_control_proxy = NULL; + g_object_unref(this->custom_gproxy); + this->custom_gproxy = NULL; + + g_cancellable_cancel(this->m_pCancellable); + g_object_unref(this->m_pCancellable); + this->m_pCancellable = NULL; + + g_object_unref(this->m_pConnection); + this->m_pConnection = NULL; + + return ZIGBEE_ERROR_NONE; +} + +GDBusConnection *GDbus::GetConnection(void) +{ + return this->m_pConnection; +} + +GCancellable *GDbus::GetCancellable(void) +{ + return this->m_pCancellable; +} + +GDBusProxy *GDbus::get_proxy_type(gproxy_type_e type) +{ + GDBusProxy *proxy = NULL; + + switch (type) + { + case SERVICE_GPROXY: + proxy = this->service_gproxy; + break; + case ON_OFF_GPROXY: + proxy = this->on_off_gproxy; + break; + case DOOR_LOCK_GPROXY: + proxy = this->door_lock_gproxy; + break; + case LEVEL_CONTROL_GPROXY: + proxy = this->level_control_gproxy; + break; + case THERMOSTAT_GPROXY: + proxy = this->thermostat_gproxy; + break; + case ALARM_GPROXY: + proxy = this->alarm_gproxy; + break; + case FAN_CONTROL_GPROXY: + proxy = this->fan_control_gproxy; + break; + case MFGLIB_GPROXY: + proxy = this->mfglib_gproxy; + break; + case ZCL_GLOBAL_PROXY: + proxy = this->zcl_global_proxy; + break; + case ZDO_DEV_PROXY: + proxy = this->zdo_dev_proxy; + break; + case ZCL_BASIC_PROXY: + proxy = this->zcl_basic_proxy; + break; + case ZCL_IDENTIFY_PROXY: + proxy = this->zcl_identify_proxy; + break; + case ZCL_IAS_ZONE_PROXY: + proxy = this->zcl_ias_zone_proxy; + break; + case ZCL_POLL_CONTROL_PROXY: + proxy = this->zcl_poll_control_proxy; + break; + case ZCL_GROUP_PROXY: + proxy = this->zcl_group_proxy; + break; + case ZCL_SCENE_PROXY: + proxy = this->zcl_scene_proxy; + break; + case ZDO_BIND_PROXY: + proxy = this->zdo_bind_proxy; + break; + case ZCL_COLOR_CONTROL_PROXY: + proxy = this->zcl_color_control_proxy; + break; + case CUSTOM_GPROXY: + proxy = this->custom_gproxy; + break; + } + + return proxy; +} + +GVariant *GDbus::invoke_proxy_method(gproxy_type_e type, const char *method, GVariant *params, int *error) +{ + GError *dbus_error = NULL; + GVariant *reply = NULL; + GDBusConnection *connection = NULL; + GDBusProxy *proxy = NULL; + + connection = GetConnection(); + if (connection == NULL) { + GLOGD("GDBusconnection is NULL"); + *error = ZIGBEE_ERROR_IO_ERROR; + return reply; + } + + proxy = get_proxy_type(type); + if (proxy == NULL) { + GLOGD("GDBusProxy is NULL"); + *error = ZIGBEE_ERROR_IO_ERROR; + return reply; + } + + reply = g_dbus_proxy_call_sync(proxy, + method, + params, + G_DBUS_CALL_FLAGS_NONE, + ZIGBEE_BROADCAST_TIMEOUT, + GetCancellable(), + &dbus_error); + + if (reply == NULL) { + if (dbus_error != NULL) { + GLOGD("g_dbus_connection_call_sync() failed " + "error [%d: %s]", dbus_error->code, dbus_error->message); + if (strstr(dbus_error->message, "AccessDenied")) + *error = ZIGBEE_ERROR_PERMISSION_DENIED; + else + *error = ZIGBEE_ERROR_IO_ERROR; + g_error_free(dbus_error); + } else { + GLOGD("g_dbus_connection_call_sync() failed"); + *error = ZIGBEE_ERROR_OPERATION_FAILED; + } + return NULL; + } + + return reply; +} + +GVariant *GDbus::InvokeMethod(const char *dest, const char *path, + const char *iface_name, const char *method, GVariant *params, int *error) +{ + GError *dbus_error = NULL; + GVariant *reply = NULL; + GDBusConnection *connection = NULL; + + connection = GetConnection(); + if (connection == NULL) { + GLOGD("GDBusconnection is NULL"); + *error = ZIGBEE_ERROR_IO_ERROR; + return reply; + } + + reply = g_dbus_connection_call_sync(connection, + dest, + path, + iface_name, + method, + params, + NULL, + G_DBUS_CALL_FLAGS_NONE, + ZIGBEE_BROADCAST_TIMEOUT, + GetCancellable(), + &dbus_error); + + if (reply == NULL) { + if (dbus_error != NULL) { + GLOGD("g_dbus_connection_call_sync() failed " + "error [%d: %s]", dbus_error->code, dbus_error->message); + if (strstr(dbus_error->message, "AccessDenied")) + *error = ZIGBEE_ERROR_PERMISSION_DENIED; + else + *error = ZIGBEE_ERROR_IO_ERROR; + g_error_free(dbus_error); + } else { + GLOGD("g_dbus_connection_call_sync() failed"); + *error = ZIGBEE_ERROR_OPERATION_FAILED; + } + return NULL; + } + + return reply; +} + +zb_error_e GDbus::InvokeMethodNonblock(const char *dest, const char *path, + const char *iface_name, const char *method, GVariant *params, int timeout, + GAsyncReadyCallback notify_func, void *user_data) +{ + GDBusConnection *connection = NULL; + + connection = GetConnection(); + if (connection == NULL) { + GLOGD("GDBusconnection is NULL"); + return ZIGBEE_ERROR_IO_ERROR; + } + + g_dbus_connection_call(connection, + dest, + path, + iface_name, + method, + params, + NULL, + G_DBUS_CALL_FLAGS_NONE, + timeout, + GetCancellable(), + (GAsyncReadyCallback) notify_func, + (gpointer)user_data); + + return ZIGBEE_ERROR_NONE; +} diff --git a/haltest/gdbus.h b/haltest/gdbus.h new file mode 100644 index 0000000..2c0775b --- /dev/null +++ b/haltest/gdbus.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017 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 __ZIGBEE_GDBUS_H__ +#define __ZIGBEE_GDBUS_H__ + +#include +#include "common.h" + +#define GMAINTIMEOUT 10000 +#define ZIGBEE_BROADCAST_TIMEOUT (9.5 + 2) * 1000 /**< default timeout for gdbus */ + + +#ifndef ZIGBEE_DBUS_INTERFACE +#define ZIGBEE_DBUS_INTERFACE "org.tizen.zigbee" +#endif + +#ifndef ZIGBEE_DBUS_OBJPATH +#define ZIGBEE_DBUS_OBJPATH "/org/tizen/zigbee" +#endif + +#define ZIGBEE_SERVER_NAME "org.tizen.zigbee" +#define ZIGBEE_CONTROL_OBJECT_PATH "/org/tizen/zigbee/control" + +#define ZIGBEE_MANAGER_INTERFACE "org.tizen.zigbee.manager" +#define ZIGBEE_SERVICE_INTERFACE "org.tizen.zigbee.service" +#define ZIGBEE_SERVICE_OBJECT_PATH "/org/tizen/zigbee/service" + +#define ZIGBEE_ZDO_DEV_CONTROL_INTERFACE "org.tizen.zigbee.zdo_dev_control" +#define ZIGBEE_ZDO_BIND_INTERFACE "org.tizen.zigbee.zdo_bind" +#define ZIGBEE_ZCL_GLOBAL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_global_control" +#define ZIGBEE_ZCL_ALARM_INTERFACE "org.tizen.zigbee.zcl_alarm" +#define ZIGBEE_ZCL_BASIC_INTERFACE "org.tizen.zigbee.zcl_basic" +#define ZIGBEE_ZCL_COLOR_CONTROL_INTERFACE "org.tizen.zigbee.zcl_color_control" +#define ZIGBEE_ZCL_ON_OFF_INTERFACE "org.tizen.zigbee.zcl_on_off" +#define ZIGBEE_ZCL_DOOR_LOCK_INTERFACE "org.tizen.zigbee.zcl_door_lock" +#define ZIGBEE_ZCL_GROUP_INTERFACE "org.tizen.zigbee.zcl_group" +#define ZIGBEE_ZCL_FAN_CONTROL_INTERFACE "org.tizen.zigbee.zcl_fan_control" +#define ZIGBEE_ZCL_IAS_ZONE_INTERFACE "org.tizen.zigbee.zcl_ias_zone" +#define ZIGBEE_ZCL_IDENTIFY_INTERFACE "org.tizen.zigbee.zcl_identify" +#define ZIGBEE_ZCL_LEVEL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_level_control" +#define ZIGBEE_ZCL_POLL_CONTROL_INTERFACE "org.tizen.zigbee.zcl_poll_control" +#define ZIGBEE_ZCL_SCENE_INTERFACE "org.tizen.zigbee.zcl_scene" +#define ZIGBEE_ZCL_THERMOSTAT_INTERFACE "org.tizen.zigbee.zcl_thermostat" +#define ZIGBEE_CUSTOM_INTERFACE "org.tizen.zigbee.custom" +#define ZIGBEE_MFGLIB_CONTROL_INTERFACE "org.tizen.zigbee.mfglib_control" + +typedef enum { + SERVICE_GPROXY, + ON_OFF_GPROXY, + DOOR_LOCK_GPROXY, + LEVEL_CONTROL_GPROXY, + THERMOSTAT_GPROXY, + ALARM_GPROXY, + FAN_CONTROL_GPROXY, + MFGLIB_GPROXY, + ZCL_GLOBAL_PROXY, + ZDO_DEV_PROXY, + ZCL_BASIC_PROXY, + ZCL_IDENTIFY_PROXY, + ZCL_IAS_ZONE_PROXY, + ZCL_POLL_CONTROL_PROXY, + ZCL_GROUP_PROXY, + ZCL_SCENE_PROXY, + ZDO_BIND_PROXY, + ZCL_COLOR_CONTROL_PROXY, + CUSTOM_GPROXY, +} gproxy_type_e; + +class GDbus { + private: + GDBusConnection *m_pConnection; + GDBusProxy *service_gproxy; + GDBusProxy *on_off_gproxy; + GDBusProxy *door_lock_gproxy; + GDBusProxy *level_control_gproxy; + GDBusProxy *thermostat_gproxy; + GDBusProxy *alarm_gproxy; + GDBusProxy *fan_control_gproxy; + GDBusProxy *mfglib_gproxy; + GDBusProxy *zcl_global_proxy; + GDBusProxy *zdo_dev_proxy; + GDBusProxy *zcl_basic_proxy; + GDBusProxy *zcl_identify_proxy; + GDBusProxy *zcl_ias_zone_proxy; + GDBusProxy *zcl_poll_control_proxy; + GDBusProxy *zcl_group_proxy; + GDBusProxy *zcl_scene_proxy; + GDBusProxy *zdo_bind_proxy; + GDBusProxy *zcl_color_control_proxy; + GDBusProxy *custom_gproxy; + GCancellable *m_pCancellable; + GDBusProxy *get_proxy_type(gproxy_type_e type); + + public: + GDbus(); + ~GDbus(); + zb_error_e Create(void); + zb_error_e Destroy(void); + GDBusConnection *GetConnection(void); + GCancellable *GetCancellable(void); + + GVariant *invoke_proxy_method(gproxy_type_e type, const char *method, GVariant *params, int *error); + GVariant *InvokeMethod(const char *dest, const char *path, + const char *iface_name, const char *method, GVariant *params, int *error); + zb_error_e InvokeMethodNonblock(const char *dest, const char *path, + const char *iface_name, const char *method, GVariant *params, int timeout, + GAsyncReadyCallback notify_func, void *user_data); +}; +#endif /* __ZIGBEE_GDBUS_H__ */ diff --git a/haltest/zbl.cpp b/haltest/zbl.cpp new file mode 100644 index 0000000..c274ceb --- /dev/null +++ b/haltest/zbl.cpp @@ -0,0 +1,71 @@ +/* + * 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 "zbl.h" + +Zigbee::Zigbee(void) +{ + Create(); +} + +Zigbee::~Zigbee(void) +{ + Destroy(); +} + +int Zigbee::zbl_enable(void) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message; + + GLOGD("zbl_enable()"); + + message = InvokeMethod(ZIGBEE_MANAGER_INTERFACE, + ZIGBEE_DBUS_OBJPATH, + ZIGBEE_MANAGER_INTERFACE, + "enable", NULL, &error); + + if (message) + g_variant_unref(message); + + return error; +} + +int Zigbee::zbl_disable(void) +{ + int error = ZIGBEE_ERROR_NONE; + GVariant *message = NULL; + + GLOGD("zbl_disable()"); + + message = InvokeMethod(ZIGBEE_MANAGER_INTERFACE, + ZIGBEE_DBUS_OBJPATH, + ZIGBEE_MANAGER_INTERFACE, + "disable", NULL, &error); + + if (message) { + g_variant_get(message, "(i)", &error); + GLOGD("ret = 0x%x", error); + g_variant_unref(message); + } + + return error; +} diff --git a/haltest/zbl.h b/haltest/zbl.h new file mode 100644 index 0000000..9cccb1f --- /dev/null +++ b/haltest/zbl.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2017 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 __ZIGBEE_MANAGER_H__ +#define __ZIGBEE_MANAGER_H__ + +#include +#include + +#include "gdbus.h" +#include "common.h" + +#define MAX_ENDPOINT_CLUSTERS 32 +#define ZB_802_15_4_CHANNELS_MASK 0x07FFF800UL + +typedef unsigned char ieee_addr[8]; +typedef unsigned short nwk_addr; +typedef unsigned char aes128_key[16]; + +typedef enum { + ZB_ZDP_ALTERNATIVE_PAN_COORDINATOR = (1 << 0), + ZB_ZDP_DEVICE_TYPE = (1 << 1), + ZB_ZDP_POWER_SOURCE = (1 << 2), + ZB_ZDP_RECEIVER_ON_WHEN_IDLE = (1 << 3), + ZB_ZDP_SECURITY_CAPABILITY = (1 << 6), + ZB_ZDP_ALLOCATE_ADDRESS = (1 << 7), +} zb_zdo_mac_capability_field_e; + +typedef enum { + ZB_APS_NO_ACK_REQUEST = (0 << 6), + ZB_APS_ACK_REQUEST = (1 << 6), +} zb_aps_ack_request_e; + +typedef enum { + ZB_APS_DELIVERY_UNICAST = 0, + ZB_APS_DELIVERY_INDIRECT = 1, + ZB_APS_DELIVERY_BROADCAST = 2, + ZB_APS_DELIVERY_MULTICAST = 3, +} zb_aps_delivery_mode_e; + +typedef enum { + ZB_ZCL_FC_GLOBALLY_USED = (0 << 0), + ZB_APS_FC_CLUSTER_SPECIFIC = (1 << 0), +} zb_zcl_fc_type_e; + +typedef enum { + ZB_ZCL_CLIENT_TO_SERVER = (0 << 3), + ZB_ZCL_SERVER_TO_CLIENT = (1 << 3), +} zb_zcl_fc_direction_e; + +typedef enum { + ZB_ZCL_LEAVE_WELL_ALONE = (0 << 4), + ZB_ZCL_DISABLE_DEFAULT_RESPONSE = (1 << 4), +} zb_zcl_fc_disable_default_response_e; + +typedef enum { + ZB_ZCL_FC_NOT_MANUFACTURER = (0 << 2), + ZB_ZCL_FC_MANUFACTURER = (1 << 2), +} zb_zcl_fc_manufacturer_present_e; + +class Zigbee:public GDbus { + private: + public: + Zigbee(); + ~Zigbee(); + int zbl_enable(void); + int zbl_disable(void); +}; +#endif /* __ZIGBEE_MANAGER_H__ */ diff --git a/haltest/zigbee_manager_hal_tc.cpp b/haltest/zigbee_manager_hal_tc.cpp new file mode 100644 index 0000000..52de0dd --- /dev/null +++ b/haltest/zigbee_manager_hal_tc.cpp @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2017 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" + +#define FEATURE_ZIGBEE "http://tizen.org/feature/network.zigbee" +static bool g_bFeatureZb = false; + +using ::testing::InitGoogleTest; +using ::testing::Test; +using ::testing::TestCase; + +static bool __check_feature_supported(char *key) +{ + bool value = false; + int ret = system_info_get_platform_bool(key, &value); + + EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; + EXPECT_EQ(true, value) << key << " feature is not supported"; + + return value; +} + +/* +@testcase Enable_p +@since_tizen 5.0 +@author SRID(abhishek.s94) +@reviewer HQ(saerome.kim) +@type auto +@description Positive, Enable zigbee manager +@apicovered "enable" method on "org.tizen.zigbee.manager" interface +@passcase when zbl_enable returns ZIGBEE_ERROR_NONE +@failcase when zbl_enable does not return ZIGBEE_ERROR_NONE +@precondition __check_feature_supported must return true for zigbee feature +@postcondition None +*/ +TEST(ZigbeeManager, Enable_p) +{ + g_bFeatureZb = __check_feature_supported((char*)FEATURE_ZIGBEE); + ASSERT_EQ(true, g_bFeatureZb) << FEATURE_ZIGBEE << " feature is not supported"; + + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_enable(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +/* +@testcase Disable_p +@since_tizen 5.0 +@author SRID(abhishek.s94) +@reviewer HQ(saerome.kim) +@type auto +@description Positive, Disable zigbee manager +@apicovered "disable" method on "org.tizen.zigbee.manager" interface +@passcase when zbl_disable returns ZIGBEE_ERROR_NONE +@failcase when zbl_disable does not return ZIGBEE_ERROR_NONE +@precondition __check_feature_supported must return true for zigbee feature +@postcondition None +*/ +TEST(ZigbeeManager, Disable_p) +{ + g_bFeatureZb = __check_feature_supported((char*)FEATURE_ZIGBEE); + ASSERT_EQ(true, g_bFeatureZb) << FEATURE_ZIGBEE << " feature is not supported"; + + int ret = ZIGBEE_ERROR_NONE; + Zigbee zb_mgr; + + ret = zb_mgr.zbl_disable(); + EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); +} + +int main(int argc, char **argv) +{ + int ret = 0; + try { + testing::InitGoogleTest(&argc, argv); + } catch (const ::testing::internal::GoogleTestFailureException& ex) { + std::cerr << "Caught: GoogleTestFailureException& " << ex.what() << std::endl; + } catch (...) { + std::cerr << "Caught: unknown exception" << std::endl; + } + + try { + ret = RUN_ALL_TESTS(); + } catch (const ::testing::internal::GoogleTestFailureException& ex) { + std::cerr << "Caught: GoogleTestFailureException& " << ex.what() << std::endl; + } catch (...) { + std::cerr << "Caught: unknown exception" << std::endl; + } + return ret; +} diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index b6e9346..479dacb 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -31,6 +31,17 @@ Requires: awk %description Description: ZigBee Manager +%package haltests +Summary: zigbee-manager extension for HAL test +BuildRequires: pkgconfig(gmock) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gio-2.0) +Requires: %{name} = %{version}-%{release} +%description haltests +TIZEN zigbee-manager extension for HAL test. + %package -n zigbee-lib Summary: ZigBee library Group: System/Libraries @@ -126,3 +137,7 @@ cp %{SOURCE3} %{buildroot}%{_sysconfdir}/dbus-1/system.d/zigbee.conf %{_includedir}/zigbee/common/*.h %{_libdir}/pkgconfig/zigbee-lib.pc %{_libdir}/libzigbee-lib.so + +%files haltests +%manifest %{name}.manifest +%{_bindir}/*hal_tc -- 2.7.4 From c90d6dd75b75307a5fcfc4fe0459a9bff9edf1a0 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Mon, 20 Aug 2018 11:38:21 +0900 Subject: [PATCH 15/16] Changed HAL test binary name to accordance with HAL test RPM package name. Change-Id: I4113b88f864b70c6740575b2bd611c93c5b3a0df Signed-off-by: saerome.kim --- haltest/CMakeLists.txt | 2 +- haltest/{zigbee_manager_hal_tc.cpp => zigbee-manager-haltests.cpp} | 0 packaging/zigbee-manager.spec | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename haltest/{zigbee_manager_hal_tc.cpp => zigbee-manager-haltests.cpp} (100%) diff --git a/haltest/CMakeLists.txt b/haltest/CMakeLists.txt index 2c081de..eb284f6 100644 --- a/haltest/CMakeLists.txt +++ b/haltest/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(gtest-haltest-zigbee-manager C CXX) -SET(HALTEST "zigbee_manager_hal_tc") +SET(HALTEST "zigbee-manager-haltests") ADD_DEFINITIONS("-DUSE_DLOG") SET(REQUIRES_LIST ${REQUIRES_LIST} diff --git a/haltest/zigbee_manager_hal_tc.cpp b/haltest/zigbee-manager-haltests.cpp similarity index 100% rename from haltest/zigbee_manager_hal_tc.cpp rename to haltest/zigbee-manager-haltests.cpp diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 479dacb..b253dce 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -140,4 +140,4 @@ cp %{SOURCE3} %{buildroot}%{_sysconfdir}/dbus-1/system.d/zigbee.conf %files haltests %manifest %{name}.manifest -%{_bindir}/*hal_tc +%{_bindir}/*haltests -- 2.7.4 From 36a8adbcfc117933995e59b8c82c73fd11dc3e14 Mon Sep 17 00:00:00 2001 From: "saerome.kim" Date: Mon, 20 Aug 2018 16:07:37 +0900 Subject: [PATCH 16/16] Check the feature in order to execute HAL accordance with the feature. Change-Id: Ic4cbc0c66a8c70c2dd02a7a9b7811a0984f2f22b Signed-off-by: saerome.kim --- haltest/zigbee-manager-haltests.cpp | 38 +++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/haltest/zigbee-manager-haltests.cpp b/haltest/zigbee-manager-haltests.cpp index 52de0dd..810047d 100644 --- a/haltest/zigbee-manager-haltests.cpp +++ b/haltest/zigbee-manager-haltests.cpp @@ -24,22 +24,26 @@ #include "zbl.h" -#define FEATURE_ZIGBEE "http://tizen.org/feature/network.zigbee" -static bool g_bFeatureZb = false; - using ::testing::InitGoogleTest; using ::testing::Test; using ::testing::TestCase; -static bool __check_feature_supported(char *key) -{ - bool value = false; - int ret = system_info_get_platform_bool(key, &value); +const char *feature_name = (char *)"http://tizen.org/feature/network.zigbee"; - EXPECT_EQ(SYSTEM_INFO_ERROR_NONE, ret) << "system_info_get_platform_bool failed"; - EXPECT_EQ(true, value) << key << " feature is not supported"; +static bool __check_feature_supported() +{ + bool zigbee_supported = FALSE; + if (!system_info_get_platform_bool(feature_name, &zigbee_supported)) { + if (FALSE == zigbee_supported) { + GLOGD("zigbee feature is disabled"); + return ZIGBEE_ERROR_NOT_SUPPORTED; + } + return ZIGBEE_ERROR_NONE; + } else { + GLOGD("Error - Feature getting from System Info"); + return ZIGBEE_ERROR_INVALID_PARAMETER; + } - return value; } /* @@ -57,13 +61,12 @@ static bool __check_feature_supported(char *key) */ TEST(ZigbeeManager, Enable_p) { - g_bFeatureZb = __check_feature_supported((char*)FEATURE_ZIGBEE); - ASSERT_EQ(true, g_bFeatureZb) << FEATURE_ZIGBEE << " feature is not supported"; - int ret = ZIGBEE_ERROR_NONE; Zigbee zb_mgr; - ret = zb_mgr.zbl_enable(); + if (ZIGBEE_ERROR_NONE == __check_feature_supported()) { + ret = zb_mgr.zbl_enable(); + } EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); } @@ -82,13 +85,12 @@ TEST(ZigbeeManager, Enable_p) */ TEST(ZigbeeManager, Disable_p) { - g_bFeatureZb = __check_feature_supported((char*)FEATURE_ZIGBEE); - ASSERT_EQ(true, g_bFeatureZb) << FEATURE_ZIGBEE << " feature is not supported"; - int ret = ZIGBEE_ERROR_NONE; Zigbee zb_mgr; - ret = zb_mgr.zbl_disable(); + if (ZIGBEE_ERROR_NONE == __check_feature_supported()) { + ret = zb_mgr.zbl_disable(); + } EXPECT_EQ(ZIGBEE_ERROR_NONE, ret); } -- 2.7.4