QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
BluetoothWorker Class Referenceabstract

#include <BluetoothWorker.h>

+ Inheritance diagram for BluetoothWorker:
+ Collaboration diagram for BluetoothWorker:

Public Slots

void setupConnection ()
 
void connectLink ()
 
void disconnectLink ()
 
void writeData (const QByteArray &data)
 

Signals

void connected ()
 
void disconnected ()
 
void errorOccurred (const QString &errorString)
 
void dataReceived (const QByteArray &data)
 
void dataSent (const QByteArray &data)
 
void rssiUpdated (qint16 rssi)
 

Public Member Functions

 BluetoothWorker (const BluetoothConfiguration *config, QObject *parent=nullptr)
 
 ~BluetoothWorker () override
 
bool isConnected () const
 

Static Public Member Functions

static BluetoothWorkercreate (const BluetoothConfiguration *config, QObject *parent=nullptr)
 

Protected Slots

void _reconnectTimeout ()
 
void _serviceDiscoveryTimeout ()
 

Protected Member Functions

virtual void onSetupConnection ()=0
 
virtual void onConnectLink ()=0
 
virtual void onDisconnectLink ()=0
 
virtual void onWriteData (const QByteArray &data)=0
 
virtual void onServiceDiscoveryTimeout ()=0
 
virtual void onResetAfterConsecutiveFailures ()=0
 

Protected Attributes

const QBluetoothDeviceInfo _device
 
const QBluetoothUuid _serviceUuid
 
const QBluetoothUuid _readCharacteristicUuid
 
const QBluetoothUuid _writeCharacteristicUuid
 
QPointer< QTimer > _reconnectTimer
 
QPointer< QTimer > _serviceDiscoveryTimer
 
std::atomic< bool > _intentionalDisconnect {false}
 
std::atomic< bool > _connected {false}
 
std::atomic< int > _reconnectAttempts {0}
 
int _consecutiveFailures = 0
 

Static Protected Attributes

static constexpr int MAX_RECONNECT_ATTEMPTS = 10
 
static constexpr int RECONNECT_BASE_INTERVAL_MS = 5000
 
static constexpr int MAX_RECONNECT_INTERVAL_MS = 60000
 
static constexpr int SERVICE_DISCOVERY_TIMEOUT_MS = 30000
 
static constexpr int MAX_CONSECUTIVE_FAILURES = 3
 

Detailed Description

Definition at line 12 of file BluetoothWorker.h.

Constructor & Destructor Documentation

◆ BluetoothWorker()

BluetoothWorker::BluetoothWorker ( const BluetoothConfiguration config,
QObject *  parent = nullptr 
)
explicit

◆ ~BluetoothWorker()

BluetoothWorker::~BluetoothWorker ( )
override

Member Function Documentation

◆ _reconnectTimeout

◆ _serviceDiscoveryTimeout

void BluetoothWorker::_serviceDiscoveryTimeout ( )
protectedslot

◆ connected

void BluetoothWorker::connected ( )
signal

◆ connectLink

void BluetoothWorker::connectLink ( )
slot

Definition at line 62 of file BluetoothWorker.cc.

References _device, _intentionalDisconnect, isConnected(), and onConnectLink().

Referenced by _reconnectTimeout().

◆ create()

BluetoothWorker * BluetoothWorker::create ( const BluetoothConfiguration config,
QObject *  parent = nullptr 
)
static

Definition at line 49 of file BluetoothWorker.cc.

Referenced by BluetoothLink::BluetoothLink().

◆ dataReceived

void BluetoothWorker::dataReceived ( const QByteArray &  data)
signal

◆ dataSent

void BluetoothWorker::dataSent ( const QByteArray &  data)
signal

◆ disconnected

void BluetoothWorker::disconnected ( )
signal

◆ disconnectLink

◆ errorOccurred

void BluetoothWorker::errorOccurred ( const QString &  errorString)
signal

◆ isConnected()

bool BluetoothWorker::isConnected ( ) const

Definition at line 44 of file BluetoothWorker.cc.

References _connected.

Referenced by connectLink(), and writeData().

◆ onConnectLink()

virtual void BluetoothWorker::onConnectLink ( )
protectedpure virtual

Implemented in BluetoothBleWorker, and BluetoothClassicWorker.

Referenced by connectLink().

◆ onDisconnectLink()

virtual void BluetoothWorker::onDisconnectLink ( )
protectedpure virtual

Implemented in BluetoothBleWorker, and BluetoothClassicWorker.

Referenced by disconnectLink().

