This commit is contained in:
vzakharchenko 2021-10-31 10:04:21 +02:00
parent fa3d36e4df
commit a40facd10d
3 changed files with 22 additions and 5 deletions

View File

@ -8,6 +8,7 @@
# Features
- can encrypt/decrypt huawei hilink-api
- support "device login password"
- can read and send SMS messages from the command line
- reconnect network
@ -44,8 +45,24 @@ add argument **--password="YOUR_PASSWORD"** to command line.
huawei-hilink sendSMS --phone=+11111111111 --message="Test message" --password="YOUR_PASSWORD"
```
## supported encrypt/decrypt hilink api
[Login API](https://github.com/vzakharchenko/huawei-hilink/blob/fa3d36e4df622999c674f39342bb196500208d8b/src/startSession.ts#L57):
- http://${MODEM_API}/api/webserver/token
- http://${MODEM_API}/api/user/challenge_login
- http://${MODEM_API}/api/user/authentication_login
Encrypted API:
- http://${MODEM_API}/api/sms/sms-list-phone
- http://${MODEM_API}/api/sms/sms-count-contact
- http://${MODEM_API}/api/sms/sms-count-contact
- http://${MODEM_API}/api/sms/delete-sms
- http://${MODEM_API}/api/sms/send-sms
- http://${MODEM_API}/api/sms/sms-list-contact
- http://${MODEM_API}/api/dialup/mobile-dataswitch
- http://${MODEM_API}/api/net/reconnect
example how to encrypt/decrypt API
```
```
## How to use
### Help

View File

@ -1,13 +1,13 @@
{
"name": "huawei-hilink",
"version": "1.1.1",
"version": "1.1.2",
"description": "huawei-hilink client",
"main": "index.js",
"scripts": {
"sendSMS": "node index.js sendSMS --phone=+11111111111 --message=test123 --url=192.168.89.1 --password=testPassword ",
"contacts": "node index.js contacts --url=192.168.89.1 --password=testPassword",
"getContactsCount": "node index.js contactPages --url=192.168.89.1 --exportFormat=json --password=testPassword",
"sms": "node index.js sms --phone=+380674819807 --url=192.168.89.1 --page=1 --password=testPassword",
"sms": "node index.js sms --phone=+11111111111 --url=192.168.89.1 --page=1 --password=testPassword",
"pages": "node index.js pages --phone=+11111111111 --url=192.168.89.1 --exportFormat=json --password=testPassword",
"enableData": "node index.js mobileData --mode=on --url=192.168.89.1 --password=testPassword",
"disableData": "node index.js mobileData --mode=off --url=192.168.89.1 --password=testPassword",

View File

@ -82,7 +82,7 @@ export async function getContactSMSPages(sessionData: SessionData,
const resp = await restCalls.sendDataRaw(`http://${sessionData.url}/api/sms/sms-count-contact`, 'POST', data, await getSessionHeaders(sessionData.url));
huawei.publicSession.token2 = resp.headers.__requestverificationtoken;
const json = await parser.parseStringPromise(resp.data);
let number = Math.floor(json.response.count / 21);
let number = Math.ceil(json.response.count / 21);
if (number > 0) {
number += 1;
}
@ -108,7 +108,7 @@ export async function getSMSPages(sessionData: SessionData,
Cookie: `SessionId=${sessionData.SesInfo}`,
});
const json = await parser.parseStringPromise(resp);
const number = Math.floor((json.response.LocalInbox[0] + json.response.LocalOutbox[0]) / 21) + 1;
const number = Math.ceil((json.response.LocalInbox[0] + json.response.LocalOutbox[0]) / 21);
if (exportFormat !== 'hide') {
if (exportFormat === 'xml') {
await saveFile(exportFile, resp);