pAkt = 0 pPass = 1 tPin = 1 pPin = 2 t = 60 udpPort$ = read(udpPortF) if udpPort$ == "" then udpPort$ = "8910" udpMAdr$ = read(udpMAdrF) if udpMAdr$ == "" then udpMAdr$ = "234.5.6.7" zD$ = read(zDF) 'Digitimp. lesen gosub [sImp] 'setzen bZ = 43 'Basisimp. sZ = 20 'Startimp. tZ = 18 'Trennimp. eZ = 70 'Endimimp. bQuit$ = " (letzter Befehl)" udpRxAdr = " (UDP-Sender-Adr.)" [start] msgbranch [msg] timer 1000, [aTimerON] 'Timer! gosub [iUDP] 'UDP Ini '------------------------------ [prg0] cls t = 60 tL = 60 'Timerzeit 60s print "EREL CRONIOS Web-Interface v6.0 " textbox aZeit$ ipAdr$ = udpMAdr$ if val(udpPort$) == 0 then goto [prg0b] if len(ipAdr$) > 8 then goto [prg0a] ipAdr$ = ip() print "UDP: " & ipAdr$ & ":" & udpPort$ & " " goto [prg0c] [prg0a] print "UDP-Multicast: " & ipAdr$ & ":" & udpPort$ & " " goto [prg0c] [prg0b] print "UDP aus! " [prg0c] button "Einstellungen", [prg5] button " WiFi Reset", [WifiRes] print "Status: " textbox udpRxAdr textbox bQuit$ print "Befehl [0]...[9],[-]: " textbox bBef$ button "Befehl senden...", [bEing] button "Taste kurz", [TaK] button "Taste lang", [TaL] print wait [prg5] cls t = 60 tL = 0 'Timer @1 s print "EREL CRONIOS Systemeinstellungen " print "Zeitzone: +" listbox uZZ$, "0,1,2,3,4", 1 textbox aZeit$ print "UDP-Multicast IP (224.0.0.0~239.255.255.255, 0=Aus), Port (0=UDP Aus):" print textbox udpMAdr$ textbox udpPort$ button "UDP-Set", [sUDP] print "Ziffernwert [ms]: " zD$ = str(dZ) textbox zD$ button "Set", [zImp] button "Reset", [rImp] print button "fertig.", [prg0] wait '=================================================== [TaK] udpRxAdr = " lokal: " quell$ = " lokal: " gosub [wTaK] wait [TaL] udpRxAdr = " lokal: " quell$ = " lokal: " gosub [wTaL] wait [bEing] udpRxAdr = " lokal: " befehl$ = bBef$ gosub [bSend] wait [rImp] zD$ = "30" [zImp] gosub [sImp] wait [sImp] if val(zD$) < 25 or val(zD$) > 35 then zD$ = "30" dZ = val(zD$) gosub [tFl] if zD$ <> read(zDF) then write(zDF, zD$) bQuit$ = "Ziff.Impuls = " &zD$ & " ms" return '=================================================== [bSend] quell$ = " Befehl " [nSend] gosub [tBusy] for n = 1 to len(befehl$) if instr("0123456789-", (mid(befehl$, n, 1))) == 0 then goto [bSendErr] next bQuit$ = quell$ & befehl$ & "..." aZ = sZ 'Start gosub [ledAkt] for n = 1 to len(befehl$) z = instr("0123456789-", (mid(befehl$, n, 1))) - 1 aZ = tZ 'Ziff.Trenn if n == len(befehl$) then aZ = eZ 'Ziff.Ende pZ = bZ + z * dZ 'Ziff.Bas+Diff gosub [ledPassAkt] 'Aus -> Ein next bQuit$ = quell$ & befehl$ & " OK!" befehl$ = "" gosub [ledPass] 'fertig LED aus gosub [tOk] return [bSendP] quell$ = "sende... " gosub [nSend] gosub [tFl] gosub [aRGB] return [bSendErr] bQuit$ = quell$ & befehl$ & " ???" befehl$ = "" gosub [ledErr] return [ledPassAkt] 'Aus -> Ein io(po,pPin,pPass) delay pZ [ledAkt] io(po,pPin,pAkt) delay aZ return [ledPass] 'Aus (fertig) io(po,pPin,pPass) delay pZ return [ledErr] 'Fehler - flackern for n = 0 to 10 io(po,pPin,pAkt) delay 20 io(po,pPin,pPass) delay 20 next gosub [tOk] return [tFl] 'Tx flackern for n = 0 to 5 io(po,tPin,pAkt) delay 100 io(po,tPin,pPass) delay 100 next [tOk] io(po,tPin,pAkt) 'Tx-LED Ein return [tBusy] io(po,tPin,pPass) 'Tx-LED Aus return '----------------------------------------------- [aTimerON] '--- TIMER --- t = t + 1 io(po,tPin,pPass) 'Tx-LED alive delay 10 io(po,tPin,pAkt) if uZZ$ == read(ZZF) and t < tL then wait 'alle 60 sek. t = 0 gosub [cTime] wait [uMEZ] uZZ$ = "1" gosub [cTime] wait [uMESZ] uZZ$ = "2" gosub [cTime] wait [cTime] 'Zeitzone berechnen nZeit$ = time() nStd = val(mid(nZeit$,12,2)) nMin$ = mid(nZeit$,15,2) nSek$ = mid(nZeit$,18,2) nDat$ = left(nZeit$,11) nStd = nStd + val(uZZ$) if nStd > 23 then nDat$ = "?" + nDat$ if nStd > 23 then nStd = nStd - 24 aZeit$ = " " & nDat$ & str(nStd) & ":" & nMin$ if tL <> 60 then aZeit$ = aZeit$ & ":" & nSek$ if uZZ$ <> read(ZZF) then write(ZZF, uZZ$) return [WifiRes] ' ---- WiFi Reset ----- cls print "Achtung! Reset Wifi-Einstellungen!" txt$ = read(WIFIname) print "WIFIname: " & txt$ & " verwerfen?" txt$ = read(WIFIpass) print "WIFIpass: (" & str(len(txt$)) & ") verwerfen?" txt$ = read(APname) print "APname: " & txt$ & " verwerfen?" txt$ = read(APpass) print "APpass: (" & str(len(txt$)) & ")"& " verwerfen?" print button " wirklich? ", [WifiOK] button " abbrechen! ", [prg0] print wait [WifiOK] cls txt$ = "ESP" print "Ungescherter Access Point: " & txt$ print "Systemadresse 192.168.4.1" print button " umschalten ", [WifiDel] button " abbrechen! ", [prg0] wait [WifiDel] del.dat(WIFIname) del.dat(WIFIpass) del.dat(APname) del.dat(APpass) write(APname, txt$) print "Bitte neu starten..." wait [sUDP] ' ------------ set/initialisiere UDP-Server ------------ gosub [tFl] if val(udpMAdr$) < 224 or val(udpMAdr$) > 239 then udpMAdr$ = "0" if udpMAdr$ <> read(udpMAdrF) then write(udpMAdrF, udpMAdr$) if udpPort$ <> read(udpPortF) then write(udpPortF, udpPort$) gosub [iUDP] goto [prg0] wait [iUDP] Udpstop bQuit$ = " UDP aus" upv = val(udpPort$) if upv == 0 then return if udpMAdr$ > "0" then UdpbeginMultiCast udpMAdr$, upv if udpMAdr$ == "0" then Udpbegin upv udpbranch [rUDP] bQuit$ = " UDP Empf.Port: " & udpPort$ return [rUDP] ' ===== UDP-Empfang ===== befehl$ = udpread() udpRxAdr = udpremote() quell$ = " UDP: " udpreply quell$ & befehl$ & "..." 'Quittung gosub [wSend] udpreply bQuit$ 'Quittung return [msg] ' ===== Message-Empfang ===== udpRxAdr = "" befehl$ = msgget("bef") quell$ = " MSG: " bQuit$ = "MSG: " & befehl$ & "... " & right(aZeit$,5) & " OK!" for n = 1 to len(befehl$) 'Formatcheck if instr("0123456789-", (mid(befehl$, n, 1))) == 0 then bQuit$ = " MSG: " & befehl$ & " ???" next msgreturn bQuit$ if right(bQuit$, 1) == "!" then gosub [wSend] wait ' msgbranch [msg] ' Beispiel: http://192.168.2.105/msg?bef=123@ [wSend] '--- Web-Befehle senden --- if left(befehl$, 1) <> "-" then gosub [nSend] 'keine Sonderbefehle if befehl$ >= "-0" and befehl$ <= "-4" then gosub [wZZ] 'ZZ +0...+4 if befehl$ == "-6" then gosub [wTaK] 'Taste kurz if befehl$ == "-7" then gosub [wTaL] 'Taste lang if befehl$ >= "-920" and befehl$ <= "-940" then gosub [wZW] 'Ziffernwert return end [wZZ] 'Zeitzone uZZ$ = mid(befehl$, 2, 1) bQuit$ = " ZZ: +" & uZZ$ & " OK!" return [wTaK] io(po,pPin,pAkt) delay 100 io(po,pPin,pPass) delay 200 bQuit$ = " Taste kurz. OK!" return [wTaL] io(po,pPin,pAkt) delay 1000 io(po,pPin,pPass) delay 200 bQuit$ = " Taste lang. OK!" return [wZW] 'Ziffernimpuls-Adj. zD$ = mid(befehl$, 3, 2) if val(zD$) < 25 or val(zD$) > 35 then zD$ = "30" dZ = val(zD$) gosub [tFl] if zD$ <> read(zDF) then write(zDF, zD$) bQuit$ = " Ziff.Imp." & zD$ & "ms OK!" return