static int bt_client_if = 0;
+struct conn_mtu_s {
+ int conn_id;
+ int mtu;
+};
static bt_status_t __bt_connect_le_device_internal(int client_if, const bt_bdaddr_t *bd_addr,
gboolean auto_connect);
static void _bt_hal_send_search_service_complete_event(int conn_id, int status);
static hal_gattc_server_info_t *__bt_find_gatt_conn_info(bt_bdaddr_t *serv_addr);
static hal_gattc_client_info_t *__bt_find_gatt_client_info(bt_bdaddr_t *serv_addr);
+static hal_gattc_client_info_t *__bt_find_gatt_client_info_from_conn_id(int conn_id);
/* To send stack event to hal-av handler */
return BT_STATUS_UNSUPPORTED;
}
+static void __bt_request_att_mtu_device_cb(GDBusProxy *proxy, GAsyncResult *res,
+ gpointer user_data)
+{
+ GError *g_error = NULL;
+ GVariant *reply = NULL;
+ int result = BT_STATUS_SUCCESS;
+ struct hal_ev_gatt_client_mtu_exchange_completed ev;
+ struct conn_mtu_s *conn_mtu = (struct conn_mtu_s *)user_data;
+
+ DBG("+");
+
+ reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
+ g_object_unref(proxy);
+ if (reply == NULL) {
+ ERR("Connect LE Dbus Call Error");
+ if (g_error) {
+ ERR("Error occured in RequestAttMtu [%s]", g_error->message);
+ g_clear_error(&g_error);
+ }
+ result = BT_STATUS_FAIL;
+ }
+ g_variant_unref(reply);
+
+ memset(&ev, 0, sizeof(ev));
+ ev.status = result;
+ ev.mtu = conn_mtu->mtu;
+ ev.conn_id = conn_mtu->conn_id;
+
+ if (!event_cb) {
+ ERR("gatt client callback not registered");
+ } else {
+ DBG("sending gatt client MTU exchange completed event");
+ event_cb(HAL_EV_GATT_CLIENT_MTU_EXCHANGE_COMPLETED , (void *)&ev, sizeof(ev));
+ }
+
+ g_free(conn_mtu);
+}
+
+
+static bt_status_t __hal_configure_mtu(int conn_id, int mtu)
+{
+ gchar *device_path = NULL;
+ GDBusProxy *device_proxy = NULL;
+ GDBusConnection *conn;
+ hal_gattc_client_info_t *gattc_client = NULL;
+ char device_address[BT_HAL_ADDRESS_STRING_SIZE] = { 0 };
+ struct conn_mtu_s *conn_mtu = g_malloc0(sizeof(struct conn_mtu_s));
+
+ conn = _bt_hal_get_system_gconn();
+ if (conn == NULL) {
+ ERR("conn NULL");
+ return BT_STATUS_FAIL;
+ }
+
+ gattc_client = __bt_find_gatt_client_info_from_conn_id(conn_id);
+ if (gattc_client == NULL) {
+ INFO("GATT client conn info not found");
+ return BT_STATUS_FAIL;
+ }
+
+ _bt_hal_convert_addr_type_to_string(device_address,
+ (unsigned char *)gattc_client->bd_addr.address);
+
+ device_path = _bt_hal_get_device_object_path(device_address);
+ if (device_path == NULL) {
+ ERR("device_path NULL : [%s]", device_address);
+ return BT_STATUS_FAIL;
+ }
+
+ device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
+ NULL, BT_HAL_BLUEZ_NAME,
+ device_path, BT_HAL_DEVICE_INTERFACE, NULL, NULL);
+
+ g_free(device_path);
+ if (NULL == device_proxy) {
+ ERR("device_proxy returned NULL");
+ return BT_STATUS_FAIL;
+ }
+
+ conn_mtu->conn_id = conn_id;
+ conn_mtu->mtu = mtu;
+
+ g_dbus_proxy_call(device_proxy, "RequestAttMtu",
+ g_variant_new("(q)", mtu),
+ G_DBUS_CALL_FLAGS_NONE,
+ BT_HAL_MAX_DBUS_TIMEOUT,
+ NULL,
+ (GAsyncReadyCallback)__bt_request_att_mtu_device_cb,
+ conn_mtu);
+
+ return BT_STATUS_SUCCESS;
+}
+
/** MTU Exchange request from client */
-bt_status_t configure_mtu(int conn_id, int mtu)
+static bt_status_t configure_mtu(int conn_id, int mtu)
{
CHECK_BTGATT_INIT();
- return BT_STATUS_UNSUPPORTED;
+
+ return __hal_configure_mtu(conn_id, mtu);
}
/** Setup scan filter params */