Example #1
0
def start_hotspot_on_wl12xx():
    if 'ap0' not in list_wifi_ifaces():
        shell_execute(
            '/data/data/fq.router/wifi-tools/iw %s interface add ap0 type managed'
            % network_interface.WIFI_INTERFACE)
    assert 'ap0' in list_wifi_ifaces()
    with open('/data/misc/wifi/fqrouter.conf', 'w') as f:
        frequency, channel = get_upstream_frequency_and_channel()
        f.write(hostapd_template.render(channel=channel or 1))
    LOGGER.info('start hostapd')
    proc = subprocess.Popen([
        '/data/data/fq.router/wifi-tools/hostapd', '-dd',
        '/data/misc/wifi/fqrouter.conf'
    ],
                            cwd='/data/misc/wifi',
                            stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT)
    time.sleep(2)
    if proc.poll():
        LOGGER.error('hostapd failed')
        LOGGER.error(proc.stdout.read())
        shell_execute('logcat -d -v time -s hostapd:V')
        raise Exception('hostapd failed')
    else:
        LOGGER.info('hostapd seems like started successfully')
    return 'ap0'
Example #2
0
def start_hotspot_on_ti(ssid, password):
    if 'ap0' not in list_wifi_ifaces():
        shell_execute(
            '%s %s interface add ap0 type managed' % (IW_PATH, WIFI_INTERFACE))
    assert 'ap0' in list_wifi_ifaces()
    shell_execute('netcfg')
    try:
        shell_execute('netcfg ap0 up')
    except:
        LOGGER.exception('failed to start ap0')
        try:
            shell_execute('netcfg wlan0 down')
            shell_execute('netcfg ap0 up')
            shell_execute('netcfg wlan0 up')
        except:
            LOGGER.exception('failed to start ap0 after stop wlan0')
    with open(FQROUTER_HOSTAPD_CONF_PATH, 'w') as f:
        frequency, channel = get_upstream_frequency_and_channel()
        f.write(hostapd_template.render(WIFI_INTERFACE, channel=channel or 1, ssid=ssid, password=password))
    os.chmod(FQROUTER_HOSTAPD_CONF_PATH, 0666)
    try:
        shell_execute('%s hostapd' % KILLALL_PATH)
    except:
        LOGGER.exception('failed to killall hostapd')
    LOGGER.info('start hostapd')
    if start_hostapd():
        return
    shell_execute('%s dev ap0 del' % IW_PATH)
    LOGGER.info('try start hostapd without ap0')
    if not start_hostapd():
        raise Exception('failed to start hotspot on ti platform')
Example #3
0
def start_hotspot_on_wl12xx(ssid, password):
    if 'ap0' not in list_wifi_ifaces():
        shell_execute('%s %s interface add ap0 type managed' %
                      (IW_PATH, WIFI_INTERFACE))
    assert 'ap0' in list_wifi_ifaces()
    shell_execute('netcfg ap0 up')
    with open(FQROUTER_HOSTAPD_CONF_PATH, 'w') as f:
        frequency, channel = get_upstream_frequency_and_channel()
        f.write(
            hostapd_template.render(WIFI_INTERFACE,
                                    channel=channel or 1,
                                    ssid=ssid,
                                    password=password))
    os.chmod(FQROUTER_HOSTAPD_CONF_PATH, 0666)
    try:
        shell_execute('%s hostapd' % KILLALL_PATH)
    except:
        LOGGER.exception('failed to killall hostapd')
    LOGGER.info('start hostapd')
    if start_hostapd():
        return
    shell_execute('%s dev ap0 del' % IW_PATH)
    LOGGER.info('try start hostapd without ap0')
    if not start_hostapd():
        raise Exception('failed to start hotspot on wl12xx')
