Commit Graph

225 Commits

Author SHA1 Message Date
Benjamin Tissoires 8e1bba496f kete: use logger instead of plain prints for device notifications 2018-01-29 09:08:22 +10:00
Benjamin Tissoires 5a5a2bc2b8 kete: validate the device address before processing it 2018-01-29 09:08:22 +10:00
Peter Hutterer ef8747f032 README: rename 'index' to 'timestamp' in GetJSONData 2018-01-29 08:23:25 +10:00
Peter Hutterer 4efc415aa1 kete: disconnect from the device/manager signals on exit
Otherwise we resubscribe if we repeatedly call listen in interactive mode
2018-01-25 16:02:34 +10:00
Peter Hutterer 6ad127da3a kete: handle Listening property changes correctly
Previously the assumption was that any change in that property is only from
True to False
2018-01-25 16:02:34 +10:00
Peter Hutterer ab385bd981 dbus: update the listening property, not the internal variable
Otherwise the PropertiesChanged never gets sent
2018-01-25 16:02:34 +10:00
Benjamin Tissoires d4c5f2c081 kete: remove unused local variables 2018-01-25 14:58:28 +10:00
Peter Hutterer a9b6ea68e5 kete: on fetch, write the file as svg into $PWD
Again, very rudimentary but we're planning on making kete a bit better anyway.

Also note that this doesn't make use of the tuhi.drawing module on purpose,
parsing the format twice avoids some bugs and also keeps tuhi-kete separate
from the tuhi daemon.

Part of #7
2018-01-25 14:56:11 +10:00
Peter Hutterer 3bc88bbbb6 config: store/load device drawing in the device's directory 2018-01-25 14:55:10 +10:00
Peter Hutterer 7a31a994fb dbus: return the drawings as array of timestamps
As we're planning to cache the data locally, the timestamps are a
unique-enough way that makes it possible to access a specific drawing.
And this way we can also delete some drawings without all other indices
shifting around.

Fixes #16
2018-01-25 14:55:10 +10:00
Peter Hutterer 80d214c78f Split the Drawing class out into a separate module
No point having multiple implementations of what a drawing is. Let's have it
in one module.
2018-01-25 14:55:10 +10:00
Peter Hutterer 3d516530c6 wacom: throw the exception (if any) to the "done" handler
Attach an errno to all exceptions, so we can bubble that up to the client
and display a message.

Fixes #24
2018-01-25 14:55:10 +10:00
Peter Hutterer bf3842c150 wacom: use a different logger for the firmware communication
This makes it easier to grep for the raw communication with the device.

Fixes #28
2018-01-25 13:42:01 +10:00
Peter Hutterer a8ea4eb01b kete: improve an error message
This is a debugging tool, but still...
2018-01-25 09:18:59 +10:00
Peter Hutterer b3fad1be1b kete: ignore errors during StopListening
If the daemon goes away while we're listening, this is not a real problem.
2018-01-25 09:18:59 +10:00
Peter Hutterer 2fd781974f dbus: pass the bus name lost signal up to tuhi
If we're losing the bus name (i.e. we can't get it on startup) there really
isn't much we can do other than fail miserably. But in passing signals around
we can't do exceptions, so we have to move the mainloop to Tuhi so we can
quit() it on error.

Fixes #25
2018-01-25 09:18:59 +10:00
Peter Hutterer cae296e030 dbus: don't unset the searching client until we received the signal from tuhi
The API requires us to send the signal after stop
2018-01-25 09:18:59 +10:00
Peter Hutterer 1e31e6cba7 dbus: add a helper for sending signals 2018-01-25 09:18:59 +10:00
Peter Hutterer ba7c62fc0c dbus: add helper for properties changed signal 2018-01-25 09:18:47 +10:00
Peter Hutterer 584925a0d9 dbus: add a DBus base object
Currently just handling some properties that are common, but will do other
things soon.
2018-01-24 21:40:42 +10:00
Peter Hutterer 1a6071b93d dbus: use self.objpath instead of the hardcoded BASE_PATH in the manager 2018-01-24 21:39:56 +10:00
Peter Hutterer fc8f0f6716 __init__: remove empty line that snuck in during rebasing 2018-01-24 21:39:56 +10:00
Peter Hutterer 2ee934a81d kete: don't let a second client start searching 2018-01-24 19:25:00 +10:00
Peter Hutterer 8bb971cdcd tuhi: don't use a timeout for searching
We track the searching client now, so the timeout is no longer required
2018-01-24 19:25:00 +10:00
Peter Hutterer cfa4aca2df dbus: limit StartSearch to one client only
Basically copied from the device's Listening approach.

