aboutsummaryrefslogtreecommitdiffstats
path: root/core/btdiscovery.cpp
AgeCommit message (Collapse)Author
2021-07-20core/ble: add auto detection for Aladin A2Gravatar Dirk Hohndel
This way it will be recognized as a dive computer when it is scanned via BLE. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-28core/BT: fix duplicate entries in BT detectionGravatar Dirk Hohndel
Somehow three identical lines snuck into commit 0a4e37ee8b ("core/BT: simplify detection of bluetooth names"). Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23core/BT: simplify detection of bluetooth namesGravatar Dirk Hohndel
Instead of that super long if-else if chain, have something more structured using a table for the common case of prefix based names. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-23core/BT: improve BT name detection for Pelagic dive computersGravatar Dirk Hohndel
It would be so much nicer if we could just let libdivecomputer do this, but the filter function there doesn't quite do things the way we need them to be. Which is why we have our own function here. This is a small attempt to rationalize the code that we have to make it easier to maintain. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-13core/bluetooth: make device discovery less noisyGravatar Dirk Hohndel
This mainly combines reasonably redundant text to make the output easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-01-10btdiscovery - Add second matcher for Ratio iX3MGravatar Damian Zaremba
New (late 2020) iX3M hardware (refered to as 'iX3m with Sequared Buttons' in the Ratio support section) appears to identify as iX5M, both in the Bluetooth name and reported revision e.g. $ ./ratio-toolbox-x86_64.AppImage info | head -n2 Model: Ratio® iX5M GPS TECH+ Firmware version: 4.1.26/016 (English) Add a second Bluetooth name matcher for this variation, returning the same (generic) model as is currently used. Signed-off-by: Damian Zaremba <damian@damianzaremba.co.uk>
2020-09-30Android BLE discovery: use discovery agentGravatar Dirk Hohndel
Android can't scan for classic BT devices, so when BT support was first added, we simply didn't use the discovery agent at all and relied on the list of paired BT devices provided by Android. This still worked fine for a lot of BLE devices that allowed 'bonding' with the Android device - similar to pairing. But some BLE devices (like the Shearwater Peregrine) don't support bonding and so our Android code didn't see them at all. With this commit we start a BLE only scan on Android to add to the list of already paired devices. Fixes: #2974 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-30bluetooth discovery: report more information about progressGravatar Dirk Hohndel
We certainly should log errors and the complete list of discovered devices. Also, it's good practice to set a specific search time (I picked three minutes). This way we won't constantly scan and drain resources. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-30bluetooth discovery: differentiate discovered and paired devicesGravatar Dirk Hohndel
We call the same helper from two spots. Once when we report the already paired BT devices on Android, and once from the deviceDescovered signal for the discovery agent. Let's make sure we can tell where the info came from. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22core/bluetooth: stop discovery once the dive computer has been foundGravatar Dirk Hohndel
There is no need to continue to look, and at least with the Shearwater Peregrine having the scan run while we are trying to discover characteristics appeared to cause issues. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22macOS/bluetooth: remove the forced rescanGravatar Dirk Hohndel
I can no longer reproduce the case where this rescan was necessary. So let's remove it as it causes additional wait time for BT/BLE users on macOS. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-22core/BLE: detect Sherwater PeregrineGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-08-18core/bt-discovery: recognize BT names of four more dive computersGravatar Dirk Hohndel
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-07-27core: detect McLean Extreme dive computer as BLE deviceGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-07-14core/BLE: add detection of Scubapro Aladin A1Gravatar Dirk Hohndel
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-06-25Add support for the Oceans S1 and McLean ExtremeGravatar Linus Torvalds
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-05-15core/bt: always add bt name for devicesGravatar Dirk Hohndel
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-15core/bt: match DC descriptor in lower caseGravatar Dirk Hohndel
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-04-10code cleanup: once we find a match, stop checkingGravatar Dirk Hohndel
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-10BLE dive computer detectionGravatar Dirk Hohndel
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-02-16Add Cressi BLE name filtering for bluetooth discoveryGravatar Linus Torvalds
.. and update the libdivecomputer submodule to have them marked as BLE capable. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-11-22Core: don't prevent some OSTC models from being recognizedGravatar Dirk Hohndel
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-10-26Mares: improve BT discovery logicGravatar Dirk Hohndel
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-25Mares: add BT discovery logicGravatar Linus Torvalds
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-09-27Revert the singleton PRGravatar Dirk Hohndel
It turns out that this isn't working the way it was intended to. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-09-25Cleanup: unify idiosyncratic singletonsGravatar Berthold Stoeger
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-08-24Update libdivecomputer to support the Aqualung i200cGravatar Linus Torvalds
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-18Add BLE name recognition for the Deepblu Cosmiq+Gravatar Linus Torvalds
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-07-19Bluetooth: autodetect Shearwater NERD modelsGravatar Dirk Hohndel
This should allow it to work with Subsurface-mobile as well. Fixes #2187 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-07-15Bluetooth: recognize Ratio iX3m GPS dive computersGravatar Dirk Hohndel
We cannot tell them apart by Bluetooth name, so pick one of the names. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-06-01Add BLE detection for the new Oceanic Geo 4.0Gravatar Linus Torvalds
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-05-17Add support for the new Suunto D5Gravatar Linus Torvalds
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-04-28Support for Scubapro G2 HUD discovery via bluetoothGravatar William Perry
Signed-off-by: William M Perry <wmperry@gmail.com>
2019-04-12get rid of some foreach and Q_FOREACH constructsGravatar Rolf Eike Beer
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-03-17Bluetooth: don't free a resource created by newGravatar Dirk Hohndel
Found via LGTM.com Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-02-14Mobile: only show dive computers in the Bluetooth connection listGravatar Dirk Hohndel
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-14Desktop: only show dive computers in the Bluetooth device listGravatar Dirk Hohndel
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-01-23Bluetooth: don't crash if BT is turned offGravatar Dirk Hohndel
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>
2018-12-23Bluetooth: all states other than HostPoweredOff qualify as validGravatar Jan Mulder
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-21core: recognize Oceanic Pro Plus X over BLEGravatar Dirk Hohndel
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-10-12core: recognize Aqualung i770R over BLEGravatar Dirk Hohndel
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-12Bluetooth: add helper to separate BT name and addressGravatar Dirk Hohndel
And restructure the existing "isBtAddress()" function in the process. Also add more tests. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12Bluetooth: restart scan for different device on macOSGravatar Dirk Hohndel
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-12Bluetooth: wait until we actually have device infoGravatar Dirk Hohndel
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-12Bluetooth: start discovery if address isn't already knownGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12Bluetooth: move declaration and make variable file scopedGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-12Bluetooth: remember all data during a scan on macOSGravatar Dirk Hohndel
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-12Bluetooth: discovery should always scan on macOS as wellGravatar Dirk Hohndel
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-12core: helper function to recognize BT/BLE addressesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-10-09BT OSTC 3 should be reported as OSTC PlusGravatar Jocke
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>