def testThread(): while True: import network import slimDNS sta_if = network.WLAN(network.STA_IF) local_addr = sta_if.ifconfig()[0] server = slimDNS.SlimDNSServer(local_addr, "micropython") print("starting slimDNS server") server.run_forever()
def connect(): import network import slimDNS sta_if = network.WLAN(network.STA_IF) if not sta_if.isconnected(): print('connecting to network...') sta_if.active(True) sta_if.connect('Pi3-AP-BAI', 'robotseverywhere') while not sta_if.isconnected(): pass print('network config:', sta_if.ifconfig()) local_addr = sta_if.ifconfig()[0] server = slimDNS.SlimDNSServer(local_addr, "micropython") server.run_forever()
import network import slimDNS network.WLAN(network.AP_IF).active( False) # <-- AP must be deactivated for address resolution to work sta_if = network.WLAN(network.STA_IF) local_addr = sta_if.ifconfig()[0] server = slimDNS.SlimDNSServer(local_addr, "micropython") ip = server.resolve_mdns_address("raspberrypi4.local") print("{0}.{1}.{2}.{3}".format(ip[0], ip[1], ip[2], ip[3]))
def testThread1(): server = d.SlimDNSServer(local_addr, "micropython") server.advertise_hostname("tvpython.local") server.run_forever()