-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbleuart.h
54 lines (44 loc) · 1.46 KB
/
bleuart.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
#ifndef BLEUART_H
#define BLEUART_H
#include <QObject>
#include <QBluetoothDeviceInfo>
#include <QLowEnergyController>
#include <QLowEnergyService>
class BleUART : public QObject
{
Q_OBJECT
public:
explicit BleUART(QObject *parent = nullptr);
void connectToDevice(QBluetoothDeviceInfo device);
~BleUART();
void write(QByteArray data);
void disconnect();
private:
bool m_foundUARTService;
QLowEnergyController *m_control;
QLowEnergyService *m_service;
QLowEnergyCharacteristic m_txChar;
QLowEnergyCharacteristic m_rxChar;
QLowEnergyDescriptor m_rxDesc;
QByteArray bleWriteQueue;
void handleConnected();
void handleDisconnected();
void handleError(QLowEnergyController::Error error);
//QLowEnergyController
void serviceDiscovered(const QBluetoothUuid &);
void serviceScanDone();
//QLowEnergyService
void serviceStateChanged(QLowEnergyService::ServiceState s);
void updateCharacteristicValue(const QLowEnergyCharacteristic &c,
const QByteArray &value);
void confirmedDescriptorWrite(const QLowEnergyDescriptor &d,
const QByteArray &value);
void confirmedCharacteristicWrite(const QLowEnergyCharacteristic &d,
const QByteArray &value);
signals:
void connectionChanged(bool connected);
void dataReceived(QByteArray data);
void dataWritten();
public slots:
};
#endif // BLEUART_H