mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	QML UI: detect BT dive computers
If we find something that looks like a known BT dive computer, set things up so that we can use it later. If multiple dive computers are found, simply use the first. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									5c4f9986fe
								
							
						
					
					
						commit
						18eff8f2b3
					
				
					 2 changed files with 41 additions and 0 deletions
				
			
		| 
						 | 
					@ -207,16 +207,48 @@ void QMLManager::mergeLocalRepo()
 | 
				
			||||||
void QMLManager::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
 | 
					void QMLManager::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString newDevice = device.name();
 | 
						QString newDevice = device.name();
 | 
				
			||||||
 | 
						QList<QBluetoothUuid> serviceUuids = device.serviceUuids();
 | 
				
			||||||
 | 
						foreach (QBluetoothUuid id, serviceUuids) {
 | 
				
			||||||
 | 
							qDebug() << id.toByteArray();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	appendTextToLog("Found new device " + newDevice + " (" + device.address().toString() + ")");
 | 
						appendTextToLog("Found new device " + newDevice + " (" + device.address().toString() + ")");
 | 
				
			||||||
	QString vendor, product;
 | 
						QString vendor, product;
 | 
				
			||||||
	foreach (vendor, productList.keys()) {
 | 
						foreach (vendor, productList.keys()) {
 | 
				
			||||||
		if (productList[vendor].contains(newDevice)) {
 | 
							if (productList[vendor].contains(newDevice)) {
 | 
				
			||||||
			appendTextToLog("this could be a " + vendor + " " + newDevice);
 | 
								appendTextToLog("this could be a " + vendor + " " + newDevice);
 | 
				
			||||||
 | 
								struct btVendorProduct btVP;
 | 
				
			||||||
 | 
								btVP.btdi = device;
 | 
				
			||||||
 | 
								btVP.vendorIdx = vendorList.indexOf(vendor);
 | 
				
			||||||
 | 
								btVP.productIdx = productList[vendor].indexOf(newDevice);
 | 
				
			||||||
 | 
								qDebug() << "adding new btDCs entry" << newDevice << btVP.vendorIdx << btVP.productIdx;
 | 
				
			||||||
 | 
								btDCs << btVP;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int QMLManager::getVendorIndex()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if BT_SUPPORT
 | 
				
			||||||
 | 
						if (!btDCs.isEmpty()) {
 | 
				
			||||||
 | 
							qDebug() << "getVendorIdx" << btDCs.first().vendorIdx;
 | 
				
			||||||
 | 
							return btDCs.first().vendorIdx;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						return -1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int QMLManager::getProductIndex()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if BT_SUPPORT
 | 
				
			||||||
 | 
						if (!btDCs.isEmpty()) {
 | 
				
			||||||
 | 
							qDebug() << "getProductIdx" << btDCs.first().productIdx;
 | 
				
			||||||
 | 
							return btDCs.first().productIdx;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
						return -1;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void QMLManager::finishSetup()
 | 
					void QMLManager::finishSetup()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// Initialize cloud credentials.
 | 
						// Initialize cloud credentials.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@
 | 
				
			||||||
#if BT_SUPPORT
 | 
					#if BT_SUPPORT
 | 
				
			||||||
#include <QBluetoothLocalDevice>
 | 
					#include <QBluetoothLocalDevice>
 | 
				
			||||||
#include <QBluetoothDeviceDiscoveryAgent>
 | 
					#include <QBluetoothDeviceDiscoveryAgent>
 | 
				
			||||||
 | 
					#include <QBluetoothUuid>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "core/gpslocation.h"
 | 
					#include "core/gpslocation.h"
 | 
				
			||||||
| 
						 | 
					@ -118,6 +119,8 @@ public:
 | 
				
			||||||
	bool showPin() const;
 | 
						bool showPin() const;
 | 
				
			||||||
	void setShowPin(bool enable);
 | 
						void setShowPin(bool enable);
 | 
				
			||||||
	Q_INVOKABLE QStringList getDCListFromVendor(const QString& vendor);
 | 
						Q_INVOKABLE QStringList getDCListFromVendor(const QString& vendor);
 | 
				
			||||||
 | 
						Q_INVOKABLE int getVendorIndex();
 | 
				
			||||||
 | 
						Q_INVOKABLE int getProductIndex();
 | 
				
			||||||
#if BT_SUPPORT
 | 
					#if BT_SUPPORT
 | 
				
			||||||
	void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
 | 
						void btDeviceDiscovered(const QBluetoothDeviceInfo &device);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -206,6 +209,12 @@ private:
 | 
				
			||||||
#if BT_SUPPORT
 | 
					#if BT_SUPPORT
 | 
				
			||||||
	QBluetoothLocalDevice localBtDevice;
 | 
						QBluetoothLocalDevice localBtDevice;
 | 
				
			||||||
	QBluetoothDeviceDiscoveryAgent *discoveryAgent;
 | 
						QBluetoothDeviceDiscoveryAgent *discoveryAgent;
 | 
				
			||||||
 | 
						struct btVendorProduct {
 | 
				
			||||||
 | 
							QBluetoothDeviceInfo btdi;
 | 
				
			||||||
 | 
							int vendorIdx;
 | 
				
			||||||
 | 
							int productIdx;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						QList<struct btVendorProduct> btDCs;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
signals:
 | 
					signals:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue