Add logic to handle notification and response
authorJiwan Kim <ji-wan.kim@samsung.com>
Wed, 18 Jan 2017 12:53:22 +0000 (21:53 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 11 May 2017 09:10:25 +0000 (18:10 +0900)
- Change GDBus most of sync API to async API
- Added Service notification.

Change-Id: I0fe5be4c62a348c1c8a21e40d866272e503fb5f6
Signed-off-by: Jiwan Kim <ji-wan.kim@samsung.com>
13 files changed:
common/include/zigbee_service_type.h
packaging/zigbee-manager.spec
zigbee-daemon/CMakeLists.txt
zigbee-daemon/zigbee-interface/introspection/service.xml
zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface.c
zigbee-daemon/zigbee-interface/src/zigbee_service_dbus_interface_service.c
zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.c
zigbee-daemon/zigbee-interface/src/zigbee_service_interface_common.h
zigbee-daemon/zigbee-lib/include/zblib_driver_service.h
zigbee-daemon/zigbee-lib/src/zblib_plugin.c
zigbee-daemon/zigbee-lib/src/zblib_request.c
zigbee-daemon/zigbee-lib/src/zblib_service.c
zigbee-daemon/zigbee-lib/src/zblib_service_interface.c

index aadc189..9f5c395 100644 (file)
@@ -21,6 +21,9 @@
 
 #include <zigbee_types.h>
 
+/* --------------------------------------------------------------------------------------
+ * For Requests
+ * -------------------------------------------------------------------------------------*/
 /**
  * @brief Definition for service coex start structure.
  * @since_tizen 3.0
@@ -73,4 +76,74 @@ typedef struct {
        char eui64[ZIGBEE_EUI64_SIZE]; /**< EUI64 (an IEEE address) */
 } ZigbeeServiceGetNodeType_t;
 
+/* --------------------------------------------------------------------------------------
+ * For Responses
+ * -------------------------------------------------------------------------------------*/
+/**
+ * @brief Definition for get network info structure.
+ * @since_tizen 3.0
+ */
+typedef struct {
+       char eui64[ZIGBEE_EUI64_SIZE]; /**< EUI64 (an IEEE address) */
+       short node_id; /**< Node ID (an Network address) */
+       short pan_id; /**< PAN ID (an Network address) */
+       char channel; /**< Channel number */
+       char radio_tx_power;  /**< Power (dBm) */
+} ZigbeeServiceGetNetworkInfo_t;
+
+/* --------------------------------------------------------------------------------------
+ * For Notifications
+ * -------------------------------------------------------------------------------------*/
+
+/**
+ * @brief Definition for service 'enabled' response.
+ * @since_tizen 4.0
+ */
+typedef struct {
+       char enabled; /**< Enabled / Disabled result */
+} ZigbeeServiceServiceState_t;
+
+/**
+ * @brief Definition for service 'form_network_done' response.
+ * @since_tizen 4.0
+ */
+typedef struct {
+       short pan_id; /**< PAN ID */
+} ZigbeeServiceServiceFormNetworkDone_t;
+
+/**
+ * @brief Definition for service 'child_rejoind' response.
+ * @since_tizen 4.0
+ */
+typedef struct {
+       char eui64[ZIGBEE_EUI64_SIZE]; /**< EUI64 (an IEEE address) */
+} ZigbeeServiceServiceChildRejoined_t;
+
+/**
+ * @brief Definition for service 'child_reft' response.
+ * @since_tizen 4.0
+ */
+typedef struct {
+       char eui64[ZIGBEE_EUI64_SIZE]; /**< EUI64 (an IEEE address) */
+       char status; /**< status */
+} ZigbeeServiceServiceChildLeft_t;
+
+/**
+ * @brief Definition for service 'leave_network_done' response.
+ * @since_tizen 4.0
+ */
+typedef struct {
+       short pan_id; /**< PAN ID */
+} ZigbeeServiceServiceLeaveNetworkDone_t;
+
+/**
+ * @brief Definition for service 'get_node_type' response.
+ * @since_tizen 4.0
+ */
+typedef struct {
+       char node_type; /**< Node Type */
+} ZigbeeServiceServiceNodeType_t;
+
+
+
 #endif /* __ZIGBEE_SERVICE_TYPE_H__ */
index ef6f07d..152b457 100644 (file)
@@ -65,8 +65,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
+# 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
 
 %post -p /sbin/ldconfig
 
