Index: denali.pro.user =================================================================== diff -u -re5a802bc26647388cfea4f1d46ae22570ec2dba3 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- denali.pro.user (.../denali.pro.user) (revision e5a802bc26647388cfea4f1d46ae22570ec2dba3) +++ denali.pro.user (.../denali.pro.user) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -1,6 +1,6 @@ - + EnvironmentId Index: denali.qrc =================================================================== diff -u -re5a802bc26647388cfea4f1d46ae22570ec2dba3 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- denali.qrc (.../denali.qrc) (revision e5a802bc26647388cfea4f1d46ae22570ec2dba3) +++ denali.qrc (.../denali.qrc) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -14,6 +14,7 @@ sources/gui/qml/dialogs/AlarmListDialog.qml sources/gui/qml/dialogs/Alert.qml sources/gui/qml/dialogs/VitalsEntry.qml + sources/gui/qml/dialogs/JoinNetwork.qml resources/images/Settings_gear_setting_tools-128.png Index: scripts/copy.sh =================================================================== diff -u -r4fab8841b1040c8eaa406713ff9bdc8c65b7b6ac -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- scripts/copy.sh (.../copy.sh) (revision 4fab8841b1040c8eaa406713ff9bdc8c65b7b6ac) +++ scripts/copy.sh (.../copy.sh) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -154,12 +154,22 @@ fi } +function setupWifiScripts() { + wifiScripts=$(ls wifi_*.sh) + for script in $wifiScripts + do + copyFileTo $script $1 + done +} + function main() { getIpAddress copyFileTo "autostart" $HOMEPATH copyFileTo "run.sh" $HOMEPATH copyFileTo "setup.sh" $HOMEPATH + setupWifiScripts $HOMEPATH + getDenaliPath copyFileTo $DENALIPATH/$DENALINAME $HOMEPATH Index: scripts/wifi_generate_wpa_supplicant.sh =================================================================== diff -u --- scripts/wifi_generate_wpa_supplicant.sh (revision 0) +++ scripts/wifi_generate_wpa_supplicant.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,14 @@ +#!/bin/sh +ssid=$1 +password=$2 +dest=$3 +echo "ctrl_interface=/var/run/wpa_supplicant +ctrl_interface_group=0 +update_config=1 + +network = { + ssid=\"$ssid\" + psk=\"$password\" +}" > $dest + + Index: scripts/wifi_get_auto_assigned_ip.sh =================================================================== diff -u --- scripts/wifi_get_auto_assigned_ip.sh (revision 0) +++ scripts/wifi_get_auto_assigned_ip.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,6 @@ +#!/bin/sh +iface=wlan0 +if [ $# -eq 1 ]; then + iface=$1 +fi +killall udhcpc; udhcpc -i $iface & disown Index: scripts/wifi_reset_adapter.sh =================================================================== diff -u --- scripts/wifi_reset_adapter.sh (revision 0) +++ scripts/wifi_reset_adapter.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,4 @@ +#!/bin/sh +rfkill block wifi +rfkill unblock wifi +ifconfig wlan0 up Index: scripts/wifi_reset_interface.sh =================================================================== diff -u --- scripts/wifi_reset_interface.sh (revision 0) +++ scripts/wifi_reset_interface.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,4 @@ +#!/bin/sh +iface=$1 +ifdown $iface +ifup $iface Index: scripts/wifi_scan_for_networks.sh =================================================================== diff -u --- scripts/wifi_scan_for_networks.sh (revision 0) +++ scripts/wifi_scan_for_networks.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,3 @@ +#!/bin/sh + +iwlist wlan0 scan Index: scripts/wifi_set_auto_assigned_ip.sh =================================================================== diff -u --- scripts/wifi_set_auto_assigned_ip.sh (revision 0) +++ scripts/wifi_set_auto_assigned_ip.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,5 @@ +#!/bin/sh +iface=$1 + +echo "auto $iface +iface $iface inet dhcp" >> /etc/network/interfaces Index: scripts/wifi_set_dns.sh =================================================================== diff -u --- scripts/wifi_set_dns.sh (revision 0) +++ scripts/wifi_set_dns.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,7 @@ +#!/bin/sh + +dns1=$1 +dns2=8.8.8.8 + +echo "nameserver $dns1 +nameserver $dns2" > /etc/resolv.conf Index: scripts/wifi_set_static_ip.sh =================================================================== diff -u --- scripts/wifi_set_static_ip.sh (revision 0) +++ scripts/wifi_set_static_ip.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,12 @@ +#!/bin/sh + +iface=$1 +ip=$2 +gateway=$3 +subnet_mask=$4 + +echo "auto $iface +iface $iface inet static + address $ip + netmask $subnet_mask + gateway $3" >> /etc/network/interfaces Index: scripts/wifi_start_wpa_supplicant.sh =================================================================== diff -u --- scripts/wifi_start_wpa_supplicant.sh (revision 0) +++ scripts/wifi_start_wpa_supplicant.sh (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,4 @@ +#!/bin/sh +iface=$1 +wpa_supplicant_path=$2 +killall wpa_supplicant; wpa_supplicant -i $iface -c $wpa_supplicant_path wext & disown Index: sources/gui/qml/dialogs/JoinNetwork.qml =================================================================== diff -u --- sources/gui/qml/dialogs/JoinNetwork.qml (revision 0) +++ sources/gui/qml/dialogs/JoinNetwork.qml (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -0,0 +1,97 @@ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * \copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN + * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * \file Alert.qml + * \author (last) Peter Lucia + * \date (last) 30-Nov-2020 + * \author (original) Peter Lucia + * \date (original) 30-Nov-2019 + * + */ + +// Qt +import QtQuick 2.12 + +// Project +// Qml imports +import "qrc:/globals" +import "qrc:/components" + +/*! + * \brief Contains the Vitals Entry Implementation + */ +ModalDialog { id: _root + property string ssid : "" + property string macAddress : "" + objectName: "JoinNetwork" // SquishQt testability + contentItem.objectName: "JoinNetworkContent" + modal: false + + onVisibleChanged: { + if (!visible) { + _password.textInput.focus = false + } + } + + Item { id: _titleBar + height: _root.height / 4 + width: _root.width + + Text { id: _titleBarText + color: Colors.textMain + font.pixelSize: Fonts.fontPixelTitle + text: qsTr("Join " + ssid) + anchors.centerIn: _titleBar + } + } + + TextEntry { id: _password + textInput.width: Variables.settingsWIFIInputWidth + line.width: Variables.settingsWIFIInputWidth + label.width: Variables.settingsWIFIInputWidth + anchors { + horizontalCenter: parent.horizontalCenter + top: _titleBar.bottom + topMargin: Variables.settingsWIFIMargin + } + textInput.inputMethodHints: Qt.ImhNone + textInput.echoMode: TextInput.Password + labelText: qsTr("Password: ") + onEnterPressed: { + _keyboard.setVisible(false) + textInput.focus = false + } + } + + Row { id: _buttons + spacing: Variables.buttonSpacing + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + bottomMargin: Variables.dialogMargin / 2 + } + + TouchRect { id: _confirm + objectName: "_joinNetworkConfirm" + width: _root.width / 3 + text.text: qsTr("CONFIRM") + button.onPressed: { + vNetworkModel.doJoinNetwork(macAddress, _password.textInput.text) + close() + } + } + + TouchRect { id: _cancel + objectName: "_joinNetworkCancel" + width: _root.width / 3 + text.text: qsTr("CANCEL") + button.onPressed: { + close() + } + } + } +} Index: sources/gui/qml/main.qml =================================================================== diff -u -re5a802bc26647388cfea4f1d46ae22570ec2dba3 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/gui/qml/main.qml (.../main.qml) (revision e5a802bc26647388cfea4f1d46ae22570ec2dba3) +++ sources/gui/qml/main.qml (.../main.qml) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -301,6 +301,7 @@ Alert { id: _alert } VitalsEntry { id: _vitalsEntry } + JoinNetwork { id: _joinNetwork } Keyboard { id: _keyboard } Connections { target: vPowerOff Index: sources/gui/qml/pages/SettingsBluetooth.qml =================================================================== diff -u -rdca8a36ea292270c4de986c0f0872f1ee1e5f85a -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/gui/qml/pages/SettingsBluetooth.qml (.../SettingsBluetooth.qml) (revision dca8a36ea292270c4de986c0f0872f1ee1e5f85a) +++ sources/gui/qml/pages/SettingsBluetooth.qml (.../SettingsBluetooth.qml) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -55,8 +55,14 @@ height: Variables.settingsBLEButtonHeight width: Variables.settingsBLEButtonWidth text.text: qsTr("Scan for devices") - animated: true - onClicked: vBluetooth.doScanForDevices() + animated: false + onClicked: { + if (!vBluetooth.scanInProgress) { + vBluetooth.doScanForDevices() + } + } + backgroundColor: vBluetooth.scanInProgress ? Colors.backgroundButtonNormal : Colors.backgroundButtonSelect + textColor: vBluetooth.scanInProgress ? "grey" : Colors.textMain } Rectangle { id: _status @@ -68,7 +74,7 @@ width: Variables.settingsBLEButtonWidth Text { id: _status_text anchors.leftMargin: 10 - text: qsTr("Status: " + vBluetooth.status) + text: qsTr(vBluetooth.status) color: Colors.textMain font.pixelSize: Fonts.fontPixelDialogText wrapMode: Text.WordWrap Index: sources/gui/qml/pages/SettingsWifi.qml =================================================================== diff -u -rea52cee2614f319804690a9b1d5091bed9676753 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/gui/qml/pages/SettingsWifi.qml (.../SettingsWifi.qml) (revision ea52cee2614f319804690a9b1d5091bed9676753) +++ sources/gui/qml/pages/SettingsWifi.qml (.../SettingsWifi.qml) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -152,9 +152,12 @@ height : 25 color: "transparent" imageSource : "" - text : "STATUS PLACEHOLDER" + text : vNetworkModel.status textColor: Colors.textMain textfontSize: Fonts.fontPixelTextRectExtra + anchors { + top: parent.bottom + } } ListView { id: _pairedDevices @@ -200,7 +203,16 @@ } onClicked: { - console.debug("Clicked " + ssid); + console.debug("Clicked " + ssid + " with macAddress: " + macAddress); + if (vNetworkModel.doCheckIfConnected(macAddress)) { + // TODO: show alert to confirm disconnect + } else { + // initiate connection to this network, as for password + _joinNetwork.ssid = ssid + _joinNetwork.macAddress = macAddress + _joinNetwork.visible = true + } + } } } Index: sources/storage/StorageGlobals.cpp =================================================================== diff -u -rea52cee2614f319804690a9b1d5091bed9676753 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision ea52cee2614f319804690a9b1d5091bed9676753) +++ sources/storage/StorageGlobals.cpp (.../StorageGlobals.cpp) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -39,6 +39,9 @@ const char *Treatment_Profiles_Dir = "/media/sd-card/treatment/profiles/"; const char *Treatment_Parameter_Ranges_Path_JSON = "/media/sd-card/treatment/denali.conf"; + // SDCard + const char *SDCard_Base_Path_Name = "/media/sd-card/"; + // Bluetooth #ifdef BUILD_FOR_DESKTOP const char *Bluetooth_Saved_Devices_Path_JSON = "/home/denali/Projects/application/settings/bledevices.conf"; @@ -52,7 +55,14 @@ #elif BUILD_FOR_TARGET const char *Wifi_Scripts_Dir = "/home/root/"; #endif - const char *Wifi_Scripts_Scan_For_Networks = "scanForNetworks.sh"; + const char *Wifi_Generate_WPA_Supplicant = "wifi_generate_wpa_supplicant.sh"; + const char *Wifi_Get_Auto_Assigned_IP = "wifi_get_auto_assigned_ip.sh"; + const char *Wifi_Reset_Adapter = "wifi_reset_adapter.sh"; + const char *Wifi_Reset_Interface = "wifi_reset_interface.sh"; + const char *Wifi_Scan_For_Networks = "wifi_scan_for_networks.sh"; + const char *Wifi_Set_Auto_Assigned_IP = "wifi_set_auto_assigned_ip.sh"; + const char *Wifi_Set_DNS = "wifi_set_dns.sh"; + const char *Wifi_Set_Static_IP = "wifi_set_static_ip.sh"; + const char *Wifi_Start_WPA_Supplicant = "wifi_start_wpa_supplicant.sh"; - const char *SDCard_Base_Path_Name = "/media/sd-card/"; } Index: sources/storage/StorageGlobals.h =================================================================== diff -u -re5a802bc26647388cfea4f1d46ae22570ec2dba3 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision e5a802bc26647388cfea4f1d46ae22570ec2dba3) +++ sources/storage/StorageGlobals.h (.../StorageGlobals.h) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -32,12 +32,22 @@ extern const char *Treatment_Base_Dir; extern const char *Treatment_Profiles_Dir; extern const char *Treatment_Parameter_Ranges_Path_JSON; + + // SDCard extern const char *SDCard_Base_Path_Name; // Bluetooth extern const char *Bluetooth_Saved_Devices_Path_JSON; // Wifi extern const char *Wifi_Scripts_Dir; - extern const char *Wifi_Scripts_Scan_For_Networks; + extern const char *Wifi_Generate_WPA_Supplicant; + extern const char *Wifi_Get_Auto_Assigned_IP; + extern const char *Wifi_Reset_Adapter; + extern const char *Wifi_Reset_Interface; + extern const char *Wifi_Scan_For_Networks; + extern const char *Wifi_Set_Auto_Assigned_IP; + extern const char *Wifi_Set_DNS; + extern const char *Wifi_Set_Static_IP; + extern const char *Wifi_Start_WPA_Supplicant; } Index: sources/view/VBluetooth.cpp =================================================================== diff -u -r5215e145a0f26a20c99e3f10af6ac8a9c3b67383 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/view/VBluetooth.cpp (.../VBluetooth.cpp) (revision 5215e145a0f26a20c99e3f10af6ac8a9c3b67383) +++ sources/view/VBluetooth.cpp (.../VBluetooth.cpp) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -66,6 +66,7 @@ void VBluetooth::doScanForDevices() { notifyStatusUpdate(tr("Scanning...")); + scanInProgress(true); _unpairedDevices.clear(); emit didDevicesChanged(); emit didRequestScanForDevices(); @@ -79,6 +80,7 @@ */ void VBluetooth::onScanForDevicesError(QBluetoothDeviceDiscoveryAgent::Error error) { + scanInProgress(false); switch (error) { case QBluetoothDeviceDiscoveryAgent::PoweredOffError: notifyStatusUpdate(tr("Error: Bluetooth module is powered off.")); @@ -109,6 +111,7 @@ */ void VBluetooth::onScanForDevicesFinished() { + scanInProgress(false); emit didScanFinished(); notifyStatusUpdate(tr("Scan Finished.")); } @@ -336,6 +339,8 @@ */ void VBluetooth::onLoadAndConnectToLastSelectedDevice(const QJsonObject &obj) { + // TODO: Use QSettings instead of QJsonObject + // TODO: Use QSettings::IniFormat and don't set the path so it is loaded from the application folder if (obj.keys().contains(_lastSelectedDeviceAddrKey)) { QJsonObject lastSelectDeviceObj = obj.value(_lastSelectedDeviceAddrKey).toObject(); if (!lastSelectDeviceObj.isEmpty()) { @@ -356,6 +361,8 @@ */ void VBluetooth::onLoadMyDevices(const QString &path) { + // TODO: Use QSettings instead of QJsonObject + // TODO: Use QSettings::IniFormat and don't set the path so it is loaded from the application folder _pairedDevices.clear(); QJsonObject obj; if (!FileHandler::read(path, obj)) Index: sources/view/VBluetooth.h =================================================================== diff -u -rfaa306f41ddc70a48d042cc265396ef32116ad97 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/view/VBluetooth.h (.../VBluetooth.h) (revision faa306f41ddc70a48d042cc265396ef32116ad97) +++ sources/view/VBluetooth.h (.../VBluetooth.h) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -37,6 +37,8 @@ Q_PROPERTY(QVariant pairedDevices READ doGetPairedDevices NOTIFY didPairedDevicesChanged) Q_PROPERTY(QVariant status READ getStatus NOTIFY didStatusChanged) + PROPERTY(bool, scanInProgress, false) + public slots: void doScanForDevices(); QVariant doGetDevices(); Index: sources/view/VNetworkModel.cpp =================================================================== diff -u -rea52cee2614f319804690a9b1d5091bed9676753 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/view/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision ea52cee2614f319804690a9b1d5091bed9676753) +++ sources/view/VNetworkModel.cpp (.../VNetworkModel.cpp) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -14,14 +14,21 @@ */ void VNetworkModel::initConnections() { - connect(this, SIGNAL(didScan()), - &_WifiInterface, SLOT(doScan())); - + // incoming connect(&_WifiInterface, SIGNAL(didAddNetwork(const Network)), this, SLOT(doAddNetwork(const Network))); connect(&_WifiInterface, SIGNAL(didScanStatusChanged(const bool)), this, SLOT(onScanStatusChanged(const bool))); + + // outgoing + connect(this, SIGNAL(didScan()), + &_WifiInterface, SLOT(doScan())); + + // outgoing + connect(this, SIGNAL(didJoinNetwork(const Network, const QString)), + &_WifiInterface, SLOT(doJoinNetwork(const Network, const QString))); + } /*! @@ -61,13 +68,21 @@ return QVariant(); const Network &network = _networks[index.row()]; - if (role == SSIDRole) - return network.ssid(); - else if (role == SecurityLevelRole) - return network.security(); - else if (role == StatusRole) - return network.status(); + switch (role) + { + case MacAddressRole: + return network.macAddress(); + case SSIDRole: + return network.ssid(); + case SecurityLevelRole: + return network.security(); + case StatusRole: + return network.status(); + case SignalLevelRole: + return network.signalLevel(); + } + return QVariant(); } @@ -78,9 +93,11 @@ */ QHash VNetworkModel::roleNames() const { QHash roles; + roles[MacAddressRole] = "macAddress"; roles[SSIDRole] = "ssid"; roles[SecurityLevelRole] = "securityLevel"; roles[StatusRole] = "status"; + roles[SignalLevelRole] = "signalLevel"; return roles; } @@ -89,6 +106,7 @@ * Handles when a user clicks the Scan button */ void VNetworkModel::doScan() { + status(tr("Scanning...")); emit didScan(); } @@ -118,5 +136,42 @@ */ void VNetworkModel::onScanStatusChanged(const bool &vScanning) { + if (!vScanning) + status(tr("Scan Finished")); + scanInProgress(vScanning); } + +/*! + * \brief VNetworkModel::doCheckIfConnected + * Checks whether the network specified by the mac address is connected or not + * \param vMacAddress - (QString) the unique mac address for the network + */ +bool VNetworkModel::doCheckIfConnected(const QString &vMacAddress) +{ + for (const Network &network : _networks) + { + if (network.macAddress() == vMacAddress && network.status() == Network::CONNECTED) + return true; + } + return false; +} + +/*! + * \brief VNetworkModel::doJoinNetwork + * Handles request from qml to join a network + * \param vMacAddress - (QString) the mac address of the network to join + * \param vPassword - (QString) the password for the network provided by the user + */ +void VNetworkModel::doJoinNetwork(const QString &vMacAddress, const QString &vPassword) +{ + for (const Network &network : _networks) + { + if (network.macAddress() == vMacAddress) + { + status(tr("Connecting to %1...").arg(network.ssid())); + emit didJoinNetwork(network, vPassword); + return; + } + } +} Index: sources/view/VNetworkModel.h =================================================================== diff -u -rea52cee2614f319804690a9b1d5091bed9676753 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/view/VNetworkModel.h (.../VNetworkModel.h) (revision ea52cee2614f319804690a9b1d5091bed9676753) +++ sources/view/VNetworkModel.h (.../VNetworkModel.h) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -26,28 +26,34 @@ { Q_OBJECT - PROPERTY(bool, scanInProgress, false) + PROPERTY(bool , scanInProgress, false) + PROPERTY(QString, status , "") public: // Note: VIEW_DEC_CLASS(VNetworkModel) requires QObject as the parent, so it's necessary to define it here // Otherwise a VIEW_DEC_CLASS macro could allow specifying the parent class with QObject as the default VNetworkModel(QAbstractListModel *parent = nullptr) : QAbstractListModel(parent) { initConnections(); } enum NetworkDataRole { - SSIDRole = Qt::UserRole + 1, + MacAddressRole = Qt::UserRole + 1, + SSIDRole, SecurityLevelRole, StatusRole, + SignalLevelRole, }; void addNetwork (const Network &network); int rowCount (const QModelIndex &parent = QModelIndex()) const; QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const; signals: void didScan(); + void didJoinNetwork(const Network, const QString); public slots: void doScan(); void doAddNetwork(const Network &vNetwork); + bool doCheckIfConnected(const QString &vMacAddress); + void doJoinNetwork(const QString &vMacAddress, const QString &vPassword); protected: QHash roleNames() const; Index: sources/wifi/WifiInterface.cpp =================================================================== diff -u -rea52cee2614f319804690a9b1d5091bed9676753 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision ea52cee2614f319804690a9b1d5091bed9676753) +++ sources/wifi/WifiInterface.cpp (.../WifiInterface.cpp) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -91,7 +91,7 @@ _scanProcess.setWorkingDirectory(Wifi_Scripts_Dir); _scanRunning = true; emit didScanStatusChanged(_scanRunning); - _scanProcess.start(Wifi_Scripts_Scan_For_Networks); + _scanProcess.start(Wifi_Scan_For_Networks); } @@ -156,3 +156,23 @@ } } } + +/*! + * \brief WifiInterface::doJoinNetwork + * Handles request to join a network + * \param vMacAddress - (QString) the mac address of the network to join + * \param vPassword - (QString) the password for the network provided by the user + */ +void WifiInterface::doJoinNetwork(const Network &vNetwork, const QString &vPassword) +{ + + _wifiInterfaceProcess.start(Wifi_Generate_WPA_Supplicant, + QStringList() << vNetwork.ssid() + << vPassword + << _wpaSupplicantConfPath); + + _wifiInterfaceProcess.start(Wifi_Start_WPA_Supplicant, + QStringList() << _iface + << _wpaSupplicantConfPath); + +} Index: sources/wifi/WifiInterface.h =================================================================== diff -u -rea52cee2614f319804690a9b1d5091bed9676753 -r5600d2133dd0ea6dc1f733aa78bd26e2a4892a38 --- sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision ea52cee2614f319804690a9b1d5091bed9676753) +++ sources/wifi/WifiInterface.h (.../WifiInterface.h) (revision 5600d2133dd0ea6dc1f733aa78bd26e2a4892a38) @@ -27,8 +27,12 @@ bool _init = false; bool _scanRunning = false; QProcess _scanProcess; + QProcess _wifiInterfaceProcess; + const QString _iface = "wlan0"; + const QString _wpaSupplicantConfPath = "/etc/wpa_supplicant.conf"; + // Singleton SINGLETON(WifiInterface) @@ -40,6 +44,7 @@ public slots: bool doInit(); void doScan(); + void doJoinNetwork(const Network &vNetwork, const QString &vPassword); signals: void didAddNetwork(const Network);