Cell modem to receive SMS?

Is there a known tested hardware/software combo, such as a USB dongle modem for example, that could allow for receiving SMS messages on a FreeBSD machine? I don't care much for the format, it could be a text file dump, but something semi-automatic, without the need to write scripts with AT commands.
Or, alternatively, accessing an Android device connected via USB for the same purpose?
 
some providers allow you to forward SMS to email or even allow access to the SMS subsystem via REST API.
I fiddled around with both, and due to the fact that API access is often rate limited and purely pull based (i.e. you have to poll for new SMS via cron or other mechanisms) it is rather impractical, so I just used the SMS-to-mail function with a tagged mail address that is catched by a sieve rule and passed to a script.
 
Not FreeBSD: I have a SixFab USB-based cell modem, connected to a Raspberry Pi 0 (running Raspbian a.k.a. Debian, not FreeBSD). The SixFab part is mostly a carrier for a Telit mPCIe card, which provides power connection and a USB interface. Note that this is not a "dongle", but a PC board, and it requires a case, wiring for its +5V supply (not a problem if you are using a Pi) and an antenna. I mostly use it as an IP modem, but the AT command set allows for sending/receiving SMS too.

You said "without the need to write scripts with AT commands". I don't know how that is possible with such a hardware solution.

Another issue is this: Most cell plans that I know of only allow for one device to use the SIM and cell phone number. So if your phone number is +X-YYY-ZZZZ, then SMS messages to that number will go to your primary cell phone, and a cell modem (which has to use a separate SIM and therefore number) will not get them. Dedicating a SIM and phone number to your device might be a good idea in your situation, or a bad idea. If you want to access the SMS that you are getting on your primary phone number, then sko's idea of going through e-mail or REST is probably better.
 
with at commands probably you can use a dumb phone
i have a huawei router from my previous isp that will receive sms message and you can probably retrieve them with curl from it's admin interface
 
I can't use REST, unfortunately. Of course it would've been the easiest way. I want to dedicate the hardware to a specific SIM card, no separate numbers.
I was looking at Raspberries as well, but if there's no wrapper for dumping incoming SMSes, it's going to make things hard. Not sure how I can connect a dumb phone to FreeBSD either. Oh well, perhaps it's easier to set some sort of a script on a smartphone to dump SMS database at regular intervals via scp to a certain IP? So many options but none are really good or stable.
 
im sure i connected old sony/ericsson and motorola phones to freebsd via serial cable
that was in the time of proprietary sockets/cables, before micro usb was a popular thing (even before mini usb)
nokia required special software but other brands were working just like an external modem
 
I don't have anything to offer for FreeBSD but under Windows Sierra uses program called Sierra Watcher that is a connection manager. It also has SMS capability.

Huawei as mentioned also has a cellular connection manager but it uses a Web interface. I believe it does SMS too.
So it works on Linux. That is probably what I would try for desktop.

Is this for desktop usage?
 
See ALCATEL ONE TOUCH X220L. I have one in reserve. AFAIK, it supports AT commands and can be controlled as usb-to-serial port. Probably it will be able to read SMS.
 
I use the Huawei USB modem in my server to send me Zabbix and UPS notifications, it works like a charm.
I also tested it to receive and read SMS (not actively using it for that though).

Huwaei USB Modem
Just to add a bit more information, this doesn't need AT commands. The SMS could be accessed either via browser or with basic BASH script to get the data in XML format through the modem's IP.
 
So what you're saying is that the usb modem itself has a web interface that allows for SMS reading, amongst other stuff? I'm not even exactly sure how SMS are received at all on various devices. Do they constantly listen on some kind of GSM stream? Is that the same as receiving a call? And then who exactly accepts the message - a modem, some hardware down the line, is there a queue, are messages stored in a hardware buffer etc... When I don't know details like that, choosing anything is very difficult.

But having said that, I think Mikrotik solution I stumbled upon after your router suggestions is a good one. There's SSH access and documented CLI and the messages are very readily available without any cruft. You can say it's for personal use, I just want to check on those messages from time to time, remotely, maybe write a simple script to do email delivery to my inbox.
 
So what you're saying is that the usb modem itself has a web interface that allows for SMS reading, amongst other stuff?
Interesting to head that some cell modems have a web interface. The one I'm using (Telit via SixFab) does not, only an AT interface. At least as far as I've found in the documentation so far.

I'm not even exactly sure how SMS are received at all on various devices. Do they constantly listen on some kind of GSM stream? Is that the same as receiving a call?
Yes. Cell phones are in constant low-level contact with the nearest cell tower, mostly to tell the tower "I am here and I will be able to hear a broadcast". Towers then regularly send out a broadcast, which says "Hi, I have some traffic for 123-456-7890, if you hear this please come online". That traffic could then become a SMS, or a phone call, or just a request for "didn't hear from you in a while, tell me that you're still around".

And then who exactly accepts the message - a modem, some hardware down the line, is there a queue, are messages stored in a hardware buffer etc... When I don't know details like that, choosing anything is very difficult.
As far as I can tell from looking at the interface, the cell "phone" does have a persistent memory buffer for multiple SMS messages, and there seem to be commands to read and delete from these buffers. I didn't go into great detail on that: Since I need to set up IP connectivity over the cell modem anyway, I decided to not bother with SMS, but instead use traditional e-mail (SMTP and all that) once the IP connection is up.

