static void gas_free(struct gas *gas) { gatt_db_unref(gas->db); bt_gatt_client_unref(gas->client); btd_device_unref(gas->device); g_free(gas); }
static void gas_reset(struct gas *gas) { gas->attr = NULL; gatt_db_unref(gas->db); gas->db = NULL; bt_gatt_client_unref(gas->client); gas->client = NULL; }
void btd_gatt_client_destroy(struct btd_gatt_client *client) { if (!client) return; queue_destroy(client->services, unregister_service); bt_gatt_client_unref(client->gatt); gatt_db_unref(client->db); free(client); }
static void gatt_conn_destroy(void *data) { struct gatt_conn *conn = data; bt_gatt_client_unref(conn->client); bt_gatt_server_unref(conn->gatt); bt_att_unref(conn->att); free(conn); }
void btd_gatt_client_disconnected(struct btd_gatt_client *client) { if (!client) return; DBG("Device disconnected. Cleaning up"); /* * Remove all services. We'll recreate them when a new bt_gatt_client * becomes ready. */ queue_remove_all(client->services, NULL, NULL, unregister_service); bt_gatt_client_unref(client->gatt); client->gatt = NULL; }
void btd_gatt_client_disconnected(struct btd_gatt_client *client) { if (!client || !client->gatt) return; DBG("Device disconnected. Cleaning up."); /* * TODO: Once GATT over BR/EDR is properly supported, we should pass the * correct bdaddr_type based on the transport over which GATT is being * done. */ queue_foreach(client->all_notify_clients, clear_notify_id, NULL); queue_foreach(client->services, cancel_ops, client->gatt); bt_gatt_client_unref(client->gatt); client->gatt = NULL; }
void btd_gatt_client_ready(struct btd_gatt_client *client) { struct bt_gatt_client *gatt; if (!client) return; gatt = btd_device_get_gatt_client(client->device); if (!gatt) { error("GATT client not initialized"); return; } bt_gatt_client_unref(client->gatt); client->gatt = bt_gatt_client_ref(gatt); client->ready = true; create_services(client); }
void btd_gatt_client_connected(struct btd_gatt_client *client) { struct bt_gatt_client *gatt; gatt = btd_device_get_gatt_client(client->device); if (!gatt) { error("GATT client not initialized"); return; } DBG("Device connected."); bt_gatt_client_unref(client->gatt); client->gatt = bt_gatt_client_ref(gatt); /* * Services have already been created before. Re-enable notifications * for any pre-registered notification sessions. */ queue_foreach(client->all_notify_clients, register_notify, client); }
static int gap_driver_accept(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); struct gatt_db *db = btd_device_get_gatt_db(device); struct bt_gatt_client *client = btd_device_get_gatt_client(device); struct gas *gas; GSList *l; char addr[18]; bt_uuid_t gap_uuid; ba2str(device_get_address(device), addr); DBG("GAP profile accept (%s)", addr); l = g_slist_find_custom(devices, device, cmp_device); if (!l) { error("GAP service not handled by profile"); return -1; } gas = l->data; /* Clean-up any old client/db and acquire the new ones */ gas->attr = NULL; gatt_db_unregister(gas->db, gas->db_id); gatt_db_unref(gas->db); bt_gatt_client_unref(gas->client); gas->db = gatt_db_ref(db); gas->client = bt_gatt_client_ref(client); gas->db_id = gatt_db_register(db, service_added, service_removed, gas, NULL); /* Handle the GAP services */ bt_uuid16_create(&gap_uuid, GAP_UUID16); gatt_db_foreach_service(db, &gap_uuid, foreach_gap_service, gas); return 0; }
static void client_destroy(struct client *cli) { bt_gatt_client_unref(cli->gatt); }