mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: start BT discovery
So far all this does is list all the BT devices that it finds (and I worry if this will have negative battery implications on a mobile device), but this should allow us to connect to a standard BT dive computer (but that will of course require more code to pick the right device). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9bea9fcdb7
commit
1ab6b50a34
2 changed files with 31 additions and 0 deletions
|
@ -89,6 +89,18 @@ QMLManager::QMLManager() : m_locationServiceEnabled(false),
|
|||
m_credentialStatus(UNKNOWN),
|
||||
alreadySaving(false)
|
||||
{
|
||||
#if BT_SUPPORT
|
||||
if (localBtDevice.isValid()) {
|
||||
localBtDevice.powerOn();
|
||||
QString localDeviceName = "localDevice " + localBtDevice.name() + " is valid, starting discovery";
|
||||
appendTextToLog(localDeviceName.toUtf8().data());
|
||||
discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
|
||||
connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, this, &QMLManager::btDeviceDiscovered);
|
||||
discoveryAgent->start();
|
||||
} else {
|
||||
appendTextToLog("localBtDevice isn't valid");
|
||||
}
|
||||
#endif
|
||||
m_instance = this;
|
||||
m_lastDevicePixelRatio = qApp->devicePixelRatio();
|
||||
connect(qobject_cast<QApplication *>(QApplication::instance()), &QApplication::applicationStateChanged, this, &QMLManager::applicationStateChanged);
|
||||
|
@ -191,6 +203,14 @@ void QMLManager::mergeLocalRepo()
|
|||
process_dives(true, false);
|
||||
}
|
||||
|
||||
#if BT_SUPPORT
|
||||
void QMLManager::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
|
||||
{
|
||||
QString newDevice = "Found new device " + device.name() + " (" + device.address().toString() + ")";
|
||||
appendTextToLog(newDevice);
|
||||
}
|
||||
#endif
|
||||
|
||||
void QMLManager::finishSetup()
|
||||
{
|
||||
// Initialize cloud credentials.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue