Commit 6e12a7e8 authored by dogmaphobic's avatar dogmaphobic

ESP8266 Component Panel

parent faea3168
......@@ -45,6 +45,7 @@
<file alias="Airframe/YMinus">src/AutoPilotPlugins/Common/Images/YMinus.svg</file>
<file alias="Airframe/YPlus">src/AutoPilotPlugins/Common/Images/YPlus.svg</file>
<file alias="wifi.svg">src/AutoPilotPlugins/Common/Images/wifi.svg</file>
<file alias="arrow-down.png">src/QmlControls/arrow-down.png</file>
<file alias="FirmwareUpgradeIcon.png">src/VehicleSetup/FirmwareUpgradeIcon.png</file>
<file alias="FlightModesComponentIcon.png">src/AutoPilotPlugins/PX4/Images/FlightModesComponentIcon.png</file>
......
......@@ -572,6 +572,7 @@ HEADERS+= \
src/AutoPilotPlugins/APM/APMSensorsComponentController.h \
src/AutoPilotPlugins/APM/APMTuningComponent.h \
src/AutoPilotPlugins/Common/RadioComponentController.h \
src/AutoPilotPlugins/Common/ESP8266ComponentController.h \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \
src/AutoPilotPlugins/PX4/AirframeComponent.h \
src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \
......@@ -583,6 +584,7 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h \
src/AutoPilotPlugins/PX4/PX4Component.h \
src/AutoPilotPlugins/PX4/PX4RadioComponent.h \
src/AutoPilotPlugins/PX4/PX4ESP8266Component.h \
src/AutoPilotPlugins/PX4/SafetyComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponentController.h \
......@@ -628,6 +630,7 @@ SOURCES += \
src/AutoPilotPlugins/APM/APMSensorsComponentController.cc \
src/AutoPilotPlugins/APM/APMTuningComponent.cc \
src/AutoPilotPlugins/Common/RadioComponentController.cc \
src/AutoPilotPlugins/Common/ESP8266ComponentController.cc \
src/AutoPilotPlugins/APM/APMAirframeComponentAirframes.cc \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \
src/AutoPilotPlugins/PX4/AirframeComponent.cc \
......@@ -640,6 +643,7 @@ SOURCES += \
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc \
src/AutoPilotPlugins/PX4/PX4Component.cc \
src/AutoPilotPlugins/PX4/PX4RadioComponent.cc \
src/AutoPilotPlugins/PX4/PX4ESP8266Component.cc \
src/AutoPilotPlugins/PX4/SafetyComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponentController.cc \
......
......@@ -106,6 +106,8 @@
<file alias="QGroundControl/ScreenTools/ScreenTools.qml">src/QmlControls/ScreenTools.qml</file>
<file alias="QmlTest.qml">src/QmlControls/QmlTest.qml</file>
<file alias="RadioComponent.qml">src/AutoPilotPlugins/Common/RadioComponent.qml</file>
<file alias="ESP8266Component.qml">src/AutoPilotPlugins/Common/ESP8266Component.qml</file>
<file alias="ESP8266ComponentSummary.qml">src/AutoPilotPlugins/Common/ESP8266ComponentSummary.qml</file>
<file alias="PX4RadioComponentSummary.qml">src/AutoPilotPlugins/PX4/PX4RadioComponentSummary.qml</file>
<file alias="PX4TuningComponentCopter.qml">src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml</file>
<file alias="PX4TuningComponentPlane.qml">src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml</file>
......
......@@ -105,9 +105,9 @@ void AutoPilotPlugin::resetAllParametersToDefaults(void)
_vehicle->sendMessage(msg);
}
void AutoPilotPlugin::refreshAllParameters(void)
void AutoPilotPlugin::refreshAllParameters(unsigned char componentID)
{
_vehicle->getParameterLoader()->refreshAllParameters();
_vehicle->getParameterLoader()->refreshAllParameters((uint8_t)componentID);
}
void AutoPilotPlugin::refreshParameter(int componentId, const QString& name)
......
......@@ -71,7 +71,7 @@
Q_INVOKABLE void resetAllParametersToDefaults(void);
/// Re-request the full set of parameters from the autopilot
Q_INVOKABLE void refreshAllParameters(void);
Q_INVOKABLE void refreshAllParameters(unsigned char componentID = MAV_COMP_ID_ALL);
/// Request a refresh on the specific parameter
Q_INVOKABLE void refreshParameter(int componentId, const QString& name);
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 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/>.
======================================================================*/
import QtQuick 2.5
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QGroundControl 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
QGCView {
id: qgcView
viewPanel: panel
QGCPalette { id: palette; colorGroupEnabled: panel.enabled }
property int _firstColumn: ScreenTools.defaultFontPixelWidth * 20
property int _secondColumn: ScreenTools.defaultFontPixelWidth * 12
readonly property string dialogTitle: "controller WiFi Bridge"
ESP8266ComponentController {
id: controller
factPanel: panel
}
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")
QGCViewPanel {
id: panel
anchors.fill: parent
Flickable {
anchors.fill: parent
clip: true
contentHeight: innerColumn.height
contentWidth: panel.width
boundsBehavior: Flickable.StopAtBounds
flickableDirection: Flickable.VerticalFlick
Column {
id: innerColumn
width: panel.width
spacing: ScreenTools.defaultFontPixelHeight * 0.5
QGCLabel {
text: "WiFi Bridge Settings"
font.weight: Font.DemiBold
}
Rectangle {
width: parent.width
height: wifiCol.height + (ScreenTools.defaultFontPixelHeight * 2)
color: palette.windowShade
Column {
id: wifiCol
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
spacing: ScreenTools.defaultFontPixelHeight / 2
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "WiFi Channel"
width: _firstColumn
anchors.baseline: channelField.baseline
}
QGCComboBox {
id: channelField
width: _secondColumn
model: controller.wifiChannels
currentIndex: wifiChannel ? wifiChannel.value - 1 : 0
onActivated: {
wifiChannel.value = index + 1
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "WiFi SSID"
width: _firstColumn
anchors.baseline: ssidField.baseline
}
QGCTextField {
id: ssidField
width: _secondColumn
text: controller.wifiSSID
maximumLength: 16
onEditingFinished: {
controller.wifiSSID = text
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "WiFi Password"
width: _firstColumn
anchors.baseline: passwordField.baseline
}
QGCTextField {
id: passwordField
width: _secondColumn
text: controller.wifiPassword
maximumLength: 16
onEditingFinished: {
controller.wifiPassword = text
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "UART Baud Rate"
width: _firstColumn
anchors.baseline: baudField.baseline
}
QGCComboBox {
id: baudField
width: _secondColumn
model: controller.baudRates
currentIndex: controller.baudIndex
onActivated: {
controller.baudIndex = index
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: "QGC UDP Port"
width: _firstColumn
anchors.baseline: qgcportField.baseline
}
QGCTextField {
id: qgcportField
width: _secondColumn
text: hostPort ? hostPort.valueString : ""
validator: IntValidator {bottom: 1024; top: 65535;}
inputMethodHints: Qt.ImhDigitsOnly
onEditingFinished: {
hostPort.value = text
}
}
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth * 1.5
QGCButton {
text: "Restore Defaults"
width: ScreenTools.defaultFontPixelWidth * 16
onClicked: {
controller.restoreDefaults()
}
}
QGCButton {
text: "Restart WiFi Bridge"
enabled: !controller.busy
width: ScreenTools.defaultFontPixelWidth * 16
onClicked: {
rebootDialog.visible = true
}
MessageDialog {
id: rebootDialog
visible: false
icon: StandardIcon.Warning
standardButtons: StandardButton.Yes | StandardButton.No
title: "Reboot WiFi Bridge"
text: "This will restart the WiFi Bridge so the settings you've changed can take effect. Note that you may have to change your computer WiFi settings and QGroundControl link settings to match these changes. Are you sure you want to restart it?"
onYes: {
controller.reboot()
rebootDialog.visible = false
}
onNo: {
rebootDialog.visible = false
}
}
}
}
}
}
}
}
This diff is collapsed.
/*=====================================================================
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
/// @brief ESP8266 WiFi Config Qml Controller
/// @author Gus Grubba <mavlink@grubba.com>
#ifndef ESP8266ComponentController_H
#define ESP8266ComponentController_H
#include <QTimer>
#include "FactPanelController.h"
#include "UASInterface.h"
#include "QGCLoggingCategory.h"
#include "AutoPilotPlugin.h"
Q_DECLARE_LOGGING_CATEGORY(ESP8266ComponentControllerLog)
namespace Ui {
class ESP8266ComponentController;
}
class ESP8266ComponentController : public FactPanelController
{
Q_OBJECT
public:
ESP8266ComponentController ();
~ESP8266ComponentController ();
Q_PROPERTY(int componentID READ componentID 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_INVOKABLE void restoreDefaults();
Q_INVOKABLE void reboot();
int componentID () { return MAV_COMP_ID_UDP_BRIDGE; }
QString wifiSSID ();
QString wifiPassword ();
QStringList wifiChannels () { return _channels; }
QStringList baudRates () { return _baudRates; }
int baudIndex ();
bool busy () { return _waitType != WAIT_FOR_NOTHING; }
void setWifiSSID (QString id);
void setWifiPassword (QString pwd);
void setBaudIndex (int idx);
signals:
void wifiSSIDChanged ();
void wifiPasswordChanged ();
void baudIndexChanged ();
void busyChanged ();
private slots:
void _processTimeout ();
void _commandAck (UASInterface* uas, uint8_t compID, uint16_t command, uint8_t result);
void _ssidChanged (QVariant value);
void _passwordChanged (QVariant value);
void _baudChanged (QVariant value);
private:
void _reboot ();
void _restoreDefaults ();
private:
QTimer _timer;
QStringList _channels;
QStringList _baudRates;
enum {
WAIT_FOR_NOTHING,
WAIT_FOR_REBOOT,
WAIT_FOR_RESTORE
};
int _waitType;
int _retries;
};
#endif // ESP8266ComponentController_H
import QtQuick 2.2
import QtQuick.Controls 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controllers 1.0
FactPanel {
id: panel
anchors.fill: parent
color: qgcPal.windowShadeDark
QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
FactPanelController { id: controller; factPanel: panel }
ESP8266ComponentController {
id: esp8266
}
property Fact debugEnabled: controller.getParameterFact(esp8266.componentID, "DEBUG_ENABLED")
property Fact wifiChannel: controller.getParameterFact(esp8266.componentID, "WIFI_CHANNEL")
property Fact wifiHostPort: controller.getParameterFact(esp8266.componentID, "WIFI_UDP_HPORT")
property Fact wifiClientPort: controller.getParameterFact(esp8266.componentID, "WIFI_UDP_CPORT")
property Fact uartBaud: controller.getParameterFact(esp8266.componentID, "UART_BAUDRATE")
Column {
anchors.fill: parent
anchors.margins: 8
VehicleSummaryRow {
labelText: "WiFi Channel:"
valueText: wifiChannel.valueString
}
VehicleSummaryRow {
labelText: "WiFi SSID:"
valueText: esp8266.wifiSSID
}
VehicleSummaryRow {
labelText: "WiFi Password:"
valueText: esp8266.wifiPassword
}
VehicleSummaryRow {
labelText: "QGC UDP Port:"
valueText: wifiHostPort.valueString
}
VehicleSummaryRow {
labelText: "UAV UDP Port:"
valueText: wifiClientPort.valueString
}
VehicleSummaryRow {
labelText: "UART Baud Rate:"
valueText: uartBaud.valueString
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 72 72" style="enable-background:new 0 0 72 72;" xml:space="preserve">
<style type="text/css">
.st0{fill:#FFFFFF;}
</style>
<path class="st0" d="M40.896,61.416c-1.317,1.371-2.921,2.043-4.814,2.016c-1.893-0.027-3.525-0.699-4.896-2.016
c-1.371-1.317-2.057-2.921-2.057-4.814s0.686-3.525,2.057-4.896c1.317-1.371,2.921-2.057,4.814-2.057s3.525,0.686,4.896,2.057
c1.371,1.317,2.057,2.935,2.057,4.855C42.953,58.481,42.267,60.099,40.896,61.416z M65.088,34.344c-1.81,0-3.401-0.686-4.772-2.057
c-6.692-6.638-14.784-9.957-24.274-9.957s-17.581,3.319-24.274,9.957c-1.371,1.371-2.99,2.043-4.855,2.016s-3.483-0.699-4.855-2.016
c-1.371-1.371-2.057-2.976-2.057-4.814s0.686-3.442,2.057-4.814c6.144-6.144,13.33-10.299,21.559-12.466s16.471-2.167,24.726,0
s15.456,6.322,21.6,12.466c1.371,1.371,2.057,2.976,2.057,4.814s-0.686,3.442-2.057,4.814
C68.571,33.658,66.953,34.344,65.088,34.344z M21.477,48.908c-1.865,0-3.483-0.686-4.855-2.057c-1.371-1.371-2.057-2.99-2.057-4.855
c0-1.865,0.686-3.483,2.057-4.855c3.511-3.511,7.625-5.883,12.343-7.118c4.718-1.234,9.435-1.234,14.153,0
c4.718,1.234,8.832,3.607,12.343,7.118c1.371,1.371,2.057,2.99,2.057,4.855c0,1.865-0.686,3.483-2.057,4.855
c-1.371,1.371-2.99,2.057-4.855,2.057s-3.483-0.686-4.855-2.057c-2.688-2.688-5.924-4.032-9.71-4.032s-7.022,1.344-9.71,4.032
C24.96,48.222,23.342,48.908,21.477,48.908z"/>
</svg>
......@@ -69,6 +69,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(Vehicle* vehicle, QObject* parent) :
AutoPilotPlugin(vehicle, parent),
_airframeComponent(NULL),
_radioComponent(NULL),
_esp8266Component(NULL),
_flightModesComponent(NULL),
_sensorsComponent(NULL),
_safetyComponent(NULL),
......@@ -102,6 +103,14 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
_radioComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_radioComponent));
//-- Is there an ESP8266 Connected?
Fact* espVersion = getFact(FactSystem::ParameterProvider, MAV_COMP_ID_UDP_BRIDGE, "SW_VER");
if(espVersion && espVersion->componentId() == MAV_COMP_ID_UDP_BRIDGE) {
_esp8266Component = new PX4ESP8266Component(_vehicle, this);
_esp8266Component->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_esp8266Component));
}
_flightModesComponent = new FlightModesComponent(_vehicle, this);
_flightModesComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_flightModesComponent));
......
......@@ -28,6 +28,7 @@
#include "PX4AirframeLoader.h"
#include "AirframeComponent.h"
#include "PX4RadioComponent.h"
#include "PX4ESP8266Component.h"
#include "FlightModesComponent.h"
#include "SensorsComponent.h"
#include "SafetyComponent.h"
......@@ -55,6 +56,7 @@ public:
// These methods should only be used by objects within the plugin
AirframeComponent* airframeComponent(void) { return _airframeComponent; }
PX4RadioComponent* radioComponent(void) { return _radioComponent; }
PX4ESP8266Component* esp8266Component(void) { return _esp8266Component; }
FlightModesComponent* flightModesComponent(void) { return _flightModesComponent; }
SensorsComponent* sensorsComponent(void) { return _sensorsComponent; }
SafetyComponent* safetyComponent(void) { return _safetyComponent; }
......@@ -70,6 +72,7 @@ private:
QVariantList _components;
AirframeComponent* _airframeComponent;
PX4RadioComponent* _radioComponent;
PX4ESP8266Component* _esp8266Component;
FlightModesComponent* _flightModesComponent;
SensorsComponent* _sensorsComponent;
SafetyComponent* _safetyComponent;
......
/*=====================================================================
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/>.
======================================================================*/
#include "PX4ESP8266Component.h"
#include "PX4AutoPilotPlugin.h"
PX4ESP8266Component::PX4ESP8266Component(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: PX4Component(vehicle, autopilot, parent)
, _name(tr("WiFi Bridge"))
{
}
QString PX4ESP8266Component::name(void) const
{
return _name;
}
QString PX4ESP8266Component::description(void) const
{
return tr("The ESP8266 WiFi Bridge Component is used to setup the WiFi link.");
}
QString PX4ESP8266Component::iconResource(void) const
{
return "/qmlimages/wifi.svg";
}
bool PX4ESP8266Component::requiresSetup(void) const
{
return false;
}
bool PX4ESP8266Component::setupComplete(void) const
{
return true;
}
QStringList PX4ESP8266Component::setupCompleteChangedTriggerList(void) const
{
return QStringList();
}
QUrl PX4ESP8266Component::setupSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/ESP8266Component.qml");
}
QUrl PX4ESP8266Component::summaryQmlSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/ESP8266ComponentSummary.qml");
}
QString PX4ESP8266Component::prerequisiteSetup(void) const
{
return QString();
}
/*=====================================================================
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/>.
======================================================================*/
#ifndef PX4ESP8266Component_H
#define PX4ESP8266Component_H
#include "PX4Component.h"
class PX4ESP8266Component : public PX4Component
{
Q_OBJECT
public:
PX4ESP8266Component (Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
QStringList setupCompleteChangedTriggerList() const;
// Virtuals from VehicleComponent
QString name () const;
QString description () const;
QString iconResource () const;
bool requiresSetup () const;
bool setupComplete () const;
QUrl setupSource () const;
QUrl summaryQmlSource () const;
QString prerequisiteSetup () const;
private:
const QString _name;
QVariantList _summaryItems;
};
#endif
......@@ -72,7 +72,7 @@ ParameterLoader::ParameterLoader(AutoPilotPlugin* autopilot, Vehicle* vehicle, Q
_cacheTimeoutTimer.setSingleShot(true);
_cacheTimeoutTimer.setInterval(2500);
connect(&_cacheTimeoutTimer, &QTimer::timeout, this, &ParameterLoader::refreshAllParameters);
connect(&_cacheTimeoutTimer, &QTimer::timeout, this, &ParameterLoader::_timeoutRefreshAll);
connect(_vehicle->uas(), &UASInterface::parameterUpdate, this, &ParameterLoader::_parameterUpdate);
......@@ -297,7 +297,7 @@ void ParameterLoader::_valueUpdated(const QVariant& value)
qCDebug(ParameterLoaderLog) << "Set parameter (componentId:" << componentId << "name:" << name << value << ")";
}
void ParameterLoader::refreshAllParameters(void)
void ParameterLoader::refreshAllParameters(uint8_t componentID)
{
_dataMutex.lock();
......@@ -306,11 +306,13 @@ void ParameterLoader::refreshAllParameters(void)
}
// Reset index wait lists
foreach (int componentId, _paramCountMap.keys()) {
foreach (int cid, _paramCountMap.keys()) {
// Add/Update all indices to the wait list, parameter index is 0-based
for (int waitingIndex=0; waitingIndex<_paramCountMap[componentId]; waitingIndex++) {
if(componentID != MAV_COMP_ID_ALL && componentID != cid)
continue;
for (int waitingIndex = 0; waitingIndex < _paramCountMap[cid]; waitingIndex++) {
// This will add a new waiting index if needed and set the retry count for that index to 0
_waitingReadParamIndexMap[componentId][waitingIndex] = 0;
_waitingReadParamIndexMap[cid][waitingIndex] = 0;
}
}
......@@ -320,10 +322,11 @@ void ParameterLoader::refreshAllParameters(void)
Q_ASSERT(mavlink);
mavlink_message_t msg;
mavlink_msg_param_request_list_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, _vehicle->id(), MAV_COMP_ID_ALL);
mavlink_msg_param_request_list_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, _vehicle->id(), componentID);
_vehicle->sendMessageOnLink(_vehicle->priorityLink(), msg);
qCDebug(ParameterLoaderLog) << "Request to refresh all parameters";
QString what = (componentID == MAV_COMP_ID_ALL) ? "MAV_COMP_ID_ALL" : QString::number(componentID);
qCDebug(ParameterLoaderLog) << "Request to refresh all parameters for component ID:" << what;
}
void ParameterLoader::_determineDefaultComponentId(void)
......@@ -863,7 +866,7 @@ void ParameterLoader::_checkInitialLoadComplete(void)
if (initialLoadFailures) {
qgcApp()->showMessage("QGroundControl was unable to retrieve the full set of parameters from the vehicle. "
"This will cause QGroundControl to be unable to display it's full user interface. "
"This will cause QGroundControl to be unable to display its full user interface. "
"If you are using modified firmware, you may need to resolve any vehicle startup errors to resolve the issue. "
"If you are using standard firmware, you may need to upgrade to a newer version to resolve the issue.");
qCWarning(ParameterLoaderLog) << "The following parameter indices could not be loaded after the maximum number of retries: " << indexList;
......@@ -883,3 +886,9 @@ void ParameterLoader::_initialRequestTimeout(void)
refreshAllParameters();
_initialRequestTimeoutTimer.start();
}
void ParameterLoader::_timeoutRefreshAll()
{
refreshAllParameters();
}
......@@ -57,7 +57,7 @@ public:
bool parametersAreReady(void) { return _parametersReady; }
/// Re-request the full set of parameters from the autopilot
void refreshAllParameters(void);
void refreshAllParameters(uint8_t componentID = MAV_COMP_ID_ALL);
/// Request a refresh on the specific parameter
void refreshParameter(int componentId, const QString& name);
......@@ -107,6 +107,9 @@ protected:
void _tryCacheLookup(void);
void _initialRequestTimeout(void);
private slots:
void _timeoutRefreshAll();
private:
static QVariant _stringToTypedVariant(const QString& string, FactMetaData::ValueType_t type, bool failOk = false);
int _actualComponentId(int componentId);
......
......@@ -68,6 +68,7 @@
#include "APMSensorsComponentController.h"
#include "PowerComponentController.h"
#include "RadioComponentController.h"
#include "ESP8266ComponentController.h"
#include "ScreenToolsController.h"
#include "AutoPilotPlugin.h"
#include "VehicleComponent.h"
......@@ -378,6 +379,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<SensorsComponentController> ("QGroundControl.Controllers", 1, 0, "SensorsComponentController");
qmlRegisterType<PowerComponentController> ("QGroundControl.Controllers", 1, 0, "PowerComponentController");
qmlRegisterType<RadioComponentController> ("QGroundControl.Controllers", 1, 0, "RadioComponentController");
qmlRegisterType<ESP8266ComponentController> ("QGroundControl.Controllers", 1, 0, "ESP8266ComponentController");
qmlRegisterType<ScreenToolsController> ("QGroundControl.Controllers", 1, 0, "ScreenToolsController");
qmlRegisterType<MainToolBarController> ("QGroundControl.Controllers", 1, 0, "MainToolBarController");
qmlRegisterType<MissionController> ("QGroundControl.Controllers", 1, 0, "MissionController");
......
......@@ -140,7 +140,7 @@ void UDPLink::run()
if(!_running)
break;
//-- Settle down (it gets here if there is nothing to read or write)
this->msleep(50);
this->msleep(5);
}
} else {
exec();
......@@ -242,30 +242,21 @@ void UDPLink::_sendBytes(const char* data, qint64 size)
**/
void UDPLink::readBytes()
{
QByteArray databuffer;
while (_socket->hasPendingDatagrams())
{
QByteArray datagram;
datagram.resize(_socket->pendingDatagramSize());
QHostAddress sender;
quint16 senderPort;
_socket->readDatagram(datagram.data(), datagram.size(), &sender, &senderPort);
// FIXME TODO Check if this method is better than retrieving the data by individual processes
emit bytesReceived(this, datagram);
databuffer.append(datagram);
//-- Wait a bit before sending it over
if(databuffer.size() > 10 * 1024) {
emit bytesReceived(this, databuffer);
databuffer.clear();
}
_logInputDataRate(datagram.length(), QDateTime::currentMSecsSinceEpoch());
// // Echo data for debugging purposes
// std::cerr << __FILE__ << __LINE__ << "Received datagram:" << std::endl;
// int i;
// for (i=0; i<s; i++)
// {
// unsigned int v=data[i];
// fprintf(stderr,"%02x ", v);
// }
// std::cerr << std::endl;
// TODO This doesn't validade the sender. Anything sending UDP packets to this port gets
// added to the list and will start receiving datagrams from here. Even a port scanner
// would trigger this.
......@@ -274,6 +265,10 @@ void UDPLink::readBytes()
if(UDP_BROKEN_SIGNAL && !_running)
break;
}
//-- Send whatever is left
if(databuffer.size()) {
emit bytesReceived(this, databuffer);
}
}
/**
......@@ -324,6 +319,14 @@ bool UDPLink::_hardwareConnect()
_socket->setProxy(QNetworkProxy::NoProxy);
_connectState = _socket->bind(host, _config->localPort(), QAbstractSocket::ReuseAddressHint | QUdpSocket::ShareAddress);
if (_connectState) {
//-- Make sure we have a large enough IO buffers
#ifdef __mobile
_socket->setSocketOption(QAbstractSocket::SendBufferSizeSocketOption, 64 * 1024);
_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, 128 * 1024);
#else
_socket->setSocketOption(QAbstractSocket::SendBufferSizeSocketOption, 256 * 1024);
_socket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, 512 * 1024);
#endif
_registerZeroconf(_config->localPort(), kZeroconfRegistration);
//-- Connect signal if this version of Qt is not broken
if(!UDP_BROKEN_SIGNAL) {
......@@ -451,17 +454,18 @@ void UDPConfiguration::addHost(const QString host)
void UDPConfiguration::addHost(const QString& host, int port)
{
bool changed = false;
QMutexLocker locker(&_confMutex);
if(_hosts.contains(host)) {
if(_hosts[host] != port) {
_hosts[host] = port;
changed = true;
}
} else {
QString ipAdd = get_ip_address(host);
if(ipAdd.isEmpty()) {
qWarning() << "UDP:" << "Could not resolve host:" << host << "port:" << port;
} else {
// In simulation and testing setups the vehicle and the GCS can be
// running on the same host. This leads to packets arriving through
// the local network or the loopback adapter, which makes it look
......@@ -470,21 +474,17 @@ void UDPConfiguration::addHost(const QString& host, int port)
//
// We detect this case and force all traffic to a simulated instance
// onto the local loopback interface.
bool not_local = true;
// Run through all IPv4 interfaces and check if their canonical
// IP address in string representation matches the source IP address
foreach (const QHostAddress &address, QNetworkInterface::allAddresses()) {
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
if (ipAdd.endsWith(address.toString())) {
// This is a local address of the same host
not_local = false;
}
}
}
if (not_local) {
// This is a normal remote host, add it using its IPv4 address
_hosts[ipAdd] = port;
......@@ -493,9 +493,12 @@ void UDPConfiguration::addHost(const QString& host, int port)
// It is localhost, so talk to it through the IPv4 loopback interface
_hosts["127.0.0.1"] = port;
}
changed = true;
}
}
if(changed) {
_updateHostList();
}
}
void UDPConfiguration::removeHost(const QString host)
......
......@@ -789,6 +789,7 @@ void UAS::receiveMessage(mavlink_message_t message)
{
mavlink_command_ack_t ack;
mavlink_msg_command_ack_decode(&message, &ack);
emit commandAck(this, message.compid, ack.command, ack.result);
switch (ack.result)
{
case MAV_RESULT_ACCEPTED:
......
......@@ -327,6 +327,9 @@ signals:
void logEntry (UASInterface* uas, uint32_t time_utc, uint32_t size, uint16_t id, uint16_t num_logs, uint16_t last_log_num);
void logData (UASInterface* uas, uint32_t ofs, uint16_t id, uint8_t count, const uint8_t* data);
/** @brief Command Ack */
void commandAck (UASInterface* uas, uint8_t compID, uint16_t command, uint8_t result);
protected:
// TIMEOUT CONSTANTS
......
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