battery: Add BT SIG reserved numbers used by Battery Service
Subsystems (3)
PATCH v2 1/3 battery: Add BT SIG reserved numbers used by Battery Service
Add the Battery Level and Battery Power State UUIDs as per:
https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.battery_level.xml
https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.battery_power_state.xml
--- lib/uuid.h | 2 ++ 1 file changed, 2 insertions(+)
lib/uuid.h +2 -0
@@ -119,6 +119,8 @@ extern "C" {#define GATT_CHARAC_RECONNECTION_ADDRESS 0x2A03#define GATT_CHARAC_PERIPHERAL_PREF_CONN 0x2A04#define GATT_CHARAC_SERVICE_CHANGED 0x2A05 +#define GATT_CHARAC_BATTERY_LEVEL 0x2A19 +#define GATT_CHARAC_BATTERY_POWER_STATE 0x2A1A#define GATT_CHARAC_SYSTEM_ID 0x2A23#define GATT_CHARAC_MODEL_NUMBER_STRING 0x2A24#define GATT_CHARAC_SERIAL_NUMBER_STRING 0x2A25
Signature · 1 line
2.14.2
PATCH v2 2/3 profiles/battery: Add Bluetooth LE Battery service
Only the Battery Level characteristic was tested with a Microsoft Arc Touch Mouse SE.
This patch however hopes to support both the Battery Level and the Battery Power State characteristics.
--- Makefile.plugins | 3 + doc/battery-api.txt | 36 +++ profiles/battery/battery.c | 570 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 609 insertions(+) create mode 100644 doc/battery-api.txt create mode 100644 profiles/battery/battery.c
Makefile.plugins +3 -0
@@ -100,6 +100,9 @@ builtin_sources += profiles/midi/midi.c \ builtin_ldadd += @ALSA_LIBS@ endif +builtin_modules += battery +builtin_sources += profiles/battery/battery.c + if SIXAXIS plugin_LTLIBRARIES += plugins/sixaxis.la plugins_sixaxis_la_SOURCES = plugins/sixaxis.c
doc/battery-api.txt new file +36 -0
@@ -0,0 +1,36 @@ +BlueZ D-Bus Battery API description +*********************************** + + +Battery hierarchy +================= + +Service org.bluez +Interface org.bluez.Battery1 +Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX + +Properties boolean Present [readonly] + + Whether the device has a battery present. + + boolean Rechargeable [readonly] + + Whether the battery built into the device is rechargeable + or not. + + uint16 Percentage [readonly] + + The percentage of battery left. Will be 0% percent if State is + used instead, depending on the Battery profile used by the device. + + string State [readonly] + + If Percentage is set, State will be an empty string. Otherwise this + will be one of 'unknown', 'discharging', 'charging' or + 'fully-charged'. + + string BatteryLevel [readonly] + + If Percentage is set, BatteryLevel will be an empty string. + Otherwise this will be one of 'normal', 'critical' or + 'unknown'.
profiles/battery/battery.c new file +570 -0
570 lines not on this page · raw message
Signature · 1 line
2.14.2
PATCH v2 3/3 profiles/battery: Remove unused bas.[ch]
In reply to Bastien NoceraThe Battery Service characteristics are not children of the HoG characteristics, so there's nothing to consume in the input profile. Remove that code which duplicated most of the battery profile plugin.
--- Makefile.am | 1 - Makefile.plugins | 1 - android/Android.mk | 1 - android/Makefile.am | 1 - profiles/battery/bas.c | 340 ----------------------------------------------- profiles/battery/bas.h | 32 ----- profiles/input/hog-lib.c | 25 +--- 7 files changed, 1 insertion(+), 400 deletions(-) delete mode 100644 profiles/battery/bas.c delete mode 100644 profiles/battery/bas.h
Makefile.am +0 -1
@@ -404,7 +404,6 @@ unit_test_hog_SOURCES = unit/test-hog.c \ $(btio_sources) \ profiles/input/hog-lib.h profiles/input/hog-lib.c \ profiles/scanparam/scpp.h profiles/scanparam/scpp.c \ - profiles/battery/bas.h profiles/battery/bas.c \ profiles/deviceinfo/dis.h profiles/deviceinfo/dis.c \ src/log.h src/log.c \ attrib/att.h attrib/att.c \
Makefile.plugins +0 -1
@@ -66,7 +66,6 @@ builtin_modules += hog builtin_sources += profiles/input/hog.c profiles/input/uhid_copy.h \ profiles/input/hog-lib.c profiles/input/hog-lib.h \ profiles/deviceinfo/dis.c profiles/deviceinfo/dis.h \ - profiles/battery/bas.c profiles/battery/bas.h \ profiles/scanparam/scpp.c profiles/scanparam/scpp.h \ profiles/input/suspend.h profiles/input/suspend-none.c
android/Android.mk +0 -1
@@ -41,7 +41,6 @@ LOCAL_SRC_FILES := \ bluez/android/bluetooth.c \ bluez/profiles/scanparam/scpp.c \ bluez/profiles/deviceinfo/dis.c \ - bluez/profiles/battery/bas.c \ bluez/profiles/input/hog-lib.c \ bluez/android/hidhost.c \ bluez/android/socket.c \
android/Makefile.am +0 -1
@@ -32,7 +32,6 @@ android_bluetoothd_SOURCES = android/main.c \ profiles/scanparam/scpp.c \ profiles/deviceinfo/dis.h \ profiles/deviceinfo/dis.c \ - profiles/battery/bas.h profiles/battery/bas.c \ profiles/input/hog-lib.h \ profiles/input/hog-lib.c \ android/ipc-common.h \
profiles/battery/bas.c deleted +0 -340
340 lines not on this page · raw message
profiles/battery/bas.h deleted +0 -32
@@ -1,32 +0,0 @@ -/* -* -* 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);
profiles/input/hog-lib.c +1 -24
@@ -57,7 +57,6 @@#include "profiles/scanparam/scpp.h" #include "profiles/deviceinfo/dis.h" -#include "profiles/battery/bas.h" #include "profiles/input/hog-lib.h" #define HOG_UUID "00001812-0000-1000-8000-00805f9b34fb"
@@ -105,7 +104,6 @@ struct bt_hog {uint16_t setrep_id;struct bt_scpp *scpp;struct bt_dis *dis; -struct queue *bas;GSList *instances;struct queue *gatt_op; };
@@ -1174,7 +1172,6 @@ static void hog_free(void *data)bt_hog_detach (hog); -queue_destroy (hog->bas, (void *) bt_bas_unref);g_slist_free_full (hog->instances, hog_free);bt_scpp_unref (hog->scpp);
@@ -1323,7 +1320,6 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor,return NULL ; hog->gatt_op =queue_new (); - hog->bas =queue_new ();if (fd <0 ) hog->uhid =bt_uhid_new_default ();
@@ -1332,7 +1328,7 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor, hog->uhid_fd = fd; -if (!hog->gatt_op || !hog->bas || !hog->uhid) { +if (!hog->gatt_op || !hog->uhid) {hog_free (hog);return NULL ; }
@@ -1483,16 +1479,6 @@ 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) -{ -struct bt_bas *instance; - - instance =bt_bas_new (primary); - -bt_bas_attach (instance, hog->attrib); -queue_push_head (hog->bas, instance); -} -static void hog_attach_hog (struct bt_hog *hog,struct gatt_primary *primary) {struct bt_hog *instance;
@@ -1555,11 +1541,6 @@ 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_attach_hog (hog, primary); }
@@ -1585,8 +1566,6 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)if (hog->dis)bt_dis_attach (hog->dis, gatt); -queue_foreach (hog->bas, (void *) bt_bas_attach, gatt); -for (l = hog->instances; l; l = l->next) {struct bt_hog *instance = l->data;
@@ -1625,8 +1604,6 @@ void bt_hog_detach(struct bt_hog *hog)if (!hog->attrib)return ; -queue_foreach (hog->bas, (void *) bt_bas_detach,NULL ); -for (l = hog->instances; l; l = l->next) {struct bt_hog *instance = l->data;
Signature · 1 line
2.14.2
Re: [PATCH v2 2/3] profiles/battery: Add Bluetooth LE Battery service
In reply to Bastien NoceraQuoted 5 lines · Bastien Nocera
Only the Battery Level characteristic was tested with a Microsoft Arc Touch Mouse SE.
This patch however hopes to support both the Battery Level and the Battery Power State characteristics.
Interdiff for this one, fixing the "Connected" state not changing:
profiles/battery/battery.c +2 -0
@@ -400,6 +400,7 @@ static void batt_reset(struct batt *batt) batt->db =NULL ;bt_gatt_client_unregister_notify (batt->client, batt->batt_power_state_cb_id);bt_gatt_client_unregister_notify (batt->client, batt->batt_level_cb_id); +bt_gatt_client_cancel_all (batt->client);bt_gatt_client_unref (batt->client); batt->client =NULL ;if (batt->path) {
@@ -408,6 +409,7 @@ static void batt_reset(struct batt *batt)g_free (batt->path); batt->path =NULL ; } +btd_device_unref (batt->device); } static gboolean property_get_battery_level(
Luiz Augusto von Dentz
maintainerRe: [PATCH v2 3/3] profiles/battery: Remove unused bas.[ch]
In reply to Bastien NoceraHi Bastian,
Quoted 3 lines · Bastien Nocera
The Battery Service characteristics are not children of the HoG characteristics, so there's nothing to consume in the input profile. Remove that code which duplicated most of the battery profile plugin.
Id rather not do this, we actually do intend the maintain a small helper library that can be unit tested, what bt_bas lacks is just proper support of bt_gatt_client nothing else. Also for the record this would probably break BfA HoG qualification which requires battery service to be supported as well, Android code does not have any other bas implementation.
Quoted 543 lines
--- Makefile.am | 1 - Makefile.plugins | 1 - android/Android.mk | 1 - android/Makefile.am | 1 - profiles/battery/bas.c | 340 ----------------------------------------------- profiles/battery/bas.h | 32 ----- profiles/input/hog-lib.c | 25 +--- 7 files changed, 1 insertion(+), 400 deletions(-) delete mode 100644 profiles/battery/bas.c delete mode 100644 profiles/battery/bas.hMakefile.am +0
-1@@ -404,7 +404,6 @@ unit_test_hog_SOURCES = unit/test-hog.c \ $(btio_sources) \ profiles/input/hog-lib.h profiles/input/hog-lib.c \ profiles/scanparam/scpp.h profiles/scanparam/scpp.c \ - profiles/battery/bas.h profiles/battery/bas.c \ profiles/deviceinfo/dis.h profiles/deviceinfo/dis.c \ src/log.h src/log.c \ attrib/att.h attrib/att.c \Makefile.plugins +0
-1@@ -66,7 +66,6 @@ builtin_modules += hog builtin_sources += profiles/input/hog.c profiles/input/uhid_copy.h \ profiles/input/hog-lib.c profiles/input/hog-lib.h \ profiles/deviceinfo/dis.c profiles/deviceinfo/dis.h \ - profiles/battery/bas.c profiles/battery/bas.h \ profiles/scanparam/scpp.c profiles/scanparam/scpp.h \ profiles/input/suspend.h profiles/input/suspend-none.candroid/Android.mk +0
-1@@ -41,7 +41,6 @@ LOCAL_SRC_FILES := \ bluez/android/bluetooth.c \ bluez/profiles/scanparam/scpp.c \ bluez/profiles/deviceinfo/dis.c \ - bluez/profiles/battery/bas.c \ bluez/profiles/input/hog-lib.c \ bluez/android/hidhost.c \ bluez/android/socket.c \android/Makefile.am +0
-1@@ -32,7 +32,6 @@ android_bluetoothd_SOURCES = android/main.c \ profiles/scanparam/scpp.c \ profiles/deviceinfo/dis.h \ profiles/deviceinfo/dis.c \ - profiles/battery/bas.h profiles/battery/bas.c \ profiles/input/hog-lib.h \ profiles/input/hog-lib.c \ android/ipc-common.h \profiles/battery/bas.c deleted +0
-340@@ -1,340 +0,0 @@ -/* -* -* 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/bluetooth.h" -#include "lib/sdp.h" -#include "lib/uuid.h" - -#include "src/shared/util.h" -#include "src/shared/queue.h" - -#include "attrib/gattrib.h" -#include "attrib/att.h" -#include "attrib/gatt.h" - -#include "profiles/battery/bas.h" - -#define ATT_NOTIFICATION_HEADER_SIZE 3 -#define ATT_READ_RESPONSE_HEADER_SIZE 1 - -struct bt_bas { -int ref_count; -GAttrib *attrib; -struct gatt_primary *primary; -uint16_t handle; -uint16_t ccc_handle; -guint id; -struct queue *gatt_op; -}; - -struct gatt_request { -unsigned int id; -struct bt_bas *bas; -void *user_data; -}; - -static void destroy_gatt_req (struct gatt_request *req) -{ -queue_remove (req->bas->gatt_op, req); -bt_bas_unref (req->bas); -free (req); -} - -static void bas_free (struct bt_bas *bas) -{ -bt_bas_detach (bas); - -g_free (bas->primary); -queue_destroy (bas->gatt_op, (void *) destroy_gatt_req); -free (bas); -} - -struct bt_bas *bt_bas_new (void *primary) -{ -struct bt_bas *bas; - - bas = new0(struct bt_bas, 1); - bas->gatt_op =queue_new (); - -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 struct gatt_request *create_request (struct bt_bas *bas, -void *user_data) -{ -struct gatt_request *req; - - req = new0(struct gatt_request, 1); - req->user_data = user_data; - req->bas =bt_bas_ref (bas); - -return req; -} - -static void set_and_store_gatt_req (struct bt_bas *bas, -struct gatt_request *req, -unsigned int id) -{ - req->id = id; -queue_push_head (bas->gatt_op, req); -} - -static void write_char (struct bt_bas *bas,GAttrib *attrib,uint16_t handle, -const uint8_t *value,size_t vlen, -GAttribResultFunc func, -gpointer user_data) -{ -struct gatt_request *req; -unsigned int id; - - req =create_request (bas, user_data); - - id =gatt_write_char (attrib, handle, value, vlen, func, req); - -set_and_store_gatt_req (bas, req, id); -} - -static void read_char (struct bt_bas *bas,GAttrib *attrib,uint16_t handle, -GAttribResultFunc func,gpointer user_data) -{ -struct gatt_request *req; -unsigned int id; - - req =create_request (bas, user_data); - - id =gatt_read_char (attrib, handle, func, req); - -set_and_store_gatt_req (bas, req, id); -} - -static void discover_char (struct bt_bas *bas,GAttrib *attrib, -uint16_t start,uint16_t end, -bt_uuid_t *uuid,gatt_cb_t func, -gpointer user_data) -{ -struct gatt_request *req; -unsigned int id; - - req =create_request (bas, user_data); - - id =gatt_discover_char (attrib, start, end, uuid, func, req); - -set_and_store_gatt_req (bas, req, id); -} - -static void discover_desc (struct bt_bas *bas,GAttrib *attrib, -uint16_t start,uint16_t end,bt_uuid_t *uuid, -gatt_cb_t func,gpointer user_data) -{ -struct gatt_request *req; -unsigned int id; - - req =create_request (bas, user_data); - - id =gatt_discover_desc (attrib, start, end, uuid, func, req); -set_and_store_gatt_req (bas, req, id); -} - -static void notification_cb (const guint8 *pdu,guint16 len,gpointer user_data) -{ -DBG ("Battery Level at %u" , pdu[ATT_NOTIFICATION_HEADER_SIZE ]); -} - -static void read_value_cb (guint8 status,const guint8 *pdu,guint16 len, -gpointer user_data) -{ -DBG ("Battery Level at %u" , pdu[ATT_READ_RESPONSE_HEADER_SIZE ]); -} - -static void ccc_written_cb (guint8 status,const guint8 *pdu, -guint16 plen,gpointer user_data) -{ -struct gatt_request *req = user_data; -struct bt_bas *bas = req->user_data; - -destroy_gatt_req (req); - -if (status !=0 ) { -error ("Write Scan Refresh CCC failed: %s" , -att_ecode2str (status)); -return ; - } - -DBG ("Battery Level: notification enabled" ); - - bas->id =g_attrib_register (bas->attrib,ATT_OP_HANDLE_NOTIFY , - bas->handle, notification_cb, bas, -NULL ); -} - -static void write_ccc (struct bt_bas *bas,GAttrib *attrib,uint16_t handle, -void *user_data) -{ -uint8_t value[2 ]; - -put_le16 (GATT_CLIENT_CHARAC_CFG_NOTIF_BIT , value); - -write_char (bas, attrib, handle, value,sizeof (value), ccc_written_cb, - user_data); -} - -static void ccc_read_cb (guint8 status,const guint8 *pdu,guint16 len, -gpointer user_data) -{ -struct gatt_request *req = user_data; -struct bt_bas *bas = req->user_data; - -destroy_gatt_req (req); - -if (status !=0 ) { -error ("Error reading CCC value: %s" ,att_ecode2str (status)); -return ; - } - -write_ccc (bas, bas->attrib, bas->ccc_handle, bas); -} - -static void discover_descriptor_cb (uint8_t status,GSList *descs, -void *user_data) -{ -struct gatt_request *req = user_data; -struct bt_bas *bas = req->user_data; -struct gatt_desc *desc; - -destroy_gatt_req (req); - -if (status !=0 ) { -error ("Discover descriptors failed: %s" ,att_ecode2str (status)); -return ; - } - -/* There will be only one descriptor on list and it will be CCC */ - desc = descs->data; - bas->ccc_handle = desc->handle; - -read_char (bas, bas->attrib, desc->handle, ccc_read_cb, bas); -} - -static void bas_discovered_cb (uint8_t status,GSList *chars,void *user_data) -{ -struct gatt_request *req = user_data; -struct bt_bas *bas = req->user_data; -struct gatt_char *chr; -uint16_t start, end; -bt_uuid_t uuid; - -destroy_gatt_req (req); - -if (status) { -error ("Battery: %s" ,att_ecode2str (status)); -return ; - } - - chr = chars->data; - bas->handle = chr->value_handle; - -DBG ("Battery handle: 0x%04x" , bas->handle); - -read_char (bas, bas->attrib, bas->handle, read_value_cb, bas); - - start = chr->value_handle +1 ; - end = bas->primary->range.end; - -bt_uuid16_create (&uuid,GATT_CLIENT_CHARAC_CFG_UUID ); - -discover_desc (bas, bas->attrib, start, end, &uuid, - discover_descriptor_cb, bas); -} - -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; - -discover_char (bas, bas->attrib, bas->primary->range.start, - bas->primary->range.end,NULL , - bas_discovered_cb, bas); - -return true; -} - -static void cancel_gatt_req (struct gatt_request *req) -{ -if (g_attrib_cancel (req->bas->attrib, req->id)) -destroy_gatt_req (req); -} - -void bt_bas_detach (struct bt_bas *bas) -{ -if (!bas || !bas->attrib) -return ; - -if (bas->id >0 ) { -g_attrib_unregister (bas->attrib, bas->id); - bas->id =0 ; - } - -queue_foreach (bas->gatt_op, (void *) cancel_gatt_req,NULL ); -g_attrib_unref (bas->attrib); - bas->attrib =NULL ; -}profiles/battery/bas.h deleted +0
-32@@ -1,32 +0,0 @@ -/* -* -* 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);profiles/input/hog-lib.c +1
-25@@ -57,7 +57,6 @@#include "profiles/scanparam/scpp.h" #include "profiles/deviceinfo/dis.h" -#include "profiles/battery/bas.h" #include "profiles/input/hog-lib.h" #define HOG_UUID "00001812-0000-1000-8000-00805f9b34fb"@@ -105,7 +104,6 @@ struct bt_hog {uint16_t setrep_id;struct bt_scpp *scpp;struct bt_dis *dis; -struct queue *bas;GSList *instances;struct queue *gatt_op; };@@ -1174,7 +1172,6 @@ static void hog_free(void *data)bt_hog_detach (hog); -queue_destroy (hog->bas, (void *) bt_bas_unref);g_slist_free_full (hog->instances, hog_free);bt_scpp_unref (hog->scpp);@@ -1323,7 +1320,6 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor,return NULL ; hog->gatt_op =queue_new (); - hog->bas =queue_new ();if (fd <0 ) hog->uhid =bt_uhid_new_default ();@@ -1332,7 +1328,7 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor, hog->uhid_fd = fd; -if (!hog->gatt_op || !hog->bas || !hog->uhid) { +if (!hog->gatt_op || !hog->uhid) {hog_free (hog);return NULL ; }@@ -1483,16 +1479,6 @@ 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) -{ -struct bt_bas *instance; - - instance =bt_bas_new (primary); - -bt_bas_attach (instance, hog->attrib); -queue_push_head (hog->bas, instance); -} -static void hog_attach_hog (struct bt_hog *hog,struct gatt_primary *primary) {struct bt_hog *instance;@@ -1555,11 +1541,6 @@ 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_attach_hog (hog, primary); }@@ -1585,8 +1566,6 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt)if (hog->dis)bt_dis_attach (hog->dis, gatt); -queue_foreach (hog->bas, (void *) bt_bas_attach, gatt); -for (l = hog->instances; l; l = l->next) {struct bt_hog *instance = l->data;@@ -1625,8 +1604,6 @@ void bt_hog_detach(struct bt_hog *hog)if (!hog->attrib)return ; -queue_foreach (hog->bas, (void *) bt_bas_detach,NULL ); -for (l = hog->instances; l; l = l->next) {struct bt_hog *instance = l->data; --2.14.2
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH v2 3/3] profiles/battery: Remove unused bas.[ch]
Quoted 10 lines · Luiz Augusto von Dentz
Hi Bastian,
Quoted 5 lines · Bastien Nocera
The Battery Service characteristics are not children of the HoG characteristics, so there's nothing to consume in the input profile.
Remove that code which duplicated most of the battery profile plugin.
Quoted 7 lines
Id rather not do this, we actually do intend the maintain a small helper library that can be unit tested, what
bt_baslacks is just proper support ofbt_gatt_clientnothing else. Also for the record this would probably break BfA HoG qualification which requires battery
service to be supported as well, Android code does not have any other bas implementation.
That's fine, we can leave this file around. What about the other patches?
Luiz Augusto von Dentz
maintainerRe: [PATCH v2 3/3] profiles/battery: Remove unused bas.[ch]
Hi Bastien,
Quoted 19 lines · Bastien Nocera
Quoted 10 lines · Luiz Augusto von Dentz
Hi Bastian,
Quoted 5 lines · Bastien Nocera
The Battery Service characteristics are not children of the HoG characteristics, so there's nothing to consume in the input profile.
Remove that code which duplicated most of the battery profile plugin.Quoted 7 lines
Id rather not do this, we actually do intend the maintain a small helper library that can be unit tested, what
bt_baslacks is just proper support ofbt_gatt_clientnothing else. Also for the record this would probably break BfA HoG qualification which requires battery
service to be supported as well, Android code does not have any other bas implementation.
Quoted 2 lines
That's fine, we can leave this file around. What about the other patches?
Id move the code around bt_gatt_client to bt_bas and let it handle the internal details, the long term plan is to get rid of GAttrib so perhaps we should start with bas.
Signature · 1 line
Luiz Augusto von Dentz
Re: [PATCH v2 3/3] profiles/battery: Remove unused bas.[ch]
Quoted 26 lines · Luiz Augusto von Dentz
Hi Bastien,
Quoted 22 lines · Bastien Nocera
Quoted 20 lines · Luiz Augusto von Dentz
Hi Bastian,
Quoted 5 lines · Bastien Nocera
The Battery Service characteristics are not children of the HoG characteristics, so there's nothing to consume in the input profile.
Remove that code which duplicated most of the battery profile plugin.Id rather not do this, we actually do intend the maintain a small helper library that can be unit tested, what
bt_baslacks is just proper support ofbt_gatt_clientnothing else. Also for the record
this would probably break BfA HoG qualification which requires battery
service to be supported as well, Android code does not have any other
bas implementation.
Quoted 7 lines
Quoted 2 lines
That's fine, we can leave this file around. What about the other patches?
Id move the code around
bt_gatt_clienttobt_basand let it handle the
internal details, the long term plan is to get rid of GAttrib so perhaps we should start with bas.
Right. That won't be me though. bas.c is a stub which isn't even capable of getting a value from the device.
If somebody wants to split off the battery.c code into a newer bas.c, I'm fine with that, but I'm not porting that code, _then_ implementing its logic when I've already done that in battery.c.
Cheers