<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#000000;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Center">
IND.T Classification: Public<br>
</p>
<br>
<div>
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<b>From:</b> Dan Williams <dan@ioncontrol.co></div>
<div dir="ltr" id="divRplyFwdMsg">
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<b>Sent:</b> Thursday, 30 January 2025 3:39 AM<br>
<br>
</div>
<div class="elementToProof" style="margin: 0px 40px; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
On Tue, 2025-01-28 at 12:05 +0000, Brendan Simon wrote:<br>
><br>
> What's the best way to monitor and wait for SMS messages for<br>
> processing?<br>
> I'm using a Debian based system and python3.<br>
> I was thinking of something involving systemd and/or a python package<br>
> such asdbus_next.<br>
<br>
With Python we'd typically use the bundled GObject introspection data<br>
to directly work with libmm-glib. There are some examples in MM git:<br>
<br>
<a href="https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/tree/main/examples?ref_type=heads" id="OWAbce95aae-acd9-03a9-0b36-d3659ef441a0" class="OWAAutoLink" data-auth="NotApplicable">https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/tree/main/examples?ref_type=heads</a><br>
<br>
I added an SMS watcher example here:<br>
<br>
<a href="https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1284" id="OWA5cb8026a-4462-5821-1832-18134354b85d" class="OWAAutoLink" data-auth="NotApplicable">https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/1284</a><br>
<br>
Hopefully that's easy enough to follow, all questions welcome.<br>
<br>
It does require a bit of D-Bus knowledge to fully understand the flow,<br>
but even without that you just plug your own code into the SmsWatcher's<br>
show() method and that'll run for any "new" SMS from any modem. I say<br>
"new" in quotes because it'll also print out any messages in the modem<br>
at the time it's run, then wait for new ones from the network or local<br>
addition.</div>
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
I tried the SMS watcher example.<br>
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.</div>
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Is this expected or is there something else missing?</div>
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
What is the purpose of SmsWatcher? Why do I need to "watch" SMS messages once we have processed them with MessagingWatcher?<br>
Is it for things like handling message deletion or other events?</div>
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
```python</div>
<div class="elementToProof" style="line-height: 19px; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
def on_sms_added(self, messaging, path, received):</div>
<div class="elementToProof" style="line-height: 19px; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
for sms in self.iface.list_sync():</div>
<div class="elementToProof" style="line-height: 19px; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
if sms.get_path() == path:</div>
<div class="elementToProof" style="text-align: left; text-indent: 0px; line-height: 19px; background-color: rgb(255, 255, 255); margin: 0px; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
#>>> NEVER GETS HERE AS THE NEW MESSAGE DOES NOT APPEAR IN THE RETURNED LIST OF MESSAGES !!!</div>
<div class="elementToProof" style="line-height: 19px; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
# Watch this SMS</div>
<div class="elementToProof" style="line-height: 19px; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
self.messages[sms.get_path()] = SmsWatcher(sms)</div>
<div class="elementToProof" style="line-height: 19px; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
```</div>
<div class="elementToProof" style="font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<br>
</div>
</div>
</div>
</body>
</html>