2017-02-25 00:13:23

by Juha Kuikka

[permalink] [raw]
Subject: [PATCH 0/3] Fix zero VID&PID on HoG initial connection

When a BLE HID-over-GATT (HoG) device is initially connected, the created uHID
device has zero VID and PID, this is due to couple issues in how HoG handles
Device Information Service (DIS).

This patch set provices a fix for this.

Juha Kuikka (3):
dis: Fix attribute handle when initializing from db
hog: Move dis_notify around
hog: When no VID&PID also register a DIS notifier

profiles/deviceinfo/dis.c | 21 ++++++++++++++++++++-
profiles/input/hog-lib.c | 21 +++++++++++----------
2 files changed, 31 insertions(+), 11 deletions(-)

--
2.7.4



2017-02-25 15:11:11

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 0/3] Fix zero VID&PID on HoG initial connection

Hi Juha,

On Sat, Feb 25, 2017 at 2:13 AM, Juha Kuikka <[email protected]> wrote:
> When a BLE HID-over-GATT (HoG) device is initially connected, the created uHID
> device has zero VID and PID, this is due to couple issues in how HoG handles
> Device Information Service (DIS).
>
> This patch set provices a fix for this.
>
> Juha Kuikka (3):
> dis: Fix attribute handle when initializing from db
> hog: Move dis_notify around
> hog: When no VID&PID also register a DIS notifier
>
> profiles/deviceinfo/dis.c | 21 ++++++++++++++++++++-
> profiles/input/hog-lib.c | 21 +++++++++++----------
> 2 files changed, 31 insertions(+), 11 deletions(-)
>
> --
> 2.7.4

Applied, thanks.


--
Luiz Augusto von Dentz

2017-02-25 00:13:26

by Juha Kuikka

[permalink] [raw]
Subject: [PATCH 3/3] hog: When no VID&PID also register a DIS notifier

DIS was reading VID & PID but they were not communicated to the HOG due to lack
of registered notifier.

Add a notified also in this case.
---
profiles/input/hog-lib.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index 71de3a1..dab385f 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -1406,6 +1406,7 @@ struct bt_hog *bt_hog_new(int fd, const char *name, uint16_t vendor,
/* Try creating a DIS instance in case pid/vid are not set */
if (!vendor && !product) {
hog->dis = bt_dis_new(db);
+ bt_dis_set_notification(hog->dis, dis_notify, hog);
}
}

--
2.7.4


2017-02-25 00:13:25

by Juha Kuikka

[permalink] [raw]
Subject: [PATCH 2/3] hog: Move dis_notify around

No functional changes
---
profiles/input/hog-lib.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/profiles/input/hog-lib.c b/profiles/input/hog-lib.c
index b93324a..71de3a1 100644
--- a/profiles/input/hog-lib.c
+++ b/profiles/input/hog-lib.c
@@ -1372,6 +1372,16 @@ static void foreach_hog_service(struct gatt_db_attribute *attr, void *user_data)
hog_attach_instace(hog, attr);
}

+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;
+}
+
struct bt_hog *bt_hog_new(int fd, const char *name, uint16_t vendor,
uint16_t product, uint16_t version,
struct gatt_db *db)
@@ -1458,16 +1468,6 @@ 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) {
--
2.7.4


2017-02-25 00:13:24

by Juha Kuikka

[permalink] [raw]
Subject: [PATCH 1/3] dis: Fix attribute handle when initializing from db

The handle field in struct bt_dis is initialized to the handle of the DIS gatt
service. It should be the value handle of the PNP ID characteristic.

This patch fixes the issue.
---
profiles/deviceinfo/dis.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/profiles/deviceinfo/dis.c b/profiles/deviceinfo/dis.c
index 91ce26b..6126a77 100644
--- a/profiles/deviceinfo/dis.c
+++ b/profiles/deviceinfo/dis.c
@@ -90,6 +90,25 @@ static void dis_free(struct bt_dis *dis)
g_free(dis);
}

+static void foreach_dis_char(struct gatt_db_attribute *attr, void *user_data)
+{
+ struct bt_dis *dis = user_data;
+ bt_uuid_t pnpid_uuid, uuid;
+ uint16_t value_handle;
+
+ /* Ignore if there are multiple instances */
+ if (dis->handle)
+ return;
+
+ if (!gatt_db_attribute_get_char_data(attr, NULL, &value_handle, NULL, NULL, &uuid))
+ return;
+
+ /* Find PNPID characteristic's value handle */
+ bt_string_to_uuid(&pnpid_uuid, PNPID_UUID);
+ if (bt_uuid_cmp(&pnpid_uuid, &uuid) == 0)
+ dis->handle = value_handle;
+}
+
static void foreach_dis_service(struct gatt_db_attribute *attr, void *user_data)
{
struct bt_dis *dis = user_data;
@@ -98,7 +117,7 @@ static void foreach_dis_service(struct gatt_db_attribute *attr, void *user_data)
if (dis->handle)
return;

- dis->handle = gatt_db_attribute_get_handle(attr);
+ gatt_db_service_foreach_char(attr, foreach_dis_char, dis);
}

struct bt_dis *bt_dis_new(struct gatt_db *db)
--
2.7.4