Commit graph

84 commits

Author SHA1 Message Date
Dirk Hohndel
cc5ae1911b core/bt-discovery: recognize BT names of four more dive computers
This adds the Oceanic Veo 4.0 & Pro Plus 4, the Sherwood Wisdom 4 and the
Tecdiving DiveComputer.eu to our list of known names.

The Oceanic Pro Plus X detection is simply moved to have the other names
in a more logical order.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-18 12:56:04 -07:00
Dirk Hohndel
01d4e59710 core: detect McLean Extreme dive computer as BLE device
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-27 07:50:54 -07:00
Dirk Hohndel
a4295a3e9f core/BLE: add detection of Scubapro Aladin A1
This was supported in libdivecomputer, but not recognized as dive computer by
our core BLE code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-14 09:12:31 -07:00
Linus Torvalds
ac533a6433 Add support for the Oceans S1 and McLean Extreme
This updates libdivecomputer to support the Oceans S1 and McLean Extreme
divecomputers.

It also adds the Oceans S1 to the list of dive computers we reconize by
bluetooth name.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-25 12:56:12 -07:00
Dirk Hohndel
a1a51e5d89 core/bt: always add bt name for devices
If the user asks to have all BT/BLE devices shown, we should behave
consistently to the case of a recognized dive computer and always show the
device name. In almost all cases the BT/BLE address (and even worse on
iOS/macOS the weird uuids) are completely meaningless.

If there isn't a name, don't add a leading space in order to make it easy to
detect if we have an address without a name (which almost certainly isn't a
dive computer, so it should be towards the end of the list of addresses - which
will be handled in a later commit).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-15 04:05:06 +03:00
Dirk Hohndel
658089d763 core/bt: match DC descriptor in lower case
This fixes a rather subtle bug.

In btdiscovery.cpp we are detecting dive computers based on their BT name and
are setting up product+vendor as the key for that lookup. QMap always uses case
sensitive comparisons and a tiny inconsistency snuck into our code.
libdivecomputer names for the Aqualung dive computers i200C / i300C / i550C end
in an upper case C (as matches the official branding), but in btdiscovery.cpp
we have those names with lower case c. And therefore didn't recognize these
dive computers.

Obviously this is easy to fix by fixing those three strings, but I decided that
it was silly to set ourselves up for similar oversights in the future. So
instead I switched the matching of the descriptor to simply be allways all
lower case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-05-15 02:49:46 +03:00
Dirk Hohndel
fe6ecb4cd8 code cleanup: once we find a match, stop checking
This isn't really a useful performance improvement, but it's still better,
IMHO, because we don't have a less specific match later on potentially change
an already executed match.

Because of our coding style the comment covering multiple cases of Pelagic dive
computers now is associated just with the first of those entries. I don't see a
way to do this differently without being in violation of our coding style, so
I'll just keep it like this.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Dirk Hohndel
55bbdc2728 BLE dive computer detection
Both Shearwater Petrel and Petrel 2 identify as 'Petrel' as their BT and BLE
names. But only the Petrel 2 supports BLE, thus only the Petrel 2 shows up in
the list of known dive computers on iOS (which supports only BLE but not
BT-only). By switching this around to always pick Petrel 2 we now correctly
detect such a dive computer on iOS.

Fixes #2739

Reported-by: Rick Holcombe <wrh@nc.rr.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-04-10 17:18:17 -07:00
Linus Torvalds
6df46a25a3 Add Cressi BLE name filtering for bluetooth discovery
.. and update the libdivecomputer submodule to have them marked as BLE
capable.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-16 12:52:56 -08:00
Dirk Hohndel
c36513a9f3 Core: don't prevent some OSTC models from being recognized
The code seemed to do something really reasonable by picking one of the
supported OSTC versions - except that the one it picked didn't support
BT/BLE and therefore our logic of recognizing dive computers on iOS
failed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-11-22 16:53:29 -08:00
Dirk Hohndel
394948e2cf Mares: improve BT discovery logic
At least in one of the logs we saw there seemed to be trailing spaces.
It should be enough for the BT name to start with "Mares Genius" in
order to be recognized.

Suggested-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-10-26 04:39:32 -07:00
Linus Torvalds
7273161acf Mares: add BT discovery logic
We don't have the "show all dive computers" logic on mobile, so we need
something like this.

Possibly we should use the libdivecomputer matching code if it exists,
but that's a much bigger change, let's do this incremental one for now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-10-25 04:34:51 -07:00
Dirk Hohndel
9ae7040a91 Revert the singleton PR
It turns out that this isn't working the way it was intended to.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-27 16:26:58 -07:00
Berthold Stoeger
05200f9266 Cleanup: unify idiosyncratic singletons
The way we handle singletons in QML, QML insists on allocating the
objects. This leads to a very idiosyncratic way of handling
singletons: The global instance pointer is set in the constructor.

Unify all these by implementing a "SillySingleton" template. All
of the weird singleton-classes can derive from this template and
don't have to bother with reimplementing the instance() function
with all the safety-checks, etc.

