예제 #1
0
def set_state(state, connections=None, timeout=180):
    global com_state, conn_list, state_id, points

    log.info('Setting state to %s' % state)

    state_info = state_matrix(state)

    log.info("get statematrix")

    nmmon.init_nmmon()

    log.info("enable")
    nmmon.enable(modemgr.get_state_device(state), state_info.pass_fn,
                 state_info.fail_fn)

    log.info("nmmon enabled")

    if connections:
        conn_list = connections

    state_id += 1
    com_state = state
    timeout_add(timeout * 1000, state_info.timeout_fn, state_id)
    log.info("state_info.start_fn()")
    state_info.start_fn()
예제 #2
0
def set_state_to(state, connections=None, timeout=180):
    global com_state, conn_list, state_id, points

    log.info('Setting state to %s' % state)

    state_info = state_matrix(state)

    nmmon.init_nmmon()

    state_id += 1

    nmmon.enable(
        modemgr.get_state_device(state),
        state_info.pass_fn,
        state_info.fail_fn,
        state_id,
    )

    if connections:
        if type(conn_list) == str:
            conn_list = [connections]
        else:
            conn_list = connections

    com_state = state
    timeout_add(timeout * 1000, state_info.timeout_fn, state_id)
    state_info.start_fn()

    return False
예제 #3
0
def init_states(hosts, callbacks):
    global hotspot_name

    nmmon.init_nmmon()
    set_hosts(*hosts)

    for callback in callbacks:
        add_state_callback(callback)

    hotspot_name = dns_to_conn(hosts[0])

    assure_hotspot(hotspot_name, modemgr.get_ap_device())

    timeout_add(10 * 1000, state_monitor)
예제 #4
0
def init_states(hosts, callbacks, hotspot_pw):
    global hotspot_name

    nmmon.init_nmmon()
    set_hosts(*hosts)

    for callback in callbacks:
        add_state_callback(callback)

    hotspot_name = dns_to_conn(hosts[0])
    assure_hotspot(hotspot_name, modemgr.get_ap_device())

    # Set an early kick to set CONNECTING mode
    set_state('HOTSPOT')
    timeout_add(5 * 1000, hotspot_timeout, state_id)
예제 #5
0
def init_states(
    hosts: List[str],
    callbacks: List[Callable[[str, str], None]],
    hotspot_pw: str,
) -> None:
    global hotspot_name, conn_list, connection, startup

    nmmon.init_nmmon()
    set_hosts(*hosts)

    for callback in callbacks:
        add_state_callback(callback)

    hotspot_name = dns_to_conn(hosts[0])
    assure_hotspot(hotspot_name, modemgr.get_ap_device(), hotspot_pw)

    startup = True
    set_state("HOTSPOT")
예제 #6
0
def set_state_to(
    state: str,
    connections: List[str],
    timeout: int,
    force: bool,
    curr_state_id: int,
):
    global com_state, conn_list, state_id

    if state == com_state and not force:
        return False

    if curr_state_id < state_id:
        return False

    log.info("Setting state to %s" % state)

    state_info: state_matrix = state_matrix(state)

    nmmon.init_nmmon()

    state_id += 1

    nmmon.enable(
        modemgr.get_state_device(state),
        state_info.pass_fn,
        state_info.fail_fn,
        state_id,
    )

    if state in ["CONNECTED", "HOTSPOT"]:
        nmmon.enhance_fail_states()

    if connections:
        conn_list = connections

    com_state = state
    timeout_add(timeout * 1000, state_info.timeout_fn, state_id, 0)
    state_info.start_fn(0)

    return False
예제 #7
0
def test_nmmon_init(check_listener, bus_fxt):
    nmmon.init_nmmon()

    assert bus_fxt.called
예제 #8
0
def test_nmmon_init(check_listener, bus_fxt):
    nmmon.init_nmmon()

    assert bus_fxt.called