-
Notifications
You must be signed in to change notification settings - Fork 0
/
wled.bsc
97 lines (74 loc) · 1.82 KB
/
wled.bsc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
uconfig 115200
buffer=alloc(500) :buflen=0
protocol$=""
host$=""
path$=""
call wget( "http://192.168.0.100/win&A=64&FX=4" )
print ""
wait 500
call serialsend("AT+CIPCLOSE")
call wget( "http://192.168.0.100/win&A=32&FX=102&FP=22" )
print ""
wait 500
call serialsend("AT+CIPCLOSE")
call wget( "http://192.168.0.100/win&A=32&FX=102&FP=22" )
print ""
wait 500
call serialsend("AT+CIPCLOSE")
call wget( "http://192.168.0.100/win&A=64&PL=1" )
print ""
wait 500
call serialsend("AT+CIPCLOSE")
call wget( "http://192.168.0.100/win&A=64&PL=2" )
print ""
wait 500
call serialsend("AT+CIPCLOSE")
call wget( "http://192.168.0.100/win&A=64&PL=3" )
print ""
wait 500
call serialsend("AT+CIPCLOSE")
print "DONE"
print ""
end
proc serialread( )
while uhasdata( ) = 0
wait 1
wend
while uhasdata( ) = -1
ureceive buffer+buflen,1
buflen=buflen+1
wend
for c = 0 to buflen
ch = peek(buffer+c)
print chr$(ch);
next
buflen = 0
endproc
proc serialsend(st$ )
usend st$ +chr$(13) +chr$(10)
wait 50
endproc
proc spliturl(url$)
protocol$=""
host$=""
path$=""
protocolend = instr(url$,"/")+1
protocol$=mid$(url$,1,protocolend)
url$=mid$(url$,protocolend+1)
pathstart=instr(url$,"/")
host$=mid$(url$,1,pathstart-1)
path$=mid$(url$,pathstart)
endproc
proc wget(url$)
call spliturl(url$)
print "protocol: " + protocol$
print "host: " + host$
print "path: " + path$
call serialsend( "AT+CIPSTART="+chr$(34)+"TCP"+chr$(34)+","+chr$(34)+host$+chr$(34)+",80" )
call serialread( )
s$="GET " + path$ + " HTTP/1.1" + chr$(13) + chr$(10) + "Host: " + host$
call serialsend( "AT+CIPSEND=" + str$(len(s$)+4))
call serialread( )
call serialsend( s$ +chr$(13) +chr$(10)+chr$(13) +chr$(10))
call serialread( )
endproc