From aaab269d8da22d4e6079408af6b5365364f8af10 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Mon, 13 Feb 2017 17:03:39 +0900 Subject: [PATCH 01/16] Fix issue with scene cluster - Fix data receiving logic Change-Id: Iaa7e84733a3c41e9b91d54cfafd30d09afce0d4d Signed-off-by: Jiwan Kim --- .../zigbee-interface/src/zigbee_service_dbus_interface_zcl_scene.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 dc57f00..079b927 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 @@ -93,6 +93,7 @@ static gboolean on_zcl_scene_add_scene(ZigbeeZcl_scene *zcl_scene_object, GVariantIter *iter = NULL; gint i = 0; + unsigned char value = 0; gboolean ret; @@ -105,7 +106,7 @@ static gboolean on_zcl_scene_add_scene(ZigbeeZcl_scene *zcl_scene_object, req.scene_id = scene_id; req.transition_time = transition_time; g_variant_get(scene_name, "a(y)", &iter); - while (g_variant_iter_loop(iter, "(y)", req.scene_name[i])) { + while (g_variant_iter_loop(iter, "(y)", &(req.scene_name[i]))) { i++; if (i >= ZIGBEE_ZCL_GROUP_NAME_MAX_LEN + 1) break; @@ -115,7 +116,8 @@ static gboolean on_zcl_scene_add_scene(ZigbeeZcl_scene *zcl_scene_object, req.ext_field_set_len = ext_length; req.ext_field_set = g_malloc0(ext_length); g_variant_get(ext_field_set, "a(y)", &iter); - while (g_variant_iter_loop(iter, "(y)", req.ext_field_set[i])) { + while (g_variant_iter_loop(iter, "(y)", &value)) { + req.ext_field_set[i] = value; i++; if (i >= ext_length) break; -- 2.7.4 From 6e92e71439f69bcb36c1088cff1a0edb3ddc0999 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Tue, 14 Feb 2017 17:33:25 +0900 Subject: [PATCH 02/16] Change 'enable' method to async operation - 'enable' method is used to execute zigbee daemon on demand. - Its synchronous operation may cause unexpected gvariant crash, change this function to act asynchronously. Change-Id: I3bd9ce51eb4c0642e7b201d58dca46416529846e Signed-off-by: Jiwan Kim --- packaging/org.tizen.zigbee.service | 6 + packaging/zigbee-manager.spec | 19 ++- zigbee-daemon/CMakeLists.txt | 3 +- zigbee-daemon/resources/zigbee-daemon.service | 6 +- .../zigbee-interface/introspection/manager.xml | 5 + .../zigbee-interface/introspection/service.xml | 7 - .../src/zigbee_service_dbus_interface.c | 72 ++++++++-- .../src/zigbee_service_dbus_interface_service.c | 156 --------------------- .../zigbee-lib/include/zblib_driver_service.h | 6 +- .../zigbee-lib/src/drivers/zblib_driver_service.c | 16 --- zigbee-daemon/zigbee-lib/src/zblib_request.c | 18 --- 11 files changed, 90 insertions(+), 224 deletions(-) create mode 100644 packaging/org.tizen.zigbee.service diff --git a/packaging/org.tizen.zigbee.service b/packaging/org.tizen.zigbee.service new file mode 100644 index 0000000..7471288 --- /dev/null +++ b/packaging/org.tizen.zigbee.service @@ -0,0 +1,6 @@ +[D-BUS Service] +Name=org.tizen.zigbee + +Exec=/bin/false +User=system +SystemdService=zigbee-daemon.service diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 3f04f55..2082223 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -9,6 +9,7 @@ License: Apache-2.0 Summary: ZigBee Daemon Group: System/Network Source0: %{name}-%{version}.tar.gz +Source1: org.tizen.zigbee.service BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(gio-2.0) @@ -39,6 +40,9 @@ ZigBee library (devel) %prep %setup -q +chmod 644 %{SOURCE1} +cp -a %{SOURCE1} . + %build cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=%{version} \ @@ -48,9 +52,11 @@ make %{?_smp_mflags} %make_install -# For debug, do not execute zigbee daemon automatically. -#mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants -#ln -s %{_libdir}/systemd/system/zigbee-daemon.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service +mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants +ln -s %{_libdir}/systemd/system/zigbee-daemon.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service + +mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ +cp org.tizen.zigbee.service %{buildroot}%{_datadir}/dbus-1/system-services/org.tizen.zigbee.service %post -p /sbin/ldconfig @@ -60,13 +66,12 @@ make %{?_smp_mflags} %manifest zigbee-daemon.manifest %defattr(644,system,system,-) %attr(755,system,system) %{_bindir}/zigbee-daemon -# For debug, do not execute zigbee daemon automatically. -#%{_libdir}/systemd/system/zigbee-daemon.service -#%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service +%{_libdir}/systemd/system/zigbee-daemon.service +%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service %{_datadir}/license/zigbee-daemon +%attr(644,root,root) %{_datadir}/dbus-1/system-services/* %files -n zigbee-lib -#%manifest lib-zigbee/lib-zigbee.manifest %defattr(644,system,system,-) %{_libdir}/libzigbee-lib.so* %{_datadir}/license/zigbee-lib diff --git a/zigbee-daemon/CMakeLists.txt b/zigbee-daemon/CMakeLists.txt index 9f2d703..4ac2665 100644 --- a/zigbee-daemon/CMakeLists.txt +++ b/zigbee-daemon/CMakeLists.txt @@ -104,5 +104,4 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} zigbee-service zigbee-interface ${pkgs_LDF INSTALL(TARGETS zigbee-lib DESTINATION lib COMPONENT Runtime) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME zigbee-daemon) -# For debug, do not execute zigbee daemon automatically. -#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/zigbee-daemon.service DESTINATION /usr/lib/systemd/system) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/zigbee-daemon.service DESTINATION /usr/lib/systemd/system) diff --git a/zigbee-daemon/resources/zigbee-daemon.service b/zigbee-daemon/resources/zigbee-daemon.service index 8e79fe2..242225d 100644 --- a/zigbee-daemon/resources/zigbee-daemon.service +++ b/zigbee-daemon/resources/zigbee-daemon.service @@ -1,12 +1,16 @@ [Unit] Description=ZigBee daemon +Requires=dbus.socket +After=dbus.socket [Service] +Type=dbus +BusName=org.tizen.zigbee User=system Group=system SmackProcessLabel=System ExecStart=/usr/bin/zigbee-daemon -Restart=always +Restart=on-failure RestartSec=0 KillMode=none diff --git a/zigbee-daemon/zigbee-interface/introspection/manager.xml b/zigbee-daemon/zigbee-interface/introspection/manager.xml index 30f16a1..520977a 100644 --- a/zigbee-daemon/zigbee-interface/introspection/manager.xml +++ b/zigbee-daemon/zigbee-interface/introspection/manager.xml @@ -4,6 +4,11 @@ + + + + + diff --git a/zigbee-daemon/zigbee-interface/introspection/service.xml b/zigbee-daemon/zigbee-interface/introspection/service.xml index a5d79cf..d4c9752 100644 --- a/zigbee-daemon/zigbee-interface/introspection/service.xml +++ b/zigbee-daemon/zigbee-interface/introspection/service.xml @@ -1,12 +1,5 @@ - - - - - - - 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 b49633f..b7a6016 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c @@ -34,19 +34,56 @@ /**< ZigBee D-BUS service interface name */ #define ZIGBEE_DBUS_SERVICE_INTERFACE_NAME "zigbee-dbus" -static gboolean zigbee_on_manager_get_zigbee_state(ZigbeeManager *zigbee_mgr, +static gboolean on_manager_enable(ZigbeeManager *zigbee_mgr, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data; + ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface); + + if (NULL == custom_data) { + ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + + return TRUE; + } + + zigbee_manager_complete_enable(zigbee_mgr, invocation); + + if (TRUE == custom_data->sevice_interface_init_complete) { + /* Emit zigbee_state - enabled */ + zigbee_manager_emit_zigbee_state(zigbee_mgr, TRUE); + } + + return TRUE; +} + +static gboolean on_manager_disable(ZigbeeManager *zigbee_mgr, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + NOT_USED(user_data); + + zigbee_manager_complete_disable(zigbee_mgr, invocation, TRUE); + + return TRUE; +} + +static gboolean on_manager_get_zigbee_state(ZigbeeManager *zigbee_mgr, GDBusMethodInvocation *invocation, gpointer user_data) { + ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data; + ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface); + Z_LOGI("Entered"); - NOT_USED(zigbee_mgr); - NOT_USED(invocation); - NOT_USED(user_data); + if (NULL == custom_data) { + ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); - /* - * TODO - - * Create and send request for processing - */ + return TRUE; + } + + zigbee_manager_complete_get_zigbee_state(zigbee_mgr, invocation, + 0, custom_data->sevice_interface_init_complete); return TRUE; } @@ -288,7 +325,8 @@ static void zigbee_on_name_acquired(GDBusConnection *connection, custom_data->name_acquired = TRUE; if (TRUE == custom_data->sevice_interface_init_complete) { - /* TODO - Emit zigbee_state signal */ + /* Emit zigbee_state - enabled */ + zigbee_manager_emit_zigbee_state(custom_data->zigbee_mgr, TRUE); } } @@ -330,8 +368,18 @@ static void zigbee_on_bus_acquired(GDBusConnection *connection, */ g_signal_connect(custom_data->zigbee_mgr, "handle-get-zigbee-state", - G_CALLBACK(zigbee_on_manager_get_zigbee_state), - custom_data); + G_CALLBACK(on_manager_get_zigbee_state), + service_interface); + + g_signal_connect(custom_data->zigbee_mgr, + "handle-enable", + G_CALLBACK(on_manager_enable), + service_interface); + + g_signal_connect(custom_data->zigbee_mgr, + "handle-disable", + G_CALLBACK(on_manager_disable), + service_interface); /* * Export 'manager' interface on ZigBee D-BUS @@ -377,7 +425,7 @@ static void zigbee_on_bus_acquired(GDBusConnection *connection, g_dbus_object_manager_server_export(custom_data->manager, G_DBUS_OBJECT_SKELETON(zigbee_object)); - /* Servcie interface initialization completed */ + /* Service interface initialization completed */ custom_data->sevice_interface_init_complete = TRUE; if (TRUE == custom_data->name_acquired) { 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 544cd83..108a923 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 @@ -43,154 +43,6 @@ static void *_service_interface_ref_zigbee_service(ZigBeeServiceInterface *servi return service; } -static void on_service_enable_resp(ZigBeeServiceInterface *service_interface, - guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data) -{ - ZigbeeServiceInterfaceRespCbData_t *cb_data = - (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data; - - ZigbeeService *service_object; - GDBusMethodInvocation *invocation; - ZigbeeServiceServiceStateResp_t *payload = - (ZigbeeServiceServiceStateResp_t*)resp_data; - - NOT_USED(service_interface); - NOT_USED(request_id); - - if (NULL == resp_data || 0 == resp_data_len) { - Z_LOGE("resp_data is null"); - g_free(cb_data); - return; - } - - service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data); - zblib_check_null_free_and_ret("service_object", service_object, cb_data); - - invocation = zigbee_service_dbus_interface_ref_invocation(cb_data); - zblib_check_null_free_and_ret("invocation", invocation, cb_data); - - zigbee_service_complete_enable(service_object, invocation, - payload->result, payload->enabled); - - g_free(cb_data); -} - -static gboolean on_service_enable(ZigbeeService *service_object, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data; - ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL; - - gboolean ret; - - /* Allocate response callback data */ - resp_cb_data = - zigbee_service_dbus_interface_create_resp_cb_data(service_object, - invocation, NULL, 0); - if (NULL == resp_cb_data) { - Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!"); - - /* Send failure response */ - ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); - - return TRUE; - } - - /* Dispatch request */ - ret = zigbee_service_dbus_interface_dispatch_request(service_interface, - ZBLIB_DRIVER_TYPE_SERVICE, - ZBLIB_SERVICE_OPS_ENABLE, - NULL, 0, - on_service_enable_resp, resp_cb_data); - if (FALSE == ret) { - Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); - - /* Free response callback data */ - zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data); - - /* Send failure response */ - ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); - - return TRUE; - } - - return TRUE; -} - -static void on_service_disable_resp(ZigBeeServiceInterface *service_interface, - guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data) -{ - ZigbeeServiceInterfaceRespCbData_t *cb_data = - (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data; - - ZigbeeService *service_object; - GDBusMethodInvocation *invocation; - ZigbeeGeneralResp_t *payload = (ZigbeeGeneralResp_t*)resp_data; - - NOT_USED(service_interface); - NOT_USED(request_id); - - if (NULL == resp_data || 0 == resp_data_len) { - Z_LOGE("resp_data is null"); - g_free(cb_data); - return; - } - - service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data); - zblib_check_null_free_and_ret("service_object", service_object, cb_data); - - invocation = zigbee_service_dbus_interface_ref_invocation(cb_data); - zblib_check_null_free_and_ret("invocation", invocation, cb_data); - - zigbee_service_complete_disable(service_object, invocation, payload->result); - - g_free(cb_data); -} - -static gboolean on_service_disable(ZigbeeService *service_object, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data; - ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL; - - gboolean ret; - - /* Allocate response callback data */ - resp_cb_data = - zigbee_service_dbus_interface_create_resp_cb_data(service_object, - invocation, NULL, 0); - if (NULL == resp_cb_data) { - Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!"); - - /* Send failure response */ - ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); - - return TRUE; - } - - /* Dispatch request */ - ret = zigbee_service_dbus_interface_dispatch_request(service_interface, - ZBLIB_DRIVER_TYPE_SERVICE, - ZBLIB_SERVICE_OPS_DISABLE, - NULL, 0, - on_service_disable_resp, resp_cb_data); - if (FALSE == ret) { - Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); - - /* Free response callback data */ - zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data); - - /* Send failure response */ - ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); - - return TRUE; - } - - return TRUE; -} - static void on_service_zb_hw_reset_resp(ZigBeeServiceInterface *service_interface, guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data) { @@ -1477,14 +1329,6 @@ gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *serv * Register signal handlers for 'service' interface */ g_signal_connect(service_object, - "handle-enable", - G_CALLBACK(on_service_enable), service_interface); - - g_signal_connect(service_object, - "handle-disable", - G_CALLBACK(on_service_disable), service_interface); - - g_signal_connect(service_object, "handle-zb-hw-reset", G_CALLBACK(on_service_zb_hw_reset), service_interface); diff --git a/zigbee-daemon/zigbee-lib/include/zblib_driver_service.h b/zigbee-daemon/zigbee-lib/include/zblib_driver_service.h index d5af5ef..21f31c6 100644 --- a/zigbee-daemon/zigbee-lib/include/zblib_driver_service.h +++ b/zigbee-daemon/zigbee-lib/include/zblib_driver_service.h @@ -21,8 +21,6 @@ /**< ZigBee 'service' driver operations */ typedef struct { - gboolean (*enable)(ZigBeeDriver *driver, guint request_id); - gboolean (*disable)(ZigBeeDriver *driver, guint request_id); gboolean (*zb_hw_reset)(ZigBeeDriver *driver, guint request_id); gboolean (*form_network)(ZigBeeDriver *driver, guint request_id); gboolean (*coex_start)(ZigBeeDriver *driver, guint request_id); @@ -41,9 +39,7 @@ typedef struct { /**< ZigBee 'service' ops IDs */ typedef enum { - ZBLIB_SERVICE_OPS_ENABLE = 1, /**< Enable */ - ZBLIB_SERVICE_OPS_DISABLE, /**< Disable */ - ZBLIB_SERVICE_OPS_ZB_HW_RESET, /**< Zb hw reset */ + ZBLIB_SERVICE_OPS_ZB_HW_RESET = 1, /**< Zb hw reset */ ZBLIB_SERVICE_OPS_FORM_NETWORK, /**< Form network */ ZBLIB_SERVICE_OPS_COEX_START, /**< Coex start */ ZBLIB_SERVICE_OPS_COEX_STOP, /**< Coex stop */ 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 f50ba4c..1659dc2 100644 --- a/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_service.c +++ b/zigbee-daemon/zigbee-lib/src/drivers/zblib_driver_service.c @@ -56,22 +56,6 @@ static gboolean __zblib_driver_service_dispatcher(ZigBeeDriver *driver, guint re /* Fetch ops ID */ ops_id = zblib_request_get_ops_id(request_type); switch (ops_id) { - case ZBLIB_SERVICE_OPS_ENABLE: { - zblib_check_null_ret_error("ops->enable", - ops->enable, FALSE); - - ret = ops->enable(driver, request_id); - } - break; - - case ZBLIB_SERVICE_OPS_DISABLE: { - zblib_check_null_ret_error("ops->disable", - ops->disable, FALSE); - - ret = ops->disable(driver, request_id); - } - break; - case ZBLIB_SERVICE_OPS_ZB_HW_RESET: { zblib_check_null_ret_error("ops->zb_hw_reset", ops->zb_hw_reset, FALSE); diff --git a/zigbee-daemon/zigbee-lib/src/zblib_request.c b/zigbee-daemon/zigbee-lib/src/zblib_request.c index 14c05da..b3c314f 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_request.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_request.c @@ -1137,16 +1137,6 @@ static gpointer __zblib_request_create_service_request_data(guint request_type, /* Fetch ops ID */ ops_id = __zblib_request_get_ops_id(request_type); switch (ops_id) { - case ZBLIB_SERVICE_OPS_ENABLE: { - service_request_data = NULL; - } - break; - - case ZBLIB_SERVICE_OPS_DISABLE: { - service_request_data = NULL; - } - break; - case ZBLIB_SERVICE_OPS_ZB_HW_RESET: { service_request_data = NULL; } @@ -3615,14 +3605,6 @@ static void __zblib_request_free_service_request_data(ZigBeeRequest *request, /* Fetch ops ID */ ops_id = __zblib_request_get_ops_id(request_type); switch (ops_id) { - case ZBLIB_SERVICE_OPS_ENABLE: { - } - break; - - case ZBLIB_SERVICE_OPS_DISABLE: { - } - break; - case ZBLIB_SERVICE_OPS_ZB_HW_RESET: { } break; -- 2.7.4 From 986877ce089078cc04996cddc54bed1c19e4398c Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Wed, 15 Feb 2017 11:07:06 +0900 Subject: [PATCH 03/16] Change 'disable' method logic - If 'disable' method called, daemon terminates itself. - Fix unexpected related crash issue related. Change-Id: I0207e7466f99cc93fb9389c4b572158f9eb392d2 Signed-off-by: Jiwan Kim --- .../src/zigbee_service_dbus_interface.c | 6 ++++++ zigbee-daemon/zigbee-lib/include/zblib_plugin.h | 1 + zigbee-daemon/zigbee-lib/src/zblib_driver.c | 7 ++++--- zigbee-daemon/zigbee-lib/src/zblib_plugin.c | 23 ++++++++++++++++++++++ 4 files changed, 34 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 b7a6016..121d6dc 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c @@ -61,10 +61,16 @@ static gboolean on_manager_disable(ZigbeeManager *zigbee_mgr, GDBusMethodInvocation *invocation, gpointer user_data) { + ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data; + ZigBeeService *service = zblib_service_interface_ref_service(service_interface); + NOT_USED(user_data); zigbee_manager_complete_disable(zigbee_mgr, invocation, TRUE); + if (service) + zblib_service_exit(service); + return TRUE; } diff --git a/zigbee-daemon/zigbee-lib/include/zblib_plugin.h b/zigbee-daemon/zigbee-lib/include/zblib_plugin.h index bf12e14..c901a96 100644 --- a/zigbee-daemon/zigbee-lib/include/zblib_plugin.h +++ b/zigbee-daemon/zigbee-lib/include/zblib_plugin.h @@ -43,6 +43,7 @@ ZigBeeService *zblib_plugin_ref_service(ZigBeePlugin *plugin); ZigBeeDriver *zblib_plugin_ref_driver(ZigBeePlugin *plugin, ZblibDriverType_e driver_type); void zblib_plugin_link_driver(ZigBeePlugin *plugin, ZigBeeDriver *driver); +void zblib_plugin_unlink_driver(ZigBeePlugin *plugin, ZblibDriverType_e driver_type); gboolean zblib_plugin_dispatch_request(ZigBeePlugin *plugin, guint request_id); diff --git a/zigbee-daemon/zigbee-lib/src/zblib_driver.c b/zigbee-daemon/zigbee-lib/src/zblib_driver.c index 1389aaf..5032997 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_driver.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_driver.c @@ -63,7 +63,7 @@ void zblib_driver_free(ZigBeeDriver *driver) if (driver->free_hook_fn) driver->free_hook_fn(driver); - Z_LOGI("Freeing Driver - Name [%p]", driver->driver_name); + Z_LOGI("Freeing Driver[%p] - Name [%s]", driver, driver->driver_name); /* Free driver memory */ g_free(driver->driver_name); @@ -134,8 +134,9 @@ gboolean zblib_driver_set_free_hook(ZigBeeDriver *driver, ZblibDriverType_e zblib_driver_ref_driver_type(ZigBeeDriver *driver) { - zblib_check_null_ret_error("driver", - driver, ZBLIB_DRIVER_TYPE_NONE); + if (NULL == driver) { + return ZBLIB_DRIVER_TYPE_NONE; + } return driver->driver_type; } diff --git a/zigbee-daemon/zigbee-lib/src/zblib_plugin.c b/zigbee-daemon/zigbee-lib/src/zblib_plugin.c index 9ec5ae6..d8ce3a9 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_plugin.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_plugin.c @@ -149,6 +149,29 @@ void zblib_plugin_link_driver(ZigBeePlugin *plugin, ZigBeeDriver *driver) Z_LOGD("Driver appended into plugin [%s]", plugin->plugin_name); } +void zblib_plugin_unlink_driver(ZigBeePlugin *plugin, ZblibDriverType_e driver_type) +{ + ZblibDriverType_e _driver_type; + GSList *list = NULL; + + zblib_check_null_ret("plugin", plugin); + + list = plugin->driver_list; + while (list) { + /* Fetch driver type of driver */ + _driver_type = zblib_driver_ref_driver_type((ZigBeeDriver *)(list->data)); + if (_driver_type == driver_type) { + /* Driver found */ + Z_LOGD("Driver[%p] removed from plugin", list->data); + list->data = NULL; + break; + } + + /* Move to next driver */ + list = g_slist_next(list); + } +} + gboolean zblib_plugin_dispatch_request(ZigBeePlugin *plugin, guint request_id) { -- 2.7.4 From eafaa5a26abfa93fa393ec08a75f4866be662f55 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Wed, 15 Feb 2017 20:16:53 +0900 Subject: [PATCH 04/16] Fix return value of disable method Change-Id: I59b4aab30a067617bdd5a5d82c9999caf6f4d3ab Signed-off-by: Jiwan Kim --- zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 121d6dc..5d790dd 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c @@ -66,7 +66,7 @@ static gboolean on_manager_disable(ZigbeeManager *zigbee_mgr, NOT_USED(user_data); - zigbee_manager_complete_disable(zigbee_mgr, invocation, TRUE); + zigbee_manager_complete_disable(zigbee_mgr, invocation, 0); if (service) zblib_service_exit(service); -- 2.7.4 From 55ef13f1d4b4d4d9b3c384987cfbecd7275d9778 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Thu, 16 Feb 2017 13:18:48 +0900 Subject: [PATCH 05/16] Change dbus auto activation bus name - Currently, zb_create() registers dbus signal but it makes daemon activated. - Change only 'enable' method can execute daemon. Change-Id: I7bf25df517f2393d95af87c164ae9e69cecc389d Signed-off-by: Jiwan Kim --- packaging/org.tizen.zigbee.service | 2 +- packaging/zigbee-manager.spec | 7 ++++--- zigbee-daemon/resources/zigbee-daemon.service | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packaging/org.tizen.zigbee.service b/packaging/org.tizen.zigbee.service index 7471288..129767e 100644 --- a/packaging/org.tizen.zigbee.service +++ b/packaging/org.tizen.zigbee.service @@ -1,5 +1,5 @@ [D-BUS Service] -Name=org.tizen.zigbee +Name=org.tizen.zigbee.manager Exec=/bin/false User=system diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 2082223..307bdc8 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -52,8 +52,9 @@ make %{?_smp_mflags} %make_install -mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants -ln -s %{_libdir}/systemd/system/zigbee-daemon.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service +# Do not execute daemon on boot time +#mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants +#ln -s %{_libdir}/systemd/system/zigbee-daemon.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ cp org.tizen.zigbee.service %{buildroot}%{_datadir}/dbus-1/system-services/org.tizen.zigbee.service @@ -67,7 +68,7 @@ cp org.tizen.zigbee.service %{buildroot}%{_datadir}/dbus-1/system-services/org.t %defattr(644,system,system,-) %attr(755,system,system) %{_bindir}/zigbee-daemon %{_libdir}/systemd/system/zigbee-daemon.service -%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service +#%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service %{_datadir}/license/zigbee-daemon %attr(644,root,root) %{_datadir}/dbus-1/system-services/* diff --git a/zigbee-daemon/resources/zigbee-daemon.service b/zigbee-daemon/resources/zigbee-daemon.service index 242225d..5353556 100644 --- a/zigbee-daemon/resources/zigbee-daemon.service +++ b/zigbee-daemon/resources/zigbee-daemon.service @@ -5,7 +5,7 @@ After=dbus.socket [Service] Type=dbus -BusName=org.tizen.zigbee +BusName=org.tizen.zigbee.manager User=system Group=system SmackProcessLabel=System -- 2.7.4 From f3ab52b0ed845dc2e826aa091b79004151a7e6f3 Mon Sep 17 00:00:00 2001 From: saerome kim Date: Fri, 17 Feb 2017 11:07:05 +0900 Subject: [PATCH 06/16] Add getting ownwership of 'org.tizen.zigbee.manager' for D-Bus activation Change-Id: Iaad9e82dfaf21168a1b5651af8d219f5f5150295 Signed-off-by: saerome kim --- .../src/zigbee_service_dbus_interface.c | 28 ++++++++++++++++++++++ .../src/zigbee_service_interface_common.h | 1 + 2 files changed, 29 insertions(+) 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 5d790dd..3f729d5 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c @@ -442,6 +442,20 @@ OUT: g_free(path); } +static void zigbee_get_activation_sbus(ZigbeeCustomData_t *interface_data) +{ + /* Get D-Bus owner to activate zigbee-daemon */ + interface_data->activation_dbus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, + ZIGBEE_DBUS_SERVICE".manager", + G_BUS_NAME_OWNER_FLAGS_REPLACE, + NULL, + NULL, + NULL, + NULL, + NULL); + Z_LOGI("ZigBee D-BUS activation ID: [%d]", interface_data->activation_dbus_id); +} + /**< Zigbee service dbus interface initialization */ gboolean zigbee_service_dbus_interface_init(ZigBeeService *service) { @@ -508,6 +522,11 @@ gboolean zigbee_service_dbus_interface_init(ZigBeeService *service) g_free, NULL); /* + * Acquire "org.tizen.zigbee.manager" named bus on D-BUS SYSTEM bus. + */ + zigbee_get_activation_sbus(interface_data); + + /* * Acquire "org.tizen.zigbee" named bus on D-BUS SYSTEM bus. */ interface_data->bus_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, @@ -573,6 +592,15 @@ void zigbee_service_dbus_interface_deinit(ZigBeeService *service) } /* + * Unown "org.tizen.zigbee.manager" named bus on D-BUS SYSTEM bus + */ + if (interface_data->activation_dbus_id > 0) { + Z_LOGI("Unowning ZigBee Service interface activation D-BUS ID: [%d]", + interface_data->activation_dbus_id); + g_bus_unown_name(interface_data->activation_dbus_id); + } + + /* * Unown "org.tizen.zigbee" named bus on D-BUS SYSTEM bus */ if (interface_data->bus_id > 0) { diff --git a/zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.h b/zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.h index 57f4241..70c9272 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.h +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.h @@ -74,6 +74,7 @@ typedef struct { GHashTable *objects; /**< ZigBee D-BUS object(s) */ gint bus_id; /**< ZigBee D-BUS ID */ + gint activation_dbus_id; /**< Activation D-BUS ID */ gboolean name_acquired; /**< ZigBee D-BUS name acquired */ gboolean sevice_interface_init_complete; /**< ZigBee D-BUS service init completed */ -- 2.7.4 From 229856b4fc53b0bc18e1c0e70c69738674c1b72b Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Wed, 22 Mar 2017 19:38:29 +0900 Subject: [PATCH 07/16] Support privilege check on daemon side Change-Id: I2c6ce0da7276752d04625a251f3644e3c8d11150 Signed-off-by: Jiwan Kim --- packaging/zigbee-manager.spec | 9 +- packaging/zigbee.conf | 368 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 375 insertions(+), 2 deletions(-) create mode 100644 packaging/zigbee.conf diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 307bdc8..f6af1cb 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -10,6 +10,7 @@ Summary: ZigBee Daemon Group: System/Network Source0: %{name}-%{version}.tar.gz Source1: org.tizen.zigbee.service +Source2: zigbee.conf BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(gio-2.0) @@ -42,6 +43,8 @@ ZigBee library (devel) chmod 644 %{SOURCE1} cp -a %{SOURCE1} . +chmod 644 %{SOURCE2} +cp -a %{SOURCE2} . %build cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=%{version} \ @@ -49,7 +52,6 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=%{version} \ make %{?_smp_mflags} %install - %make_install # Do not execute daemon on boot time @@ -57,7 +59,9 @@ make %{?_smp_mflags} #ln -s %{_libdir}/systemd/system/zigbee-daemon.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ -cp org.tizen.zigbee.service %{buildroot}%{_datadir}/dbus-1/system-services/org.tizen.zigbee.service +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.d/zigbee.conf %post -p /sbin/ldconfig @@ -71,6 +75,7 @@ cp org.tizen.zigbee.service %{buildroot}%{_datadir}/dbus-1/system-services/org.t #%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service %{_datadir}/license/zigbee-daemon %attr(644,root,root) %{_datadir}/dbus-1/system-services/* +%{_datadir}/dbus-1/system.d/zigbee.conf %files -n zigbee-lib %defattr(644,system,system,-) diff --git a/packaging/zigbee.conf b/packaging/zigbee.conf new file mode 100644 index 0000000..7080e4d --- /dev/null +++ b/packaging/zigbee.conf @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.7.4 From 2d6956cfe0264531e07aad7391e569eb77daaf55 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Fri, 24 Mar 2017 13:35:05 +0900 Subject: [PATCH 08/16] Add privilege check method - 'check_privilege' method is added for privilege check Change-Id: Ic4508898d95274a069e84ffa445389fc5923652d Signed-off-by: Jiwan Kim --- zigbee-daemon/zigbee-interface/introspection/service.xml | 1 + .../src/zigbee_service_dbus_interface_service.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/zigbee-daemon/zigbee-interface/introspection/service.xml b/zigbee-daemon/zigbee-interface/introspection/service.xml index d4c9752..68cf015 100644 --- a/zigbee-daemon/zigbee-interface/introspection/service.xml +++ b/zigbee-daemon/zigbee-interface/introspection/service.xml @@ -64,6 +64,7 @@ + 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 108a923..9403883 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 @@ -1217,6 +1217,17 @@ static gboolean on_service_get_node_type(ZigbeeService *service_object, return TRUE; } +static gboolean on_service_check_privilege(ZigbeeService *service_object, + GDBusMethodInvocation *invocation, + gpointer user_data) +{ + NOT_USED(user_data); + + zigbee_service_complete_check_privilege(service_object, invocation); + + return TRUE; +} + void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *service_interface, guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data) { @@ -1384,5 +1395,9 @@ gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *serv "handle-get-node-type", G_CALLBACK(on_service_get_node_type), service_interface); + g_signal_connect(service_object, + "handle-check-privilege", + G_CALLBACK(on_service_check_privilege), service_interface); + return TRUE; } -- 2.7.4 From 352eeded64d38344829acb67cdf61184bc6478b6 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Fri, 24 Mar 2017 17:02:43 +0900 Subject: [PATCH 09/16] Adjust privileges for platform APIs - coex_start / stop - aps_send - zcl_send - send_to_local Change-Id: I16ef2ec9fc8d1d73b9668d79c42ec1c486c58fc3 Signed-off-by: Jiwan Kim --- packaging/zigbee.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/zigbee.conf b/packaging/zigbee.conf index 7080e4d..1b7b821 100644 --- a/packaging/zigbee.conf +++ b/packaging/zigbee.conf @@ -44,9 +44,9 @@ + send_member="coex_start" privilege="http://tizen.org/privilege/zigbee.admin"/> + send_member="coex_stop" privilege="http://tizen.org/privilege/zigbee.admin"/> + send_member="aps_send" privilege="http://tizen.org/privilege/zigbee.admin"/> + send_member="zcl_send" privilege="http://tizen.org/privilege/zigbee.admin"/> + send_member="send_to_local" privilege="http://tizen.org/privilege/zigbee.admin"/> -- 2.7.4 From d568797ecbc98b9bbf7d537690c326f88f07424d Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Mon, 3 Apr 2017 15:33:56 +0900 Subject: [PATCH 10/16] Support asynchronous plugin initializer - To support firmware update on plugin initialize time, asynchronous init function is required. - Add support logic for async initializer. Change-Id: Ie8631a62c0fdb97cef87383bf075e3e346880a97 Signed-off-by: Jiwan Kim --- zigbee-daemon/src/main.c | 15 +- .../src/zigbee_service_dbus_interface.c | 47 +++-- zigbee-daemon/zigbee-lib/include/zblib.h | 1 + .../zigbee-lib/include/zblib_driver_manager.h | 27 +++ zigbee-daemon/zigbee-lib/include/zblib_plugin.h | 6 +- zigbee-daemon/zigbee-lib/include/zblib_service.h | 1 + zigbee-daemon/zigbee-lib/src/zblib_service.c | 190 ++++++++++++++++++++- zigbee-daemon/zigbee-service/src/zigbee_service.c | 10 +- 8 files changed, 278 insertions(+), 19 deletions(-) create mode 100644 zigbee-daemon/zigbee-lib/include/zblib_driver_manager.h diff --git a/zigbee-daemon/src/main.c b/zigbee-daemon/src/main.c index 05895ff..78639c3 100644 --- a/zigbee-daemon/src/main.c +++ b/zigbee-daemon/src/main.c @@ -34,6 +34,15 @@ /**< ZigBee Service */ ZigBeeService *zigbee_service; +static gboolean _request_terminate(gpointer user_data) +{ + NOTUSED(user_data); + + zblib_service_exit(zigbee_service); + + return G_SOURCE_REMOVE; +} + int main(int arg, char **argv) { ZigBeeService *service = NULL; @@ -49,8 +58,6 @@ int main(int arg, char **argv) NOTUSED(arg); NOTUSED(argv); - Z_LOGI("service mainloop start"); - /* Create ZigBee service */ zigbee_service = service = zblib_service_new(); @@ -65,10 +72,12 @@ int main(int arg, char **argv) ret = zigbee_service_init(service); if (G_UNLIKELY(FALSE == ret)) { Z_LOGE("zigbee_service_init failed!"); - goto END; + /* Minimum mainloop time is required to notify the result */ + g_timeout_add(100, _request_terminate, NULL); } /* Run ZigBee service */ + Z_LOGI("service mainloop start"); ret = zblib_service_run(service); if (G_UNLIKELY(FALSE == ret)) { Z_LOGE("Run service failed!"); 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 3f729d5..97111d9 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "zigbee_service_interface.h" #include "zigbee_service_interface_common.h" @@ -34,6 +35,26 @@ /**< ZigBee D-BUS service interface name */ #define ZIGBEE_DBUS_SERVICE_INTERFACE_NAME "zigbee-dbus" +static void _notify_zigbee_state(ZigBeeServiceInterface *service_interface, + gboolean result) +{ + ZigbeeCustomData_t *custom_data = zblib_service_interface_ref_user_data(service_interface); + ZigBeeService *service = zblib_service_interface_ref_service(service_interface); + + if (NULL == custom_data) { + Z_LOGE("Unexpected invalid parameter !"); + return; + } + + if (result) { + /* Notify zigbee service manually here (Enabled) */ + zigbee_manager_emit_zigbee_state(custom_data->zigbee_mgr, result); + } else { + /* ZigBee state will be emitted on bus termination */ + zblib_service_exit(service); + } +} + static gboolean on_manager_enable(ZigbeeManager *zigbee_mgr, GDBusMethodInvocation *invocation, gpointer user_data) @@ -49,11 +70,6 @@ static gboolean on_manager_enable(ZigbeeManager *zigbee_mgr, zigbee_manager_complete_enable(zigbee_mgr, invocation); - if (TRUE == custom_data->sevice_interface_init_complete) { - /* Emit zigbee_state - enabled */ - zigbee_manager_emit_zigbee_state(zigbee_mgr, TRUE); - } - return TRUE; } @@ -291,6 +307,18 @@ static void zigbee_service_dbus_interface_noti_cb(ZigBeeServiceInterface *servic } break; + case ZBLIB_DRIVER_TYPE_MANAGER: { + /* Handle 'enabled' notification here */ + if (notification_id == ZBLIB_MANAGER_NOTI_ZIGBEE_ENABLED) { + gboolean *rsp = (gboolean*)noti_data; + + Z_LOGD("Firmware update result : [%s]", ((*rsp) ? "Succeed" : "Failed")); + _notify_zigbee_state(service_interface, *rsp); + } else + Z_LOGE("Unhandled notification id: [%d]", notification_id); + } + break; + case ZBLIB_DRIVER_TYPE_NONE: /* Fall through */ default: { Z_LOGE("Unhandled driver type: [%d]", driver_type); @@ -329,11 +357,6 @@ static void zigbee_on_name_acquired(GDBusConnection *connection, /* Bus name is 'acquired' */ custom_data->name_acquired = TRUE; - - if (TRUE == custom_data->sevice_interface_init_complete) { - /* Emit zigbee_state - enabled */ - zigbee_manager_emit_zigbee_state(custom_data->zigbee_mgr, TRUE); - } } static void zigbee_on_bus_acquired(GDBusConnection *connection, @@ -591,6 +614,10 @@ void zigbee_service_dbus_interface_deinit(ZigBeeService *service) goto EXIT; } + /* Emit zigbee_state - disabled */ + Z_LOGD("Update zigbee_state ----"); + zigbee_manager_emit_zigbee_state(interface_data->zigbee_mgr, FALSE); + /* * Unown "org.tizen.zigbee.manager" named bus on D-BUS SYSTEM bus */ diff --git a/zigbee-daemon/zigbee-lib/include/zblib.h b/zigbee-daemon/zigbee-lib/include/zblib.h index d439aa5..2fc35ac 100644 --- a/zigbee-daemon/zigbee-lib/include/zblib.h +++ b/zigbee-daemon/zigbee-lib/include/zblib.h @@ -61,6 +61,7 @@ typedef struct zblib_request_type ZigBeeRequest; /**< ZigBee driver types */ typedef enum { ZBLIB_DRIVER_TYPE_NONE, /**< None */ + ZBLIB_DRIVER_TYPE_MANAGER, /**< Manager */ ZBLIB_DRIVER_TYPE_SERVICE, /**< Service */ ZBLIB_DRIVER_TYPE_ZDO_DEV_CONTROL, /**< ZDO Dev control */ ZBLIB_DRIVER_TYPE_ZDO_BIND, /**< ZDO bind */ diff --git a/zigbee-daemon/zigbee-lib/include/zblib_driver_manager.h b/zigbee-daemon/zigbee-lib/include/zblib_driver_manager.h new file mode 100644 index 0000000..5b5bafa --- /dev/null +++ b/zigbee-daemon/zigbee-lib/include/zblib_driver_manager.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Suresh Kumar N (suresh.n@samsung.com) + * + * 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_LIB_DRIVER_MANAGER_H__ +#define __ZIGBEE_LIB_DRIVER_MANAGER_H__ + +/**< ZigBee 'Manager' notification IDs */ +typedef enum { + ZBLIB_MANAGER_NOTI_ZIGBEE_ENABLED = 1, /**< Zigbee enabled */ +} ZblibManagerNoti_e; + +#endif /* __ZIGBEE_LIB_DRIVER_MANAGER_H__ */ diff --git a/zigbee-daemon/zigbee-lib/include/zblib_plugin.h b/zigbee-daemon/zigbee-lib/include/zblib_plugin.h index c901a96..cd77d97 100644 --- a/zigbee-daemon/zigbee-lib/include/zblib_plugin.h +++ b/zigbee-daemon/zigbee-lib/include/zblib_plugin.h @@ -19,13 +19,17 @@ #ifndef __ZIGBEE_LIB_PLUGIN_H__ #define __ZIGBEE_LIB_PLUGIN_H__ +/**< ZigBee plug-in asynchronous initializer callback */ +typedef void (*zblib_plugin_init_finished_cb)(gboolean result, void *user_data); + /**< ZigBee plug-in descriptor */ typedef struct { const gchar *name; int version; - gboolean (*is_implemented)(); /**< Is plug-in implemented */ gboolean (*load)(); /**< Load plugin */ gboolean (*init)(ZigBeePlugin *); /**< Initialize plugin */ + gboolean (*init_async)(ZigBeePlugin *, zblib_plugin_init_finished_cb, void *); + /**< Initialize plugin asynchronously */ void (*unload)(ZigBeePlugin *); /**< Unload plugin */ } ZblibPluginDescriptor_t; diff --git a/zigbee-daemon/zigbee-lib/include/zblib_service.h b/zigbee-daemon/zigbee-lib/include/zblib_service.h index 6034098..e0dc480 100644 --- a/zigbee-daemon/zigbee-lib/include/zblib_service.h +++ b/zigbee-daemon/zigbee-lib/include/zblib_service.h @@ -30,6 +30,7 @@ gboolean zblib_service_remove_plugin(ZigBeeService *service, ZigBeePlugin *plugi gboolean zblib_service_load_plugins(ZigBeeService *service, const char *plugin_path); gboolean zblib_service_initialize_plugins(ZigBeeService *service); +gboolean zblib_service_initialize_async_plugins(ZigBeeService *service); gboolean zblib_service_unload_plugins(ZigBeeService *service); GSList *zblib_service_ref_plugins(ZigBeeService *service); diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index 681dc31..72e26e7 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -24,6 +24,16 @@ #include #include #include +#include +#include + +struct _zblib_async_init_info { + gboolean is_initialized; /**< Does initialization succeeded? */ + gboolean is_finished; /**< Does initialization finished? */ + + ZigBeePlugin *plugin; /**< ZigBee plugin */ + void *user_data; /**< User data */ +}; /**< ZigBee Service object */ struct zblib_service_type { @@ -34,8 +44,95 @@ struct zblib_service_type { GHashTable *request_table; /**< Request Hash table */ guint request_id; /**< Request ID */ + + GSList *async_initializer; /**< Hash table for asynchronous initializer */ + zblib_plugin_init_finished_cb callback; /**< Callback */ }; +static GSList *__zblib_service_ref_async_initializer(ZigBeeService* service) +{ + zblib_check_null_ret_error("service", service, NULL); + + return service->async_initializer; +} + +static void __zblib_service_set_async_initializer(ZigBeeService* service, GSList* list) +{ + zblib_check_null_ret("service", service); + + service->async_initializer = list; +} + +static void __on_zblib_init_async_finished(gboolean result, void *user_data) +{ + GSList *list_async = NULL; + ZigBeeService *service = NULL; + ZigBeePlugin *plugin = NULL; + struct _zblib_async_init_info *info = (struct _zblib_async_init_info*)user_data; + char *plugin_name = NULL; + + int i = 0; + int _finished_count = 0; + int _succeeded_count = 0; + + zblib_check_null_ret("info", info); + + plugin = info->plugin; + service = zblib_plugin_ref_service(plugin); + plugin_name = zblib_plugin_get_plugin_name(plugin); + + zblib_check_null_ret("service", service); + + info->is_finished = TRUE; + if (result) { + Z_LOGD("Plugin [%s] succeeded async init", plugin_name); + info->is_initialized = TRUE; + } else { + Z_LOGE("Plugin [%s] failed to init !", plugin_name); + } + g_free(plugin_name); + + /* Check all async initializer list */ + list_async = __zblib_service_ref_async_initializer(service); + while (list_async != NULL) { + /* Initialize each plug-in */ + struct _zblib_async_init_info *in = + (struct _zblib_async_init_info *)(list_async->data); + i++; + if (G_UNLIKELY(NULL == in)) { + Z_LOGE("Invalid parameter !"); + list_async = g_slist_next(list_async); + continue; + } + + if (in->is_finished) + _finished_count++; + if (in->is_initialized) + _succeeded_count++; + + list_async = g_slist_next(list_async); + } + + if (i == _finished_count) { + gboolean ret = TRUE; + guint driver_noti_id = (ZBLIB_DRIVER_TYPE_MANAGER << 24) + | ZBLIB_MANAGER_NOTI_ZIGBEE_ENABLED; + + if (_finished_count == _succeeded_count) { + /* All initializer finished successfully */ + Z_LOGD("All async init finished !"); + ret = TRUE; + } else { + /* Some initializers are failed */ + Z_LOGE("There are some failed plugin initializer !"); + ret = FALSE; + } + /* Notify whether zigbee service is enabled or not */ + zblib_plugin_send_notification(plugin, + driver_noti_id, &ret, sizeof(ret)); + } +} + static void *__zblib_service_load_plugin(gchar *filename, ZblibPluginDescriptor_t **descriptor_out) { @@ -97,7 +194,10 @@ static gboolean __zblib_service_init_plugin(ZigBeePlugin *plugin) const ZblibPluginDescriptor_t *descriptor = zblib_plugin_get_descriptor(plugin); zblib_check_null_ret_error("descriptor", descriptor, FALSE); - zblib_check_null_ret_error("descriptor->init", descriptor->init, FALSE); + if (NULL == descriptor->init) { + Z_LOGD("descriptor->init is NULL, trying async init"); + return FALSE; + } if (G_UNLIKELY(FALSE == descriptor->init(plugin))) { char *plugin_name = zblib_plugin_get_plugin_name(plugin); @@ -111,6 +211,28 @@ static gboolean __zblib_service_init_plugin(ZigBeePlugin *plugin) return TRUE; } +static gboolean __zblib_service_init_async_plugin(ZigBeePlugin *plugin, + zblib_plugin_init_finished_cb callback, void *user_data) +{ + const ZblibPluginDescriptor_t *descriptor = zblib_plugin_get_descriptor(plugin); + char *plugin_name = zblib_plugin_get_plugin_name(plugin); + + zblib_check_null_ret_error("descriptor", descriptor, FALSE); + zblib_check_null_ret_error("descriptor->init_async", descriptor->init_async, FALSE); + + if (G_UNLIKELY(NULL != plugin_name)) + plugin_name = g_strdup("NONAME"); + + if (G_UNLIKELY(FALSE == descriptor->init_async(plugin, callback, user_data))) { + Z_LOGE("plugin(%s) init failed!", plugin_name); + g_free(plugin_name); + return FALSE; + } + + g_free(plugin_name); + return TRUE; +} + static gboolean __zblib_service_unload_plugin(ZigBeePlugin *plugin) { const ZblibPluginDescriptor_t *descriptor = zblib_plugin_get_descriptor(plugin); @@ -193,6 +315,12 @@ void zblib_service_free(ZigBeeService *service) } } + /* Free async initializer */ + if (service->async_initializer) { + g_slist_free(service->async_initializer); + service->async_initializer = NULL; + } + /* Free plug-ins */ if (service->plugins) { g_slist_free(service->plugins); @@ -315,20 +443,74 @@ gboolean zblib_service_load_plugins(ZigBeeService *service, const char *plugin_p gboolean zblib_service_initialize_plugins(ZigBeeService *service) { GSList *list; + GSList *list_async; zblib_check_null_ret_error("service", service, FALSE); /* Refer plug-in list */ list = zblib_service_ref_plugins(service); + list_async = __zblib_service_ref_async_initializer(service); while (list != NULL) { /* Initialize each plug-in */ - if (G_UNLIKELY(FALSE == __zblib_service_init_plugin((ZigBeePlugin *)(list->data)))) { - list = g_slist_next(list); - continue; + ZigBeePlugin *plugin = (ZigBeePlugin *)(list->data); + if (FALSE == __zblib_service_init_plugin(plugin)) { + /* If there is no initializer, it should have asynchronous one */ + const ZblibPluginDescriptor_t *descriptor = + zblib_plugin_get_descriptor(plugin); + if (NULL != descriptor->init_async) { + /* Register async initializer */ + struct _zblib_async_init_info *info = + g_try_new0(struct _zblib_async_init_info, 1); + if(NULL == info) { + Z_LOGE("Fatal : Failed to allocate memory"); + return FALSE; + } + info->is_finished = FALSE; + info->is_initialized = FALSE; + info->plugin = plugin; + info->user_data = NULL; + + list_async = g_slist_append(list_async, info); + } else { + Z_LOGE("Fatal : Failed to initialize plugin"); + return FALSE; + } } list = g_slist_next(list); } + __zblib_service_set_async_initializer(service, list_async); + + return TRUE; +} + +gboolean zblib_service_initialize_async_plugins(ZigBeeService *service) +{ + GSList *list_async; + + zblib_check_null_ret_error("service", service, FALSE); + + /* Refer async initializer list */ + list_async = __zblib_service_ref_async_initializer(service); + while (list_async != NULL) { + /* Initialize each plug-in */ + struct _zblib_async_init_info *info = + (struct _zblib_async_init_info *)(list_async->data); + + if (G_UNLIKELY(NULL == info)) { + Z_LOGE("Invalid parameter !"); + list_async = g_slist_next(list_async); + continue; + } + + if (G_UNLIKELY(FALSE == __zblib_service_init_async_plugin( + info->plugin, __on_zblib_init_async_finished, info))) { + Z_LOGE("Fatal : Failed to initialize mandatory plugin"); + return FALSE; + } + list_async = g_slist_next(list_async); + } + return TRUE; } diff --git a/zigbee-daemon/zigbee-service/src/zigbee_service.c b/zigbee-daemon/zigbee-service/src/zigbee_service.c index d80dbf7..b2a7284 100644 --- a/zigbee-daemon/zigbee-service/src/zigbee_service.c +++ b/zigbee-daemon/zigbee-service/src/zigbee_service.c @@ -56,7 +56,15 @@ gboolean zigbee_service_init(ZigBeeService *service) return FALSE; } - Z_TIME_CHECK("Initializing Plugins Complete. Starting Daemon"); + Z_TIME_CHECK("Initializing Plugins Complete."); + + /* Initialize ZigBee plug-ins */ + if (G_UNLIKELY(TRUE != zblib_service_initialize_async_plugins(service))) { + Z_LOGE("Asynchronously initialize plug-ins failed!"); + return FALSE; + } + + Z_TIME_CHECK("Asynchronous initializer launched successfully. Starting Daemon"); return TRUE; } -- 2.7.4 From c3c8fb7249b79edaecc7e7c397c901fadfcb16df Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Wed, 26 Apr 2017 13:36:07 +0900 Subject: [PATCH 11/16] Fix a bug on zb_zcl_identify_query() - Callback was not launched as 'dest_ep' was not set. - Set 'dest_ep' with given parameter. Change-Id: I7f18a1ee51e17c4bcfb793d4e5b330db8c963a80 Signed-off-by: Jiwan Kim --- zigbee-daemon/zigbee-lib/src/zblib_request.c | 1 + 1 file changed, 1 insertion(+) diff --git a/zigbee-daemon/zigbee-lib/src/zblib_request.c b/zigbee-daemon/zigbee-lib/src/zblib_request.c index b3c314f..9a9c7bd 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_request.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_request.c @@ -1844,6 +1844,7 @@ static gpointer __zblib_request_create_zcl_identify_request_data(guint request_t /* Copy data */ req->node_id = in_req->node_id; + req->dest_ep = in_req->dest_ep; } zclidentify_control_request_data = (gpointer)req; -- 2.7.4 From 2e7f11f7c6188f80d1b4f157897bbe6d5402d5ee Mon Sep 17 00:00:00 2001 From: saerome kim Date: Fri, 28 Apr 2017 10:39:45 +0900 Subject: [PATCH 12/16] Disable privilege check function temporally until ACR compelte Change-Id: I542ad01de258dfaef119bb97f2cb109a877087df Signed-off-by: saerome kim --- packaging/zigbee-manager.spec | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index f6af1cb..19fb9fc 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -1,6 +1,7 @@ %define major 0 %define minor 1 %define patchlevel 0 +%define CHECK_ZIGBEE_PRIVILEGE False Name: zigbee-manager Version: %{major}.%{minor}.%{patchlevel} @@ -43,8 +44,10 @@ ZigBee library (devel) chmod 644 %{SOURCE1} cp -a %{SOURCE1} . +%if %{CHECK_ZIGBEE_PRIVILEGE} == "True" chmod 644 %{SOURCE2} cp -a %{SOURCE2} . +%endif %build cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=%{version} \ @@ -61,7 +64,9 @@ make %{?_smp_mflags} 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 +%if %{CHECK_ZIGBEE_PRIVILEGE} == "True" cp %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/system.d/zigbee.conf +%endif %post -p /sbin/ldconfig @@ -75,7 +80,9 @@ cp %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/system.d/zigbee.conf #%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service %{_datadir}/license/zigbee-daemon %attr(644,root,root) %{_datadir}/dbus-1/system-services/* +%if %{CHECK_ZIGBEE_PRIVILEGE} == "True" %{_datadir}/dbus-1/system.d/zigbee.conf +%endif %files -n zigbee-lib %defattr(644,system,system,-) -- 2.7.4 From 691ff0189bb1cf9097978cf40e7459fe188f1306 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Wed, 10 May 2017 20:25:51 +0900 Subject: [PATCH 13/16] Fix to follow coding convention Change-Id: Ic3841e498e07fc936d49a9cbeebdb36b9482ec15 Signed-off-by: Jiwan Kim --- .../src/zigbee_service_dbus_interface.c | 10 +- .../src/zigbee_service_dbus_interface_custom.c | 2 +- .../src/zigbee_service_dbus_interface_service.c | 37 ++- .../src/zigbee_service_dbus_interface_zcl_alarm.c | 2 +- .../src/zigbee_service_dbus_interface_zcl_basic.c | 2 +- ...gbee_service_dbus_interface_zcl_color_control.c | 2 +- ...bee_service_dbus_interface_zcl_global_control.c | 34 ++- .../src/zigbee_service_dbus_interface_zcl_group.c | 2 +- .../zigbee_service_dbus_interface_zcl_ias_zone.c | 2 +- .../zigbee_service_dbus_interface_zcl_identify.c | 2 +- ...gbee_service_dbus_interface_zcl_level_control.c | 2 +- .../src/zigbee_service_dbus_interface_zcl_on_off.c | 2 +- ...igbee_service_dbus_interface_zcl_poll_control.c | 2 +- .../src/zigbee_service_dbus_interface_zcl_scene.c | 2 +- .../zigbee_service_dbus_interface_zcl_thermostat.c | 2 +- .../src/zigbee_service_dbus_interface_zdo_bind.c | 2 +- ...zigbee_service_dbus_interface_zdo_dev_control.c | 46 +-- zigbee-daemon/zigbee-lib/src/zblib_driver.c | 3 +- zigbee-daemon/zigbee-lib/src/zblib_request.c | 315 +++++++-------------- zigbee-daemon/zigbee-lib/src/zblib_service.c | 5 +- 20 files changed, 179 insertions(+), 297 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 97111d9..afab090 100644 --- a/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c +++ b/zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c @@ -457,10 +457,6 @@ static void zigbee_on_bus_acquired(GDBusConnection *connection, /* Service interface initialization completed */ custom_data->sevice_interface_init_complete = TRUE; - if (TRUE == custom_data->name_acquired) { - /* TODO - Emit zigbee_state signal */ - } - OUT: g_free(path); } @@ -574,9 +570,8 @@ EXIT: */ ret = zblib_service_remove_service_interface(service, service_interface); - if (FALSE == ret) { + if (FALSE == ret) Z_LOGE("Remove service interface failed!"); - } /* * Free Service interface object @@ -645,9 +640,8 @@ EXIT: */ ret = zblib_service_remove_service_interface(service, service_interface); - if (FALSE == ret) { + if (FALSE == ret) Z_LOGE("Remove service interface failed!"); - } /* * 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 19404db..3389215 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 @@ -364,7 +364,7 @@ void zigbee_service_dbus_interface_custom_notification(ZigBeeServiceInterface *s NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_CUSTOM_NOTI_APS_SEND: { int i; GVariant* payload = NULL; 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 9403883..3327890 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 @@ -701,8 +701,8 @@ static void on_service_get_device_list_resp(ZigBeeServiceInterface *service_inte invocation = zigbee_service_dbus_interface_ref_invocation(cb_data); zblib_check_null_free_and_ret("invocation", invocation, cb_data); - /* To-To : zigbee_service_complete_get_device_list */ - //zigbee_service_complete_get_device_list(service_object, invocation, resp_data); + /* TODO : zigbee_service_complete_get_device_list */ + /* zigbee_service_complete_get_device_list(service_object, invocation, resp_data); */ g_free(cb_data); } @@ -861,25 +861,23 @@ static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_inte invocation = zigbee_service_dbus_interface_ref_invocation(cb_data); zblib_check_null_free_and_ret("invocation", invocation, cb_data); - builder = g_variant_builder_new(G_VARIANT_TYPE ("a(qyayyay)")); + builder = g_variant_builder_new(G_VARIANT_TYPE("a(qyayyay)")); for (index = 0; index < payload->count; index++) { ZigbeeServiceGetDeviceInfoDetailResp_t *device = &(payload->list[index]); - GVariantBuilder* mac_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay")); - GVariantBuilder* endpoint_builder = g_variant_builder_new(G_VARIANT_TYPE ("ay")); + GVariantBuilder* mac_builder = g_variant_builder_new(G_VARIANT_TYPE("ay")); + GVariantBuilder* endpoint_builder = g_variant_builder_new(G_VARIANT_TYPE("ay")); - for (i = 0; i < ZIGBEE_EUI64_SIZE; i++) { - g_variant_builder_add (mac_builder, "y", device->eui64[i]); - } - for (i = 0; i < device->endpoint_count; i++) { - g_variant_builder_add (endpoint_builder, "y", device->endpoints[i]); - } + for (i = 0; i < ZIGBEE_EUI64_SIZE; i++) + g_variant_builder_add(mac_builder, "y", device->eui64[i]); + for (i = 0; i < device->endpoint_count; i++) + g_variant_builder_add(endpoint_builder, "y", device->endpoints[i]); - g_variant_builder_add (builder, "(qyayyay)", + g_variant_builder_add(builder, "(qyayyay)", device->node_id, device->node_type, mac_builder, device->endpoint_count, endpoint_builder); - g_variant_builder_unref (mac_builder); - g_variant_builder_unref (endpoint_builder); + g_variant_builder_unref(mac_builder); + g_variant_builder_unref(endpoint_builder); } variant = g_variant_builder_end(builder); @@ -1245,7 +1243,7 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface * NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_SERVICE_NOTI_FORM_NETWORK_DONE: { ZigbeeServiceServiceFormNetworkDone_t *panid_t = (ZigbeeServiceServiceFormNetworkDone_t*)noti_data; @@ -1284,11 +1282,10 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface * GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"), child_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL); - if (NULL == v_eui64) { + if (NULL == v_eui64) Z_LOGE("Failed to create variant!"); - } else { + else zigbee_service_emit_child_rejoined(service_object, v_eui64); - } } break; case ZBLIB_SERVICE_NOTI_CHILD_LEFT: { @@ -1297,9 +1294,9 @@ void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface * GVariant *v_eui64 = g_variant_new_from_data(G_VARIANT_TYPE("a(y)"), child_left_t->eui64, ZIGBEE_EUI64_SIZE, TRUE, NULL, NULL); - if (NULL == v_eui64) { + if (NULL == v_eui64) Z_LOGE("Failed to create variant!"); - } else { + else { zigbee_service_emit_child_left(service_object, v_eui64, child_left_t->status); } 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 20b8e36..787a40c 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 @@ -590,7 +590,7 @@ void zigbee_service_dbus_interface_zcl_alarm_notification(ZigBeeServiceInterface NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZCL_ALARM_NOTI_GET_ALARM_RSP: { ZigbeeZclAlarmGetAlarmRsp_t *rsp = (ZigbeeZclAlarmGetAlarmRsp_t*)noti_data; 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 fdb7332..2512877 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 @@ -144,7 +144,7 @@ void zigbee_service_dbus_interface_zcl_basic_notification(ZigBeeServiceInterface NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { default: Z_LOGE("Unexpected notification [%x]", noti_id); break; 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 08f4206..6a5b4a5 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 @@ -1041,7 +1041,7 @@ void zigbee_service_dbus_interface_zcl_color_control_notification(ZigBeeServiceI NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { default: Z_LOGE("Unexpected notification [%x]", noti_id); 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 c8f1fe2..19eb958 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 @@ -1326,7 +1326,7 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZCL_GLOBAL_NOTI_READ_ATTR_RSP: { ZigbeeZclGlobalControlReadAttributesResp_t *attr_t = (ZigbeeZclGlobalControlReadAttributesResp_t*)noti_data; @@ -1455,7 +1455,7 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService break; } - index_builder = g_variant_builder_new (G_VARIANT_TYPE ("aq")); + index_builder = g_variant_builder_new(G_VARIANT_TYPE("aq")); if (NULL == index_builder) { Z_LOGE("Failed to create variant builder!"); g_variant_unref(v_status); @@ -1463,12 +1463,11 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService g_variant_unref(v_indicator); break; } - for(i = 0; i < attr_t->record_length; i++) { - for(j = 0; j < attr_t->indicator_list[i]; j++) { - g_variant_builder_add (index_builder, "q", attr_t->index_list[i][j]); - } + for (i = 0; i < attr_t->record_length; i++) { + for (j = 0; j < attr_t->indicator_list[i]; j++) + g_variant_builder_add(index_builder, "q", attr_t->index_list[i][j]); } - v_index = g_variant_builder_end (index_builder); + v_index = g_variant_builder_end(index_builder); g_variant_builder_unref(index_builder); Z_LOGD("Write attribute structured resp"); @@ -1582,19 +1581,18 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService break; } - values_builder = g_variant_builder_new (G_VARIANT_TYPE ("a(y)")); + 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); break; } - for(i = 0; i < attr_t->list_count; i++) { - for(j = 0; j < attr_t->values_count[i]; j++) { - g_variant_builder_add (values_builder, "(y)", attr_t->values[i][j]); - } + for (i = 0; i < attr_t->list_count; i++) { + for (j = 0; j < attr_t->values_count[i]; j++) + g_variant_builder_add(values_builder, "(y)", attr_t->values[i][j]); } - v_values = g_variant_builder_end (values_builder); + v_values = g_variant_builder_end(values_builder); g_variant_builder_unref(values_builder); Z_LOGD("Report attributes handler resp"); @@ -1613,15 +1611,15 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService GVariant *v_entries = NULL; GVariantBuilder *entry_builder = - g_variant_builder_new (G_VARIANT_TYPE ("a(yyqyqqayq)")); + g_variant_builder_new(G_VARIANT_TYPE("a(yyqyqqayq)")); if (NULL == entry_builder) { Z_LOGE("Failed to create variant builder!"); break; } - for(i = 0; i < resp_t->record_count ; i++) { + for (i = 0; i < resp_t->record_count ; i++) { GVariantBuilder *change_builder = - g_variant_builder_new (G_VARIANT_TYPE ("ay")); + g_variant_builder_new(G_VARIANT_TYPE("ay")); if (NULL == change_builder) { Z_LOGE("Failed to create variant builder!"); g_variant_builder_unref(entry_builder); @@ -1629,11 +1627,11 @@ void zigbee_service_dbus_interface_zcl_global_control_notification(ZigBeeService } for (v = 0; v < resp_t->entry_list[i].change_count; v++) { - g_variant_builder_add (change_builder, "y", + g_variant_builder_add(change_builder, "y", resp_t->entry_list[i].change[v]); } - g_variant_builder_add (entry_builder, "(yyqyqqayq)", + g_variant_builder_add(entry_builder, "(yyqyqqayq)", resp_t->entry_list[i].status, resp_t->entry_list[i].dir, resp_t->entry_list[i].attribute_id, 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 7ade053..c449a5f 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 @@ -608,7 +608,7 @@ void zigbee_service_dbus_interface_zcl_group_notification(ZigBeeServiceInterface NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_SERVICE_NOTI_ADD_GROUP_RSP: { ZigbeeZclGroupAddGroupNoti_t *rsp = (ZigbeeZclGroupAddGroupNoti_t*)noti_data; 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 c49f883..5f67aee 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 @@ -147,7 +147,7 @@ void zigbee_service_dbus_interface_zcl_ias_zone_notification(ZigBeeServiceInterf NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZCL_IAS_ZONE_NOTI_ZONE_STATUS_CHANGE: { ZigbeeZclIasZoneStatusChangeNoti_t *rsp = (ZigbeeZclIasZoneStatusChangeNoti_t*)noti_data; 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 25d9fbf..b6e2d45 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 @@ -229,7 +229,7 @@ void zigbee_service_dbus_interface_zcl_identify_notification(ZigBeeServiceInterf NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZCL_IDENTIFY_NOTI_QUERY_RSP: { ZigbeeZclIdentifyQueryNoti_t *rsp = (ZigbeeZclIdentifyQueryNoti_t*)noti_data; 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 941f9f0..22ba279 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 @@ -676,7 +676,7 @@ void zigbee_service_dbus_interface_zcl_level_control_notification(ZigBeeServiceI NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { default: Z_LOGE("Unexpected notification [%x]", noti_id); break; 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 17d2bde..396fed3 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 @@ -228,7 +228,7 @@ void zigbee_service_dbus_interface_zcl_on_off_notification(ZigBeeServiceInterfac NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZCL_ON_OFF_NOTI_ON_OFF_STATE: { ZigbeeZclOnOffOnOffState_t *state_t = (ZigbeeZclOnOffOnOffState_t*)noti_data; 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 2ecf836..f787200 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 @@ -401,7 +401,7 @@ void zigbee_service_dbus_interface_zcl_poll_control_notification(ZigBeeServiceIn NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZCL_POLL_CONTROL_NOTI_CHECKIN_RESPONSE: { ZigbeeZclPollControlCheckinResponseNoti_t *rsp = (ZigbeeZclPollControlCheckinResponseNoti_t*)noti_data; 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 079b927..a7c9832 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 @@ -696,7 +696,7 @@ void zigbee_service_dbus_interface_zcl_scene_notification(ZigBeeServiceInterface NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZCL_SCENE_NOTI_ADD_SCENE: { ZigbeeZclSceneAddSceneResp_t *rsp = (ZigbeeZclSceneAddSceneResp_t*)noti_data; 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 b3ad201..08a5b97 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 @@ -538,7 +538,7 @@ void zigbee_service_dbus_interface_zcl_thermostat_notification(ZigBeeServiceInte NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { default: Z_LOGE("Unexpected notification [%x]", noti_id); break; 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 ffdabcc..46e3fcd 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 @@ -279,7 +279,7 @@ void zigbee_service_dbus_interface_zdo_bind_notification(ZigBeeServiceInterface NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZDO_BIND_NOTI_BIND_REQ: { ZigbeeZdoBindUnbindNoti_t *rsp = (ZigbeeZdoBindUnbindNoti_t*)noti_data; 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 0388c28..15f3fa2 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 @@ -1558,7 +1558,7 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt NOT_USED(noti_cb_data); - switch(noti_id) { + switch (noti_id) { case ZBLIB_ZDO_DEV_CONTROL_NOTI_NWK_ADDR_RSP: { ZigbeeZdoDevControlNwkAddrResp_t *nwk_addr_t = (ZigbeeZdoDevControlNwkAddrResp_t*)noti_data; @@ -1668,17 +1668,17 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt GVariant *v_entries = NULL; GVariantBuilder *entry_builder = - g_variant_builder_new (G_VARIANT_TYPE ("a(ayyqyqayy)")); + g_variant_builder_new(G_VARIANT_TYPE("a(ayyqyqayy)")); if (NULL == entry_builder) { Z_LOGE("Failed to create variant builder!"); break; } - for(i = 0; i < desc_t->table_list_count ; i++) { + for (i = 0; i < desc_t->table_list_count ; i++) { GVariantBuilder *eui64_builder = - g_variant_builder_new (G_VARIANT_TYPE ("ay")); + g_variant_builder_new(G_VARIANT_TYPE("ay")); GVariantBuilder *dest_eui64_builder = - g_variant_builder_new (G_VARIANT_TYPE ("ay")); + g_variant_builder_new(G_VARIANT_TYPE("ay")); if (NULL == eui64_builder || NULL == dest_eui64_builder) { Z_LOGE("Failed to create variant builder!"); @@ -1691,13 +1691,13 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt } for (v = 0; v < ZIGBEE_EUI64_SIZE; v++) { - g_variant_builder_add (eui64_builder, "y", + g_variant_builder_add(eui64_builder, "y", desc_t->table_list[i].eui64[v]); - g_variant_builder_add (dest_eui64_builder, "y", + g_variant_builder_add(dest_eui64_builder, "y", desc_t->table_list[i].dest_eui64[v]); } - g_variant_builder_add (entry_builder, "(ayyqyqayy)", + g_variant_builder_add(entry_builder, "(ayyqyqayy)", eui64_builder, desc_t->table_list[i].source_endpoint, desc_t->table_list[i].cluster_id, @@ -1726,17 +1726,17 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt GVariant *v_entries = NULL; GVariantBuilder *entry_builder = - g_variant_builder_new (G_VARIANT_TYPE ("a(ayayyqyyyyy)")); + g_variant_builder_new(G_VARIANT_TYPE("a(ayayyqyyyyy)")); if (NULL == entry_builder) { Z_LOGE("Failed to create variant builder!"); break; } - for(i = 0; i < desc_t->table_list_count ; i++) { + for (i = 0; i < desc_t->table_list_count ; i++) { GVariantBuilder *ext_pan_builder = - g_variant_builder_new (G_VARIANT_TYPE ("ay")); + g_variant_builder_new(G_VARIANT_TYPE("ay")); GVariantBuilder *eui64_builder = - g_variant_builder_new (G_VARIANT_TYPE ("ay")); + g_variant_builder_new(G_VARIANT_TYPE("ay")); if (NULL == ext_pan_builder || NULL == eui64_builder) { Z_LOGE("Failed to create variant builder!"); @@ -1749,13 +1749,13 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt } for (v = 0; v < ZIGBEE_EUI64_SIZE; v++) { - g_variant_builder_add (ext_pan_builder, "y", + g_variant_builder_add(ext_pan_builder, "y", desc_t->table_list[i].extended_pan_id[v]); - g_variant_builder_add (eui64_builder, "y", + g_variant_builder_add(eui64_builder, "y", desc_t->table_list[i].eui64[v]); } - g_variant_builder_add (entry_builder, "(ayayyqyyyyy)", + g_variant_builder_add(entry_builder, "(ayayyqyyyyy)", ext_pan_builder, eui64_builder, desc_t->table_list[i].node_id, @@ -1785,14 +1785,14 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt GVariant *v_entries = NULL; GVariantBuilder *entry_builder = - g_variant_builder_new (G_VARIANT_TYPE ("a(qyyyyq)")); + g_variant_builder_new(G_VARIANT_TYPE("a(qyyyyq)")); if (NULL == entry_builder) { Z_LOGE("Failed to create variant builder!"); break; } - for(i = 0; i < desc_t->table_list_count ; i++) { - g_variant_builder_add (entry_builder, "(qyyyyq)", + for (i = 0; i < desc_t->table_list_count ; i++) { + g_variant_builder_add(entry_builder, "(qyyyyq)", desc_t->table_list[i].dest_addr, desc_t->table_list[i].status, desc_t->table_list[i].memory_constrained, @@ -1833,15 +1833,15 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt GVariant *v_entries = NULL; GVariantBuilder *entry_builder = - g_variant_builder_new (G_VARIANT_TYPE ("a(ayyyyyyy)")); + g_variant_builder_new(G_VARIANT_TYPE("a(ayyyyyyy)")); if (NULL == entry_builder) { Z_LOGE("Failed to create variant builder!"); break; } - for(i = 0; i < nwk_disc_t->table_list_count ; i++) { + for (i = 0; i < nwk_disc_t->table_list_count ; i++) { GVariantBuilder *ext_pan_builder = - g_variant_builder_new (G_VARIANT_TYPE ("ay")); + g_variant_builder_new(G_VARIANT_TYPE("ay")); if (NULL == ext_pan_builder) { Z_LOGE("Failed to create variant builder!"); g_variant_builder_unref(entry_builder); @@ -1849,11 +1849,11 @@ void zigbee_service_dbus_interface_zdo_dev_control_notification(ZigBeeServiceInt } for (v = 0; v < ZIGBEE_EUI64_SIZE; v++) { - g_variant_builder_add (ext_pan_builder, "y", + g_variant_builder_add(ext_pan_builder, "y", nwk_disc_t->table_list[i].extended_pan_id[v]); } - g_variant_builder_add (entry_builder, "(ayyyyyyy)", + g_variant_builder_add(entry_builder, "(ayyyyyyy)", ext_pan_builder, nwk_disc_t->table_list[i].logical_channel, nwk_disc_t->table_list[i].stack_profile, diff --git a/zigbee-daemon/zigbee-lib/src/zblib_driver.c b/zigbee-daemon/zigbee-lib/src/zblib_driver.c index 5032997..e1d36cd 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_driver.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_driver.c @@ -134,9 +134,8 @@ gboolean zblib_driver_set_free_hook(ZigBeeDriver *driver, ZblibDriverType_e zblib_driver_ref_driver_type(ZigBeeDriver *driver) { - if (NULL == driver) { + if (NULL == driver) return ZBLIB_DRIVER_TYPE_NONE; - } return driver->driver_type; } diff --git a/zigbee-daemon/zigbee-lib/src/zblib_request.c b/zigbee-daemon/zigbee-lib/src/zblib_request.c index 9a9c7bd..2df88f0 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_request.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_request.c @@ -3095,9 +3095,8 @@ static void __zblib_request_free_zcl_alarm_request_data(ZigBeeRequest *request, ZigbeeZclAlarmGetAlarmCount_t *req = NULL; req = (ZigbeeZclAlarmGetAlarmCount_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3105,9 +3104,8 @@ static void __zblib_request_free_zcl_alarm_request_data(ZigBeeRequest *request, ZigbeeZclAlarmResetAlarm_t *req = NULL; req = (ZigbeeZclAlarmResetAlarm_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3115,9 +3113,8 @@ static void __zblib_request_free_zcl_alarm_request_data(ZigBeeRequest *request, ZigbeeZclAlarmResetAllAlarm_t *req = NULL; req = (ZigbeeZclAlarmResetAllAlarm_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3125,9 +3122,8 @@ static void __zblib_request_free_zcl_alarm_request_data(ZigBeeRequest *request, ZigbeeZclAlarmAlarm_t *req = NULL; req = (ZigbeeZclAlarmAlarm_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3135,9 +3131,8 @@ static void __zblib_request_free_zcl_alarm_request_data(ZigBeeRequest *request, ZigbeeZclAlarmResetAlarmLogs_t *req = NULL; req = (ZigbeeZclAlarmResetAlarmLogs_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3162,9 +3157,8 @@ static void __zblib_request_free_custom_request_data(ZigBeeRequest *request, ZigbeeCustomApsSend_t *req = NULL; req = (ZigbeeCustomApsSend_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3172,9 +3166,8 @@ static void __zblib_request_free_custom_request_data(ZigBeeRequest *request, ZigbeeCustomZclSend_t *req = NULL; req = (ZigbeeCustomZclSend_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3182,9 +3175,8 @@ static void __zblib_request_free_custom_request_data(ZigBeeRequest *request, ZigbeeCustomSendToLocal_t *req = NULL; req = (ZigbeeCustomSendToLocal_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3205,9 +3197,8 @@ static void __zblib_request_free_zcl_door_lock_request_data(ZigBeeRequest *reque ZigbeeZclDoorLockSubscriberLockEvent_t *req = NULL; req = (ZigbeeZclDoorLockSubscriberLockEvent_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3215,9 +3206,8 @@ static void __zblib_request_free_zcl_door_lock_request_data(ZigBeeRequest *reque ZigbeeZclDoorLockSetDoorLockPin_t *req = NULL; req = (ZigbeeZclDoorLockSetDoorLockPin_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3225,9 +3215,8 @@ static void __zblib_request_free_zcl_door_lock_request_data(ZigBeeRequest *reque ZigbeeZclDoorLockSetDoorLock_t *req = NULL; req = (ZigbeeZclDoorLockSetDoorLock_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3235,9 +3224,8 @@ static void __zblib_request_free_zcl_door_lock_request_data(ZigBeeRequest *reque ZigbeeZclDoorLockGetDoorLock_t *req = NULL; req = (ZigbeeZclDoorLockGetDoorLock_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3258,9 +3246,8 @@ static void __zblib_request_free_zcl_fan_control_request_data(ZigBeeRequest *req ZigbeeZclFanControlSetFanMode_t *req = NULL; req = (ZigbeeZclFanControlSetFanMode_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3268,9 +3255,8 @@ static void __zblib_request_free_zcl_fan_control_request_data(ZigBeeRequest *req ZigbeeZclFanControlGetFanMode_t *req = NULL; req = (ZigbeeZclFanControlGetFanMode_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3278,9 +3264,8 @@ static void __zblib_request_free_zcl_fan_control_request_data(ZigBeeRequest *req ZigbeeZclFanControlSetFanModeSequence_t *req = NULL; req = (ZigbeeZclFanControlSetFanModeSequence_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3288,9 +3273,8 @@ static void __zblib_request_free_zcl_fan_control_request_data(ZigBeeRequest *req ZigbeeZclFanControlGetFanModeSequence_t *req = NULL; req = (ZigbeeZclFanControlGetFanModeSequence_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3311,9 +3295,8 @@ static void __zblib_request_free_zcl_level_control_request_data(ZigBeeRequest *r ZigbeeZclLevelControlMoveToLevel_t *req = NULL; req = (ZigbeeZclLevelControlMoveToLevel_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3321,9 +3304,8 @@ static void __zblib_request_free_zcl_level_control_request_data(ZigBeeRequest *r ZigbeeZclLevelControlMove_t *req = NULL; req = (ZigbeeZclLevelControlMove_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3331,9 +3313,8 @@ static void __zblib_request_free_zcl_level_control_request_data(ZigBeeRequest *r ZigbeeZclLevelControlStep_t *req = NULL; req = (ZigbeeZclLevelControlStep_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3341,9 +3322,8 @@ static void __zblib_request_free_zcl_level_control_request_data(ZigBeeRequest *r ZigbeeZclLevelControlMoveToLevelWithOnOff_t *req = NULL; req = (ZigbeeZclLevelControlMoveToLevelWithOnOff_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3351,9 +3331,8 @@ static void __zblib_request_free_zcl_level_control_request_data(ZigBeeRequest *r ZigbeeZclLevelControlMoveWithOnOff_t *req = NULL; req = (ZigbeeZclLevelControlMoveWithOnOff_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3361,9 +3340,8 @@ static void __zblib_request_free_zcl_level_control_request_data(ZigBeeRequest *r ZigbeeZclLevelControlStepWithOnOff_t *req = NULL; req = (ZigbeeZclLevelControlStepWithOnOff_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3371,9 +3349,8 @@ static void __zblib_request_free_zcl_level_control_request_data(ZigBeeRequest *r ZigbeeZclLevelControlStop_t *req = NULL; req = (ZigbeeZclLevelControlStop_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3394,9 +3371,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlStart_t *req = NULL; req = (ZigbeeMfglibControlStart_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3404,9 +3380,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlEnd_t *req = NULL; req = (ZigbeeMfglibControlEnd_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3414,9 +3389,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlStartTone_t *req = NULL; req = (ZigbeeMfglibControlStartTone_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3424,9 +3398,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlStopTone_t *req = NULL; req = (ZigbeeMfglibControlStopTone_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3434,9 +3407,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlStartStream_t *req = NULL; req = (ZigbeeMfglibControlStartStream_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3444,9 +3416,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlStopStream_t *req = NULL; req = (ZigbeeMfglibControlStopStream_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3454,9 +3425,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlSendPacket_t *req = NULL; req = (ZigbeeMfglibControlSendPacket_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3464,9 +3434,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlSetChannel_t *req = NULL; req = (ZigbeeMfglibControlSetChannel_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3474,9 +3443,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlGetChannel_t *req = NULL; req = (ZigbeeMfglibControlGetChannel_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3484,9 +3452,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlSetPower_t *req = NULL; req = (ZigbeeMfglibControlSetPower_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3494,9 +3461,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlGetPower_t *req = NULL; req = (ZigbeeMfglibControlGetPower_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3504,9 +3470,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlSetSynOffset_t *req = NULL; req = (ZigbeeMfglibControlSetSynOffset_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3514,9 +3479,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlGetSynOffset_t *req = NULL; req = (ZigbeeMfglibControlGetSynOffset_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3524,9 +3488,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlRxStart_t *req = NULL; req = (ZigbeeMfglibControlRxStart_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3534,9 +3497,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlRxStop_t *req = NULL; req = (ZigbeeMfglibControlRxStop_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3544,9 +3506,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlRxVerify_t *req = NULL; req = (ZigbeeMfglibControlRxVerify_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3554,9 +3515,8 @@ static void __zblib_request_free_mfglib_control_request_data(ZigBeeRequest *requ ZigbeeMfglibControlGetRssi_t *req = NULL; req = (ZigbeeMfglibControlGetRssi_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3577,9 +3537,8 @@ static void __zblib_request_free_zcl_on_off_request_data(ZigBeeRequest *request, ZigbeeZclOnOffSetOnOff_t *req = NULL; req = (ZigbeeZclOnOffSetOnOff_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3587,9 +3546,8 @@ static void __zblib_request_free_zcl_on_off_request_data(ZigBeeRequest *request, ZigbeeZclOnOffGetOnOffState_t *req = NULL; req = (ZigbeeZclOnOffGetOnOffState_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3618,9 +3576,8 @@ static void __zblib_request_free_service_request_data(ZigBeeRequest *request, ZigbeeServiceCoexStart_t *req = NULL; req = (ZigbeeServiceCoexStart_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3640,9 +3597,8 @@ static void __zblib_request_free_service_request_data(ZigBeeRequest *request, ZigbeeServicePermitJoin_t *req = NULL; req = (ZigbeeServicePermitJoin_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3650,9 +3606,8 @@ static void __zblib_request_free_service_request_data(ZigBeeRequest *request, ZigbeeServiceLeaveRequest_t *req = NULL; req = (ZigbeeServiceLeaveRequest_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3672,9 +3627,8 @@ static void __zblib_request_free_service_request_data(ZigBeeRequest *request, ZigbeeServiceGetEndpointList_t *req = NULL; req = (ZigbeeServiceGetEndpointList_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3682,9 +3636,8 @@ static void __zblib_request_free_service_request_data(ZigBeeRequest *request, ZigbeeServiceGetClusterList_t *req = NULL; req = (ZigbeeServiceGetClusterList_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3692,9 +3645,8 @@ static void __zblib_request_free_service_request_data(ZigBeeRequest *request, ZigbeeServiceGetNodeType_t *req = NULL; req = (ZigbeeServiceGetNodeType_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3715,9 +3667,8 @@ static void __zblib_request_free_zcl_thermostat_request_data(ZigBeeRequest *requ ZigbeeZclThermostatGetLocalTemp_t *req = NULL; req = (ZigbeeZclThermostatGetLocalTemp_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3725,9 +3676,8 @@ static void __zblib_request_free_zcl_thermostat_request_data(ZigBeeRequest *requ ZigbeeZclThermostatGetWeeklySchedule_t *req = NULL; req = (ZigbeeZclThermostatGetWeeklySchedule_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3735,9 +3685,8 @@ static void __zblib_request_free_zcl_thermostat_request_data(ZigBeeRequest *requ ZigbeeZclThermostatSetWeeklySchedule_t *req = NULL; req = (ZigbeeZclThermostatSetWeeklySchedule_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3745,9 +3694,8 @@ static void __zblib_request_free_zcl_thermostat_request_data(ZigBeeRequest *requ ZigbeeZclThermostatClearWeeklySchedule_t *req = NULL; req = (ZigbeeZclThermostatClearWeeklySchedule_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3755,9 +3703,8 @@ static void __zblib_request_free_zcl_thermostat_request_data(ZigBeeRequest *requ ZigbeeZclThermostatSetpointRaiseLower_t *req = NULL; req = (ZigbeeZclThermostatSetpointRaiseLower_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3778,9 +3725,8 @@ static void __zblib_request_free_zcl_basic_request_data(ZigBeeRequest *request, ZigbeeZclBasicResetFactoryDefault_t *req = NULL; req = (ZigbeeZclBasicResetFactoryDefault_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3889,9 +3835,8 @@ static void __zblib_request_free_zcl_global_control_request_data(ZigBeeRequest * ZigbeeZclGlobalControlDiscoverAttributes_t *req = NULL; req = (ZigbeeZclGlobalControlDiscoverAttributes_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3899,9 +3844,8 @@ static void __zblib_request_free_zcl_global_control_request_data(ZigBeeRequest * ZigbeeZclGlobalControlDiscoverAttributesExtended_t *req = NULL; req = (ZigbeeZclGlobalControlDiscoverAttributesExtended_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3909,9 +3853,8 @@ static void __zblib_request_free_zcl_global_control_request_data(ZigBeeRequest * ZigbeeZclGlobalControlDiscoverCommandsReceived_t *req = NULL; req = (ZigbeeZclGlobalControlDiscoverCommandsReceived_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3919,9 +3862,8 @@ static void __zblib_request_free_zcl_global_control_request_data(ZigBeeRequest * ZigbeeZclGlobalControlDiscoverCommandsGenerated_t *req = NULL; req = (ZigbeeZclGlobalControlDiscoverCommandsGenerated_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3942,9 +3884,8 @@ static void __zblib_request_free_zcl_ias_zone_request_data(ZigBeeRequest *reques ZigbeeZclIasZoneEnrollResponse_t *req = NULL; req = (ZigbeeZclIasZoneEnrollResponse_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3965,9 +3906,8 @@ static void __zblib_request_free_zcl_identify_request_data(ZigBeeRequest *reques ZigbeeZclIdentifyIdentify_t *req = NULL; req = (ZigbeeZclIdentifyIdentify_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3975,9 +3915,8 @@ static void __zblib_request_free_zcl_identify_request_data(ZigBeeRequest *reques ZigbeeZclIdentifyQuery_t *req = NULL; req = (ZigbeeZclIdentifyQuery_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -3998,9 +3937,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlMoveToHue_t *req = NULL; req = (ZigbeeZclColorControlMoveToHue_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4008,9 +3946,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlMoveHue_t *req = NULL; req = (ZigbeeZclColorControlMoveHue_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4018,9 +3955,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlStepHue_t *req = NULL; req = (ZigbeeZclColorControlStepHue_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4028,9 +3964,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlMoveToSaturation_t *req = NULL; req = (ZigbeeZclColorControlMoveToSaturation_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4038,9 +3973,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlMoveSaturation_t *req = NULL; req = (ZigbeeZclColorControlMoveSaturation_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4048,9 +3982,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlStepSaturation_t *req = NULL; req = (ZigbeeZclColorControlStepSaturation_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4058,9 +3991,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlMoveToHueAndSaturation_t *req = NULL; req = (ZigbeeZclColorControlMoveToHueAndSaturation_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4068,9 +4000,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlMoveToColor_t *req = NULL; req = (ZigbeeZclColorControlMoveToColor_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4078,9 +4009,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlMoveColor_t *req = NULL; req = (ZigbeeZclColorControlMoveColor_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4088,9 +4018,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlStepColor_t *req = NULL; req = (ZigbeeZclColorControlStepColor_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4098,9 +4027,8 @@ static void __zblib_request_free_zcl_color_control_request_data(ZigBeeRequest *r ZigbeeZclColorControlMoveColorTemperature_t *req = NULL; req = (ZigbeeZclColorControlMoveColorTemperature_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4121,9 +4049,8 @@ static void __zblib_request_free_zcl_group_request_data(ZigBeeRequest *request, ZigbeeZclGroupAddGroup_t *req = NULL; req = (ZigbeeZclGroupAddGroup_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4131,9 +4058,8 @@ static void __zblib_request_free_zcl_group_request_data(ZigBeeRequest *request, ZigbeeZclGroupViewGroup_t *req = NULL; req = (ZigbeeZclGroupViewGroup_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4152,9 +4078,8 @@ static void __zblib_request_free_zcl_group_request_data(ZigBeeRequest *request, ZigbeeZclGroupRemoveGroup_t *req = NULL; req = (ZigbeeZclGroupRemoveGroup_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4162,9 +4087,8 @@ static void __zblib_request_free_zcl_group_request_data(ZigBeeRequest *request, ZigbeeZclGroupRemoveAllGroup_t *req = NULL; req = (ZigbeeZclGroupRemoveAllGroup_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4172,9 +4096,8 @@ static void __zblib_request_free_zcl_group_request_data(ZigBeeRequest *request, ZigbeeZclGroupAddGroupIfIdentifying_t *req = NULL; req = (ZigbeeZclGroupAddGroupIfIdentifying_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4195,9 +4118,8 @@ static void __zblib_request_free_zcl_poll_control_request_data(ZigBeeRequest *re ZigbeeZclPollControlCheckInResponse_t *req = NULL; req = (ZigbeeZclPollControlCheckInResponse_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4205,9 +4127,8 @@ static void __zblib_request_free_zcl_poll_control_request_data(ZigBeeRequest *re ZigbeeZclPollControlFastPollStop_t *req = NULL; req = (ZigbeeZclPollControlFastPollStop_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4215,9 +4136,8 @@ static void __zblib_request_free_zcl_poll_control_request_data(ZigBeeRequest *re ZigbeeZclPollControlSetLongPollInterval_t *req = NULL; req = (ZigbeeZclPollControlSetLongPollInterval_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4225,9 +4145,8 @@ static void __zblib_request_free_zcl_poll_control_request_data(ZigBeeRequest *re ZigbeeZclPollControlSetShortPollInterval_t *req = NULL; req = (ZigbeeZclPollControlSetShortPollInterval_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4259,9 +4178,8 @@ static void __zblib_request_free_zcl_scene_request_data(ZigBeeRequest *request, ZigbeeZclSceneViewScene_t *req = NULL; req = (ZigbeeZclSceneViewScene_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4269,9 +4187,8 @@ static void __zblib_request_free_zcl_scene_request_data(ZigBeeRequest *request, ZigbeeZclSceneRemoveScene_t *req = NULL; req = (ZigbeeZclSceneRemoveScene_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4279,9 +4196,8 @@ static void __zblib_request_free_zcl_scene_request_data(ZigBeeRequest *request, ZigbeeZclSceneStoreScene_t *req = NULL; req = (ZigbeeZclSceneStoreScene_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4289,9 +4205,8 @@ static void __zblib_request_free_zcl_scene_request_data(ZigBeeRequest *request, ZigbeeZclSceneRecallScene_t *req = NULL; req = (ZigbeeZclSceneRecallScene_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4299,9 +4214,8 @@ static void __zblib_request_free_zcl_scene_request_data(ZigBeeRequest *request, ZigbeeZclSceneRemoveAllScene_t *req = NULL; req = (ZigbeeZclSceneRemoveAllScene_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4309,9 +4223,8 @@ static void __zblib_request_free_zcl_scene_request_data(ZigBeeRequest *request, ZigbeeZclSceneGetSceneMembership_t *req = NULL; req = (ZigbeeZclSceneGetSceneMembership_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4332,9 +4245,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlNwkAddrReq_t *req = NULL; req = (ZigbeeZdoDevControlNwkAddrReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4354,9 +4266,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlIeeeAddrReq_t *req = NULL; req = (ZigbeeZdoDevControlIeeeAddrReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4364,9 +4275,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlActiveEpReq_t *req = NULL; req = (ZigbeeZdoDevControlActiveEpReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4374,9 +4284,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlNodeDescriptorReq_t *req = NULL; req = (ZigbeeZdoDevControlNodeDescriptorReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4384,9 +4293,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlPowerDescriptorReq_t *req = NULL; req = (ZigbeeZdoDevControlPowerDescriptorReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4394,9 +4302,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlComplexDescriptorReq_t *req = NULL; req = (ZigbeeZdoDevControlComplexDescriptorReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4404,9 +4311,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlUserDescriptorReq_t *req = NULL; req = (ZigbeeZdoDevControlUserDescriptorReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4414,9 +4320,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlUserDescriptorSetReq_t *req = NULL; req = (ZigbeeZdoDevControlUserDescriptorSetReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4424,9 +4329,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlDeviceAnnounce_t *req = NULL; req = (ZigbeeZdoDevControlDeviceAnnounce_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4434,9 +4338,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlSimpleDescriptorReq_t *req = NULL; req = (ZigbeeZdoDevControlSimpleDescriptorReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4444,9 +4347,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlMgmtLqiReq_t *req = NULL; req = (ZigbeeZdoDevControlMgmtLqiReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4454,9 +4356,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlMgmtRtgReq_t *req = NULL; req = (ZigbeeZdoDevControlMgmtRtgReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4464,9 +4365,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlMgmtBindReq_t *req = NULL; req = (ZigbeeZdoDevControlMgmtBindReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4474,9 +4374,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlMgmtPermitJoinReq_t *req = NULL; req = (ZigbeeZdoDevControlMgmtPermitJoinReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4484,9 +4383,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlMgmtNwkUpdateReq_t *req = NULL; req = (ZigbeeZdoDevControlMgmtNwkUpdateReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4494,9 +4392,8 @@ static void __zblib_request_free_zdo_dev_control_request_data(ZigBeeRequest *req ZigbeeZdoDevControlMgmtNwkDiscoveryReq_t *req = NULL; req = (ZigbeeZdoDevControlMgmtNwkDiscoveryReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4517,9 +4414,8 @@ static void __zblib_request_free_zdo_bind_request_data(ZigBeeRequest *request, ZigbeeZdoBindBindReq_t *req = NULL; req = (ZigbeeZdoBindBindReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; @@ -4527,9 +4423,8 @@ static void __zblib_request_free_zdo_bind_request_data(ZigBeeRequest *request, ZigbeeZdoBindUnbindReq_t *req = NULL; req = (ZigbeeZdoBindUnbindReq_t *)request->request_data; - if (NULL != req) { + if (NULL != req) g_free(req); - } } break; diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index 72e26e7..df81d69 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -429,9 +429,8 @@ gboolean zblib_service_load_plugins(ZigBeeService *service, const char *plugin_p /* Add new plug-in */ ret = zblib_service_add_plugin(service, plugin); - if (G_UNLIKELY(FALSE == ret)) { + if (G_UNLIKELY(FALSE == ret)) zblib_plugin_free(plugin); - } g_free(filename); } @@ -461,7 +460,7 @@ gboolean zblib_service_initialize_plugins(ZigBeeService *service) /* Register async initializer */ struct _zblib_async_init_info *info = g_try_new0(struct _zblib_async_init_info, 1); - if(NULL == info) { + if (NULL == info) { Z_LOGE("Fatal : Failed to allocate memory"); return FALSE; } -- 2.7.4 From be31bfb8a24c116ef5b46acfc226cbd8d4e5b421 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Thu, 11 May 2017 14:29:21 +0900 Subject: [PATCH 14/16] Fix svace issues Change-Id: I4f396cba56dfcf97505180131a7537c16320752b Signed-off-by: Jiwan Kim --- ...bee_service_dbus_interface_zcl_global_control.c | 42 ++++++++++++++++++++++ .../src/zigbee_service_dbus_interface_zcl_scene.c | 1 + ...zigbee_service_dbus_interface_zdo_dev_control.c | 2 ++ zigbee-daemon/zigbee-lib/src/zblib_service.c | 7 ++-- 4 files changed, 49 insertions(+), 3 deletions(-) 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 19eb958..9c5a0e8 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 @@ -216,6 +216,7 @@ static gboolean on_zclglobal_control_write_attributes_req(ZigbeeZcl_global_contr /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.write_records); return TRUE; } @@ -245,6 +246,7 @@ static gboolean on_zclglobal_control_write_attributes_req(ZigbeeZcl_global_contr /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.write_records); return TRUE; } @@ -254,6 +256,10 @@ static gboolean on_zclglobal_control_write_attributes_req(ZigbeeZcl_global_contr ZBLIB_ZCL_GLOBAL_CONTROL_OPS_WRITE_ATTRIBUTES_REQ, &req, sizeof(req), on_zclglobal_control_write_attributes_req_resp, resp_cb_data); + + /* Free resource */ + g_free(req.write_records); + if (FALSE == ret) { Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); @@ -330,6 +336,7 @@ static gboolean on_zclglobal_control_write_attributes_undivided_req(ZigbeeZcl_gl /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.write_records); return TRUE; } @@ -357,6 +364,7 @@ static gboolean on_zclglobal_control_write_attributes_undivided_req(ZigbeeZcl_gl /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.write_records); return TRUE; } @@ -366,6 +374,10 @@ static gboolean on_zclglobal_control_write_attributes_undivided_req(ZigbeeZcl_gl ZBLIB_ZCL_GLOBAL_CONTROL_OPS_WRITE_ATTRIBUTES_UNDIVIDED_REQ, &req, sizeof(req), on_zclglobal_control_write_attributes_undivided_req_resp, resp_cb_data); + + /* Free resource */ + g_free(req.write_records); + if (FALSE == ret) { Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); @@ -442,6 +454,7 @@ static gboolean on_zclglobal_control_write_attributes_no_resp(ZigbeeZcl_global_c /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.write_records); return TRUE; } @@ -469,6 +482,7 @@ static gboolean on_zclglobal_control_write_attributes_no_resp(ZigbeeZcl_global_c /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.write_records); return TRUE; } @@ -478,6 +492,10 @@ static gboolean on_zclglobal_control_write_attributes_no_resp(ZigbeeZcl_global_c ZBLIB_ZCL_GLOBAL_CONTROL_OPS_WRITE_ATTRIBUTES_NO_RESP, &req, sizeof(req), on_zclglobal_control_write_attributes_no_resp_resp, resp_cb_data); + + /* Free resource */ + g_free(req.write_records); + if (FALSE == ret) { Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); @@ -554,6 +572,7 @@ static gboolean on_zclglobal_control_write_attributes_structured(ZigbeeZcl_globa /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.write_records); return TRUE; } @@ -581,6 +600,7 @@ static gboolean on_zclglobal_control_write_attributes_structured(ZigbeeZcl_globa /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.write_records); return TRUE; } @@ -590,6 +610,10 @@ static gboolean on_zclglobal_control_write_attributes_structured(ZigbeeZcl_globa ZBLIB_ZCL_GLOBAL_CONTROL_OPS_WRITE_ATTRIBUTES_STRUCTURED, &req, sizeof(req), on_zclglobal_control_write_attributes_structured_resp, resp_cb_data); + + /* Free resource */ + g_free(req.write_records); + if (FALSE == ret) { Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); @@ -666,6 +690,7 @@ static gboolean on_zclglobal_control_read_attributes_structured(ZigbeeZcl_global /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.read_records); return TRUE; } @@ -693,6 +718,7 @@ static gboolean on_zclglobal_control_read_attributes_structured(ZigbeeZcl_global /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.read_records); return TRUE; } @@ -702,6 +728,10 @@ static gboolean on_zclglobal_control_read_attributes_structured(ZigbeeZcl_global ZBLIB_ZCL_GLOBAL_CONTROL_OPS_READ_ATTRIBUTES_STRUCTURED, &req, sizeof(req), on_zclglobal_control_read_attributes_structured_resp, resp_cb_data); + + /* Free resource */ + g_free(req.read_records); + if (FALSE == ret) { Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); @@ -778,6 +808,7 @@ static gboolean on_zclglobal_control_configure_reporting_req(ZigbeeZcl_global_co /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.read_records); return TRUE; } @@ -805,6 +836,7 @@ static gboolean on_zclglobal_control_configure_reporting_req(ZigbeeZcl_global_co /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.read_records); return TRUE; } @@ -814,6 +846,10 @@ static gboolean on_zclglobal_control_configure_reporting_req(ZigbeeZcl_global_co ZBLIB_ZCL_GLOBAL_CONTROL_OPS_CONFIGURE_REPORTING_REQ, &req, sizeof(req), on_zclglobal_control_configure_reporting_req_resp, resp_cb_data); + + /* Free resource */ + g_free(req.read_records); + if (FALSE == ret) { Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); @@ -890,6 +926,7 @@ static gboolean on_zclglobal_control_read_configure_reporting(ZigbeeZcl_global_c /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.read_records); return TRUE; } @@ -917,6 +954,7 @@ static gboolean on_zclglobal_control_read_configure_reporting(ZigbeeZcl_global_c /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.read_records); return TRUE; } @@ -926,6 +964,10 @@ static gboolean on_zclglobal_control_read_configure_reporting(ZigbeeZcl_global_c ZBLIB_ZCL_GLOBAL_CONTROL_OPS_READ_CONFIGURE_REPORTING, &req, sizeof(req), on_zclglobal_control_read_configure_reporting_resp, resp_cb_data); + + /* Free resource */ + g_free(req.read_records); + if (FALSE == ret) { Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!"); 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 a7c9832..655e1c7 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 @@ -133,6 +133,7 @@ static gboolean on_zcl_scene_add_scene(ZigbeeZcl_scene *zcl_scene_object, /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.ext_field_set); return TRUE; } 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 15f3fa2..6012740 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 @@ -230,6 +230,8 @@ static gboolean on_zdodev_control_matched_descriptor_req(ZigbeeZdo_dev_control * /* Send failure response */ ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG); + g_free(req.in_cl); + g_free(req.out_cl); return TRUE; } diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index df81d69..ff46159 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -79,10 +79,10 @@ static void __on_zblib_init_async_finished(gboolean result, void *user_data) plugin = info->plugin; service = zblib_plugin_ref_service(plugin); - plugin_name = zblib_plugin_get_plugin_name(plugin); - zblib_check_null_ret("service", service); + plugin_name = zblib_plugin_get_plugin_name(plugin); + info->is_finished = TRUE; if (result) { Z_LOGD("Plugin [%s] succeeded async init", plugin_name); @@ -215,11 +215,12 @@ static gboolean __zblib_service_init_async_plugin(ZigBeePlugin *plugin, zblib_plugin_init_finished_cb callback, void *user_data) { const ZblibPluginDescriptor_t *descriptor = zblib_plugin_get_descriptor(plugin); - char *plugin_name = zblib_plugin_get_plugin_name(plugin); + char *plugin_name = NULL; zblib_check_null_ret_error("descriptor", descriptor, FALSE); zblib_check_null_ret_error("descriptor->init_async", descriptor->init_async, FALSE); + plugin_name = zblib_plugin_get_plugin_name(plugin); if (G_UNLIKELY(NULL != plugin_name)) plugin_name = g_strdup("NONAME"); -- 2.7.4 From ce9e8acb09307150ee2913eb60f8eedfa0e35037 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Fri, 12 May 2017 15:08:56 +0900 Subject: [PATCH 15/16] Fix build issue on 64bit environment Change-Id: I95653b356fe68d8125262b32b2d21c903d21f85b Signed-off-by: Jiwan Kim --- packaging/zigbee-manager.spec | 13 ++++++++----- zigbee-client/CMakeLists.txt | 4 ++-- zigbee-client/zigbee-client.pc.in | 2 +- zigbee-daemon/CMakeLists.txt | 4 ++-- zigbee-daemon/zigbee-lib/CMakeLists.txt | 2 +- zigbee-daemon/zigbee-lib/src/zblib_request.c | 6 +++--- zigbee-daemon/zigbee-lib/src/zblib_service.c | 2 +- zigbee-daemon/zigbee-lib/zigbee-lib.pc.in | 2 +- 8 files changed, 19 insertions(+), 16 deletions(-) diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 19fb9fc..79e1b2a 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -50,7 +50,10 @@ cp -a %{SOURCE2} . %endif %build -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DVERSION=%{version} \ +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \ + -DVERSION=%{version} \ + -DLIB_INSTALL_DIR=%{_libdir} \ + -DUNIT_INSTALL_DIR=%{_unitdir} \ make %{?_smp_mflags} @@ -58,8 +61,8 @@ make %{?_smp_mflags} %make_install # Do not execute daemon on boot time -#mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants -#ln -s %{_libdir}/systemd/system/zigbee-daemon.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service +#mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants +#ln -s %{_unitdir}/zigbee-daemon.service %{buildroot}%{_unitdir}/multi-user.target.wants/zigbee-daemon.service mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/ mkdir -p %{buildroot}%{_datadir}/dbus-1/system.d/ @@ -76,8 +79,8 @@ cp %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/system.d/zigbee.conf %manifest zigbee-daemon.manifest %defattr(644,system,system,-) %attr(755,system,system) %{_bindir}/zigbee-daemon -%{_libdir}/systemd/system/zigbee-daemon.service -#%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service +%{_unitdir}/zigbee-daemon.service +#%{_unitdir}/multi-user.target.wants/zigbee-daemon.service %{_datadir}/license/zigbee-daemon %attr(644,root,root) %{_datadir}/dbus-1/system-services/* %if %{CHECK_ZIGBEE_PRIVILEGE} == "True" diff --git a/zigbee-client/CMakeLists.txt b/zigbee-client/CMakeLists.txt index 8622e3d..aaeed6c 100644 --- a/zigbee-client/CMakeLists.txt +++ b/zigbee-client/CMakeLists.txt @@ -50,9 +50,9 @@ CONFIGURE_FILE(zigbee-client.pc.in zigbee-client.pc @ONLY) ### Install files ### INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/zigbee/client) INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/common/include/ DESTINATION include/zigbee/common) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zigbee-client.pc DESTINATION lib/pkgconfig) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zigbee-client.pc DESTINATION ${LIBDIR}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME zigbee-client) -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT Runtime) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR} COMPONENT Runtime) IF (TIZEN_ENGINEER_MODE) ADD_SUBDIRECTORY(test_src) ENDIF (TIZEN_ENGINEER_MODE) diff --git a/zigbee-client/zigbee-client.pc.in b/zigbee-client/zigbee-client.pc.in index 75c7f4b..3634b35 100644 --- a/zigbee-client/zigbee-client.pc.in +++ b/zigbee-client/zigbee-client.pc.in @@ -1,6 +1,6 @@ prefix=@PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib +libdir=@LIBDIR@ includedir=${prefix}/include Name: ZigBee Client Library diff --git a/zigbee-daemon/CMakeLists.txt b/zigbee-daemon/CMakeLists.txt index 4ac2665..09a577f 100644 --- a/zigbee-daemon/CMakeLists.txt +++ b/zigbee-daemon/CMakeLists.txt @@ -101,7 +101,7 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS} ${ZIGBEE_LIB_SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} zigbee-service zigbee-interface ${pkgs_LDFLAGS} "-ldl") ### Install files ### -INSTALL(TARGETS zigbee-lib DESTINATION lib COMPONENT Runtime) +INSTALL(TARGETS zigbee-lib DESTINATION ${LIBDIR} COMPONENT Runtime) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME zigbee-daemon) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/zigbee-daemon.service DESTINATION /usr/lib/systemd/system) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/zigbee-daemon.service DESTINATION ${UNITDIR}) diff --git a/zigbee-daemon/zigbee-lib/CMakeLists.txt b/zigbee-daemon/zigbee-lib/CMakeLists.txt index 352d5c1..fb40778 100644 --- a/zigbee-daemon/zigbee-lib/CMakeLists.txt +++ b/zigbee-daemon/zigbee-lib/CMakeLists.txt @@ -39,6 +39,6 @@ CONFIGURE_FILE(zigbee-lib.pc.in zigbee-lib.pc @ONLY) ### Install files ### INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/zigbee/lib) INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/common/include/ DESTINATION include/zigbee/common) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zigbee-lib.pc DESTINATION lib/pkgconfig) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zigbee-lib.pc DESTINATION ${LIBDIR}/pkgconfig) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME zigbee-lib) #INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT Runtime) diff --git a/zigbee-daemon/zigbee-lib/src/zblib_request.c b/zigbee-daemon/zigbee-lib/src/zblib_request.c index 2df88f0..f23f3e5 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_request.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_request.c @@ -87,7 +87,7 @@ static ZigBeeRequest *__zblib_request_ref_request_by_by_request_id(ZigBeeService } /* Look-up requets_id in request hash table */ - request = (ZigBeeRequest *)g_hash_table_lookup(request_table, (gconstpointer)request_id); + request = (ZigBeeRequest *)g_hash_table_lookup(request_table, (gconstpointer)GUINT_TO_POINTER(request_id)); if (NULL == request) { Z_LOGE("No request available for request_id: [%d]", request_id); return NULL; @@ -125,7 +125,7 @@ static ZigBeeRequest *__zblib_request_ref_request_by_request_id(ZigBeeService *s } /* Look-up requets_id in request hash table */ - request = (ZigBeeRequest *)g_hash_table_lookup(request_table, (gconstpointer)request_id); + request = (ZigBeeRequest *)g_hash_table_lookup(request_table, (gconstpointer)GUINT_TO_POINTER(request_id)); if (NULL == request) { Z_LOGE("No request available for request_id: [%d]", request_id); return NULL; @@ -4597,7 +4597,7 @@ gint zblib_request_new(ZigBeeServiceInterface *service_interface, } /* Insert request to request table */ - g_hash_table_insert(request_table, (gpointer)(request->request_id), request); + g_hash_table_insert(request_table, GINT_TO_POINTER(request->request_id), request); return request->request_id; } diff --git a/zigbee-daemon/zigbee-lib/src/zblib_service.c b/zigbee-daemon/zigbee-lib/src/zblib_service.c index ff46159..045b651 100644 --- a/zigbee-daemon/zigbee-lib/src/zblib_service.c +++ b/zigbee-daemon/zigbee-lib/src/zblib_service.c @@ -256,7 +256,7 @@ static void __zblib_service_remove_request_table_iter(gpointer key, gpointer value, gpointer user_data) { ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data; - gint request_id = (gint)key; + gint request_id = GPOINTER_TO_INT(key); NOT_USED(value); diff --git a/zigbee-daemon/zigbee-lib/zigbee-lib.pc.in b/zigbee-daemon/zigbee-lib/zigbee-lib.pc.in index 444788e..4faa1b8 100644 --- a/zigbee-daemon/zigbee-lib/zigbee-lib.pc.in +++ b/zigbee-daemon/zigbee-lib/zigbee-lib.pc.in @@ -1,6 +1,6 @@ prefix=@PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/lib +libdir=@LIBDIR@ includedir=${prefix}/include Name: lib-zigbee -- 2.7.4 From 265aa3b0c41ee3c8d6e20be30b0c06334c05d7d8 Mon Sep 17 00:00:00 2001 From: Jiwan Kim Date: Wed, 7 Jun 2017 17:10:39 +0900 Subject: [PATCH 16/16] Add license documentation - add '%license' macro on build spec file Change-Id: I4923f05a6091ba38ed0571125c472ce770ce6880 Signed-off-by: Jiwan Kim --- packaging/zigbee-manager.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/zigbee-manager.spec b/packaging/zigbee-manager.spec index 79e1b2a..57a94e4 100644 --- a/packaging/zigbee-manager.spec +++ b/packaging/zigbee-manager.spec @@ -1,6 +1,6 @@ %define major 0 %define minor 1 -%define patchlevel 0 +%define patchlevel 1 %define CHECK_ZIGBEE_PRIVILEGE False Name: zigbee-manager @@ -86,11 +86,13 @@ cp %{SOURCE2} %{buildroot}%{_datadir}/dbus-1/system.d/zigbee.conf %if %{CHECK_ZIGBEE_PRIVILEGE} == "True" %{_datadir}/dbus-1/system.d/zigbee.conf %endif +%license LICENSE %files -n zigbee-lib %defattr(644,system,system,-) %{_libdir}/libzigbee-lib.so* %{_datadir}/license/zigbee-lib +%license LICENSE %files -n zigbee-lib-devel %defattr(644,system,system,-) -- 2.7.4