Community discussions

MikroTik App
 
dakobg
Member Candidate
Member Candidate
Topic Author
Posts: 120
Joined: Mon Nov 06, 2017 8:58 am

Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Sep 27, 2020 10:23 pm

Hi,

This script will send SMS via Huawei USB lte modem API with tool/fetch (tested with E3372)
I hope can be helpful :)

github: https://github.com/NikolayDachev/Router ... endSMS.txt
:global sendSMS do={
	# Send SMS messages via Huawei LTE modem API (tested with  E3372)
	# global vars:
	# 	lteIP - lte modem ip address (api)
	# 	phone - sms destination phone number
	#	sms - sms text message
	# usage example
	#	:global sendSMS
	#	:put [$sendSMS lteIP="192.168.8.1" phone="+35912345678" sms="test sms via lte api"]
	#

	:local getBetween do={
		# "CuriousKiwi - mikrotik forum" 
		# This is a basic parser, can be used for XML
		# It takes three parameters:
		# inputString - The main string
		# betweenStart - Text AFTER this point will be returned
		# betweenEnd - Text BEFORE this point will be returned
		:local posStart 0;
		:if ([:len $betweenStart] > 0) do={
		:set posStart [:find $inputString $betweenStart]
			:if ([:len $posStart] = 0) do={
				:set posStart 0
			} else={
				:set posStart ($posStart + [:len $betweenStart])
			}
		}

		:local posEnd 9999;
		:if ([:len $betweenEnd] > 0) do={
		:set posEnd [:find $inputString $betweenEnd];
		:if ([:len $posEnd] = 0) do={ :set posEnd 9999 }
		}

		:local result [:pick $inputString $posStart $posEnd];
		:return $result;
	}

	# get SessionID and Token via LTE modem API
	:local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo";
	:local api [/tool fetch $urlSesTokInfo output=user as-value]; 
	:local apiData  ($api->"data");

	# pars SessionID and Token from API session data 
	:local apiSessionID [$getBetween inputString=$apiData betweenStart="<SesInfo>" betweenEnd="</SesInfo>"];
	:local apiToken [$getBetween inputString=$apiData betweenStart="<TokInfo>" betweenEnd="</TokInfo>"];

	# header and data config
	:local apiHead "Content-Type:application/x-www-form-urlencoded,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken";
	:local sendData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$sms</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>";

	# send SMS via LTE modem API with fetch
	/tool fetch  http-method=post output=user  \
	http-header-field=$apiHead \
	url="http://$lteIP/api/sms/send-sms" \
	http-data=$sendData;
}
 
creatin
Member Candidate
Member Candidate
Posts: 108
Joined: Sat Nov 23, 2019 2:59 am

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Sep 28, 2020 12:48 am

Will try it with B715 next year :)
 
gustavganzz
just joined
Posts: 1
Joined: Thu Dec 09, 2021 7:15 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Dec 09, 2021 8:45 pm

Works great! Do you also have a script for receiving SMS ?
 
dakobg
Member Candidate
Member Candidate
Topic Author
Posts: 120
Joined: Mon Nov 06, 2017 8:58 am

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Dec 12, 2021 1:33 am

No I do not need such script, but I think will be somtihing similar.

Probably you need to read for new sms recv on lte and do something on routeros, just if you try to do that be sure to have additionally check for sender phone number aka to lock it to single number .. I think there is no need to explain why .,,,😀
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sat Oct 22, 2022 9:13 pm

Hi.
I'm starting to deal with scripts. Can't figure out what I need to change (uncomment) to make it work?
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sat Oct 22, 2022 11:08 pm

Hi.
I'm starting to deal with scripts. Can't figure out what I need to change (uncomment) to make it work?
Found solution in another author's script 8)
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sat Oct 22, 2022 11:25 pm

Could someone handle script to read SMS from LTE modem?
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Oct 23, 2022 1:57 pm

I've tested bash script to get SMS xml content:
#!/bin/bash

DATA=`curl http://192.168.8.1/api/webserver/SesTokInfo`
SESSION_ID=`echo "$DATA" | grep "SessionID=" | cut -b 10-147`
TOKEN=`echo "$DATA" | grep "TokInfo" | cut -b 10-41`

curl http://192.168.8.1/api/sms/sms-list -H "Cookie: $SESSION_ID" -H "__RequestVerificationToken: $TOKEN" --data \
"<?xml version='1.0' encoding='UTF-8'?> \
<request> \
<PageIndex>1</PageIndex> \
<ReadCount>20</ReadCount> \
<BoxType>1</BoxType> \
<SortType>0</SortType> \
<Ascending>0</Ascending> \
<UnreadPreferred>0</UnreadPreferred> \
</request>"
Result:
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   277  100   277    0     0   3186      0 --:--:-- --:--:-- --:--:--  3220
<?xml version="1.0" encoding="utf-8"?>
<response>
        <Count>1</Count>
        <Messages>
                <Message>
                        <Smstat>1</Smstat>
                        <Index>40002</Index>
                        <Phone>lifecell</Phone>
                        <Content>SMS TEXT.... </Content>
                        <Date>2022-10-18 22:02:41</Date>
                        <Sca></Sca>
                        <SaveType>4</SaveType>
                        <Priority>0</Priority>
                        <SmsType>2</SmsType>
                </Message>
        </Messages>
</response>
And trying to reproduce the same in mikrotik terminal:
:global recvSMS do={

:local getBetween do={
	# This is a basic parser, can be used for XML
	# It takes three parameters:
	# inputString - The main string
	# betweenStart - Text AFTER this point will be returned
	# betweenEnd - Text BEFORE this point will be returned
	:local posStart 0;
	:if ([:len $betweenStart] > 0) do={
	:set posStart [:find $inputString $betweenStart]
		:if ([:len $posStart] = 0) do={
			:set posStart 0
		} else={
			:set posStart ($posStart + [:len $betweenStart])
		}
	}

	:local posEnd 9999;
	:if ([:len $betweenEnd] > 0) do={
	:set posEnd [:find $inputString $betweenEnd];
	:if ([:len $posEnd] = 0) do={ :set posEnd 9999 }
	}

	:local result [:pick $inputString $posStart $posEnd];
	:return $result;
}

# get SessionID and Token via LTE modem API
:local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo";
:local api [/tool fetch $urlSesTokInfo output=user as-value]; 
:local apiData  ($api->"data");

:local lteIP "192.168.8.1";

# pars SessionID and Token from API session data 
:local apiSessionID [$getBetween inputString=$apiData betweenStart="<SesInfo>" betweenEnd="</SesInfo>"];
:local apiToken [$getBetween inputString=$apiData betweenStart="<TokInfo>" betweenEnd="</TokInfo>"];

# header and data config
:local apiHead "Content-Type:application/x-www-form-urlencoded,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken";
:local recvData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>0</UnreadPreferred></request>";

# recv SMS via LTE modem API with fetch
/tool fetch  http-method=post output=user  \
http-header-field=$apiHead \
url="http://$lteIP/api/sms/sms-list" \
http-data=$recvData;
}

:local arrData [ :toarray $recvSMS ];
:local varData ( $arrData->"data" );
:put [ $varData ];
And getting nothing:
[admin@gateway] > system/script/run recvSMS1

[admin@gateway] > 
What I missed ?
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Oct 23, 2022 3:17 pm

also tried
# recv SMS via LTE modem API with fetch
:put ([/tool fetch  http-method=post output=user \
http-header-field=$apiHead \
url="http://$lteIP/api/sms/sms-list" \
http-data=$recvData as-value]->"data");
}
and delete bottom block, still display nothing
Last edited by notanial on Sun Oct 23, 2022 9:57 pm, edited 2 times in total.
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Oct 23, 2022 7:37 pm

works with addiing new line at the end after last bracket
[$recvSMS lteIP="192.168.8.1"];
Now I want to write output to file for futher parse to separate message content and use it as script name run command
Last edited by notanial on Sun Oct 23, 2022 9:02 pm, edited 1 time in total.
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Oct 23, 2022 8:00 pm

By adding new script:
{
:local a [/system script get recvSMS1 source]
:local outFile "recvSMS1.xml"
execute script=$a file=$outFile
}
I got file recvSMS1.xml.txt with wanted content like in bash script

Could someone help me do script to parse xml to get text inside <Content>wol_pc</Content> and put in command /script/run/ wol_pc (script with name "wol_pc" already exists)
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Oct 23, 2022 9:08 pm

Third script:
:local getBetween do={
	:local posStart 0;
	:if ([:len $betweenStart] > 0) do={
	:set posStart [:find $inputString $betweenStart]
		:if ([:len $posStart] = 0) do={
			:set posStart 0
		} else={
			:set posStart ($posStart + [:len $betweenStart])
		}
	}

	:local posEnd 9999;
	:if ([:len $betweenEnd] > 0) do={
	:set posEnd [:find $inputString $betweenEnd];
	:if ([:len $posEnd] = 0) do={ :set posEnd 9999 }
	}

	:local result [:pick $inputString $posStart $posEnd];
	:return $result;
}

:local statusXML [/file get recvSMS1.xml.txt contents];

:if ([:len $statusXML] > 50) do={
	:local script ([$getBetween inputString=$statusXML betweenStart="<Content>" betweenEnd="</Content>"]);
	
	system/script/run $script
}
but it get only last message because I set in recvData parametr:
<ReadCount>1</ReadCount>
I dont know how to parse all messages in xml
 
notanial
just joined
Posts: 11
Joined: Tue Aug 04, 2015 3:04 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Oct 23, 2022 9:26 pm

Would be great to implement additionally to parse all file and check for sender phone number and parse only his <Message> content <Message> with <Date><Date> that no older system time than 1 minute that equal scheduler time of script execution
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Dec 22, 2022 12:10 pm

Hi all,

I have a Huawei B311s-220 router compatible with the API to fully manage it. I have tested it on Linux Debian with Python+Pip according to info circulating on the internet and I get a lot of information.

So, my idea is to use that router/modem as a WAN backup connection (failover type) and also use the API functionality to be able to read and send SMS by other means (Telegram, WhatsApp or Email).

In this post I am not very clear on how to use it, since I need to first receive the SMS (checking by scheduler) and then forward them by another way. And if it is possible, to send them also from my Mikrotik router.

@notanial, have you solved the script to analyze the received SMS?


Has anyone experimented with this issue?

Thanks.
BR.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Dec 22, 2022 1:28 pm

I have tried sending SMS and it does not work:

Image

BR.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Dec 25, 2022 8:25 pm

I confirm. I have the same script error.

Modem Huawei E3372 Hlink
software version: 22.333.01.00.00
WEB interface version: 17.100.13.112.03 (17.100.13.01.03_Mod 1.12)
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Dec 25, 2022 9:10 pm

Analyzing the code:

