BLE Gatt Server Socket notify implementation.
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-gatt-server.c
index e306822..b90ed57 100644 (file)
@@ -1359,8 +1359,70 @@ static void __bt_gatt_char_method_call(GDBusConnection *connection,
                        return;
                } else if (g_strcmp0(method_name, "AcquireNotify") == 0) {
 
+                               uint16_t mtu = 512;
+                               int char_hdl = -1;
+                               struct hal_ev_gatt_server_acquire_notify  ev;
+                               struct gatt_service_info *svc_info = NULL;
+                               struct gatt_client_info_t *conn_info = NULL;
+                               struct gatt_req_info *req_info = NULL;
+                               char * link = 0;
+                               int len = 0;
+
+                               DBG("AcquireNotify");
+                               DBG("Application path = %s", object_path);
+                               DBG("Sender = %s", sender);
+
+                               GVariantIter* iter;
+                               g_variant_get(parameters, "(a{sv})", &iter);
+                               char* key = NULL;
+                               GVariant* value = NULL;
+                               while (g_variant_iter_loop(iter, "{sv}", &key, &value)) {
+                                               if (g_strcmp0(key, "MTU") == 0)
+                                                       g_variant_get(value, "q", &mtu);
+                               }
+
+                               DBG("AcquireNotify  values retived");
+                               DBG(" MTU = %u",  mtu);
+
+                               svc_info = __bt_gatt_find_gatt_service_from_char(object_path, &char_hdl);
+
+                       if (svc_info == NULL) {
+                                       ERR("svc_info  info not found\n");
+                                       goto done;
+                               }
+
+                               /* Store requets information */
+                               req_info = g_new0(struct gatt_req_info, 1);
+                               req_info->attr_path = g_strdup(object_path);
+                               req_info->svc_path = g_strdup(svc_info->serv_path);
+                               req_info->request_id = 33;
+                               req_info->request_type = BT_HAL_GATT_REQUEST_TYPE_ACQUIRE_NOTIFY;
+                               req_info->offset = mtu;
+                               req_info->context = invocation;
+
+                               conn_info = g_new0(struct gatt_client_info_t, 1);
+                               conn_info->addr = g_strdup(object_path);
+                               INFO("Added GATT client path[%s]", conn_info->addr);
+                               conn_info->connection_id = 33;
+                               conn_info->instance_id = 33;
+                               /* Append request info in list of requests for the particular connection */
+                               conn_info->gatt_req_info_list = g_slist_append(conn_info->gatt_req_info_list, req_info);
+                               gatt_client_info_list = g_slist_append(gatt_client_info_list, conn_info);
+
+                               /* Send HAL event */
+                               memset(&ev, 0, sizeof(ev));
+                               ev.conn_id = 33;
+                               ev.char_handl = char_hdl;
+                               ev.mtu = mtu;
+                               ev.trans_id = 33;
+
+                               event_cb(HAL_EV_GATT_SERVER_ACQUIRE_NOTIFY_RES, (void *)&ev, sizeof(ev));
+
+                               DBG("HAL_EV_GATT_ACQUIRE_NOTIFY_RES   called");
+
+                               return;
+       }
 
-               }
 done:
        g_dbus_method_invocation_return_value(invocation, NULL);
 }
@@ -3039,8 +3101,11 @@ static bt_status_t gatt_server_send_acquire_response(int conn_id, int trans_id,
                                req_info->context, g_variant_new("(hq)", 0, mtu), (GUnixFDList*)fdlist);
 
        } else if (req_info->request_type == BT_HAL_GATT_REQUEST_TYPE_ACQUIRE_NOTIFY) {
-               g_dbus_method_invocation_return_value(req_info->context,
-                                       g_variant_new("(hq)", fd, mtu));
+
+               INFO("GATT Server Send Response BT_HAL_GATT_REQUEST_TYPE_ACQUIRE_NOTIFY  to bluez  %d\n", fd);
+               g_dbus_method_invocation_return_value_with_unix_fd_list(
+                               req_info->context, g_variant_new("(hq)", 0, mtu), (GUnixFDList*)fdlist);
+
        } else {
                g_dbus_method_invocation_return_value(req_info->context, NULL);
        }