Commit Graph

38 Commits (master)

Author SHA1 Message Date
Peter Hutterer 27164aba52 Fix flake8 errors - f-string without placeholders
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-01-22 17:09:27 +10:00
Peter Hutterer 74ffe763b6 ble: downgrade three more debug messages
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-03 16:22:18 +10:00
Peter Hutterer 97a4ab04d0 ble: downgrade a message from info to debug
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-08-29 10:42:10 +10:00
Daniel Martin b52891f8fd ble: prefix all device logs with address
Use a logger child in BlueZDevice prefixing all log messages with the
device address.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
2019-06-07 08:34:07 +10:00
Daniel Martin c719ecf2e2 ble: use properties instead of variables
Replace variables (objpath, interface, uuid) with properties.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
2019-06-07 08:34:07 +10:00
Daniel Martin 7f9e58e587 ble: simplify GATT characteristic lookup
No need to get triggered by BlueZDeviceManager when it finds any GATT
characteristic. The BlueZDevice just needs its 'ServicesResolved' and
can resolve the GATT characteristics itself.

This solves a FIXME.

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
2019-06-07 08:34:07 +10:00
Daniel Martin e7f8cc2bc2 ble: make object manager return sorted object list
The object list returned by object managers get_objects() function is
not sorted. Though, we rely on objects being sorted by their object
path.

Replace the object managers get_objects() function with a variant
fixing that. Additionally, our variant makes it possible to filter
the returned object list by object path and interface.

Examples:

- get_objects():
  /
  /org/bluez
  /org/bluez/hci0
  /org/bluez/hci0/dev_00_00_00_00_00_00
  /org/bluez/hci0/dev_00_00_00_00_00_00/service0000
  /org/bluez/hci0/dev_00_00_00_00_00_00/service0000/char0000
  /org/bluez/hci0/dev_00_00_00_00_00_00/service1111
  /org/bluez/hci0/dev_00_00_00_00_00_00/service1111/char1111
  /org/bluez/hci0/dev_FF_FF_FF_FF_FF_FF
  /org/bluez/hci0/dev_FF_FF_FF_FF_FF_FF/serviceffff
  /org/bluez/hci0/dev_FF_FF_FF_FF_FF_FF/serviceffff/charffff

- get_objects(interface='org.bluez.Adapter1'):
  /org/bluez/hci0

- get_objects(interface='org.bluez.GattCharacteristic1'
              base_path='/org/bluez/hci0/dev_00_00_00_00_00_00'):
  /org/bluez/hci0/dev_00_00_00_00_00_00/service0000/char0000
  /org/bluez/hci0/dev_00_00_00_00_00_00/service1111/char1111

Signed-off-by: Daniel Martin <consume.noise@gmail.com>
2019-06-07 08:34:07 +10:00
Peter Hutterer 4b02a6f51c Fix flake8-3 complaints
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-05 10:58:21 +02:00
Peter Hutterer 9fbfe17e13 ble: disable a debug message
Now that we got the basics running and reliable, this debug message is mostly
just noise, especially when in an office with lots of bluetooth devices
around. Comment it out, to be enabled when necessary.
2018-02-16 15:43:28 +10:00
Peter Hutterer 637f539194 ble: drop the 'event' argument from device-added
An 'event' boolean is less than obvious ('is-event' may be better). This
signalled the difference between a device-added during Manager startup and the
device-added at runtime (i.e. device goes online).

We don't need that differentiation. The manager adds all existing devices
immediately after connnect_to_bluez(). All we have to do is run through the
device list, add them locally and then subscribe to the signal.

This keeps the is-event confusion within one file only instead of spreading it
across two and an internal API. And we can re-name it to hotplugged.
2018-02-13 14:51:40 +01:00
Peter Hutterer 46ec85d718 ble: make manufacturer_data a property
We only ever used it in conjunction with vendor_id, so we can just make this a
normal property and send GObject notifies when it changes. This allows us to
listen for the MD to change when it finished registration.

[BT: do not add the second indirection by calling vendor_id]
2018-02-09 11:34:42 +01:00
Benjamin Tissoires 72523df3af ble: make sure the length of the manufacturer data is at least 1
We never encounter the issue, but I bet we will
2018-02-09 11:34:42 +01:00
Peter Hutterer ae41b23c10 ble: don't make property updates exclusive
A single event may be sent for multiple properties, we need to check all of
them.
2018-02-09 10:28:43 +01:00
Benjamin Tissoires fc219e4c57 janitor: silence deprecated warnings
While running the app in flatpak, there are a few deprecation warnings
coming in:
PyGIDeprecationWarning: GObject.SIGNAL_RUN_FIRST is deprecated;
	use GObject.SignalFlags.RUN_FIRST instead
PyGIDeprecationWarning: GObject.property is deprecated;
	use GObject.Property instead
PyGIDeprecationWarning: GObject.MainLoop is deprecated;
	use GLib.MainLoop instead
2018-02-02 10:46:47 +10:00
Peter Hutterer 9cecc1b535 Replace @property with @GObject.property
Let's stick to just one for consistency
2018-02-01 10:13:22 +10:00
Benjamin Tissoires 9f118bbe15 janitor: convert double quotes into single quotes
Let's the developers of tuhi to consume more energy in their monitor
to light up more pixel when displaying single quotes whereas double
quotes.

It also makes the whole bit more uniform.

Fixes #32
2018-01-29 21:18:06 +10:00
Benjamin Tissoires 04f25a0a38 drop .format(), switch to f{} everywhere
and change some double quotes into single quotes when encountering them.

It's a new project, so force use of Python 3.6 right now