{
:local getBetween do={
	# This is a basic parser, can be used for XML
	# It takes three parameters:
	# inputString - The main string
	# betweenStart - Text AFTER this point will be returned
	# betweenEnd - Text BEFORE this point will be returned
	:local posStart 0;
	:if ([:len $betweenStart] > 0) do={
	:set posStart [:find $inputString $betweenStart]
		:if ([:len $posStart] = 0) do={
			:set posStart 0
		} else={
			:set posStart ($posStart + [:len $betweenStart])
		}
	}

	:local posEnd 9999;
	:if ([:len $betweenEnd] > 0) do={
	:set posEnd [:find $inputString $betweenEnd];
	:if ([:len $posEnd] = 0) do={ :set posEnd 9999 }
	}

	:local result [:pick $inputString $posStart $posEnd];
	:return $result;
}

:local lteIP "192.168.8.1";

# get SessionID and Token via LTE modem API
:local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo";
:local api [/tool fetch $urlSesTokInfo output=user as-value]; 
:local apiData  ($api->"data");

# pars SessionID and Token from API session data 
:local apiSessionID [$getBetween inputString=$apiData betweenStart="<SesInfo>" betweenEnd="</SesInfo>"];
:local apiToken [$getBetween inputString=$apiData betweenStart="<TokInfo>" betweenEnd="</TokInfo>"];

:put $apiSessionID
:put " "
:put $apiToken
}

# Result:
4pO9ltivvOQXURfVlfVrHL8hUJ06Z5UBMnYNHNXXXXXXXXXXXXXXXXXXXXXXXXXvA8PerIyT0rJDBUpYtghj9BFjWVuAA7fE0N2IePPjD76Nef0zcCDLVU

aJCem0vXXXXXXXXXXXXXFJcjDiij
So far so good, it extracts Session and Token correctly.

The problem comes when it tries to validate with those data introduced in the http headers (following code), something happens that does not start the session correctly and returns the error 100003.

# header and data config
:local apiHead "Content-Type:application/x-www-form-urlencoded,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken";
:local sendData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$sms</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>";

# send SMS via LTE modem API with fetch
/tool fetch  http-method=post output=user  \
http-header-field=$apiHead \
url="http://$lteIP/api/sms/send-sms" \
http-data=$sendData;

Let's see if anyone has had this experience with Huawei LTE/4G modems.

BR.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Jan 11, 2023 7:13 pm

Well, I have already received my Huawei E3372h-320 modem that incorporates an API that allows to manage some functions of the modem.

I have tested the following script and it works correctly:

:global sendSMS do={
	# Send SMS messages via Huawei LTE modem API (tested with  E3372)
	# global vars:
	# 	lteIP - lte modem ip address (api)
	# 	phone - sms destination phone number
	#	sms - sms text message
	# usage example
	#	:global sendSMS
	#	:put [$sendSMS lteIP="192.168.8.1" phone="+35912345678" sms="test sms via lte api"]
	#

	:local getBetween do={
		# "CuriousKiwi - mikrotik forum" 
		# This is a basic parser, can be used for XML
		# It takes three parameters:
		# inputString - The main string
		# betweenStart - Text AFTER this point will be returned
		# betweenEnd - Text BEFORE this point will be returned
		:local posStart 0;
		:if ([:len $betweenStart] > 0) do={
		:set posStart [:find $inputString $betweenStart]
			:if ([:len $posStart] = 0) do={
				:set posStart 0
			} else={
				:set posStart ($posStart + [:len $betweenStart])
			}
		}

		:local posEnd 9999;
		:if ([:len $betweenEnd] > 0) do={
		:set posEnd [:find $inputString $betweenEnd];
		:if ([:len $posEnd] = 0) do={ :set posEnd 9999 }
		}

		:local result [:pick $inputString $posStart $posEnd];
		:return $result;
	}

	:local lteIP "192.168.8.1"

	# get SessionID and Token via LTE modem API
	:local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo";
	:local api [/tool fetch $urlSesTokInfo output=user as-value]; 
	:local apiData  ($api->"data");

	# pars SessionID and Token from API session data 
	:local apiSessionID [$getBetween inputString=$apiData betweenStart="<SesInfo>" betweenEnd="</SesInfo>"];
	:local apiToken [$getBetween inputString=$apiData betweenStart="<TokInfo>" betweenEnd="</TokInfo>"];

	# header and data config
	:local apiHead "Content-Type:application/x-www-form-urlencoded,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken";
	:local sendData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$sms</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>";

	# send SMS via LTE modem API with fetch
	/tool fetch  http-method=post output=user  \
	http-header-field=$apiHead \
	url="http://$lteIP/api/sms/send-sms" \
	http-data=$sendData;
}

To use it, I type from Terminal the following command:

:put [$sendSMS lteIP="192.168.8.1" phone="+35912345678" sms="test sms via lte api"]

All correct, it sends the SMS without errors.

Now, like my colleague @notanial I am trying to figure out how I can get the list of received SMS and be able to forward them by email or save them in a file.

Using this script:

:global recvSMS do={

	:local lteIP "192.168.8.1"
	:local getBetween do={

		:local posStart 0;
		:if ([:len $betweenStart] > 0) do={
			:set posStart [:find $inputString $betweenStart]
			:if ([:len $posStart] = 0) do={
				:set posStart 0
			} else={
				:set posStart ($posStart + [:len $betweenStart])
			}
		}

		:local posEnd 9999;
		:if ([:len $betweenEnd] > 0) do={
			:set posEnd [:find $inputString $betweenEnd]
			:if ([:len $posEnd] = 0) do={ :set posEnd 9999 }
		}

		:local result [:pick $inputString $posStart $posEnd]
		:return $result
	}

	# get SessionID and Token via LTE modem API
	:local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
	:local api [/tool fetch $urlSesTokInfo output=user as-value]
	:local apiData  ($api->"data")

	# pars SessionID and Token from API session data 
	:local apiSessionID [$getBetween inputString=$apiData betweenStart="<SesInfo>" betweenEnd="</SesInfo>"]
	:local apiToken [$getBetween inputString=$apiData betweenStart="<TokInfo>" betweenEnd="</TokInfo>"]

	# header and data config
	:local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
	:local recvData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"

	# recv SMS via LTE modem API with fetch
	/tool fetch  http-method=post output=user \
    http-header-field=$apiHead \
    url="http://$lteIP/api/sms/sms-list" \
    http-data=$recvData;
}

:local arrData [ :toarray $recvSMS ]
:local varData ( $arrData->"data" )
:put [ $varData ]

I execute with
:put [$recvSMS]
and I get the following result:


# With a message received:

status: finished
downloaded: 0KiBC-z pause]
data: <?xml version="1.0" encoding="UTF-8"?> <response> <Count>1</Count> <Messages> <Message> <Smstat>0</Smstat>
<Index>40001</Index> <Phone>+34XXXXXXXXX</Phone> <Content>SMS test from my Mobile</Content> <Date>2023-01-11
13:20:26</Date> <Sca></Sca> <SaveType>0</SaveType> <Priority>0</Priority> <SmsType>1</SmsType> </Message>
</Messages> </response>


# With 3 messages received:

status: finished
downloaded: 0KiBC-z pause]
data: <?xml version="1.0" encoding="UTF-8"?> <response> <Count>3</Count> <Messages> <Message> <Smstat>1</Smstat>
<Index>40003</Index> <Phone>+34XXXXXXXXX</Phone> <Content>SMS test from my Mobile3</Content> <Date>2023-01-11
17:02:05</Date> <Sca></Sca> <SaveType>0</SaveType> <Priority>0</Priority> <SmsType>1</SmsType> </Message>
<Message> <Smstat>1</Smstat> <Index>40002</Index> <Phone>+34XXXXXXXXX</Phone> <Content>SMS test from my
Mobile2</Content> <Date>2023-01-11 16:59:48</Date> <Sca></Sca> <SaveType>0</SaveType> <Priority>0</Priority>
<SmsType>1</SmsType> </Message> <Message> <Smstat>1</Smstat> <Index>40001</Index> <Phone>+34XXXXXXXXX</Phone>
<Content>SMS test from my Mobile</Content> <Date>2023-01-11 13:20:26</Date> <Sca></Sca> <SaveType>0</SaveType>
<Priority>0</Priority> <SmsType>1</SmsType> </Message> </Messages> </response>

There is a function that allows you to extract certain data from XML:

:global getBetween do={

      :local posStart 0;
      :if ([:len $betweenStart] > 0) do={
            :set posStart [:find $inputString $betweenStart]
            :if ([:len $posStart] = 0) do={
                  :set posStart 0
            } else={
                  :set posStart ($posStart + [:len $betweenStart])
            }
      }

      :local posEnd 9999;
      :if ([:len $betweenEnd] > 0) do={
            :set posEnd [:find $inputString $betweenEnd]
            :if ([:len $posEnd] = 0) do={ :set posEnd 9999 }
      }

      :local result [:pick $inputString $posStart $posEnd]
      :return $result
}

The idea is to extract the content of <Phone> and <Content> of each SMS using the previous function and save it to give those values to local variables in order to resend those messages or save them in a file. But I don't know how to do it. :(

I have tried this without success:

{
:global getBetween
:execute {$recvSMS} file=sms-list.xml
:local ExtractedXML [/file get sms-list.xml.txt contents]
:local phon [$getBetween inputString=$ExtractedXML betweenStart="<Phone>" betweenEnd="</Phone>"]
:local mens [$getBetween inputString=$ExtractedXML betweenStart="<Content>" betweenEnd="</Content>"]
:put "$phon\t$mens"
}

Any help please??

BR.
 
dakobg
Member Candidate
Member Candidate
Topic Author
Posts: 120
Joined: Mon Nov 06, 2017 8:58 am

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Jan 16, 2023 9:52 am

diamuxin,

Not sure if you contact me over email, unfortunately I incidentally delete it (sorry about that!)
I have a lot of personal tasks this days, however when I have a free time will check If I can help here

Quick question: You want to get the a list of recv sms or you want to get the content as well ?

Regards,
Nikolay
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Jan 16, 2023 10:48 am

Yes, also the content, thank you.

The idea is that the content of the SMS received (phone number and message) can be forwarded by email or sms, for example.

BR.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Jan 24, 2023 8:51 pm

Any progress Nikolay?

BR.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 02, 2023 8:34 am

Well, I have already received my Huawei E3372h-320 modem that incorporates an API that allows to manage some functions of the modem.
So does this script only work with this version of the modem ?
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 02, 2023 8:57 am

So does this script only work with this version of the modem ?
I have tested it on two models:

- E8372h-320 -> Does not work.
- E3372h-320 -> Yes it works (only to send SMS).

I have tested (read back) to receive SMS and process the content, without success.

I am waiting to see if the author of the script gives us an idea on how to receive SMS using the Huawei API.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 02, 2023 11:10 am

Yes, I would also wait for the author to tell me exactly which versions of the firmware and WEB interface his script works with? And where to get the API documentation for these modems ...
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Fri Feb 03, 2023 12:57 am

...the author to tell me exactly...

These scripts are contributed unselfishly by its creators. It's unfair to expect or demand them any kind of guarantee about its applicability. For this kind of info you should contact the modem manufacturer or vendor.

I think that there are two kind of HiLink devices:
  • single-user devices: with only one usb connection like E3372h
  • multi-user devices: like full-fledged routers with ethernet and/or WiFi, and also MiFi devices with usb connection and WiFi hotspot, like E8372h

Single-user devices (at least older ones) are only connected to other one device via a physical link, so access is somewhat controlled and use a simple way of authentication consisting of retrieving a session id and token thru a http request.

Multi-user devices are exposed to arbitrary users and therefore, API access is authenticated with user and password. The problem is that user-password authentication returns access tokens in the headers of the http response and /tool/fetch has no way to get them, so it's no possible to access these devices from RoS scripts.

The best documentation links for HiLink API that I know are: They are not 100% accurate, but are a good source of information.

Here is a discussion of the several authentication methods:
Last edited by pkt on Fri Feb 03, 2023 1:27 am, edited 2 times in total.
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Fri Feb 03, 2023 1:23 am

