I have long used a cellphone connected via USB to our network management system (running Nagios) for page/text/sms'ing, but we recently got a notice from ATT that our ancient Samsung 2G phone was no longer going to be supported. We originally used some software called
gnokii for this purpose, but over time moved to
gammu (I believe we had originally been using a Nokia phone for this purpose).
Looking at the current state of those two pieces of software, Gammu has been updated more recently but it's author has stated he will not support Android. The pickings are pretty thin, and it is difficult to get to the bottom of if your non-Android/Non-Apple phone will be supported under the software and your provider. So I explored another option, and that ended up being Android and ADB.
For initial testing, I plugged my HTC One M8 into my desktop Ubuntu 14.04 Linux box and started testing. This required me to turn on USB Debugging on my phone and to install the android-tools-adb package. There are many blogs that cover how to do this, my only advice is don't bother with the SDK steps if this is all you are doing. I found Innokenty Sokolov's blog entry about
sending sms via adb shell from bash and used that as the initial basis of my work.
After the initial proof of concept, we talked to AT&T about our eligible free upgrades and went with the HTC Desire 610.
I eventually expanded that script to deal with screen blanking, ICS+ changes in screen blanking activity, and added locking with retries. And it eventually ended up something like:
#!/bin/bash
# Initial work from http://qbbr.io/blog/send-sms-via-adb-shell-from-bash.html
# using: ./sendsms.sh 89999999999 "Hello, im SMS from bash"
#
lockfile-create --use-pid --retry 5 /tmp/sendsms
ADB=/usr/bin/adb
# KEYCODE_POWER
$ADB shell input keyevent 26
# KEYCODE_HOME
$ADB shell input keyevent 3
# open form and fill them
$ADB shell am start -a android.intent.action.SENDTO -d sms:$1 --es sms_body "$2" --ez exit_on_sent true
# sleep 1 sec
sleep 1
# KEYCODE_DPAD_RIGHT
$ADB shell input keyevent 22
# KEYCODE_ENTER
$ADB shell input keyevent 66
# KEYCODE_POWER
$ADB shell input keyevent 26
This seems to be working fairly reliably, and allows our NMS system to stack a sufficient number of texts, though it doesn't have quite the elegance of Gammu's queueing, it is getting the job done.