dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
uploadergadgetwidget.h
Go to the documentation of this file.
1 
13 /*
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  * for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, see <http://www.gnu.org/licenses/>
26  *
27  * Additional note on redistribution: The copyright and license notices above
28  * must be maintained in each individual source file that is a derivative work
29  * of this source file; otherwise redistribution is prohibited.
30  */
31 
32 #ifndef UPLOADERGADGETWIDGET_H
33 #define UPLOADERGADGETWIDGET_H
34 
35 #include <QPointer>
36 #include "tl_dfu.h"
37 #include <coreplugin/iboardtype.h>
38 #include "uploader_global.h"
44 #include "upgradeassistantdialog.h"
45 
46 class QNetworkAccessManager;
47 class Ui_UploaderWidget;
48 
49 using namespace tl_dfu;
50 
51 namespace uploader {
52 
54 
55 class UPLOADER_EXPORT UploaderGadgetWidget : public QWidget
56 {
57  Q_OBJECT
58 
59 public:
60  UploaderGadgetWidget(QWidget *parent = nullptr);
62 
67  bool active() const;
68 
69 signals:
70  void newBoardSeen(deviceInfo board, deviceDescriptorStruct device);
71  void enteredLoader();
72 private slots:
73  void onAutopilotConnect();
74  void onAutopilotDisconnect();
75  void onAutopilotReady();
76  void onIAPUpdated();
77  void onLoadFirmwareButtonClick();
78  void onFlashButtonClick();
79  void onRescueButtonClick();
80  void onExportButtonClick();
81  void onBootloaderDetected();
82  void onBootloaderRemoved();
83  void onRescueTimer();
84  void onStatusUpdate(QString, int);
85  void onPartitionSave();
86  void onPartitionFlash();
87  void onPartitionErase();
88  void onBootButtonClick();
89  void openHelp();
90  void onDeviceDiscovered();
91 
92 private:
93  void FirmwareOnDeviceClear(bool clear);
94  void FirmwareLoadedClear(bool clear);
95  void PartitionBrowserClear();
96  void DeviceInformationClear();
97  void DeviceInformationUpdate(deviceInfo board);
98  void FirmwareOnDeviceUpdate(deviceDescriptorStruct firmware, QString crc);
99  void FirmwareLoadedUpdate(QByteArray firmwareArray);
100  QString LoadFirmwareFileDialog(QString);
101  uploader::UploaderStatus getUploaderStatus() const;
102  void setUploaderStatus(const uploader::UploaderStatus &value);
103  void CheckAutopilotReady();
104  bool CheckInBootloaderState();
105  /* XXX TODO: make capitalization consistent */
106  void setStatusInfo(QString str, uploader::StatusIcon ic);
107  QString getImagePath(QString boardName, QString imageType = QString("fw"));
108  bool FirmwareLoadFromFile(QString filename, QByteArray *contents);
109  bool FirmwareCheckForUpdate(deviceDescriptorStruct device);
110  void triggerPartitionDownload(int index);
111  void haltOrReset(bool halting);
112  void startRescue();
113  bool tradeSettingsWithCloud(QString srcRelease, QString ancestor, bool upgrading = false,
114  QByteArray *settingsOut = NULL);
115  int isCloudReleaseAvailable(QString srcRelease);
116 
117  bool saveSettings(const QByteArray &settingsDump);
118 
119  bool askIfShouldContinue();
120  bool downloadSettings();
121  void stepChangeAndDelay(QEventLoop &loop, int delayMs,
123  void doUpgradeOperation(bool blankFC, tl_dfu::device &dev);
124  void upgradeError(QString why);
125  bool flashFirmware(QByteArray &firmwareImage);
126  bool haveSettingsPart() const;
127 
128  Ui_UploaderWidget *m_widget;
129 
130  UpgradeAssistantDialog m_dialog;
131 
132  bool telemetryConnected;
133  bool iapUpdated;
134 
135  QByteArray loadedFile;
136  QByteArray settingsDump;
137 
138  DFUObject dfu;
139  USBSignalFilter *usbFilterBL;
140  USBSignalFilter *usbFilterUP;
142  TelemetryManager *telMngr;
143  UAVObjectUtilManager *utilMngr;
144  Core::ConnectionManager *conMngr;
145  QNetworkAccessManager *netMngr;
146  UAVSettingsImportExportManager *importMngr;
147 
148  FirmwareIAPObj *firmwareIap;
149  deviceInfo currentBoard;
150  QString ignoredRev;
151 
152  uploader::UploaderStatus uploaderStatus;
153  QByteArray tempArray;
154  QTimer rescueTimer;
155  bool upgraderActive = false;
156 
157  const QString exportUrl = QString("http://dronin-autotown.appspot.com/convert");
158  const QString hasRevUrl = QString("http://dronin-autotown.appspot.com/uavos/%1");
159 };
160 }
161 #endif // UPLOADERGADGETWIDGET_H
Core plugin system that manages the plugins, their life cycle and their registered objects...
Definition: pluginmanager.h:53
function crc