I have tested (read back) to receive SMS and process the content, without success.

The recvSMS works well, but retrieves a bunch of sms messages at a time. The getBetween parser is very limited and can only process the first appearance ot each tag.

I've a more advanced parser that walks incrementally across the xml:
# TOKEN PARSER LIBRARY
# v1.0.0 pkt

# :put [($tokenParser->"getTag") source=$xml tag="SessionInfo"]

# ($tokenParser->"getBetween")
#  get delimited value
#    source - source string
#    fromTok - (optional) text AFTER this token (or from source beginning) will be returned
#    toTok - (optional) text BEFORE this token (or until source finish) will be returned
#    startPos - (optional) start position (default 0 = beginning)
#  returns an array with fields data and pos
# 
# ($tokenParser->"getTag")
#  get value for XML tag
#    source - xml string
#    tag - tag which value is to be returned
#    startPos - (optional, text index) start position (if not specified, it will search from the beginning of the string)
#  returns the tag content
# 
# ($tokenParser->"getTagDetailed")
#  get value and end position for XML tag
#    source - xml string
#    tag - tag which value is to be returned
#    startPos - (optional, text index) start position (if not specified, it will search from the beginning of the string)
#  returns an array with fields "data" (tag content) and "pos" (where tag ends)
# 
# ($tokenParser->"getTagList")
#  get a list with the content of each appearance of tag
#    source - xml string
#    tag - tag which value is to be returned
#  returns an array with tag contents
# 
# ($tokenParser->"forEachTag")
#  incremental parser that calls the callback with the content of each appearance of tag
#    source - xml string
#    tag - tag which value is to be returned
#    callback - callback (with param content) to be called for each appearance of tag
#    callbackArgs - callback will be called passing this value in param args


:global tokenParser ({})

:set ($tokenParser->"getBetween") do={ # get delimited value
  # source - source string
  # fromTok - (optional) text AFTER this token (or from source beginning) will be returned
  # toTok - (optional) text BEFORE this token (or until source finish) will be returned
  # startPos - (optional) start position (default 0 = beginning)
  
  # returns an array with fields data and pos
  # if fromTok and/or toTok are specified and neither of them appear in source, empty string "" will be returned as data

  # based on function getBetween by CuriousKiwi, modified by pkt

  :local posStart
  if ([:len $startPos] = 0) do={
    :set posStart -1
  } else={
    :set posStart ($startPos-1)
  }

  :local found true
  :local data 

  :local resultStart
  :if ([:len $fromTok] > 0) do={
    :set resultStart [:find $source $fromTok $posStart]
    :if ([:len $resultStart] = 0) do={ # start token not found
      :set found false
      :set data ""
    }
    :set resultStart ($resultStart + [:len $fromTok])
  } else={
    :set resultStart 0
  }

  :local resultEnd
  :if (found = true && [:len $toTok] > 0) do={
    :set resultEnd [:find $source $toTok ($resultStart-1)]
    :if ([:len $resultEnd] = 0) do={ # end token not found
      :set found false
      :set data ""
    }
  } else={
    :set resultEnd [:len $source]
  }

  :if ($found = true) do={ :set data [:pick $source $resultStart $resultEnd] }

  :return { data=$data; pos=$resultEnd }
}

:set ($tokenParser->"getTag") do={ # get value for XML tag
  # source - xml string
  # tag - tag which value is to be returned
  # startPos - (optional, text index) start position (if not specified, it will search from the beginning of the string)

  # returns the tag content

  :global tokenParser
  :return ([($tokenParser->"getBetween") source=$source fromTok=("<$tag>") toTok=("</$tag>") startPos=$startPos]->"data")
}

:set ($tokenParser->"getTagDetailed") do={ # get value and end position for XML tag
  # source - xml string
  # tag - tag which value is to be returned
  # startPos - (optional, text index) start position (if not specified, it will search from the beginning of the string)

  # returns an array with fields "data" (tag content) and "pos" (where tag ends)

  :global tokenParser
  :return [($tokenParser->"getBetween") source=$source fromTok=("<$tag>") toTok=("</$tag>") startPos=$startPos]
}

:set ($tokenParser->"getTagList") do={ # get a list with the content of each appearance of tag
  # source - xml string
  # tag - tag which value is to be returned

  # returns an array with tag contents

  :global tokenParser

  :local result ({})
  :local doneTags false
  :local startPos 0

  :do {
    :local tagContent [($tokenParser->"getTagDetailed") source=$source tag=$tag startPos=$startPos]

    :local content ($tagContent->"data")
    :if ($content != "") do={
      :set ($result->[:len $result]) $content

      # advance start pos to search for next tag
      :set startPos ($tagContent->"pos")
    } else={
      :set doneTags true
    }
  } while=($doneTags = false)

  :return $result
}

:set ($tokenParser->"forEachTag") do={ # incremental parser that calls the callback with the content of each appearance of tag
  # source - xml string
  # tag - tag which value is to be returned
  # callback - callback (with param content) to be called for each appearance of tag
  # callbackArgs - callback will be called passing this value in param args

  :global tokenParser

  :local doneTags false
  :local startPos 0

  :do {
    :local tagContent [($tokenParser->"getTagDetailed") source=$source tag=$tag startPos=$startPos]

    :local content ($tagContent->"data")
    :if ($content != "") do={
      [$callback tagContent=$content args=$callbackArgs]

      # advance start pos to search for next tag
      :set startPos ($tagContent->"pos")
    } else={
      :set doneTags true
    }
  } while=($doneTags = false)
}

The receive script will be something as this:
:global recvSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local recvData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"

  # recv SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/sms-list" http-data=$recvData output=user as-value]
}

:local xmlSmsList ([$recvSMS]->"data")

:global tokenParser

:local smsList [($tokenParser->"getTagList") source=$xmlSmsList tag="Message"]

:foreach tagContent in=$smsList do={
  # tagContent - content of tag

  :local index ([($tokenParser->"getTag") source=$tagContent tag="Index"])
  :local phone ([($tokenParser->"getTag") source=$tagContent tag="Phone"])
  :local content ([($tokenParser->"getTag") source=$tagContent tag="Content"])
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)

  :put "$index $read $phone $[pick $content 0 50]"
}

With this you can try to made some progress.

But you will encounter more problems, such as that some characters are escaped (< is &lt; ...), how to mark the sms as processed so next time it will be ignored, how to avoid skipping sms if they arrive when the inbox is being processed...

I am working (in my very limited spare time) in a more powerful library for HiLink access in RouterOS scripts that will try to solve these problems, call a function when new sms arrives, and even implements automatic execution of RoS scripts when receiving sms with :cmd, as Mikrotik's own SMS support do.

I except to have a test version the next week or maybe the next one.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Fri Feb 03, 2023 10:08 am

I except to have a test version the next week or maybe the next one.
Fantastic @pkt!

Thank you very, very much for helping us with the Huawei API.
We'll keep an eye out for your review.

Best regards.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Fri Feb 03, 2023 12:35 pm

Hi @pkt

You have made a very important breakthrough in research, thank you for your work.

Your script works very fine.

Unread messages:
[admin@MikroTik] > sys scr run test-sms
40002 false +34XXXXXXXXX Received message test 2
40001 false +34XXXXXXXXX Received message test 1
Already read messages: (Changes the state of the variable "$read" to true)
[admin@MikroTik] > sys scr run test-sms
40002 true +34XXXXXXXXX Received message test 2
40001 true +34XXXXXXXXX Received message test 1

It would be great, that once we get the messages, we can use the content of the $phone and $[pick $content 0 50] variables independent of the $read condition and be able to forward it for example by email. After sending it, apply a :relay 5s and delete the inbox.

With a scheduler task, I would check the inbox for X minutes.

At the time I was trying to delete messages and I created this script, but does not delete them.
# Original code by @pkt

:global delSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local delData "<?xml version:\"1.0\" encoding=\"UTF-8\"?><request><Index>10</Index></request>"

  # delete SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/delete-sms" http-data=$delData output=user as-value]
}


BR.
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sat Feb 04, 2023 11:29 am

Afaik, you can't delete the entire inbox with one command. But can do it one message at a time using its index.

In the delete request, instead of <Index>10</Index> use <Index>$index</Index>.

And then (not tested):
...

:local index ([($tokenParser->"getTag") source=$tagContent tag="Index"])

[:delSMS index=$index]

Note that you can't know if email is sent successfully, so, if there is an error, you have a risk of deleting a sms not really sent and you will lost it.

One approach could be to include the sms index in the email subject so you can easily note in received email the hole in numbering if one is missing (assuming hilink increments index with each sms} if e.g. you receive 40001, 40002 and then 40004, then 40003 is missing and you can check mikrotik log for errors, and also read the sms in modem's web interface.

So you should not delete it immediately, but after a few days. For this it is needed to parse the date time of the sms so it can be deleted when is older than a given elapsed time. I have some functions for this, but are not finished yet.

For ignoring messages already sent by email but yet not deleted and avoid sending it in each scheduler talk execution, the only way I can imagine is sending by email only not read messages, and marking it as read after email is sent. No delay is needed.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sat Feb 04, 2023 2:17 pm

The SMSs can be stored locally:

Example:
{
:local SMSfolder "SMS" ; # must already exist, do not count "flash", is added automatically if is needed
:local SMSfileend "backup_sms.txt" ; # only .txt file, the date and the time is added automatically at the start

:local arrMonths {an="01";eb="02";ar="03";pr="04";ay="05";un="06";ul="07";ug="08";ep="09";ct="10";ov="11";ec="12"}
/system clock ; # instead of use local date and time, if can be obtained, the SMS date and time can be used.
:local date [get date]
:local time [get time]
:local SMSfntime  "$[:pick $date 7 11]$($arrMonths->[:pick $date 1 3])$[:pick $date 4 6]$[:pick $time 0 2]$[:pick $time 3 5]"
:local SMSfpath   "$SMSfolder/$SMSfntime_$SMSfileend"
:local SMSnumber  "+18005551234567890"
:local SMSmessage "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
/file
:put $SMSfpath
:if ([:len [find where name="flash" and type="disk"]] = 1) do={:set SMSfpath "flash/$SMSfpath"}
:put $SMSfpath
:if ([:len [find where name=$SMSfpath]] = 0) do={print file=$SMSfpath; :delay 5s; set $SMSfpath contents=""}
:put $SMSfpath
:delay 2s
set $SMSfpath contents="$[get $SMSfpath contents]$SMSnumber $SMSmessage\r\n"
}
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Feb 05, 2023 10:55 am

Using local storage is great idea. This way there are no risk of exceeding the (not documented) storage capacity of the modem.

Thanks for the code, I will make good use of it. I have already reused successfully some of your snippets in my hilink routines..
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Sun Feb 05, 2023 11:35 pm

Afaik, you can't delete the entire inbox with one command. But can do it one message at a time using its index.

In the delete request, instead of <Index>10</Index> use <Index>$index</Index>.

And then (not tested):
...
:local index ([($tokenParser->"getTag") source=$tagContent tag="Index"])
[:delSMS index=$index]
Hello, thank you for replying @pkt.

But, I don't quite understand your approach. In the script I use called test-sms has the following content:
:global recvSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local recvData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"

  # recv SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/sms-list" http-data=$recvData output=user as-value]
}

