Skip to content

Commit

Permalink
WiFiSetup: add check for default network
Browse files Browse the repository at this point in the history
  • Loading branch information
vldpro authored and AlexeyBulatov committed Mar 30, 2018
1 parent af2962b commit 8291827
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/AutoPilotPlugins/Common/WiFiSetupComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down
6 changes: 6 additions & 0 deletions src/AutoPilotPlugins/Common/WiFiSetupComponentController.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/AutoPilotPlugins/Common/WiFiSetupComponentController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 8291827

Please sign in to comment.