diff --git a/android/hog.c b/android/hog.c
index aae1f83..f93f246 100644
--- a/android/hog.c
+++ b/android/hog.c
#include "android/scpp.h"
#include "android/dis.h"
+#include "android/bas.h"
#include "android/hog.h"
#define HOG_UUID "00001812-0000-1000-8000-00805f9b34fb"
uint8_t flags;
struct bt_scpp *scpp;
struct bt_dis *dis;
+ struct bt_bas *bas;
};
struct report {
{
bt_scpp_unref(hog->scpp);
bt_dis_unref(hog->dis);
+ bt_bas_unref(hog->bas);
bt_uhid_unref(hog->uhid);
g_slist_free_full(hog->reports, report_free);
g_attrib_unref(hog->attrib);
}
}
+static void hog_attach_bas(struct bt_hog *hog, struct gatt_primary *primary)
+{
+ if (hog->bas) {
+ bt_bas_attach(hog->bas, hog->attrib);
+ return;
+ }
+
+ hog->bas = bt_bas_new(primary);
+ if (hog->bas)
+ bt_bas_attach(hog->bas, hog->attrib);
+}
+
static void primary_cb(uint8_t status, GSList *services, void *user_data)
{
struct bt_hog *hog = user_data;
continue;
}
+ if (strcmp(primary->uuid, BATTERY_UUID) == 0) {
+ hog_attach_bas(hog, primary);
+ continue;
+ }
+
if (strcmp(primary->uuid, HOG_UUID) == 0)
hog->primary = g_memdup(primary, sizeof(*primary));
}
if (hog->dis)
bt_dis_attach(hog->dis, gatt);
+ if (hog->bas)
+ bt_bas_attach(hog->bas, gatt);
+
if (hog->reports == NULL) {
gatt_discover_char(hog->attrib, primary->range.start,
primary->range.end, NULL,
if (hog->dis)
bt_dis_detach(hog->dis);
+ if (hog->bas)
+ bt_bas_detach(hog->bas);
+
g_attrib_unref(hog->attrib);
hog->attrib = NULL;
}