:global tokenParser
:local xmlSmsList ([$recvSMS]->"data")
:local smsList [($tokenParser->"getTagList") source=$xmlSmsList tag="Message"]
:local sendthisuniquelist ""

:foreach tagContent in=$smsList do={
  # tagContent - content of tag
  
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  :local phone [($tokenParser->"getTag") source=$tagContent tag="Phone"]
  :local content [($tokenParser->"getTag") source=$tagContent tag="Content"]
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)

  :if ($content != "") do={
  :put "$index $read $phone $content"
  :set sendthisuniquelist ($sendthisuniquelist."$index $read $phone $content\r\n")
  }
}
/tool e-mail send to=to@gmail.com subject="SMS List" body=$sendthisuniquelist

And the script with the function "delSMS" has the following content:

:global delSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  :local delData "<?xml version:\"1.0\" encoding=\"UTF-8\"?><request><Index>$index</Index></request>"

  # delete SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/delete-sms" http-data=$delData output=user as-value]
}

If I run the first script "test-sms" I get the two test messages on screen and by email:

40001 false +34XXXXXXXXX Lorem ipsum 2
40000 false +34XXXXXXXXX Lorem ipsum 1

and then, if I run the "delSMS" script it does not delete any message.

This line does not work:
[:delSMS index=$index]
Can you help me?

I would like that once the messages are read, I can delete them.

BR.
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 12:48 am

I thought that you wanted to send one email for each sms. In that case the script would be something like this:
...

:foreach tagContent in=$smsList do={
  # tagContent - content of tag
  
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  :local phone [($tokenParser->"getTag") source=$tagContent tag="Phone"]
  :local content [($tokenParser->"getTag") source=$tagContent tag="Content"]
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)

  :if ($content != "") do={
    :put "$index $read $phone $content"
    /tool e-mail send to=to@gmail.com subject="SMS List" body="$index $read $phone $content"
    [$delSMS index=$index]
  }
}

But if you want to send all sms grouped in only one email, then it is better to first concatenate all sms and send the email (you are already doing this), and then do a second foreach to delete all sms:
...

:local sendthisuniquelist ""

:foreach tagContent in=$smsList do={
  # tagContent - content of tag
  
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  :local phone [($tokenParser->"getTag") source=$tagContent tag="Phone"]
  :local content [($tokenParser->"getTag") source=$tagContent tag="Content"]
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)

  :if ($content != "") do={
    :put "$index $read $phone $content"
    :set sendthisuniquelist ($sendthisuniquelist."$index $read $phone $content\r\n")
  }
}

/tool e-mail send to=to@gmail.com subject="SMS List" body=$sendthisuniquelist

:foreach tagContent in=$smsList do={
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  [$delSMS index=$index]
}

Correct syntax is [$delSMS index=$index] no [:delSMS index=$index] as I posted before. My fault.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 11:37 am

The second foreach does not work, tested as follows:

{
:global tokenParser
:local xmlSmsList ([$recvSMS]->"data")
:local smsList [($tokenParser->"getTagList") source=$xmlSmsList tag="Message"]

:foreach tagContent in=$smsList do={
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  [$delSMS index=$index]
}
}

SMS messages are not deleted, verified:

[admin@MikroTik] > :put ([$recvSMS]->"data")

<?xml version="1.0" encoding="UTF-8"?>
<response>
  <Count>2</Count>
  <Messages>
    <Message>
      <Smstat>1</Smstat>
      <Index>40002</Index>
      <Phone>+34XXXXXXXXX</Phone>
      <Content>Received message test 2</Content>
      <Date>2023-02-03 16:33:01</Date>
      <Sca></Sca>
      <SaveType>0</SaveType>
      <Priority>0</Priority>
      <SmsType>1</SmsType>
    </Message>
    <Message>
      <Smstat>1</Smstat>
      <Index>40001</Index>
      <Phone>+34XXXXXXXXX</Phone>
      <Content>Received message test 1</Content>
      <Date>2023-02-03 14:02:27</Date>
      <Sca></Sca>
      <SaveType>0</SaveType>
      <Priority>0</Priority>
      <SmsType>1</SmsType>
    </Message>
  </Messages>
</response>
Any ideas please?

BR.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:05 pm

Well , then they started tweeting without me ... In order not to disassemble all the posts, can someone clearly write how to receive SMS and how to send it and on which firmware it will work?
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:09 pm

Well , then they started tweeting without me ... In order not to disassemble all the posts, can someone clearly write how to receive SMS and how to send it and on which firmware it will work?
viewtopic.php?t=166859#p981850

viewtopic.php?p=982481#p981623

Device name: E3372h-320
Hardware version: CL4E3372HM
Software version: 11.0.1.1(H697SP4C983)
Web UI version: WEBUI 11.0.1.1(W13SP4C7110)

Some info can be found here http://forum.jdtech.pl/Watek-hilink-api ... zen-huawei (in polish)
Last edited by diamuxin on Mon Feb 06, 2023 2:20 pm, edited 1 time in total.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:19 pm

Well , then they started tweeting without me ... In order not to disassemble all the posts, can someone clearly write how to receive SMS and how to send it and on which firmware it will work?
None of the above scripts for sending/receiving SMS are working for me ...
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:24 pm

Well , then they started tweeting without me ... In order not to disassemble all the posts, can someone clearly write how to receive SMS and how to send it and on which firmware it will work?
None of the above scripts for sending/receiving SMS are working for me ...
You will need to look for a Huawei Modem model that supports the API. Mine if you read backwards is the E3372h-320 model that I can send and receive messages via MIkrotik fetch (I just need to know how to delete them once read).
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:24 pm

None of the above scripts for sending/receiving SMS are working for me ...
At least you have Send SMS messages via Huawei LTE modem API (tested with E3372 ) ???
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:26 pm

I have two E3372 modems here are their data:

Device name: E3372
Hardware version: CL2E3372HM
Software version: 22.315.01.00.00
Web UI version: WEBUI 17.100.13.01.03-Mod1.10

Device name: E3372
Hardware version: CL2E3372HM
Software version: 22.333.01.00.00
Web UI version: WEBUI 17.100.13.112.03 (17.100.13.01.03_Mod1.12)
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:28 pm

Hello, Rex! No, these modems of mine don't send SMS via API... They are sent from the WEB interface without any problems...
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:36 pm

Apparently they need to be flashed to E3372-320
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:37 pm

Sorry, I can't help here, except this,
viewtopic.php?p=982500#p982173
I do not have that poduct...
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:41 pm

Apparently they need to be flashed to E3372-320
No, my firmware is the original factory firmware. I bought it that way and it updated itself.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 2:42 pm

Sorry, I can't help here, except this,
viewtopic.php?p=982500#p982173
I do not have that poduct...
Your help is always welcome. That script is very useful.
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 9:44 pm

SMS messages are not deleted

delSMS had a few errors. New version:
:global delSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local delData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>$index</Index></request>"

  # delete SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/delete-sms" http-data=$delData output=user as-value]
}

Now it seems to work ok. Tested in terminal deleting one sms:
:put [$delSMS index="40008"] 

I use :put so output of /tool/fetch is shown in terminal.

A interesting note:
  1. Before deleting sms 40008, I had: 40000, 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010 (no holes).
  2. After deleting it, I had: 40000, 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40009, 40010 (hole between 40007 and 40009, as expected).
  3. Then modem received 2 more sms, and as result, I now have: 40000, 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40009, 40010, 40008, 40011 (no holes).

SMS were fetched with <Ascending>1</Ascending> (ascending order: older first).

Conclusions:
  • HiLink reuses holes, so sms index number is not monotonically increasing (new indexes are not always greater than existent ones).
  • Sort and comparison of sms by age can't be done using "Index", has to be done using "Date".
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 10:04 pm

Hello, Rex! No, these modems of mine don't send SMS via API... They are sent from the WEB interface without any problems...

You can try this in terminal to test if you can authenticate with HiLink API (assuming modem IP is 192.168.8.1):
[admin@MikroTik] > :put [/tool fetch "http://192.168.8.1/api/webserver/SesTokInfo" output=user as-value]

Output has to be something like these:
data=<?xml version="1.0" encoding="UTF-8"?><response><SesInfo>938z9a0QgNbIk27xff3LoPNw02XUtxq2xkc0orPIZe
bLSzpEvNUONe7mb4SbLm8Vj9rba5CfNEA0jqVOd7EFn0RBzum6i6lBJofjp1kSsSuPMqPfQCfa6uKDNFifm3Vz</SesInfo><TokInfo
>jcgWVFYc3cR8hvbO2R4byN2QPurVnA7M</TokInfo></response>;downloaded=0;status=finished
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Mon Feb 06, 2023 10:29 pm

Thank you very much for your help @pkt,
we are very close to solve it.

I just tried it like this and I notice something curious, if I insert this code inside a script, it doesn't work.

{
:global tokenParser
:local xmlSmsList ([$recvSMS]->"data")
:local smsList [($tokenParser->"getTagList") source=$xmlSmsList tag="Message"]

:foreach tagContent in=$smsList do={
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  [$delSMS index=$index]
}

}

However, if I run it directly from the terminal (between {}) it DOES delete correctly the messages in the inbox.

Image

What can happen?
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 12:16 am

Maybe you have not delSMS in scope.

If it is not defined in the same script or function in which is used, it's necessary to "import" the symbol declaring it.

You can try to put :global delSMS in a line before the foreach one.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 12:29 am

Maybe you have not delSMS in scope.

If it is not defined in the same script or function in which is used, it's necessary to "import" the symbol declaring it.

You can try to put :global delSMS in a line before the foreach one.

You are right, declaring the global variable "delSMS" is already solved! Thanks!!!
Final and correct script:
:global recvSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local recvData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"

  # recv SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/sms-list" http-data=$recvData output=user as-value]
}

:global tokenParser
:global delSMS
:local xmlSmsList ([$recvSMS]->"data")
:local smsList [($tokenParser->"getTagList") source=$xmlSmsList tag="Message"]

:foreach tagContent in=$smsList do={

  :local index ([($tokenParser->"getTag") source=$tagContent tag="Index"])
  :local phone ([($tokenParser->"getTag") source=$tagContent tag="Phone"])
  :local content ([($tokenParser->"getTag") source=$tagContent tag="Content"])
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)

  :if ($content != "") do={
  # :put "$index $read $phone $content"
  /tool e-mail send to=to@mail.com subject="\F0\9F\93\A9 SMS $phone" body="$index $read $phone $content"
  }
}

:foreach tagContent in=$smsList do={
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  [$delSMS index=$index]
}

BR.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 9:44 am

