android/dis: Add copy to Device Info implementation
Luiz Augusto von Dentz
maintainerPATCH 1/4 android/dis: Add copy to Device Info implementation
From: Luiz Augusto von Dentz <[email protected]>
--- profiles/deviceinfo/deviceinfo.c => android/dis.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) copy profiles/deviceinfo/deviceinfo.c => android/dis.c (100%)
android/dis.c renamed from profiles/deviceinfo/deviceinfo.c +0 -0
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH 2/4 android/dis: Strip dependencies from deviceinfo plugin
From: Luiz Augusto von Dentz <[email protected]>
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
android/Android.mk +1 -0
@@ -35,6 +35,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES := \ bluez/android/main.c \ bluez/android/bluetooth.c \ + bluez/android/dis.c \ bluez/android/hog.c \ bluez/android/hidhost.c \ bluez/android/socket.c \
android/Makefile.am +1 -0
@@ -38,6 +38,7 @@ android_bluetoothd_SOURCES = android/main.c \ src/shared/uhid.h src/shared/uhid.c \ android/bluetooth.h android/bluetooth.c \ android/hidhost.h android/hidhost.c \ + android/dis.h android/dis.c \ android/hog.h android/hog.c \ android/ipc-common.h \ android/ipc.h android/ipc.c \
android/dis.c +72 -82
213 lines not on this page · raw message
android/dis.h new file +32 -0
@@ -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);
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH 3/4 android/dis: Add bt_dis_set_notification
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
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(+)
android/dis.c +21 -0
@@ -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; +}
android/dis.h +7 -0
@@ -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);
Signature · 1 line
1.9.3
Luiz Augusto von Dentz
maintainerPATCH 4/4 android/hog: Add support for reading device details via DIS
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
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 | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-)
android/hog.c +42 -12
@@ -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 {
@@ -647,6 +649,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);
@@ -750,6 +753,16 @@ 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 primary_cb (uint8_t status,GSList *services,void *user_data) {struct bt_hog *hog = user_data;
@@ -772,26 +785,40 @@ 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 ) { +if (hog->dis) { +bt_dis_attach (hog->dis, hog->attrib); +continue ; + } + + 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); + } +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)
@@ -841,6 +868,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 ; }
Signature · 1 line
1.9.3