This serves firstly as documentation but also improves debugging
as we will now see wanted and unwanted creation and destruction
of these weird singletons.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-09-25 13:35:30 -07:00
Linus Torvalds
d570cb789f Update libdivecomputer to support the Aqualung i200c
I got confirmation from Tiago Thedim Dias that my libdivecomputer patch
makes BLE downloading work from the i200c, and already pushed out the
libdivecomputer changes earlier.  This updates the subproject in
subsurface to have those changes.

This also adds the bluetooth name patterns for the i300c and a few other
Aqualung dive computers we hadn't added yet.  That should make them show
up in the bleutooth device list even without having to check the "Show
all bluetooth devices" check-box.

Tiago claims he didn't need that, and I wonder if we have some overly
permissive match somewhere, but it's the right thing to do regardless.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-24 15:02:50 -07:00
Linus Torvalds
25db28b905 Add BLE name recognition for the Deepblu Cosmiq+
It needs a newer version of libdivecomputer to actually download, but
early very experimental code exists in the Subsurface-NG branch.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-18 23:28:48 +03:00
Dirk Hohndel
52cb38e540 Bluetooth: autodetect Shearwater NERD models
This should allow it to work with Subsurface-mobile as well.

Fixes #2187

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-19 21:50:36 -07:00
Dirk Hohndel
3e5d60d95a Bluetooth: recognize Ratio iX3m GPS dive computers
We cannot tell them apart by Bluetooth name, so pick one of the names.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-15 11:18:32 -07:00
Linus Torvalds
ba31c56c78 Add BLE detection for the new Oceanic Geo 4.0
Note that we don't really have libdivecomputer support for it yet, only
newly added model numbers etc.  But the name detection should make it
easier for people to at least download a memory dump.

In addition to the libdivecomputer model number updates, this also has a
merge of Jef's upstram libdivecomputer changes.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-06-01 05:25:23 +03:00
Linus Torvalds
9590709e8c Add support for the new Suunto D5
This is just a trivial update to recognize the BT name, and a
libdivecomputer submodule update to get the updates to libdivecomputer
to recognize the new USB IDs etc.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-17 09:42:05 +02:00
William Perry
9bb7bbef84 Support for Scubapro G2 HUD discovery via bluetooth
Signed-off-by: William M Perry <wmperry@gmail.com>
2019-04-28 09:39:50 +02:00
Rolf Eike Beer
c4c8094e32 get rid of some foreach and Q_FOREACH constructs
See https://www.kdab.com/goodbye-q_foreach/

This is reduced to the places where the container is const or can be made const
without the need to always introduce an extra variable. Sadly qAsConst (Qt 5.7)
and std::as_const (C++17) are not available in all supported setups.

Also do some minor cleanups along the way.

Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Dirk Hohndel
f3d98518d5 Bluetooth: don't free a resource created by new
Found via LGTM.com

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-17 11:23:49 -07:00
Dirk Hohndel
9d582c5512 Mobile: only show dive computers in the Bluetooth connection list
And offer an option to show all devices in the settings. This is intentionally
not stored in the preferences as this should never be needed. We don't support
BT or BLE dive computers that we don't recognize. This is a last resort in case
a new firmware were to change the name or some other weird issue causes us not
to recognize a dive computer - and that should be fixed instead of worked
around.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-14 09:05:58 -08:00
Dirk Hohndel
f35a0f3b09 Desktop: only show dive computers in the Bluetooth device list
By default we'll only show devices that we believe to be dive computers,
but the user can override that with the recently introduced check box.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-14 09:05:58 -08:00
Dirk Hohndel
2f9bf92a17 Bluetooth: don't crash if BT is turned off
At least on a Mac we can get here without a discoveryAgent if BT is off,
so don't derefence the NULL pointer in that case.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-01-23 14:41:17 +13:00
Jan Mulder
ffec5f4991 Bluetooth: all states other than HostPoweredOff qualify as valid
This is an attempt to fix issue #1896. While this seems a Qt issue in
combination with very specific Android devices, this might be a fix. Do
not check for a very specific state of the local BT controller, but just
check if it is powered on.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-12-23 21:43:57 +01:00
Dirk Hohndel
6ba1cf8cf7 core: recognize Oceanic Pro Plus X over BLE
Just like with the Aqualung i770R in 7697003498 this name follows the
pattern of a model number in ASCII encoding, followed by the serial
number of the device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-12-21 12:41:43 -08:00
Dirk Hohndel
7697003498 core: recognize Aqualung i770R over BLE
The name seems crazy until you realize that FQ is 0x4651 which is the model
number of the i770R. And the six digits are the serial number of the device.
Still crazy, but at least now you understand WHY.

