Lines Matching refs:gatt
48 #include "gatt.h"
75 struct gatt_service *gatt;
140 g_dbus_remove_watch(prim->gatt->conn, watcher->id);
151 struct gatt_service *gatt = user_data;
153 g_slist_foreach(gatt->primary, (GFunc) primary_free, NULL);
154 g_slist_free(gatt->primary);
155 g_attrib_unref(gatt->attrib);
156 g_free(gatt->path);
157 btd_device_unref(gatt->dev);
158 dbus_connection_unref(gatt->conn);
159 g_free(gatt);
164 const struct gatt_service *gatt = a;
167 return gatt->dev != dev;
226 struct gatt_service *gatt = prim->gatt;
232 g_attrib_unref(gatt->attrib);
252 DBusConnection *conn = w->prim->gatt->conn;
271 struct gatt_service *gatt = user_data;
287 for (lprim = gatt->primary, prim = NULL, chr = NULL; lprim;
307 g_attrib_send(gatt->attrib, 0, opdu[0], opdu, olen,
320 struct gatt_service *gatt = user_data;
322 gatt->attrib = NULL;
327 struct gatt_service *gatt = user_data;
330 g_attrib_unref(gatt->attrib);
335 struct gatt_service *gatt = user_data;
338 if (gatt->msg) {
339 DBusMessage *reply = btd_error_failed(gatt->msg,
341 g_dbus_send_message(gatt->conn, reply);
348 if (gatt->attrib == NULL)
352 if (gatt->listen == TRUE) {
353 g_attrib_register(gatt->attrib,
355 events_handler, gatt, NULL);
356 g_attrib_register(gatt->attrib,
358 events_handler, gatt, NULL);
364 g_attrib_unref(gatt->attrib);
367 static int l2cap_connect(struct gatt_service *gatt, GError **gerr,
372 if (gatt->attrib != NULL) {
373 gatt->attrib = g_attrib_ref(gatt->attrib);
374 gatt->listen = listen;
383 if (gatt->psm < 0)
384 io = bt_io_connect(BT_IO_L2CAP, connect_cb, gatt, NULL, gerr,
385 BT_IO_OPT_SOURCE_BDADDR, &gatt->sba,
386 BT_IO_OPT_DEST_BDADDR, &gatt->dba,
391 io = bt_io_connect(BT_IO_L2CAP, connect_cb, gatt, NULL, gerr,
392 BT_IO_OPT_SOURCE_BDADDR, &gatt->sba,
393 BT_IO_OPT_DEST_BDADDR, &gatt->dba,
394 BT_IO_OPT_PSM, gatt->psm,
400 gatt->attrib = g_attrib_new(io);
402 gatt->listen = listen;
404 g_attrib_set_destroy_function(gatt->attrib, attrib_destroy, gatt);
405 g_attrib_set_disconnect_function(gatt->attrib, attrib_disconnect,
406 gatt);
424 if (l2cap_connect(prim->gatt, &gerr, TRUE) < 0) {
474 struct gatt_service *gatt = chr->prim->gatt;
488 if (l2cap_connect(gatt, &gerr, FALSE) < 0) {
494 gatt_write_cmd(gatt->attrib, chr->handle, value, len, NULL, NULL);
576 static void store_characteristics(struct gatt_service *gatt,
584 write_device_characteristics(&gatt->sba, &gatt->dba, att->start,
596 g_dbus_register_interface(prim->gatt->conn, chr->path,
646 struct gatt_service *gatt = user_data;
655 str = read_device_characteristics(&gatt->sba, &gatt->dba, att->start);
672 static void store_attribute(struct gatt_service *gatt, uint16_t handle,
689 write_device_attribute(&gatt->sba, &gatt->dba, handle, str);
697 struct gatt_service *gatt = current->prim->gatt;
708 store_attribute(gatt, current->handle,
712 GIOChannel *io = g_attrib_get_channel(gatt->attrib);
717 gatt_read_char(gatt->attrib, current->handle, 0,
723 g_attrib_unref(gatt->attrib);
731 struct gatt_service *gatt = current->prim->gatt;
745 store_attribute(gatt, current->handle, GATT_CHARAC_FMT_UUID,
749 g_attrib_unref(gatt->attrib);
757 struct gatt_service *gatt = current->prim->gatt;
763 GIOChannel *io = g_attrib_get_channel(gatt->attrib);
768 gatt_read_char(gatt->attrib, chr->handle, 0,
774 g_attrib_unref(gatt->attrib);
791 struct gatt_service *gatt = current->prim->gatt;
828 gatt->attrib = g_attrib_ref(gatt->attrib);
829 gatt_read_char(gatt->attrib, handle, 0, update_char_desc,
832 gatt->attrib = g_attrib_ref(gatt->attrib);
833 gatt_read_char(gatt->attrib, handle, 0,
841 g_attrib_unref(gatt->attrib);
850 struct gatt_service *gatt = prim->gatt;
856 gatt->attrib = g_attrib_ref(gatt->attrib);
857 gatt_find_info(gatt->attrib, chr->handle + 1, chr->end, descriptor_cb,
864 gatt->attrib = g_attrib_ref(gatt->attrib);
865 gatt_read_char(gatt->attrib, chr->handle, 0, update_char_value, qvalue);
876 struct gatt_service *gatt = prim->gatt;
918 store_characteristics(gatt, prim);
940 g_dbus_send_message(gatt->conn, reply);
941 g_attrib_unref(gatt->attrib);
950 struct gatt_service *gatt = prim->gatt;
954 if (l2cap_connect(prim->gatt, &gerr, FALSE) < 0) {
964 gatt_discover_char(gatt->attrib, att->start, att->end, NULL,
1023 static GSList *register_primaries(struct gatt_service *gatt, GSList *primaries)
1033 prim->gatt = gatt;
1034 prim->path = g_strdup_printf("%s/service%04x", gatt->path,
1037 g_dbus_register_interface(gatt->conn, prim->path,
1042 gatt->primary = g_slist_append(gatt->primary, prim);
1044 load_characteristics(prim, gatt);
1056 struct gatt_service *gatt;
1062 gatt = g_new0(struct gatt_service, 1);
1063 gatt->dev = btd_device_ref(device);
1064 gatt->conn = dbus_connection_ref(connection);
1065 gatt->listen = FALSE;
1066 gatt->path = g_strdup(path);
1067 bacpy(&gatt->sba, &sba);
1068 bacpy(&gatt->dba, &dba);
1069 gatt->psm = psm;
1072 gatt->attrib = g_attrib_ref(attrib);
1074 gatt_services = g_slist_append(gatt_services, gatt);
1076 return register_primaries(gatt, primaries);
1081 struct gatt_service *gatt;
1088 gatt = l->data;
1089 gatt_services = g_slist_remove(gatt_services, gatt);
1091 for (lp = gatt->primary; lp; lp = lp->next) {
1095 g_dbus_unregister_interface(gatt->conn, chr->path,
1098 g_dbus_unregister_interface(gatt->conn, prim->path,
1102 gatt_service_free(gatt);