iOS

Murillo Bernardes mfbernardes at gmail.com
Fri Dec 1 01:08:46 PST 2017


For now this is just a hack, not final code yet, but *works* fine with my
Perdix AI. I'm able to connect and download dives.

Actually populating BtDeviceInfo with devices discovered, it can be used
successfully later.

I was able to successfully connect, download dives, cancel download,
restart.


​

--
Murillo

On Fri, Dec 1, 2017 at 3:35 PM, Murillo Bernardes <mfbernardes at gmail.com>
wrote:

>
>
> On Fri, Dec 1, 2017 at 2:56 PM, Dirk Hohndel <dirk at hohndel.org> wrote:
>
>>
>> On Nov 30, 2017, at 8:53 PM, Murillo Bernardes <mfbernardes at gmail.com>
>> wrote:
>>
>>> Could this mean that the device cannot be paired with iPhone using the
>>> iOS settings? Of course, I have already paired the DC with my Android
>>> tablet and that might also affect my hardship... How did others pair their
>>> BLE Perdix with iPhone/iPad?
>>>
>>
>> With Perdix AI (BLE) is up to the application to discover and connect to
>> the dive computer. While it is connected it will show under iOS settings,
>> but as soon as the application disconnects or closes it will be gone.
>> Nothing wrong there.
>>
>>
>> I'll have to figure out if I can scan for the device, or if I need to
>> hard code UUIDs or something.
>> Nothing is ever easy :-(
>>
>> Subsurface-mobile on iOS is not working properly with BLE yet, so it
>> doesn't connect.
>>
>>
>> Yup
>>
>> I'll work on it. I'm still hoping that other developers will start
>> participating in the iOS development.
>> Because you all know my time is limited and this is not the most
>> important thing to spend it on in the larger scope of things (by FAR our
>> smallest user group)
>>
>> /D
>>
>>
> I'm taking a look. Got my dev environment setup. Here is somethings I
> found.
>
> I can get my Perdix AI to show in the list, but it fails to connect.
>
> First thing on DownloadFromDiveComputer.qml:161 it contains a regex to
> match an address. On iOS it is actually the uuid, so it passes as a serial.
>
> I changed the regex to:
>
> var btAddr = /(LE:)?\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\}
> .*?/;
>
> then it's set as bluetooth and actually tries to open via qt_ble_open.
>
> On qt-ble.cpp:300 getBtDeviceInfo does not return a populated object. I
> couldn't see btDeviceInfo (btdiscovery.cpp) ever being populated actually,
> so there is nothing to return.
>
> --
> Murillo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20171201/275abaab/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: IMG_3579.PNG
Type: image/png
Size: 329083 bytes
Desc: not available
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20171201/275abaab/attachment-0001.png>
-------------- next part --------------
diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp
index f51a62b23..a61778c6a 100644
--- a/core/btdiscovery.cpp
+++ b/core/btdiscovery.cpp
@@ -162,6 +162,8 @@ void BTDiscovery::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
 		qDebug() << id.toByteArray();
 	}
 
+	saveBtDeviceInfo(btDeviceAddress(&device, false), device);
+
 	btDeviceDiscoveredMain(this_d);
 #endif
 }
@@ -189,7 +191,7 @@ void BTDiscovery::btDeviceDiscoveredMain(const btPairedDevice &device)
 		connectionListModel.addAddress(device.address + " (" + newDevice + ")");
 		return;
 	}
-	connectionListModel.addAddress(device.address);
+	//connectionListModel.addAddress(device.address);
 	qDebug() << "Not recognized as dive computer";
 }
 
@@ -277,12 +279,12 @@ bool BTDiscovery::checkException(const char* method, const QAndroidJniObject *ob
 
 QHash<QString, QBluetoothDeviceInfo> btDeviceInfo;
 
-void saveBtDeviceInfo(const char* devaddr, QBluetoothDeviceInfo deviceInfo)
+void saveBtDeviceInfo(QString devaddr, QBluetoothDeviceInfo deviceInfo)
 {
 	btDeviceInfo[devaddr] = deviceInfo;
 }
 
-QBluetoothDeviceInfo getBtDeviceInfo(const char* devaddr)
+QBluetoothDeviceInfo getBtDeviceInfo(QString devaddr)
 {
 	if (btDeviceInfo.contains(devaddr))
 		return btDeviceInfo[devaddr];
diff --git a/core/btdiscovery.h b/core/btdiscovery.h
index 7a9e9c655..6198f45f1 100644
--- a/core/btdiscovery.h
+++ b/core/btdiscovery.h
@@ -16,8 +16,8 @@
 #include <QAndroidJniEnvironment>
 #endif
 
-void saveBtDeviceInfo(const char* devaddr, QBluetoothDeviceInfo deviceInfo);
-QBluetoothDeviceInfo getBtDeviceInfo(const char* devaddr);
+void saveBtDeviceInfo(QString devaddr, QBluetoothDeviceInfo deviceInfo);
+QBluetoothDeviceInfo getBtDeviceInfo(QString devaddr);
 
 class BTDiscovery : public QObject {
 	Q_OBJECT
diff --git a/mobile-widgets/qml/DownloadFromDiveComputer.qml b/mobile-widgets/qml/DownloadFromDiveComputer.qml
index d1ee08f86..0f26d538a 100644
--- a/mobile-widgets/qml/DownloadFromDiveComputer.qml
+++ b/mobile-widgets/qml/DownloadFromDiveComputer.qml
@@ -158,7 +158,7 @@ Kirigami.Page {
 				}
 				onCurrentTextChanged: {
 					// pattern that matches BT addresses
-					var btAddr = /[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]/ ;
+                    var btAddr = /(LE:)?\{?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\} .*?/;
 					if (btAddr.test(currentText))
 						downloadThread.deviceData.bluetoothMode = true
 					else


More information about the subsurface mailing list