Notification was faling as Gatt serv info was NULL
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-gatt-server.c
index 649639e..b95d6a4 100644 (file)
@@ -613,6 +613,7 @@ static void __bt_gatt_manager_method_call(GDBusConnection *connection,
                if (g_slist_length(gatt_services) == 0) {
                        ERR("No registered GATT services!!!!");
                        g_dbus_method_invocation_return_value(invocation, NULL);
+                       g_variant_builder_unref(builder);
                        return;
                }
 
@@ -1728,6 +1729,7 @@ static char* __bt_hal_convert_uuid_to_string(bt_uuid_t *srvc_id)
 
 int __bt_hal_add_service_to_dbus(char *app_path, int slot, btgatt_srvc_id_t *srvc_id)
 {
+       gboolean ret;
        /* For GATT service specific */
        GDBusNodeInfo *node_info;
        guint object_id;
@@ -1796,12 +1798,20 @@ int __bt_hal_add_service_to_dbus(char *app_path, int slot, btgatt_srvc_id_t *srv
        g_variant_builder_add(builder, "{sa{sv}}",
                        GATT_SERV_INTERFACE, inner_builder);
 
-       g_dbus_connection_emit_signal(g_conn, NULL, "/",
+       ret = g_dbus_connection_emit_signal(g_conn, NULL, "/",
                        "org.freedesktop.Dbus.ObjectManager",
                        "InterfacesAdded",
                        g_variant_new("(oa{sa{sv}})",
                                path, builder),
                        &error);
+       if (!ret) {
+               if (error) {
+                       /* dbus gives error cause */
+                       ERR("d-bus api failure: errcode[%x], message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
+       }
 
        /* Send Service handle to application */
        user_data = g_malloc0(sizeof(hal_gatt_service_added));
@@ -2080,6 +2090,7 @@ static bt_status_t gatt_server_add_characteristic(int slot, int service_handle,
                bt_uuid_t *uuid, int properties,
                int permissions)
 {
+       gboolean ret;
        GError *error = NULL;
        guint object_id;
        GDBusNodeInfo *node_info;
@@ -2181,12 +2192,20 @@ static bt_status_t gatt_server_add_characteristic(int slot, int service_handle,
                        GATT_CHAR_INTERFACE,
                        inner_builder);
 
-       g_dbus_connection_emit_signal(g_conn, NULL, "/",
+       ret = g_dbus_connection_emit_signal(g_conn, NULL, "/",
                        "org.freedesktop.Dbus.ObjectManager",
                        "InterfacesAdded",
                        g_variant_new("(oa{sa{sv}})",
                                path, builder),
                        &error);
+       if (!ret) {
+               if (error) {
+                       /* dbus gives error cause */
+                       ERR("d-bus api failure: errcode[%x], message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               }
+       }
 
        //*char_path = g_strdup(path);
 
@@ -2345,6 +2364,11 @@ static bt_status_t gatt_server_add_descriptor(int slot, int service_handle, bt_u
                        g_variant_new("(oa{sa{sv}})",
                                path, builder),
                        &error);
+       if (error != NULL) {
+               ERR("g_dbus_connection_emit_signal failed: errCode[%x], message[%s]",
+                               error->code, error->message);
+               g_clear_error(&error);
+       }
 
        //*desc_path = g_strdup(path);
 
@@ -2614,11 +2638,12 @@ static gboolean __bt_gatt_get_service_state(const char *service_path)
 {
        struct gatt_service_info *svc_info = NULL;
        GSList *l = NULL;
-
        for (l = gatt_services; l; l = g_slist_next(l)) {
 
                svc_info = (struct gatt_service_info *)l->data;
-               if (svc_info->serv_path == service_path) {
+
+
+               if (!g_strcmp0(svc_info->serv_path, service_path)) {
                        DBG("Return the state of the gatt service %d",
                                        svc_info->is_svc_registered);
                        return svc_info->is_svc_registered;
@@ -2907,7 +2932,6 @@ static bt_status_t gatt_server_update_att_value(int server_if, int attribute_han
 
        update_value = g_variant_new("ay", inner_builder);
 
-       outer_builder = g_variant_builder_new(G_VARIANT_TYPE_ARRAY);
        g_variant_builder_add(outer_builder, "{sv}", "Value",
                        update_value);