![]() |
Limb Range Analyzer
Cross-platform application for human limb range analysis.
|
This class manages Bluetooth connection capabilities. More...
#include <bluetooth.hpp>
Signals | |
| void | Bluetooth_SignalStatusReady () |
| Signal that depicts a need to update device discovery status bar in MainWindow. | |
| void | Bluetooth_SignalDevicesReady () |
| Signal that gets emitted when device discovery finishes. | |
| void | Bluetooth_SignalDisconnected () |
| Signal that gets emitted when a device gets disconnected. | |
| void | Bluetooth_SignalConnectionError (const QString &error) |
| Signal that gets emitted when errors occur while discovering devices. | |
| void | Bluetooth_SignalDeviceConnected () |
| Signal that gets emitted when a device gets successfully connected. | |
| void | Bluetooth_SignalDeviceIncompatible () |
| Signal that gets emitted if a device is incompatible (not a BlueCoin). | |
| void | Bluetooth_SignalDeviceUnreachable () |
| Signal that gets emitted if a device goes out of reach/availability. | |
| void | Bluetooth_SignalDeviceBeyondLimit () |
| Signal that gets emitted if a connection occurs when all controllers are in use. | |
| void | Bluetooth_SignalCharacteristicsUpdated () |
| Signal that gets emitted when characteristics properties change. | |
| void | Bluetooth_SignalSensorDataReady (const QString &hexValue) |
| Signal that gets emitted each time when measurement retrieving timer ticks. | |
Public Member Functions | |
| Bluetooth () | |
| Default class constructor for Bluetooth. More... | |
| ~Bluetooth () | |
| Default class destructor. More... | |
| void | Bluetooth_StartScanning () |
| Initiates the Bluetooth scanning process. More... | |
| bool | Bluetooth_Connect (const QString &deviceAddress) |
| Manages selected device connection. More... | |
| void | Bluetooth_Disconnect (const QString &deviceAddress) |
| Manages chosen device's disconnection. More... | |
| bool | Bluetooth_IsDeviceConnected (const QString &deviceAddress) |
| Provides checking whether a device is connected or not. More... | |
| void | Bluetooth_RetrieveSensorData () |
| Handles the data recovery and possibility of further processing. More... | |
| void | Bluetooth_StopRetrievingSensorData () |
| Function stops repeated data recovery. More... | |
| void | Bluetooth_SetServiceRetrievalSpeed (qint16 serviceRetrievalSpeed) |
| Setter function for recovery timer member variable. More... | |
| void | Bluetooth_SetDebugInformations (bool debugInformations) |
| Setter function for debugging informations member variable. More... | |
| QStringList | Bluetooth_GetDevicesList () |
| Getter function for device names list. More... | |
| QStringList | Bluetooth_GetAddressList () |
| Getter function for device addresses list. More... | |
| quint16 | Bluetooth_GetConnectedDevicesCount () |
| Function for connected devices calculation. More... | |
Private Slots | |
| void | Bluetooth_AddDevice (const QBluetoothDeviceInfo &device) |
| Slot that adds new found device to the list. More... | |
| void | Bluetooth_CatchError (QBluetoothDeviceDiscoveryAgent::Error error) |
| Slot used for error catching while discovering devices. More... | |
| void | Bluetooth_ReportStatus () |
| Slot that manages discovery status reporting to MainWindow. More... | |
| void | Bluetooth_StopScanning () |
| Slot that is processed when device discovery finishes. More... | |
| void | Bluetooth_DeviceConnected (ControllerType controllerType) |
| Slot that initiates service discovery. More... | |
| void | Bluetooth_DeviceHasError (ControllerType controllerType) |
| Slot that reports device error. More... | |
| void | Bluetooth_DeviceDisconnected () |
| Slot that reports device disconnection. More... | |
| void | Bluetooth_RegisterService (ControllerType controllerType, const QBluetoothUuid &uuid) |
| Slot function for service registration. More... | |
| void | Bluetooth_ServicesRegistered () |
| Slot function for service and characteristics analysis. More... | |
| void | Bluetooth_ServiceDetailsObtained (qint16 serviceID, QLowEnergyService::ServiceState newState) |
| Slot that enables repeated characteristics reading. More... | |
Private Attributes | |
| QBluetoothDeviceDiscoveryAgent * | mDiscoveryAgent |
| QBluetoothDeviceDiscoveryAgent member variable pointer for device discovery functionalities. | |
| QLowEnergyController * | mPrimaryController |
| QLowEnergyController, a primary controller member object. | |
| QLowEnergyController * | mSecondaryController |
| QLowEnergyController, a secondary controller member object. | |
| QLowEnergyService * | mPrimaryService |
| QLowEnergyService member for primary BLE service object. | |
| QLowEnergyService * | mSecondaryService |
| QLowEnergyService member for secondary BLE service object. | |
| QList< QObject * > | mDevices |
QList<QObject>, a list of BLE devices held as a QObject pointers. | |
| QList< QObject * > | mServices |
QList<QObject>, a list of discovered Bluetooth services held as a QObject pointers. | |
| QRegularExpression | mHighLevelUUIDExpression |
| QRegularExpression, a member object for UUID pattern recognition used for services and characteristics. | |
| BluetoothDevice | mPrimaryBluetoothDevice |
| BluetoothDevice is custom class based member depicting primary Bluetooth device. | |
| BluetoothDevice | mSecondaryBluetoothDevice |
| BluetoothDevice is custom class based member depicting secondary Bluetooth device. | |
| QStringList | mDevicesList |
| QStringList, it is a list of text strings with device names information. | |
| QStringList | mAddressList |
| QStringList that is a list of text strings with device addresses information. | |
| QString | mPrimaryConnectedAddress |
| QString that holds information about the primary connected device address. | |
| QString | mSecondaryConnectedAddress |
| QString that holds information about the secondary connected device address. | |
| QString | mLatestDeviceAddress |
| QString that holds information about the latest connected device address used. | |
| QString | mPrimaryHighLevelServiceUUID |
| QString with a pre-set value of service UUID used by BlueCoin primary device. | |
| QString | mSecondaryHighLevelServiceUUID |
| QString with a pre-set value of service UUID used by BlueCoin secondary device. | |
| QString | mBaseLowLevelServiceUUID |
| QString with a pre-set value of characteristics UUID used by any BlueCoin device. | |
| QString | mPrimaryLowLevelServiceUUID |
| QString with a pre-set value of characteristics UUID used by primary BlueCoin device. | |
| QString | mSecondaryLowLevelServiceUUID |
| QString with a pre-set value of characteristics UUID used by secondary BlueCoin device. | |
| QTimer * | mBluetoothDiscoveryTimer |
| QTimer that is used for continual Bluetooth devices discovery status reporting. | |
| QTimer * | mBluetoothRetrieveTimer |
| QTimer that is key part of Bluetooth module, it uses time in ms that will elapse before new data retrieval is processed. | |
| qint16 | mServiceRetrievalSpeed |
qint16 value that defines the time needed before mBluetoothRetrieveTimer ticks. | |
| bool | mScanningCompleted |
bool value that in its TRUE state depicts a successful connection response while FALSE means a failure. | |
| bool | mEnableDebugInformations |
bool value that in its TRUE state enables additional debugging informations reporting while FALSE disables it. | |
This class manages Bluetooth connection capabilities.
Bluetooth is QObject derived class meant for implementation of Bluetooth Low Energy technology device discovery and connection along with services and characteristics reading in a periodically repeated manner. It relies on helper classes BluetoothDevice, BluetoothService and BluetoothInfo.
| Bluetooth::Bluetooth | ( | ) |
Default class constructor for Bluetooth.
Function is used for members initialization and Qt's signals and slots connection.
| Bluetooth::~Bluetooth | ( | ) |
Default class destructor.
Provides memory cleaning and object destruction process.
|
privateslot |
Slot that adds new found device to the list.
This slot manages enlisting of a newly discovered device to the list of all found devices. Device names and addresses list are also expanded. This function adds Bluetooth Low Energy devices only, such as BlueCoin.
| device | - a device found by QBluetoothDeviceDiscoveryAgent |
|
privateslot |
Slot used for error catching while discovering devices.
This slot function filters incoming error types and provides informations to the application user.
| error | - error identified by device discovery of QBluetoothDeviceDiscoveryAgent |
| bool Bluetooth::Bluetooth_Connect | ( | const QString & | deviceAddress | ) |
Manages selected device connection.
Function handles Bluetooth connection request and uses the function parameter deviceAddress for connection to a previously discovered device. The function uses member variables to recognise which ControllerType handles connection and quits prematurely if both primary and secondary devices are already connected.
| deviceAddress | - device address to be connected |
TRUE in case of connection success, FALSE otherwise
|
privateslot |
Slot that initiates service discovery.
This slot starts service discovery when a Bluetooth device is connected.
| controllerType | - determines which controller starts the service discovery |
|
privateslot |
Slot that reports device disconnection.
This slot manages Bluetooth_SignalDisconnected signal emitting and informs the user through standard application output if debugging information notifications are turned on.
|
privateslot |
Slot that reports device error.
If debugging informations are turned on, report that a controller (primary or secondary) has an error, if such occurs.
| controllerType | - determines which controller has encountered an error |
| void Bluetooth::Bluetooth_Disconnect | ( | const QString & | deviceAddress | ) |
Manages chosen device's disconnection.
This function manages disconnection of selected device (hence the address parameter). If two devices are connected, the remaining device is re-connected through primary controller.
| deviceAddress | - device address to be disconnected |
| QStringList Bluetooth::Bluetooth_GetAddressList | ( | ) |
Getter function for device addresses list.
This is a getter function that returns the value of mAddressList member variable - list of device addresses.
| quint16 Bluetooth::Bluetooth_GetConnectedDevicesCount | ( | ) |
Function for connected devices calculation.
This function returns the number of connected Bluetooth devices.
| QStringList Bluetooth::Bluetooth_GetDevicesList | ( | ) |
Getter function for device names list.
This is a getter function that returns the value of mDevicesList member variable - list of device names.
| bool Bluetooth::Bluetooth_IsDeviceConnected | ( | const QString & | deviceAddress | ) |
Provides checking whether a device is connected or not.
Function handles checking of a device address and informs whether it is connected or not.
| deviceAddress | - device address to be checked |
TRUE if device with given address is connected, FALSE otherwise
|
privateslot |
Slot function for service registration.
This slot uses obtained service UUID for registration while using selected ControllerType, both received via function parameters. This slot uses custom class BluetoothService which is then added to the list of found and registered services.
| controllerType | - determines which controller has discovered a service |
| uuid | - service UUID to be registered |
|
privateslot |
Slot that manages discovery status reporting to MainWindow.
Slot (function) that emits signal Bluetooth_SignalStatusReady .
| void Bluetooth::Bluetooth_RetrieveSensorData | ( | ) |
Handles the data recovery and possibility of further processing.
This function reads connected device's service characteristics and provides signal emitting, so that it can be processed outside Bluetooth module, namely in SensorModule.
|
privateslot |
Slot that enables repeated characteristics reading.
This slot function responds to signal/slot connection established while processing Bluetooth_ServicesRegistered and finishes the characteristics discovery for a service. If a characteristics UUID matches BlueCoin defined identifier, periodically maintained characteristics reading can be started.
| serviceID | - an identifier of a service |
| newState | - a currently observed state received as a parameter |
|
privateslot |
Slot function for service and characteristics analysis.
Slot function manages Bluetooth services analysis after their discovery is finished. If a BlueCoin specific service UUID is found and low-level UUID of characteristics interpreting the important measured data can also be confirmed, the device is successfully connected to and data can be periodically received. Note that user is informed if a required service is not found, which means that the device is incompatible (it is not a BlueCoin device).
| void Bluetooth::Bluetooth_SetDebugInformations | ( | bool | debugInformations | ) |
Setter function for debugging informations member variable.
This is a setter function that manages the value held by mEnableDebugInformations member variable.
| debugInformations | - TRUE if debug info enabled, FALSE otherwise |
| void Bluetooth::Bluetooth_SetServiceRetrievalSpeed | ( | qint16 | serviceRetrievalSpeed | ) |
Setter function for recovery timer member variable.
This is a setter function that manages the value held by mServiceRetrievalSpeed member variable.
| serviceRetrievalSpeed | - retrieval speed for recovery in ms |
| void Bluetooth::Bluetooth_StartScanning | ( | ) |
Initiates the Bluetooth scanning process.
This function responds to user need of device discovery in area, which is monitored through a QTimer that manages periodical reporting.
| void Bluetooth::Bluetooth_StopRetrievingSensorData | ( | ) |
Function stops repeated data recovery.
Function is used for stopping the QTimer that periodically retrieves BlueCoin measured data obtained via Bluetooth.
|
privateslot |
Slot that is processed when device discovery finishes.
Slot manages discovery QTimer stopping and handles Bluetooth_SignalDevicesReady signal emitting for further device processing.