2016-04-21 15:32:11 +02:00
|
|
|
import * as rest from '../rest.js';
|
2015-07-15 15:06:18 +02:00
|
|
|
|
|
|
|
export default class {
|
2015-07-24 13:15:00 +02:00
|
|
|
constructor (api) {
|
|
|
|
this.api = api;
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
scan () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.get(`${ this.api }network/scan`);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
known () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.get(`${ this.api }network/known`);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
status () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.get(`${ this.api }network/status`);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-10-12 12:33:33 +02:00
|
|
|
assosiate (ssid, phrase, recreate = false) {
|
2016-04-16 18:05:15 +02:00
|
|
|
const data = { ssid, recreate, phrase };
|
2015-07-23 19:12:50 +02:00
|
|
|
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.post(`${ this.api }network/associate`, data);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-10-12 13:06:20 +02:00
|
|
|
disassociate () {
|
2015-07-15 15:06:18 +02:00
|
|
|
//not tested
|
|
|
|
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.post(`${ this.api }network/disassociate`, {});
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
openAccesPoint () {
|
2015-07-15 15:06:18 +02:00
|
|
|
//not tested
|
|
|
|
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.post(`${ this.api }network/openap`, {});
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
remove (ssid) {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.post(`${ this.api }network/remove`, {
|
2015-07-15 15:06:18 +02:00
|
|
|
'ssid': ssid
|
2015-07-23 19:12:50 +02:00
|
|
|
});
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 19:12:50 +02:00
|
|
|
signin () {
|
2016-04-21 15:09:49 +02:00
|
|
|
return rest.get(`${ this.api }network/signin`);
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
|
|
|
|
2016-04-16 18:05:35 +02:00
|
|
|
async alive () {
|
|
|
|
try {
|
2016-04-21 15:09:49 +02:00
|
|
|
await rest.get(`${ this.api }network/alive`);
|
2016-04-16 18:05:35 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch(error) {
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-15 15:06:18 +02:00
|
|
|
}
|
2015-10-12 12:33:33 +02:00
|
|
|
}
|