add password field
This commit is contained in:
parent
2d7186c7c9
commit
db1731fde6
22
scripts/connectToWifi.sh
Normal file
22
scripts/connectToWifi.sh
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sudo ip addr flush dev wlan0
|
||||||
|
sudo killall wpa_supplicant
|
||||||
|
sudo truncate -s 0 /tmp/wifi_connection_status.txt
|
||||||
|
sudo wpa_supplicant -B -i wlan0 -f /tmp/wifi_connection_status.txt -c /etc/wpa_supplicant/wpa_supplicant.conf
|
||||||
|
|
||||||
|
declare -i i=0
|
||||||
|
declare -i timeout=10
|
||||||
|
while [ $i -le $timeout ]; do
|
||||||
|
if grep -iq 'CTRL-EVENT-CONNECTED' /tmp/wifi_connection_status.txt; then
|
||||||
|
sudo dhclient wlan0
|
||||||
|
exit 2
|
||||||
|
elif grep -iq '4-Way Handshake failed' /tmp/wifi_connection_status.txt; then
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
|
(( i++ ))
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
@ -10,7 +10,7 @@ export default class OSHandler {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static addWifi(wifi: WiFiNetwork) {
|
static addWifi(wifi: WiFiNetwork, passkey: string|null) {
|
||||||
return new Promise<WiFiNetwork>((resolve, reject) => {
|
return new Promise<WiFiNetwork>((resolve, reject) => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import {IPCHandler} from "./IPCHandler";
|
import {IPCHandler} from "./IPCHandler";
|
||||||
import {FunctionTest, WiFiNetwork} from "./IPCConstants";
|
import {FunctionTest, WiFiNetwork} from "./IPCConstants";
|
||||||
import OSHandler from "./OSHandler";
|
import OSHandler from "./OSHandler";
|
||||||
|
import WiFi from "./web/WiFi";
|
||||||
|
|
||||||
const wifiScan = require("node-wifi-scanner");
|
const wifiScan = require("node-wifi-scanner");
|
||||||
|
|
||||||
@ -28,7 +29,10 @@ export default class SmartMonopoly {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
IPCHandler("WIFI_CONNECT", (e, request, args) => {
|
IPCHandler("WIFI_CONNECT", async (e, request, args) => {
|
||||||
|
let data = request.data as {wifi: WiFiNetwork, password: string}
|
||||||
|
await OSHandler.addWifi(data.wifi, data.password);
|
||||||
|
|
||||||
|
|
||||||
return {status: false}
|
return {status: false}
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
Select, SelectChangeEvent,
|
Select, SelectChangeEvent,
|
||||||
Stack,
|
Stack,
|
||||||
|
TextField,
|
||||||
Typography
|
Typography
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
|
|
||||||
@ -163,6 +164,7 @@ export default class WiFi extends Component<{}, WiFiState> {
|
|||||||
{null}
|
{null}
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormControl sx={{mt: 2, minWidth: '5%'}}>
|
<FormControl sx={{mt: 2, minWidth: '5%'}}>
|
||||||
<Button variant="contained" disabled={this.state.scanning || this.state.status == "CONNECTING"} onClick={() => this.scanWifi()}>Aktualisieren
|
<Button variant="contained" disabled={this.state.scanning || this.state.status == "CONNECTING"} onClick={() => this.scanWifi()}>Aktualisieren
|
||||||
{this.state.scanning && (
|
{this.state.scanning && (
|
||||||
@ -178,6 +180,12 @@ export default class WiFi extends Component<{}, WiFiState> {
|
|||||||
/>
|
/>
|
||||||
)}</Button>
|
)}</Button>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
|
<FormControl sx={{m: 1, minWidth: '70%'}}>
|
||||||
|
<TextField id="password" label="Passwort" disabled={this.state.scanning} variant="outlined" />
|
||||||
|
|
||||||
|
</FormControl>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user