Thanks to Jef for decoding that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 10:10:06 -07:00
Dirk Hohndel
c8fec97695 Bluetooth: add helper to separate BT name and address
And restructure the existing "isBtAddress()" function in the process.
Also add more tests.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 08:22:44 -07:00
Dirk Hohndel
7512a6e915 Bluetooth: restart scan for different device on macOS
This makes no sense, but apparently we need to start a fresh scan in order to be able
to talk to a different BLE dive computer on the Mac.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 08:22:44 -07:00
Dirk Hohndel
497c1248d4 Bluetooth: wait until we actually have device info
On macOS, we cannot connect to a BT/BLE device until we have scanned it. Right
now this just sits quietly and waits, which given how long this can take is
rather unsatisfying and might look like Subsurface is hung.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 08:22:44 -07:00
Dirk Hohndel
9491c96103 Bluetooth: start discovery if address isn't already known
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 08:22:44 -07:00
Dirk Hohndel
2954bc5f22 Bluetooth: move declaration and make variable file scoped
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 08:22:44 -07:00
Dirk Hohndel
a5416b9bea Bluetooth: remember all data during a scan on macOS
Since we trigger a scan even without the dialog to pick the right
device, we need to remember all devices that we find.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 08:22:44 -07:00
Dirk Hohndel
2ba3eab319 Bluetooth: discovery should always scan on macOS as well
Instead of only starting the scan when explicitly asked to do so in the BT
dialog, create the discovery agent when the download dialog opens, since on
macOS we cannot connect to a device without having scanned for it first.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 08:22:44 -07:00
Dirk Hohndel
0cfd76740b core: helper function to recognize BT/BLE addresses
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12 08:22:44 -07:00
Jocke
636505f818 BT OSTC 3 should be reported as OSTC Plus
Report BT/BLE capable OSTC 3/3+ as OSTC PLus as it is required to get a 
functional download.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2018-10-09 21:04:23 -07:00
Dirk Hohndel
1f59629a76 Bluetooth: use standard Qt code on Windows
We shouldn't need our hand crafted code anymore.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-30 08:09:37 -07:00
Dirk Hohndel
7c320854b3 Bluetooth: turn on logging earlier
This way we should get logging output for the discovery phase as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-29 14:16:37 -07:00
Dirk Hohndel
428af68e64 BLE: add Teric to list of auto-detected Shearwater computers
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-12 14:00:49 -07:00
Dirk Hohndel
988d6682f2 Correctly recognize more OSTC variants as BLE
Some OSTC 2 and OSTC Plus variants show 'OSTC+ xxxxx' as BLE name and we
recognized this as OSTC 3 (but that one doesn't support BLE). With this
we recognize these models as OSTC 2 (which is identical from a download
perspective to the OSTC Plus) and both of those support BLE.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-02 09:24:30 -07:00
jan Iversen
a312e53f0c core: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
Dirk Hohndel
cef6dff762 BLE: add EON Core and Mares Bluelink to detection
Detection isn't required, but it makes things easier.  For the Mares dive
computers we only see the Bluelink, so we can't tell which dive computer is
connected to it. We guess "Quad", but the user can pick a different one.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-11 22:18:19 -07:00
Dirk Hohndel
e9fd4cb7dc Android: correctly detect the different BT device types
The previous code would not add the non-LE address for dual stack
devices. Unfortunately, even with this fix we still don't get the
correct result for the dual stack Shearwater Petrel 2 that I have
for testing as Android incorrectly reports it as a BLE-only device.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-04-27 16:02:17 -07:00
Linus Torvalds
13f5c75ac4 Convert our custom IO model to new libdivecomputer IO model
This converts our old custom IO model to the new model that
libdivecomputer introduced.  This is partly based on Jef's rough patch
to make things build, with further work by me.

The FTDI code is temporarily disabled here, because it will need to be
integrated with the new way of opening devices.

The ble_serial code goes away entirely, since now libdivecomputer knows
about BLE transport natively, and doesn't need to have any serial
wrapper around it.

Signed-off-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:54:08 -07:00
Berthold Stoeger
7bd860f2b7 Cleanup: Use QString as parameter for [get|save]BtDeviceInfo()
Each callsite of saveBtDeviceInfo() has a QString, which is converted
to a C-string, passed and immediately converted back. Remove these
conversions by taking a reference to QString directly.

getBtDeviceInfo() is not as clear. Here, the callsite has a C-string
handed down from libdivecomputer. Nevertheless, pass a reference of
QString here as well. Firstly, for reasons of symmetry. Secondly,
to avoid multiple conversions in the getBtDeviceInfo() functions.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-26 08:52:34 +01:00
Berthold Stoeger
5c248d91cd Coding-style: remove superfluous parentheses
Mostly replace "return (expression);" by "return expression;" and one
case of "function((parameter))" by "function(parameter)".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17 19:38:52 -08:00
Dirk Hohndel
db434702be Cleanup: avoid potentially uninitialized members
Realistically this is a false positive as we should never use a second
BTDiscovery instance - but there's nothing wrong with being extra certain.

Coverity CID 208319

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-27 17:24:12 -08:00
Robert C. Helling
1c223b09c3 Show BT device names first
Show them left of address (so they are in the user's view) rather
than on the right.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-07 18:15:40 +01:00