* [PATCH BlueZ v4 02/12] android/dis: Strip dependencies from deviceinfo plugin
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 ` 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
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This strip any dependecy from deviceinfo plugin so the code can be reused
by HoG implementation.
---
android/Android.mk | 1 +
android/Makefile.am | 1 +
android/dis.c | 154 ++++++++++++++++++++++++----------------------------
android/dis.h | 32 +++++++++++
4 files changed, 106 insertions(+), 82 deletions(-)
create mode 100644 android/dis.h
diff --git a/android/Android.mk b/android/Android.mk
index 404f365..3cd17d5 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -36,6 +36,7 @@ LOCAL_SRC_FILES := \
bluez/android/main.c \
bluez/android/bluetooth.c \
bluez/android/scpp.c \
+ bluez/android/dis.c \
bluez/android/hog.c \
bluez/android/hidhost.c \
bluez/android/socket.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index 5845af9..b1842f9 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -39,6 +39,7 @@ android_bluetoothd_SOURCES = android/main.c \
android/bluetooth.h android/bluetooth.c \
android/hidhost.h android/hidhost.c \
android/scpp.h android/scpp.c \
+ android/dis.h android/dis.c \
android/hog.h android/hog.c \
android/ipc-common.h \
android/ipc.h android/ipc.c \
diff --git a/android/dis.c b/android/dis.c
index 208598a..7914293 100644
--- a/android/dis.c
+++ b/android/dis.c
@@ -29,55 +29,86 @@
#include <glib.h>
+#include "src/log.h"
+
#include "lib/uuid.h"
-#include "src/plugin.h"
-#include "src/adapter.h"
-#include "src/device.h"
-#include "src/profile.h"
-#include "src/service.h"
#include "src/shared/util.h"
+
#include "attrib/gattrib.h"
-#include "src/attio.h"
#include "attrib/att.h"
#include "attrib/gatt.h"
-#include "src/log.h"
+
+#include "android/dis.h"
#define PNP_ID_SIZE 7
-struct deviceinfo {
- struct btd_device *dev; /* Device reference */
+struct bt_dis {
+ int ref_count;
+ uint8_t source;
+ uint16_t vendor;
+ uint16_t product;
+ uint16_t version;
GAttrib *attrib; /* GATT connection */
- guint attioid; /* Att watcher id */
- struct att_range *svc_range; /* DeviceInfo range */
+ struct gatt_primary *primary; /* Primary details */
GSList *chars; /* Characteristics */
};
struct characteristic {
struct gatt_char attr; /* Characteristic */
- struct deviceinfo *d; /* deviceinfo where the char belongs */
+ struct bt_dis *d; /* deviceinfo where the char belongs */
};
-static void deviceinfo_driver_remove(struct btd_service *service)
+static void dis_free(struct bt_dis *dis)
+{
+ if (dis->attrib)
+ g_attrib_unref(dis->attrib);
+
+ g_slist_free_full(dis->chars, g_free);
+
+ g_free(dis->primary);
+ g_free(dis);
+}
+
+struct bt_dis *bt_dis_new(void *primary)
{
- struct deviceinfo *d = btd_service_get_user_data(service);
+ struct bt_dis *dis;
- if (d->attioid > 0)
- btd_device_remove_attio_callback(d->dev, d->attioid);
+ dis = g_try_new0(struct bt_dis, 1);
+ if (!dis)
+ return NULL;
- if (d->attrib != NULL)
- g_attrib_unref(d->attrib);
+ if (primary)
+ dis->primary = g_memdup(primary, sizeof(*dis->primary));
- g_slist_free_full(d->chars, g_free);
+ return bt_dis_ref(dis);
+}
+
+struct bt_dis *bt_dis_ref(struct bt_dis *dis)
+{
+ if (!dis)
+ return NULL;
- btd_device_unref(d->dev);
- g_free(d->svc_range);
- g_free(d);
+ __sync_fetch_and_add(&dis->ref_count, 1);
+
+ return dis;
+}
+
+void bt_dis_unref(struct bt_dis *dis)
+{
+ if (!dis)
+ return;
+
+ if (__sync_sub_and_fetch(&dis->ref_count, 1))
+ return;
+
+ dis_free(dis);
}
static void read_pnpid_cb(guint8 status, const guint8 *pdu, guint16 len,
gpointer user_data)
{
struct characteristic *ch = user_data;
+ struct bt_dis *dis = ch->d;
uint8_t value[PNP_ID_SIZE];
ssize_t vlen;
@@ -97,8 +128,10 @@ static void read_pnpid_cb(guint8 status, const guint8 *pdu, guint16 len,
return;
}
- btd_device_set_pnpid(ch->d->dev, value[0], get_le16(&value[1]),
- get_le16(&value[3]), get_le16(&value[5]));
+ dis->source = value[0];
+ dis->vendor = get_le16(&value[1]);
+ dis->product = get_le16(&value[3]);
+ dis->version = get_le16(&value[5]);
}
static void process_deviceinfo_char(struct characteristic *ch)
@@ -111,7 +144,7 @@ static void process_deviceinfo_char(struct characteristic *ch)
static void configure_deviceinfo_cb(uint8_t status, GSList *characteristics,
void *user_data)
{
- struct deviceinfo *d = user_data;
+ struct bt_dis *d = user_data;
GSList *l;
if (status != 0) {
@@ -136,71 +169,28 @@ static void configure_deviceinfo_cb(uint8_t status, GSList *characteristics,
process_deviceinfo_char(ch);
}
}
-static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
-{
- struct deviceinfo *d = user_data;
-
- d->attrib = g_attrib_ref(attrib);
-
- gatt_discover_char(d->attrib, d->svc_range->start, d->svc_range->end,
- NULL, configure_deviceinfo_cb, d);
-}
-static void attio_disconnected_cb(gpointer user_data)
+bool bt_dis_attach(struct bt_dis *dis, void *attrib)
{
- struct deviceinfo *d = user_data;
+ struct gatt_primary *primary = dis->primary;
- g_attrib_unref(d->attrib);
- d->attrib = NULL;
-}
-
-static int deviceinfo_register(struct btd_service *service,
- struct gatt_primary *prim)
-{
- struct btd_device *device = btd_service_get_device(service);
- struct deviceinfo *d;
+ if (dis->attrib || !primary)
+ return false;
- d = g_new0(struct deviceinfo, 1);
- d->dev = btd_device_ref(device);
- d->svc_range = g_new0(struct att_range, 1);
- d->svc_range->start = prim->range.start;
- d->svc_range->end = prim->range.end;
+ dis->attrib = g_attrib_ref(attrib);
- btd_service_set_user_data(service, d);
+ gatt_discover_char(dis->attrib, primary->range.start,
+ primary->range.end, NULL,
+ configure_deviceinfo_cb, dis);
- d->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
- attio_disconnected_cb, d);
- return 0;
+ return true;
}
-static int deviceinfo_driver_probe(struct btd_service *service)
+void bt_dis_detach(struct bt_dis *dis)
{
- struct btd_device *device = btd_service_get_device(service);
- struct gatt_primary *prim;
-
- prim = btd_device_get_primary(device, DEVICE_INFORMATION_UUID);
- if (prim == NULL)
- return -EINVAL;
-
- return deviceinfo_register(service, prim);
-}
-
-static struct btd_profile deviceinfo_profile = {
- .name = "deviceinfo",
- .remote_uuid = DEVICE_INFORMATION_UUID,
- .device_probe = deviceinfo_driver_probe,
- .device_remove = deviceinfo_driver_remove
-};
-
-static int deviceinfo_init(void)
-{
- return btd_profile_register(&deviceinfo_profile);
-}
+ if (!dis->attrib)
+ return;
-static void deviceinfo_exit(void)
-{
- btd_profile_unregister(&deviceinfo_profile);
+ g_attrib_unref(dis->attrib);
+ dis->attrib = NULL;
}
-
-BLUETOOTH_PLUGIN_DEFINE(deviceinfo, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
- deviceinfo_init, deviceinfo_exit)
diff --git a/android/dis.h b/android/dis.h
new file mode 100644
index 0000000..6cc0b58
--- /dev/null
+++ b/android/dis.h
@@ -0,0 +1,32 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+struct bt_dis;
+
+struct bt_dis *bt_dis_new(void *primary);
+
+struct bt_dis *bt_dis_ref(struct bt_dis *dis);
+void bt_dis_unref(struct bt_dis *dis);
+
+bool bt_dis_attach(struct bt_dis *dis, void *gatt);
+void bt_dis_detach(struct bt_dis *dis);
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 03/12] android/dis: Add bt_dis_set_notification
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 ` 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
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Function bt_dis_set_notification can be used to set notify callback.
---
android/dis.c | 21 +++++++++++++++++++++
android/dis.h | 7 +++++++
2 files changed, 28 insertions(+)
diff --git a/android/dis.c b/android/dis.c
index 7914293..3237c03 100644
--- a/android/dis.c
+++ b/android/dis.c
@@ -51,6 +51,8 @@ struct bt_dis {
GAttrib *attrib; /* GATT connection */
struct gatt_primary *primary; /* Primary details */
GSList *chars; /* Characteristics */
+ bt_dis_notify notify;
+ void *notify_data;
};
struct characteristic {
@@ -132,6 +134,13 @@ static void read_pnpid_cb(guint8 status, const guint8 *pdu, guint16 len,
dis->vendor = get_le16(&value[1]);
dis->product = get_le16(&value[3]);
dis->version = get_le16(&value[5]);
+
+ DBG("source: 0x%02X vendor: 0x%04X product: 0x%04X version: 0x%04X",
+ dis->source, dis->vendor, dis->product, dis->version);
+
+ if (dis->notify)
+ dis->notify(dis->source, dis->vendor, dis->product,
+ dis->version, dis->notify_data);
}
static void process_deviceinfo_char(struct characteristic *ch)
@@ -194,3 +203,15 @@ void bt_dis_detach(struct bt_dis *dis)
g_attrib_unref(dis->attrib);
dis->attrib = NULL;
}
+
+bool bt_dis_set_notification(struct bt_dis *dis, bt_dis_notify func,
+ void *user_data)
+{
+ if (!dis)
+ return false;
+
+ dis->notify = func;
+ dis->notify_data = user_data;
+
+ return true;
+}
diff --git a/android/dis.h b/android/dis.h
index 6cc0b58..faf27b3 100644
--- a/android/dis.h
+++ b/android/dis.h
@@ -30,3 +30,10 @@ void bt_dis_unref(struct bt_dis *dis);
bool bt_dis_attach(struct bt_dis *dis, void *gatt);
void bt_dis_detach(struct bt_dis *dis);
+
+typedef void (*bt_dis_notify) (uint8_t source, uint16_t vendor,
+ uint16_t product, uint16_t version,
+ void *user_data);
+
+bool bt_dis_set_notification(struct bt_dis *dis, bt_dis_notify func,
+ void *user_data);
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 04/12] android/dis: Only cache the handle not all the characteristics
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 ` 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
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/dis.c | 33 +++++++++------------------------
1 file changed, 9 insertions(+), 24 deletions(-)
diff --git a/android/dis.c b/android/dis.c
index 3237c03..ce6e063 100644
--- a/android/dis.c
+++ b/android/dis.c
@@ -44,13 +44,13 @@
struct bt_dis {
int ref_count;
+ uint16_t handle;
uint8_t source;
uint16_t vendor;
uint16_t product;
uint16_t version;
GAttrib *attrib; /* GATT connection */
struct gatt_primary *primary; /* Primary details */
- GSList *chars; /* Characteristics */
bt_dis_notify notify;
void *notify_data;
};
@@ -65,8 +65,6 @@ static void dis_free(struct bt_dis *dis)
if (dis->attrib)
g_attrib_unref(dis->attrib);
- g_slist_free_full(dis->chars, g_free);
-
g_free(dis->primary);
g_free(dis);
}
@@ -109,8 +107,7 @@ void bt_dis_unref(struct bt_dis *dis)
static void read_pnpid_cb(guint8 status, const guint8 *pdu, guint16 len,
gpointer user_data)
{
- struct characteristic *ch = user_data;
- struct bt_dis *dis = ch->d;
+ struct bt_dis *dis = user_data;
uint8_t value[PNP_ID_SIZE];
ssize_t vlen;
@@ -143,13 +140,6 @@ static void read_pnpid_cb(guint8 status, const guint8 *pdu, guint16 len,
dis->version, dis->notify_data);
}
-static void process_deviceinfo_char(struct characteristic *ch)
-{
- if (g_strcmp0(ch->attr.uuid, PNPID_UUID) == 0)
- gatt_read_char(ch->d->attrib, ch->attr.value_handle,
- read_pnpid_cb, ch);
-}
-
static void configure_deviceinfo_cb(uint8_t status, GSList *characteristics,
void *user_data)
{
@@ -164,18 +154,12 @@ static void configure_deviceinfo_cb(uint8_t status, GSList *characteristics,
for (l = characteristics; l; l = l->next) {
struct gatt_char *c = l->data;
- struct characteristic *ch;
-
- ch = g_new0(struct characteristic, 1);
- ch->attr.handle = c->handle;
- ch->attr.properties = c->properties;
- ch->attr.value_handle = c->value_handle;
- memcpy(ch->attr.uuid, c->uuid, MAX_LEN_UUID_STR + 1);
- ch->d = d;
-
- d->chars = g_slist_append(d->chars, ch);
- process_deviceinfo_char(ch);
+ if (strcmp(c->uuid, PNPID_UUID) == 0) {
+ d->handle = c->value_handle;
+ gatt_read_char(d->attrib, d->handle, read_pnpid_cb, d);
+ break;
+ }
}
}
@@ -188,7 +172,8 @@ bool bt_dis_attach(struct bt_dis *dis, void *attrib)
dis->attrib = g_attrib_ref(attrib);
- gatt_discover_char(dis->attrib, primary->range.start,
+ if (!dis->handle)
+ gatt_discover_char(dis->attrib, primary->range.start,
primary->range.end, NULL,
configure_deviceinfo_cb, dis);
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 05/12] android/hog: Add support for reading device details via DIS
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (2 preceding siblings ...)
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 ` 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
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
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 | 63 +++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 50 insertions(+), 13 deletions(-)
diff --git a/android/hog.c b/android/hog.c
index 55a3ee4..aae1f83 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -53,6 +53,7 @@
#include "btio/btio.h"
#include "android/scpp.h"
+#include "android/dis.h"
#include "android/hog.h"
#define HOG_UUID "00001812-0000-1000-8000-00805f9b34fb"
@@ -91,6 +92,7 @@ struct bt_hog {
uint16_t ctrlpt_handle;
uint8_t flags;
struct bt_scpp *scpp;
+ struct bt_dis *dis;
};
struct report {
@@ -647,6 +649,7 @@ static void report_free(void *data)
static void hog_free(struct bt_hog *hog)
{
bt_scpp_unref(hog->scpp);
+ bt_dis_unref(hog->dis);
bt_uhid_unref(hog->uhid);
g_slist_free_full(hog->reports, report_free);
g_attrib_unref(hog->attrib);
@@ -762,6 +765,30 @@ static void hog_attach_scpp(struct bt_hog *hog, struct gatt_primary *primary)
bt_scpp_attach(hog->scpp, hog->attrib);
}
+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;
@@ -789,26 +816,30 @@ static void primary_cb(uint8_t status, GSList *services, void *user_data)
continue;
}
+ 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)
@@ -829,6 +860,9 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)
if (hog->scpp)
bt_scpp_attach(hog->scpp, gatt);
+ 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,
@@ -861,9 +895,12 @@ void bt_hog_detach(struct bt_hog *hog)
g_attrib_unregister(hog->attrib, r->notifyid);
}
-
if (hog->scpp)
bt_scpp_detach(hog->scpp);
+
+ if (hog->dis)
+ bt_dis_detach(hog->dis);
+
g_attrib_unref(hog->attrib);
hog->attrib = NULL;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 06/12] android: Add initial implementation of Battery Service client
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (3 preceding siblings ...)
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 ` 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
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/Android.mk | 1 +
android/Makefile.am | 1 +
android/bas.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++
android/bas.h | 32 ++++++++++++
4 files changed, 171 insertions(+)
create mode 100644 android/bas.c
create mode 100644 android/bas.h
diff --git a/android/Android.mk b/android/Android.mk
index 3cd17d5..075fe70 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -37,6 +37,7 @@ LOCAL_SRC_FILES := \
bluez/android/bluetooth.c \
bluez/android/scpp.c \
bluez/android/dis.c \
+ bluez/android/bas.c \
bluez/android/hog.c \
bluez/android/hidhost.c \
bluez/android/socket.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index b1842f9..730be2f 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -40,6 +40,7 @@ android_bluetoothd_SOURCES = android/main.c \
android/hidhost.h android/hidhost.c \
android/scpp.h android/scpp.c \
android/dis.h android/dis.c \
+ android/bas.h android/bas.c \
android/hog.h android/hog.c \
android/ipc-common.h \
android/ipc.h android/ipc.c \
diff --git a/android/bas.c b/android/bas.c
new file mode 100644
index 0000000..ae7d274
--- /dev/null
+++ b/android/bas.c
@@ -0,0 +1,137 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ *
+ * This library is free software; you can rebastribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is bastributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdbool.h>
+#include <errno.h>
+
+#include <glib.h>
+
+#include "src/log.h"
+
+#include "lib/uuid.h"
+#include "src/shared/util.h"
+
+#include "attrib/gattrib.h"
+#include "attrib/att.h"
+#include "attrib/gatt.h"
+
+#include "android/bas.h"
+
+struct bt_bas {
+ int ref_count;
+ GAttrib *attrib;
+ struct gatt_primary *primary;
+ uint16_t handle;
+};
+
+static void bas_free(struct bt_bas *bas)
+{
+ if (bas->attrib)
+ g_attrib_unref(bas->attrib);
+
+ g_free(bas->primary);
+ g_free(bas);
+}
+
+struct bt_bas *bt_bas_new(void *primary)
+{
+ struct bt_bas *bas;
+
+ bas = g_try_new0(struct bt_bas, 1);
+ if (!bas)
+ return NULL;
+
+ if (primary)
+ bas->primary = g_memdup(primary, sizeof(*bas->primary));
+
+ return bt_bas_ref(bas);
+}
+
+struct bt_bas *bt_bas_ref(struct bt_bas *bas)
+{
+ if (!bas)
+ return NULL;
+
+ __sync_fetch_and_add(&bas->ref_count, 1);
+
+ return bas;
+}
+
+void bt_bas_unref(struct bt_bas *bas)
+{
+ if (!bas)
+ return;
+
+ if (__sync_sub_and_fetch(&bas->ref_count, 1))
+ return;
+
+ bas_free(bas);
+}
+
+static void bas_discovered_cb(uint8_t status, GSList *chars, void *user_data)
+{
+ struct bt_bas *bas = user_data;
+ struct gatt_char *chr;
+
+ if (status) {
+ error("Battery: %s", att_ecode2str(status));
+ return;
+ }
+
+ chr = chars->data;
+ bas->handle = chr->value_handle;
+
+ DBG("Battery handle: 0x%04x", bas->handle);
+
+ /* TODO: Add handling for notification */
+}
+
+bool bt_bas_attach(struct bt_bas *bas, void *attrib)
+{
+ if (!bas || bas->attrib || !bas->primary)
+ return false;
+
+ bas->attrib = g_attrib_ref(attrib);
+
+ if (bas->handle > 0)
+ return true;
+
+ gatt_discover_char(bas->attrib, bas->primary->range.start,
+ bas->primary->range.end, NULL,
+ bas_discovered_cb, bas);
+
+ return true;
+}
+
+void bt_bas_detach(struct bt_bas *bas)
+{
+ if (!bas || !bas->attrib)
+ return;
+
+ g_attrib_unref(bas->attrib);
+ bas->attrib = NULL;
+}
diff --git a/android/bas.h b/android/bas.h
new file mode 100644
index 0000000..3e175b5
--- /dev/null
+++ b/android/bas.h
@@ -0,0 +1,32 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ *
+ * This library is free software; you can rebastribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is bastributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+struct bt_bas;
+
+struct bt_bas *bt_bas_new(void *primary);
+
+struct bt_bas *bt_bas_ref(struct bt_bas *bas);
+void bt_bas_unref(struct bt_bas *bas);
+
+bool bt_bas_attach(struct bt_bas *bas, void *gatt);
+void bt_bas_detach(struct bt_bas *bas);
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 07/12] lib/uuid: Add define for Battery UUID
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (4 preceding siblings ...)
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 ` Luiz Augusto von Dentz
2014-06-27 18:08 ` [PATCH BlueZ v4 08/12] android/hog: Add support for Battery Service Luiz Augusto von Dentz
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
lib/uuid.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/uuid.h b/lib/uuid.h
index b44d6ae..7901d34 100644
--- a/lib/uuid.h
+++ b/lib/uuid.h
@@ -60,6 +60,7 @@ extern "C" {
#define IMMEDIATE_ALERT_UUID "00001802-0000-1000-8000-00805f9b34fb"
#define LINK_LOSS_UUID "00001803-0000-1000-8000-00805f9b34fb"
#define TX_POWER_UUID "00001804-0000-1000-8000-00805f9b34fb"
+#define BATTERY_UUID "0000180f-0000-1000-8000-00805f9b34fb"
#define SCAN_PARAMETERS_UUID "00001813-0000-1000-8000-00805f9b34fb"
#define SAP_UUID "0000112D-0000-1000-8000-00805f9b34fb"
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 08/12] android/hog: Add support for Battery Service
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (5 preceding siblings ...)
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
2014-06-27 18:08 ` [PATCH BlueZ v4 09/12] android/hog: Add support for multiple instaces Luiz Augusto von Dentz
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
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
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 09/12] android/hog: Add support for multiple instaces
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (6 preceding siblings ...)
2014-06-27 18:08 ` [PATCH BlueZ v4 08/12] android/hog: Add support for Battery Service Luiz Augusto von Dentz
@ 2014-06-27 18:08 ` 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
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is necessary to pass PTS tests which does include 2 instances.
---
android/hog.c | 49 +++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 41 insertions(+), 8 deletions(-)
diff --git a/android/hog.c b/android/hog.c
index f93f246..42b7d73 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -95,6 +95,7 @@ struct bt_hog {
struct bt_scpp *scpp;
struct bt_dis *dis;
struct bt_bas *bas;
+ GSList *instances;
};
struct report {
@@ -648,8 +649,12 @@ static void report_free(void *data)
g_free(report);
}
-static void hog_free(struct bt_hog *hog)
+static void hog_free(void *data)
{
+ struct bt_hog *hog = data;
+
+ g_slist_free_full(hog->instances, hog_free);
+
bt_scpp_unref(hog->scpp);
bt_dis_unref(hog->dis);
bt_bas_unref(hog->bas);
@@ -804,6 +809,27 @@ static void hog_attach_bas(struct bt_hog *hog, struct gatt_primary *primary)
bt_bas_attach(hog->bas, hog->attrib);
}
+static void hog_attach_hog(struct bt_hog *hog, struct gatt_primary *primary)
+{
+ struct bt_hog *instance;
+
+ if (!hog->primary) {
+ hog->primary = g_memdup(primary, sizeof(*primary));
+ gatt_discover_char(hog->attrib, primary->range.start,
+ primary->range.end, NULL,
+ char_discovered_cb, hog);
+ return;
+ }
+
+ instance = bt_hog_new(hog->name, hog->vendor, hog->product,
+ hog->version, primary);
+ if (!instance)
+ return;
+
+ bt_hog_attach(instance, hog->attrib);
+ hog->instances = g_slist_append(hog->instances, instance);
+}
+
static void primary_cb(uint8_t status, GSList *services, void *user_data)
{
struct bt_hog *hog = user_data;
@@ -842,16 +868,11 @@ static void primary_cb(uint8_t status, GSList *services, void *user_data)
}
if (strcmp(primary->uuid, HOG_UUID) == 0)
- hog->primary = g_memdup(primary, sizeof(*primary));
+ hog_attach_hog(hog, primary);
}
- if (hog->primary) {
- gatt_discover_char(hog->attrib, hog->primary->range.start,
- hog->primary->range.end, NULL,
- char_discovered_cb, hog);
-
+ if (hog->primary)
return;
- }
for (l = services; l; l = l->next) {
primary = l->data;
@@ -886,6 +907,12 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)
if (hog->bas)
bt_bas_attach(hog->bas, gatt);
+ for (l = hog->instances; l; l = l->next) {
+ struct bt_hog *instance = l->data;
+
+ bt_hog_attach(instance, gatt);
+ }
+
if (hog->reports == NULL) {
gatt_discover_char(hog->attrib, primary->range.start,
primary->range.end, NULL,
@@ -912,6 +939,12 @@ void bt_hog_detach(struct bt_hog *hog)
if (!hog->attrib)
return;
+ for (l = hog->instances; l; l = l->next) {
+ struct bt_hog *instance = l->data;
+
+ bt_hog_detach(instance);
+ }
+
for (l = hog->reports; l; l = l->next) {
struct report *r = l->data;
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 10/12] android/hog: Fix using the same callback for different descriptors
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (7 preceding siblings ...)
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 ` 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
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
External Report and Report descriptors take different user_data so have
different callbacks to avoid possible crash if a discover happen to find
the descriptors of unexpect type.
---
android/hog.c | 80 +++++++++++++++++++++++++++++++++++++----------------------
1 file changed, 50 insertions(+), 30 deletions(-)
diff --git a/android/hog.c b/android/hog.c
index 42b7d73..ad4eee5 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -166,14 +166,14 @@ static void report_ccc_written_cb(guint8 status, const guint8 *pdu,
DBG("Report characteristic descriptor written: notifications enabled");
}
-static void write_ccc(uint16_t handle, gpointer user_data)
+static void write_ccc(GAttrib *attrib, uint16_t handle, void *user_data)
{
- struct report *report = user_data;
- struct bt_hog *hog = report->hog;
- uint8_t value[] = { 0x01, 0x00 };
+ uint8_t value[2];
+
+ put_le16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value);
- gatt_write_char(hog->attrib, handle, value, sizeof(value),
- report_ccc_written_cb, report);
+ gatt_write_char(attrib, handle, value, sizeof(value),
+ report_ccc_written_cb, user_data);
}
static void report_reference_cb(guint8 status, const guint8 *pdu,
@@ -200,15 +200,45 @@ static void report_reference_cb(guint8 status, const guint8 *pdu,
static void external_report_reference_cb(guint8 status, const guint8 *pdu,
guint16 plen, gpointer user_data);
-static void discover_descriptor_cb(uint8_t status, GSList *descs,
- void *user_data)
+static void discover_external_cb(uint8_t status, GSList *descs, void *user_data)
{
- struct report *report;
- struct bt_hog *hog;
- GAttrib *attrib = NULL;
+ struct bt_hog *hog = user_data;
if (status != 0) {
- error("Discover all descriptors failed: %s",
+ error("Discover external descriptors failed: %s",
+ att_ecode2str(status));
+ return;
+ }
+
+ for ( ; descs; descs = descs->next) {
+ struct gatt_desc *desc = descs->data;
+
+ gatt_read_char(hog->attrib, desc->handle,
+ external_report_reference_cb, hog);
+ }
+}
+
+static void discover_external(GAttrib *attrib, uint16_t start, uint16_t end,
+ gpointer user_data)
+{
+ bt_uuid_t uuid;
+
+ if (start > end)
+ return;
+
+ bt_uuid16_create(&uuid, GATT_EXTERNAL_REPORT_REFERENCE);
+
+ gatt_discover_desc(attrib, start, end, NULL, discover_external_cb,
+ user_data);
+}
+
+static void discover_report_cb(uint8_t status, GSList *descs, void *user_data)
+{
+ struct report *report = user_data;
+ struct bt_hog *hog = report->hog;
+
+ if (status != 0) {
+ error("Discover report descriptors failed: %s",
att_ecode2str(status));
return;
}
@@ -218,34 +248,24 @@ static void discover_descriptor_cb(uint8_t status, GSList *descs,
switch (desc->uuid16) {
case GATT_CLIENT_CHARAC_CFG_UUID:
- report = user_data;
- attrib = report->hog->attrib;
- write_ccc(desc->handle, report);
+ write_ccc(hog->attrib, desc->handle, report);
break;
case GATT_REPORT_REFERENCE:
- report = user_data;
- attrib = report->hog->attrib;
- gatt_read_char(attrib, desc->handle,
+ gatt_read_char(hog->attrib, desc->handle,
report_reference_cb, report);
break;
- case GATT_EXTERNAL_REPORT_REFERENCE:
- hog = user_data;
- attrib = hog->attrib;
- gatt_read_char(attrib, desc->handle,
- external_report_reference_cb, hog);
- break;
}
}
}
-static void discover_descriptor(GAttrib *attrib, uint16_t start, uint16_t end,
+static void discover_report(GAttrib *attrib, uint16_t start, uint16_t end,
gpointer user_data)
{
if (start > end)
return;
- gatt_discover_desc(attrib, start, end, NULL,
- discover_descriptor_cb, user_data);
+ gatt_discover_desc(attrib, start, end, NULL, discover_report_cb,
+ user_data);
}
static void external_service_char_cb(uint8_t status, GSList *chars,
@@ -278,7 +298,7 @@ static void external_service_char_cb(uint8_t status, GSList *chars,
hog->reports = g_slist_append(hog->reports, report);
start = chr->value_handle + 1;
end = (next ? next->handle - 1 : primary->range.end);
- discover_descriptor(hog->attrib, start, end, report);
+ discover_report(hog->attrib, start, end, report);
}
}
@@ -614,11 +634,11 @@ static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
report->hog = hog;
report->decl = g_memdup(chr, sizeof(*chr));
hog->reports = g_slist_append(hog->reports, report);
- discover_descriptor(hog->attrib, start, end, report);
+ discover_report(hog->attrib, start, end, report);
} else if (bt_uuid_cmp(&uuid, &report_map_uuid) == 0) {
gatt_read_char(hog->attrib, chr->value_handle,
report_map_read_cb, hog);
- discover_descriptor(hog->attrib, start, end, hog);
+ discover_external(hog->attrib, start, end, hog);
} else if (bt_uuid_cmp(&uuid, &info_uuid) == 0)
info_handle = chr->value_handle;
else if (bt_uuid_cmp(&uuid, &proto_mode_uuid) == 0)
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 11/12] android/hog: Enable notifications only for Input Reports
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (8 preceding siblings ...)
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 ` 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
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:08 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
HoG spec has the following statement:
"The Report Host shall enable notifications, via the Client
Characteristic Configuration descriptor, of the Report characteristic
for all instances of the Report characteristic where the Report Type
as defined in the Report Reference characteristic descriptor
refers to an Input Report."
---
android/hog.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/android/hog.c b/android/hog.c
index ad4eee5..83f5d53 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -102,6 +102,7 @@ struct report {
struct bt_hog *hog;
uint8_t id;
uint8_t type;
+ uint16_t ccc_handle;
guint notifyid;
struct gatt_char *decl;
};
@@ -195,6 +196,10 @@ static void report_reference_cb(guint8 status, const guint8 *pdu,
report->id = pdu[1];
report->type = pdu[2];
DBG("Report ID: 0x%02x Report type: 0x%02x", pdu[1], pdu[2]);
+
+ /* Enable notifications only for Input Reports */
+ if (report->type == 0x01)
+ write_ccc(report->hog->attrib, report->ccc_handle, report);
}
static void external_report_reference_cb(guint8 status, const guint8 *pdu,
@@ -248,7 +253,7 @@ static void discover_report_cb(uint8_t status, GSList *descs, void *user_data)
switch (desc->uuid16) {
case GATT_CLIENT_CHARAC_CFG_UUID:
- write_ccc(hog->attrib, desc->handle, report);
+ report->ccc_handle = desc->handle;
break;
case GATT_REPORT_REFERENCE:
gatt_read_char(hog->attrib, desc->handle,
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH BlueZ v4 12/12] android/hog: Only discover if External Report has a Report UUID
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (9 preceding siblings ...)
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 ` Luiz Augusto von Dentz
2014-06-29 12:58 ` [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Szymon Janc
11 siblings, 0 replies; 13+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-27 18:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Some devices, including PTS, may include characteristics other than
Report as External Report.
---
android/hog.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/hog.c b/android/hog.c
index 83f5d53..7e61790 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -328,6 +328,11 @@ static void external_report_reference_cb(guint8 status, const guint8 *pdu,
uuid16 = get_le16(&pdu[1]);
DBG("External report reference read, external report characteristic "
"UUID: 0x%04x", uuid16);
+
+ /* Do not discover if is not a Report */
+ if (uuid16 != HOG_REPORT_UUID)
+ return;
+
bt_uuid16_create(&uuid, uuid16);
gatt_discover_char(hog->attrib, 0x0001, 0xffff, &uuid,
external_service_char_cb, hog);
--
1.9.3
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation
2014-06-27 18:08 [PATCH BlueZ v4 01/12] android/dis: Add copy to Device Info implementation Luiz Augusto von Dentz
` (10 preceding siblings ...)
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 ` Szymon Janc
11 siblings, 0 replies; 13+ messages in thread
From: Szymon Janc @ 2014-06-29 12:58 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Friday 27 of June 2014 21:08:49 Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> ---
> profiles/deviceinfo/deviceinfo.c => android/dis.c | 0
> 1 file changed, 0 insertions(+), 0 deletions(-)
> copy profiles/deviceinfo/deviceinfo.c => android/dis.c (100%)
>
> diff --git a/profiles/deviceinfo/deviceinfo.c b/android/dis.c
> similarity index 100%
> copy from profiles/deviceinfo/deviceinfo.c
> copy to android/dis.c
All patches applied, thanks.
--
BR
Szymon Janc
^ permalink raw reply [flat|nested] 13+ messages in thread