# Cell modem to receive SMS?



## Buck (Dec 16, 2022)

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?


----------



## sko (Dec 16, 2022)

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.


----------



## ralphbsz (Dec 16, 2022)

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.


----------



## covacat (Dec 16, 2022)

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


----------



## Buck (Dec 16, 2022)

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.


----------



## Buck (Dec 16, 2022)

Oh look, Mikrotik can do that. https://wiki.mikrotik.com/wiki/Manual:Tools/Sms
Better than Huawei for sure.


----------



## covacat (Dec 16, 2022)

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


----------



## Phishfry (Dec 16, 2022)

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?


----------



## freebuser (Dec 17, 2022)

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


----------



## 6502 (Dec 17, 2022)

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.


----------



## freebuser (Dec 17, 2022)

freebuser said:


> 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.


----------



## 6502 (Dec 17, 2022)

Browser is not a good idea for automation.






						SMS Tutorial: Using the +CMGR AT Command to Read an SMS Message from a Message Storage Area
					

Learn how to use the +CMGR AT command to read an SMS message from a message storage area. Learn the syntax of the +CMGR AT command in SMS text mode.




					www.developershome.com


----------



## Buck (Dec 17, 2022)

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.


----------



## ralphbsz (Dec 17, 2022)

Buck said:


> 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.


----------



## freebuser (Dec 17, 2022)

Buck said:


> 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.


----------

