-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
38 lines (36 loc) · 883 Bytes
/
api.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
var NetworkInterface = require('./lib/NetworkInterface.js');
var WifiSetting = require('./lib/WifiSetting.js');
var child_process = require('child_process');
var interface = new NetworkInterface(child_process.exec, 'wlan0');
var setting = new WifiSetting();
module.exports = {
resetWifi: function(fnCallback) {
setting.reset(function(error) {
if(error) {
return fnCallback(error);
}
interface.stop(function(error) {
fnCallback(error);
});
});
},
connectToWifi: function(oOptions, fnCallback) {
setting.write(oOptions, function(error) {
if(error) {
return fnCallback(error);
}
interface.restart(function(error) {
fnCallback(error);
});
});
},
getCurrentWifiSettings: function(fnCallback) {
setting.read(function(error, data) {
if(error) {
fnCallback(error);
} else {
fnCallback(undefined, data);
}
});
}
}