2021-05-05 20:23:55 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import dbus
|
|
|
|
|
2021-09-24 00:57:24 +02:00
|
|
|
if len(sys.argv) < 2 or len(sys.argv) > 3:
|
|
|
|
print("Usage: %s [device] <mac>" % (sys.argv[0]))
|
2021-05-05 20:23:55 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
bus = dbus.SystemBus()
|
2021-09-24 00:57:24 +02:00
|
|
|
device = None
|
|
|
|
|
|
|
|
if len(sys.argv) == 2:
|
|
|
|
manager = dbus.Interface(bus.get_object("net.connman.iwd", "/"),
|
|
|
|
"org.freedesktop.DBus.ObjectManager")
|
|
|
|
objects = manager.GetManagedObjects()
|
|
|
|
for path in objects:
|
|
|
|
for interface in objects[path]:
|
|
|
|
if interface == "net.connman.iwd.StationDebug":
|
|
|
|
device = dbus.Interface(bus.get_object("net.connman.iwd", path),
|
2021-08-12 21:07:23 +02:00
|
|
|
"net.connman.iwd.StationDebug")
|
2021-09-24 00:57:24 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
if not device:
|
|
|
|
print("StationDebug interface not found")
|
|
|
|
exit()
|
2021-05-05 20:23:55 +02:00
|
|
|
|
2021-09-24 00:57:24 +02:00
|
|
|
mac = sys.argv[1]
|
|
|
|
else:
|
|
|
|
device = dbus.Interface(bus.get_object("net.connman.iwd", sys.argv[1]),
|
|
|
|
"net.connman.iwd.StationDebug")
|
|
|
|
mac = sys.argv[2]
|
2021-05-05 20:23:55 +02:00
|
|
|
|
2021-09-24 00:57:24 +02:00
|
|
|
mac = mac.replace(':', '')
|
2021-05-05 20:23:55 +02:00
|
|
|
device.Roam(dbus.ByteArray.fromhex(mac))
|