+ } else if (g_strcmp0(method_name, "AcquireWrite") == 0) {
+
+ uint16_t mtu = 512;
+ int char_hdl = -1;
+ struct hal_ev_gatt_server_acquire_write_res ev;
+ struct gatt_service_info *svc_info = NULL;
+ struct gatt_req_info *req_info = NULL;
+ struct gatt_client_info_t *conn_info = NULL;
+ char *dev_path = NULL;
+ char *link = NULL;
+ char addr[BT_HAL_ADDRESS_STRING_SIZE];
+
+ DBG("AcquireWrite : Application path %s, sender %s", object_path, 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);
+ else if (g_strcmp0(key, "link") == 0)
+ g_variant_get(value, "s", &link);
+ else if (g_strcmp0(key, "device") == 0)
+ g_variant_get(value, "o", &dev_path);
+ }
+
+ DBG(" path %s LINK = %s, MTU = %u", dev_path, link, mtu);
+
+ svc_info = __bt_gatt_find_gatt_service_from_char(object_path, &char_hdl);
+
+ _bt_hal_convert_device_path_to_address(dev_path, addr);
+
+ DBG("remote address %s", addr);
+ g_free(link);
+ g_free(dev_path);
+
+ /* Check if device is already in connected list */
+ conn_info = __bt_find_remote_gatt_client_info(addr);
+ if (conn_info == NULL) {
+ ERR("Cleint info not found\n");
+ g_variant_iter_free(iter);
+ goto done;
+ }
+
+ if (svc_info == NULL) {
+ ERR("svc_info info not found\n");
+ g_variant_iter_free(iter);
+ 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 = conn_info->connection_id;
+ req_info->request_type = BT_HAL_GATT_REQUEST_TYPE_ACQUIRE_WRITE;
+ req_info->offset = mtu;
+ req_info->context = invocation;
+
+ /* 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);
+
+ /* Send HAL event */
+ memset(&ev, 0, sizeof(ev));
+ ev.conn_id = conn_info->connection_id;
+ ev.char_handl = char_hdl;
+ ev.mtu = mtu;
+ ev.trans_id = conn_info->connection_id;
+ _bt_hal_convert_addr_string_to_type(ev.bdaddr, addr);
+ event_cb(HAL_EV_GATT_SERVER_ACQUIRE_WRITE_RES, (void *)&ev, sizeof(ev));
+ g_variant_iter_free(iter);
+ 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;
+
+ DBG("AcquireNotify : Application path %s, sender %s", object_path, 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("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");
+ g_variant_iter_free(iter);
+ 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("AcquireNotify : 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));
+ g_variant_iter_free(iter);
+ return;