Fixes #29
2018-01-29 21:18:06 +10:00
Peter Hutterer 44a2d5e8eb ble: if we connect twice, log the error as debug
We likely get multiple 'udpated' notifications as the RSSI property changes,
all causing a Connect() on the device and an ugly error message (that we used
to catch and print). Make that error message prettier.
2018-01-23 14:22:33 +10:00
Peter Hutterer f9ba9fe6ca ble: don't crash if a device doesn't have a Name attribute
Hello, tradies next door with your weird phones...
2018-01-23 14:22:33 +10:00
Benjamin Tissoires ca82af78de tuhi: handle cold-plugged devices
When bluez restarts (or the tuhi daemon restarts), the values we have
in the bluez device's field ManufacturerData are quite not accurate.

When bluez restarts they are empty, and if the last time we saw the
device was for the pairing process, the device will still be marked
as in the pairing mode.

So we should mark the cold-plug sequence differently from the hot-plug
one, and we should be more confident in the current configuration we
have stored to export the currently known devices over dbus.

Fixes #13
2018-01-23 14:22:33 +10:00
Benjamin Tissoires 3e5ef6c939 ble: remove the duplicate events filter
So we get more chances of capturing the advertisement from the device
if it is rather static.
2018-01-22 15:24:56 +10:00
Benjamin Tissoires 380518d0c7 ble: keep track of Start/StopDiscovery
discovery-stopped may call stop_discovery() if there
is no client listening, resulting in an infinite loop
2018-01-22 15:24:26 +10:00
Peter Hutterer 5f9766cb71 ble: catch and ignore the InProgress error when we're already listening 2018-01-19 13:45:32 +10:00
Peter Hutterer aa1820e21c Send out the PairableDevice signal when we have a device 2018-01-19 11:15:12 +10:00
Benjamin Tissoires c073ff2f06 ignore Wacom devices that are in pairing mode
When the device is in pairing mode (blinking blue), the manufacturer
data contains less than 7 fields. We should ignore those devices
as we are not supposed to pull pen data out of them.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-01-19 11:08:16 +10:00
Peter Hutterer 43b1c4057c dbus: implement StartPairing/StopPairing on the manager
Triggers a StartDiscovery()/StopDiscovery() on the bluetooth adapters, but
with a fixed timeout of 30s.
2018-01-19 11:07:25 +10:00
Peter Hutterer f9756a71ce Add commandline arguments to enable verbose mode
Create a logger hierarchy, that way we only need to set the root logger to
DEBUG and the rest goes along with it.
2018-01-17 13:41:35 +01:00
Benjamin Tissoires f88a5b2222 wacom: disconnect when we have finished retrieving the data
There is no point keeping the connection alive just to drain the battery.
2018-01-17 13:41:35 +01:00
Peter Hutterer dde2ad4b46 ble: use ServicesResolved for the connected signal 2018-01-17 13:41:35 +01:00
Peter Hutterer febde33f0a ble: wrap the DBus properties into property functions 2018-01-15 16:14:11 +10:00
Peter Hutterer 6de262d2e9 ble: more documentation 2018-01-15 16:14:11 +10:00
Peter Hutterer 35e75b4aa7 ble: match the disconnected signal with 'connect'
No need to pass self as argument, it's the first argument to the signal
handler anyway
2018-01-15 16:14:11 +10:00
Peter Hutterer f3a39ee57c ble: remove leftover wacom-specific code 2018-01-15 16:14:11 +10:00
Peter Hutterer 4ec3069f78 ble: add two FIXMEs, we need to handle ServicesResolved
Connected can be True when ServicesResolved is False but without the latter we
can't do anything.
2018-01-15 11:59:57 +10:00
Peter Hutterer e29c201756 ble: remove obsolete comment
Filtering is done a layer above now
2018-01-15 11:50:52 +10:00
Peter Hutterer c64446b48c ble: drop unused objectpath variable 2018-01-15 11:34:46 +10:00
Benjamin Tissoires 0d88d9d0e7 ble: fix flake8 warnings
./tuhi/ble.py:14:1: F401 'sys' imported but unused
./tuhi/ble.py:15:1: F401 'enum.Enum' imported but unused
./tuhi/ble.py:16:1: F401 'gi.repository.GLib' imported but unused
./tuhi/ble.py:26:1: E302 expected 2 blank lines, found 1
./tuhi/ble.py:81:1: W293 blank line contains whitespace
./tuhi/ble.py:84:13: E126 continuation line over-indented for hanging indent
./tuhi/ble.py:85:17: E131 continuation line unaligned for hanging indent
./tuhi/ble.py:203:39: F821 undefined name 'WACOM_CHRC_LIVE_PEN_DATA_UUID'
./tuhi/ble.py:204:38: E128 continuation line under-indented for visual indent
./tuhi/ble.py:205:39: F821 undefined name 'WACOM_OFFLINE_CHRC_PEN_DATA_UUID'
./tuhi/ble.py:206:38: E128 continuation line under-indented for visual indent
./tuhi/ble.py:207:39: F821 undefined name 'NORDIC_UART_CHRC_RX_UUID'
./tuhi/ble.py:208:38: E128 continuation line under-indented for visual indent
./tuhi/ble.py:232:1: E302 expected 2 blank lines, found 1
./tuhi/ble.py:240:13: E126 continuation line over-indented for hanging indent
./tuhi/ble.py:241:17: E131 continuation line unaligned for hanging indent
./tuhi/ble.py:250:21: E126 continuation line over-indented for hanging indent
./tuhi/ble.py:263:43: W291 trailing whitespace
./tuhi/ble.py:272:72: W291 trailing whitespace
./tuhi/ble.py:310:1: W391 blank line at end of file

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-01-12 20:23:47 +01:00
Peter Hutterer bf2c000b57 Add a BLE abstraction layer 2018-01-12 16:00:24 +10:00