Commit Graph

268 Commits

Author SHA1 Message Date
Peter Hutterer 4661cf9ae8 wacom: remove state-based decision of whether to listen or register
Previously, we set self._mode and used that to determine what connection to
attempt. This can sometimes lead to a device attempting to register in
response to a listen() request (and vice versa).

Make this dependent on the caller arguments only. So when listen() is
requested do exactly that and generate the right exception if the device is in
the wrong mode.

Fixes #79 (multiple patches required)
2018-02-13 14:51:40 +01:00
Peter Hutterer 0d825e2e3c wacom: replace the signal forwarders with lambdas
We're doing nothing but forwarding the signal here, so let's just replace them
with lambdas so it's immediately obvious what we do with the signal.
2018-02-13 14:51:32 +01:00
Peter Hutterer 94bc52efb6 kete: if listening/searching is stopped by the daemon, clean up after us 2018-02-13 14:49:39 +01:00
Benjamin Tissoires abfb0db6a8 kete: catch the ServiceUnknown exception in TuhiKeteDevice
This allows to have more symmetrical handling of the Searcher and
the Listener
2018-02-13 14:49:17 +01:00
Peter Hutterer de033c3b6a wacom: 0x05 appears to be the error for 'invalid opcode' 2018-02-12 15:30:16 +10:00
Peter Hutterer c9d48ed4b2 wacom: document the signals we send 2018-02-12 15:30:14 +10:00
Peter Hutterer 7cd9a89f3b wacom: prettify the 'returned time' debug message 2018-02-12 12:49:48 +10:00
Peter Hutterer 3cbbfbf056 base: remove write-only variable registering_mode 2018-02-12 09:41:54 +10:00
Peter Hutterer 60535a6859 wacom: remove unused define 2018-02-12 09:41:54 +10: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 6cff3b8f79 wacom: split the time parsing functions out
Doesn't gain us that much, but we can re-use it when parsing stroke data
lateron.

This also will be useful for the Intuos Pro support
2018-02-09 10:39:18 +01:00
Peter Hutterer b5e6ad6559 wacom: make room for a more diverse register_device
Fold register_connection into register_device and (with comments) handle the
spark and slate here. This makes it easier to handle the Intuos Pro paper
later.
2018-02-09 10:31:37 +01:00
Peter Hutterer b45977c2d2 wacom: fix typo 2018-02-09 10:31:37 +01:00
Peter Hutterer bc95a0b414 wacom: prettify a debug message 2018-02-09 10:31:37 +01:00
Peter Hutterer 654dea6810 wacom: pass the uuid up to the slate's super() constructor 2018-02-09 10:31:37 +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 c2bba6bd43 wacom: move protocol instantiation into a class
During the first attempt to register, we might not know before hand
the protocol of the device. Have a special class for it, and then
instantiate the correct protocol before continuing.

This makes the 'Protocol' entry in the config file mandatory
2018-02-09 13:31:11 +10:00
Benjamin Tissoires 59db1a28ae wacom: make the slate a subclass of the spark
The Slate is more recent than the Spark. We better have the Spark as a
base class that we will never touch again and make the Slate depend on it.

