Skip to contentSkip to conversation

battery: Add BT SIG reserved number used by Battery Service

PATCH Applied Bastien Nocera 2 participants 3 messages Nov 2, 2017 – Nov 3, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/2 battery: Add BT SIG reserved number used by Battery Service

Add the Battery Level UUID as per:
https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.battery_level.xml

---
 lib/uuid.h | 1 +
 1 file changed, 1 insertion(+)
lib/uuid.h +1 -0
index 2c57a3378..7e13e0fda 100644
@@ -119,6 +119,7 @@ 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_SYSTEM_ID				0x2A23
 #define GATT_CHARAC_MODEL_NUMBER_STRING			0x2A24
 #define GATT_CHARAC_SERIAL_NUMBER_STRING		0x2A25
Signature · 1 line
2.14.3
#1 lore raw

PATCH v5 2/2 profiles/battery: Add Bluetooth LE Battery service

The Battery Level characteristic was tested with a Microsoft Arc Touch Mouse SE.

The Battery1 interface is now exported for Bluetooth LE devices which support the Battery Level characteristic, providing a single "Percentage" value to other integration points in the OS, such as UPower for consumption on most free desktops.

See https://bugs.freedesktop.org/show_bug.cgi?id=92370

---
 Makefile.plugins           |   3 +
 doc/battery-api.txt        |  14 ++
 profiles/battery/battery.c | 373 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 390 insertions(+)
 create mode 100644 doc/battery-api.txt
 create mode 100644 profiles/battery/battery.c
Makefile.plugins +3 -0
index 73377e532..1f3b5b552 100644
@@ -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 +14 -0
new file mode 100644
index 000000000..dc7dbeda2
@@ -0,0 +1,14 @@
+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	byte Percentage [readonly]
+
+			The percentage of battery left as an unsigned 8-bit integer.
profiles/battery/battery.c new file +373 -0

373 lines not on this page · raw message

Signature · 1 line
2.14.3
maintainer Applied
#2 lore raw
In reply to Bastien Nocera

Hi,

Quoted 19 lines · Bastien Nocera

Add the Battery Level UUID as per:
https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.battery_level.xml

---
 lib/uuid.h | 1 +
 1 file changed, 1 insertion(+)
lib/uuid.h +1 -1
index 2c57a3378..7e13e0fda 100644
@@ -119,6 +119,7 @@ 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_SYSTEM_ID                          0x2A23
 #define GATT_CHARAC_MODEL_NUMBER_STRING                        0x2A24
 #define GATT_CHARAC_SERIAL_NUMBER_STRING               0x2A25
--
Quoted 1 line

2.14.3

Applied, thanks.

Signature · 1 line
Luiz Augusto von Dentz