-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevice.h
More file actions
52 lines (42 loc) · 1.36 KB
/
device.h
File metadata and controls
52 lines (42 loc) · 1.36 KB
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
#ifndef DEVICE_H
#define DEVICE_H
#include <QObject>
#include <QString>
#include <QLowEnergyController>
#include <QLowEnergyService>
#include <QLowEnergyCharacteristic>
class Device : public QObject
{
Q_OBJECT
public:
explicit Device(QBluetoothDeviceInfo &info,QObject *parent = nullptr);
~Device();
QString m_name;
QString getName() { return m_name; }
void setName(QString name) { m_name = name;}
QBluetoothAddress getAddress() { return m_info.address(); }
void write(QString data);
QString read();
void disconnectIt() { m_control->disconnectFromDevice(); }
private:
QLowEnergyController* m_control;
QLowEnergyService *m_service;
QList<QLowEnergyCharacteristic> m_chars;
QBluetoothDeviceInfo m_info;
QList<QBluetoothUuid> services;
signals:
void devCon(QString ID);
void devDis(QString ID);
void Packet(QString ID, QByteArray data);
void errorMsg(QString msg);
public slots:
void deviceConnected();
void deviceDisconnected();
void addService(QBluetoothUuid serv);
void selectService();
void selectChar(QLowEnergyService::ServiceState a);
void characteristicChanged(QLowEnergyCharacteristic b ,QByteArray a);
void error(QLowEnergyController::Error er);
void error(QLowEnergyService::ServiceError er);
};
#endif // DEVICE_H