QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ESP8266ComponentController.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QLoggingCategory>
4#include <QtCore/QVariant>
5#include <QtQmlIntegration/QtQmlIntegration>
6
8#include "MAVLinkLib.h"
9
10Q_DECLARE_LOGGING_CATEGORY(ESP8266ComponentControllerLog)
11
12class Fact;
13class Vehicle;
14
16{
17 Q_OBJECT
18 QML_ELEMENT
19 Q_MOC_INCLUDE("Vehicle.h")
20 Q_PROPERTY(int componentID READ componentID CONSTANT)
21 Q_PROPERTY(QString version READ version NOTIFY versionChanged)
22 Q_PROPERTY(QString wifiIPAddress READ wifiIPAddress CONSTANT)
23 Q_PROPERTY(QString wifiSSID READ wifiSSID WRITE setWifiSSID NOTIFY wifiSSIDChanged)
24 Q_PROPERTY(QString wifiPassword READ wifiPassword WRITE setWifiPassword NOTIFY wifiPasswordChanged)
25 Q_PROPERTY(QString wifiSSIDSta READ wifiSSIDSta WRITE setWifiSSIDSta NOTIFY wifiSSIDStaChanged)
26 Q_PROPERTY(QString wifiPasswordSta READ wifiPasswordSta WRITE setWifiPasswordSta NOTIFY wifiPasswordStaChanged)
27 Q_PROPERTY(QStringList wifiChannels READ wifiChannels CONSTANT)
28 Q_PROPERTY(QStringList baudRates READ baudRates CONSTANT)
29 Q_PROPERTY(int baudIndex READ baudIndex WRITE setBaudIndex NOTIFY baudIndexChanged)
30 Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
31 Q_PROPERTY(Vehicle *vehicle READ vehicle CONSTANT)
32
33public:
34 explicit ESP8266ComponentController(QObject *parent = nullptr);
36
37 Q_INVOKABLE void restoreDefaults();
38 Q_INVOKABLE void reboot();
39
40 static int componentID() { return MAV_COMP_ID_UDP_BRIDGE; }
41 QString version() const;
42 QString wifiIPAddress();
43 QString wifiSSID() const;
44 QString wifiPassword() const;
45 QString wifiSSIDSta() const;
46 QString wifiPasswordSta() const;
47 QStringList wifiChannels() const { return _channels; }
48 QStringList baudRates() const { return _baudRates; }
49 int baudIndex() const;
50 bool busy() const { return (_waitType != WAIT_FOR_NOTHING); }
51 Vehicle *vehicle() const { return _vehicle; }
52
53 void setWifiSSID(const QString &id) const;
54 void setWifiPassword(const QString &pwd) const;
55 void setWifiSSIDSta(const QString &id) const;
56 void setWifiPasswordSta(const QString &pwd) const;
57 void setBaudIndex(int idx) const;
58
59signals:
67
68private slots:
69 void _mavCommandResult(int vehicleId, int component, int command, int result, int failureCode);
70 void _ssidChanged(QVariant /*value*/) { emit wifiSSIDChanged(); }
71 void _passwordChanged(QVariant /*value*/) { emit wifiPasswordChanged(); }
72 void _baudChanged(QVariant /*value*/) { emit baudIndexChanged(); }
73 void _versionChanged(QVariant /*value*/) { emit versionChanged(); }
74
75private:
76 void _reboot() const;
77 void _restoreDefaults() const;
78
79 QStringList _channels;
80 const QStringList _baudRates = { QStringLiteral("57600"), QStringLiteral("115200"), QStringLiteral("230400"), QStringLiteral("460800"), QStringLiteral("921600") };
81 QString _ipAddress;
82
83 enum {
84 WAIT_FOR_NOTHING,
85 WAIT_FOR_REBOOT,
86 WAIT_FOR_RESTORE
87 };
88
89 int _waitType = WAIT_FOR_NOTHING;
90 int _retries = 0;
91
92 Fact *_baud = nullptr;
93 Fact *_ver = nullptr;
94
95 Fact *_ssid1 = nullptr;
96 Fact *_ssid2 = nullptr;
97 Fact *_ssid3 = nullptr;
98 Fact *_ssid4 = nullptr;
99
100 Fact *_pwd1 = nullptr;
101 Fact *_pwd2 = nullptr;
102 Fact *_pwd3 = nullptr;
103 Fact *_pwd4 = nullptr;
104
105 Fact *_ssidsta1 = nullptr;
106 Fact *_ssidsta2 = nullptr;
107 Fact *_ssidsta3 = nullptr;
108 Fact *_ssidsta4 = nullptr;
109
110 Fact *_pwdsta1 = nullptr;
111 Fact *_pwdsta2 = nullptr;
112 Fact *_pwdsta3 = nullptr;
113 Fact *_pwdsta4 = nullptr;
114};
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
Used for handling missing Facts from C++ code.
A Fact is used to hold a single value within the system.
Definition Fact.h:19