@@ -76,8 +77,9 @@ ln -s %{_libdir}/systemd/system/zigbee-daemon.service %{buildroot}%{_libdir}/sys
 %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
+# For debug, do not execute zigbee daemon automatically.
+#%{_libdir}/systemd/system/zigbee-daemon.service
+#%{_libdir}/systemd/system/multi-user.target.wants/zigbee-daemon.service
 %{_datadir}/license/zigbee-daemon
 
 %files -n zigbee-client
index 8d0dc42..9f2d703 100644 (file)
@@ -104,5 +104,5 @@ 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)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/zigbee-daemon.service DESTINATION /usr/lib/systemd/system)
-
+# For debug, do not execute zigbee daemon automatically.
+#INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/zigbee-daemon.service DESTINATION /usr/lib/systemd/system)
index aaec71b..1928756 100644 (file)
@@ -1,6 +1,7 @@
 <node>
        <interface name='org.tizen.zigbee.service'>
                <method name='enable'>
+                       <arg type='b' name='enabled' direction='out'/>
                </method>
                <method name='disable'>
                </method>
@@ -16,7 +17,6 @@
                <method name='leave_network'>
                </method>
                <method name='get_network_info'>
-                       <arg type='i' name='result' direction='out'/>
                        <arg type='ay' name='macAddress' direction='out'/>
                        <arg type='q' name='nodeId' direction='out'/>
                        <arg type='q' name='panId' direction='out'/>
                        <arg type='y' name='rejoin' direction='in'/>
                </method>
                <method name='get_device_list'>
-                       <arg type='i' name='result' direction='out'/>
                        <arg type='a(ay)' name='device_list' direction='out'/>
                </method>
                <method name='get_mac'>
-                       <arg type='i' name='result' direction='out'/>
                        <arg type='ay' name='mac_addr' direction='out'/>
                </method>
                <method name='get_device_info'>
-                       <arg type='i' name='result' direction='out'/>
                        <arg type='a(qyayyay)' name='device_list' direction='out'/>
                </method>
                <method name='get_endpoint_list'>
                        <arg type='ay' name='eui64' direction='in'/>
-                       <arg type='i' name='result' direction='out'/>
                        <arg type='ay' name='endpoint_list' direction='out'/>
                </method>
                <method name='get_cluster_list'>
                        <arg type='ay' name='eui64' direction='in'/>
                        <arg type='y' name='endpoint' direction='in'/>
-                       <arg type='i' name='result' direction='out'/>
                        <arg type='aq' name='cluster_list' direction='out'/>
                </method>
                <method name='get_node_type'>
                        <arg type='ay' name='eui64' direction='in'/>
-                       <arg type='i' name='result' direction='out'/>
                        <arg type='y' name='node_type' direction='out'/>
                </method>
 
-               <signal name='enabled'>
-                       <arg type='b' name='enabled'/>
-               </signal>
-               <signal name='disabled'>
-                       <arg type='b' name='disabled'/>
-               </signal>
                <signal name='form_network_done'>
-                       <arg type='q' name='panid'/>
+                       <arg type='q' name='pan_id'/>
                </signal>
                <signal name='child_joined'>
                        <arg type='ayyayq' name='child_addr'/>
@@ -81,7 +69,7 @@
                        <arg type='y' name='status'/>
                </signal>
                <signal name='leave_network_done'>
-                       <arg type='q' name='panid'/>
+                       <arg type='q' name='pan_id'/>
                </signal>
        </interface>
 </node>