When adding the Intuos Paper, we should make it a subclass of the Slate,
as the 2 protocols are similar.
2018-02-09 13:31:11 +10:00
Benjamin Tissoires f6e7c72d9d wacom: Split out the Nordic communication protocol in its own class
So the low level bits are not in the same class than the protocols
2018-02-09 13:31:11 +10:00
Peter Hutterer 82e7dbf515 wacom: remove the Spark's 0xb3 opcode from register_connection
This is handled in the subclass now
2018-02-09 13:31:11 +10:00
Benjamin Tissoires d62a97a8cd wacom: have subclasses to distinguish between protocols
The Intuos Pro Paper is close enough to the Slate but with some
subtleties. Instead of having a bunch of ifs, let's have nice subclasses
for the differences in the protocol.
2018-02-09 13:31:11 +10:00
Benjamin Tissoires 1f843b1434 wacom: split out the low level protocol from the interface with Tuhi
We are already handling 2 protocols, one for the Spark, and one for
the Slate. That's one too many, and given that there are some subtleties
in the Intuos Pro Paper (see #56), we better start splitting the protocol
from the interface, so we can have different protocols for different
devices instead of having a bunch of 'ifs'
2018-02-09 13:31:11 +10:00
Benjamin Tissoires 4b494917b1 wacom: load the protocol of the device from the config file
We can store this once for all, which will allow to keep the logic
of detecting the protocol while registering only
2018-02-09 13:31:11 +10:00
Benjamin Tissoires ecd99ea9b6 config: store the protocol used by the device in the config file
Instead of having to detect the protocol multiple times, we should just
store it once so we can detect oddities when they arrive.
2018-02-09 13:31:11 +10:00
Peter Hutterer 8f2ad50fa5 base: allow for multiple company IDs
The Intuos Paper uses a different one, because of course it does.
The 'company ID' from the Paper will be added while adding support for it.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-09 13:31:11 +10:00
Peter Hutterer 7f230859fe wacom: don't save the current time
This is a write-only value. And for read_time() if we want to compare
timestamps we can just do so with time.time()
2018-02-09 13:31:11 +10:00
Benjamin Tissoires f684a0efb3 wacom: decipher 0xbb command
It's just the name of the device :)
2018-02-09 13:31:11 +10:00
Peter Hutterer 112b689bf8 wacom: drop Orientation from the Tuhi daemon
This isn't something we need in the daemon, it depends too much on what the
client expects so let the client save this data and handle the rotation
accordingly.

Note that the sensor in Sparks and Slates is in landscape format, i.e. every
picture is 90 deg rotated from what you'd expect.

Fixes #33 (wontfix)
2018-02-09 13:31:11 +10:00
Peter Hutterer ad145cc078 base: require Python 3.6
Instead of failing with a syntax error on format strings, actually bail out
instead. Likewise for setup.py, require 3.6 and add this to the classifiers
too while we're there.

Related to #71
2018-02-07 09:18:11 +01:00
Benjamin Tissoires c86c318d6b kete: rename the history file to be histfile
for googleability, as being said
2018-02-07 09:15:59 +01:00
Benjamin Tissoires e63785b5b2 kete: persistent history
We write the history immediately after receiving a new command,
just in case something bad happens.

Fixes #54
2018-02-07 09:38:31 +10:00
Benjamin Tissoires 00fbff37ab dbus: fix signal name exported in the dbus introspection
We are using ListeningStopped, not ListenComplete
2018-02-06 15:17:27 +01:00
Benjamin Tissoires 9829fa6822 flatpak: ship tuhi-kete in the sandbox
To be able to run tuhi-kete, we need a tuhi server running. Provide a
script that spawns one if none is running.

Running simple 'python3 setup.py --install' started to go havoc by
complaining that /app/lib/python3.6/site-packages/easy-install.pth
was read-only.

The solution mentioned in https://github.com/flatpak/flatpak-builder/issues/5
didn't do the trick.

So using https://stackoverflow.com/questions/6301003/stopping-setup-py-from-installing-as-egg/27175492#27175492
as a trick to install the dependencies without the egg part

To start tuhi-kete:
$> flatpak run --command=tuhi-kete org.freedesktop.tuhi

Note that currently the fetched files are not available outside of the
sandbox

Related to #62
2018-02-06 09:03:47 +01:00
Peter Hutterer 5e82d1b378 Rename "pair" to "register"
"pair" is alrady taken by Bluetooth and since we have a bluetooth device here,
it can cause confusion. Use "register" instead, with an explanation in the
README for the more paranoid of us.

Fixes #67
2018-02-02 09:23:08 +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
Benjamin Tissoires b0284415ac Add a flatpak-builder json
flatpak-builder can produce an app by calling:
$> flatpak-builder --force-clean flatpak-tuhi \
	org.freedesktop.tuhi.json

and it can run it through:
$> flatpak-builder --run flatpak-tuhi org.freedesktop.tuhi.json tuhi

The install with a local repo would be:
$> flatpak-builder --repo=repo --force-clean flatpak-tuhi \
	org.freedesktop.tuhi.json
$> flatpak --user remote-add --no-gpg-verify --if-not-exists \
	tuhi-repo repo
$> flatpak --user install tuhi-repo org.freedesktop.tuhi
$> flatpak org.freedesktop.tuhi

Fixes #31
2018-02-02 10:46:47 +10:00
Peter Hutterer b305d6e287 kete: ignore dbus errors during StopSearch
we may call StopSearch after the daemon vanished and while we're stopping all
the workers. Ignore the ServiceUnknown error here.
2018-02-02 09:56:24 +10:00
Peter Hutterer ddef5ea38a kete: allow 'help' even when not connected 2018-02-02 08:55:48 +10:00
Peter Hutterer 02e8cf53ce kete: while disconnected, print a message to that effect
$> ./tools/tuhi-kete.py
Tuhi shell control
WARNING: Tuhi daemon not running
tuhi> list
Not connected to the Tuhi daemon

Better than just a noop
2018-02-02 08:55:13 +10:00
Peter Hutterer 1f93db6ca0 kete: improve some messaging
In the normal mode (without -v) we'd see the errors, but not the messages when
we reconnect. Elevate the "connected to" message to info so it shows up.

And slight rewording, which may or may not be better.
2018-02-02 08:27:23 +10:00
Benjamin Tissoires 3e444d6a0c kete: make the shell survive the disappearing of the daemon
We need to move the mainloop in the Shell as we need to watch on the
name there.

Fixes #55
2018-02-02 08:13:30 +10:00
Benjamin Tissoires 277523c7d5 kete: stop listening when pairing a device
Or the internal state of kete is that the device is listening while
tuhi says it is not.
2018-02-02 08:13:30 +10:00
Benjamin Tissoires 3f75c927dc tuhi: do not stop discovering if search is on
If a client requested both listen and search, on listen off on the device,
the discovery was stopped too which lead to some unbalanced state in
the client.
2018-02-02 08:13:30 +10:00
Benjamin Tissoires db2f37c561 kete: do_fetch: do not remember the worker
There is no stop() method attached to Fetcher, so we don't really need
to remember we called it once to call a NOOP
2018-02-02 08:13:30 +10:00
Benjamin Tissoires 5368e49f5d kete: rename 'list' command into 'devices'
'list' and 'listen' are just too close to each other, meaning the
completion stops at 'list' while the lazy developer/tester want to
do a 'listen'.

Change the name of the less used command so we have separate spaces
for completion
2018-02-02 08:13:30 +10:00
Benjamin Tissoires 0c829754cd tools: add the parse_log script we used to dump the raw btsnoop logs
Better keep this in a public place where it won't vanish from our disks.
Note that this is a python 2 script (because btsnoop), and it should not
be part of the installation, ever.
2018-02-02 08:00:41 +10:00
Peter Hutterer 31e1f2ad3b Export the Bluez device's object path
Rather than proxying all metadata (name, address, ...) add a reference to the
bluez device instead.

Fixes #60
2018-02-01 10:13:39 +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 501c891a12 kete: bubble up the dbus vanished errors
Not much is done for now, but the shell is notified, which is a big step
2018-01-31 17:03:25 +01:00