aboutsummaryrefslogtreecommitdiff
path: root/examples/modem-watcher-python
diff options
context:
space:
mode:
authorDan Williams <dan@ioncontrol.co>2025-01-29 10:20:18 -0600
committerAleksander Morgado <aleksander@aleksander.es>2025-02-17 21:57:33 +0000
commitc320e50753e544e3277280ee53b10eadcdd46fdb (patch)
tree570c976270bf174df86badc42bd13a3e1a7eb333 /examples/modem-watcher-python
parentbc7198df8a3217d29c936fccde66820774228e30 (diff)
examples: add sms-watch-python
Add an example that watches for and prints all SMS messages of all modems. Signed-off-by: Dan Williams <dan@ioncontrol.co>
Diffstat (limited to 'examples/modem-watcher-python')
-rw-r--r--examples/modem-watcher-python/ModemWatcher.py8
-rwxr-xr-xexamples/modem-watcher-python/modem-watcher-python2
2 files changed, 8 insertions, 2 deletions
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)
+
diff --git a/examples/modem-watcher-python/modem-watcher-python b/examples/modem-watcher-python/modem-watcher-python
index f7dd1fc6..ab7399d1 100755
--- a/examples/modem-watcher-python/modem-watcher-python
+++ b/examples/modem-watcher-python/modem-watcher-python
@@ -33,7 +33,7 @@ def signal_handler(loop):
def main():
"""Main routine."""
# Create modem watcher
- ModemWatcher.ModemWatcher()
+ ModemWatcher.ModemWatcher(None)
# Main loop
main_loop = GLib.MainLoop()