[HN Gopher] Simple Raspberry Pi Powered SMS Gateway
       ___________________________________________________________________
        
       Simple Raspberry Pi Powered SMS Gateway
        
       Author : DeathArrow
       Score  : 155 points
       Date   : 2021-12-05 15:31 UTC (7 hours ago)
        
 (HTM) web link (blog.haschek.at)
 (TXT) w3m dump (blog.haschek.at)
        
       | INTPenis wrote:
       | Just a heads up to anyone thinking of doing this in prod.
       | 
       | We had a USB connected 3G dongle as SMS modem for years, every
       | other month someone had to head over to the DC and re-seat the
       | thing. Because it just stopped working. I don't think they're
       | designed to be connected 24/7.
       | 
       | We eventually switched to an Ethernet connected SMS modem. Much
       | more reliable, and it was actually made for production, had a
       | longer antenna you could fix on top of a rack cabinet.
        
       | nyadesu wrote:
       | Is there something similar but for Whatsapp?
        
         | trees101 wrote:
         | https://github.com/AsamK/signal-cli
        
           | geek_at wrote:
           | Funnily enough that was the route I was initially going to go
           | but I got scared because I read that the project is a
           | violation of the ToS and your number _might_ get blocked if
           | you use these third party clients.
           | 
           | That's why I wrote the article on how to do it via SMS with a
           | Pi. I tried to send myself notifications from NodeRed
        
             | cuu508 wrote:
             | > I read that the project is a violation of the ToS
             | 
             | Could you find that source? Curious precisely what part of
             | ToS it violates.
        
               | ComputerGuru wrote:
               | https://github.com/LibreSignal/LibreSignal/issues/37#issu
               | eco...
        
       | korse wrote:
       | Why not have even less moving parts? Nearly every SMS/MMS address
       | is backed by an email address. Look up email to sms gateway list
       | and go for it, sans dongle.
        
         | rahimnathwani wrote:
         | Sending an email requires a data connection, which might not be
         | available when the power goes out.
         | 
         | When there's a local power cut, most people switch to using
         | cellular data, overloading the local backhaul. The same problem
         | doesn't affect outbound SMS.
        
       | josteink wrote:
       | I'm not sure if anyone actually looked at the code for the PHP-
       | based API-gateway, but as a TLDR: it's trivially injectable to
       | give RCEs and not really hardeneded nor is input sanitized
       | properly at all.
       | 
       | I realize this is meant for deployment on a local trusted
       | network, but I still think that's worth putting somewhere in big
       | bold fonts.
        
       | marban wrote:
       | I was looking to get a dedicated Waveshare GSM HAT for the Pi but
       | Twilio is so dirt cheap that I never really got into messing
       | around with a DIY solution.
        
         | DeathArrow wrote:
         | I can send unlimited SMS for free with my 5EUR monthly plan, so
         | why should I pay?
        
           | geek_at wrote:
           | Hey DeathArrow.
           | 
           | Very very strange I'm the author of the article and I created
           | this post and got the first few comments then when I reloaded
           | the page it says you posted it and I can't upvote the post
           | like it was my own.
           | 
           | What gives? Do you work for ycombinator or somehing? Or did
           | you post it shortly before me and the mods combined our posts
           | and attributed it to you?
        
             | bitxbitxbitcoin wrote:
             | Mods combining posts and choosing the wrong winner sounds
             | most plausible. Just email them and they'll make the
             | correction because they do a dang good job.
        
               | actually_a_dog wrote:
               | > ...a dang good job.
               | 
               | I see what you did there.
        
         | [deleted]
        
         | toun wrote:
         | At 6 cents/SMS, I find Twilio and similar services way too
         | expensive. Compare that to the unlimited SMS plan that I can
         | get for 2EUR/month here in France, and setting up a gateway
         | like that becomes very attractive.
         | 
         | In my experience it's very unstable however. Sending and
         | receiving SMS can take anywhere from 5 to 30 seconds, and the
         | modem can't do both at the same time. I tried configuring
         | gammu's timeouts, loop delays and whatnot, but couldn't get
         | something that's reliable enough for production.
        
           | littlestymaar wrote:
           | Free's EUR2 per month is probably one of the best mobile deal
           | in the world :). Beware though, last I checked using their
           | SIM card in something not a mobile phone was against Fred's
           | ToS. I don't know if it have since changed.
        
       | allisfalafel wrote:
       | I'd love to get a setup like this with voice calls also
       | supported. I'd like to be able to recieve my calls and texts on
       | any device as I can with email/irc/matrix etc
        
         | daneel_w wrote:
         | If you don't absolutely need this to originate from a mobile
         | subscription with your name on it, you can for far less money
         | get a DID ("direct inwards dial"; the term colloquially means a
         | virtual mobile number) with any of the numerous VoIP providers
         | out there. Most of them not only provide in- and outbound calls
         | on those DIDs, but also ditto for SMSes. The interface for
         | voice calls is almost exclusively SIP, and for SMSes it's
         | usually an HTTP-based API.
        
           | psanford wrote:
           | These services are great, except for the sites with mandatory
           | sms 2fa that refuse to send to voip phone numbers (I'm
           | looking at you, Apple).
        
           | dvtrn wrote:
           | If you go this route, make sure you absolutely know how to,
           | and that you absolutely lock this down. SIP toll fraud is
           | still a problem and if it happens to you, it can get
           | _destructively expensive_.
           | 
           | https://www.twilio.com/learn/voice-and-video/toll-fraud
        
             | daneel_w wrote:
             | Common sense obviously applies. With a cell phone, don't
             | call back to unknown numbers ringing once or twice
             | ("wangiri"). With a SIP trunk, don't allow remote anonymous
             | access.
        
               | dvtrn wrote:
               | Yeah I suppose it's really easy to call this common-
               | sense, it probably _should_ be common-sense.
               | 
               | Yet at the same time, if it _were_ common-sense in
               | practice, I probably wouldn 't have a job.
        
       | jacob019 wrote:
       | I wrote a similar project this year that runs on my router, in
       | python. I communicates with ModemManager over dbus. I use a
       | Quectel EC25 LTE modem, it forwards incoming SMS to an https
       | webhook as JSON. It listens to http requests to provide an
       | outgoing SMS gateway. It also provides automatic failover for the
       | WAN link, for when Comcast craps out. On another machine I have
       | python script that bridges with prosody, to provide an SMS-XMPP
       | bridge. It works well, receives messages faster than the SMS api
       | services that I have tried, and since it's a real mobile number
       | it works everywhere for 2FA.
       | 
       | ModemManager is great, abstracting away manufacturer specific
       | implementation details. The same script is also working on a Pi
       | connected to The Franklin T9 hotspot that I got for free from
       | T-Mobile, running in QMI mode.
       | 
       | I wish it were easier to bridge voice with asterisk, but from
       | what I have seen it is necessary to run asterisk on the same
       | device and communicate directly with the modem, with modem
       | specific tweaks and custom built modules.
        
       | hellelujah wrote:
       | iirc, i can send AT command directly to ttyUSB0
       | 
       | https://openwrt.org/docs/guide-user/advanced/sms-from-shell
       | 
       | no need to install gammu etc
        
       | slicktux wrote:
       | I'd be curious to know what carriers I could use with the dongle
       | here in the USA..? I've been trying to make an IoT project and
       | being that T-Mobile is shutting down their 3G GSM there's only a
       | few IoT devices that are licensed and approved for use with
       | Verizon and AT&T for the 4G band. :/
        
         | zamadatix wrote:
         | Shouldn't be anything special to what you were doing with 3G,
         | there are dozens of cheap 4G dongles or hat and certification
         | isn't really any more special (heck Verizon even recommends and
         | shows how to set up and configure a particular $30 5G/4G modem
         | they connect to a Pi in their ThingSpace tutorial).
         | 
         | As far as plans every major carrier has 4G IoT plans, prepaid
         | or not depending on what you want. Also look into places like
         | Databalaze if you're doing something at scale commercially.
        
         | [deleted]
        
       | offbyone wrote:
       | The article is interesting in general, but this line really needs
       | more than "works like a charm": `usb_modeswitch -W -v 12d1 -p
       | 14fe -K -P 14ac -M
       | "55534243000000000000000000000011060000000000000000000000000000"`
       | 
       | I mean, I believe you, but ... what on earth IS all of that?
        
         | tyingq wrote:
         | Here's what it sounds like. Most of these types of devices
         | (USB/3G) are "multimode" devices. That is, they can act like
         | either USB storage or a USB 3G/4G device. On Windows, that's
         | handy because it can come up as storage and then the end user
         | can install the drivers right from the device, and the drivers
         | then handle the "mode switching" from storage to 3G/4G-device.
         | It's basically a way to bootstrap operation without requiring
         | driver downloads.
         | 
         | This "usb_modeswitch" program handles that for linux. It sniffs
         | the USB traffic and switches the mode to 3G/4G for you. All the
         | crazy args are whatever was in the Windows config file. The -v
         | 12d1 is the "VID" (vendor ID) of the device to sniff traffic
         | for. The -p arg is similar, but the "PID" (product ID). The -P
         | 14ac is the "PID" to switch to to get from storage to 3G/4G
         | device. The -M <long-string> is the magic payload sent to the
         | device to make it switch.
        
           | ajsnigrutin wrote:
           | It has to be said here, that usb_modeswitch software already
           | recognises most modems and has those magic strings saved in a
           | file, and does the switch automagically.
           | 
           | Only if you have a relatively new or rare modem, you need to
           | find the magic string yourself (or even reverse engineer it
           | from a windows setup), to make it work.
        
         | numpad0 wrote:
         | This is a USB Mass Storage SCSI Command Block Wrapper packet as
         | far as I can google out. Content looks like "Test Unit Ready
         | 0001 0001 10 flag=true link=false". Could be completely wrong.
         | Thank you for pointing this out, this is interesting.
         | 
         | 55 53 42 43: "USBC"
         | 
         | 00 00 00 00: CBW Tag
         | 
         | 00 00 00 00: Transfer length
         | 
         | 00 00 00 00: CBW direction, LUN, CBW CB length, CBW Command
         | Block
         | 
         | 00 00 00 11: CBW CB(cont.)
         | 
         | 06 00 00 00: (same)
         | 
         | 00 00 00 00: (same)
         | 
         | 00 00 00 00: (same)
         | 
         | 00 00 00 : (same)
         | 
         | ---
         | 
         | 00 00 00 00 11 06: TUR LUN0 RSVD RSVD RSV1 0001 0110
         | 
         | 00 00 00 00 00 00: TUR LUN0 RSVD RSVD RSVD 00RS VD00
         | 
         | 00 00 00 00 00 00: TUR LUN0 RSVD RSVD RSVD 00RS VD00
         | 
         | 00 00: ?
        
       | jraph wrote:
       | > MMS or Multimedia Messages are supported by gammu but they are
       | stored in a binary format I have yet to find documentation on how
       | to make something usable out of it for download. Any info in it
       | is greatly appreciated.
       | 
       | You could look at this implementation: mmsd-tng [1]. It is used
       | to handle MMSes on the PinePhone for instance.
       | 
       | [1] https://gitlab.com/kop316/mmsd/
        
       | albertgoeswoof wrote:
       | Whats the max throughput here? Would the carrier be the
       | bottleneck?
        
       | 71a54xd wrote:
       | An LTE-M pi-hat would be awesome! Usually the biggest challenge
       | for projects like this is to find cheap and available modems that
       | can actually be used with reasonable GSM carriers.
        
         | mobilio wrote:
         | Also Blues.IO:
         | 
         | https://blues.io/products/notecarrier/notecarrier-pi/
        
         | dthakur wrote:
         | I've used Sixfab before. https://sixfab.com/product/raspberry-
         | pi-cellular-iot-kit-lte...
        
       | alias_neo wrote:
       | I made something similar a few years back with a Pi 1 and a GSM
       | "hat".
       | 
       | It came with a C SDK so I had to write AT commands to communicate
       | directly with the modem and it worked great until I didn't need
       | it anymore.
       | 
       | Its purpose was to text me when my power or internet connection
       | went down at home then I could respond with commands such as to
       | shutdown the servers etc.
       | 
       | When power/network came back it would text me the new address so
       | I wouldnt need an outside service for DDNS.
       | 
       | The biggest challenge with the whole setup was finding a SIM from
       | a provider who would let me top it up once per year and maybe
       | send half a dozen texts in that time without deactivating the
       | SIM, for a reasonable price.
        
         | fibbberMEN wrote:
         | I like the country wide LoRa networks that are coming up
         | helping with this purpose, all you need is like 1kb per month
         | lol
        
         | jsharkey wrote:
         | Instead of paying for a separate SIM, I've been piggybacking on
         | the "data only" SIMs that Google Fi let's you add to a normal
         | subscription. No extra per-SIM fees, and you just pay for
         | whatever data it uses at $10/gb.
         | 
         | More details on my modem, monitoring setup, and IPMI backhaul
         | strategy using Wireguard here: http://jsharkey.org/ipmi/
        
           | sneak wrote:
           | It surprises me how many people are willing to let Google
           | know their home address.
        
             | throaway46546 wrote:
             | They already know.
        
             | godelski wrote:
             | You don't need Google Fi for Google to know your home
             | address. An Android phone will do that. Or Chrome. Or
             | really just broadcasting wifi. Really the problem is you
             | have a home address and someone will sell it to Google.
        
         | jll29 wrote:
         | > The biggest challenge with the whole setup was finding a SIM
         | from a provider who would let me top it up once per year and
         | maybe send half a dozen texts in that time without deactivating
         | the SIM, for a reasonable price
         | 
         | Good point - so-called "pre-paid" SIMs seem to be hidden
         | subscriptions nowadays. Does anyone have a table of suitable
         | low-usage, long-term SIM vendors?
        
           | sbarre wrote:
           | Looking at B2B IoT services is one way to find prepaid SIM
           | plans that don't require monthly top-ups, but usually you
           | have to buy 5+ SIMs so it doesn't necessarily fit the single-
           | device use-case...
        
           | dspillett wrote:
           | You might want to say what location you are in for a truly
           | useful answer.
           | 
           | In the UK at least most providers keep the SIM active if it
           | sees some activity in a given space of time1 irrespective of
           | top-up activity2. So if "low" use stretches as far as one
           | text every month or two maybe just have it send an "I'm still
           | here" message regularly. Also acts as a double-check that not
           | getting alerts means all is OK instead of that the alerting
           | service is broken.
           | 
           | 1: the GiffGaff one I used for pure data for a week-and-a-
           | half when my landline was down in2020, shut off after three
           | months and a few nagging texts IIRC
           | 
           | 2: though if you don't top-up once per month you usually drop
           | onto the basic tariff, so no more "unlimited texts", but if
           | you are topping up that infrequently that is probably fine
        
             | actually_a_dog wrote:
             | What would be the answer in the US?
        
         | trees101 wrote:
         | A good free way to achieve this is to use Signal. This project
         | https://github.com/AsamK/signal-cli enables you to send Signal
         | messages from the command line, including from Raspberry Pis.
         | It obviously needs an internet connection to work, but has the
         | added bonus of being more secure than SMS.
        
           | bee_rider wrote:
           | Neat tech, but probably not super appropriate for this
           | person's particular application, which involved detecting
           | network outages.
        
       | tyingq wrote:
       | That's pretty straightforward and nice. I'm curious if there are
       | some good references to where the cheapest US SIM+plan would be
       | if you only care about sending SMS messages.
        
       | f311a wrote:
       | Some dongles can be hackable so the RPi is not a necessary
       | requirement.
        
       | hoistbypetard wrote:
       | Does anyone know of an inexpensive plan in the US to use with a
       | setup similar to this that sends dozens of text messages/month?
        
         | vgeek wrote:
         | I was investigating solutions for sensor SMS notifications &
         | the best IoT type SIM plan that I came across was
         | https://www.hologram.io/pricing/flexible-data . $1.50/line per
         | month, $0.19/outbound SMS, data is pricey.
         | 
         | If you need more SMS, the next cheapest I've used is RedPocket
         | Mobile-- https://www.ebay.com/itm/2-50-Mo-Red-Pocket-Prepaid-
         | Plan-200... - $30/yr for 200 voice/1000 texts/200mb per month
         | on T-Mobile's network.
        
           | BenjiWiebe wrote:
           | US Mobile has very cheap plans, and you can build your own.
        
       | s0rce wrote:
       | Id love something like this with meshtastic/Lora support to link
       | a mesh to cell via SMS
        
       ___________________________________________________________________
       (page generated 2021-12-05 23:00 UTC)