diff --git a/android/scpp.c b/android/scpp.c
index 8087ada..77f48cd 100644
--- a/android/scpp.c
+++ b/android/scpp.c
free(req);
}
+static void write_char(struct bt_scpp *scan, GAttrib *attrib, uint16_t handle,
+ const uint8_t *value, size_t vlen,
+ GAttribResultFunc func,
+ gpointer user_data)
+{
+ struct gatt_request *req;
+ unsigned int id;
+
+ req = create_request(scan, user_data);
+ if (!req)
+ return;
+
+ id = gatt_write_char(attrib, handle, value, vlen, func, req);
+
+ if (set_and_store_gatt_req(scan, req, id))
+ return;
+
+ error("scpp: Could not read char");
+ g_attrib_cancel(attrib, id);
+ free(req);
+}
+
static void scpp_free(struct bt_scpp *scan)
{
bt_scpp_detach(scan);
refresh_value_cb, scan, NULL);
}
-static void write_ccc(GAttrib *attrib, uint16_t handle, void *user_data)
+static void write_ccc(struct bt_scpp *scan, GAttrib *attrib, uint16_t handle,
+ void *user_data)
{
uint8_t value[2];
put_le16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value);
- gatt_write_char(attrib, handle, value, sizeof(value), ccc_written_cb,
+ write_char(scan, attrib, handle, value, sizeof(value), ccc_written_cb,
user_data);
}
static void discover_descriptor_cb(uint8_t status, GSList *descs,
void *user_data)
{
- struct bt_scpp *scan = user_data;
+ struct gatt_request *req = user_data;
+ struct bt_scpp *scan = req->user_data;
struct gatt_desc *desc;
+ destroy_gatt_req(req);
if (status != 0) {
error("Discover descriptors failed: %s", att_ecode2str(status));
/* There will be only one descriptor on list and it will be CCC */
desc = descs->data;
- write_ccc(scan->attrib, desc->handle, scan);
+ write_ccc(scan, scan->attrib, desc->handle, scan);
}
static void refresh_discovered_cb(uint8_t status, GSList *chars,