-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblerfcomm.hpp
58 lines (43 loc) · 1.42 KB
/
blerfcomm.hpp
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
#pragma once
#include <QBluetoothUuid>
#include <QByteArray>
#include <QObject>
#include "blecomm.hpp"
class BLERFComm : public QObject
{
Q_OBJECT
Q_PROPERTY(QBluetoothUuid serviceUuid READ serviceUuid WRITE setServiceUuid
NOTIFY serviceUuidChanged)
Q_PROPERTY(QBluetoothUuid charUuid READ charUuid WRITE setCharUuid NOTIFY
charUuidChanged)
BLEComm* m_comm{nullptr};
QByteArray m_rxBuffer{};
int m_expectedBytes{0};
bool m_rxInProgress{false};
bool m_deviceReady{false};
bool m_deviceConnected{false};
public:
explicit BLERFComm(QObject* parent = nullptr);
QBluetoothUuid serviceUuid() const;
QBluetoothUuid charUuid() const;
bool isDeviceConnected() const;
bool isDeviceReady() const;
signals:
void dataReceived(QByteArray const& data);
void connectedToDevice();
void deviceReady();
void disconnectedFromDevice();
void connectionError(BLEComm::Error error, QString const& description);
void serviceUuidChanged(QBluetoothUuid const& serviceUuid);
void charUuidChanged(QBluetoothUuid const& charUuid);
public slots:
void sendData(QByteArray const& data);
void connectToDevice(QBluetoothDeviceInfo const& device);
void disconnectFromDevice();
void setServiceUuid(QBluetoothUuid const& serviceUuid);
void setCharUuid(QBluetoothUuid const& charUuid);
private slots:
void handleRx(QByteArray const& data);
private:
bool rxInProgress() const;
};