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),
......@@ -101,7 +102,15 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
_radioComponent = new PX4RadioComponent(_vehicle, this);
_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."