-
Notifications
You must be signed in to change notification settings - Fork 0
/
esp01.h
49 lines (36 loc) · 971 Bytes
/
esp01.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
#ifndef SERIALPORTCONTROLLER_H
#define SERIALPORTCONTROLLER_H
#include <QObject>
#include <QSerialPort>
#include <QSerialPortInfo>
using SerialPortList = QList<QSerialPortInfo>;
enum state {
DISCONNECTED,
IDLE,
WAIT_RESULT,
};
class ESP01 : public QObject
{
Q_OBJECT
public:
explicit ESP01(QObject *parent = nullptr);
~ESP01();
static SerialPortList enumerateSerialPorts(bool dump=false);
bool open(QString portName = QString());
void close();
bool isOpen() const;
void sendCommand(QString cmd);
signals:
void commandResponse(bool status, QStringList response);
public slots:
void onReadyRead();
protected:
QString serPortName;
QSerialPort serPort;
bool cmdSent = false;
enum state curState = DISCONNECTED;
bool configurePort();
QString replyLineBuffer;
QStringList response;
};
#endif // SERIALPORTCONTROLLER_H