Ok i've modified the monitor service example based on yours tests, it's that:

import gobject

import dbus
import dbus.mainloop.glib

def extract_values(values):
    val = "{"
    for key in values.keys():
        val += " " + key + "="
        if key in ["Servers", "Excludes"]:
            val += extract_list(values[key])
        else:
            val += str(values[key])
    val += " }"
    return val

def extract_list(list):
    val = "["
    for i in list:
        val += " " + str(i)
    val += " ]"
    return val

def property_changed(name, value, path):
    service = path[path.rfind("/") + 1:]
    #print "propriety changed"

    if name in ["AutoConnect"]:
        print "%s %s" % (name, service
        path = "/net/connman/service/" + service
service = dbus.Interface(bus.get_object("net.connman", path),"net.connman.Service")
        try:
            service.Connect(timeout=60000)
        except dbus.DBusException, error:
            print "%s: %s" % (error._dbus_error_name, error.message)
    return

def services_changed(services, removed):
    print "services_changed"
    for i in services:
        service = i[0][i[0].rfind("/") + 1:]
        print "[%s] changed" % (service)
        for n in i[1].keys():
            property_changed(n, i[1][n], i[0])
    for i in removed:
        service = i[i.rfind("/") + 1:]
        print "[%s] removed" % (service)

if __name__ == '__main__':
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

    bus = dbus.SystemBus()

    bus.add_signal_receiver(services_changed,
                bus_name="net.connman",
                dbus_interface="net.connman.Manager",
                signal_name="ServicesChanged")

    mainloop = gobject.MainLoop()
    mainloop.run()

But i'm worried if connman drops...i can't get back my device because i manage network devices with this,
how to instruct systemd or connmand itself to restart if crashes?
I i've experienced that if i startin rapid succession set-ipv4-method connman may die.

Thanks, if necessary i will attach the connman service error when the issues happen.
Thanks.

On 31/01/2014 13:26, Patrik Flykt wrote:
        Hi,

On Fri, 2014-01-31 at 09:54 +0100, andrea pola wrote:

I use two Ethernet interface (one is IP over USB) and the other the real
one, I 've add to boot a simple script that call connman connect to all the
devices, and in this way i can obtain all interfaces connected.

If i mantain all the cables connected during boot, i'm ok, and all
devices will be up and connected.
Actually only the first device that appears will be connected by
ConnMan. Once connected, ConnMan will not connect more networks. The
rest of the devices are connected due to the script you have added.

If i try to remove one of the cable and reinsert, this device can't
automatically connect to the network.
All services has autoconnect flag true.
When you reinsert the cable, the corresponding service gets (re)created
and autoconnect is run. But since ConnMan is connected to the other
network, it won't connect the new one. It's the same situation as above.
So here too the same script could be run as during boot.

Cheers,

        Patrik

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to