:if ($content != "") do={
  # :put "$index $read $phone $content"
  /tool e-mail send to=to@mail.com subject="\F0\9F\93\A9 SMS $phone" body="$index $read $phone $content"
And it's better to go to Telegram:
/tool fetch url="https://api.telegram.org/bot$TToken/sendmessage\?chat_id=$TChatId"  \
    http-method=post  http-data="text=\F0\9F\93\A9 SMS $phone%0A$index $read $phone $content" keep-result=no
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 9:59 am

I use Telegram in most of my scripts, I tried it at the time here and I had errors with the encoding of some SMS characters, so I discarded it.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 2:56 pm

I use Telegram in most of my scripts, I tried it at the time here and I had errors with the encoding of some SMS characters, so I discarded it.
The 2nd function on my post can be used before sent the string (ASCII-7 and/or CP125x) to telegram (UTF-8):
viewtopic.php?t=177551#p967513

Or directly URL encode the string:
viewtopic.php?t=177551#p980163
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 4:51 pm

I use Telegram in most of my scripts, I tried it at the time here and I had errors with the encoding of some SMS characters, so I discarded it.
The 2nd function on my post can be used before sent the string (ASCII-7 and/or CP125x) to telegram (UTF-8):
viewtopic.php?t=177551#p967513

Or directly URL encode the string:
viewtopic.php?t=177551#p980163
Thanks Rex. I am already testing it.

Which ascii characters are displayed, only from 32 to 126?
Would it be possible to include the character "ñ" or "€" or others that I need in the future?

BR.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 6:57 pm

1> Which ascii characters are displayed, only from 32 to 126?
2> Would it be possible to include the character "ñ" or "€" or others that I need in the future?

1a> MikroTik support only the display of 7-bit characters (as in CP470),
the remaining 8-bit are unsupported and € symbol (And be can insterted only by winbox and webfig because terminal do not support it)
is translated from winbox/webfig on hexadecimal value 0x80 (that is € on CP1252 and others).
Since there is not correspondence from various language on 8-bit characters, codepage is needed and what is, for example € on CP1252 is Ђ on another codepage.

1b> MikroTik do not support UCS-2 alphabet, if the message contain simply one UCS-2 character, all mesage is on UCS-2 format and MikroTik can not read it.
On GSM7 alphabet the only currency symbol supported are £ $ ¥ and the generic ¤
If € is used, can't be encoded on GSM7, and the character is removed, or message is not sent.
viewtopic.php?p=411358#p411358

2> I do not know if MikroTik add sooner or later the support for the UCS-2 SMS, but actually you can not read or sent that characters.
At least must be implemented a method for read by AT commands the SMS memory and convert the RAW binary data to readable message,
and do the opposite to send the SMS with support for UCS-2


Probably using the API of the Huawei, is possible to send one message with "ñ" or "€" simply converting first the message with ASCIItoCP1252toUTF8.
If your codepage is not CP1252 / Windows 1252, must be done one appropriate function using the ASCIItoCP1252toUTF8 as base.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 7:47 pm

Probably using the API of the Huawei, is possible to send one message with "ñ" or "€" simply converting first the message with ASCIItoCP1252toUTF8.
If your codepage is not CP1252 / Windows 1252, must be done one appropriate function using the ASCIItoCP1252toUTF8 as base.

When an SMS is received on the Huawei modem, through the API we get the data (with :put) and it is fully compatible with the Mikrotik Terminal.

[admin@MikroTik] > sys scr run check-sms
40008 false +34XXXXXXXXX SOLOPTICAL Ofertas hasta 60% dto + REGALO Gafas mod España. CÓDIGO DESCUENTO: UoxTM

In the following example you can see that I forward the SMS received via Email, SMS and Telegram, the characters are perfectly readable in Email and SMS. I have only had some sporadic problem with the text in Telegram, but it has been quite reduced thanks to the function "ASCIItoCP1252toUTF8".

:foreach tagContent in=$smsList do={
  
  :global tokenParser
  :global sendSMS
  :global ASCIItoCP1252toUTF8
  :local phoneTG ""
  :local contentTG ""
  :local index ([($tokenParser->"getTag") source=$tagContent tag="Index"])
  :local phone ([($tokenParser->"getTag") source=$tagContent tag="Phone"])
  :local content ([($tokenParser->"getTag") source=$tagContent tag="Content"])
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)
  :set phoneTG [$ASCIItoCP1252toUTF8 $phone];  # It is also needed, otherwise remove the "+"34.... original
  :set contentTG [$ASCIItoCP1252toUTF8 $content]

  :if ($content != "") do={
  
  :put "$index $read $phone $content"
  
  /tool e-mail send \
  to=mail1@mail.com \
  cc=mail2@mail.com \
  subject="SMS $phone" \
  body="$phone - $content"
  
  :delay 2s; :execute [$sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms=($"phone" . " " . $"content")];
  
  # --- TG Start ---
  :local MessageText "\F0\9F\93\A9 SMS $phoneTG %0A $contentTG"
  :local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]]
  $SendTelegramMessage MessageText=$MessageText
  # --- TG End -----

  }
}

Thanks.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 7:57 pm

[admin@MikroTik] > sys scr run check-sms
40008 false +34XXXXXXXXX SOLOPTICAL Ofertas hasta 60% dto + REGALO Gafas mod España. CÓDIGO DESCUENTO: UoxTM
How ñ and Ó on terminal????????
What you use SSL? Telenet? Other?
On 7.7 I haven't find any way to print other characters.
Is a script results??? Hmmm....
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Tue Feb 07, 2023 8:04 pm

How ñ and Ó on terminal????????
What you use SSL? Telenet? Other?
On 7.7 I haven't find any way to print other characters.
Is a script results??? Hmmm....
I use MobaXterm as an external terminal SSH, it is wonderful and very visual.

Image

I can read SMS, but I can't write those characters.

If you need any information do not hesitate to ask for it.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 2:49 pm

Hi @pkt,

One last question please, is it possible to delete also the sent SMS? when I enter the web-ui 192.168.8.1, I see that the received SMS are deleted correctly, however the sent SMS are visible. It is not important, just curious.

Edit: I reply to myself:

The key is in the following: <BoxType>2</BoxType> of the local variable "recvData"

Type 1 we get the Inbox messages.
Type 2 we get the Outbox messages.

# Script name: recvSMSoutbox (or any)

:global recvSMSoutbox do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local recvData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>2</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"

  # recv SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/sms-list" http-data=$recvData output=user as-value]
}

:global delSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local delData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>$index</Index></request>"

  # delete SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/delete-sms" http-data=$delData output=user as-value]
}

:global tokenParser; # The content is posted a few posts above
:global recvSMSoutbox
:global delSMS
:local xmlSmsList ([$recvSMSoutbox]->"data")
:local smsList [($tokenParser->"getTagList") source=$xmlSmsList tag="Message"]

:foreach tagContent in=$smsList do={
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  [$delSMS index=$index]
}

It works fine.

[admin@MikroTik] > :put ([$recvSMSoutbox]->"data")
<?xml version="1.0" encoding="UTF-8"?>
<response>
<Count>0</Count>
<Messages></Messages>
</response>

BR.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 8:26 pm

I finally reflashed my modem and these functions worked for me. Thanks to the authors for them.

The question arose - is there any stable feature that could be used to understand whether there is an API modem in the WEB or not? So that you could write a short function that would return "true" or "false" for example?
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 8:48 pm

There are many scripts written here, but there is no system, you can get confused ... Is it possible to ask the authors to put this chaos in order?
As far as I understand, there are ready-made functions:

:global tokenParser - main API parser
:global sendSMS - function send SMS
:global delSMS - function delete SMS
:global ASCIItoCP1252toUTF8 (or ASCIItoCP12XXtoUTF8) - recoding function (depends on which national alphabet is used)
... + script for enumerating messages in a loop with sending SMS in some way ... (e-mail, telegram, sms, etc...)

As I see it, it is necessary to make a library of functions that would be able to:
- send an arbitrary SMS,
- get a list of incoming SMS,
- get the Nth SMS from this list into a variable,
- get a list of sent SMS,
- get the Nth SMS from the list of sent SMS into a variable,
- delete an arbitrary SMS by number from the list of incoming/outgoing SMS

Based on this, you can do whatever you want. Maybe someone will take it and make it "turnkey"?
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 8:50 pm

Hi @pkt,

Starting from this: <Count>1</Count> for example.

How can I do to execute an action if <Count> is >0.

I have started like this:

[admin@MikroTik] > :put ([$recvSMS]->"data")
<?xml version="1.0" encoding="UTF-8"?>
<response>
<Count>1</Count>
<Messages>
<Message>
<Smstat>0</Smstat>
<Index>40000</Index>
<Phone>+34XXXXXXXXX</Phone>
<Content>Lorem ipsum</Content>
<Date>2023-02-08 16:44:19</Date>
<Sca></Sca>
<SaveType>0</SaveType>
<Priority>0</Priority>
<SmsType>1</SmsType>
</Message>
</Messages>
</response>
...
{
:global tokenParser
:global recvSMS
:local xmlSmsList ([$recvSMS]->"data")
:put [($tokenParser->"getTag") source=$xmlSmsList tag="Count"]
}
Output:  1

thanks.
Last edited by diamuxin on Wed Feb 08, 2023 10:07 pm, edited 3 times in total.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 9:07 pm

There are many scripts written here, but there is no system, you can get confused ... Is it possible to ask the authors to put this chaos in order?
As far as I understand, there are ready-made functions
You can not demand that the information in the thread is ordered to your liking, especially when no one has been able to solve the Mikrotik compatibility with the Huawei API, until the comrade @pkt arrived and thanks to his help the light was made (he is a very busy person and helps when he can).

Chaos? of course, right now the posts are the result of tests and more tests until it is finally working as it should. You should read from the beginning to find out everything.

Anyway, I'm going to try to sort out the content of the main functions and script.

By the way, this thread is NOT MINE, I'm just trying to understand and collaborate.
Last edited by diamuxin on Wed Feb 08, 2023 9:09 pm, edited 1 time in total.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 9:09 pm

I also found out that I could not have reflashed my modem, since it turned out that the API is available only if the user password for entering the WEB interface settings is not set. As soon as I reset the password on my old firmware, these Mikrotik SMS functions worked. I wonder if it is possible to work with SMS with a "secure" API - there should be the possibility of authorization to access the API ...
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 9:12 pm

Yes, I understand all the difficulties and the amount of work done. Many thanks to all authors. Let's hope that someday we will get a good library of functions.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 9:37 pm

Collection of Huawei API scripts for use with MikroTik
(Tested on a Huawei E3372h-320 modem)

Token Parser Library
(Main Script base)
# TOKEN PARSER LIBRARY
# v1.0.0 pkt

# :put [($tokenParser->"getTag") source=$xml tag="SessionInfo"]

# ($tokenParser->"getBetween")
#  get delimited value
#    source - source string
#    fromTok - (optional) text AFTER this token (or from source beginning) will be returned
#    toTok - (optional) text BEFORE this token (or until source finish) will be returned
#    startPos - (optional) start position (default 0 = beginning)
#  returns an array with fields data and pos
# 
# ($tokenParser->"getTag")
#  get value for XML tag
#    source - xml string
#    tag - tag which value is to be returned
#    startPos - (optional, text index) start position (if not specified, it will search from the beginning of the string)
#  returns the tag content
# 
# ($tokenParser->"getTagDetailed")
#  get value and end position for XML tag
#    source - xml string
#    tag - tag which value is to be returned
#    startPos - (optional, text index) start position (if not specified, it will search from the beginning of the string)
#  returns an array with fields "data" (tag content) and "pos" (where tag ends)
# 
# ($tokenParser->"getTagList")
#  get a list with the content of each appearance of tag
#    source - xml string
#    tag - tag which value is to be returned
#  returns an array with tag contents
# 
# ($tokenParser->"forEachTag")
#  incremental parser that calls the callback with the content of each appearance of tag
#    source - xml string
#    tag - tag which value is to be returned
#    callback - callback (with param content) to be called for each appearance of tag
#    callbackArgs - callback will be called passing this value in param args


:global tokenParser ({})