You can say it's for personal use, I just want to check on those messages from time to time, remotely, maybe write a simple script to do email delivery to my inbox.
That might be easier to do if the cell phone provider has a service that allows e-mail based SMSes. In reality, SMS come from the cell provider (In the US, typically AT&T, Verizon and T-Mobile), and are held in their cloud during transit. These providers know how to interface to other services, right from their cloud. I know that in the US, the Twilio e-mail service had some SMS capability in its sendgrid product, but I never looked into the details. You might not need to use a cell phone or modem at all to integrate SMS.
 
So what you're saying is that the usb modem itself has a web interface that allows for SMS reading, amongst other stuff? I'm not even exactly sure how SMS are received at all on various devices. Do they constantly listen on some kind of GSM stream? Is that the same as receiving a call? And then who exactly accepts the message - a modem, some hardware down the line, is there a queue, are messages stored in a hardware buffer etc... When I don't know details like that, choosing anything is very difficult.

But having said that, I think Mikrotik solution I stumbled upon after your router suggestions is a good one. There's SSH access and documented CLI and the messages are very readily available without any cruft. You can say it's for personal use, I just want to check on those messages from time to time, remotely, maybe write a simple script to do email delivery to my inbox.

Yes, the Huawei USB dongle has a built-in web interface (and a router too with its own IP and DHCP server).

All information including SMS, DATA usage, etc is stored in the USB dongle. This can be viewed by accessing the dongle's IP through a web browser or a bash script.
 
There's package called smstools3, however I was unsuccessful to make it receive messages. That might have been a hardware limitation though.

Apart from dedicated USB devices, old mobile phones are also fine for SMS communication.
 
freebuser Are you sure about that? I think the mode you're talking about is called HiLink and it's restricted to IP protocol, in that mode it doesn't work with phone calls or SMSes at all.
 
Anyhow, I set up that Mikrotik and here are a couple of findings.
So RouterOS on Mikrotik appears to instruct the modem to poll the provider every few seconds with specific AT commands asking for new messages. Once there are new ones in the queue upstream, it would begin to receive exactly one SMS on each AT query and store it in its buffer which can have only 5 messages maximum. If the buffer overflows it will generate an error, but I'm not sure if unreceived messages stay in the queue. Need to dig way deep into those specifics. If the whole stack is set up correctly, upon each receipt the OS will store the message elsewhere and instruct the modem to delete it from its internal memory, and the cycle repeats. The messages arrive in a special PDU format which requires decoding. Mikrotik's own implementation doesn't handle that decoding well and there's no way I'm going to learn their scripting language, so I've set up remote syslogging of a gsm log to a FreeBSD box which is an insecure method but fits my purposes and now it's only a matter of finding a proper PDU parser and writing a shell script to automate the process.
 
freebuser Are you sure about that? I think the mode you're talking about is called HiLink and it's restricted to IP protocol, in that mode it doesn't work with phone calls or SMSes at all.
Absolutely. I am using it in my server to send me sms whenever zabbix trigger an issue.
I have also retrieved received messages and thought of using it to capture as an incoming message handler for my business but didn't get a chance to figure out if it supports MMS, so just using for SMS notifications for now.
 
This is the script I use:

Code:
#!/bin/sh
MODEM_IP="192.168.8.1"
/usr/local/bin/curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > /tmp/ses_tok.xml
/bin/chmod 777 /tmp/ses_tok.xml
COOKIE=`grep "SesInfo" /tmp/ses_tok.xml | cut -b 58-185`
TOKEN=`grep "TokInfo" /tmp/ses_tok.xml | cut -b 205-236`

if [ "$1" = "sms" ]; then
/usr/local/bin/curl -v http://$MODEM_IP/api/sms/send-sms -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"  --data "<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>$2</Phone></Phones><Sca></Sca><Content>$3</Content><Length>160</Length><Reserved>1</Reserved><Date>-1</Date></request>"

elif [ "$1" = "read" ]; then
curl -s -X POST "http://$MODEM_IP/api/sms/sms-list" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" -d "<request><PageIndex>1</PageIndex><ReadCount>10</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>" > /tmp/modem_status.xml
message=$(grep -r -E 'Phone|Content' /tmp/modem_status.xml | sed -e 's/<[^>]*>//g' | sed -e 's/^[ \t]*/------\n/g')
echo "$message\n------"

elif [ "$1" = "rssi" ]; then
curl -s -X GET "http://$MODEM_IP/api/device/information" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" > modem_status.xml
curl -s -X GET "http://$MODEM_IP/api/device/signal" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" >> modem_status.xml
wmode=$(cat modem_status.xml | grep workmode | sed -e 's/<[^>]*>//g')
rssi=$(cat modem_status.xml | grep rssi | sed -e 's/<[^>]*>//g')
echo "mode: $wmode"
echo "signal: $rssi"

fi
 
I see. Smart. So you have it as an IP device.

How does it all handle multiple incoming SMS messages? Is there a maximum after which the modem starts to delete older messages automatically? When you trigger "read", does it mark those messages as read so the next time you issue "read" you're not seeing the messages that were already processed by the script?
 
I see. Smart. So you have it as an IP device.

How does it all handle multiple incoming SMS messages? Is there a maximum after which the modem starts to delete older messages automatically? When you trigger "read", does it mark those messages as read so the next time you issue "read" you're not seeing the messages that were already processed by the script?

I only use it for sending SMS. I tested the receiving part but didn't have the need to utilise it.
 
Back
Top