-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwifi_config.js
executable file
·44 lines (35 loc) · 1.12 KB
/
wifi_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var exec = require('child_process').exec;
var WiFiControl = require("wifi-control");
var cmd = 'echo "./data/wifi.sh" | telnet 192.168.1.1';
console.log("Connecting to ssid: " + process.argv[2]);
if (process.argv[2] == null) {
console.log("please give ssid flag:");
console.log("node wifi_config.js ssidNameHere");
} else {
WiFiControl.resetWiFi(function() {
WiFiControl.init({
debug: true,
connectionTimeout: 2000,
iface: 'wlp2s0'
});
console.log(WiFiControl.getIfaceState());
WiFiControl.scanForWiFi(function(error, response) {
if (error) console.log(error);
console.log(response);
});
var open_ap = {
ssid: process.argv[2]
};
WiFiControl.connectToAP(open_ap, function(error, response) {
if (error) {
console.log(error);
}
console.log(response);
exec(cmd, function(error, stdout, stderr) {
if (error) {
//console.log(error);
}
}, 3000);
});
});
}