Wait for SMS messages

Brendan Simon brendan.simon at ind-technology.com
Thu Jan 30 23:46:27 UTC 2025


IND.T Classification: Public

From: Dan Williams <dan at ioncontrol.co>
Sent: Thursday, 30 January 2025 3:39 AM

On Tue, 2025-01-28 at 12:05 +0000, Brendan Simon wrote:
>
> What's the best way to monitor and wait for SMS messages for
> processing?
> I'm using a Debian based system and python3.
> I was thinking of something involving systemd and/or a python package
> such asdbus_next.

With Python we'd typically use the bundled GObject introspection data
to directly work with libmm-glib. There are some examples in MM git:

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/tree/main/examples?ref_type=heads

I added an SMS watcher example here:

https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1284

Hopefully that's easy enough to follow, all questions welcome.

It does require a bit of D-Bus knowledge to fully understand the flow,
but even without that you just plug your own code into the SmsWatcher's
show() method and that'll run for any "new" SMS from any modem. I say
"new" in quotes because it'll also print out any messages in the modem
at the time it's run, then wait for new ones from the network or local
addition.

I tried the SMS watcher example.
It seems to work mostly, however in the code snippet below, the new message does not appear in the list from list_sysnc(), and therefore the sms object is never added to self.messages.
Is this expected or is there something else missing?

What is the purpose of SmsWatcher?  Why do I need to "watch" SMS messages once we have processed them with MessagingWatcher?
Is it for things like handling message deletion or other events?

```python
    def on_sms_added(self, messaging, path, received):
        for sms in self.iface.list_sync():
            if sms.get_path() == path:
                #>>> NEVER GETS HERE AS THE NEW MESSAGE DOES NOT APPEAR IN THE RETURNED LIST OF MESSAGES !!!
                # Watch this SMS
                self.messages[sms.get_path()] = SmsWatcher(sms)
```

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/modemmanager-devel/attachments/20250130/8c2225a3/attachment-0001.htm>


More information about the ModemManager-devel mailing list