While it's possible to have multiple clients searching at the same time it's a
niche case and the effort at fixing the race conditions that come from that is
likely not worth the effort.

Let's add multiple simultaneous clients when we have a real need for it.
2018-01-24 19:23:20 +10:00
Peter Hutterer cce63d267b dbus: stop discovery when the searching client disappears
This is the single-client version only, we can deal with multiple clients
later.

Fixes #21
2018-01-24 19:23:20 +10:00
Peter Hutterer 71dd70cc95 README: fix the API documentation, Pairing* is now Search* 2018-01-24 19:23:20 +10:00
Peter Hutterer daf2693927 Add setup.py
Fixes #17
2018-01-24 19:09:35 +10:00
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
Benjamin Tissoires 6fa14b65f2 kete: Move the file in a tools folder
This is an unbelievable commit. This just moves one file in a new dir,
and this fixes bug #19.
2018-01-23 19:42:23 +10:00
Peter Hutterer 5e32dc4872 dbus: don't update self.paired unless it changes
TuhDevice.paired is set on every device update (RSSI changes!) and that sends
a GObject.notify() for the property. Filter those, otherwise
we're just spamming dbus with PropertiesChanged notify events even
though nothing has actually changed.
2018-01-23 14:57:00 +10:00
Peter Hutterer 7aa4314c3d wacom: use .format instead of hex to generate the timestring
hex() skips leading zeroes, so 180123 turns into 18, 12, 3
2018-01-23 14:44:01 +10:00
Peter Hutterer 790f2337dc kete: allow pairing on existing devices 2018-01-23 14:22:33 +10:00
Peter Hutterer d9459ef3f9 kete: quit after a successful pairing 2018-01-23 14:22:33 +10:00
Peter Hutterer 08ab047d0a tuhi: set pairing to False on known devices too 2018-01-23 14:22:33 +10:00
Peter Hutterer fc23247ffa kete: handle the 'searching' property correctly in the manager 2018-01-23 14:22:33 +10:00
Peter Hutterer efbae8c50c kete: add a basic comment to fetch drawings
All it does is print information about the drawings, but it has the data, so
converting to svgs in $PWD is doable now.
2018-01-23 14:22:33 +10:00
Peter Hutterer 415ecd39a5 kete: move the MainLoop into the manager so we can watch the bus name
And the basic mainloop code is the same everywhere anyway
2018-01-23 14:22:33 +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
Peter Hutterer 63ba0462ea dbus: send out PropertiesChanged when we update the drawings 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
Peter Hutterer 45196fbdca kete: print when drawings are available 2018-01-23 14:22:33 +10:00
Peter Hutterer 59ab21a5e8 kete: add the 'listen' command
Doesn't do anything but start/stop listening but hey, that's what it says on
the box
2018-01-23 14:22:33 +10:00
Benjamin Tissoires a51663342f dbus: keep track of the senders of the StartListening() method
If the sender disappear, we should stop listening for incoming events.

We match the Start/StopListening() that way, but if a client forgets
to call StopListening() before leaving and some data are being retrieved,
it's not our problem.
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
Benjamin Tissoires 0e6d82dd14 README: document the new listening process
We need to be able to selectively enable/disable listening mode per
device, and the Listening property needs to be updated.

The current approach uses a Listening property as a public state, and the
StartListening()/StopListening() calls to start/stop. The ListeningStopped
signal is just there to carry error codes.

The current design only allows for a single client to trigger listening,
anyone else will see -EAGAIN and has to wait for the property to update.
2018-01-23 14:22:33 +10:00
Peter Hutterer 010c651d6f dbus: add a __repr__ for the TuhiDBusDevice
And remove a now obsolete debugging statement, this was just put there to
debug the PropertyChanged code
2018-01-23 14:22:33 +10:00
Peter Hutterer e5d3da5590 kete: default to 'list' if we don't have a subcommand 2018-01-23 09:05:17 +10:00