◆ onResetAfterConsecutiveFailures()

virtual void BluetoothWorker::onResetAfterConsecutiveFailures ( )
protectedpure virtual

Implemented in BluetoothBleWorker, and BluetoothClassicWorker.

Referenced by _reconnectTimeout().

◆ onServiceDiscoveryTimeout()

virtual void BluetoothWorker::onServiceDiscoveryTimeout ( )
protectedpure virtual

◆ onSetupConnection()

virtual void BluetoothWorker::onSetupConnection ( )
protectedpure virtual

Implemented in BluetoothBleWorker, and BluetoothClassicWorker.

Referenced by setupConnection().

◆ onWriteData()

virtual void BluetoothWorker::onWriteData ( const QByteArray &  data)
protectedpure virtual

Implemented in BluetoothBleWorker, and BluetoothClassicWorker.

Referenced by writeData().

◆ rssiUpdated

void BluetoothWorker::rssiUpdated ( qint16  rssi)
signal

◆ setupConnection

void BluetoothWorker::setupConnection ( )
slot

Definition at line 57 of file BluetoothWorker.cc.

References onSetupConnection().

Referenced by BluetoothLink::BluetoothLink().

◆ writeData

void BluetoothWorker::writeData ( const QByteArray &  data)
slot

Definition at line 90 of file BluetoothWorker.cc.

References errorOccurred(), isConnected(), and onWriteData().

Member Data Documentation

◆ _connected

std::atomic<bool> BluetoothWorker::_connected {false}
protected

Definition at line 59 of file BluetoothWorker.h.

Referenced by isConnected().

◆ _consecutiveFailures

int BluetoothWorker::_consecutiveFailures = 0
protected

◆ _device

const QBluetoothDeviceInfo BluetoothWorker::_device
protected

◆ _intentionalDisconnect

std::atomic<bool> BluetoothWorker::_intentionalDisconnect {false}
protected

◆ _readCharacteristicUuid

const QBluetoothUuid BluetoothWorker::_readCharacteristicUuid
protected

Definition at line 52 of file BluetoothWorker.h.

◆ _reconnectAttempts

std::atomic<int> BluetoothWorker::_reconnectAttempts {0}
protected

Definition at line 60 of file BluetoothWorker.h.

Referenced by _reconnectTimeout(), and disconnectLink().

◆ _reconnectTimer

QPointer<QTimer> BluetoothWorker::_reconnectTimer
protected

◆ _serviceDiscoveryTimer

QPointer<QTimer> BluetoothWorker::_serviceDiscoveryTimer
protected

Definition at line 56 of file BluetoothWorker.h.

Referenced by BluetoothWorker(), disconnectLink(), and ~BluetoothWorker().

◆ _serviceUuid

const QBluetoothUuid BluetoothWorker::_serviceUuid
protected

Definition at line 51 of file BluetoothWorker.h.

◆ _writeCharacteristicUuid

const QBluetoothUuid BluetoothWorker::_writeCharacteristicUuid
protected

Definition at line 53 of file BluetoothWorker.h.

◆ MAX_CONSECUTIVE_FAILURES

constexpr int BluetoothWorker::MAX_CONSECUTIVE_FAILURES = 3
staticconstexprprotected

Definition at line 67 of file BluetoothWorker.h.

Referenced by _reconnectTimeout().

◆ MAX_RECONNECT_ATTEMPTS

constexpr int BluetoothWorker::MAX_RECONNECT_ATTEMPTS = 10
staticconstexprprotected

Definition at line 63 of file BluetoothWorker.h.

Referenced by _reconnectTimeout().

◆ MAX_RECONNECT_INTERVAL_MS

constexpr int BluetoothWorker::MAX_RECONNECT_INTERVAL_MS = 60000
staticconstexprprotected

Definition at line 65 of file BluetoothWorker.h.

Referenced by _reconnectTimeout().

◆ RECONNECT_BASE_INTERVAL_MS

constexpr int BluetoothWorker::RECONNECT_BASE_INTERVAL_MS = 5000
staticconstexprprotected

Definition at line 64 of file BluetoothWorker.h.

Referenced by _reconnectTimeout(), BluetoothWorker(), and disconnectLink().

◆ SERVICE_DISCOVERY_TIMEOUT_MS

constexpr int BluetoothWorker::SERVICE_DISCOVERY_TIMEOUT_MS = 30000
staticconstexprprotected

Definition at line 66 of file BluetoothWorker.h.

Referenced by _serviceDiscoveryTimeout(), and BluetoothWorker().


The documentation for this class was generated from the following files: