-
-
Notifications
You must be signed in to change notification settings - Fork 208
/
bluetoothreceiver.h
69 lines (56 loc) · 2.58 KB
/
bluetoothreceiver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/***************************************************************************
bluetoothreceiver.h - BluetoothReceiver
---------------------
begin : 18.11.2020
copyright : (C) 2020 by David Signer
email : david (at) opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef BLUETOOTHRECEIVER_H
#define BLUETOOTHRECEIVER_H
#include "nmeagnssreceiver.h"
#include <QObject>
#include <QtBluetooth/QBluetoothLocalDevice>
#include <QtBluetooth/QBluetoothSocket>
/**
* The bluetoothreceiver connects to a device and feeds the QgsNmeaConnection over QBluetoothSocket.
* It receives QgsGpsInformation and converts it to GnssPositionInformation
*/
class BluetoothReceiver : public NmeaGnssReceiver
{
Q_OBJECT
public:
explicit BluetoothReceiver( const QString &address = QString(), QObject *parent = nullptr );
~BluetoothReceiver() override;
private slots:
/**
* these functions used for repairing are only needed in the linux (not android) environment
* since there are troubles by connect to a paired device. Maybe it can be resolved in future
* but meanwhile we keep them as the developer setup.
*/
void pairingFinished( const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing status );
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
void confirmPairing( const QBluetoothAddress &address, QString pin );
#endif
void setSocketState( const QBluetoothSocket::SocketState socketState );
private:
void handleConnectDevice() override;
void handleDisconnectDevice() override;
void handleError( QBluetoothSocket::SocketError error );
void repairDevice( const QBluetoothAddress &address );
//! Used to wait for previous connection to finish disconnecting
void doConnectDevice();
QString mAddress;
std::unique_ptr<QBluetoothLocalDevice> mLocalDevice;
QBluetoothSocket *mSocket = nullptr;
bool mPoweringOn = false;
bool mDisconnecting = false;
bool mConnectOnDisconnect = false;
};
#endif // BLUETOOTHRECEIVER_H