How can I cancel the WLan and time query after about 30 seconds without getting a connection?
-
How can I cancel the WLan and time query after about 30 seconds without getting a connection? (Restart)
And how can you query the times that you automatically get summer or winter time.
Can anyone help me?
Here's my code that usually works very well.# W-Lan Verbindungsaufbau--------------------------------------------- if (Verbindung) == 1: from network import WLAN wlan = WLAN(mode=WLAN.STA) nets = wlan.scan() for net in nets: #Suche nach W-Lan Netzen Routerwahl = 1 #Der Router aus den Settings print(net.ssid) #Gefundene Netzwerke time.sleep(0.5) if net.ssid == 'XXXXX': #Immer Zugang Routerwahl = 2 time.sleep(0.5) if net.ssid == settings.Router or net.ssid == 'XXXXX': #Auswahl von 2 Zugängen print('Netzwerk gefunden!') print('Verbinde mit... ' + net.ssid) if (ssd1306) == 1: if (settings.Display) == 1: x = OledDisplay.OledDisplay(True) xo = OledGrafx.OledGrafx(True) x.clear() xo = OledGrafx.OledGrafx(True) xo.PrintStrings("W-Lan Netz...","wurde gefunden","Verbindung wird","aufgebaut...") time.sleep(1) if Routerwahl == 1: #Der Router aus den Settings wlan.connect(net.ssid, auth=(net.sec, settings.Pass), timeout=5000) while not wlan.isconnected(): machine.idle() # save power while waiting print('WLAN-Verbindung erfolgreich!') if (ssd1306) == 1: if (settings.Display) == 1: x.clear() xo = OledGrafx.OledGrafx(True) xo.PrintStrings(""," Verbindung..."," O K","") time.sleep(1) if Routerwahl == 2: #Immer Zugang wlan.connect(net.ssid, auth=(net.sec, 'XXXXX'), timeout=5000) while not wlan.isconnected(): machine.idle() # save power while waiting print('WLAN-Verbindung erfolgreich!') if (ssd1306) == 1: if (settings.Display) == 1: x.clear() xo = OledGrafx.OledGrafx(True) xo.PrintStrings(""," Verbindung..."," O K","") time.sleep(1) # Datum und Uhrzeit vom Server holen------------------------------------------------------------------------------------ print("Syncing RTC to NTP...") if (ssd1306) == 1: if (settings.Display) == 1: x.clear() xo = OledGrafx.OledGrafx(True) xo.PrintStrings("Datum und","Uhrzeit...","wird vom","Server geholt") time.sleep(1) rtc.ntp_sync("pool.ntp.org", update_period=3600) # Datum und Uhrzeit holen #rtc.ntp_sync("pool.ntp.org") while not rtc.synced(): machine.idle() # save power while waiting # Startzeit #print(rtc.now()) time1 = rtc.now() # Übergabe Datum und Uhrzeit in die Variable time1 startzeit = time.time() LogDateTime = "{}.{:}.{:};{:0>2d}:{:0>2d}:{:0>2d}".format(time1[2], time1[1], time1[0], time1[3]+TimeDiff, time1[4], time1[5]) LogDate = "{}.{:}.{:}".format(time1[2], time1[1], time1[0]) LogTime = "{:0>2d}:{:0>2d}:{:0>2d}".format(time1[3]+TimeDiff, time1[4], time1[5]) print (LogDateTime) break # Datum und Uhrzeit vom Server holen------------------------------------------------------------------------------------
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login