Commit Graph

35 Commits (83d669c0595755ed22761e4c1049d7c0f0c42639)

Author SHA1 Message Date
Peter Hutterer eb5efd2e1c tuhi: move everything to base.py
Let tuhi.py just be the script that calls main. This way we're somewhat
setup.py compatible.
2018-01-24 19:08:12 +10:00
Peter Hutterer 08ab047d0a tuhi: set pairing to False on known devices too 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 ea890958d6 Start discovery mode when one device requests it
We need to check when the discovery stops (timeout from StartSearch)
if we should keep the discover one or not.
2018-01-23 14:22:33 +10:00
Benjamin Tissoires e3fff4015a implement a basic Start/StopListening
This implements the ListeningStopped signal (especially the EAGAIN if we're
already listening) but does not yet actually trigger the listening on the
device.

There is still no timeout, and no signal gets emitted.
The current way of testing this is:
- call StartListening() on the DBus device
- start discovery on the adapter by some other mean
- press the button on the device -> the sync will happen
- call StopDiscovery()
- press the button on the device -> the sync will *not* happen
2018-01-23 14:22:33 +10:00
Peter Hutterer d3192dc070 dbus: Send out a PropertyChanged event when a device is paired
Just updating the array isn't enough, we need to bubble up the property
change and then manually send the PropertyChanged event
2018-01-22 17:14:37 +10:00
Peter Hutterer daac6e6d96 dbus: drop the "paired" flag from create_device
We can get this from the device now
2018-01-22 17:14:37 +10:00
Peter Hutterer ec87503209 tuhi: keep a reference to the Tuhi dbus device in the TuhiDevice
Because we need to notify it when we have paired so the daemon can update
2018-01-22 17:14:37 +10:00
Benjamin Tissoires 56dc8741dc defer the creation of the wacom device object
If bluez is restarted, the services are not resolved.
If the data has not been connected, the manufacturerData might be
correctly set, but the services are still not resolved, meaning that
we can not start listening on the various GATT characteristics.

Defer the creation of the wacom device object after connect, when
we are sure the services are resolved.
2018-01-22 15:24:56 +10:00
Benjamin Tissoires f4e35df67d tuhi: merge _on_bluez_device_added with _on_bluez_device_updated
This allows to create the device even if the conditions were not met
while starting up tuhi (if bluez considers the device still in
pairing mode).

This will also allow us to retrieve the button presses from the devices,
as they are triggering a BLE advertisement.
2018-01-22 15:23:05 +10:00
Benjamin Tissoires fda5d7f132 update the paired property on uuid change
When the uuid changes, it means the device just has been paired.
We should therefore update the paired property or a subsequent connect
to retrieve the data will result in an attempt to pair to the device.
2018-01-20 12:37:50 +10:00
Benjamin Tissoires c79ffbd12c do not create more than one DBus object per bluetooth device
When the device is in pairing mode, it will send several properties
updates, and tuhi will attempt to create a second DBus object.

This is not good.
2018-01-20 12:37:50 +10:00
Peter Hutterer 4ee07a18b6 Hook up UUID changes to be written in the config file
Make the uuid property a GObject.Property so we can listen to it. Notify about
the uuid change at the end of the pairing process, then write that value into
the device's config file.
2018-01-19 16:17:44 +10:00
Peter Hutterer 0deb5f8e49 Add an extra log message when it's time to call Pair()
Otherwise it looks like we just sit here and do nothing
2018-01-19 16:17:44 +10:00
Peter Hutterer 76449bf608 config: add a basic storage backend
$XDG_DATA_HOME/tuhi/<mac address>/settings.ini

And that file contains a [Device] section with two entries, address and uuid.
2018-01-19 16:17:44 +10:00
Peter Hutterer d4405cc1ef Hook up a ButtonPressRequired signal
When the nordic communication requires us to notify the user to press the
button, emit a signal and pass that up.
2018-01-19 13:40:26 +10:00
Peter Hutterer aa1a5e6689 Revamp the pairing process and rename to Search
The previous process had a problem: the device object didn't exist until after
pairing was complete. But to pair we need some user interaction (press button
on device) and thus the ability to send notifications from the device to the
dbus client at the right time. This wasn't possible with the previous
approach.

The new approach:
* renames Start/StopPairing to Start/StopSearch to indicate we're just
  searching, not pairing in the manager
* creates a org.freedesktop.tuhi1.Device object when a suitable device is
  found. That object is not in Manager.Devices, it's "hidden" unless you know
  the object path.
* Sends a PairableDevice signal with the new device's object path
* Requires the client to call Pair() on the device
* If the timeout expires without pairing, the device is removed again
2018-01-19 13:40:26 +10:00
Benjamin Tissoires 06e8d69e9d Implement pairing of a new device
This includes the new pairing code for the Spark which is slightly different
to the one from the Slate
2018-01-19 13:40:26 +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
Benjamin Tissoires 0d82afd690 WIP remove automatic connect of the devices
This creates an infinite loop on the Slate, as the device accepts the
following connect right after the disconnect
2018-01-17 15:21:14 +01: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 1841508c33 Pass the timestamps to the json file 2018-01-15 16:15:35 +10:00
Peter Hutterer 3a23610e08 Connect the WacomDevice drawings to the TuhiDrawings
And fixing a few issues with pressure, etc. on the way
2018-01-15 16:15:35 +10:00
Peter Hutterer cf68ebc9ce tuhi: create a TuhiDevice as glue object between front and backends 2018-01-15 16:15:33 +10:00
Peter Hutterer 285c7991bc tuhi: fix reconnection of the WacomDevice
Previously we created a new instance on every connected signal. We should
instead create the device once and then just re-start the sync process when
we get the connected data.
2018-01-15 16:14:11 +10:00
Peter Hutterer c4b0807c3c dbusserver: emit the bus-name-owned when we have the bus
And rename from 'owned' to 'acquired', that's better english
2018-01-15 09:14:29 +10:00
Benjamin Tissoires d20e2b70ad tuhi: fix flake8 warning
./tuhi.py:68:5: F841 local variable 't' is assigned to but never used

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
2018-01-12 20:23:47 +01:00
Peter Hutterer 4aca12b6e7 Add the signals to expose the device over Tuhi's DBus interface
bus_own_name is asynchronous, so we first need to send a signal back and then
we can start connecting to the devices. Otherwise we'll have to implement a
queue which would be a lot harder than just waiting.
2018-01-12 20:32:09 +10:00
Peter Hutterer 8e907ba81a wacom: notify via signal when a drawing is available 2018-01-12 16:18:40 +10:00
Peter Hutterer d214778a1c Add the wacom nordic communication bits
Mostly copy/paste from an earlier project. Needs some more cleanup for
integration with Tuhi
2018-01-12 16:11:00 +10:00
Peter Hutterer bf2c000b57 Add a BLE abstraction layer 2018-01-12 16:00:24 +10:00
Peter Hutterer 89cf8ef67d Add the basic DBus server implementation 2018-01-12 07:46:06 +10:00