Python sample to send SMS

Aleksander Morgado aleksander at aleksander.es
Sun Jan 10 15:46:02 PST 2016


On Sun, Jan 10, 2016 at 9:25 PM, Brendan Simon (eTRIX)
<brendan.simon at etrix.com.au> wrote:
> I'm looking for a Python example/sample/snippet to send an SMS message to a
> mobile phone.
>
> All I can find is older code that uses EnumerateDevices() method.
>
>     e.g.
> https://github.com/miurahr/ModemManager/blob/master/test/mm-send-sms.py
>
> which appears to be old and obsolete, and not supported on my system (Debian
> Jessie, modemmanager v 1.4).
>
> I've read some of the ModemManager and DBus docs (not that easy going).
> All I can work out is that the API is now more generic but I can't find the
> right set of methods to use.  e.g. to get a list of modems.
>
> Is there an equivalent to the sample above?

The modem watcher example will give you an insight on how to get the
list of modem objects (we use the standard DBus ObjectManager
interface):
http://cgit.freedesktop.org/ModemManager/ModemManager/tree/examples/modem-watcher-python

Once you have the modem to use, you'll need to (at least):

1) Modem.Enable()
http://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Modem.html#gdbus-method-org-freedesktop-ModemManager1-Modem.Enable

2) Modem.Messaging.Create()   // returns DBus path of newly created SMS
http://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Modem.Messaging.html#gdbus-method-org-freedesktop-ModemManager1-Modem-Messaging.Create

3) SMS.Send()
http://www.freedesktop.org/software/ModemManager/api/latest/gdbus-org.freedesktop.ModemManager1.Sms.html#gdbus-method-org-freedesktop-ModemManager1-Sms.Send

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list