From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v4 08/12] android/hog: Add support for Battery Service
Date: Fri, 27 Jun 2014 21:08:56 +0300 [thread overview]
Message-ID: <1403892540-21222-8-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1403892540-21222-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If primary is not provided meaning primary should be auto discovered it
probably means other primary services such as Battery Service are not
being handled either so just handle BaS as well in such case.
---
android/hog.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/android/hog.c b/android/hog.c
index aae1f83..f93f246 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -54,6 +54,7 @@
#include "android/scpp.h"
#include "android/dis.h"
+#include "android/bas.h"
#include "android/hog.h"
#define HOG_UUID "00001812-0000-1000-8000-00805f9b34fb"
@@ -93,6 +94,7 @@ struct bt_hog {
uint8_t flags;
struct bt_scpp *scpp;
struct bt_dis *dis;
+ struct bt_bas *bas;
};
struct report {
@@ -650,6 +652,7 @@ static void hog_free(struct bt_hog *hog)
{
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);
@@ -789,6 +792,18 @@ static void hog_attach_dis(struct bt_hog *hog, struct gatt_primary *primary)
}
}
+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;
@@ -821,6 +836,11 @@ static void primary_cb(uint8_t status, GSList *services, void *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));
}
@@ -863,6 +883,9 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)
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,
@@ -901,6 +924,9 @@ void bt_hog_detach(struct bt_hog *hog)
if (hog->dis)
bt_dis_detach(hog->dis);
+ if (hog->bas)
+ bt_bas_detach(hog->bas);
+
g_attrib_unref(hog->attrib);
hog->attrib = NULL;
}
--
1.9.3
next prev parent reply other threads:[~2014-06-27 18:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 02/12] android/dis: Strip dependencies from deviceinfo plugin Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 03/12] android/dis: Add bt_dis_set_notification Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 04/12] android/dis: Only cache the handle not all the characteristics Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 05/12] android/hog: Add support for reading device details via DIS Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 06/12] android: Add initial implementation of Battery Service client Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 07/12] lib/uuid: Add define for Battery UUID Luiz Augusto von Dentz
2014-06-27 18:08 ` Luiz Augusto von Dentz [this message]
2014-06-27 18:08 ` [PATCH BlueZ v4 09/12] android/hog: Add support for multiple instaces Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 10/12] android/hog: Fix using the same callback for different descriptors Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 11/12] android/hog: Enable notifications only for Input Reports Luiz Augusto von Dentz
2014-06-27 18:09 ` [PATCH BlueZ v4 12/12] android/hog: Only discover if External Report has a Report UUID Luiz Augusto von Dentz
2014-06-29 12:58 ` [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Szymon Janc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1403892540-21222-8-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).