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 { ...@@ -41,7 +41,7 @@ QGCView {
QGCPalette { id: palette; colorGroupEnabled: panel.enabled } QGCPalette { id: palette; colorGroupEnabled: panel.enabled }
property int _firstColumn: ScreenTools.defaultFontPixelWidth * 20 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") readonly property string dialogTitle: qsTr("controller WiFi Bridge")
property int stStatus: XMLHttpRequest.UNSENT property int stStatus: XMLHttpRequest.UNSENT
property int stErrorCount: 0 property int stErrorCount: 0
...@@ -64,15 +64,19 @@ QGCView { ...@@ -64,15 +64,19 @@ QGCView {
function updateStatus() { function updateStatus() {
timer.stop() timer.stop()
var req = new XMLHttpRequest; var req = new XMLHttpRequest;
var url = "http://192.168.4.1/status.json" var url = "http://"
url += controller.wifiIPAddress
url += "/status.json"
if(stResetCounters) { if(stResetCounters) {
url = url + "?r=1" url = url + "?r=1"
stResetCounters = false stResetCounters = false
} }
console.log(url)
req.open("GET", url); req.open("GET", url);
req.onreadystatechange = function() { req.onreadystatechange = function() {
stStatus = req.readyState; stStatus = req.readyState;
if (stStatus === XMLHttpRequest.DONE) { if (stStatus === XMLHttpRequest.DONE) {
console.log(req.responseText)
var objectArray = JSON.parse(req.responseText); var objectArray = JSON.parse(req.responseText);
if (objectArray.errors !== undefined) { if (objectArray.errors !== undefined) {
console.log(qsTr("Error fetching WiFi Bridge Status: %1").arg(objectArray.errors[0].message)) console.log(qsTr("Error fetching WiFi Bridge Status: %1").arg(objectArray.errors[0].message))
...@@ -107,6 +111,7 @@ QGCView { ...@@ -107,6 +111,7 @@ QGCView {
timer.triggered.connect(updateStatus) 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 wifiChannel: controller.getParameterFact(controller.componentID, "WIFI_CHANNEL")
property Fact hostPort: controller.getParameterFact(controller.componentID, "WIFI_UDP_HPORT") property Fact hostPort: controller.getParameterFact(controller.componentID, "WIFI_UDP_HPORT")
property Fact clientPort: controller.getParameterFact(controller.componentID, "WIFI_UDP_CPORT") property Fact clientPort: controller.getParameterFact(controller.componentID, "WIFI_UDP_CPORT")
...@@ -149,6 +154,24 @@ QGCView { ...@@ -149,6 +154,24 @@ QGCView {
id: wifiCol id: wifiCol
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: ScreenTools.defaultFontPixelHeight / 2 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 { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
QGCLabel { QGCLabel {
...@@ -159,6 +182,7 @@ QGCView { ...@@ -159,6 +182,7 @@ QGCView {
QGCComboBox { QGCComboBox {
id: channelField id: channelField
width: _secondColumn width: _secondColumn
enabled: wifiMode && wifiMode.value === 0
model: controller.wifiChannels model: controller.wifiChannels
currentIndex: wifiChannel ? wifiChannel.value - 1 : 0 currentIndex: wifiChannel ? wifiChannel.value - 1 : 0
onActivated: { onActivated: {
......
...@@ -74,6 +74,21 @@ ESP8266ComponentController::version() ...@@ -74,6 +74,21 @@ ESP8266ComponentController::version()
return versionString; 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 QString
ESP8266ComponentController::wifiSSID() ESP8266ComponentController::wifiSSID()
......
...@@ -52,6 +52,7 @@ public: ...@@ -52,6 +52,7 @@ public:
Q_PROPERTY(int componentID READ componentID CONSTANT) Q_PROPERTY(int componentID READ componentID CONSTANT)
Q_PROPERTY(QString version READ version NOTIFY versionChanged) 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 wifiSSID READ wifiSSID WRITE setWifiSSID NOTIFY wifiSSIDChanged)
Q_PROPERTY(QString wifiPassword READ wifiPassword WRITE setWifiPassword NOTIFY wifiPasswordChanged) Q_PROPERTY(QString wifiPassword READ wifiPassword WRITE setWifiPassword NOTIFY wifiPasswordChanged)
Q_PROPERTY(QStringList wifiChannels READ wifiChannels CONSTANT) Q_PROPERTY(QStringList wifiChannels READ wifiChannels CONSTANT)
...@@ -65,6 +66,7 @@ public: ...@@ -65,6 +66,7 @@ public:
int componentID () { return MAV_COMP_ID_UDP_BRIDGE; } int componentID () { return MAV_COMP_ID_UDP_BRIDGE; }
QString version (); QString version ();
QString wifiIPAddress ();
QString wifiSSID (); QString wifiSSID ();
QString wifiPassword (); QString wifiPassword ();
QStringList wifiChannels () { return _channels; } QStringList wifiChannels () { return _channels; }
...@@ -100,6 +102,7 @@ private: ...@@ -100,6 +102,7 @@ private:
QTimer _timer; QTimer _timer;
QStringList _channels; QStringList _channels;
QStringList _baudRates; QStringList _baudRates;
QString _ipAddress;
enum { enum {
WAIT_FOR_NOTHING, 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