:set ($tokenParser->"getBetween") do={ # get delimited value
  # source - source string
  # fromTok - (optional) text AFTER this token (or from source beginning) will be returned
  # toTok - (optional) text BEFORE this token (or until source finish) will be returned
  # startPos - (optional) start position (default 0 = beginning)
  
  # returns an array with fields data and pos
  # if fromTok and/or toTok are specified and neither of them appear in source, empty string "" will be returned as data

  # based on function getBetween by CuriousKiwi, modified by pkt

  :local posStart
  if ([:len $startPos] = 0) do={
    :set posStart -1
  } else={
    :set posStart ($startPos-1)
  }

  :local found true
  :local data 

  :local resultStart
  :if ([:len $fromTok] > 0) do={
    :set resultStart [:find $source $fromTok $posStart]
    :if ([:len $resultStart] = 0) do={ # start token not found
      :set found false
      :set data ""
    }
    :set resultStart ($resultStart + [:len $fromTok])
  } else={
    :set resultStart 0
  }

  :local resultEnd
  :if (found = true && [:len $toTok] > 0) do={
    :set resultEnd [:find $source $toTok ($resultStart-1)]
    :if ([:len $resultEnd] = 0) do={ # end token not found
      :set found false
      :set data ""
    }
  } else={
    :set resultEnd [:len $source]
  }

  :if ($found = true) do={ :set data [:pick $source $resultStart $resultEnd] }

  :return { data=$data; pos=$resultEnd }
}

:set ($tokenParser->"getTag") do={ # get value for XML tag
  # source - xml string
  # tag - tag which value is to be returned
  # startPos - (optional, text index) start position (if not specified, it will search from the beginning of the string)

  # returns the tag content

  :global tokenParser
  :return ([($tokenParser->"getBetween") source=$source fromTok=("<$tag>") toTok=("</$tag>") startPos=$startPos]->"data")
}

:set ($tokenParser->"getTagDetailed") do={ # get value and end position for XML tag
  # source - xml string
  # tag - tag which value is to be returned
  # startPos - (optional, text index) start position (if not specified, it will search from the beginning of the string)

  # returns an array with fields "data" (tag content) and "pos" (where tag ends)

  :global tokenParser
  :return [($tokenParser->"getBetween") source=$source fromTok=("<$tag>") toTok=("</$tag>") startPos=$startPos]
}

:set ($tokenParser->"getTagList") do={ # get a list with the content of each appearance of tag
  # source - xml string
  # tag - tag which value is to be returned

  # returns an array with tag contents

  :global tokenParser

  :local result ({})
  :local doneTags false
  :local startPos 0

  :do {
    :local tagContent [($tokenParser->"getTagDetailed") source=$source tag=$tag startPos=$startPos]

    :local content ($tagContent->"data")
    :if ($content != "") do={
      :set ($result->[:len $result]) $content

      # advance start pos to search for next tag
      :set startPos ($tagContent->"pos")
    } else={
      :set doneTags true
    }
  } while=($doneTags = false)

  :return $result
}

:set ($tokenParser->"forEachTag") do={ # incremental parser that calls the callback with the content of each appearance of tag
  # source - xml string
  # tag - tag which value is to be returned
  # callback - callback (with param content) to be called for each appearance of tag
  # callbackArgs - callback will be called passing this value in param args

  :global tokenParser

  :local doneTags false
  :local startPos 0

  :do {
    :local tagContent [($tokenParser->"getTagDetailed") source=$source tag=$tag startPos=$startPos]

    :local content ($tagContent->"data")
    :if ($content != "") do={
      [$callback tagContent=$content args=$callbackArgs]

      # advance start pos to search for next tag
      :set startPos ($tagContent->"pos")
    } else={
      :set doneTags true
    }
  } while=($doneTags = false)
}


Function to get a list of SMS messages
:global recvSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local recvData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"

  # recv SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/sms-list" http-data=$recvData output=user as-value]
}


Function to delete SMS messages (Inbox)
:global delSMS do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local delData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>$index</Index></request>"

  # delete SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/delete-sms" http-data=$delData output=user as-value]
}


Script to delete SMS messages (Sentbox)
:global recvSMSsentbox do={
  :local lteIP "192.168.8.1"

  :global tokenParser

  # get SessionID and Token via LTE modem API
  :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
  :local api [/tool fetch $urlSesTokInfo output=user as-value]
  :local apiData  ($api->"data")

  # parse SessionID and Token from API session data 
  :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
  :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

  # header and data config
  :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
  :local recvData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><PageIndex>1</PageIndex><ReadCount>20</ReadCount><BoxType>2</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"

  # delete SMS via LTE modem API with fetch
  :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/sms-list" http-data=$recvData output=user as-value]
}

:global tokenParser
:global delSMS
:local xmlSmsList ([$recvSMSsentbox]->"data")
:local smsList [($tokenParser->"getTagList") source=$xmlSmsList tag="Message"]
:local smsCount [:tonum [($tokenParser->"getTag") source=$xmlSmsList tag="Count"]]

:if ($smsCount > 0) do={

:delay 5s
:foreach tagContent in=$smsList do={
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  [$delSMS index=$index]
}
}

Function to send SMS messages
:global sendSMS do={
	# Example:	
	# :put [$sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="test sms via lte api"]

    :local lteIP "192.168.8.1"

    :global tokenParser

    # get SessionID and Token via LTE modem API
    :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
    :local api [/tool fetch $urlSesTokInfo output=user as-value]
    :local apiData  ($api->"data")
      
    # parse SessionID and Token from API session data 
    :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
    :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

	# header and data config
	:local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
	:local sendData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$sms</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>"

	# send SMS via LTE modem API with fetch
    :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/send-sms" http-data=$sendData output=user as-value]
}


Script to get a list of SMS messages from Inbox, forward them by email and SMS, then delete them.
:global tokenParser
:global recvSMS
:global delSMS
:global sendSMS
:local xmlSmsList ([$recvSMS]->"data")
:local smsList [($tokenParser->"getTagList") source=$xmlSmsList tag="Message"]
:local smsCount [:tonum [($tokenParser->"getTag") source=$xmlSmsList tag="Count"]]

:if ($smsCount > 0) do={

:foreach tagContent in=$smsList do={

  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  :local date [($tokenParser->"getTag") source=$tagContent tag="Date"]
  :local phone [($tokenParser->"getTag") source=$tagContent tag="Phone"]
  :local content [($tokenParser->"getTag") source=$tagContent tag="Content"]
  :local read ([($tokenParser->"getTag") source=$tagContent tag="Smstat"] = 1)

  :if ($content != "") do={
    :put "$index $read $date $phone $content"    
    /tool e-mail send to=user@mail.com subject="SMS $phone" body="$index $read $date $phone $content"    
    :execute [$sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="$phone $content"]
  }
}

:delay 5s
:foreach tagContent in=$smsList do={
  :local index [($tokenParser->"getTag") source=$tagContent tag="Index"]
  [$delSMS index=$index]
}
}

TIP:

Change DHCP server IP address range (modem) to be able to configure a single IP for the Mikrotik DHCP client.

1. Run the following script to create the global variable dhcpSMS.
2. From the Terminal type:
:put [$dhcpSMS lteIP="192.168.8.1" startIP="192.168.8.100" endIP="192.168.8.100"]
3. Done! you have now changed the IP address range.

Script contents:
:global dhcpSMS do={
   
    # Example:	
    # :put [$dhcpSMS lteIP="192.168.8.1" startIP="192.168.8.100" endIP="192.168.8.100"]
    
    :global tokenParser

    # get SessionID and Token via LTE modem API
    :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
    :local api [/tool fetch $urlSesTokInfo output=user as-value]
    :local apiData  ($api->"data")
      
    # parse SessionID and Token from API session data 
    :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
    :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

    # header and data config
    :local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
    :local dhcpData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><DnsStatus>1</DnsStatus><DhcpStartIPAddress>$startIP</DhcpStartIPAddress><DhcpIPAddress>192.168.8.1</DhcpIPAddress><accessipaddress></accessipaddress><homeurl>hi.link</homeurl><DhcpStatus>1</DhcpStatus><DhcpLanNetmask>255.255.255.0</DhcpLanNetmask><SecondaryDns>192.168.8.1</SecondaryDns><PrimaryDns>192.168.8.1</PrimaryDns><DhcpEndIPAddress>$endIP</DhcpEndIPAddress><DhcpLeaseTime>86400</DhcpLeaseTime></request>"
    
    # change IP address range with fetch
    :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/dhcp/settings" http-data=$dhcpData output=user as-value]
}
Enjoy!.
Last edited by diamuxin on Wed Jul 26, 2023 10:43 am, edited 6 times in total.
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 10:50 pm

I wonder if it is possible to work with SMS with a "secure" API - there should be the possibility of authorization to access the API ...
AFAIK, user-password authentication in HiLink returns access tokens in the headers of the http response and /tool/fetch has no way to get them, so it's actually no possible to use this type of authentication with RoS scripts.

I have suggested a new feature to Mikrotik to enhance /tool/fetch to return also response headers: SUP-107232.


Let's hope that someday we will get a good library of functions.

I quote myself:
I am working (in my very limited spare time) in a more powerful library for HiLink access in RouterOS scripts that will try to solve these problems, call a function when new sms arrives, and even implements automatic execution of RoS scripts when receiving sms with :cmd, as Mikrotik's own SMS support do.
 
User avatar
pkt
just joined
Posts: 14
Joined: Tue Jan 24, 2023 10:12 pm
Location: /u/mw/ss/e/eu/es

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Feb 08, 2023 11:08 pm

How can I do to execute an action if <Count> is >0.

I think this will work even if Count tag is empty or non-existent:
:global tokenParser
:global recvSMS

:local xmlSmsList ([$recvSMS]->"data")

:local smsCount [:tonum [($tokenParser->"getTag") source=$xmlSmsList tag="Count"]]

:if ($smsCount > 0) do={
  ...
}
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 9:22 am

Many thanks to diamuxin for "ordering" the developments so far and pkt for his great contribution! We look forward to your more powerful library.

I still have questions:

1. what sign can be used to understand whether the API firmware supports or not to write a "check" function whether a particular modem has an API in the firmware or not. and
2. If access to the WEB is password protected, then the above functions (I only checked on sendSMS) work, but do nothing - in particular, SMS is not sent. Is it possible to somehow get a sign that password authorization is enabled in order to inform RouterOS (in the log, for example) that the functions are not possible and it should remove the password
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 9:37 am

By the way, Huawei E3372h-320 modem is much worse than the earlier model E3372h-153. Modification 320 does not have an SD slot, does not have the ability to connect external antennas and does not have the ability to change the firmware to alternative ones.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 10:46 am

By the way, Huawei E3372h-320 modem is much worse than the earlier model E3372h-153. Modification 320 does not have an SD slot, does not have the ability to connect external antennas and does not have the ability to change the firmware to alternative ones.

