From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v3 05/15] android/hog: Add support for reading device details via DIS
Date: Fri, 27 Jun 2014 11:27:49 +0300 [thread overview]
Message-ID: <1403857679-14341-5-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1403857679-14341-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 Device Information
Service are not being handled either so just handle DIS as well in such
case.
---
android/hog.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 49 insertions(+), 12 deletions(-)
diff --git a/android/hog.c b/android/hog.c
index c88fe9d..007146a 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -52,6 +52,7 @@
#include "btio/btio.h"
+#include "android/dis.h"
#include "android/hog.h"
#define HOG_UUID "00001812-0000-1000-8000-00805f9b34fb"
@@ -89,6 +90,7 @@ struct bt_hog {
uint16_t proto_mode_handle;
uint16_t ctrlpt_handle;
uint8_t flags;
+ struct bt_dis *dis;
};
struct report {
@@ -644,6 +646,7 @@ static void report_free(void *data)
static void hog_free(struct bt_hog *hog)
{
+ bt_dis_unref(hog->dis);
bt_uhid_unref(hog->uhid);
g_slist_free_full(hog->reports, report_free);
g_attrib_unref(hog->attrib);
@@ -747,6 +750,30 @@ static void find_included_cb(uint8_t status, GSList *services, void *user_data)
char_discovered_cb, hog);
}
+static void dis_notify(uint8_t source, uint16_t vendor, uint16_t product,
+ uint16_t version, void *user_data)
+{
+ struct bt_hog *hog = user_data;
+
+ hog->vendor = vendor;
+ hog->product = product;
+ hog->version = version;
+}
+
+static void hog_attach_dis(struct bt_hog *hog, struct gatt_primary *primary)
+{
+ if (hog->dis) {
+ bt_dis_attach(hog->dis, hog->attrib);
+ return;
+ }
+
+ hog->dis = bt_dis_new(primary);
+ if (hog->dis) {
+ bt_dis_set_notification(hog->dis, dis_notify, hog);
+ bt_dis_attach(hog->dis, hog->attrib);
+ }
+}
+
static void primary_cb(uint8_t status, GSList *services, void *user_data)
{
struct bt_hog *hog = user_data;
@@ -769,26 +796,30 @@ static void primary_cb(uint8_t status, GSList *services, void *user_data)
for (l = services; l; l = l->next) {
primary = l->data;
+ if (strcmp(primary->uuid, DEVICE_INFORMATION_UUID) == 0) {
+ hog_attach_dis(hog, primary);
+ continue;
+ }
+
if (strcmp(primary->uuid, HOG_UUID) == 0)
- break;
+ hog->primary = g_memdup(primary, sizeof(*primary));
}
- if (!l) {
- for (l = services; l; l = l->next) {
- primary = l->data;
+ if (hog->primary) {
+ gatt_discover_char(hog->attrib, hog->primary->range.start,
+ hog->primary->range.end, NULL,
+ char_discovered_cb, hog);
- gatt_find_included(hog->attrib, primary->range.start,
- primary->range.end, find_included_cb,
- hog);
- }
return;
}
- hog->primary = g_memdup(primary, sizeof(*primary));
+ for (l = services; l; l = l->next) {
+ primary = l->data;
- gatt_discover_char(hog->attrib, hog->primary->range.start,
- hog->primary->range.end, NULL,
- char_discovered_cb, hog);
+ gatt_find_included(hog->attrib, primary->range.start,
+ primary->range.end, find_included_cb,
+ hog);
+ }
}
bool bt_hog_attach(struct bt_hog *hog, void *gatt)
@@ -806,6 +837,9 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)
return true;
}
+ if (hog->dis)
+ bt_dis_attach(hog->dis, gatt);
+
if (hog->reports == NULL) {
gatt_discover_char(hog->attrib, primary->range.start,
primary->range.end, NULL,
@@ -838,6 +872,9 @@ void bt_hog_detach(struct bt_hog *hog)
g_attrib_unregister(hog->attrib, r->notifyid);
}
+ if (hog->dis)
+ bt_dis_detach(hog->dis);
+
g_attrib_unref(hog->attrib);
hog->attrib = NULL;
}
--
1.9.3
next prev parent reply other threads:[~2014-06-27 8:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-27 8:27 [PATCH BlueZ v3 01/15] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 02/15] android/dis: Strip dependencies from deviceinfo plugin Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 03/15] android/dis: Add bt_dis_set_notification Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 04/15] android/dis: Only cache the handle not all the characteristics Luiz Augusto von Dentz
2014-06-27 8:27 ` Luiz Augusto von Dentz [this message]
2014-06-27 8:27 ` [PATCH BlueZ v3 06/15] lib/uuid: Add define for Scan Parameter UUID Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 07/15] android/scpp: Add copy to Scan Parameter Profile implementation Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 08/15] android/scpp: Strip dependencies from scan plugin Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 09/15] android/scpp: Add bt_scpp_set_interval and bt_scpp_set_window Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 10/15] android/scpp: Check for cached handles on attach Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 11/15] android/hog: Add support for Scan Parameter Service Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 12/15] android: Add initial implementation of Battery Service client Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 13/15] lib/uuid: Add define for Battery UUID Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 14/15] android/hog: Add support for Battery Service Luiz Augusto von Dentz
2014-06-27 8:27 ` [PATCH BlueZ v3 15/15] android/hog: Add support for multiple instaces Luiz Augusto von Dentz
2014-06-27 16:35 ` [PATCH BlueZ v3 01/15] 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=1403857679-14341-5-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).