Add reference to network object
This commit is contained in:
parent
53f99f4c28
commit
bfdaffa14b
@ -18,7 +18,7 @@ from pwnagotchi.utils import StatusFile
|
|||||||
READY = False
|
READY = False
|
||||||
INTERVAL = StatusFile('/root/.bt-tether')
|
INTERVAL = StatusFile('/root/.bt-tether')
|
||||||
OPTIONS = dict()
|
OPTIONS = dict()
|
||||||
|
NETWORK = None
|
||||||
|
|
||||||
class BTError(Exception):
|
class BTError(Exception):
|
||||||
"""
|
"""
|
||||||
@ -275,15 +275,15 @@ class BTNap:
|
|||||||
try:
|
try:
|
||||||
logging.debug('BT-TETHER: Connecting to nap network ...')
|
logging.debug('BT-TETHER: Connecting to nap network ...')
|
||||||
net.Connect('nap')
|
net.Connect('nap')
|
||||||
return True
|
return net, True
|
||||||
except dbus.exceptions.DBusException as err:
|
except dbus.exceptions.DBusException as err:
|
||||||
if err.get_dbus_name() == 'org.bluez.Error.AlreadyConnected':
|
if err.get_dbus_name() == 'org.bluez.Error.AlreadyConnected':
|
||||||
return True
|
return net, True
|
||||||
|
|
||||||
connected = BTNap.prop_get(net, 'Connected')
|
connected = BTNap.prop_get(net, 'Connected')
|
||||||
if not connected:
|
if not connected:
|
||||||
return False
|
return None, False
|
||||||
return True
|
return net, True
|
||||||
|
|
||||||
|
|
||||||
class SystemdUnitWrapper:
|
class SystemdUnitWrapper:
|
||||||
@ -444,6 +444,7 @@ def on_ui_update(ui):
|
|||||||
|
|
||||||
if READY:
|
if READY:
|
||||||
global INTERVAL
|
global INTERVAL
|
||||||
|
global NETWORK
|
||||||
if INTERVAL.newer_then_minutes(OPTIONS['interval']):
|
if INTERVAL.newer_then_minutes(OPTIONS['interval']):
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -488,7 +489,9 @@ def on_ui_update(ui):
|
|||||||
if not btnap_iface.exists():
|
if not btnap_iface.exists():
|
||||||
# connected and paired but not napping
|
# connected and paired but not napping
|
||||||
logging.debug('BT-TETHER: Try to connect to nap ...')
|
logging.debug('BT-TETHER: Try to connect to nap ...')
|
||||||
if BTNap.nap(dev_remote):
|
network, status = BTNap.nap(dev_remote)
|
||||||
|
NETWORK = network
|
||||||
|
if status:
|
||||||
logging.info('BT-TETHER: Napping!')
|
logging.info('BT-TETHER: Napping!')
|
||||||
ui.set('bluetooth', 'C')
|
ui.set('bluetooth', 'C')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user