You are totally wrong (and more if you haven't tried it), it is a newer model than the previous one and it is improved in LTE frequencies, allowing Cat6 with speeds up to 150/50 Mb/s.

It does have space for 2 antennas, but I don't need them (95% coverage with my operator).

It doesn't have a SD slot (only older models do) but I don't need it either.

As for the firmware, it is not necessary to modify it (or turn it into a slow modem) as it is 100% compatible with the Huawei API and for me it is enough.

It is not a question of whether a device IS BETTER OR WORSE if not that it meets my needs, for me it is enough.

I advise you that instead of demanding so much or asking meaningless questions, you get down to work, investigate and contribute something interesting to the forum.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 10:59 am

I think this will work even if Count tag is empty or non-existent:
:global tokenParser
:global recvSMS

:local xmlSmsList ([$recvSMS]->"data")

:local smsCount [:tonum [($tokenParser->"getTag") source=$xmlSmsList tag="Count"]]

:if ($smsCount > 0) do={
  ...
}

Thank you very much, that's exactly what I needed.
-- I have already updated the script collection.

BR.
 
markom
Member Candidate
Member Candidate
Posts: 112
Joined: Thu Dec 17, 2009 10:42 pm

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 11:12 am

Can someone explain procedure of deploy script and using it. I am little confuse how to get any of this script work in practice.
like:
create script
name script
run script
output result.
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 12:53 pm

I didn't mean to offend you or "offend your modem". And my contribution to the scripts is here:

https://forummikrotik.ru/viewtopic.php?f=14&t=13947

Now I am busy writing my own Telegram Notifier and Runner system, which differs from the existing works. I am also writing a universal function FuncAS, capable of sending messages through different systems and hardware (you can read here https://habr.com/ru/post/646663/, it will just be replenished with your Huawey sendSMS) and I am working on the SSH-exec library. All this takes time, and I'm just a doctor... I see no reason for me to get into your library "SMS Huawey" You will do fine there without me.
You have already written many wonderful scripts and the community is very grateful to you for this.

And E3372h-320 is still worse than E3372h-153 (at least for those who like to break protection and make their own firmware for modems). Modification 320 is not stitched, so we have less interest in it and the price is two times lower compared to modification 153.
I also have an E3372h-320. As for the speeds, maybe it's faster, we really don't have Cat6 speeds.
Most of all, we value the router modem E8372 with wifi and native Huawey firmware. There are very few new ones left and they cost us about $ 200. But for our purposes, as I understand, they are not suitable, because they wrote above that it is impossible to access the API of such a modem from the Router OS.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 1:29 pm

I didn't mean to offend you or "offend your modem". And my contribution to the scripts is here:

https://forummikrotik.ru/viewtopic.php?f=14&t=13947

Now I am busy writing my own Telegram Notifier and Runner system, which differs from the existing works. I am also writing a universal function FuncAS, capable of sending messages through different systems and hardware (you can read here https://habr.com/ru/post/646663/, it will just be replenished with your Huawey sendSMS) and I am working on the SSH-exec library. All this takes time, and I'm just a doctor... I see no reason for me to get into your library "SMS Huawey" You will do fine there without me.
You have already written many wonderful scripts and the community is very grateful to you for this.

And E3372h-320 is still worse than E3372h-153 (at least for those who like to break protection and make their own firmware for modems). Modification 320 is not stitched, so we have less interest in it and the price is two times lower compared to modification 153.
I also have an E3372h-320. As for the speeds, maybe it's faster, we really don't have Cat6 speeds.
Most of all, we value the router modem E8372 with wifi and native Huawey firmware. There are very few new ones left and they cost us about $ 200. But for our purposes, as I understand, they are not suitable, because they wrote above that it is impossible to access the API of such a modem from the Router OS.

No comments.

..
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 1:46 pm

Exactly :)
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 9:55 pm

By the way, the smsSend function sends SMS, putting them in the list of sent messages with a wrong date (I have all the messages sent via the API dated December 31, 1969. If the messages from the WEB interface are sent correctly).
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Feb 09, 2023 10:06 pm

By the way, the smsSend function sends SMS, putting them in the list of sent messages with a wrong date (I have all the messages sent via the API dated December 31, 1969. If the messages from the WEB interface are sent correctly).

It works fine for me.

[admin@MikroTik] > $sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="Lorem Ipsum Epsilon"

# SMS Outbox:

<?xml version="1.0" encoding="UTF-8"?>
<response>
	<Count>1</Count>
	<Messages>
		<Message>
			<Smstat>3</Smstat>
			<Index>40000</Index>
			<Phone>+34XXXXXXXXX</Phone>
			<Content>Lorem Ipsum Epsilon</Content>
			<Date>2023-02-09 20:58:45</Date>  # OK
			<Sca></Sca>
			<SaveType>3</SaveType>
			<Priority>4</Priority>
			<SmsType>1</SmsType>
		</Message>
	</Messages>
</response>
..
 
User avatar
Sertik
Member
Member
Posts: 425
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Fri Feb 10, 2023 11:29 am

no, I have shows 23:59:59 on 31.12.1969 in all sent SMS

there are 153 modifications with different firmware on three modems. I'll try to unsubscribe on 320

Have you looked at the WEB interface itself ?
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Jun 29, 2023 4:19 pm

I am working (in my very limited spare time) in a more powerful library for HiLink access in RouterOS scripts that will try to solve these problems, call a function when new sms arrives, and even implements automatic execution of RoS scripts when receiving sms with :cmd, as Mikrotik's own SMS support do.
Hi @pkt !

Did you manage to create the library you mentioned in the post?
Have you made progress on this issue?

BR.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Wed Jul 26, 2023 10:32 am

New TIP:

Change DHCP server IP address range (modem) to be able to configure a single IP for the Mikrotik DHCP client.

1. Run the following script to create the global variable dhcpSMS.
2. From the Terminal type:
:put [$dhcpSMS lteIP="192.168.8.1" startIP="192.168.8.100" endIP="192.168.8.100"]
3. Done! you have now changed the IP address range.

Script contents:
:global dhcpSMS do={
   
    # Example:	
    # :put [$dhcpSMS lteIP="192.168.8.1" startIP="192.168.8.100" endIP="192.168.8.100"]
    
    :global tokenParser

    # get SessionID and Token via LTE modem API
    :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
    :local api [/tool fetch $urlSesTokInfo output=user as-value]
    :local apiData  ($api->"data")
      
    # parse SessionID and Token from API session data 
    :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
    :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

	# header and data config
	:local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
	:local dhcpData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><DnsStatus>1</DnsStatus><DhcpStartIPAddress>$startIP</DhcpStartIPAddress><DhcpIPAddress>192.168.8.1</DhcpIPAddress><accessipaddress></accessipaddress><homeurl>hi.link</homeurl><DhcpStatus>1</DhcpStatus><DhcpLanNetmask>255.255.255.0</DhcpLanNetmask><SecondaryDns>192.168.8.1</SecondaryDns><PrimaryDns>192.168.8.1</PrimaryDns><DhcpEndIPAddress>$endIP</DhcpEndIPAddress><DhcpLeaseTime>86400</DhcpLeaseTime></request>"
    
    # change IP address range with fetch
    :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/dhcp/settings" http-data=$dhcpData output=user as-value]
}
Enjoy!.
 
MIG85
just joined
Posts: 2
Joined: Thu Aug 10, 2023 7:29 am

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Aug 10, 2023 7:38 am

Hello! dealt with error 100005 when sending SMS on some modems... construction <Date>-1</Date> does not work

for firmware RouterOS v7.10+
:global sendSMS do={
	# Example:	
	# :put [$sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="test sms via lte api"]

    :local lteIP "192.168.8.1"

    :global tokenParser

    # get SessionID and Token via LTE modem API
    :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
    :local api [/tool fetch $urlSesTokInfo output=user as-value]
    :local apiData  ($api->"data")
      
    # parse SessionID and Token from API session data 
    :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
    :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]
	
	
	 :local time;
:set time [/system clock get time];
:local date [/system clock get date];



	# header and data config
	:local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
	:global sendData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$sms</Content><Length>-1</Length><Reserved>1</Reserved><Date>$date $time</Date></request>"

	# send SMS via LTE modem API with fetch
    :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/send-sms" http-data=$sendData output=user as-value]
}
for firmware older than RouterOS v7.10
:global sendSMS do={
	# Example:	
	# :put [$sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="test sms via lte api"]

    :local lteIP "192.168.8.1"

    :global tokenParser

    # get SessionID and Token via LTE modem API
    :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
    :local api [/tool fetch $urlSesTokInfo output=user as-value]
    :local apiData  ($api->"data")
      
    # parse SessionID and Token from API session data 
    :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
    :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]
	
	
	 :local time;
:set time [/system clock get time];
:local date [/system clock get date];
:local months {"jan"="01";"feb"="02";"mar"="03";"apr"="04";"may"="05";"jun"="06";"jul"="07";"aug"="08";"sep"="09";"oct"=10;"nov"=11;"dec"=12};
:local day [:pick $date 4 6];:local year [:tonum [:pick $date 7 11]];:local month [:pick $date 0 3];:local mm (:$months->$month);
:local newdate "$year-$mm-$day";


	# header and data config
	:local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
	:global sendData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$sms</Content><Length>-1</Length><Reserved>1</Reserved><Date>$newdate $time</Date></request>"

	# send SMS via LTE modem API with fetch
    :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/send-sms" http-data=$sendData output=user as-value]
}
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Aug 10, 2023 12:36 pm

Hi, I have RouterOS v7.10 and it works correctly both ways:

@diamuxin
:global sendSMS do={
	# Example:	
	# :put [$sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="test sms via lte api"]

    :local lteIP "192.168.8.1"

    :global tokenParser

    # get SessionID and Token via LTE modem API
    :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
    :local api [/tool fetch $urlSesTokInfo output=user as-value]
    :local apiData  ($api->"data")
      
    # parse SessionID and Token from API session data 
    :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
    :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]

	# header and data config
	:local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
	:local sendData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$sms</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>"

	# send SMS via LTE modem API with fetch
    :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/send-sms" http-data=$sendData output=user as-value]
}

TEST code

[admin@MikroTik] > :put [$sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="test sms via lte api"]
data=<?xml version="1.0" encoding="UTF-8"?>
<response>OK</response>
;downloaded=0;status=finished

@MIG85
:global sendSMS do={
	# Example:	
	# :put [$sendSMS lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="test sms via lte api"]

    :local lteIP "192.168.8.1"

    :global tokenParser

    # get SessionID and Token via LTE modem API
    :local urlSesTokInfo "http://$lteIP/api/webserver/SesTokInfo"
    :local api [/tool fetch $urlSesTokInfo output=user as-value]
    :local apiData  ($api->"data")
      
    # parse SessionID and Token from API session data 
    :local apiSessionID [($tokenParser->"getTag") source=$apiData tag="SesInfo"]
    :local apiToken [($tokenParser->"getTag") source=$apiData tag="TokInfo"]
	
	
	:local time;
    :set time [/system clock get time];
    :local date [/system clock get date];



	# header and data config
	:local apiHead "Content-Type:text/xml,Cookie: $apiSessionID,__RequestVerificationToken:$apiToken"
	:global sendData "<?xml version=\"1.0\" encoding=\"UTF-8\"?><request><Index>-1</Index><Phones><Phone>$phone</Phone></Phones><Sca></Sca><Content>$sms</Content><Length>-1</Length><Reserved>1</Reserved><Date>$date $time</Date></request>"

	# send SMS via LTE modem API with fetch
    :return [/tool fetch http-method=post http-header-field=$apiHead url="http://$lteIP/api/sms/send-sms" http-data=$sendData output=user as-value]
}

TEST code

[admin@MikroTik] > :put [$sendSMS2 lteIP="192.168.8.1" phone="+34XXXXXXXXX" sms="test sms via lte api2"]
data=<?xml version="1.0" encoding="UTF-8"?>
<response>OK</response>
;downloaded=0;status=finished

My USB modem model is Huawei E3372h-320, I have not tested it on other models. If you follow the above instructions it should work.

