From 82918277a8d21b0b8874281aa4c52a054dfea636 Mon Sep 17 00:00:00 2001 From: Vladimir ProvaLove Date: Thu, 29 Mar 2018 21:32:22 +0300 Subject: [PATCH] WiFiSetup: add check for default network --- src/AutoPilotPlugins/Common/WiFiSetupComponent.qml | 5 +++-- src/AutoPilotPlugins/Common/WiFiSetupComponentController.cc | 6 ++++++ src/AutoPilotPlugins/Common/WiFiSetupComponentController.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/AutoPilotPlugins/Common/WiFiSetupComponent.qml b/src/AutoPilotPlugins/Common/WiFiSetupComponent.qml index ae0d762be2c..e99d3709d30 100644 --- a/src/AutoPilotPlugins/Common/WiFiSetupComponent.qml +++ b/src/AutoPilotPlugins/Common/WiFiSetupComponent.qml @@ -160,7 +160,8 @@ SetupPage { onClicked: { if (checked) { controller.bootAsAccessPoint() - } else if (controller.defaultNetwork.length > 0) { + } else if (controller.defaultNetwork.length > 0 + && controller.savedNetworksContains(controller.defaultNetwork)) { controller.bootAsClient(controller.defaultNetwork) } else { switchWarnDialog.visible = true @@ -189,7 +190,7 @@ SetupPage { icon: StandardIcon.Warning standardButtons: StandardButton.Ok title: qsTr("Connect to Network") - text: qsTr("Can not connect to default network.Default network is unspecified.") + text: qsTr("Can not connect to default network. Default network is unspecified.") onAccepted: { visible = false } diff --git a/src/AutoPilotPlugins/Common/WiFiSetupComponentController.cc b/src/AutoPilotPlugins/Common/WiFiSetupComponentController.cc index 5ff4f6233f0..fec0476b4dd 100644 --- a/src/AutoPilotPlugins/Common/WiFiSetupComponentController.cc +++ b/src/AutoPilotPlugins/Common/WiFiSetupComponentController.cc @@ -162,6 +162,12 @@ WiFiSetupComponentController::WiFiSetupComponentController() } +bool WiFiSetupComponentController::savedNetworksContains(QString netwk) +{ + return _savedNetworks.contains(netwk); +} + + void WiFiSetupComponentController::bootAsAccessPoint() { _vehicle->sendMavCommand(MAV_COMP_ID_WIFI, MAV_CMD_WIFI_START_AP, true, 1); diff --git a/src/AutoPilotPlugins/Common/WiFiSetupComponentController.h b/src/AutoPilotPlugins/Common/WiFiSetupComponentController.h index 28ad62079c4..947224623f4 100644 --- a/src/AutoPilotPlugins/Common/WiFiSetupComponentController.h +++ b/src/AutoPilotPlugins/Common/WiFiSetupComponentController.h @@ -79,6 +79,8 @@ class WiFiSetupComponentController : public FactPanelController Q_PROPERTY(WifiNetworksListModel* scannedNetworks READ scannedNetworks NOTIFY scannedNetworksUpdated) + Q_INVOKABLE bool savedNetworksContains(QString netwk); + Q_INVOKABLE void bootAsAccessPoint (void); Q_INVOKABLE void bootAsClient (QString const& netwkName);