Commit 275ea54a authored by dogmaphobic's avatar dogmaphobic

Support for new firmware.

Added setting to set the WiFi mode (AP or Station)
parent c5a25cf7
......@@ -41,7 +41,7 @@ QGCView {
QGCPalette { id: palette; colorGroupEnabled: panel.enabled }
property int _firstColumn: ScreenTools.defaultFontPixelWidth * 20
property int _secondColumn: ScreenTools.defaultFontPixelWidth * 12
property int _secondColumn: ScreenTools.defaultFontPixelWidth * 18
readonly property string dialogTitle: qsTr("controller WiFi Bridge")
property int stStatus: XMLHttpRequest.UNSENT
property int stErrorCount: 0
......@@ -64,15 +64,19 @@ QGCView {
function updateStatus() {
timer.stop()
var req = new XMLHttpRequest;
var url = "http://192.168.4.1/status.json"
var url = "http://"
url += controller.wifiIPAddress
url += "/status.json"
if(stResetCounters) {
url = url + "?r=1"
stResetCounters = false
}
console.log(url)
req.open("GET", url);
req.onreadystatechange = function() {
stStatus = req.readyState;
if (stStatus === XMLHttpRequest.DONE) {
console.log(req.responseText)
var objectArray = JSON.parse(req.responseText);
if (objectArray.errors !== undefined) {
console.log(qsTr("Error fetching WiFi Bridge Status: %1").arg(objectArray.errors[0].message))
......@@ -107,6 +111,7 @@ QGCView {
timer.triggered.connect(updateStatus)
}
property Fact wifiMode: controller.getParameterFact(controller.componentID, "WIFI_MODE", false) //-- Don't bitch about missing as this is new
property Fact wifiChannel: controller.getParameterFact(controller.componentID, "WIFI_CHANNEL")
property Fact hostPort: controller.getParameterFact(controller.componentID, "WIFI_UDP_HPORT")
property Fact clientPort: controller.getParameterFact(controller.componentID, "WIFI_UDP_CPORT")
......@@ -149,6 +154,24 @@ QGCView {
id: wifiCol
anchors.verticalCenter: parent.verticalCenter
spacing: ScreenTools.defaultFontPixelHeight / 2
Row {
visible: wifiMode
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("WiFi Mode")
width: _firstColumn
anchors.baseline: modeField.baseline
}
QGCComboBox {
id: modeField
width: _secondColumn
model: ["Access Point Mode", "Station Mode"]
currentIndex: wifiMode ? wifiMode.value : 0
onActivated: {
wifiMode.value = index
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
......@@ -159,6 +182,7 @@ QGCView {
QGCComboBox {
id: channelField
width: _secondColumn
enabled: wifiMode && wifiMode.value === 0
model: controller.wifiChannels
currentIndex: wifiChannel ? wifiChannel.value - 1 : 0
onActivated: {
......@@ -395,8 +419,8 @@ QGCView {
}
}
QGCButton {
text: stEnabled ? qsTr("Hide Status") : qsTr("Show Status")
width: ScreenTools.defaultFontPixelWidth * 16
text: stEnabled ? qsTr("Hide Status") : qsTr("Show Status")
width: ScreenTools.defaultFontPixelWidth * 16
onClicked: {
stEnabled = !stEnabled
if(stEnabled)
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/// @file
......@@ -74,6 +74,21 @@ ESP8266ComponentController::version()
return versionString;
}
//-----------------------------------------------------------------------------
QString
ESP8266ComponentController::wifiIPAddress()
{
if(_ipAddress.isEmpty()) {
if(parameterExists(MAV_COMP_ID_UDP_BRIDGE, "WIFI_IPADDRESS")) {
QHostAddress address(ntohl(getParameterFact(MAV_COMP_ID_UDP_BRIDGE, "WIFI_IPADDRESS")->rawValue().toUInt()));
_ipAddress = address.toString();
} else {
_ipAddress = "192.168.4.1";
}
}
return _ipAddress;
}
//-----------------------------------------------------------------------------
QString
ESP8266ComponentController::wifiSSID()
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
......@@ -45,26 +45,28 @@ namespace Ui {
class ESP8266ComponentController : public FactPanelController
{
Q_OBJECT
public:
ESP8266ComponentController ();
~ESP8266ComponentController ();
Q_PROPERTY(int componentID READ componentID CONSTANT)
Q_PROPERTY(QString version READ version NOTIFY versionChanged)
Q_PROPERTY(QString wifiIPAddress READ wifiIPAddress CONSTANT)
Q_PROPERTY(QString wifiSSID READ wifiSSID WRITE setWifiSSID NOTIFY wifiSSIDChanged)
Q_PROPERTY(QString wifiPassword READ wifiPassword WRITE setWifiPassword NOTIFY wifiPasswordChanged)
Q_PROPERTY(QStringList wifiChannels READ wifiChannels CONSTANT)
Q_PROPERTY(QStringList baudRates READ baudRates CONSTANT)
Q_PROPERTY(int baudIndex READ baudIndex WRITE setBaudIndex NOTIFY baudIndexChanged)
Q_PROPERTY(bool busy READ busy NOTIFY busyChanged)
Q_PROPERTY(Vehicle* vehicle READ vehicle CONSTANT)
Q_PROPERTY(Vehicle* vehicle READ vehicle CONSTANT)
Q_INVOKABLE void restoreDefaults();
Q_INVOKABLE void reboot ();
int componentID () { return MAV_COMP_ID_UDP_BRIDGE; }
QString version ();
QString wifiIPAddress ();
QString wifiSSID ();
QString wifiPassword ();
QStringList wifiChannels () { return _channels; }
......@@ -100,6 +102,7 @@ private:
QTimer _timer;
QStringList _channels;
QStringList _baudRates;
QString _ipAddress;
enum {
WAIT_FOR_NOTHING,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment