Exemple #1
0
 def up(self):
     try:
         card = pyw.getcard(self.iface)
     except:
         wpa(self.wiface, 'p2p_group_add', 'persistent=0')
         self.iface = self.get_iface()
         self.password = wpa(self.iface, 'p2p_get_passphrase')
         card = pyw.getcard(self.iface)
     pyw.inetset(card, self.ip)
     copyfile('/etc/dnsmasq.conf', '/tmp/dnsmasq-bk.conf')
     self.save()
     sysctrl('restart', 'dnsmasq.service')
Exemple #2
0
 def up(self):
     try:
         card = pyw.getcard(self.iface)
     except:
         wpa(self.wiface, 'p2p_group_add', 'persistent=0')
         self.iface = self.get_iface()
         self.password = wpa(self.iface, 'p2p_get_passphrase')
         card = pyw.getcard(self.iface)
     pyw.inetset(card, self.ip)
     copyfile('/etc/dnsmasq.conf', '/tmp/dnsmasq-bk.conf')
     self.save()
     sysctrl('restart', 'dnsmasq.service')
    def __init__(self, wiface):
        self.wiface = wiface
        self.subnet = '172.24.1'
        self.ip = self.subnet + '.1'
        self.ip_start = self.subnet + '.50'
        self.ip_end = self.subnet + '.150'

        wpa(self.wiface, 'p2p_group_add', 'persistent=0')
        self.iface = self.get_iface()
        self.password = wpa(self.iface, 'p2p_get_passphrase')

        LOG.debug('Wiface: ' + self.wiface)
        LOG.debug('Iface: ' + self.iface)

        card = pyw.getcard(self.iface)
        pyw.inetset(card, self.ip)
        copyfile('/etc/dnsmasq.conf', '/tmp/dnsmasq-bk.conf')
        self.save()
        sysctrl('restart', 'dnsmasq.service')
Exemple #4
0
def setup_hotspot(interface):
    if interface == 'internal':
        interface = PI3_WIFI_NIC
    if pyw.isinterface(HOTSPOT_NIC):
        interface = HOTSPOT_NIC  # check if we already setup a hot spot
    if pyw.isinterface(interface):
        card = pyw.getcard(interface)
        pyw.down(card)
        subprocess.run(["ip link set " + card.dev + " name " + HOTSPOT_NIC], shell=True)
        time.sleep(1)
        card = pyw.getcard(HOTSPOT_NIC)
        pyw.up(card)
        pyw.inetset(card, '192.168.2.1')
        subprocess.run(["udhcpd -I 192.168.2.1 " + os.path.join(DRONEBRIDGE_BIN_PATH, "udhcpd-wifi.conf")], shell=True,
                       stdout=DEVNULL)
        subprocess.run(
            ["dos2unix -n " + os.path.join(DRONEBRIDGE_SETTINGS_PATH, "apconfig.txt") + " /tmp/apconfig.txt"],
            shell=True, stdout=DEVNULL)
        subprocess.Popen(["hostapd", "/tmp/apconfig.txt"], shell=False)
        print("Setup wifi hotspot: " + card.dev + " AP-IP: 192.168.2.1")
    else:
        print("Error: Could not find AP-adapter: " + str(interface) + ", unable to enable access point")
Exemple #5
0
 def test_inetgetset(self):
     self.assertEqual(None,pyw.inetset(self.card,pri['ip'],pri['mask'],pri['bcast']))
     self.assertEqual(pri['ip'],pyw.inetget(self.card)[0])