Example #4
0
def start_hotspot_on_wl12xx():
    if 'ap0' not in list_wifi_ifaces():
        shell_execute('iw wlan0 interface add ap0 type managed')
    assert 'ap0' in list_wifi_ifaces()
    with open('/data/misc/wifi/fqrouter.conf', 'w') as f:
        f.write(hostapd_template.render(channel=get_upstream_channel() or 1))
    LOGGER.info('start hostapd')
    proc = subprocess.Popen(
        ['hostapd', '/data/misc/wifi/fqrouter.conf'],
        cwd='/data/misc/wifi', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    time.sleep(2)
    if proc.poll():
        LOGGER.error('hostapd failed')
        LOGGER.error(proc.stdout.read())
        raise Exception('hostapd failed')
    else:
        LOGGER.info('hostapd seems like started successfully')
    return 'ap0'
Example #5
0
def start_hotspot_on_ti(ssid, password):
    if 'ap0' not in list_wifi_ifaces():
        try:
            shell_execute('%s dev %s interface add ap0 type managed' %
                          (IW_PATH, WIFI_INTERFACE))
        except:
            LOGGER.exception('failed to add ap0')
            shell_execute('%s phy phy0 interface add ap0 type managed' %
                          IW_PATH)
    assert 'ap0' in list_wifi_ifaces()
    shell_execute('netcfg')
    try:
        shell_execute('netcfg ap0 up')
    except:
        LOGGER.exception('failed to start ap0')
        try:
            shell_execute('netcfg wlan0 down')
            shell_execute('netcfg ap0 up')
            shell_execute('netcfg wlan0 up')
        except:
            LOGGER.exception('failed to start ap0 after stop wlan0')
    with open(FQROUTER_HOSTAPD_CONF_PATH, 'w') as f:
        frequency, channel = get_upstream_frequency_and_channel()
        f.write(
            hostapd_template.render(WIFI_INTERFACE,
                                    channel=channel or 1,
                                    ssid=ssid,
                                    password=password))
    os.chmod(FQROUTER_HOSTAPD_CONF_PATH, 0666)
    try:
        shell_execute('%s hostapd' % KILLALL_PATH)
    except:
        LOGGER.exception('failed to killall hostapd')
    LOGGER.info('start hostapd')
    if start_hostapd():
        return
    try:
        shell_execute('%s dev ap0 del' % IW_PATH)
    except:
        LOGGER.exception('failed to delete ap0')
    LOGGER.info('try start hostapd without ap0')
    if not start_hostapd():
        LOGGER.error('failed to start hotspot on ti platform')
Example #6
0
def start_hotspot_on_wl12xx():
    if 'ap0' not in list_wifi_ifaces():
        shell_execute('/data/data/fq.router/wifi-tools/iw %s interface add ap0 type managed' % network_interface.WIFI_INTERFACE)
    assert 'ap0' in list_wifi_ifaces()
    with open('/data/misc/wifi/fqrouter.conf', 'w') as f:
        frequency, channel = get_upstream_frequency_and_channel()
        f.write(hostapd_template.render(channel=channel or 1))
    LOGGER.info('start hostapd')
    proc = subprocess.Popen(
        ['/data/data/fq.router/wifi-tools/hostapd', '-dd', '/data/misc/wifi/fqrouter.conf'],
        cwd='/data/misc/wifi', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    time.sleep(2)
    if proc.poll():
        LOGGER.error('hostapd failed')
        LOGGER.error(proc.stdout.read())
        shell_execute('logcat -d -v time -s hostapd:V')
        raise Exception('hostapd failed')
    else:
        LOGGER.info('hostapd seems like started successfully')
    return 'ap0'
Example #7
0
def start_hotspot_on_wl12xx(ssid, password):
    if 'ap0' not in list_wifi_ifaces():
        shell_execute(
            '%s %s interface add ap0 type managed' % (IW_PATH, WIFI_INTERFACE))
    assert 'ap0' in list_wifi_ifaces()
    with open(FQROUTER_HOSTAPD_CONF_PATH, 'w') as f:
        frequency, channel = get_upstream_frequency_and_channel()
        f.write(hostapd_template.render(WIFI_INTERFACE, channel=channel or 1, ssid=ssid, password=password))
    os.chmod(FQROUTER_HOSTAPD_CONF_PATH, 0666)
    LOGGER.info('start hostapd')
    proc = subprocess.Popen(
        [HOSTAPD_PATH, '-dd', FQROUTER_HOSTAPD_CONF_PATH],
        cwd='/data/misc/wifi', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    time.sleep(2)
    if proc.poll():
        LOGGER.error('hostapd failed')
        LOGGER.error(proc.stdout.read())
        shell_execute('logcat -d -v time -s hostapd:V')
        raise Exception('hostapd failed')
    else:
        LOGGER.info('hostapd seems like started successfully')
    return 'ap0'