If you’ve bought a modem from Optus, here in Australia, you may be delighted – and disappointed that the SMSs that are received on the Modem, are now served through a web interface.
I wasn’t happy about this, as I wanted to interrogate the SMS database through the “Mobile Partner” program. So, because Optus have custom firmware it’s basically not possible to do this (Yes, I was on the phone to both parties), it has caused me to look elsewhere. If you wanted to use a custom firmware, go for it, but I couldn’t be bothered.
Specifically, I have an E3372 modem.
I came across this post and information, it got me thinking…
The same hackaround can be used to programatically send SMS from the LAN using the E3372 API, here’s a simple script that does just that:
#!/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/send-sms -H "Cookie: $SESSION_ID" -H "__RequestVerificationToken: $TOKEN" --data "<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>$1</Phone></Phones><Sca></Sca><Content>$2</Content><Length>-1</Length><Reserved>1</Reserved><Date>-1</Date></request>"
Use it like this:
./send_sms.sh +1234567890 "Hello world!"
After studying the code a little, I’ve been able to discover that the SMS messages can easily be read from the stick, as XML.
Request URL:http://192.168.8.1/api/sms/sms-list Request method:POST Remote address:192.168.8.1:80
<?xml version="1.0" encoding="utf-8"?> <response> <Count>12</Count> <Messages> <Message> <Smstat>1</Smstat> <Index>40013</Index> <Phone>OPTUS</Phone> <Content>An SMS you tried to send or receive has failed as you are out of credit for that message type. Recharge now to allow future SMS messages to be sent or received.</Content> <Date>2019-02-13 16:04:02</Date> <Sca></Sca> <SaveType>4</SaveType> <Priority>0</Priority> <SmsType>1</SmsType> </Message> <Message> <Smstat>0</Smstat> <Index>40011</Index> <Phone>OPTUS</Phone> <Content>An SMS you tried to send or receive has failed as you are out of credit for that message type. Recharge now to allow future SMS messages to be sent or received.</Content> <Date>2019-02-13 16:03:20</Date> <Sca></Sca> <SaveType>4</SaveType> <Priority>0</Priority> <SmsType>1</SmsType> </Message> </Messages> </Response>
This should be enough to get me started, and once again (possibly) start to read SMS messages from my (new) USB Modem.
While I haven’t tried this method fully yet, but in theory this will be completely possible.
This may also remove the need for Gammu as well.
For other valuable information on these devices (which are all very similar)
https://blog.hqcodeshop.fi/archives/259-Huawei-E5186-AJAX-API.html
http://www.gnuton.org/blog/2015/07/huawei-e3372/
http://blog.asiantuntijakaveri.fi/2015/07/convert-huawei-e3372h-153-from.html
https://sh.com.hr/en/modificiranje-huawei-e3372-lte-sticka/
I recently bought an Optus E3372h-607 for use in a remote monitoring application. Did you ever manage to write a script to read the messages from the stick via the sms-list API call?
Hi Tim, I didn’t really pursue this too much in the end. Just enough to write a quick blog “discovery” post. It would be very easy to do this with a php script using curl, or something though.
how or where to get into the file
Get in to what file?
can you please help when i execute the file for sending the message the message is saved under draft and really being sent
Do you have any code examples, because that’s a very generic statement. Otherwise, I would suggest posting your question on StackOverflow.
Interesting as I have an Huawei E3372 modem which I tried to use your script to send an SMS message. I get this output and error. Can you assisit/comment?…Rob
sudo /usr/pgms/SMSSend.sh 12345678 “Hello”
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 277 100 277 0 0 3693 0 –:–:– –:–:– –:–:– 3794
100005
Have you added the country code of the sms number??
Yes, here is the command line: “sudo /usr/pgms/SMSSend.sh 07****40 “Hello””. I have it working now with the Huawei API calls.