' WLAN RS232 Device Server ' (c) Avisaro AG 18.03.2010 ' Version 1.16 setleds 32+128 exec "stpseq +\097+v+i+s+" sleep 100 exec "prompt" sleep 100 exec "sched 0" sleep 100 let n = 0 REM Default-Werte ? if ((KEYS & 1) = 1) then for n = 0 to 100 if ((KEYS & 1) = 0) then goto STARTING end if setleds 255 sleep 10 setleds 0+128 sleep 10 next n exec "restart clear" sleep 100 setleds 255 do sleep 1 loop end if STARTING: sleep 400 ' DIM A(500) DIM B(0) let n = 0 let t = TIME let f = 60 let m = 0 let u = 0 let y = 0 REM INIT WEB let x$ = "Connect to (IP, =0 for listen):" put -100, x$, len(x$) let x$ = "Connect to / Listen (Port):" put -102, x$, len(x$) let x$ = "Status (WR1 V14):" put -104, x$, len(x$) load 0, t$ put -101, t$, len(t$) load 25, u if (-1 = u) then let u = 23 save 25, u end if let x$ = str$(u) put -103, x$, len(x$) TRY_CONNECT: sleep 5 ' RS232 leer lesen inmode -3 input A if (t$ = str$(0)) then let x$ = "listening" else let x$ = "try to connect" end if gosub load_web let y = status(101) if (y = 0) then if (t$ = str$(0)) then ' listen 101, u, 0 listen 101, u, 10 setleds 32+128 else let y = RESOLV (t$) sleep 500 ' connect 101, y, u, 0 connect 101, y, u, 10 setleds 32+128 end if end if let y = status(101) if y = 9 then let x$ = "Connected (Web locked)" inmode 0 gosub load_web REM Connected exec "stream 101" goto MAIN end if goto TRY_CONNECT MAIN: setleds 48+128 if ((KEYS & 1) = 1) then close 101 setleds 32 gosub load_web goto TRY_CONNECT end if sleep 10 let y = status(101) if (y <> 9) then close 101 setleds 32 goto TRY_CONNECT end if goto MAIN: load_web: put -105, x$, len(x$) REM Änderung auf Webseite ? get -103, x$ if val(x$) <> u then let u = val(x$) save 25, u close 101 end if get -101, x$ if t$ <> x$ then let t$ = x$ save 0, t$ close 101 end if return '+++ 'a+v+i+s