This documentation treats admin user interface Home page. The module is able to retrieve 3 essential information :
- Network
- Current connection
- WLAN information
const { HuaweiWingle4G } = require('huawei-wingle-4g');
const username = 'your username on admin user interface';
const password = 'your password on admin user interface';
const huaweiWingle4G = new HuaweiWingle4G(username, password);
const home = huaweiWingle4G.getHome();
//Use home for rest of code
const network = await home.getNetwork();
Network contains theses informations :
- Signal strength
const strength = network.signal.strength;
In the following screenshot, strengh value will be 1
.
- Signal max strength
const maxStrength = network.signal.total;
In the following screenshot, max strengh value will be 5
.
- Phone operator
const phoneOperator = network.operator
In the following screenshot, phone operator value will be TELMA
.
- Network type
const networkType = network.type;
In the following screenshot, metwork type value will be 4G
.
Network type can take one of value :
2G
3G
4G
NB : An exception will be thrown if it cannot figure out it.
- Network status
const networkStatus = network.status;
Network status is an enumeration which is defined by :
// src/model/NetworkStatus.ts
enum NetworkStatus {
CONNECTING,
CONNECTED,
DISCONNECTED,
DISCONNECTING,
STATISTIC_TRAFFIC_EXCEEDED_LIMITED
}
NB : Because it is a TypeScript, after compilation each value of enum will be converted to number. So to work effectively, follow the code style below :
const { NetworkStatus } = require('huawei-wingle-4g/lib/src/model/home/NetworkStatus');
//Some code
const networkStatus = network.status;
switch (networkStatus) {
case NetworkStatus.CONNECTED:
//Do something
break;
case NetworkStatus.CONNECTING:
//Do something
break;
case NetworkStatus.DISCONNECTING:
//Do something
break;
case NetworkStatus.DISCONNECTED:
//Do something;
break;
}
In the following screenshot, network status will be equals to NetworkStatus.CONNECTED
.
const currentConnection = await home.getCurrentConnection();
Current connection contains theses informations :
- Duration
const duration = currentConnection.duration;
In the following screenshot, duration will be 5810000
ms.
NB : Duration unit is millisecond.
- Received data
const receivedData = currentConnection.received;
In the following screenshot, received data will be 28 206 694
byte.
NB : Received data unit is byte
- Sent data
const sentData = currentConnection.sent;
In the following screenshot, send data will be 5 431 623
byte.
NB : Sent data unit is byte
const wlanInformation = await home.getWlanInformation();
It contains theses information :
- WLAN status
const wlanStatus = wlanInformation.status;
Wlan status is an enumeration which is defined by :
// src/model/WlanStatus.ts
export enum WlanStatus {
ON,
OFF
};
NB : Because it is a TypeScript, after compilation each value of enum will be converted to number. So to work effectively, follow the code style below :
const { WlanStatus } = require('huawei-wingle-4g/lib/src/model/home/WlanStatus');
//Some code
const wlanStatus = wlanInformation.status;
switch (wlanStatus) {
case WlanStatus.ON:
//Do something
break;
case WlanStatus.ON:
//Do something
break;
}
In the following screenshot, wlan status will be equals to WlanStatus.ON
.
- Users count
const users = wlanInformation.users;
In the following screenshot, users count will be 0
.
It's the equivalent of clicking data mobile button.
If you want to connect data mobile :
await home.connectDataMobile();
NB : If data mobile is already connected and you attempt to connect data mobile, it skips process.
else if you want to disconnect data mobile :
await home.disconnectDataMobile();
NB : If data mobile is already disconnected and you attempt to disconnect data mobile, it skips process.