On Feb 14, 2017 11:20 PM, "Dan Williams" <d...@redhat.com> wrote:

On Tue, 2017-02-14 at 15:46 -0600, Russ Westrem wrote:
> You mean you can still use the WWAN even if MM says it's
> disconnected?
> Not sure I understood, otherwise.
>
>
> --
> Aleksander
> https://aleksander.es
>
>
>
> No, nothing is usable untill i ifup.

Here's what's probably going on...  When the network tells the modem to
disconnect the PDP context (eg, bearer), MM sees the message and sets
the status on the bearer and does some other cleanup.  But that doesn't
actually trigger a bearer disconnect, because ModemManager is waiting
for a connection manager to notice the bearer/modem state change and to
delete the bearer, which in your case actually clears the WDS client
and tells the modem to release the bearer resources.

But MM should probably call the bearer disconnect sequence when the
bearer is disconnected unexpectedly, and ignore errors since the bearer
is already dead.  But this doesn't help your actual problem, which is
that nothing is telling ModemManager to activate another bearer when
the first one drops...

So to circle back to your original question, which was "how do I
automatically reconnect a bearer when the network disconnects me",
you'd have a small script that watches the modem state, and if the
modem state moves from connected -> registered just runs 'ifup
broadband'.

Dan

Here's how to do that in Python, for example:
---------------------------------------------

import sys, signal, gi, os

gi.require_version('ModemManager', '1.0')
from gi.repository import GLib, GObject, Gio, ModemManager

def modem_state_changed(modem, old_state, new_state, reason):
    print "Modem state changed: %d -> %d (reason %d)" % (old_state,
new_state, reason)
    if old_state == getattr(ModemManager,"ModemState").CONNECTED and
new_state == getattr(ModemManager,"ModemState").REGISTERED:
        os.system("ifup broadband")

sigids = {}

def watch_modem(manager, obj):
    modem = obj.get_modem()
    sigids[modem] = modem.connect('state-changed', modem_state_changed)

def unwatch_modem(manager, obj):
    modem = obj.get_modem()
    modem.disconnect(sigids[modem])
    del sigids[modem]

def signal_handler(data):
    main_loop.quit()

if __name__ == "__main__":
    main_loop = GLib.MainLoop()
    GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGHUP, signal_handler,
None)
    GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGTERM,
signal_handler, None)

    # Connection to ModemManager
    connection = Gio.bus_get_sync (Gio.BusType.SYSTEM, None)
    manager = ModemManager.Manager.new_sync (connection, Gio.
DBusObjectManagerClientFlags.DO_NOT_AUTO_START, None)

    # watch the manager for new modems
    manager.connect('object-added', watch_modem)
    manager.connect('object-removed', unwatch_modem)

    # Watch existing modems
    if manager.get_name_owner() != None:
        for obj in manager.get_objects():
            watch_modem(manager, obj)

    # Main loop
    try:
        main_loop.run()
    except KeyboardInterrupt:
        pass



Is there anything in the modemmanager scripts that I could change to have
it ignore the deregistered modem and stop it from removing it from the
bearer.  I have a feeling these deregistrations happen often but very
quickly and maybe if ignored, everything might work.
_______________________________________________
ModemManager-devel mailing list
ModemManager-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Reply via email to