diff --git a/android/scpp.c b/android/scpp.c
index 9d8bb10..69bb717 100644
--- a/android/scpp.c
+++ b/android/scpp.c
#include "lib/uuid.h"
#include "src/shared/util.h"
+#include "src/shared/queue.h"
#include "attrib/att.h"
#include "attrib/gattrib.h"
uint16_t iwhandle;
uint16_t refresh_handle;
guint refresh_cb_id;
+ struct queue *gatt_op;
};
+struct gatt_request {
+ unsigned int id;
+ struct bt_scpp *scpp;
+ void *user_data;
+};
+
+static void destroy_gatt_req(struct gatt_request *req)
+{
+ queue_remove(req->scpp->gatt_op, req);
+ bt_scpp_unref(req->scpp);
+ free(req);
+}
+
static void scpp_free(struct bt_scpp *scan)
{
bt_scpp_detach(scan);
g_free(scan->primary);
+ queue_destroy(scan->gatt_op, (void *) destroy_gatt_req);
g_free(scan);
}
scan->interval = SCAN_INTERVAL;
scan->window = SCAN_WINDOW;
+ scan->gatt_op = queue_new();
+ if (!scan->gatt_op) {
+ scpp_free(scan);
+ return NULL;
+ }
+
if (primary)
scan->primary = g_memdup(primary, sizeof(*scan->primary));
return true;
}
+static void cancel_gatt_req(struct gatt_request *req)
+{
+ if (g_attrib_cancel(req->scpp->attrib, req->id))
+ destroy_gatt_req(req);
+}
+
void bt_scpp_detach(struct bt_scpp *scan)
{
if (!scan || !scan->attrib)
scan->refresh_cb_id = 0;
}
+ queue_foreach(scan->gatt_op, (void *) cancel_gatt_req, NULL);
g_attrib_unref(scan->attrib);
scan->attrib = NULL;
}