GSList *reports;
struct bt_uhid *uhid;
int uhid_fd;
+ bool uhid_created;
gboolean has_report_id;
uint16_t bcdhid;
uint8_t bcountrycode;
report->len = len;
}
+static int report_chrc_cmp(const void *data, const void *user_data)
+{
+ const struct report *report = data;
+ const struct gatt_char *decl = user_data;
+
+ return report->decl->handle - decl->handle;
+}
+
static struct report *report_new(struct bt_hog *hog, struct gatt_char *chr)
{
struct report *report;
+ GSList *l;
+
+ /* Skip if report already exists */
+ l = g_slist_find_custom(hog->reports, chr, report_chrc_cmp);
+ if (l)
+ return l->data;
report = g_new0(struct report, 1);
report->hog = hog;
destroy_gatt_req(req);
+ DBG("HoG inspecting report map");
+
if (status != 0) {
error("Report Map read failed: %s", att_ecode2str(status));
return;
bt_uhid_register(hog->uhid, UHID_FEATURE, get_feature, hog);
bt_uhid_register(hog->uhid, UHID_GET_REPORT, get_report, hog);
bt_uhid_register(hog->uhid, UHID_SET_REPORT, set_report, hog);
+
+ hog->uhid_created = true;
+
+ DBG("HoG created uHID device");
}
static void info_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
destroy_gatt_req(req);
+ DBG("HoG inspecting characteristics");
+
if (status != 0) {
const char *str = att_ecode2str(status);
DBG("Discover all characteristics failed: %s", str);
report = report_new(hog, chr);
discover_report(hog, hog->attrib, start, end, report);
} else if (bt_uuid_cmp(&uuid, &report_map_uuid) == 0) {
+ DBG("HoG discovering report map");
read_char(hog, hog->attrib, chr->value_handle,
report_map_read_cb, hog);
discover_external(hog, hog->attrib, start, end, hog);
bt_hog_attach(instance, gatt);
}
- if (hog->reports == NULL) {
+ if (!hog->uhid_created) {
+ DBG("HoG discovering characteristics");
discover_char(hog, hog->attrib, primary->range.start,
primary->range.end, NULL,
char_discovered_cb, hog);