7 ms·
Simple Raspberry Pi Powered SMS Gateway
- offbyone 5y agoThe 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 5y agoHere'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 5y agoIt 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 5y agoThis 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: ?
- marban 5y agoI 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.
- deleted 5y ago[deleted]
- toun 5y agoAt 6 cents/SMS, I find Twilio and similar services way too expensive. Compare that to the unlimited SMS plan that I can get for 2€/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 5y agoFree's €2 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.
- DeathArrow 5y agoI can send unlimited SMS for free with my 5€ monthly plan, so why should I pay?
- geek_at 5y agoHey 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?
- allisfalafel 5y agoI'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 5y agoIf 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.
- dvtrn 5y agoIf 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 https://www.twilio.com/learn/voice-and-video/toll-fraud
- daneel_w 5y agoCommon 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 5y agoYeah 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.
- psanford 5y agoThese 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).
- 71a54xd 5y agoAn 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.
- dthakur 5y agoI've used Sixfab before. https://sixfab.com/product/raspberry-pi-cellular-iot-kit-lte-m/ https://sixfab.com/product/raspberry-pi-cellular-iot-kit-lte...
- mobilio 5y agoAlso Blues.IO: https://blues.io/products/notecarrier/notecarrier-pi/ https://blues.io/products/notecarrier/notecarrier-pi/
- alias_neo 5y agoI 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.
- jll29 5y ago> 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 5y agoLooking 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 5y agoYou 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 time¹ irrespective of top-up activity². 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
- f311a 5y agoSome dongles can be hackable so the RPi is not a necessary requirement.
- hoistbypetard 5y agoDoes 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 5y agoI 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 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-Talk-1000-Text-200MB/133196831828 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 5y agoUS Mobile has very cheap plans, and you can build your own.
- jqpabc123 5y agoUltramobile PayGo - $3 per month on a month to month basis, 100 mins talk, 100 texts, 100 mb data.
- jacob019 5y agoI 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.
- tyingq 5y agoThat'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.
- nyadesu 5y agoIs there something similar but for Whatsapp?
- trees101 5y agohttps://github.com/AsamK/signal-cli https://github.com/AsamK/signal-cli
- geek_at 5y agoFunnily 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 5y ago> 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 5y agohttps://github.com/LibreSignal/LibreSignal/issues/37#issuecomment-217211165 https://github.com/LibreSignal/LibreSignal/issues/37#issueco...
- jraph 5y ago> 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/ https://gitlab.com/kop316/mmsd/
- hellelujah 5y agoiirc, i can send AT command directly to ttyUSB0 https://openwrt.org/docs/guide-user/advanced/sms-from-shell https://openwrt.org/docs/guide-user/advanced/sms-from-shell no need to install gammu etc
- slicktux 5y agoI’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. :/
- deleted 5y ago[deleted]
- zamadatix 5y agoShouldn'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.
- slicktux 5y agoIt’s been a while since I’ve checked ThingSpace but looking at it now they have the SixFab hat listed.. Few years ago I bought the 4G hat from SixFab because it was marketed as being Verizon certified but it never worked. I’ll have to look into things again…
- korse 5y agoWhy 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 5y agoSending 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 5y agoI’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.
- s0rce 5y agoId love something like this with meshtastic/Lora support to link a mesh to cell via SMS
- INTPenis 5y agoJust 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.
- orixilus 5y agoCan you point me to some brand who sell those?
- INTPenis 5y agoNot that one, it was many years ago and I have moved on from that department since. But it was also purchased in Sweden, from a Swedish retailer, so not sure what good this would do you. A quick google gives me Induo [1] who make industrial 3G modems, with serial connection among others. 1. https://www.induo.com/produkt/modem/3g-modem/ https://www.induo.com/produkt/modem/3g-modem/
- albertgoeswoof 5y agoWhats the max throughput here? Would the carrier be the bottleneck?
- jqpabc123 5y agoI have read that the typical consumer wireless account is for "personal use" and is limited to a "few hundred" SMS messages per day. The service provider may define exactly what "personal use" means at their discretion.
- lamnk 5y agoSure, they will throttle or suspend your SIM if you send out an abnormal number of SMSs to prevent spam.
- tiernano 5y agoMy first though when i read this was "um... Twilio, Telnyx and Signalwire all do texting... why do i need... (facepalm) network down... ahhh!!! Bookmarked!" very handy!
- DavidMankin 5y agoGammu seems like an ideal candidate for a Home Assistant integration or add-on. Could use incoming SMS as triggers and outgoing as notification methods.
- mikece 5y agoI wonder if I can integrate this with a matrix server so I can send/receive SMS from a carrier-issued SIM via a Matrix client like Element.
- djbeadle 5y agoThis is great for situations where your Raspberry Pi doesn't have any other internet access. But if you do have and ethernet drop or Wi-Fi you can also use your carrier's email to SMS gateway! For example "[YOUR-PHONE-NUMBER]@txt.att.net" https://www.dialmycalls.com/blog/send-text-messages-email-address https://www.dialmycalls.com/blog/send-text-messages-email-ad...
- merlyn 5y agoAs long as it isn't critical that your carrier's gateway is operating normally. I have a customer that routinely emails through various carier's SMS gateways, and has reports several times a month that their messages aren't getting through and ask us to verify everything was handed off correctly. It always was handed off good, but their gateway is backlogged or broken for that half day or day. This echos my direct experience years ago (before I made my own solution similar to this setup).
- intrasight 5y agoBack in the day - 15 years ago - I built web apps for clients that sent SMS by merely sending an email to the email alias for that SMS destination. Is that no longer possible?
- gorgoiler 5y agoIs there a generic app I can install on my phones that lets me push notifications to them from curl? It would be incredibly useful if Apple (or a third party app) gave people a way to POST to some secret URL and have the form data show up as a notification. I can think of a billion one-off projects that would benefit from this. The smoker/ribs are done, the pool is up to temperature, a post-interview email from that recruiter has finally arrived, etc.
- swiley 5y agoNo. That would take value add away from apple et all. Install Xorg.
- Karrot_Kream 5y agoIf you're on Android, there's Gotify [1]. You can self-host the server and install the app on either the Play Store, F-Droid, or just by downloading the APK. [1]: https://gotify.net/ https://gotify.net/
- genericacct 5y agoYou can probably achieve the same effect with the telegram API and an afternoon of coding.
- neurostimulant 5y agoThere is Push Bullet but they removed it from apple app store last year. Too bad. It's actually fit your use case very well. https://docs.pushbullet.com/#create-push https://docs.pushbullet.com/#create-push
- gorgoiler 5y ago[replying to myself] Notifications from macOS are possible with osascript: https://github.com/lodestone/ims/blob/4bb2566224af53904c7267c8a48cff4e0afd501f/lib/ims/sender.rb#L45 https://github.com/lodestone/ims/blob/4bb2566224af53904c7267... Or in brief: osascript -e 'tell application "Messages" to send "Hello World" to buddy "J Appleseed"'
- hayyyyydos 5y ago
- babayega2 5y ago5 years ago, I built the same SMS gateway without using the AT command "Explicitly" [0], but by letting Kannel handle that for me. Thus, I had an endpoint generally usable. Kannel is still used by Mobile Network Operators in Africa. [0]: https://hackernoon.com/build-an-sms-center-with-python-kannel-and-a-gsm-modem-9c0d29560d82 https://hackernoon.com/build-an-sms-center-with-python-kanne...