Since I learnt how to send emails from my servers and desktop, I thought it would be useful to send SMS (Short Message Service) texts as well. No specific use cases yet, but I’m sure one day it’ll be needed…

After looking into smstools, Gammu, and loads of others, I was getting nowhere and ready to give up. But then, I remembered ADB. Like most people, I’ve got numerous Android phones knocking about, surely I could use an old Android phone + ADB to send an SMS.

I started off with my first Android phone, an HTC Desire. Even though this phone is now 11 years old, it still works perfectly and it’d be nice to give it something to do!

Android 2 (Gingerbread)

The first thing to notice is that we put the phone number in just as we’d type in to to the phone. No +44XXXXXXXXX needed here. So let’s start sending some SMS messages.

To send an sms with spaces, which is almost certainly required, we either escape each space character with a back slash, or far better, enclose the string in single quotes:

simon@computer:~$ adb shell service call isms 5 s16 "07123456789" i32 0 i32 0 s16 "'Here is some text with spaces but not escaped.'"
Result: Parcel(00000000    '....')
simon@computer:~$

I wondered if I could send the output of shell commands (yep):

simon@computer:~$ adb shell service call isms 5 s16 "07123456789" i32 0 i32 0 s16 "'$(uptime)'"

Here are some of the messages I received on my mobile. The last message was the uptime message above.

SMS received on phone

I also had a Nokia 5 in a drawer.

Android 9

simon@computer:~$ adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "+447123456789" s16 "null" s16 "Hello\ from\ your\ home\ computer." s16 "null" s16 "null"

As you can see, the syntax is different depending on your Android version. I’ve only just started scratching the surface with ADB, but there’s lots of potential for all sorts of helpful notifications.

I’ll probably write a new post once I’ve done some more experimenting.