From c320e50753e544e3277280ee53b10eadcdd46fdb Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 29 Jan 2025 10:20:18 -0600 Subject: examples: add sms-watch-python Add an example that watches for and prints all SMS messages of all modems. Signed-off-by: Dan Williams --- examples/modem-watcher-python/ModemWatcher.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'examples/modem-watcher-python/ModemWatcher.py') diff --git a/examples/modem-watcher-python/ModemWatcher.py b/examples/modem-watcher-python/ModemWatcher.py index b7cf4e7c..c42d26a7 100644 --- a/examples/modem-watcher-python/ModemWatcher.py +++ b/examples/modem-watcher-python/ModemWatcher.py @@ -28,7 +28,7 @@ class ModemWatcher: The ModemWatcher class is responsible for monitoring ModemManager. """ - def __init__(self): + def __init__(self, modem_cb): # Flag for initial logs self.initializing = True # Setup DBus monitoring @@ -40,6 +40,7 @@ class ModemWatcher: # IDs for added/removed signals self.object_added_id = 0 self.object_removed_id = 0 + self.modem_callback = modem_cb # Follow availability of the ModemManager process self.available = False self.manager.connect('notify::name-owner', self.on_name_owner) @@ -109,6 +110,8 @@ class ModemWatcher: obj.get_object_path()) else: modem.connect('state-changed', self.on_modem_state_updated) + if self.modem_callback != None: + self.modem_callback(obj, True) def on_object_removed(self, manager, obj): """ @@ -116,3 +119,6 @@ class ModemWatcher: """ print('[ModemWatcher] %s: modem unmanaged by ModemManager' % obj.get_object_path()) + if self.modem_callback != None: + self.modem_callback(obj, False) + -- cgit v1.2.3-70-g09d2