def connected_timeout(dummy: int) -> None: active_ssid: Optional[str] active_ssid = nm.get_active_ssid(modemgr.get_state_device("CONNECTED")) log.debug("connected_timeout comparing {} to {}".format( connection, active_ssid)) if connection != active_ssid: log.warning("Connection lost on timeout") dev = modemgr.get_state_device("CONNECTED") set_state("CONNECTING", candidate_connections(dev)) if modemgr.get_mode() == modemgr.MULTI_MODE: wpa.check_wpa(modemgr.get_ap_device().Interface) active_ssid = nm.get_active_ssid(modemgr.get_state_device("HOTSPOT")) if not active_ssid: log.warning("Hotspot lost on timeout") set_state("HOTSPOT") defroute_devname: Optional[str] = routemgr.defroute_dev() ap_dev: NetworkManager.Device = modemgr.get_ap_device() link_dev: NetworkManager.Device = modemgr.get_link_device() if defroute_devname == nm.device_name(ap_dev): # default route is bad. Disconnect link and count on state # processing to restore log.error("AP is holding default route while CONNECTED, kicking") nm.disconnect(link_dev)
def connecting_start(): global conn_list if conn_list: log.debug("states: Calling nm.disconnect()") nm.disconnect(modemgr.get_state_device('CONNECTING')) conn = conn_list.pop(0) log.info('Attempting connection to %s' % conn) activate_connection(conn, 'CONNECTING') else: set_state('HOTSPOT')
def connecting_start(dummy: int) -> None: global conn_list, connection dev = modemgr.get_state_device("CONNECTED") full_conn_list = candidate_connections(dev) active_ssid = nm.get_active_ssid(modemgr.get_state_device("CONNECTED")) if active_ssid in full_conn_list: log.debug("Didn't need to connect - already connected") connection = active_ssid # the connect callback won't happen - let's 'pass' manually timeout_add(100, fake_cg_pass, state_id) else: if conn_list: log.debug("states: Calling nm.disconnect()") nm.disconnect(modemgr.get_state_device("CONNECTING")) conn = conn_list.pop(0) log.info("Attempting connection to %s" % conn) activate_connection(conn, "CONNECTING") else: set_state("HOTSPOT")
def connecting_start(): global conn_list mdns.clear_entries() if conn_list: log.debug("states: Calling nm.disconnect()") nm.disconnect(modemgr.get_state_device('CONNECTING')) conn = conn_list.pop(0) log.info('Attempting connection to %s' % conn) activate_connection(conn, 'CONNECTING') else: # Give NetworkManager a chance to update the access point list try: # todo - clean this up log.debug("states: Calling nm.deactivate_connection()") nm.deactivate_connection(modemgr.get_state_device('CONNECTING')) except DBusException: pass time.sleep(5) set_state('HOTSPOT')