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