index b7e4f80..1b962a5 100644 (file)
@@ -339,7 +339,7 @@ static void zigbee_on_bus_acquired(GDBusConnection *connection,
         */
        g_dbus_object_manager_server_set_connection(custom_data->manager, connection);
 
-       path = g_strdup_printf("%s/service", ZIGBEE_DBUS_PATH);
+       path = g_strdup_printf("%s", ZIGBEE_SERVICE_PATH);
        Z_LOGI("dbus object path: [%s]", path);
 
        /*
index 55a2d0a..879ba23 100644 (file)
 
 #include <zblib_driver_service.h>
 
+static void *_service_interface_ref_zigbee_service(ZigBeeServiceInterface *service_interface)
+{
+       ZigbeeObjectSkeleton *zigbee_object;
+       ZigbeeCustomData_t *custom_data = NULL;
+       ZigbeeService *service = NULL;
+
+       custom_data = (ZigbeeCustomData_t *)zblib_service_interface_ref_user_data(service_interface);
+       if (NULL == custom_data) {
+               Z_LOGE("D-BUS service interface custom_data is NULL!");
+               return NULL;
+       }
+
+       /* Get zigbee object */
+       zigbee_object = g_hash_table_lookup(custom_data->objects, ZIGBEE_SERVICE_PATH);
+       if (zigbee_object) {
+               Z_LOGW("Cannot find ZigBee D-BUS interface object!", zigbee_object);
+               return NULL;
+       }
+
+       service = zigbee_object_get_service(ZIGBEE_OBJECT(zigbee_object));
+       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;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_enable(service_object, invocation, TRUE);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_enable(ZigbeeService *service_object,
@@ -84,11 +119,23 @@ static void on_service_disable_resp(ZigBeeServiceInterface *service_interface,
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_disable(service_object, invocation);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_disable(ZigbeeService *service_object,
@@ -140,11 +187,23 @@ static void on_service_zb_hw_reset_resp(ZigBeeServiceInterface *service_interfac
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_zb_hw_reset(service_object, invocation);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_zb_hw_reset(ZigbeeService *service_object,
@@ -196,11 +255,23 @@ static void on_service_form_network_resp(ZigBeeServiceInterface *service_interfa
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_form_network(service_object, invocation);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_form_network(ZigbeeService *service_object,
@@ -252,11 +323,23 @@ static void on_service_coex_start_resp(ZigBeeServiceInterface *service_interface
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_coex_start(service_object, invocation);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_coex_start(ZigbeeService *service_object,
@@ -315,11 +398,23 @@ static void on_service_coex_stop_resp(ZigBeeServiceInterface *service_interface,
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_coex_stop(service_object, invocation);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_coex_stop(ZigbeeService *service_object,
@@ -371,11 +466,23 @@ static void on_service_leave_network_resp(ZigBeeServiceInterface *service_interf
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_leave_network(service_object, invocation);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_leave_network(ZigbeeService *service_object,
@@ -427,11 +534,28 @@ static void on_service_get_network_info_resp(ZigBeeServiceInterface *service_int
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
+       ZigbeeServiceGetNetworkInfo_t payload;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       memcpy(&payload, resp_data, resp_data_len);
+       zigbee_service_complete_get_network_info(service_object, invocation,
+               payload.eui64, payload.node_id, payload.pan_id, payload.channel,
+               payload.radio_tx_power);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_get_network_info(ZigbeeService *service_object,
@@ -483,11 +607,23 @@ static void on_service_permit_join_resp(ZigBeeServiceInterface *service_interfac
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_permit_join(service_object, invocation);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_permit_join(ZigbeeService *service_object,
@@ -548,11 +684,23 @@ static void on_service_leave_request_resp(ZigBeeServiceInterface *service_interf
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
        NOT_USED(resp_data);
        NOT_USED(resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_leave_request(service_object, invocation);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_leave_request(ZigbeeService *service_object,
@@ -623,11 +771,27 @@ static void on_service_get_device_list_resp(ZigBeeServiceInterface *service_inte
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
-       NOT_USED(cb_data);
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       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_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_get_device_list(service_object, invocation,     resp_data);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_get_device_list(ZigbeeService *service_object,
@@ -679,11 +843,30 @@ static void on_service_get_mac_resp(ZigBeeServiceInterface *service_interface,
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       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_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       /* Todo : plugin must load resp_data as char pointer */
+       zigbee_service_complete_get_mac(service_object, invocation, resp_data);
+
+       g_free(cb_data);
+
 }
 
 static gboolean on_service_get_mac(ZigbeeService *service_object,
@@ -735,11 +918,28 @@ static void on_service_get_device_info_resp(ZigBeeServiceInterface *service_inte
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       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_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_get_device_info(service_object, invocation, resp_data);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_get_device_info(ZigbeeService *service_object,
@@ -791,11 +991,29 @@ static void on_service_get_endpoint_list_resp(ZigBeeServiceInterface *service_in
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       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_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       /* To fix : end-points must be changed gchar* -> GVariant ay */
+       zigbee_service_complete_get_endpoint_list(service_object, invocation, resp_data);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_get_endpoint_list(ZigbeeService *service_object,
@@ -862,11 +1080,28 @@ static void on_service_get_cluster_list_resp(ZigBeeServiceInterface *service_int
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+
        NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       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_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_get_cluster_list(service_object, invocation, resp_data);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_get_cluster_list(ZigbeeService *service_object,
@@ -935,11 +1170,31 @@ static void on_service_get_node_type_resp(ZigBeeServiceInterface *service_interf
        ZigbeeServiceInterfaceRespCbData_t *cb_data =
                (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
 
+       ZigbeeService *service_object;
+       GDBusMethodInvocation *invocation;
+       ZigbeeServiceServiceNodeType_t payload;
+
        NOT_USED(cb_data);
        NOT_USED(service_interface);
        NOT_USED(request_id);
-       NOT_USED(resp_data);
-       NOT_USED(resp_data_len);
+
+       if (NULL == resp_data || 0 == resp_data_len) {
+               Z_LOGE("resp_data is null");
+               g_free(cb_data);
+               return;
+       }
+
+       memcpy(&payload, resp_data, resp_data_len);
+
+       service_object = zigbee_service_dbus_interface_ref_interface_object(cb_data);
+       zblib_check_null_ret("service_object", service_object);
+
+       invocation = zigbee_service_dbus_interface_ref_invocation(cb_data);
+       zblib_check_null_ret("invocation", invocation);
+
+       zigbee_service_complete_get_node_type(service_object, invocation, payload.node_type);
+
+       g_free(cb_data);
 }
 
 static gboolean on_service_get_node_type(ZigbeeService *service_object,
@@ -1003,15 +1258,56 @@ static gboolean on_service_get_node_type(ZigbeeService *service_object,
 void zigbee_service_dbus_interface_service_notification(ZigBeeServiceInterface *service_interface,
        guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
 {
-       if (NULL == service_interface) {
-               Z_LOGE("service_interface is NULL");
+       ZigbeeService *service_object;
+
+       zblib_check_null_ret("service_interface", service_interface);
+
+       if (NULL == noti_data || 0 == noti_data_len) {
+               Z_LOGE("noti_data is NULL");
                return;
        }
 
-       NOT_USED(noti_id);
-       NOT_USED(noti_data);
-       NOT_USED(noti_data_len);
+       service_object = _service_interface_ref_zigbee_service(service_interface);
+       zblib_check_null_ret("service_object", service_object);
+
        NOT_USED(noti_cb_data);
+
+       switch(noti_id) {
+       case ZBLIB_SERVICE_NOTI_FORM_NETWORK_DONE: {
+               ZigbeeServiceServiceFormNetworkDone_t panid_t;
+               memcpy(&panid_t, noti_data, noti_data_len);
+               zigbee_service_emit_form_network_done(service_object, panid_t.pan_id);
+       }
+       break;
+       case ZBLIB_SERVICE_NOTI_CHILD_JOINED: {
+               zigbee_service_emit_child_joined(service_object, (GVariant *)noti_data);
+       }
+       break;
+       case ZBLIB_SERVICE_NOTI_CHILD_REJOINED: {
+               ZigbeeServiceServiceChildRejoined_t ieee_addr_t;
+               memcpy(&ieee_addr_t, noti_data, noti_data_len);
+               zigbee_service_emit_child_rejoined(service_object, ieee_addr_t.eui64);
+       }
+       break;
+       case ZBLIB_SERVICE_NOTI_CHILD_LEFT: {
+               ZigbeeServiceServiceChildLeft_t child_left_t;
+               memcpy(&child_left_t, noti_data, noti_data_len);
+               zigbee_service_emit_child_left(service_object, child_left_t.eui64, child_left_t.status);
+       }
+       break;
+       case ZBLIB_SERVICE_NOTI_LEAVE_NETWORK_DONE: {
+               ZigbeeServiceServiceLeaveNetworkDone_t leave_net_t;
+               memcpy(&leave_net_t, noti_data, noti_data_len);
+               zigbee_service_emit_leave_network_done(service_object, leave_net_t.pan_id);
+       }
+       break;
+       default:
+               Z_LOGE("Unexpected notification [%x]", noti_id);
+       break;
+       }
+
+       /* ZigbeeService should be dereferenced */
+       g_object_unref(service_object);
 }
 
 gboolean zigbee_service_dbus_interface_service_init(ZigBeeServiceInterface *service_interface,
index 4cdf672..1c0a2bf 100644 (file)
@@ -70,6 +70,23 @@ void zigbee_service_dbus_interface_destroy_resp_cb_data(ZigbeeServiceInterfaceRe
        g_free(resp_cb_data);
 }
 
+void *zigbee_service_dbus_interface_ref_interface_object(ZigbeeServiceInterfaceRespCbData_t *resp_cb_data)
+{
+       if (resp_cb_data)
+               return resp_cb_data->interface_object;
+
+       return NULL;
+}
+
+GDBusMethodInvocation *
+zigbee_service_dbus_interface_ref_invocation(ZigbeeServiceInterfaceRespCbData_t *resp_cb_data)
+{
+       if (resp_cb_data)
+               return resp_cb_data->invocation;
+
+       return NULL;
+}
+
 gboolean zigbee_service_dbus_interface_dispatch_request(ZigBeeServiceInterface *service_interface,
        ZblibDriverType_e driver_type, guint ops_id,
        gpointer request_data, guint request_data_len,
index 924d61c..57f4241 100644 (file)
@@ -56,6 +56,7 @@
 
 /**< ZigBee D-BUS service path */
 #define ZIGBEE_DBUS_PATH               "/org/tizen/zigbee"
+#define ZIGBEE_SERVICE_PATH            ZIGBEE_DBUS_PATH"/control"
 
 /**< ZigBee D-BUS generic fail response macro */
 #define ZIGBEE_DBUS_FAIL_RESPONSE(invocation, msg) do { \
@@ -91,6 +92,10 @@ zigbee_service_dbus_interface_create_resp_cb_data(void *interface_object,
 
 void zigbee_service_dbus_interface_destroy_resp_cb_data(ZigbeeServiceInterfaceRespCbData_t *resp_cb_data);
 
+void *zigbee_service_dbus_interface_ref_interface_object(ZigbeeServiceInterfaceRespCbData_t *resp_cb_data);
+GDBusMethodInvocation *
+zigbee_service_dbus_interface_ref_invocation(ZigbeeServiceInterfaceRespCbData_t *resp_cb_data);
+
 gboolean zigbee_service_dbus_interface_dispatch_request(ZigBeeServiceInterface *service_interface,
        ZblibDriverType_e driver_type, guint ops_id,
        gpointer request_data, guint request_data_len,
index 3a24594..f9d632e 100644 (file)
@@ -59,6 +59,15 @@ typedef enum {
        ZBLIB_SERVICE_OPS_GET_NODE_TYPE, /**< Get node type */
 } ZblibServiceOps_e;
 
+/**< ZigBee 'service' notification IDs */
+typedef enum {
+       ZBLIB_SERVICE_NOTI_FORM_NETWORK_DONE, /**< Form network done */
+       ZBLIB_SERVICE_NOTI_CHILD_JOINED, /**< Child is joined */
+       ZBLIB_SERVICE_NOTI_CHILD_REJOINED, /**< Child is rejoined */
+       ZBLIB_SERVICE_NOTI_CHILD_LEFT, /**< Child left */
+       ZBLIB_SERVICE_NOTI_LEAVE_NETWORK_DONE, /**< Leave network is done */
+} ZblibServiceNoti_e;
+
 /* ZigBee 'service' driver APIs */
 ZigBeeDriver *zblib_driver_service_new(ZigBeePlugin *plugin,
        const gchar *driver_name,
index 8aa1fd6..9ec5ae6 100644 (file)
@@ -203,4 +203,4 @@ void zblib_plugin_send_notification(ZigBeePlugin *plugin,
        /* Send notification to service */
        zblib_service_send_notification(service,
                noti_id, noti_data, noti_data_len);
-}
\ No newline at end of file
+}
index 11ea73e..51ecdec 100644 (file)
@@ -1282,6 +1282,7 @@ static gpointer __zblib_request_create_service_request_data(guint request_type,
        break;
 
        default:
+               Z_LOGE("Unexpected operation [%x]", ops_id);
        break;
        }
 
index 2217049..6d64f8c 100644 (file)
@@ -437,6 +437,8 @@ void zblib_service_send_response(ZigBeeService *service,
 {
        ZigBeeServiceInterface *service_interface = NULL;
 
+       zblib_check_null_ret("service", service);
+
        service_interface = zblib_request_ref_service_interface(service, request_id);
        zblib_check_null_ret("service_interface", service_interface);
 
index 9c074fc..c28407d 100644 (file)
@@ -32,6 +32,8 @@ struct zblib_service_interface_type {
        gpointer noti_cb_data; /**< Notification callback data */
 
        ZigBeeService *service; /**< ZigBee Service */
+
+       void *service_object; /**< Zigbee DBus object */
 };
 
 ZigBeeServiceInterface *zblib_service_interface_new(ZigBeeService *service,