aboutsummaryrefslogtreecommitdiffstats
path: root/core/btdiscovery.cpp
AgeCommit message (Collapse)Author
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>
2018-09-30Bluetooth: use standard Qt code on WindowsGravatar Dirk Hohndel
We shouldn't need our hand crafted code anymore. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-29Bluetooth: turn on logging earlierGravatar Dirk Hohndel
This way we should get logging output for the discovery phase as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-12BLE: add Teric to list of auto-detected Shearwater computersGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-02Correctly recognize more OSTC variants as BLEGravatar Dirk Hohndel
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-05-21core: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-11BLE: add EON Core and Mares Bluelink to detectionGravatar Dirk Hohndel
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-04-27Android: correctly detect the different BT device typesGravatar Dirk Hohndel
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-24Convert our custom IO model to new libdivecomputer IO modelGravatar Linus Torvalds
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-02-26Cleanup: Use QString as parameter for [get|save]BtDeviceInfo()Gravatar Berthold Stoeger
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-17Coding-style: remove superfluous parenthesesGravatar Berthold Stoeger
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>
2017-12-27Cleanup: avoid potentially uninitialized membersGravatar Dirk Hohndel
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-07Show BT device names firstGravatar Robert C. Helling
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-02iOS: save BT DeviceInfo on discoveryGravatar Murillo Bernardes
On iOS save all discovered devices. Later qt_ble_open queries this list in order to actually connect to the remove device. The Desktop code stores this data with the list items and only saves when the "Save" button is clicked. This is not supported with the current ConnectionListModel implementation. Signed-off-by: Murillo Bernardes <mfbernardes@gmail.com>
2017-11-16Introduce mode field in Bluetooth device selection dialogGravatar Berthold Stoeger
Some BT devices support both, classical and LE, modes. Users could choose either by prepending or removing "LE:" in the device address field. After commit d23bd46a1be2dfb25293639abcf06b5b4d4b94df, the device field is always disabled in Bluetooth mode. Therefore, add a mode combo box to the Bluetooth device selection dialog. In the default mode (auto), the old code path (based on the Qt device flags) is used. The two other modes (force LE, force classical) allow the user to force the preferred behavior. This feature is meant as a stop-gap measure until a more refined transport choice is implemented. Therefore, the value of the new combo box is not saved in the settings, to avoid cluttering of the preferences with soon to be obsolete entries. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-06Add "Aladin" to the list of recognized BT names.Gravatar Berthold Stoeger
Recognize Aladin as the Bluetooth name of the Scubapro Aladin Sport Matrix. Note that the Scubapro Aladin H Matrix most likely also identifies itself using this BT name. But it probably uses the same BT protocol (i.e. the G2 protocol) and therefore this should not pose a problem. Ultimately a common name should be found. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-04Replace QMap::operator[] with QMap::value()Gravatar Berthold Stoeger
QMap::operator[] creates a new default constructed entry in the map if no entry with the given key exists. While not problematic (since typically nullptrs are inserted) this is usually not what you want for read access. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-10-14BLE: try to enable on iOSGravatar Dirk Hohndel
We can't use the localBtDevice on iOS, so hack around that and go straight to discovery. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-12mobile: enable switching BT on/off during session.Gravatar Jan Mulder
This commit implements possible switching BT on and off during a session, so not needing a restart of the app when the user forgot to switch it on when starting the app. For this, the following needed to be done: 1) create a handler that reacts on local BT device status changes. 2) repopulate the connection list in the download screen when a BT status change is detected. Notice the subtile change of the Q_INVOKABLE btEnabled() function to a Q_PROPERTY. This gives a nice dynamic behaviour when switching BT on/off with the app open. Fixes: #556 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-07Move ConnectionListModel into its own source fileGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-09-17BLE: helper function to get QBtDeviceInfo from UUIDGravatar Dirk Hohndel
Right now this will only work if you scan for your BLE dive computer every time. Ideally we should simply initiate a scan and look for that address if it's not found in the hash. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>