Test if your modem is compatible by launching this command and you should get some codes:
http://192.168.8.1/api/webserver/SesTokInfo

BR.
 
MIG85
just joined
Posts: 2
Joined: Thu Aug 10, 2023 7:29 am

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Aug 10, 2023 12:54 pm

I have with <Date>-1</Date>
123123123131231.jpg
You do not have the required permissions to view the files attached to this post.
 
User avatar
diamuxin
Member
Member
Posts: 317
Joined: Thu Sep 09, 2021 5:46 pm
Location: Alhambra's City

Re: Send SMS messages via Huawei LTE modem API (tested with E3372)

Thu Aug 10, 2023 4:57 pm

According to error code 100005 it corresponds to "ERROR_FORMAT_ERROR".

Also, the date format you have is the one before v7.10 (aug/09/2023). I would try a version >=v7.10 where the date comes with the international ISO 8601 format (2023-08-09) which matches the date format of the Huawei modem.

What exact model is your modem? It has only worked on my model E3372h-320, on Huawei B311s-220 and E8372h-155 this method has not worked.

# Message received in the Inbox
<?xml version="1.0" encoding="UTF-8"?>
<response>
    <Count>1</Count>
    <Messages>
        <Message>
            <Smstat>0</Smstat>
            <Index>40000</Index>
            <Phone>+34XXXXXXXXX</Phone>
            <Content>Lorem ipsum dolor sit amet, consectetur adipiscing elit</Content>
            <Date>2023-02-08 16:44:19</Date>       <== ORIGINAL ISO FORMAT
            <Sca></Sca>
            <SaveType>0</SaveType>
            <Priority>0</Priority>
            <SmsType>1</SmsType>
        </Message>
    </Messages>
</response>

Errors code

ERROR_UNKNOWN	100001
ERROR_NOT_SUPPORT	100002
ERROR_NO_RIGHT	100003
ERROR_BUSY	100004
ERROR_FORMAT_ERROR	100005
ERROR_PARAMETER_ERROR	100006
ERROR_SAVE_CONFIG_FILE_ERROR	100007
ERROR_GET_CONFIG_FILE_ERROR	100008
ERROR_NO_SIM_CARD_OR_INVALID_SIM_CARD	101001
ERROR_CHECK_SIM_CARD_PIN_LOCK	101002
ERROR_CHECK_SIM_CARD_PUN_LOCK	101003
ERROR_CHECK_SIM_CARD_CAN_UNUSEABLE	101004
ERROR_ENABLE_PIN_FAILED	101005
ERROR_DISABLE_PIN_FAILED	101006
ERROR_UNLOCK_PIN_FAILED	101007
ERROR_DISABLE_AUTO_PIN_FAILED	101008
ERROR_ENABLE_AUTO_PIN_FAILED	101009
ERROR_GET_NET_TYPE_FAILED	102001
ERROR_GET_SERVICE_STATUS_FAILED	102002
ERROR_GET_ROAM_STATUS_FAILED	102003
ERROR_GET_CONNECT_STATUS_FAILED	102004
ERROR_DEVICE_AT_EXECUTE_FAILED	103001
ERROR_DEVICE_PIN_VALIDATE_FAILED	103002
ERROR_DEVICE_PIN_MODIFFY_FAILED	103003
ERROR_DEVICE_PUK_MODIFFY_FAILED	103004
ERROR_DEVICE_GET_AUTORUN_VERSION_FAILED	103005
ERROR_DEVICE_GET_API_VERSION_FAILED	103006
ERROR_DEVICE_GET_PRODUCT_INFORMATON_FAILED	103007
ERROR_DEVICE_SIM_CARD_BUSY	103008
ERROR_DEVICE_SIM_LOCK_INPUT_ERROR	103009
ERROR_DEVICE_NOT_SUPPORT_REMOTE_OPERATE	103010
ERROR_DEVICE_PUK_DEAD_LOCK	103011
ERROR_DEVICE_GET_PC_AISSST_INFORMATION_FAILED	103012
ERROR_DEVICE_SET_LOG_INFORMATON_LEVEL_FAILED	103013
ERROR_DEVICE_GET_LOG_INFORMATON_LEVEL_FAILED	103014
ERROR_DEVICE_COMPRESS_LOG_FILE_FAILED	103015
ERROR_DEVICE_RESTORE_FILE_DECRYPT_FAILED	103016
ERROR_DEVICE_RESTORE_FILE_VERSION_MATCH_FAILED	103017
ERROR_DEVICE_RESTORE_FILE_FAILED	103018
ERROR_DEVICE_SET_TIME_FAILED	103101
ERROR_COMPRESS_LOG_FILE_FAILED	103102
ERROR_DHCP_ERROR	104001
ERROR_SAFE_ERROR	106001
ERROR_DIALUP_GET_CONNECT_FILE_ERROR	107720
ERROR_DIALUP_SET_CONNECT_FILE_ERROR	107721
ERROR_DIALUP_DIALUP_MANAGMENT_PARSE_ERROR	107722
ERROR_DIALUP_ADD_PRORILE_ERROR	107724
ERROR_DIALUP_MODIFY_PRORILE_ERROR	107725
ERROR_DIALUP_SET_DEFAULT_PRORILE_ERROR	107726
ERROR_DIALUP_GET_PRORILE_LIST_ERROR	107727
ERROR_DIALUP_GET_AUTO_APN_MATCH_ERROR	107728
ERROR_DIALUP_SET_AUTO_APN_MATCH_ERROR	107729
ERROR_LOGIN_NO_EXIST_USER	108001
ERROR_LOGIN_PASSWORD_ERROR	108002
ERROR_LOGIN_ALREADY_LOGINED	108003
ERROR_LOGIN_MODIFY_PASSWORD_FAILED	108004
ERROR_LOGIN_TOO_MANY_USERS_LOGINED	108005
ERROR_LOGIN_USERNAME_OR_PASSWORD_ERROR	108006
ERROR_LOGIN_TOO_MANY_TIMES	108007
ERROR_LANGUAGE_GET_FAILED	109001
ERROR_LANGUAGE_SET_FAILED	109002
ERROR_ONLINE_UPDATE_SERVER_NOT_ACCESSED	110001
ERROR_ONLINE_UPDATE_ALREADY_BOOTED	110002
ERROR_ONLINE_UPDATE_GET_DEVICE_INFORMATION_FAILED	110003
ERROR_ONLINE_UPDATE_GET_LOCAL_GROUP_COMMPONENT_INFORMATION_FAILED	110004
ERROR_ONLINE_UPDATE_NOT_FIND_FILE_ON_SERVER	110005
ERROR_ONLINE_UPDATE_NEED_RECONNECT_SERVER	110006
ERROR_ONLINE_UPDATE_CANCEL_DOWNLODING	110007
ERROR_ONLINE_UPDATE_SAME_FILE_LIST	110008
ERROR_ONLINE_UPDATE_CONNECT_ERROR	110009
ERROR_ONLINE_UPDATE_INVALID_URL_LIST	110021
ERROR_ONLINE_UPDATE_NOT_SUPPORT_URL_LIST	110022
ERROR_ONLINE_UPDATE_NOT_BOOT	110023
ERROR_ONLINE_UPDATE_LOW_BATTERY	110024
ERROR_USSD_ERROR	111001
ERROR_USSD_FUCNTION_RETURN_ERROR	111012
ERROR_USSD_IN_USSD_SESSION	111013
ERROR_USSD_TOO_LONG_CONTENT	111014
ERROR_USSD_EMPTY_COMMAND	111016
ERROR_USSD_CODING_ERROR	111017
ERROR_USSD_AT_SEND_FAILED	111018
ERROR_USSD_NET_NO_RETURN	111019
ERROR_USSD_NET_OVERTIME	111020
ERROR_USSD_XML_SPECIAL_CHARACTER_TRANSFER_FAILED	111021
ERROR_USSD_NET_NOT_SUPPORT_USSD	111022
ERROR_SET_NET_MODE_AND_BAND_WHEN_DAILUP_FAILED	112001
ERROR_SET_NET_SEARCH_MODE_WHEN_DAILUP_FAILED	112002
ERROR_SET_NET_MODE_AND_BAND_FAILED	112003
ERROR_SET_NET_SEARCH_MODE_FAILED	112004
ERROR_NET_REGISTER_NET_FAILED	112005
ERROR_NET_NET_CONNECTED_ORDER_NOT_MATCH	112006
ERROR_NET_CURRENT_NET_MODE_NOT_SUPPORT	112007
ERROR_NET_SIM_CARD_NOT_READY_STATUS	112008
ERROR_NET_MEMORY_ALLOC_FAILED	112009
ERROR_SMS_NULL_ARGUMENT_OR_ILLEGAL_ARGUMENT	113017
ERROR_SMS_OVERTIME	113018
ERROR_SMS_QUERY_SMS_INDEX_LIST_ERROR	113020
ERROR_SMS_SET_SMS_CENTER_NUMBER_FAILED	113031
ERROR_SMS_DELETE_SMS_FAILED	113036
ERROR_SMS_SAVE_CONFIG_FILE_FAILED	113047
ERROR_SMS_LOCAL_SPACE_NOT_ENOUGH	113053
ERROR_SMS_TELEPHONE_NUMBER_TOO_LONG	113054
ERROR_SD_FILE_EXIST	114001
ERROR_SD_DIRECTORY_EXIST	114002
ERROR_SD_FILE_OR_DIRECTORY_NOT_EXIST	114004
ERROR_SD_IS_OPERTED_BY_OTHER_USER	114004
ERROR_SD_FILE_NAME_TOO_LONG	114005
ERROR_SD_NO_RIGHT	114006
ERROR_SD_FILE_IS_UPLOADING	114007
ERROR_PB_NULL_ARGUMENT_OR_ILLEGAL_ARGUMENT	115001
ERROR_PB_OVERTIME	115002
ERROR_PB_CALL_SYSTEM_FUCNTION_ERROR	115003
ERROR_PB_WRITE_FILE_ERROR	115004
ERROR_PB_READ_FILE_ERROR	115005
ERROR_PB_LOCAL_TELEPHONE_FULL_ERROR	115199
ERROR_STK_NULL_ARGUMENT_OR_ILLEGAL_ARGUMENT	116001
ERROR_STK_OVERTIME	116002
ERROR_STK_CALL_SYSTEM_FUCNTION_ERROR	116003
ERROR_STK_WRITE_FILE_ERROR	116004
ERROR_STK_READ_FILE_ERROR	116005
ERROR_WIFI_STATION_CONNECT_AP_PASSWORD_ERROR	117001
ERROR_WIFI_WEB_PASSWORD_OR_DHCP_OVERTIME_ERROR	117002
ERROR_WIFI_PBC_CONNECT_FAILED	117003
ERROR_WIFI_STATION_CONNECT_AP_WISPR_PASSWORD_ERROR	117004
ERROR_CRADLE_GET_CRURRENT_CONNECTED_USER_IP_FAILED	118001
ERROR_CRADLE_GET_CRURRENT_CONNECTED_USER_MAC_FAILED	118002
ERROR_CRADLE_SET_MAC_FAILED	118003
ERROR_CRADLE_GET_WAN_INFORMATION_FAILED	118004
ERROR_CRADLE_CODING_FAILED	118005
ERROR_CRADLE_UPDATE_PROFILE_FAILED	118006

Who is online

Users browsing this forum: JDF and 26 guests