Received SMS with python
Colin Helliwell
colin.helliwell at ln-systems.com
Tue Sep 19 11:36:15 UTC 2017
> On 19 September 2017 at 09:03 colin.helliwell at ln-systems.com wrote:
>
> I came across an old example (get-sms.py) using dbus, but are there any
> examples via gi/Glib for reading and deleting received SMSs (and any events
> that can be hooked for catching the reception)?
> I'm guessing the ModemMessaging class is the starting point? Then, in the
> Sms class, when would be the times to use the 'dup_' functions instead of
> 'get_'?
> Thanks
>
So far I've proven out some *basic* principles (sensible checking omitted for clarity) on a python command line:
import gi
gi.require_version('ModemManager', '1.0')
from gi.repository import GLib, GObject, Gio, ModemManager
connection = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
manager = ModemManager.Manager.new_sync (connection, Gio.DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)
for obj in manager.get_objects():
modem.get_manufacturer()
msging = obj.get_modem_messaging()
rcvd = msging.list_sync()
for m in rcvd:
print m.get_number(), m.get_timestamp(), '"%s"' % m.get_text()
But I have noticed that if a new SMS is then received, this doesn't get reflected in list_sync() - I seem to have to repeat all the way back to the Manager.new_sync() instantiation for it to ripple through?
More information about the ModemManager-devel
mailing list