nabaztag_hack_kit 0.1.0.beta3 → 0.1.0.beta8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -2
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +2 -2
  5. data/CHANGELOG.md +17 -2
  6. data/LICENSE +21 -0
  7. data/README.md +115 -44
  8. data/Rakefile +2 -6
  9. data/bytecode/{Commands.md → _docs/commands.md} +0 -0
  10. data/bytecode/{Docs.md → _docs/grammar.md} +0 -0
  11. data/bytecode/_docs/grammar.pdf +0 -0
  12. data/bytecode/{src → _original}/README.md +0 -0
  13. data/bytecode/{src → _original}/lib/arp.mtl +0 -0
  14. data/bytecode/{src → _original}/lib/cfg.mtl +0 -0
  15. data/bytecode/{src → _original}/lib/choreos.mtl +0 -0
  16. data/bytecode/{src → _original}/lib/dhcp.mtl +0 -0
  17. data/bytecode/{src → _original}/lib/dns.mtl +0 -0
  18. data/bytecode/{src → _original}/lib/http.mtl +0 -0
  19. data/bytecode/{src → _original}/lib/tcp.mtl +0 -0
  20. data/bytecode/{src → _original}/lib/udp.mtl +0 -0
  21. data/bytecode/{src → _original}/lib/util.mtl +0 -0
  22. data/bytecode/{src → _original}/lib/var.mtl +0 -0
  23. data/bytecode/{src → _original}/lib/wav.mtl +0 -0
  24. data/bytecode/{src → _original}/lib/wifi.mtl +0 -0
  25. data/bytecode/{src → _original}/nominal-ping.mtl +0 -0
  26. data/bytecode/main.mtl +11 -11
  27. data/bytecode/test/test.mtl +8 -8
  28. data/examples/basic/Gemfile +1 -3
  29. data/examples/basic/config.ru +14 -4
  30. data/examples/record/Gemfile +0 -5
  31. data/examples/record/{config.ru.example → config.ru} +2 -2
  32. data/examples/record/server.rb +0 -2
  33. data/ext/Makefile +10 -0
  34. data/ext/bin/mtl_comp +29 -0
  35. data/{bytecode → ext}/bin/mtl_merge +0 -0
  36. data/ext/bin/mtl_simu +29 -0
  37. data/{bytecode/src/mtl → ext}/extconf.rb +0 -0
  38. data/ext/mtl_linux/.gitignore +7 -0
  39. data/ext/mtl_linux/LICENSE +21 -0
  40. data/ext/mtl_linux/Makefile +116 -0
  41. data/ext/mtl_linux/MetalC.project +196 -0
  42. data/ext/mtl_linux/conf.bin +0 -0
  43. data/{bytecode/src/mtl → ext/mtl_linux}/conf.bin.sans_password +0 -0
  44. data/{bytecode/src/mtl → ext/mtl_linux}/config.txt +0 -0
  45. data/ext/mtl_linux/inc/log.h +21 -0
  46. data/{bytecode/src/mtl → ext/mtl_linux/inc}/properties.h +0 -0
  47. data/{bytecode/src/mtl/linux_simuaudio.h → ext/mtl_linux/inc/simu/linux/simuaudio.h} +0 -0
  48. data/{bytecode/src/mtl/linux_simunet.h → ext/mtl_linux/inc/simu/linux/simunet.h} +0 -0
  49. data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simuaudio.h +18 -18
  50. data/{bytecode/src/mtl → ext/mtl_linux/inc/simu/win}/simunet.h +0 -0
  51. data/ext/mtl_linux/inc/vcomp/compiler.h +200 -0
  52. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/file.h +11 -11
  53. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/filesystem.h +0 -0
  54. data/ext/mtl_linux/inc/vcomp/interpreter.h +121 -0
  55. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/memory.h +120 -92
  56. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/param.h +0 -0
  57. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/parser.h +27 -27
  58. data/ext/mtl_linux/inc/vcomp/prodbuffer.h +42 -0
  59. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/resource.h +1 -1
  60. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/terminal.h +8 -8
  61. data/{bytecode/src/mtl → ext/mtl_linux/inc}/vcomp/util.h +7 -7
  62. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vaudio.h +0 -0
  63. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vbc.h +1 -1
  64. data/ext/mtl_linux/inc/vm/vbc_str.h +167 -0
  65. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vinterp.h +0 -0
  66. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vloader.h +0 -0
  67. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vlog.h +0 -0
  68. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vmem.h +0 -0
  69. data/{bytecode/src/mtl → ext/mtl_linux/inc/vm}/vnet.h +0 -0
  70. data/ext/mtl_linux/nominal.mtl +3959 -0
  71. data/ext/mtl_linux/src/comp/main.cpp +123 -0
  72. data/ext/mtl_linux/src/simu/dumpbc.c +2566 -0
  73. data/ext/mtl_linux/src/simu/linux/main.cpp +288 -0
  74. data/ext/mtl_linux/src/simu/linux/simu.c +309 -0
  75. data/ext/mtl_linux/src/simu/linux/simuaudio.c +44 -0
  76. data/ext/mtl_linux/src/simu/linux/simunet.c +707 -0
  77. data/ext/mtl_linux/src/simu/log.c +340 -0
  78. data/ext/mtl_linux/src/simu/properties.c +368 -0
  79. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/GTKANAL.H +0 -0
  80. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/LAYER3.C +0 -0
  81. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/TABINIT.C +0 -0
  82. data/ext/mtl_linux/src/simu/win/mp3/common.c +302 -0
  83. data/ext/mtl_linux/src/simu/win/mp3/dct64_i386.c +316 -0
  84. data/ext/mtl_linux/src/simu/win/mp3/decode_i386.c +160 -0
  85. data/ext/mtl_linux/src/simu/win/mp3/huffman.h +332 -0
  86. data/ext/mtl_linux/src/simu/win/mp3/interface.c +276 -0
  87. data/{bytecode/src/mtl → ext/mtl_linux/src/simu/win}/mp3/mpg123.h +34 -30
  88. data/ext/mtl_linux/src/simu/win/mp3/mpglib.h +47 -0
  89. data/ext/mtl_linux/src/simu/win/simu.c +819 -0
  90. data/ext/mtl_linux/src/simu/win/simuaudio.c +787 -0
  91. data/ext/mtl_linux/src/simu/win/simunet.c +489 -0
  92. data/ext/mtl_linux/src/vcomp/bootstrap.cpp +95 -0
  93. data/ext/mtl_linux/src/vcomp/compiler.cpp +587 -0
  94. data/ext/mtl_linux/src/vcomp/compiler_file.cpp +1253 -0
  95. data/ext/mtl_linux/src/vcomp/compiler_prog.cpp +437 -0
  96. data/ext/mtl_linux/src/vcomp/compiler_term.cpp +1500 -0
  97. data/ext/mtl_linux/src/vcomp/compiler_type.cpp +1238 -0
  98. data/ext/mtl_linux/src/vcomp/compiler_var.cpp +502 -0
  99. data/ext/mtl_linux/src/vcomp/file.cpp +100 -0
  100. data/ext/mtl_linux/src/vcomp/interpreter.cpp +93 -0
  101. data/ext/mtl_linux/src/vcomp/memory.cpp +313 -0
  102. data/ext/mtl_linux/src/vcomp/parser.cpp +584 -0
  103. data/ext/mtl_linux/src/vcomp/parser_xml.cpp +137 -0
  104. data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/prodbuffer.cpp +57 -36
  105. data/ext/mtl_linux/src/vcomp/stdlib_core.cpp +130 -0
  106. data/ext/mtl_linux/src/vcomp/terminal.cpp +80 -0
  107. data/{bytecode/src/mtl → ext/mtl_linux/src}/vcomp/util.cpp +18 -11
  108. data/ext/mtl_linux/src/vm/vaudio.c +830 -0
  109. data/ext/mtl_linux/src/vm/vinterp.c +1780 -0
  110. data/ext/mtl_linux/src/vm/vloader.c +139 -0
  111. data/ext/mtl_linux/src/vm/vlog.c +782 -0
  112. data/ext/mtl_linux/src/vm/vmem.c +461 -0
  113. data/ext/mtl_linux/src/vm/vnet.c +298 -0
  114. data/{bytecode/src/mtl → ext/mtl_linux}/utils/correct_const.sh +0 -0
  115. data/lib/nabaztag_hack_kit/server.rb +4 -7
  116. data/lib/nabaztag_hack_kit/version.rb +1 -1
  117. data/lib/nabaztag_hack_kit.rb +2 -2
  118. data/nabaztag_hack_kit.gemspec +10 -11
  119. data/spec/integration/server_spec.rb +3 -3
  120. data/spec/spec_helper.rb +2 -0
  121. data/spec/unit/message_spec.rb +12 -18
  122. data/spec/unit/server_spec.rb +13 -10
  123. metadata +145 -137
  124. data/bytecode/bin/mtl_comp +0 -50
  125. data/bytecode/bin/mtl_simu +0 -49
  126. data/bytecode/src/mtl/Makefile +0 -42
  127. data/bytecode/src/mtl/README.md +0 -13
  128. data/bytecode/src/mtl/bc.cpp +0 -1891
  129. data/bytecode/src/mtl/dumpbc.c +0 -2566
  130. data/bytecode/src/mtl/linux_simu.c +0 -271
  131. data/bytecode/src/mtl/linux_simuaudio.c +0 -16
  132. data/bytecode/src/mtl/linux_simunet.c +0 -620
  133. data/bytecode/src/mtl/log.c +0 -297
  134. data/bytecode/src/mtl/log.h +0 -20
  135. data/bytecode/src/mtl/main_compiler.cpp +0 -104
  136. data/bytecode/src/mtl/main_simu.cpp +0 -221
  137. data/bytecode/src/mtl/mp3/common.c +0 -265
  138. data/bytecode/src/mtl/mp3/dct64_i386.c +0 -316
  139. data/bytecode/src/mtl/mp3/decode_i386.c +0 -155
  140. data/bytecode/src/mtl/mp3/huffman.h +0 -332
  141. data/bytecode/src/mtl/mp3/interface.c +0 -258
  142. data/bytecode/src/mtl/mp3/mpglib.h +0 -44
  143. data/bytecode/src/mtl/properties.c +0 -293
  144. data/bytecode/src/mtl/simu.c +0 -750
  145. data/bytecode/src/mtl/simuaudio.c +0 -662
  146. data/bytecode/src/mtl/simunet.c +0 -400
  147. data/bytecode/src/mtl/vaudio.c +0 -677
  148. data/bytecode/src/mtl/vbc_str.h +0 -166
  149. data/bytecode/src/mtl/vcomp/Makefile +0 -29
  150. data/bytecode/src/mtl/vcomp/bootstrap.cpp +0 -89
  151. data/bytecode/src/mtl/vcomp/compiler.cpp +0 -470
  152. data/bytecode/src/mtl/vcomp/compiler.h +0 -200
  153. data/bytecode/src/mtl/vcomp/compiler_file.cpp +0 -929
  154. data/bytecode/src/mtl/vcomp/compiler_prog.cpp +0 -250
  155. data/bytecode/src/mtl/vcomp/compiler_term.cpp +0 -1053
  156. data/bytecode/src/mtl/vcomp/compiler_type.cpp +0 -872
  157. data/bytecode/src/mtl/vcomp/compiler_var.cpp +0 -289
  158. data/bytecode/src/mtl/vcomp/file.cpp +0 -79
  159. data/bytecode/src/mtl/vcomp/interpreter.cpp +0 -85
  160. data/bytecode/src/mtl/vcomp/interpreter.h +0 -121
  161. data/bytecode/src/mtl/vcomp/memory.cpp +0 -241
  162. data/bytecode/src/mtl/vcomp/parser.cpp +0 -427
  163. data/bytecode/src/mtl/vcomp/parser_xml.cpp +0 -124
  164. data/bytecode/src/mtl/vcomp/prodbuffer.h +0 -42
  165. data/bytecode/src/mtl/vcomp/stdlib_core.cpp +0 -122
  166. data/bytecode/src/mtl/vcomp/terminal.cpp +0 -73
  167. data/bytecode/src/mtl/vinterp.c +0 -1349
  168. data/bytecode/src/mtl/vloader.c +0 -127
  169. data/bytecode/src/mtl/vlog.c +0 -589
  170. data/bytecode/src/mtl/vmem.c +0 -424
  171. data/bytecode/src/mtl/vnet.c +0 -255
  172. data/examples/basic/Procfile +0 -2
  173. data/examples/basic/server.rb +0 -14
@@ -0,0 +1,3959 @@
1
+ // VLISP - Feb 06 - by Sylvain Huet
2
+ // Metal
3
+
4
+ proto main 0;;
5
+
6
+ //var SIMU;;
7
+ var NOMINAL;;
8
+
9
+ var AUDIOLIB;;
10
+
11
+ ifdef NOMINAL
12
+ {
13
+ var AUDIOLIB;;
14
+ var EARSLIB;;
15
+ var INFOLIB;;
16
+ var RECLIB;;
17
+ }
18
+
19
+ ifdef SIMU
20
+ {
21
+ var HARDWARE=4;;
22
+ var DNSLOCAL=999;;
23
+ }
24
+ else
25
+ {
26
+ var HARDWARE=4;;
27
+ var DNSLOCAL=1597;;
28
+ }
29
+
30
+ proto buttoncheckevent 0;;
31
+
32
+
33
+
34
+ type Wifi=initW | gomasterW | masterW | gostationW _ | dhcpW _| stationW | reconnectW;;
35
+ var wifi;;
36
+
37
+ var netip="\0\0\0\0";;
38
+ var netmask="\255\255\255\0";;
39
+ var netgateway="\0\0\0\0";;
40
+ var netdns="\0\0\0\0";;
41
+
42
+ var mymac;;
43
+
44
+ var macbroadcast="\$ff\$ff\$ff\$ff\$ff\$ff";;
45
+ var ipbroadcast="\$ff\$ff\$ff\$ff";;
46
+
47
+ var master=0;;
48
+
49
+ var netip_empty="\0\0\0\0";;
50
+
51
+ var netip_master="\192\168\2\1";;
52
+ var netmask_master="\255\255\255\0";;
53
+ var netgateway_master="\192\168\0\1";;
54
+
55
+ var wifiscans;;
56
+
57
+ var IEEE80211_CRYPT_NONE=0;;
58
+ var IEEE80211_CRYPT_WEP64=1;;
59
+ var IEEE80211_CRYPT_WEP128=2;;
60
+ var IEEE80211_CRYPT_WPA=3;;
61
+ var IEEE80211_CRYPT_WPA_UNSUPPORTED=4;;
62
+
63
+ var IEEE80211_AUTH_OPEN=0;;
64
+ var IEEE80211_AUTH_SHARED=1;;
65
+
66
+ var FIRMWARE=0x01010f;;
67
+
68
+
69
+ // --------------- UTIL debut
70
+ //fun strcmp a b = vstrcmp a 0 b 0 nil;;
71
+ fun strstr s p i=strfind s i p 0 nil;;
72
+ fun itoanil l=if l==nil then '0'::nil else l;;
73
+ fun listlen l=if l==nil then 0 else 1+listlen tl l;;
74
+ fun listrem l x=if l!=nil then if x==hd l then tl l else (hd l)::listrem tl l x;;
75
+ fun slistlen l= if l==nil then 0 else (strlen hd l)+slistlen tl l;;
76
+ fun listnth l i=if !i then hd l else if i>0 then listnth tl l i-1;;
77
+
78
+ fun listtostr l=
79
+ let strnew listlen l -> s in
80
+ let 0->i in
81
+ (
82
+ for p=l;p!=nil;tl p do
83
+ (
84
+ strset s i hd p;
85
+ set i=i+1
86
+ );
87
+ s
88
+ );;
89
+
90
+ fun atoibin2 val=itobin2 atoi val;;
91
+
92
+ fun countpattern s p i=
93
+ let strstr s p i -> j in
94
+ if j==nil then 0
95
+ else 1+countpattern s p j+strlen p;;
96
+
97
+ fun strreplace2 sn s p v i id=
98
+ if i<strlen s then
99
+ let strstr s p i -> j in
100
+ let if j==nil then strlen s else j -> k in
101
+ (
102
+ strcpy sn id s i k-i;
103
+ if j!=nil then strcpy sn id+k-i v 0 nil;
104
+ strreplace2 sn s p v k+strlen p id+k-i+strlen v
105
+ );;
106
+
107
+ fun strreplace s p v=
108
+ let countpattern s p 0 -> i in
109
+ if !i then s
110
+ else let strnew (strlen s) + ((strlen v)-(strlen p))*i -> sn in
111
+ (
112
+ strreplace2 sn s p v 0 0;
113
+ sn
114
+ );;
115
+
116
+
117
+ fun rev p q=if p==nil then q else rev tl p (hd p)::q;;
118
+
119
+ fun remfromlist l t= if l!=nil then if t==hd l then tl l else (hd l)::remfromlist tl l t;;
120
+
121
+ fun insert x l f=
122
+ if l==nil then x::nil
123
+ else let call f [x hd l] -> r in
124
+ if r>0 then (hd l)::insert x tl l f
125
+ else if r<0 then x::l
126
+ else insert x tl l f;;
127
+
128
+ fun sort l f= if l!=nil then insert hd l sort tl l f f;;
129
+
130
+ fun select l a f= if l!=nil then let hd l-> x in if call f [x a] then x::select tl l a f else select tl l a f;;
131
+
132
+ fun conc p q=if p==nil then q else (hd p)::conc tl p q;;
133
+
134
+ fun _useparamip s i val j=
135
+ if i<4 then
136
+ let strstr val "." j -> k in
137
+ (
138
+ strset s i atoi strsub val j if k==nil then nil else k-j;
139
+ _useparamip s i+1 val if k==nil then strlen val else k+1
140
+ );;
141
+
142
+ fun useparamip val=
143
+ let strnew 4 -> ip in
144
+ (
145
+ _useparamip ip 0 val 0;
146
+ ip
147
+ );;
148
+
149
+ fun webip ip=
150
+ strcatlist (itoa strget ip 0)::"."::(itoa strget ip 1)::"."::(itoa strget ip 2)::"."::(itoa strget ip 3)::nil;;
151
+
152
+ fun _webmac key i=
153
+ if i<strlen key then (ctoh strget key i)::if i+1<strlen key then ":"::_webmac key i+1 else _webmac key i+1;;
154
+
155
+ fun webmac key=strcatlist _webmac key 0;;
156
+
157
+ proto setleds 1;;
158
+
159
+ // ---------------- UTIL fin
160
+
161
+ fun MACecho src i0 ln=
162
+ for i=0;i<6 do (Secho ctoh strget src i0+i; Secho "."); if ln then Secholn "";
163
+ src;;
164
+
165
+ fun SEQecho src i0 ln=
166
+ for i=0;i<4 do (Secho ctoh strget src i0+i; Secho "."); if ln then Secholn "";
167
+ src;;
168
+
169
+ fun IPecho src i0 ln=
170
+ for i=0;i<4 do (Iecho strget src i0+i; Secho ".");if ln then Secholn "";
171
+ src;;
172
+
173
+ fun itoh4 i = strcatlist (ctoh i>>24)::(ctoh i>>16)::(ctoh i>>8)::(ctoh i)::nil;;
174
+
175
+ fun dump s=
176
+ for i0=0;i0<strlen s;i0+16 do
177
+ (
178
+ Secho itoh4 i0;
179
+ Secho " ";
180
+ for i=0;i<16 do let strget s i0+i -> c in
181
+ (
182
+ Secho if c==nil then " " else ctoh c;
183
+ Secho " "
184
+ );
185
+ Secho " ";
186
+ for i=0;i<16 do let strget s i0+i -> c in
187
+ (
188
+ Secho if c==nil then " " else if c<32 then "." else ctoa c
189
+ );
190
+ Secholn ""
191
+ );
192
+
193
+ s;;
194
+
195
+ fun dumpscan l0=
196
+ Secholn "## DUMPSCAN >>>>";
197
+ for l=l0;l!=nil;tl l do
198
+ let hd l->[ssid mac bssid rssi channel rateset encryption] in
199
+ (
200
+ Secho "## SCAN "; Secholn ssid;
201
+ Secho "mac:"; MACecho mac 0 1;
202
+ Secho "bssid:"; MACecho bssid 0 1;
203
+ Secho "rssi:"; Iecholn rssi;
204
+ Secho "channel:"; Iecholn channel;
205
+ Secho "rateset:"; Iecholn rateset;
206
+ Secho "encryption:"; Iecholn encryption
207
+ );
208
+ l0;;
209
+
210
+ // ------------- Config debut
211
+ var CONF_SERVERURL=0;; //41
212
+ var CONF_NETDHCP=41;; //1
213
+ var CONF_NETIP=42;; //4
214
+ var CONF_NETMASK=46;; //4
215
+ var CONF_NETGATEWAY=50;; //4
216
+ var CONF_NETDNS=54;; //4
217
+ var CONF_WIFISSID=58;; //32
218
+ var CONF_WIFIAUTH=90;; //1
219
+ var CONF_WIFICRYPT=91;; //1
220
+ var CONF_WIFIKEY0=92;; //64
221
+ var CONF_PROXYENABLE=156;; //1
222
+ var CONF_PROXYIP=157;; //4
223
+ var CONF_PROXYPORT=161;; //2
224
+ var CONF_LOGIN=163;; //6
225
+ var CONF_PWD=169;; //6
226
+ var CONF_WIFIPMK=175;; //32
227
+ var CONF_MAGIC=207;; //1
228
+ var CONF_LENGTH=208;;
229
+
230
+ var conf;;
231
+
232
+ /*
233
+ var conf0=
234
+ "r.nabaztag.com/vl\0-----------------------\
235
+ \1\0\0\0\0\255\255\255\0\0\0\0\0\0\0\0\0\
236
+ \0-------------------------------\
237
+ \0\0abcde\0----------------------------------------------------------\
238
+ \0\0\0\0\0\0\0\
239
+ \0\0\0\0\0\0\
240
+ \0\0\0\0\0\0\
241
+ --------------------------------\
242
+ \$48";;
243
+ */
244
+
245
+ fun confSave=
246
+ Secholn "## save configuration";
247
+ dump conf;
248
+ save conf 0 "conf.bin" 0 CONF_LENGTH;;
249
+
250
+ fun confInit=
251
+ set conf=strnew CONF_LENGTH;
252
+ load conf 0 "conf.bin" 0 CONF_LENGTH;
253
+ /* if (strget conf CONF_MAGIC)!=0x48 then
254
+ (
255
+ set conf=strnew CONF_LENGTH;
256
+ strcpy conf 0 conf0 0 nil;
257
+ confSave;
258
+ set conf=strnew CONF_LENGTH;
259
+ load conf 0 "conf.bin" 0 CONF_LENGTH
260
+ );
261
+ */ dump conf;;
262
+
263
+ fun confGet i len= strsub conf i len;;
264
+
265
+ fun confGetbin i len= strsub conf i len;;
266
+
267
+ fun confGetstr i len=
268
+ let strstr conf "\0" i -> j in
269
+ strsub conf i (if j==nil then len else min len j-i);;
270
+
271
+ fun confSet i val len=
272
+ strcpy conf i val 0 len;;
273
+
274
+ fun confSetbin i val len=strcpy conf i val 0 len;;
275
+
276
+ fun confSetstr i val len=
277
+ let min strlen val len-1 -> len in
278
+ (
279
+ strcpy conf i val 0 len;
280
+ strset conf i+len 0
281
+ );;
282
+
283
+ fun webport s= ((strget s 0)<<8)+strget s 1;;
284
+
285
+ fun confGetWifissid=confGetstr CONF_WIFISSID 32;;
286
+ fun confGetWificrypt=strget confGet CONF_WIFICRYPT 1 0;;
287
+ fun confGetWifikey0=confGetstr CONF_WIFIKEY0 64;;
288
+ fun confGetWifiauth=strget confGet CONF_WIFIAUTH 1 0;;
289
+ fun confGetWifipmk=confGetbin CONF_WIFIPMK 32;;
290
+
291
+ fun confGetDhcp=strget confGet CONF_NETDHCP 1 0;;
292
+ fun confGetNetip=confGet CONF_NETIP 4;;
293
+ fun confGetNetmask=confGet CONF_NETMASK 4;;
294
+ fun confGetNetgateway=confGet CONF_NETGATEWAY 4;;
295
+ fun confGetNetdns=confGet CONF_NETDNS 4;;
296
+
297
+ fun confGetServerUrl=confGetstr CONF_SERVERURL 40;;
298
+ fun confGetLogin=confGet CONF_LOGIN 6;;
299
+ fun confGetPwd=confGet CONF_PWD 6;;
300
+
301
+ fun confGetProxy=strget confGet CONF_PROXYENABLE 1 0;;
302
+ fun confGetProxyip=confGet CONF_PROXYIP 4;;
303
+ fun confGetProxyport=webport confGet CONF_PROXYPORT 2;;
304
+
305
+ // ------------- Config fin
306
+
307
+ ifndef SIMU
308
+ {
309
+
310
+
311
+ // ------------- IP debut
312
+ fun strputchk s i w=
313
+ strset s i ~(w>>8);
314
+ strset s i+1 ~w;
315
+ 0;;
316
+
317
+ // ------------- IP fin
318
+
319
+ // ------------- ARP debut
320
+ var ARPREQ=1;;
321
+ var ARPANS=2;;
322
+
323
+ var larp;;
324
+ var larpreq;;
325
+
326
+
327
+ fun mkarp op ipsrc macdst ipdst=
328
+ strcatlist
329
+ "\$aa\$aa\$03\$00\$00\$00\$08\$06\$00\$01\$08\$00\$06\$04\$00"::(ctoa op)::
330
+ mymac::
331
+ netip::
332
+ macdst::
333
+ ipdst
334
+ ::nil;;
335
+
336
+ fun sendarp ip=
337
+ netSend (mkarp ARPREQ netip macbroadcast ip) 0 nil macbroadcast 0 1;;
338
+
339
+
340
+ fun filterarpip l src =
341
+ if l!=nil then let hd l->[ip _ _] in if !vstrcmp src 8+14 ip 0 4 then filterarpip tl l src
342
+ else (hd l)::filterarpip tl l src;;
343
+
344
+ fun checkarp l src=
345
+ if l!=nil then let hd l->[ip _ cb] in
346
+ (
347
+ if !vstrcmp src 8+14 ip 0 4 then
348
+ let strsub src 8+8 6 -> mac in
349
+ (
350
+ Secho "found MAC target : "; MACecho mac 0 1;
351
+ set larp=[ip mac]::larp;
352
+ call cb [mac]
353
+ );
354
+ checkarp tl l src
355
+ );;
356
+
357
+ fun cbnetarp src mac=
358
+ Secho "<a";
359
+ let strget src 8+7-> op in
360
+ if op==1 then // req
361
+ (
362
+ // Secho "ask ";MACecho src 16+10 1; IPecho src 16+16 1;
363
+ if !vstrcmp src 32 netip 0 4 then
364
+ netSend (mkarp ARPANS netip strsub src 16 6 strsub src 22 4) 0 nil mac 0 1;
365
+ nil
366
+ )
367
+ else if op==2 then
368
+ let larpreq->l in
369
+ (
370
+ set larpreq=filterarpip larpreq src;
371
+ checkarp l src
372
+ );;
373
+
374
+ fun subnet_ ip i=
375
+ if i<0 then 1
376
+ else if ((strget ip i)^(strget netip i))&(strget netmask i) then 0
377
+ else subnet_ ip i-1;;
378
+
379
+ fun subnet ip=
380
+ Secho "test subnet "; IPecho ip 0 1;
381
+ Iecholn subnet_ ip 3;;
382
+
383
+
384
+ fun arpreq ip cb=
385
+ let IPecho (if subnet ip then ip else netgateway) 0 1 -> ip in
386
+ let listswitchstr larp ip -> mac in
387
+ if mac!=nil then call cb [mac]
388
+ else
389
+ (
390
+ sendarp ip;
391
+ set larpreq=[ip time cb]::larpreq; // ### attention � la taille de la liste
392
+ 0
393
+ );;
394
+
395
+ fun filterarp l dt =
396
+ if l!=nil then let hd l->[ip t _] in if (time-t)>dt then filterarp tl l dt
397
+ else
398
+ (
399
+ sendarp ip;
400
+ (hd l)::filterarp tl l dt
401
+ );;
402
+
403
+ fun arptime =
404
+ set larpreq=filterarp larpreq 10;;
405
+
406
+ fun resetarp=
407
+ set larp=nil;
408
+ set larpreq=nil;
409
+ 0;;
410
+
411
+ // ------------- ARP fin
412
+
413
+
414
+ // ------------- UDP debut
415
+ fun mkudp ipsrc ipdst portsrc portdst content=
416
+ let strcatlist
417
+ "\$aa\$aa\$03\$00\$00\$00\$08\$00\$45\$00\$00\$00\$00\$00\$00\$00\100\17\0\0"::
418
+ ipsrc::
419
+ ipdst::
420
+ "\0\0\0\0\0\0\0\0"::
421
+ content::
422
+ nil -> udp in
423
+ (
424
+ strputword udp 8+2 28+strlen content;
425
+ strputword udp 8+20 portsrc;
426
+ strputword udp 8+22 portdst;
427
+ strputword udp 8+24 8+strlen content;
428
+ strputchk udp 8+10 netChk udp 8 20 0;
429
+ strputchk udp 8+26 netChk udp 8+20 (8+strlen content) netChk udp 8+24 2 netChk "\0\17" 0 nil netChk udp 8+12 8 0;
430
+ udp
431
+ );;
432
+
433
+ fun udpSend2 mac udp=
434
+ Secho ">u";
435
+ // dump udp;
436
+ netSend udp 0 nil (MACecho mac 0 1) 0 1;;
437
+
438
+ fun udpsend local localp dst dstp content mac=
439
+ let mkudp local dst localp dstp content -> udp in
440
+ if mac!=nil then udpSend2 mac udp
441
+ else let dst -> ip in // ajouter le test de passerelle
442
+ arpreq ip fixarg2 #udpSend2 udp;;
443
+
444
+ var ludp;;
445
+
446
+ fun remudp l port=
447
+ if l!=nil then let hd l ->[p _] in if p==port then remudp tl l port else (hd l)::remudp tl l port;;
448
+
449
+ fun regudp port cb=
450
+ set ludp=[port cb]::remudp ludp port;;
451
+
452
+ fun unregudp port=
453
+ set ludp=remudp ludp port;;
454
+
455
+ fun resetudp= set ludp=nil;;
456
+
457
+ fun cbnetudp src mac=
458
+ Secho "<u";
459
+ let Iecholn strgetword src 8+20+2 -> locp in
460
+ let listswitch ludp locp -> cb in
461
+ call cb [strsub src 8+20+8 nil mac strsub src 20 4];;
462
+
463
+
464
+ // -------------- UDP fin
465
+
466
+ // ------------- TCP debut
467
+ var TFIN=0x01;;
468
+ var TSYN=0x02;;
469
+ var TRST=0x04;;
470
+ var TPUSH=0x08;;
471
+ var TACK=0x10;;
472
+ var TURGE=0x20;;
473
+
474
+ var STOFF=-1;;
475
+ var STSYN=0;;
476
+ var STEST=1;;
477
+ var STLISTEN=2;;
478
+ var STFIN=3;;
479
+
480
+ var CLIENT_SEQ_START="\0\0\1\0";;
481
+ var CLIENT_SEQ_NULL="\0\0\0\0";;
482
+
483
+ var TCPWRITE=0;;
484
+ var TCPREAD=1;;
485
+ var TCPCLOSE=-1;;
486
+ var TCPSTART=2;;
487
+
488
+ var TCPMAX=1024;;
489
+
490
+ type Tcp=[stateT locT dstT locpT dstpT seqT ackT cbT macT lastsentT retryT locksendT enableT];;
491
+
492
+ fun mktcp_ ipsrc ipdst portsrc portdst seq ack flag content=
493
+ let strcatlist
494
+ "\$aa\$aa\$03\$00\$00\$00\$08\$00\$45\$00\$00\$00\$00\$00\$00\$00\100\6\0\0"::
495
+ ipsrc::
496
+ ipdst::
497
+ "\0\0\0\0"::
498
+ seq::
499
+ ack::
500
+ "\0\0\$ff\$ff\0\0\0\0"::
501
+ if flag&TSYN then "\2\4\5\$b4"::content::nil // 5.b4 final : taille MSS
502
+ else content::nil
503
+ -> tcp in
504
+ let strlen tcp ->len in
505
+ (
506
+ strputword tcp 8+2 len-8;
507
+ strputword tcp 8+20 portsrc;
508
+ strputword tcp 8+22 portdst;
509
+
510
+ strset tcp 8+32 4*if flag&TSYN then 24 else 20;
511
+ strset tcp 8+33 flag;
512
+
513
+ strputchk tcp 8+10 netChk tcp 8 20 0;
514
+
515
+ let strnew 2 -> s in
516
+ (
517
+ strputword s 0 len-28;
518
+ strputchk tcp 8+36
519
+ netChk tcp 8+20 (len-28) netChk s 0 2 netChk "\0\6" 0 nil netChk tcp 8+12 8 0
520
+ );
521
+ tcp
522
+ );;
523
+
524
+ fun mktcp t flag content=
525
+ // Secholn "mktcp "; Secho "seq "; SEQecho t.seqT 0 1; Secho "ack "; SEQecho t.ackT 0 1;
526
+ mktcp_ t.locT t.dstT t.locpT t.dstpT t.seqT t.ackT flag content;;
527
+
528
+ fun resendtcp t=
529
+ netSend t.lastsentT 0 nil (MACecho t.macT 0 1) 0 1;
530
+ 0;;
531
+
532
+ fun headerlen src=((strget src 8+32)>>4)<<2;;
533
+
534
+ fun datalength src=(strgetword src 10)-20-headerlen src;;
535
+
536
+ fun sendtcp t trame=
537
+ // Secholn "tcpSend"; dump trame;
538
+ netSend trame 0 nil (/*MACecho*/ t.macT /*0 1*/) 0 1;
539
+ let strget trame 8+33 -> flag in
540
+ set t.seqT=netSeqAdd t.seqT (datalength trame)+(if flag&(TSYN|TFIN) then 1 else 0);
541
+ 0;;
542
+
543
+ fun sendtcpforretry t trame=
544
+ set t.lastsentT=trame;
545
+ set t.retryT=nil;
546
+ sendtcp t trame;;
547
+
548
+
549
+ fun tcpSend2 mac tcp trame=
550
+ set tcp.macT=mac;
551
+ sendtcpforretry/*sendtcp*/ tcp trame;;
552
+
553
+ var ltcp;;
554
+
555
+
556
+ fun remtcp t=set t.stateT=STOFF; set ltcp=remfromlist ltcp t;;
557
+
558
+ var counttcp;;
559
+
560
+ fun opentcp local localp dst dstp cb=
561
+ let if localp==nil then 1024+set counttcp=((if counttcp==nil then time_ms else counttcp)+1)&16383 else localp -> localp in
562
+ let [stateT:STSYN locT:local dstT:dst locpT:localp dstpT:dstp seqT:CLIENT_SEQ_START ackT:CLIENT_SEQ_NULL cbT:cb enableT:1] -> tcp in
563
+ let mktcp tcp TSYN nil -> trame in
564
+ let dst -> ip in // ajouter le test de passerelle
565
+ (
566
+ set ltcp=tcp::ltcp;
567
+ arpreq ip fixarg2 fixarg3 #tcpSend2 trame tcp;
568
+ tcp
569
+ );;
570
+
571
+ fun listentcp localp cb=
572
+ let [stateT:STLISTEN locpT:localp cbT:cb enableT:1] -> tcp in
573
+ (
574
+ set ltcp=tcp::ltcp
575
+ );;
576
+
577
+ fun findtcp l localp dstp src=
578
+ if l!=nil then let hd l-> t in
579
+ if t.locpT==localp && t.dstpT==dstp && (!vstrcmp src 8+16 t.locT 0 4)&& (!vstrcmp src 8+12 t.dstT 0 4)
580
+ then t
581
+ else if t.stateT==STLISTEN && t.locpT==localp then t
582
+ else findtcp tl l localp dstp src;;
583
+
584
+ fun sendclose t=
585
+ Secholn "## sendclose";
586
+ sendtcp t mktcp t TFIN+TACK nil;
587
+ set t.stateT=STFIN;
588
+ 0;;
589
+
590
+ fun cbnettcp src mac=
591
+ Secho "t";
592
+ let /*Iecholn*/ strgetword src 8+20+2 -> locp in
593
+ let /*Iecholn*/ strgetword src 8+20+0 -> dstp in
594
+ let findtcp ltcp locp dstp src -> t in
595
+ if t!=nil && t.enableT then let t.stateT -> st in
596
+ let /*Iecholn*/ strget src 8+33 -> flag in
597
+ let /*SEQecho*/ (strsub src 8+24 4) /*0 1*/-> rseq in
598
+ let /*SEQecho*/ (strsub src 8+28 4) /*0 1*/-> rack in
599
+ if st==STSYN then
600
+ (
601
+ Secholn "stsyn";
602
+ if (flag==TSYN+TACK) && !vstrcmp (SEQecho(t.seqT)0 1) 0 rack 0 4 then
603
+ (
604
+ set t.ackT=SEQecho (netSeqAdd rseq 1) 0 1;
605
+ sendtcp t mktcp t TACK nil;
606
+ set t.stateT=STEST;
607
+ set t.lastsentT=nil;
608
+ // Secholn "call TCPWRITE";
609
+ call t.cbT [t TCPWRITE nil]
610
+ )
611
+ else
612
+ (
613
+ // Secholn "TSRT+TACK";
614
+ sendtcp t mktcp t TRST+TACK nil;
615
+ remtcp t;
616
+ nil
617
+ )
618
+ )
619
+ else if st==STEST then
620
+ if !vstrcmp t.ackT 0 rseq 0 4 then
621
+ let strgetword src 10 -> iplen in
622
+ let ((strget src 8+32)>>4)<<2 -> tcplen in
623
+ let datalength src -> datalen in
624
+ (
625
+ if datalen then
626
+ (
627
+ // dump src;
628
+ // Iecholn iplen;
629
+ // Iecholn tcplen;
630
+ // Secho "update ackT : add ";
631
+ set t.ackT=netSeqAdd t.ackT datalen
632
+ );
633
+ if flag&TFIN then
634
+ (
635
+ set t.ackT=netSeqAdd t.ackT 1;
636
+ nil
637
+ )
638
+ else if !vstrcmp t.seqT 0 rack 0 4 then
639
+ (
640
+ // Secholn "acquittement de l'envoi";
641
+ set t.lastsentT=nil; // acquittement de l'envoi
642
+ if t.locksendT==1 then
643
+ (
644
+ set t.locksendT=0;
645
+ call t.cbT [t TCPWRITE nil]
646
+ )
647
+ else if t.locksendT==2 then
648
+ (
649
+ sendclose t;
650
+ nil
651
+ )
652
+ )
653
+ else (Secholn "##bad ack"; SEQecho t.seqT 0 1;SEQecho rack 0 1; nil);
654
+ if datalen then
655
+ let 8+20+headerlen src -> start in
656
+ let strsub src start datalen -> data in
657
+ call t.cbT [t TCPREAD data];
658
+ if datalen || flag&TFIN then sendtcp t mktcp t TACK nil;
659
+ if flag&TFIN then
660
+ (
661
+ sendtcp t mktcp t TFIN+TACK nil;
662
+ remtcp t;
663
+ call t.cbT [t TCPCLOSE nil]
664
+ )
665
+ )
666
+ else (/*SEQecho(t.ackT)0 1; SEQecho rseq 0 1;*/Secho "##bs/";sendtcp t mktcp t TACK nil; nil)
667
+ else if st==STFIN then
668
+ (
669
+ Secholn "STFIN";
670
+ set t.ackT=SEQecho (netSeqAdd rseq 1) 0 1;
671
+ sendtcp t mktcp t TACK nil;
672
+ remtcp t;
673
+ nil
674
+ )
675
+ else if st==STLISTEN then
676
+ if flag&TSYN then
677
+ (
678
+ let [stateT:STEST locT:(strsub src 8+16 4) dstT:(strsub src 8+12 4) locpT:locp dstpT:dstp
679
+ seqT:CLIENT_SEQ_START ackT:(netSeqAdd rseq 1) cbT:t.cbT macT:mac enableT:1] -> tcp in
680
+ (
681
+ set ltcp=tcp::ltcp;
682
+ sendtcpforretry tcp mktcp tcp TACK+TSYN nil;
683
+ call tcp.cbT [tcp TCPSTART nil]
684
+ )
685
+ )
686
+ ;;
687
+
688
+
689
+ fun writetcp t msg i=
690
+ if t.stateT!=STEST then nil
691
+ else if t.lastsentT!=nil then
692
+ (
693
+ // Secholn "locksend";
694
+ set t.locksendT=1;
695
+ i
696
+ )
697
+ else let strsub msg i TCPMAX -> content in
698
+ let mktcp t TACK content -> trame in
699
+ (
700
+ sendtcpforretry t trame;
701
+ let i+strlen content -> ni in
702
+ (
703
+ if ni!=strlen msg then set t.locksendT=1;
704
+ ni
705
+ )
706
+ );;
707
+
708
+
709
+ fun closetcp t=
710
+ if t.stateT!=STEST then 0
711
+ else if t.lastsentT!=nil then
712
+ (
713
+ set t.locksendT=2;
714
+ 0
715
+ )
716
+ else sendclose t;
717
+ 0;;
718
+
719
+ fun tcpcb t cb= set t.cbT=cb;;
720
+
721
+ fun enabletcp t v= set t.enableT=v;;
722
+
723
+ fun tcptime =
724
+ for l=ltcp;l!=nil;tl l do let hd l-> t in
725
+ if t.lastsentT!=nil then
726
+ (
727
+ if t.retryT!=nil then
728
+ (
729
+ set t.retryT=1+t.retryT;
730
+ if t.retryT>10 then
731
+ (
732
+ remtcp t;
733
+ call t.cbT [t TCPCLOSE nil];
734
+ nil
735
+ )
736
+ else resendtcp t
737
+ )
738
+ else set t.retryT=0
739
+ );
740
+ 0;;
741
+
742
+ fun resettcp=
743
+ set ltcp=nil;
744
+ 0;;
745
+
746
+ // -------------- TDP fin
747
+
748
+ // --------------- DHCP debut
749
+
750
+ var DHCP_DISCOVER=1;;
751
+ var DHCP_OFFER=2;;
752
+ var DHCP_REQUEST=3;;
753
+ var DHCP_DECLINE=4;;
754
+ var DHCP_ACK=5;;
755
+
756
+ fun mkdhcp op netip hostip newip =
757
+ let 236+16+14->n in
758
+ let strnew n -> b in
759
+ (
760
+ for i=0;i<n do strset b i 0;
761
+ strcpy b 0 "\1\1\6" 0 3;
762
+ strcpy b 12 netip 0 4;
763
+ strcpy b 12+16 mymac 0 6;
764
+ strcpy b 236 "\99\130\83\99\53\1" 0 6;
765
+ strset b 236+6 op;
766
+ strcpy b 236+7 "\61\7\1" 0 3;
767
+ strcpy b 236+10 mymac 0 6;
768
+ strcpy b 236+16 "\12\7Pabcdef\55\3\1\3\6" 0 14;
769
+ if op==DHCP_REQUEST then strcatlist b::"\54\4"::hostip::"\50\4"::newip::"\255"::nil
770
+ else strcat b "\255"
771
+ );;
772
+
773
+ fun mkdhcpans op tid newip dmac=
774
+ let 236+7->n in
775
+ let strnew n -> b in
776
+ (
777
+ for i=0;i<n do strset b i 0;
778
+ strcpy b 0 "\2\1\6" 0 3;
779
+ strcpy b 4 tid 0 4;
780
+ strcpy b 16 newip 0 4;
781
+ strcpy b 12+16 dmac 0 6;
782
+ strcpy b 236 "\99\130\83\99\53\1" 0 6;
783
+ strset b 236+6 op;
784
+ strcatlist b::"\54\4"::newip::"\51\4\0\1\$51\$80\1\4"::netmask::"\3\4"::netip::"\6\4"::netip::"\15\4home\255"::nil
785
+ );;
786
+
787
+ fun extractdhcp src i type lease submask dns gateway mac=
788
+ if i<strlen src then
789
+ let strget src i -> c in
790
+ if c==255 then [type lease submask dns gateway mac]
791
+ else let strget src i+1 -> len in
792
+ let i+2->i in
793
+ if c==53 then extractdhcp src i+len (strget src i) lease submask dns gateway mac
794
+ else if c==51 then extractdhcp src i+len type (strgetword src i) submask dns gateway mac
795
+ else if c==1 then extractdhcp src i+len type lease (strsub src i 4) dns gateway mac
796
+ else if c==6 then extractdhcp src i+len type lease submask (strsub src i 4) gateway mac
797
+ else if c==3 then extractdhcp src i+len type lease submask dns (strsub src i 4) mac
798
+ else if c==61 then extractdhcp src i+len type lease submask dns gateway (strsub src i+1 6)
799
+ else extractdhcp src i+len type lease submask dns gateway mac;;
800
+
801
+ fun mkdhcpip mac=
802
+ let strnew 4 -> s in
803
+ (
804
+ strcpy s 0 netip 0 4;
805
+ strset s 3 ((strget mac 5)&0x7f)+100;
806
+ s
807
+ );;
808
+
809
+ fun cbnetdhcp src macfrom hostip=
810
+ Secholn "<dhcp"; MACecho macfrom 0 1;
811
+ let strget src 0 -> x in
812
+ let MACecho (strsub src 28 6)0 1 -> mac in
813
+ if x==2 && !strcmp mac mymac then
814
+ (
815
+ let IPecho (strsub src 16 4) 0 1-> newip in
816
+ let extractdhcp src 240 0 nil nil nil nil nil->[type lease submask dns gateway _] in
817
+ if type==DHCP_OFFER then
818
+ (
819
+ Secholn ">>>>>>>>>>>>>>>OFFER";
820
+ udpsend netip 68 ipbroadcast 67 (mkdhcp DHCP_REQUEST netip hostip newip) macbroadcast;
821
+ nil
822
+ )
823
+ else if type==DHCP_ACK then
824
+ (
825
+ Secholn ">>>>>>>>>>>>>>>ACK";
826
+ Secho "server ";IPecho hostip 0 1;
827
+ Secho "ip ";IPecho set netip=newip 0 1;
828
+ Secho "type ";Iecholn type;
829
+ Secho "leasetime ";Iecholn lease;
830
+ Secho "submask ";IPecho set netmask=submask 0 1;
831
+ Secho "dns ";IPecho set netdns=dns 0 1;
832
+ Secho "gateway ";IPecho set netgateway=gateway 0 1;
833
+ nil
834
+ )
835
+ );;
836
+
837
+ fun cbnetdhcp67 src macfrom hostip=
838
+ Secholn "<dhcp"; MACecho macfrom 0 1;
839
+ let strget src 0 -> x in
840
+ let MACecho (strsub src 28 6)0 1 -> mac in
841
+ if x==1 /*&& !strcmp mac mymac*/ then
842
+ (
843
+ let extractdhcp src 240 0 nil nil nil nil nil ->[type _ _ _ _ dmac] in
844
+ let strsub src 4 4 -> tid in
845
+ let mkdhcpip macfrom -> newip in
846
+ if type==DHCP_DISCOVER then
847
+ (
848
+ Secholn ">>>>>>>>>>>>>>>DISCOVER";
849
+ // dump src;
850
+ udpsend netip 67 ipbroadcast 68 (mkdhcpans DHCP_OFFER tid newip dmac) macbroadcast;
851
+ nil
852
+ )
853
+ else if type==DHCP_REQUEST then
854
+ (
855
+ Secholn ">>>>>>>>>>>>>>>REQUEST";
856
+ // dump src;
857
+ udpsend netip 67 ipbroadcast 68 (mkdhcpans DHCP_ACK tid newip dmac) macbroadcast;
858
+ nil
859
+ )
860
+
861
+ );;
862
+
863
+ fun startdhcp=
864
+ udpsend netip 68 ipbroadcast 67 (mkdhcp DHCP_DISCOVER "\0\0\0\0" nil nil) macbroadcast;
865
+ regudp 68 #cbnetdhcp;
866
+ 0;;
867
+
868
+ fun startdhcpserver=
869
+ regudp 67 #cbnetdhcp67;
870
+ 0;;
871
+
872
+ // --------------- DHCP fin
873
+
874
+
875
+ // --------------- net HOOK debut
876
+
877
+ fun net src mac=
878
+ Secho "n ";//MACecho mac 0 1;
879
+ // dump src;
880
+ let strget src 7 -> p in
881
+ (
882
+ if p==6 then cbnetarp src mac // ARP
883
+ else if p==0 then
884
+ let strget src 17 -> ip in
885
+ if ip==6 then cbnettcp src mac
886
+ else if ip==17 then cbnetudp src mac;
887
+ 0
888
+ );
889
+ buttoncheckevent;
890
+ 0;;
891
+
892
+ fun netstart=
893
+ netCb #net;
894
+ resetarp;
895
+ resettcp;
896
+ resetudp;
897
+ 0;;
898
+
899
+ fun nettime=
900
+ arptime;
901
+ tcptime;
902
+ 0;;
903
+
904
+ // --------------- net HOOK fin
905
+
906
+ }
907
+ else
908
+ {
909
+
910
+ // --------------- TCP/UDP EMULATION debut
911
+
912
+ var TCPWRITE=0;;
913
+ var TCPREAD=1;;
914
+ var TCPCLOSE=-1;;
915
+ var TCPSTART=2;;
916
+
917
+ fun udpsend local localp dst dstp content mac=
918
+ udpSend localp dst dstp content 0 nil;;
919
+
920
+ var ludp;;
921
+
922
+ fun regudp port cb=
923
+ set ludp=[udpStart port cb]::ludp;;
924
+
925
+ fun resetudp=set ludp=nil;;
926
+
927
+
928
+ fun netudp t src ip=
929
+ let listswitch ludp t -> cb in
930
+ call cb [src nil ip];;
931
+
932
+ var ltcp;;
933
+
934
+ fun writetcp t msg i=
935
+ tcpSend t msg i nil;;
936
+
937
+ fun remtcp l t= if l!=nil then let hd l->[tt _] in if t==tt then tl l
938
+ else (hd l)::remtcp tl l t;;
939
+
940
+ fun updatetcp l t cb= if l!=nil then let hd l->[tt _] in if t==tt then [t cb]::tl l
941
+ else (hd l)::updatetcp tl l t cb;;
942
+
943
+ fun closetcp t=
944
+ set ltcp=remtcp ltcp t;
945
+ tcpClose t;;
946
+
947
+ fun tcpcb t cb=
948
+ set ltcp=updatetcp ltcp t cb;
949
+ cb;;
950
+
951
+ fun listentcp port cb=
952
+ set ltcp=[tcpListen port cb]::ltcp;;
953
+
954
+
955
+ fun opentcp local localp dst dstp cb=
956
+ // Secholn "opentcp";IPecho dst 0 0; Secho ":"; Iecholn dstp;
957
+
958
+ let tcpOpen dst dstp -> t in
959
+ if t!=nil then
960
+ (
961
+ set ltcp=[t cb]::ltcp;
962
+ t
963
+ );;
964
+
965
+ fun enabletcp t v=
966
+ tcpEnable t v;;
967
+
968
+ fun nettcp t val msg=
969
+ if val==TCPSTART then
970
+ let listswitch ltcp atoi msg -> cb in
971
+ (
972
+ if cb==nil then Secholn "callback is nil"
973
+ else Secholn "callback is not nil";
974
+ set ltcp=[t cb]::ltcp;
975
+ call cb [t val msg]
976
+ )
977
+ else let listswitch ltcp t -> cb in
978
+ call cb [t val msg];;
979
+
980
+ fun startdhcp=0;;
981
+ fun startdhcpserver=0;;
982
+
983
+ fun nettime=0;;
984
+
985
+ fun netstart=
986
+ tcpCb #nettcp;
987
+ udpCb #netudp;
988
+ set ltcp=nil;
989
+ set ludp=nil;
990
+ // set wifi=stationW;
991
+ set netdns=confGetNetdns;
992
+ set netdns="\192\168\1\1";
993
+ // set netdns="\10\0\1\1";
994
+ set netip="\127\0\0\1";
995
+ 0;;
996
+ // --------------- TCP/UDP EMULATION fin
997
+ }
998
+
999
+ // --------------- DNS debut
1000
+ fun parsequ s i= let strfind s i "\0" 0 nil -> j in j+5;;
1001
+
1002
+ fun parsequs s i n= if n<=0 then i else parsequs s parsequ s i n-1;;
1003
+
1004
+ fun skipname s i=
1005
+ let strgetword s i -> x in
1006
+ if (x&0xc000)==0xc000 then i+2
1007
+ else (strfind s i "\0" 0 nil)+1;;
1008
+
1009
+ fun parseans s i n=
1010
+ if n<=0 then nil
1011
+ else let skipname s i -> j in
1012
+ let strgetword s j -> typ in
1013
+ if typ==1 then
1014
+ strcatlist (itoa strget s j+10)::"."::(itoa strget s j+11)::"."::
1015
+ (itoa strget s j+12)::"."::(itoa strget s j+13)::nil
1016
+ else parseans s (j+10+strgetword s j+8) n-1;;
1017
+
1018
+ fun parsemsg s=
1019
+ let strgetword s 0 -> id in
1020
+ let strgetword s 2 -> code in
1021
+ let strgetword s 4 -> nbqu in
1022
+ let strgetword s 6 -> nbans in
1023
+ if nbans==0 then nil
1024
+ else let parsequs s 12 nbqu -> i in
1025
+ parseans s i nbans;;
1026
+
1027
+ fun filterdns src=
1028
+ let strfind src 0 "." 0 nil ->i in
1029
+ if i!=nil then
1030
+ strcat
1031
+ strcat ctoa i strsub src 0 i
1032
+ filterdns strsub src i+1 nil
1033
+ else strcat ctoa strlen src src;;
1034
+
1035
+ fun question id dns=
1036
+ strcatlist (itobin2 id)::"\$01\$00\$00\$01\$00\$00\$00\$00\$00\$00"::(filterdns dns)::"\$00\$00\$01\$00\$01"::nil;;
1037
+
1038
+ var dnsid=0;;
1039
+
1040
+ type Dns=[idD domainD reqD timeoutD cbD];;
1041
+ var ldnsreq;;
1042
+ var ldns;;
1043
+
1044
+ fun dnsreq domain cb=
1045
+ set dnsid=if dnsid==nil then time_ms else dnsid+1;
1046
+ let listswitchstr ldns domain -> ip in
1047
+ if ip!=nil then call cb[ip]
1048
+ else let dump question dnsid domain -> tramedns in
1049
+ (
1050
+ udpsend netip DNSLOCAL netdns 53 tramedns nil;
1051
+ set ldnsreq=[idD:dnsid domainD:domain reqD:tramedns timeoutD:time+5 cbD:cb]::ldnsreq;
1052
+ nil
1053
+ );
1054
+ 0;;
1055
+
1056
+ fun selectbyid d v= d.idD==v;;
1057
+
1058
+ fun cbnetdns msg mac ipfrom=
1059
+ let strgetword msg 0 -> id in
1060
+ let parsemsg msg -> ip in
1061
+ let hd select ldnsreq id #selectbyid -> x in
1062
+ if x!=nil then
1063
+ (
1064
+ set ldnsreq=listrem ldnsreq x;
1065
+ if ip!=nil then set ldns=[x.domainD ip]::ldns; // ### attention � la taille de la liste
1066
+ call x.cbD [ip]
1067
+ );
1068
+ 0;;
1069
+
1070
+ fun filterdnsdead l=if l!=nil then let hd l-> d in if d.timeoutD==nil then filterdnsdead tl l else (hd l)::filterdnsdead tl l;;
1071
+
1072
+ fun dnstime=
1073
+ for l=ldnsreq;l!=nil;tl l do let hd l-> d in
1074
+ if time-d.timeoutD>=0 then
1075
+ (
1076
+ set d.timeoutD=nil;
1077
+ call d.cbD [nil]
1078
+ );
1079
+ set ldnsreq=filterdnsdead ldnsreq;
1080
+ 0;;
1081
+
1082
+
1083
+ fun startdnsclient=
1084
+ regudp DNSLOCAL #cbnetdns;
1085
+ set ldnsreq=nil;
1086
+ set ldns=nil;
1087
+ 0;;
1088
+
1089
+ // --------------- DNS fin
1090
+
1091
+
1092
+ //-------------------
1093
+ var HTTP_NORMAL=0;;
1094
+ var HTTP_STREAM=1;;
1095
+ var HTTP_DIRECT=2;;
1096
+
1097
+ var HTTP_SOLVE=0;;
1098
+ var HTTP_REACH=1;;
1099
+ var HTTP_CONNECTED=2;;
1100
+
1101
+ var lasthttpevent;;
1102
+
1103
+ // type Httpreq contenant l'�tat d'une requ�te
1104
+ type Httpreq=[cnxH inputH outputH indexH cbH typeH stateH aliveH];;
1105
+
1106
+ // callback de lecture sur la socket d'une requ�te
1107
+ fun tcpread cnx input httpreq=
1108
+ if input==nil ||0==strlen input then // erreur ou fin
1109
+ ( closetcp cnx; // on ferme la socket
1110
+ if httpreq.typeH==HTTP_NORMAL then call httpreq.cbH [httpreq strcatlist rev httpreq.inputH nil] // on retourne ce qui a �t� re�u
1111
+ else call httpreq.cbH [httpreq nil]
1112
+ )
1113
+ else
1114
+ (
1115
+ // dump input;
1116
+ set lasthttpevent=time;
1117
+ set httpreq.aliveH=time_ms;
1118
+ if httpreq.typeH==HTTP_NORMAL then set httpreq.inputH=input::httpreq.inputH // on bufferise ce qui a �t� re�u
1119
+ else if httpreq.typeH==HTTP_DIRECT then
1120
+ (
1121
+ call httpreq.cbH [httpreq input];
1122
+ nil
1123
+ )
1124
+ else let strcat hd httpreq.inputH input -> s in
1125
+ let strstr s "\13\10\13\10" 0 -> i in
1126
+ if i==nil then
1127
+ (
1128
+ set httpreq.inputH=s::nil
1129
+ )
1130
+ else
1131
+ (
1132
+ set httpreq.inputH=nil;
1133
+ set httpreq.typeH=HTTP_DIRECT;
1134
+ call httpreq.cbH [httpreq strsub s 0 i];
1135
+ if i+4<strlen s then call httpreq.cbH [httpreq strsub s i+4 nil];
1136
+ nil
1137
+ );
1138
+ nil
1139
+ );;
1140
+
1141
+ // callback d'�criture sur la socket d'une requ�te
1142
+ fun tcpwrite cnx httpreq=
1143
+ set httpreq.stateH=HTTP_CONNECTED;
1144
+ set httpreq.aliveH=time_ms;
1145
+ if httpreq.outputH!=nil then // s'il y a des choses � envoyer (notamment la premi�re fois)
1146
+ (
1147
+ set httpreq.indexH=writetcp cnx httpreq.outputH httpreq.indexH; // envoyer ce qui peut l'�tre
1148
+ if httpreq.indexH==nil then // si erreur lors de l'envoi
1149
+ ( closetcp cnx; // on ferme la socket
1150
+ call httpreq.cbH [httpreq nil] ) // on retourne nil
1151
+ else if httpreq.indexH>=strlen httpreq.outputH then // sinon si tout a �t� envoy�
1152
+ ( set httpreq.indexH=nil; // purger les donn�es d'�mission
1153
+ set httpreq.outputH=nil;
1154
+ nil
1155
+ )
1156
+ );;
1157
+
1158
+ var http_prefurl="http://";; // en-t�te normal (mais ici facultatif) d'une requ�te http
1159
+
1160
+ fun isip s i=
1161
+ if i>=strlen s then 1
1162
+ else let strget s i -> c in
1163
+ if (c<'0' || c>'9')&&c!='.' then 0
1164
+ else isip s i+1;;
1165
+
1166
+
1167
+ // d�couper une url en [host port path].
1168
+ // host est de la forme ip:port
1169
+ // path ne commence pas par /
1170
+ fun cuturl url =
1171
+ if !strcmp (strsub url 0 strlen http_prefurl) http_prefurl then cuturl strsub url strlen http_prefurl strlen url
1172
+ else let strstr url "/" 0 -> i in
1173
+ let if i==nil then url else strsub url 0 i -> addr in
1174
+ let strstr addr ":" 0 -> j in
1175
+ let if j==nil then [addr 80]
1176
+ else [strsub addr 0 j atoi strsub addr j+1 strlen addr] -> [host port] in
1177
+ let if i==nil then "/" else strsub url i strlen url -> path in
1178
+ [host port path];;
1179
+
1180
+ fun tcpevent t val msg sock=
1181
+ if val==TCPWRITE then tcpwrite t sock
1182
+ else if val==TCPCLOSE then tcpread t nil sock
1183
+ else tcpread t msg sock;
1184
+ 0;;
1185
+
1186
+
1187
+ fun httpsendreq ip x=
1188
+ Secho "found ip>>>>>>>>>>>>>>>>>>>>>>>>>"; Secholn ip;
1189
+ let x->[port httpreq] in
1190
+ if ip==nil then (call httpreq.cbH [httpreq nil]; nil)
1191
+ else
1192
+ (
1193
+ set httpreq.cnxH=opentcp netip nil useparamip ip port fixarg4 #tcpevent httpreq;
1194
+ set httpreq.stateH=HTTP_REACH;
1195
+ nil
1196
+ );
1197
+ 0;;
1198
+
1199
+
1200
+ //##> cr�ation d'une requ�te http
1201
+ // param�tres : verb=verbe de la requ�te url=url de la requ�te postdata=donn�es suppl�mentaires (nil si aucune) cb=callback de retour
1202
+ fun httprequest verb url postdata cb type=
1203
+ // Secho "HTTPREQUEST url =";Secholn url;
1204
+ let cuturl url ->[host port path] in // d�codage de l'url de la requ�te
1205
+ let if confGetProxy then strcatlist "http://"::host::":"::(itoa port)::path::nil else path -> path in //Icy-MetaData:1\13\n
1206
+ let strcatlist verb::" "::path::" HTTP/1.0\13\nUser-Agent: MTL\13\nPragma: no-cache\13\nIcy-MetaData:1\13\nHost: "::host::"\13\n"::
1207
+ if postdata==nil then "\13\n"::nil
1208
+ else "Content-length: "::(itoa strlen postdata)::"\13\n\13\n"::postdata::nil
1209
+ -> request in // cr�ation de la cha�ne requ�te
1210
+ let if confGetProxy then webip confGetProxyip else host -> host in
1211
+ let if confGetProxy then confGetProxyport else port -> port in
1212
+ let [outputH:request indexH:0 cbH:cb typeH:type stateH:HTTP_SOLVE aliveH:time_ms] -> httpreq in // cr�ation de la structure requ�te
1213
+ (
1214
+ // Secho "HTTPREQUEST host =";Secholn host;
1215
+ if isip host 0 then httpsendreq host [port httpreq]
1216
+ else
1217
+ (
1218
+ dnsreq host fixarg2 #httpsendreq [port httpreq];
1219
+ nil
1220
+ );
1221
+ httpreq // on retourne la structure requ�te pour pouvoir �ventuellement l'interrompre en cours de route
1222
+ );;
1223
+
1224
+ //##> interruption d'une requ�te en cours
1225
+ fun httpabort httpreq=
1226
+ closetcp httpreq.cnxH;; // on ferme la socket de la requ�te
1227
+
1228
+ fun httpenable httpreq v=
1229
+ enabletcp httpreq.cnxH v;;
1230
+
1231
+ fun httpstate httpreq = httpreq.stateH;;
1232
+
1233
+ fun httpinactive httpreq = time_ms-httpreq.aliveH;;
1234
+
1235
+
1236
+ var http_sep="\13\n\13\n";; // s�parateur entre l'en-t�te et le corps de la r�ponse � une requ�te
1237
+
1238
+
1239
+
1240
+ //##> retourne le header d'une r�ponse � une requ�te
1241
+ fun httpgetheader res =
1242
+ let strstr res http_sep 0 -> i in
1243
+ if i==nil then res
1244
+ else strsub res 0 i+strlen http_sep;;
1245
+
1246
+ //##> retourne le contenu d'une r�ponse � une requ�te (sans header)
1247
+ fun httpgetcontent res =
1248
+ let strstr res http_sep 0 -> i in
1249
+ if i==nil then nil
1250
+ else strsub res i+strlen http_sep strlen res;;
1251
+
1252
+ //-------------------
1253
+
1254
+ ifdef RECLIB {
1255
+ var lrec;;
1256
+ var recording=0;;
1257
+
1258
+ fun sqrt_ i i0 i1=
1259
+ let (i0+i1)>>1 -> m in
1260
+ if m==i0 then i0
1261
+ else if m*m>i then sqrt_ i i0 m else sqrt_ i m i1;;
1262
+ fun sqrt i=sqrt_ i 0 256;;
1263
+
1264
+ var buff;;
1265
+ var buffx;;
1266
+ var buffy;;
1267
+
1268
+ fun cbrec s=
1269
+ /* if buff==nil then set buff=strnew 505*2;
1270
+ if buffx==nil then set buffx=strnew 505;
1271
+ if buffy==nil then set buffy=strnew 505*2;
1272
+ adp2wav buff 0 s 0 256;
1273
+ // wav2alaw buffx 0 buff 0 505*2 1;
1274
+ // alaw2wav buffy 0 buffx 0 505 1;
1275
+ set s=wav2adp strnew 256 0 buff 0 505*2;
1276
+ */
1277
+ Iecho strlen s; Secho "!";
1278
+ let 255-(Iecholn sqrt recVol s 0) -> vol in
1279
+ let 255-((vol*vol)>>8) -> vol in
1280
+ let vol<<16 -> vol in
1281
+ (
1282
+ led 1 vol; led 2 vol; led 3 vol
1283
+ );
1284
+ set lrec=s::lrec;
1285
+ 0;;
1286
+
1287
+ fun itobin4 i=
1288
+ let strnew 4 -> s in
1289
+ (
1290
+ strset s 0 i;
1291
+ strset s 1 i>>8;
1292
+ strset s 2 i>>16;
1293
+ strset s 3 i>>24;
1294
+ s
1295
+ );;
1296
+
1297
+ fun liststrlen l r= if l==nil then r else liststrlen tl l r+strlen hd l;;
1298
+
1299
+ fun mkriff ldata=
1300
+ Secho "mkriff len=";
1301
+ let Iecholn liststrlen ldata 0 -> len in
1302
+ (strcatlist "RIFF"::(itobin4 len+52)::"WAVEfmt \$14\0\0\0\$11\0\1\0\$40\$1f\0\0\$d7\$0f\0\0\0\1\4\0\2\0\$f9\01"::
1303
+ "fact\4\0\0\0"::(itobin4 (len>>8)*505)::"data"::(itobin4 len)::nil)::ldata;;
1304
+
1305
+ fun recstart =
1306
+ recStop;
1307
+ Secholn "record";
1308
+ set recording=1;
1309
+ set lrec=nil;
1310
+ recStart 8000 0 #cbrec;;
1311
+
1312
+ fun recstop =
1313
+ set recording=0;
1314
+ recStop;;
1315
+
1316
+ fun recriff =
1317
+ let mkriff rev lrec nil -> res in
1318
+ (
1319
+ set lrec=nil;
1320
+ res
1321
+ );;
1322
+
1323
+ }
1324
+
1325
+ ifdef AUDIOLIB {
1326
+
1327
+ var WAV_IDLE=0;;
1328
+ var WAV_RUN=1;;
1329
+ var WAV_EOF=2;;
1330
+
1331
+ var WAV_BUFFER_STARTSIZE=80000;;
1332
+ var WAV_BUFFER_MAXSIZE=400000;;
1333
+
1334
+ var WAV_END_TIMEOUT=500;;
1335
+ var WAV_NET_TIMEOUT=10000;;
1336
+
1337
+ var wav_end_timeout;;
1338
+
1339
+ var wav_state=0;;
1340
+ var wav_http;;
1341
+ var wav_fifo;;
1342
+ var wav_buffering;;
1343
+ var wav_index;;
1344
+ var wav_lasttime;;
1345
+ var wav_lastnet;;
1346
+ var wav_zeros;;
1347
+
1348
+ var lastvol;;
1349
+ var forcedvol=0;;
1350
+ fun volfrombutton v=let 255-v -> v in 255-((v*v)>>8);;
1351
+
1352
+ fun updatevol=
1353
+ let button3 -> v in
1354
+ if !forcedvol && v!=lastvol && (!recording) && (lastvol!=255 || v<250) then
1355
+ (
1356
+ set lastvol=v;
1357
+ sndVol volfrombutton v
1358
+ );;
1359
+
1360
+ fun forcevol v=
1361
+ sndVol volfrombutton (button3*v)>>8;
1362
+ set forcedvol=1;
1363
+ 0;;
1364
+ fun unforcevol=
1365
+ set forcedvol=0;
1366
+ set lastvol=nil;
1367
+ 0;;
1368
+
1369
+ fun wavgetzeros=
1370
+ if wav_zeros==nil then
1371
+ (
1372
+ set wav_zeros=strnew 2048;
1373
+ for i=0;i<2048 do strset wav_zeros i 0
1374
+ );
1375
+ wav_zeros;;
1376
+
1377
+ fun wavstop =
1378
+ Secholn "###wavstop";
1379
+ if wav_state!=WAV_IDLE then
1380
+ (
1381
+ playStop;
1382
+ if wav_http!=nil then httpabort wav_http;
1383
+ set wav_http=nil;
1384
+ set wav_state=WAV_IDLE
1385
+ );;
1386
+
1387
+ fun wavrunning =
1388
+ if wav_state==WAV_IDLE then 0
1389
+ else if wav_fifo==nil && wav_state==WAV_EOF && (time_ms-wav_lasttime>wav_end_timeout) then
1390
+ (
1391
+ Secholn "###wav detected end";
1392
+ wavstop;
1393
+ 0
1394
+ )
1395
+ else if wav_lasttime==nil then -1 else 1;;
1396
+
1397
+ fun _wavcb i =
1398
+ //Secho "p";
1399
+ set wav_lasttime=time_ms;
1400
+ // Iecho i;Secho ":cbplay\n";
1401
+ if wav_fifo==nil then
1402
+ (
1403
+ if wav_state==WAV_EOF then playFeed nil nil nil
1404
+ else
1405
+ (
1406
+ if !wav_buffering then Secholn ">>>>buffering...............";
1407
+ set wav_buffering=1
1408
+ )
1409
+ )
1410
+ else
1411
+ (
1412
+ if wav_buffering && (wav_state==WAV_EOF || (slistlen wav_fifo)>=WAV_BUFFER_STARTSIZE)
1413
+ then set wav_buffering=0;
1414
+ if !wav_buffering then let hd wav_fifo -> sample in
1415
+ let strlen sample -> len in
1416
+ (
1417
+ if wav_index<len then
1418
+ set wav_index=wav_index+playFeed sample /*Iecho*/ wav_index nil;
1419
+ if wav_index>=len then
1420
+ (
1421
+ set wav_index=0;
1422
+ set wav_fifo=tl wav_fifo;
1423
+ if wav_http!=nil then if (slistlen wav_fifo)<WAV_BUFFER_MAXSIZE then httpenable wav_http 1
1424
+ )
1425
+ )
1426
+ );
1427
+ 0;;
1428
+
1429
+ fun _wavstartnow =
1430
+ set wav_index=0;
1431
+ set wav_buffering=1;
1432
+ playStart 1024 #_wavcb;;
1433
+
1434
+ fun wavstartlocalEx l timeout=
1435
+ wavstop;
1436
+ set wav_end_timeout=timeout;
1437
+ set wav_fifo=conc l (wavgetzeros)::nil;
1438
+ set wav_state=WAV_EOF;
1439
+ set wav_lasttime=time_ms;
1440
+ set wav_http=nil;
1441
+ _wavstartnow
1442
+ ;;
1443
+
1444
+ fun wavstartlocal l=wavstartlocalEx l WAV_END_TIMEOUT;;
1445
+ /*
1446
+ fun itobin4 i=strcatlist (ctoa i)::(ctoa i>>8)::(ctoa i>>16)::(ctoa i>>24)::nil;;
1447
+ fun itobin2 i=strcatlist (ctoa i)::(ctoa i>>8)::nil;;
1448
+
1449
+ fun mkwav freq channel bps=
1450
+ let strcatlist
1451
+ "WAVEfmt "::(itobin4 0x12)::
1452
+ (itobin2 1)::(itobin2 channel)::
1453
+ (itobin4 freq)::(itobin4 freq*channel*bps/8)::
1454
+ (itobin2 channel*bps/8)::(itobin4 bps)::
1455
+ "data"::(itobin4 0)::nil -> c in
1456
+ strcatlist "RIFF"::(itobin4 (strlen c))::c::nil;;
1457
+ */
1458
+
1459
+ fun _wavcbhttp httpreq req=
1460
+ set wav_lastnet=time_ms;
1461
+ if req==nil then
1462
+ (
1463
+ Secholn ">>>>>>>>>>>>>>>>>>>>>>>>>>>>><end of file";
1464
+ set wav_state=WAV_EOF;
1465
+ if wav_fifo!=nil then set wav_fifo=conc wav_fifo (wavgetzeros)::nil;
1466
+ if wav_index==nil then
1467
+ (
1468
+ set wav_fifo=tl wav_fifo;
1469
+ if wav_fifo==nil then wavstop
1470
+ else _wavstartnow
1471
+ );
1472
+ 0
1473
+ )
1474
+ else
1475
+ (
1476
+ // dump req;
1477
+ set wav_fifo=conc wav_fifo req::nil;
1478
+ let slistlen wav_fifo -> n in
1479
+ if wav_index==nil && n>WAV_BUFFER_STARTSIZE then
1480
+ (
1481
+ set wav_fifo=tl wav_fifo;
1482
+ _wavstartnow
1483
+ )
1484
+ else if n>WAV_BUFFER_MAXSIZE then
1485
+ (
1486
+ Secholn "\n>>>>>>>>>>>>>>http wait";
1487
+ httpenable httpreq 0
1488
+ );
1489
+ nil
1490
+ );
1491
+ updatevol;
1492
+ 0;;
1493
+
1494
+ fun wavstarthttp url =
1495
+ wavstop;
1496
+ set wav_end_timeout=WAV_END_TIMEOUT;
1497
+ set wav_fifo=nil;
1498
+ set wav_state=WAV_RUN;
1499
+ set wav_index=nil;
1500
+ set wav_buffering=1;
1501
+ set wav_lasttime=nil;
1502
+ set wav_lastnet=time_ms;
1503
+ set wav_http=httprequest "GET" url nil #_wavcbhttp HTTP_STREAM;;
1504
+
1505
+ fun wavtime =
1506
+ if wav_http!=nil && wav_state==WAV_RUN && (time_ms-wav_lastnet>WAV_NET_TIMEOUT) then
1507
+ (
1508
+ if wav_http!=nil then
1509
+ (
1510
+ Secholn "####wavhttp abort";
1511
+ httpabort wav_http;
1512
+ set wav_http=nil;
1513
+ _wavcbhttp wav_http nil;
1514
+ 0
1515
+ )
1516
+ );
1517
+ // wavrunning;
1518
+ 0;;
1519
+
1520
+ }
1521
+
1522
+
1523
+ //-------------------
1524
+
1525
+ ifdef EARSLIB {
1526
+
1527
+ // ears management
1528
+
1529
+ var EARSMODE_RESET=0;;
1530
+ var EARSMODE_WAIT=1;;
1531
+ var EARSMODE_WAITANDDETECT=2;;
1532
+ var EARSMODE_DETECT=3;;
1533
+
1534
+ var EARS_HOLES=17;;
1535
+ var EARS_TIMEOUT=2000;;
1536
+ var EARS_OFFZERO=2;;
1537
+
1538
+ type Ear=[numE dirE targetE posE lvalE ldelayE ltimeE countE brokenE];;
1539
+
1540
+ var ears;;
1541
+ var earsmode;;
1542
+ var earslastmove;; // somme des deux compteurs
1543
+ var earslastmovetime;; // heure du dernier mouvement (=nil=> acquisition en cours)
1544
+
1545
+ var earevent;;
1546
+
1547
+ fun eargetevent=
1548
+ let earevent -> ev in
1549
+ (
1550
+ set earevent=nil;
1551
+ ev
1552
+ );;
1553
+
1554
+ fun earCheck v=
1555
+ if v<0 then earCheck v+EARS_HOLES
1556
+ else if v>=EARS_HOLES then earCheck v-EARS_HOLES
1557
+ else v;;
1558
+
1559
+ fun earMotorset e val=
1560
+ set e.dirE=val;
1561
+ motorset e.numE val;;
1562
+
1563
+ fun earReset=
1564
+ Secholn "earReset";
1565
+ set earsmode=EARSMODE_RESET;
1566
+ for i=0;i<2 do let ears.i -> e in
1567
+ (
1568
+ earMotorset e 1;
1569
+ set e.brokenE=0;
1570
+ set e.targetE=nil;
1571
+ set e.lvalE=motorget i;
1572
+ set e.ldelayE=nil;
1573
+ set e.ltimeE=time_ms
1574
+ );;
1575
+
1576
+ fun earInit =
1577
+ set ears=tabnew nil 2;
1578
+ for i=0;i<2 do set ears.i=[numE:i];
1579
+ earReset;;
1580
+
1581
+
1582
+ fun earStartDetect=
1583
+ setleds 0xff8000;
1584
+ set earsmode=EARSMODE_DETECT;
1585
+ set earslastmovetime=time_ms;
1586
+ set earslastmove=(motorget 0)+(motorget 1);;
1587
+
1588
+
1589
+ fun earDetectRun=
1590
+ if earslastmovetime!=nil then
1591
+ (
1592
+ let (motorget 0)+(motorget 1)->newval in
1593
+ if newval!=earslastmove then
1594
+ (
1595
+ Secho "new val ";Iecholn newval;
1596
+ set earslastmove=newval;
1597
+ set earslastmovetime=time_ms
1598
+ )
1599
+ else if time_ms-earslastmovetime>EARS_TIMEOUT then
1600
+ (
1601
+ set earslastmovetime=nil;
1602
+ for i=0;i<2 do let ears.i -> e in
1603
+ if e.brokenE!=1 then
1604
+ (
1605
+ set e.lvalE=motorget i;
1606
+ set e.ldelayE=0;
1607
+ set e.ltimeE=time_ms;
1608
+ earMotorset e 1;
1609
+ set e.countE=e.lvalE+EARS_HOLES
1610
+ )
1611
+ )
1612
+ )
1613
+ else
1614
+ (
1615
+ for i=0;i<2 do let ears.i -> e in
1616
+ if e.brokenE!=1 then
1617
+ if e.dirE then
1618
+ let motorget i -> v in
1619
+ if v!=e.lvalE then
1620
+ let time_ms -> t in
1621
+ let t-e.ltimeE -> d in
1622
+ (
1623
+ if d>e.ldelayE then
1624
+ (
1625
+ set e.posE=earCheck e.countE-e.lvalE-EARS_OFFZERO-1;
1626
+ set e.ldelayE=d
1627
+ );
1628
+ set e.ltimeE=t;
1629
+ set e.lvalE=v;
1630
+ if v-e.countE>=0 then earMotorset e 0
1631
+ );
1632
+ if (ears.(0).dirE)==0 && (ears.(1).dirE)==0 then
1633
+ (
1634
+ set earevent=0x8000+(ears.(0).posE<<8)+(ears.(1).posE);
1635
+ Secho "Acquisition : "; Iecho ears.(0).posE; Secho ", ";Iecholn ears.(1).posE;
1636
+ set earsmode=EARSMODE_WAITANDDETECT
1637
+ )
1638
+ );;
1639
+
1640
+ fun earResetRun=
1641
+ for i=0;i<2 do let ears.i -> e in
1642
+ if e.dirE then
1643
+ (
1644
+ let motorget i -> v in
1645
+ if v==e.lvalE then
1646
+ (
1647
+ let time_ms -> t in
1648
+ let t-e.ltimeE -> d in
1649
+ if d>5000 then
1650
+ (
1651
+ Secholn "broken :";
1652
+ Iecholn i;
1653
+ set e.brokenE=1;
1654
+ set e.posE=0;
1655
+ set e.lvalE=v;
1656
+ set e.targetE=0;
1657
+ set e.ldelayE=0;
1658
+ earMotorset e 0
1659
+ )
1660
+ )
1661
+ else
1662
+ if e.targetE!=nil then
1663
+ (
1664
+ set e.posE=earCheck e.posE+v-e.lvalE;
1665
+ set e.lvalE=v;
1666
+ if e.posE==e.targetE then earMotorset e 0
1667
+ )
1668
+ else
1669
+ let time_ms -> t in
1670
+ let t-e.ltimeE -> d in
1671
+ (
1672
+ if (d<10000) && (d>600) && (nil!=e.ldelayE) then
1673
+ (
1674
+ // Secho "gowait "; Iecholn d; Iecholn ldelay;
1675
+ set e.posE=earCheck -EARS_OFFZERO;
1676
+ set e.targetE=0
1677
+ )
1678
+ else
1679
+ (
1680
+ // Secho "position "; Iecho e.numE; Secho " : "; Iecho v; Secho " during "; Iecholn d;
1681
+ set e.ltimeE=t
1682
+ );
1683
+ set e.lvalE=v;
1684
+ set e.ldelayE=d
1685
+ )
1686
+ );
1687
+ if (ears.(0).dirE)==0 && (ears.(1).dirE)==0 then
1688
+ (
1689
+ set earsmode=EARSMODE_WAIT
1690
+ );;
1691
+
1692
+ fun earWaitRun=
1693
+ for i=0;i<2 do let ears.i -> e in
1694
+ if e.brokenE!=1 then
1695
+ (
1696
+ let motorget i -> v in
1697
+ if v!=e.lvalE then
1698
+ let v-e.lvalE-> dv in
1699
+ if e.dirE then
1700
+ (
1701
+ set e.lvalE=v;
1702
+ set e.posE=earCheck e.posE+ if e.dirE>0 then dv else -dv;
1703
+ if e.posE==e.targetE then
1704
+ (
1705
+ // Secho "stop "; Iecholn e.numE;
1706
+ earMotorset e 0
1707
+ )
1708
+ )
1709
+ else if dv>2 then
1710
+ (
1711
+ set e.lvalE=v;
1712
+ if earsmode==EARSMODE_WAITANDDETECT then earStartDetect
1713
+ )
1714
+ );;
1715
+
1716
+ fun earRun=
1717
+ if earsmode==EARSMODE_RESET then earResetRun
1718
+ else if earsmode==EARSMODE_DETECT then earDetectRun
1719
+ else earWaitRun;
1720
+ 0;;
1721
+
1722
+ fun earReady= earsmode!=EARSMODE_RESET;;
1723
+ fun earDetecting= earsmode==EARSMODE_DETECT;;
1724
+ fun earComplete = earReady && (!ears.(0).dirE) && (!ears.(1).dirE);;
1725
+
1726
+ fun earDetect=
1727
+ if earsmode== EARSMODE_WAIT then set earsmode=EARSMODE_WAITANDDETECT;;
1728
+
1729
+ fun earUndetect=
1730
+ if earsmode== EARSMODE_WAITANDDETECT then set earsmode=EARSMODE_WAIT;;
1731
+
1732
+ fun earStop=
1733
+ Secholn "earStop";
1734
+ if earsmode!=EARSMODE_RESET then for i=0;i<2 do earMotorset ears.i 0;
1735
+ 0;;
1736
+
1737
+ fun earTarget i=ears.(i).targetE;;
1738
+
1739
+ fun earGo i p d=
1740
+ if earsmode==EARSMODE_WAIT ||earsmode==EARSMODE_WAITANDDETECT then
1741
+ let ears.i->e in
1742
+ let earCheck p->p in
1743
+ if e.brokenE==1 then
1744
+ (
1745
+ Secho "earGo ";Iecho i; Secholn " broken !";
1746
+ nil
1747
+ )
1748
+ else
1749
+ if p!=e.targetE then
1750
+ (
1751
+ Secho "earGo ";Iecho i; Secho " to ";Iecho p;Secho " dir ";Iecholn d;
1752
+ set e.targetE=p;
1753
+ earMotorset e if p==e.posE then 0 else if d then -1 else 1
1754
+ );
1755
+ 0;;
1756
+
1757
+ }
1758
+
1759
+ //-------------------
1760
+ ifdef INFOLIB {
1761
+
1762
+ var infodata;;
1763
+ var infosrc;;
1764
+
1765
+ fun infoInit=
1766
+ set infosrc=tabnew 0 32;
1767
+
1768
+ set infodata=
1769
+ [0
1770
+ {
1771
+ [4 {3 3 3 0 0 0}]
1772
+ [4 {0 3 0 4 0 4}]
1773
+ [3 {4 4 4 4 4 4 4 4 4 0 0 0}]
1774
+ [3 {4 0 0 0 0 4 0 0 0 0 4 0 4 0 0 0 0 0 4 0 4 0 0 0}]
1775
+ [4 {4 0 0 0 4 0 4 0 0 0 4 0 0 0 4 0 4 0 0 0 4 0 4 0}]
1776
+ [3 {0 3 4 3 4 0xd5 0x47 0 0 4 3 0 0 4 3 0 0 0 3 4 0 0 0 0}]
1777
+ }
1778
+ ]::
1779
+ [1
1780
+ {
1781
+ [1 {0 0 11 0 11 0 11 0 0 0 0 0}]
1782
+ [2 {0 0 11 0 11 0 11 0 0 0 0 0}]
1783
+ [3 {0 0 11 0 11 0 11 0 0 0 0 0}]
1784
+ [4 {0 11 0 0 0 0}]
1785
+ [3 {11 0 0 0 11 0 0 0 11 0 0 0}]
1786
+ [2 {11 0 0 0 11 0 0 0 11 0 0 0}]
1787
+ [1 {11 0 0 0 11 0 0 0 11 0 0 0}]
1788
+ }
1789
+ ]::
1790
+ [2
1791
+ {
1792
+ [6 {9 0 9 0 0 0}]
1793
+ [5 {0 9 0 9 0 9 0 0 0 0 0 0}]
1794
+ [4 {0 9 0 9 0 9 0 0 0 0 0 0}]
1795
+ [3 {0 9 0 9 0 9 0 0 0 0 0 0}]
1796
+ [2 {0 9 0 9 0 9 0 0 0 0 0 0}]
1797
+ [1 {0 9 0 9 0 9 0 0 0 0 0 0}]
1798
+ [0 {0 9 0 9 0 9 0 0 0 0 0 0}]
1799
+ }
1800
+ ]::
1801
+ [5
1802
+ {
1803
+ [3 {5 0 0 0 5 0 0 0 5 0 5 0}]
1804
+ [3 {0 5 0 0 0 0}]
1805
+ [3 {5 0 5 0 0 0}]
1806
+ [3 {5 5 5 0 0 0}]
1807
+ }
1808
+ ]::
1809
+ [6
1810
+ {
1811
+ [4 {6 6 6 6 6 6 6 6 6 0 0 0}]
1812
+ [4 {6 6 6 6 6 6 6 6 6 0 0 0}]
1813
+ [4 {6 6 6 6 6 6 6 6 6 0 0 0}]
1814
+ [4 {6 6 6 6 6 6 6 6 6 0 0 0}]
1815
+ [4 {6 6 6 6 6 6 6 6 6 0 0 0}]
1816
+ [3 {6 0 0 0 6 0 6 6 0 6 6 6 0 6 6 0 0 6 6 0 6 6 6 6}]
1817
+ [3 {6 0 0 0 6 0 6 6 0 6 6 6 0 6 6 0 0 6 6 0 6 6 6 6}]
1818
+ [3 {6 0 0 0 6 0 6 6 0 6 6 6 0 6 6 0 0 6 6 0 6 6 6 6}]
1819
+ [2 {6 0 0 0 6 0 6 6 0 6 6 6 0 6 6 0 0 6 6 0 6 6 6 6}]
1820
+ [2 {6 0 0 0 6 0 6 6 0 6 6 6 0 6 6 0 0 6 6 0 6 6 6 6}]
1821
+ [2 {6 0 0 0 6 0 6 6 0 6 6 6 0 6 6 0 0 6 6 0 6 6 6 6}]
1822
+ }
1823
+ ]::
1824
+ nil;;
1825
+
1826
+ var col={
1827
+ 0x000000 0xff0000 0x00ff00 0xffff00 0x0000ff 0xff00ff 0x00ffff 0xffffff
1828
+ 0x808080 0xff8080 0x80ff80 0xffff80 0x8080ff 0xff80ff 0x80ffff 0xff8000
1829
+ };;
1830
+
1831
+
1832
+ var infoType;;
1833
+ var infoVal;;
1834
+ var infoInd;;
1835
+ var infoCount;;
1836
+
1837
+ var infoTime;;
1838
+ var infoIndex=0;;
1839
+
1840
+ var INFO_TIMEOUT=10;;
1841
+
1842
+ fun infobytype i=listswitch infodata i;;
1843
+
1844
+ fun nextindex src i=
1845
+ let i+2-> i in
1846
+ if i>=16 then 0 else if src.i then i else nextindex src i;;
1847
+
1848
+ fun infoNext=
1849
+ set infoIndex=nextindex infosrc infoIndex;
1850
+ set infoType=(infosrc.(infoIndex))-1;
1851
+ set infoVal=infosrc.(infoIndex+1);
1852
+ set infoTime=time;
1853
+ set infoInd=0;
1854
+ let infobytype infoType -> t0 in
1855
+ if t0==nil then set infoTime=nil
1856
+ else set infoCount=let t0.infoVal ->[c0 _] in 2<<c0;
1857
+ 0;;
1858
+
1859
+ fun dumpinfosrc=
1860
+ for i=0;i<16 do (Iecho infosrc.i;Secho " : ");
1861
+ Secholn ""
1862
+ ;;
1863
+
1864
+ fun infoRun=
1865
+ if !earDetecting then
1866
+ (
1867
+ set infoType=(infosrc.(infoIndex))-1;
1868
+ if infoTime==nil || (time-infoTime>INFO_TIMEOUT) || infoType<0 then infoNext;
1869
+
1870
+ let infosrc.(16+2) -> msg1 in
1871
+ let infosrc.(16+3) -> msg2 in
1872
+ let (time_ms>>8)&7 -> t in
1873
+ led 0 if (t==1 && msg1) || (t==3 && msg1 && msg2) then 0xff00ff else 0;
1874
+
1875
+ set infoType=(infosrc.(infoIndex))-1;
1876
+ set infoVal=infosrc.(infoIndex+1);
1877
+ let infobytype infoType -> t0 in
1878
+ let t0.infoVal ->[c0 t] in
1879
+ if t!=nil then
1880
+ (
1881
+ led 1 col.(t.infoInd);
1882
+ led 2 col.(t.(1+infoInd));
1883
+ led 3 col.(t.(2+infoInd));
1884
+ if (set infoCount=infoCount-1)<=0 then
1885
+ (
1886
+ set infoInd=infoInd+3;
1887
+ set infoCount=2<<c0;
1888
+ if infoInd>=tablen t then set infoInd=0
1889
+ )
1890
+ )
1891
+ else
1892
+ (
1893
+ led 3 0; led 2 0; led 1 0
1894
+ )
1895
+ );;
1896
+
1897
+
1898
+ fun infoUpdate data=
1899
+ let strlen data -> len in
1900
+ for i=0;i<len do set infosrc.i=strget data i;
1901
+ 0;;
1902
+
1903
+ fun infoGet_ i typ=
1904
+ if i>=tablen infosrc then 0
1905
+ else if typ==infosrc.i then infosrc.(i+1)
1906
+ else infoGet_ i+1 typ;;
1907
+
1908
+ fun infoGet typ=infoGet_ 0 typ;;
1909
+
1910
+
1911
+
1912
+ }
1913
+
1914
+ //-------------------
1915
+
1916
+
1917
+
1918
+ fun setleds col= for i=0;i<5 do led i col;;
1919
+
1920
+
1921
+ var RT2501_S_BROKEN=0;;
1922
+ var RT2501_S_IDLE=1;;
1923
+ var RT2501_S_SCAN=2;;
1924
+ var RT2501_S_CONNECTING=3;;
1925
+ var RT2501_S_CONNECTED=4;;
1926
+ var RT2501_S_MASTER=5;;
1927
+
1928
+ var IEEE80211_M_MANAGED=0;;
1929
+ var IEEE80211_M_MASTER=1;;
1930
+
1931
+ var wifitry;;
1932
+
1933
+
1934
+
1935
+ fun _scanserialize l=
1936
+ if l!=nil then
1937
+ let hd l->[ssid mac bssid rssi channel rateset encryption] in
1938
+ ssid::"\0"::mac::bssid::(itoh4 rssi)::(itoh4 channel)::(itoh4 rateset)::(itoh4 encryption)::
1939
+ _scanserialize tl l;;
1940
+
1941
+ fun scanserialize l=
1942
+ (itoh4 listlen l)::_scanserialize l;;
1943
+
1944
+
1945
+ fun ssidlen s i=
1946
+ if i>=strlen s then i
1947
+ else if !strget s i then i
1948
+ else ssidlen s i+1;;
1949
+
1950
+ fun scanunserialize s n i0=
1951
+ if n>0 then
1952
+ let ssidlen s i0 -> j in
1953
+ let j+1->i in
1954
+ [
1955
+ strsub s i0 j-i0
1956
+ strsub s i 6
1957
+ strsub s i+6 6
1958
+ htoi strsub s i+12 8
1959
+ htoi strsub s i+20 8
1960
+ htoi strsub s i+28 8
1961
+ htoi strsub s i+36 8
1962
+ ]::scanunserialize s n-1 i+44;;
1963
+
1964
+
1965
+ fun envmake =
1966
+ strcatlist netip::netmask::netgateway::netdns::scanserialize wifiscans;;
1967
+
1968
+ fun envrestore s =
1969
+ if s!=nil then
1970
+ (
1971
+ set netip=strsub s 0 4;
1972
+ set netmask=strsub s 4 4;
1973
+ set netgateway=strsub s 8 4;
1974
+ set netdns=strsub s 12 4;
1975
+ let htoi strsub s 16 8 -> nscan in
1976
+ set wifiscans=scanunserialize s nscan 24;
1977
+ 0
1978
+ );;
1979
+
1980
+ fun scancmpssid a b=
1981
+ let a->[sa _ _ _ _ _ _] in
1982
+ let b->[sb _ _ _ _ _ _] in
1983
+ strcmp sa sb;;
1984
+
1985
+
1986
+ fun wifiInit rescan=
1987
+ set wifitry=nil;
1988
+ let envget -> env in
1989
+ if env==nil then
1990
+ (
1991
+ setleds 0xff00ff;
1992
+ set wifi=initW;
1993
+ if rescan then set wifiscans=nil;
1994
+ if master then
1995
+ (
1996
+ set netip=netip_master;
1997
+ set netmask=netmask_master;
1998
+ set netgateway=netgateway_master;
1999
+ 0
2000
+ )
2001
+ else
2002
+ (
2003
+ if confGetDhcp then set netip=netip_empty
2004
+ else
2005
+ (
2006
+ set netmask=confGetNetmask;
2007
+ set netgateway=confGetNetgateway;
2008
+ set netdns=confGetNetdns;
2009
+ set netip=confGetNetip
2010
+ );
2011
+ 0
2012
+ );
2013
+ 0
2014
+ )
2015
+ else
2016
+ (
2017
+ setleds 0x00ff00;
2018
+ set mymac=netMac;
2019
+ set wifi=stationW;
2020
+ envrestore env;
2021
+ envset nil;
2022
+ nil
2023
+ );
2024
+ 0;;
2025
+
2026
+ var laststate;;
2027
+
2028
+ fun wifibyssid x v=let x->[s _ _ _ _ _ _] in (s!=nil)&& !strcmp v s;;
2029
+
2030
+
2031
+ var retrytime;;
2032
+
2033
+ fun _wifiwepkey val i len=
2034
+ if i<len then
2035
+ (htoi strsub val i 2)::_wifiwepkey val i+2 len;;
2036
+
2037
+ fun wifiwepkey val=
2038
+ let strlen val -> len in
2039
+ if len==5 || len==13 then val
2040
+ else let strreplace val ":" "" -> val in
2041
+ let if len<10 then 0 else if len<26 then 5 else 13 -> len in
2042
+ listtostr _wifiwepkey val 0 len<<1;;
2043
+
2044
+ fun wificrypttype crypt key=
2045
+ if crypt==1 then if 5==strlen key then IEEE80211_CRYPT_WEP64 else IEEE80211_CRYPT_WEP128
2046
+ else if crypt==2 then IEEE80211_CRYPT_WPA
2047
+ else IEEE80211_CRYPT_NONE;;
2048
+
2049
+ fun wifiAuth=
2050
+ setleds 0xff8000;
2051
+ if wifiscans==nil then 0
2052
+ else
2053
+ let Iecholn confGetWificrypt -> crypt in
2054
+ let confGetWifiauth -> auth in
2055
+ let if crypt==1 then wifiwepkey confGetWifikey0
2056
+ else if crypt==2 then confGetWifipmk -> key in
2057
+ (
2058
+ dump key;
2059
+ set wifitry=time;
2060
+ netAuth hd wifiscans Iecholn auth (Iecholn wificrypttype crypt key) key; //## ajouter les param�tres de crypto
2061
+ 1
2062
+ );;
2063
+
2064
+ fun wifiRun=
2065
+ let netState -> state in
2066
+ (
2067
+ if state!=laststate then (Secho "wifi state=";Iecholn state);
2068
+ let match wifi with
2069
+ (stationW -> nil)
2070
+ |(initW -> if state==RT2501_S_IDLE then
2071
+ (
2072
+ set mymac=MACecho netMac 0 1;
2073
+ setleds 0xff8000;
2074
+ if master then
2075
+ (
2076
+ dumpscan set wifiscans=sort netScan nil #scancmpssid;
2077
+ netSetmode IEEE80211_M_MASTER (strcat "Nabaztag" ctoh strget mymac 5) 1;
2078
+ Secholn "-------------gomaster";
2079
+ gomasterW
2080
+ )
2081
+ else
2082
+ (
2083
+ if wifiscans==nil then
2084
+ (
2085
+ let confGetWifissid -> ssid in
2086
+ let if strlen ssid then ssid else nil -> ssid in
2087
+ let netScan ssid -> lscan in
2088
+ let sort lscan #scancmpssid -> l in
2089
+ let if ssid==nil then l else select l ssid #wifibyssid-> l in
2090
+ dumpscan set wifiscans=l
2091
+ );
2092
+ if wifiAuth then
2093
+ (
2094
+ Secho confGetWifissid; Secholn ":-------------gostation";
2095
+ gostationW [0 time]
2096
+ )
2097
+ )
2098
+ )
2099
+ )
2100
+ |(gomasterW -> if state==RT2501_S_MASTER then
2101
+ (
2102
+ setleds 0x0000ff;
2103
+ Secholn "-------------master";
2104
+ startdhcpserver;
2105
+ // startconfigserver 80;
2106
+ masterW)
2107
+ )
2108
+ |(masterW -> if !master then
2109
+ (
2110
+ wifiInit 1;
2111
+ resetudp;
2112
+ netSetmode IEEE80211_M_MANAGED nil 11;
2113
+ nil)
2114
+ )
2115
+ |(gostationW x-> if state==RT2501_S_CONNECTED then
2116
+ (
2117
+ Secholn "-------------dhcp";
2118
+ if confGetDhcp then startdhcp;
2119
+ startdnsclient;
2120
+ dhcpW time
2121
+ )
2122
+ )
2123
+ |(dhcpW t-> if netip!=netip_empty then
2124
+ (
2125
+ Secholn "-------------station";
2126
+ stationW
2127
+ )
2128
+ else if (time-t)>3 then // retry dhcp client
2129
+ (
2130
+ startdhcp;
2131
+ dhcpW time
2132
+ )
2133
+ )
2134
+ |(reconnectW ->
2135
+ netSetmode IEEE80211_M_MANAGED nil 11;
2136
+ if wifiAuth then
2137
+ (
2138
+ Secho confGetWifissid; Secholn ":-------------gostation";
2139
+ gostationW [0 time]
2140
+ )
2141
+ )
2142
+ -> nwifi in
2143
+ if nwifi!=nil then set wifi=nwifi;
2144
+ set laststate=state
2145
+ );
2146
+ if retrytime!=time then
2147
+ (
2148
+ set retrytime=time;
2149
+ nettime;
2150
+ dnstime;
2151
+ 0
2152
+ )
2153
+ ;;
2154
+
2155
+ fun wifiReady= match wifi with (stationW -> 1)|(_ -> 0);;
2156
+
2157
+ fun wifiConnected= match wifi with (stationW -> 1)|(_ -> 0);;
2158
+
2159
+
2160
+
2161
+
2162
+
2163
+
2164
+
2165
+ ifdef NOMINAL {
2166
+
2167
+ var TYPE_taichi=14;;
2168
+
2169
+ var tab_osc={
2170
+ 0 0 0 0 0 0 1 1 2 3 3 4 5 6 7 8
2171
+ 9 10 12 13 15 16 18 19 21 23 25 27 29 31 33 35
2172
+ 37 39 42 44 46 49 51 54 56 59 62 64 67 70 73 76
2173
+ 79 81 84 87 90 93 96 99 103 106 109 112 115 118 121 124
2174
+ };;
2175
+
2176
+
2177
+ fun osc x=
2178
+ let (x>>6)&3 -> q in
2179
+ let x&255 -> x in
2180
+ if q==0 then tab_osc.x
2181
+ else if q==1 then 255-tab_osc.(127-x)
2182
+ else if q==2 then 255-tab_osc.(x-128)
2183
+ else tab_osc.(255-x);;
2184
+
2185
+
2186
+ var midi_connect=
2187
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2188
+ \$72\$6b\$00\$00\$00\$5d\$00\$ff\$51\$03\$10\$59\$43\$00\$c0\$09\
2189
+ \$02\$90\$58\$5a\$12\$48\$62\$31\$60\$62\$0a\$80\$58\$78\$2c\$90\
2190
+ \$58\$52\$12\$80\$60\$54\$43\$90\$60\$49\$04\$80\$58\$6c\$33\$90\
2191
+ \$58\$45\$05\$80\$60\$6a\$81\$00\$90\$60\$40\$22\$80\$58\$6f\$7a\
2192
+ \$90\$5d\$58\$03\$80\$48\$49\$04\$60\$52\$0b\$90\$4f\$48\$84\$24\
2193
+ \$80\$5d\$4d\$11\$4f\$76\$81\$3a\$90\$30\$01\$74\$80\$30\$40\$00\
2194
+ \$ff\$2f\$00";;
2195
+
2196
+ type Run= configstartRun | configwaitRun _| pingstartRun |pingwaitRun _|
2197
+ msgloadstartRun | msgloadwaitRun _ | msginitwaitRun | msgchorRun _ |msgchorstreamRun _ | msgRun _| idlewaitRun | waitRun _ |
2198
+ pingsendwaitRun _ |recordRun |asleepRun |recordStartRun;;
2199
+
2200
+ var run;;
2201
+ var pingsrv;;
2202
+ var broadcasturl;;
2203
+ var senddata=0;;
2204
+ var currenttrame=0;;
2205
+ var pingdelay=10;;
2206
+ var recorddelay=4;;
2207
+
2208
+ var sources;;
2209
+ var extleft;;
2210
+ var extright;;
2211
+
2212
+ var msgtoplay;;
2213
+ var msgtimestart;;
2214
+ var rsctoget;;
2215
+ var rscloaded;;
2216
+ var rsctmp;; // buffer de chargement des ressources en petits morceaux
2217
+
2218
+ proto _pingcbhttp 2;;
2219
+
2220
+ var BROADCAST_KEYWORD="broadcast";;
2221
+ var SIGNCUTSIZE=40000;; // taille max du fichier audio de signature
2222
+
2223
+ var MSG_IDLE=0x7fffffff;;
2224
+ var MSG_ASLEEP=0x7ffffffe;;
2225
+
2226
+ var STREAMING_MOTORSTOP=60;;
2227
+ var STREAMING_PING=60;;
2228
+
2229
+ var LED_TIMEOUT=600;;
2230
+ var CH_frame_duration=1;;
2231
+ //var CH_set_color=6;;
2232
+ var CH_set_led_color=7;;
2233
+ var CH_set_motor=8;;
2234
+ var CH_set_led_palette=14;;
2235
+ //var CH_set_palette=15;;
2236
+ var CH_randmidi=16;;
2237
+ var CH_avance=17;;
2238
+ var CH_ifne=18;;
2239
+ var CH_attend=19;;
2240
+
2241
+ var palette;;
2242
+
2243
+ var palettes=
2244
+ {
2245
+ {255 12 0 0 255 31 255 242 0 0 3 255 255 242 0 0 255 31 255 12 0 0 0 0}
2246
+ {95 0 255 127 0 255 146 0 255 191 0 255 223 0 255 255 0 223 255 0 146 0 0 0}
2247
+ {255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0}
2248
+ {254 128 2 243 68 2 216 6 7 200 4 13 170 0 24 218 5 96 207 6 138 0 0 0}
2249
+ {20 155 18 255 0 0 252 243 5 20 155 18 252 243 5 255 0 0 20 155 18 0 0 0}
2250
+ {252 238 71 206 59 69 85 68 212 78 167 82 243 75 153 151 71 196 255 255 255 0 0 0}
2251
+ {204 255 102 204 255 0 153 255 0 51 204 0 0 153 51 0 136 0 0 102 510 0 0}
2252
+ {204 255 102 204 255 0 153 255 0 51 204 0 0 153 51 0 136 0 0 102 510 0 0}
2253
+ };;
2254
+
2255
+ var midi_acquired=
2256
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2257
+ \$72\$6b\$00\$00\$00\$71\$00\$ff\$03\$07\$63\$6f\$6d\$70\$72\$69\
2258
+ \$73\$00\$ff\$51\$03\$07\$a1\$20\$00\$ff\$58\$04\$04\$02\$18\$08\
2259
+ \$00\$c0\$0c\$7a\$90\$34\$50\$6f\$53\$1a\$08\$80\$34\$40\$81\$02\
2260
+ \$53\$40\$15\$90\$64\$27\$81\$02\$54\$37\$08\$80\$64\$40\$81\$02\
2261
+ \$54\$40\$15\$90\$34\$50\$81\$02\$53\$2b\$07\$80\$34\$40\$81\$02\
2262
+ \$53\$40\$16\$90\$43\$3f\$81\$02\$64\$60\$07\$80\$43\$40\$81\$02\
2263
+ \$64\$40\$15\$90\$54\$5c\$55\$80\$54\$40\$83\$39\$90\$25\$01\$74\
2264
+ \$80\$25\$40\$00\$ff\$2f\$00";;
2265
+
2266
+ var midi_abort=
2267
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2268
+ \$72\$6b\$00\$00\$00\$5a\$00\$ff\$03\$05\$73\$74\$6f\$70\$30\$00\
2269
+ \$ff\$51\$03\$07\$a1\$20\$00\$ff\$58\$04\$04\$02\$18\$08\$00\$c9\
2270
+ \$00\$00\$c4\$09\$03\$99\$2a\$7f\$00\$2c\$7f\$00\$56\$7f\$00\$94\
2271
+ \$24\$7f\$00\$28\$64\$00\$2d\$64\$01\$99\$3c\$64\$0a\$84\$24\$40\
2272
+ \$01\$28\$40\$01\$2d\$40\$0b\$89\$2a\$40\$00\$56\$40\$01\$2c\$40\
2273
+ \$00\$3c\$40\$81\$52\$99\$2c\$01\$1a\$89\$2c\$40\$00\$ff\$2f\$00";;
2274
+
2275
+ var midi_ears=
2276
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2277
+ \$72\$6b\$00\$00\$00\$9b\$00\$ff\$03\$0b\$63\$6f\$6d\$6d\$75\$6e\
2278
+ \$69\$6f\$6e\$30\$30\$00\$ff\$51\$03\$10\$59\$43\$00\$ff\$58\$04\
2279
+ \$04\$02\$18\$08\$00\$c0\$0c\$02\$90\$60\$67\$04\$48\$6a\$7b\$5f\
2280
+ \$4d\$12\$80\$60\$65\$2a\$90\$5d\$51\$0b\$80\$5f\$76\$18\$48\$2b\
2281
+ \$10\$5d\$7f\$07\$90\$60\$64\$08\$4f\$5e\$7c\$5f\$52\$15\$80\$60\
2282
+ \$71\$19\$90\$5d\$56\$1a\$80\$5f\$6c\$15\$5d\$7f\$0e\$90\$58\$56\
2283
+ \$0c\$80\$4f\$7c\$14\$90\$4d\$5e\$6e\$80\$58\$73\$01\$90\$5d\$62\
2284
+ \$75\$80\$5d\$7a\$0d\$4d\$67\$05\$90\$5b\$5a\$05\$54\$60\$2a\$80\
2285
+ \$5b\$65\$81\$1e\$54\$60\$51\$90\$58\$60\$15\$4c\$6a\$81\$1e\$80\
2286
+ \$58\$63\$0e\$4c\$45\$4d\$90\$24\$01\$72\$80\$24\$40\$00\$ff\$2f\
2287
+ \$00";;
2288
+
2289
+ var midi_communion=
2290
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2291
+ \$72\$6b\$00\$00\$00\$9b\$00\$ff\$03\$0b\$63\$6f\$6d\$6d\$75\$6e\
2292
+ \$69\$6f\$6e\$30\$30\$00\$ff\$51\$03\$10\$59\$43\$00\$ff\$58\$04\
2293
+ \$04\$02\$18\$08\$00\$c0\$0c\$02\$90\$60\$67\$04\$48\$6a\$7b\$5f\
2294
+ \$4d\$12\$80\$60\$65\$2a\$90\$5d\$51\$0b\$80\$5f\$76\$18\$48\$2b\
2295
+ \$10\$5d\$7f\$07\$90\$60\$64\$08\$4f\$5e\$7c\$5f\$52\$15\$80\$60\
2296
+ \$71\$19\$90\$5d\$56\$1a\$80\$5f\$6c\$15\$5d\$7f\$0e\$90\$58\$56\
2297
+ \$0c\$80\$4f\$7c\$14\$90\$4d\$5e\$6e\$80\$58\$73\$01\$90\$5d\$62\
2298
+ \$75\$80\$5d\$7a\$0d\$4d\$67\$05\$90\$5b\$5a\$05\$54\$60\$2a\$80\
2299
+ \$5b\$65\$81\$1e\$54\$60\$51\$90\$58\$60\$15\$4c\$6a\$81\$1e\$80\
2300
+ \$58\$63\$0e\$4c\$45\$4d\$90\$24\$01\$72\$80\$24\$40\$00\$ff\$2f\
2301
+ \$00";;
2302
+
2303
+ var midi_ack=
2304
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2305
+ \$72\$6b\$00\$00\$00\$55\$00\$ff\$03\$07\$65\$66\$66\$61\$63\$65\
2306
+ \$30\$00\$ff\$51\$03\$10\$59\$43\$00\$ff\$58\$04\$04\$02\$18\$08\
2307
+ \$00\$90\$3c\$7f\$00\$41\$7f\$00\$48\$7f\$00\$4f\$7f\$00\$54\$7f\
2308
+ \$00\$c0\$77\$00\$c1\$74\$84\$54\$80\$4f\$40\$40\$91\$30\$7f\$00\
2309
+ \$53\$64\$1a\$80\$41\$40\$00\$54\$40\$00\$81\$30\$40\$00\$53\$40\
2310
+ \$3c\$80\$48\$40\$1e\$3c\$40\$00\$ff\$2f\$00";;
2311
+
2312
+ var taichi=
2313
+ "\$00\$00\$0f\$6f\$00\$01\$0a\$00\$10\$00\$01\$04\$01\$07\$04\$00\
2314
+ \$33\$ff\$00\$00\$00\$07\$02\$ff\$00\$00\$00\$00\$00\$07\$00\$ff\
2315
+ \$ff\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$02\$00\
2316
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$00\$07\$01\$ff\
2317
+ \$ff\$00\$00\$00\$01\$07\$01\$00\$00\$00\$00\$00\$00\$07\$04\$ff\
2318
+ \$ff\$00\$00\$00\$00\$07\$02\$00\$ee\$00\$00\$00\$00\$07\$00\$ff\
2319
+ \$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$02\$00\
2320
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$00\$07\$03\$00\
2321
+ \$ee\$00\$00\$00\$01\$07\$03\$00\$00\$00\$00\$00\$00\$07\$04\$ee\
2322
+ \$00\$00\$00\$00\$00\$07\$01\$00\$33\$ff\$00\$00\$01\$07\$04\$00\
2323
+ \$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\$07\$04\$ff\
2324
+ \$00\$00\$00\$00\$00\$07\$00\$ff\$ff\$00\$00\$00\$01\$07\$04\$00\
2325
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$00\$07\$03\$00\
2326
+ \$33\$ff\$00\$00\$01\$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$ff\
2327
+ \$ff\$00\$00\$00\$00\$07\$00\$ff\$00\$00\$00\$00\$01\$07\$02\$00\
2328
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$01\$07\$03\$ee\
2329
+ \$00\$00\$00\$00\$00\$07\$00\$00\$ee\$00\$00\$00\$01\$07\$03\$00\
2330
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$00\$07\$03\$ff\
2331
+ \$00\$00\$00\$00\$00\$07\$02\$00\$ee\$00\$00\$00\$01\$07\$03\$00\
2332
+ \$00\$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\
2333
+ \$33\$ff\$00\$00\$01\$07\$01\$00\$00\$00\$00\$00\$01\$07\$04\$00\
2334
+ \$33\$ff\$00\$00\$00\$07\$02\$ff\$00\$00\$00\$00\$00\$07\$00\$ff\
2335
+ \$ff\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$02\$00\
2336
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$00\$07\$01\$ff\
2337
+ \$ff\$00\$00\$00\$01\$07\$01\$00\$00\$00\$00\$00\$00\$07\$04\$ff\
2338
+ \$ff\$00\$00\$00\$00\$07\$02\$00\$ee\$00\$00\$00\$00\$07\$00\$ff\
2339
+ \$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$02\$00\
2340
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$00\$07\$03\$00\
2341
+ \$ee\$00\$00\$00\$01\$07\$03\$00\$00\$00\$00\$00\$00\$07\$04\$ee\
2342
+ \$00\$00\$00\$00\$00\$07\$01\$00\$33\$ff\$00\$00\$01\$07\$04\$00\
2343
+ \$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\$07\$04\$ff\
2344
+ \$00\$00\$00\$00\$00\$07\$00\$ff\$ff\$00\$00\$00\$01\$07\$04\$00\
2345
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$00\$07\$03\$00\
2346
+ \$33\$ff\$00\$00\$01\$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$ff\
2347
+ \$ff\$00\$00\$00\$00\$07\$00\$ff\$00\$00\$00\$00\$01\$07\$02\$00\
2348
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$01\$07\$03\$ee\
2349
+ \$00\$00\$00\$00\$00\$07\$00\$00\$ee\$00\$00\$00\$01\$07\$03\$00\
2350
+ \$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$00\$07\$03\$ff\
2351
+ \$00\$00\$00\$00\$00\$07\$02\$00\$ee\$00\$00\$00\$01\$07\$03\$00\
2352
+ \$00\$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\
2353
+ \$33\$ff\$00\$00\$01\$07\$01\$00\$00\$00\$00\$00\$00\$01\$0a\$00\
2354
+ \$12\$00\$03\$43\$00\$01\$08\$00\$07\$04\$ee\$00\$00\$00\$00\$00\
2355
+ \$07\$03\$ee\$00\$00\$00\$00\$00\$07\$02\$ee\$00\$00\$00\$00\$00\
2356
+ \$07\$01\$ee\$00\$00\$00\$00\$00\$07\$00\$ee\$00\$00\$00\$00\$00\
2357
+ \$11\$01\$04\$00\$11\$00\$04\$01\$07\$04\$00\$00\$00\$00\$00\$00\
2358
+ \$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\
2359
+ \$07\$01\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$01\
2360
+ \$07\$04\$ee\$00\$00\$00\$00\$00\$07\$03\$ee\$00\$00\$00\$00\$00\
2361
+ \$07\$02\$ee\$00\$00\$00\$00\$00\$07\$01\$ee\$00\$00\$00\$00\$00\
2362
+ \$07\$00\$ee\$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\
2363
+ \$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\
2364
+ \$07\$01\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$20\
2365
+ \$07\$04\$ee\$00\$00\$00\$00\$00\$07\$03\$ee\$00\$00\$00\$00\$00\
2366
+ \$07\$02\$ee\$00\$00\$00\$00\$00\$07\$01\$ee\$00\$00\$00\$00\$00\
2367
+ \$07\$00\$ee\$00\$00\$00\$00\$00\$11\$01\$04\$00\$11\$00\$04\$01\
2368
+ \$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\
2369
+ \$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\
2370
+ \$07\$00\$00\$00\$00\$00\$00\$01\$07\$04\$ee\$00\$00\$00\$00\$00\
2371
+ \$07\$03\$ee\$00\$00\$00\$00\$00\$07\$02\$ee\$00\$00\$00\$00\$00\
2372
+ \$07\$01\$ee\$00\$00\$00\$00\$00\$07\$00\$ee\$00\$00\$00\$00\$01\
2373
+ \$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\
2374
+ \$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\
2375
+ \$07\$00\$00\$00\$00\$00\$00\$20\$07\$04\$ee\$00\$00\$00\$00\$00\
2376
+ \$07\$03\$ee\$00\$00\$00\$00\$00\$07\$02\$ee\$00\$00\$00\$00\$00\
2377
+ \$07\$01\$ee\$00\$00\$00\$00\$00\$07\$00\$ee\$00\$00\$00\$00\$00\
2378
+ \$11\$01\$05\$00\$11\$00\$05\$01\$07\$04\$00\$00\$00\$00\$00\$00\
2379
+ \$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\
2380
+ \$07\$01\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$01\
2381
+ \$07\$04\$ee\$00\$00\$00\$00\$00\$07\$03\$ee\$00\$00\$00\$00\$00\
2382
+ \$07\$02\$ee\$00\$00\$00\$00\$00\$07\$01\$ee\$00\$00\$00\$00\$00\
2383
+ \$07\$00\$ee\$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\
2384
+ \$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\
2385
+ \$07\$01\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$20\
2386
+ \$07\$04\$ee\$00\$00\$00\$00\$00\$07\$03\$ee\$00\$00\$00\$00\$00\
2387
+ \$07\$02\$ee\$00\$00\$00\$00\$00\$07\$01\$ee\$00\$00\$00\$00\$00\
2388
+ \$07\$00\$ee\$00\$00\$00\$00\$00\$11\$01\$04\$00\$11\$00\$04\$01\
2389
+ \$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\
2390
+ \$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\
2391
+ \$07\$00\$00\$00\$00\$00\$00\$01\$07\$04\$ee\$00\$00\$00\$00\$00\
2392
+ \$07\$03\$ee\$00\$00\$00\$00\$00\$07\$02\$ee\$00\$00\$00\$00\$00\
2393
+ \$07\$01\$ee\$00\$00\$00\$00\$00\$07\$00\$ee\$00\$00\$00\$00\$01\
2394
+ \$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\
2395
+ \$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\
2396
+ \$07\$00\$00\$00\$00\$00\$00\$17\$07\$04\$ee\$00\$00\$00\$00\$00\
2397
+ \$07\$03\$ee\$00\$00\$00\$00\$00\$07\$02\$ee\$00\$00\$00\$00\$00\
2398
+ \$07\$01\$ee\$00\$00\$00\$00\$00\$07\$00\$ee\$00\$00\$00\$00\$01\
2399
+ \$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\
2400
+ \$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\
2401
+ \$07\$00\$00\$00\$00\$00\$00\$01\$07\$04\$ee\$00\$00\$00\$00\$00\
2402
+ \$07\$03\$ee\$00\$00\$00\$00\$00\$07\$02\$ee\$00\$00\$00\$00\$00\
2403
+ \$07\$01\$ee\$00\$00\$00\$00\$00\$07\$00\$ee\$00\$00\$00\$00\$01\
2404
+ \$07\$00\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\
2405
+ \$07\$02\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\
2406
+ \$07\$04\$00\$00\$00\$00\$00\$00\$12\$01\$01\$6b\$00\$01\$14\$00\
2407
+ \$07\$02\$00\$ee\$00\$00\$00\$00\$11\$01\$06\$00\$11\$00\$06\$01\
2408
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2409
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$00\$00\$ff\$00\$00\$01\
2410
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$99\$ff\$00\$00\$00\$01\
2411
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$ff\$00\$00\$00\$00\$01\
2412
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$cc\$00\$ff\$00\$00\$01\
2413
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ff\$ff\$00\$00\$01\
2414
+ \$07\$02\$00\$00\$00\$00\$00\$00\$11\$01\$05\$00\$11\$00\$05\$01\
2415
+ \$07\$02\$ff\$cc\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2416
+ \$07\$02\$00\$99\$ff\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2417
+ \$07\$02\$ee\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2418
+ \$07\$02\$ff\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2419
+ \$07\$02\$cc\$00\$ff\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2420
+ \$07\$02\$00\$ff\$ff\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2421
+ \$07\$02\$ff\$cc\$00\$00\$00\$00\$11\$01\$06\$00\$11\$00\$06\$01\
2422
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2423
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$00\$00\$ff\$00\$00\$01\
2424
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$cc\$00\$ff\$00\$00\$01\
2425
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ff\$ff\$00\$00\$01\
2426
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$ff\$cc\$00\$00\$00\$01\
2427
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$cc\$00\$ff\$00\$00\$01\
2428
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ff\$ff\$00\$00\$01\
2429
+ \$07\$02\$00\$00\$00\$00\$00\$00\$12\$02\$02\$6b\$00\$01\$10\$00\
2430
+ \$11\$01\$02\$07\$07\$04\$ff\$ff\$00\$00\$00\$00\$07\$03\$ff\$ff\
2431
+ \$00\$00\$00\$00\$07\$02\$ff\$ff\$00\$00\$00\$00\$07\$01\$ff\$ff\
2432
+ \$00\$00\$00\$00\$07\$00\$ff\$ff\$00\$00\$00\$00\$11\$00\$02\$07\
2433
+ \$11\$01\$02\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\
2434
+ \$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\
2435
+ \$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$06\$07\$04\$ff\$ff\
2436
+ \$00\$00\$00\$00\$07\$03\$ff\$ff\$00\$00\$00\$00\$07\$02\$ff\$ff\
2437
+ \$00\$00\$00\$00\$07\$01\$ff\$ff\$00\$00\$00\$00\$07\$00\$ff\$ff\
2438
+ \$00\$00\$00\$00\$11\$00\$02\$07\$11\$01\$02\$01\$07\$04\$00\$00\
2439
+ \$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\
2440
+ \$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\
2441
+ \$00\$00\$00\$06\$07\$04\$ff\$ff\$00\$00\$00\$00\$07\$03\$ff\$ff\
2442
+ \$00\$00\$00\$00\$07\$02\$ff\$ff\$00\$00\$00\$00\$07\$01\$ff\$ff\
2443
+ \$00\$00\$00\$00\$07\$00\$ff\$ff\$00\$00\$00\$00\$11\$00\$02\$07\
2444
+ \$11\$01\$03\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\
2445
+ \$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\
2446
+ \$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$06\$07\$04\$ff\$ff\
2447
+ \$00\$00\$00\$00\$07\$03\$ff\$ff\$00\$00\$00\$00\$07\$02\$ff\$ff\
2448
+ \$00\$00\$00\$00\$07\$01\$ff\$ff\$00\$00\$00\$00\$07\$00\$ff\$ff\
2449
+ \$00\$00\$00\$00\$11\$00\$03\$07\$11\$01\$02\$01\$07\$04\$00\$00\
2450
+ \$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\
2451
+ \$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\
2452
+ \$00\$00\$00\$06\$07\$04\$ff\$ff\$00\$00\$00\$00\$07\$03\$ff\$ff\
2453
+ \$00\$00\$00\$00\$07\$02\$ff\$ff\$00\$00\$00\$00\$07\$01\$ff\$ff\
2454
+ \$00\$00\$00\$00\$07\$00\$ff\$ff\$00\$00\$00\$00\$11\$00\$02\$07\
2455
+ \$11\$01\$04\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\
2456
+ \$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\
2457
+ \$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\$00\$06\$07\$04\$ff\$ff\
2458
+ \$00\$00\$00\$00\$07\$03\$ff\$ff\$00\$00\$00\$00\$07\$02\$ff\$ff\
2459
+ \$00\$00\$00\$00\$07\$01\$ff\$ff\$00\$00\$00\$00\$07\$00\$ff\$ff\
2460
+ \$00\$00\$00\$00\$11\$00\$04\$07\$11\$01\$02\$01\$07\$04\$00\$00\
2461
+ \$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\
2462
+ \$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\
2463
+ \$00\$00\$00\$06\$07\$04\$ff\$ff\$00\$00\$00\$00\$07\$03\$ff\$ff\
2464
+ \$00\$00\$00\$00\$07\$02\$ff\$ff\$00\$00\$00\$00\$07\$01\$ff\$ff\
2465
+ \$00\$00\$00\$00\$07\$00\$ff\$ff\$00\$00\$00\$00\$11\$00\$02\$08\
2466
+ \$07\$04\$00\$00\$00\$00\$00\$00\$07\$03\$00\$00\$00\$00\$00\$00\
2467
+ \$07\$02\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\$00\$00\
2468
+ \$07\$00\$00\$00\$00\$00\$00\$00\$12\$03\$01\$1b\$00\$01\$10\$00\
2469
+ \$07\$03\$ff\$00\$00\$00\$00\$00\$11\$01\$02\$07\$07\$01\$ff\$00\
2470
+ \$00\$00\$00\$00\$11\$00\$02\$01\$07\$03\$00\$00\$00\$00\$00\$06\
2471
+ \$07\$03\$ff\$00\$00\$00\$00\$00\$11\$01\$02\$01\$07\$01\$00\$00\
2472
+ \$00\$00\$00\$06\$07\$01\$ff\$00\$00\$00\$00\$00\$11\$00\$02\$01\
2473
+ \$07\$03\$00\$00\$00\$00\$00\$06\$07\$03\$ff\$00\$00\$00\$00\$00\
2474
+ \$11\$01\$02\$01\$07\$01\$00\$00\$00\$00\$00\$06\$07\$01\$ff\$00\
2475
+ \$00\$00\$00\$00\$11\$00\$02\$01\$07\$03\$00\$00\$00\$00\$00\$06\
2476
+ \$07\$03\$ff\$00\$00\$00\$00\$00\$11\$01\$03\$01\$07\$01\$00\$00\
2477
+ \$00\$00\$00\$06\$07\$01\$ff\$00\$00\$00\$00\$00\$11\$00\$03\$01\
2478
+ \$07\$03\$00\$00\$00\$00\$00\$06\$07\$03\$ff\$00\$00\$00\$00\$00\
2479
+ \$11\$01\$02\$01\$07\$01\$00\$00\$00\$00\$00\$06\$07\$01\$ff\$00\
2480
+ \$00\$00\$00\$00\$11\$00\$02\$01\$07\$03\$00\$00\$00\$00\$00\$06\
2481
+ \$07\$03\$ff\$00\$00\$00\$00\$00\$11\$01\$04\$01\$07\$01\$00\$00\
2482
+ \$00\$00\$00\$06\$07\$01\$ff\$00\$00\$00\$00\$00\$11\$00\$04\$01\
2483
+ \$07\$03\$00\$00\$00\$00\$00\$06\$07\$03\$ff\$00\$00\$00\$00\$00\
2484
+ \$11\$01\$02\$01\$07\$01\$00\$00\$00\$00\$00\$06\$07\$01\$ff\$00\
2485
+ \$00\$00\$00\$00\$11\$00\$02\$01\$07\$03\$00\$00\$00\$00\$00\$07\
2486
+ \$07\$01\$00\$00\$00\$00\$00\$00\$12\$04\$01\$03\$00\$01\$08\$00\
2487
+ \$11\$01\$04\$00\$11\$00\$04\$1e\$07\$03\$00\$ee\$00\$00\$00\$01\
2488
+ \$07\$03\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2489
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$01\$00\$ee\$00\$00\$00\$01\
2490
+ \$07\$01\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2491
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$03\$00\$ee\$00\$00\$00\$01\
2492
+ \$07\$03\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2493
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$01\$00\$ee\$00\$00\$00\$01\
2494
+ \$07\$01\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2495
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$03\$00\$ee\$00\$00\$00\$01\
2496
+ \$07\$03\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2497
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$01\$00\$ee\$00\$00\$00\$01\
2498
+ \$07\$01\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2499
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$03\$00\$ee\$00\$00\$00\$01\
2500
+ \$07\$03\$00\$00\$00\$00\$00\$01\$07\$02\$00\$ee\$00\$00\$00\$01\
2501
+ \$07\$02\$00\$00\$00\$00\$00\$01\$07\$01\$00\$ee\$00\$00\$00\$01\
2502
+ \$07\$01\$00\$00\$00\$00\$00\$00\$11\$01\$0d\$00\$11\$00\$0d\$00\
2503
+ \$12\$05\$01\$03\$00\$01\$08\$00\$11\$01\$04\$00\$11\$00\$04\$1e\
2504
+ \$07\$04\$ff\$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$01\
2505
+ \$07\$02\$ff\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2506
+ \$07\$00\$ff\$00\$00\$00\$00\$01\$07\$00\$00\$00\$00\$00\$00\$01\
2507
+ \$07\$02\$ff\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2508
+ \$07\$04\$ff\$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$01\
2509
+ \$07\$02\$ff\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2510
+ \$07\$00\$ff\$00\$00\$00\$00\$01\$07\$00\$00\$00\$00\$00\$00\$01\
2511
+ \$07\$02\$ff\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2512
+ \$07\$04\$ff\$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$01\
2513
+ \$07\$02\$ff\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2514
+ \$07\$00\$ff\$00\$00\$00\$00\$01\$07\$00\$00\$00\$00\$00\$00\$01\
2515
+ \$07\$02\$ff\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2516
+ \$07\$04\$ff\$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\$00\$01\
2517
+ \$07\$02\$ff\$00\$00\$00\$00\$01\$07\$02\$00\$00\$00\$00\$00\$01\
2518
+ \$07\$00\$ff\$00\$00\$00\$00\$01\$07\$00\$00\$00\$00\$00\$00\$00\
2519
+ \$11\$01\$0d\$00\$11\$00\$0d\$01\$13\$00\$01\$0a\$00\$10\$00\$01\
2520
+ \$04\$01\$07\$04\$00\$33\$ff\$00\$00\$00\$07\$02\$ff\$00\$00\$00\
2521
+ \$00\$00\$07\$00\$ff\$ff\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\
2522
+ \$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2523
+ \$00\$00\$07\$01\$ff\$ff\$00\$00\$00\$01\$07\$01\$00\$00\$00\$00\
2524
+ \$00\$00\$07\$04\$ff\$ff\$00\$00\$00\$00\$07\$02\$00\$ee\$00\$00\
2525
+ \$00\$00\$07\$00\$ff\$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\
2526
+ \$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2527
+ \$00\$00\$07\$03\$00\$ee\$00\$00\$00\$01\$07\$03\$00\$00\$00\$00\
2528
+ \$00\$00\$07\$04\$ee\$00\$00\$00\$00\$00\$07\$01\$00\$33\$ff\$00\
2529
+ \$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\
2530
+ \$00\$00\$07\$04\$ff\$00\$00\$00\$00\$00\$07\$00\$ff\$ff\$00\$00\
2531
+ \$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2532
+ \$00\$00\$07\$03\$00\$33\$ff\$00\$00\$01\$07\$03\$00\$00\$00\$00\
2533
+ \$00\$00\$07\$02\$ff\$ff\$00\$00\$00\$00\$07\$00\$ff\$00\$00\$00\
2534
+ \$00\$01\$07\$02\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2535
+ \$00\$01\$07\$03\$ee\$00\$00\$00\$00\$00\$07\$00\$00\$ee\$00\$00\
2536
+ \$00\$01\$07\$03\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2537
+ \$00\$00\$07\$03\$ff\$00\$00\$00\$00\$00\$07\$02\$00\$ee\$00\$00\
2538
+ \$00\$01\$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\
2539
+ \$00\$00\$07\$01\$00\$33\$ff\$00\$00\$01\$07\$01\$00\$00\$00\$00\
2540
+ \$00\$01\$07\$04\$00\$33\$ff\$00\$00\$00\$07\$02\$ff\$00\$00\$00\
2541
+ \$00\$00\$07\$00\$ff\$ff\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\
2542
+ \$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2543
+ \$00\$00\$07\$01\$ff\$ff\$00\$00\$00\$01\$07\$01\$00\$00\$00\$00\
2544
+ \$00\$00\$07\$04\$ff\$ff\$00\$00\$00\$00\$07\$02\$00\$ee\$00\$00\
2545
+ \$00\$00\$07\$00\$ff\$00\$00\$00\$00\$01\$07\$04\$00\$00\$00\$00\
2546
+ \$00\$00\$07\$02\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2547
+ \$00\$00\$07\$03\$00\$ee\$00\$00\$00\$01\$07\$03\$00\$00\$00\$00\
2548
+ \$00\$00\$07\$04\$ee\$00\$00\$00\$00\$00\$07\$01\$00\$33\$ff\$00\
2549
+ \$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$01\$00\$00\$00\$00\
2550
+ \$00\$00\$07\$04\$ff\$00\$00\$00\$00\$00\$07\$00\$ff\$ff\$00\$00\
2551
+ \$00\$01\$07\$04\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2552
+ \$00\$00\$07\$03\$00\$33\$ff\$00\$00\$01\$07\$03\$00\$00\$00\$00\
2553
+ \$00\$00\$07\$02\$ff\$ff\$00\$00\$00\$00\$07\$00\$ff\$00\$00\$00\
2554
+ \$00\$01\$07\$02\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2555
+ \$00\$01\$07\$03\$ee\$00\$00\$00\$00\$00\$07\$00\$00\$ee\$00\$00\
2556
+ \$00\$01\$07\$03\$00\$00\$00\$00\$00\$00\$07\$00\$00\$00\$00\$00\
2557
+ \$00\$00\$07\$03\$ff\$00\$00\$00\$00\$00\$07\$02\$00\$ee\$00\$00\
2558
+ \$00\$01\$07\$03\$00\$00\$00\$00\$00\$00\$07\$02\$00\$00\$00\$00\
2559
+ \$00\$00\$07\$01\$00\$33\$ff\$00\$00\$01\$07\$01\$00\$00\$00\$00\
2560
+ \$00\$01\$13\$00\$00\$00\$00";;
2561
+
2562
+ var chorstream=
2563
+ "\$00\$04\$ff\$66\$00\$00\$03\$ff\$ff\$00\$00\$01\$ff\$ff\$00\$00\$00\$ff\$00\$00\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\
2564
+ \$ff\$ff\$00\$01\$02\$00\$00\$00\$01\$00\$00\$00\$00\$01\$03\$ff\$ff\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$00\$02\$ff\$ff\
2565
+ \$00\$00\$00\$ff\$00\$00\$01\$02\$00\$00\$00\$00\$01\$ff\$ff\$00\$01\$01\$00\$00\$00\$00\$04\$ff\$66\$00\$01\$00\$00\$00\$00\$01\
2566
+ \$03\$ff\$ff\$00\$01\$03\$00\$00\$00\$00\$02\$ff\$ff\$00\$00\$00\$ff\$00\$00\$01\$02\$00\$00\$00\$00\$01\$ff\$ff\$00\$01\$04\$00\
2567
+ \$00\$00\$00\$01\$00\$00\$00\$01\$00\$00\$00\$00\$01\$04\$ff\$66\$00\$00\$01\$ff\$ff\$00\$01\$01\$00\$00\$00\$00\$02\$ff\$ff\$00\
2568
+ \$00\$00\$ff\$00\$00\$01\$02\$00\$00\$00\$00\$03\$ff\$ff\$00\$01\$03\$00\$00\$00\$01\$00\$00\$00\$00\$01\$04\$00\$00\$00\$00\$02\
2569
+ \$ff\$ff\$00\$01\$02\$00\$00\$00\$00\$03\$ff\$ff\$00\$00\$01\$ff\$ff\$00\$00\$00\$ff\$00\$00\$01\$03\$00\$00\$00\$00\$01\$00\$00\
2570
+ \$00\$00\$04\$ff\$66\$00\$00\$02\$ff\$ff\$00\$01\$02\$00\$00\$00\$01\$00\$00\$00\$00\$01\$03\$ff\$ff\$00\$00\$02\$ff\$ff\$00\$00\
2571
+ \$01\$ff\$ff\$00\$01\$03\$00\$00\$00\$00\$02\$00\$00\$00\$00\$01\$00\$00\$00\$00\$00\$ff\$00\$00\$01\$04\$00\$00\$00\$02\$00\$00\
2572
+ \$00\$00\$00\$04\$ff\$66\$00\$02\$00\$ff\$00\$00\$01\$03\$ff\$ff\$00\$00\$01\$ff\$ff\$00\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\
2573
+ \$00\$02\$ff\$ff\$00\$01\$04\$00\$00\$00\$00\$02\$00\$00\$00\$00\$00\$00\$00\$00\$02\$04\$ff\$66\$00\$00\$03\$ff\$ff\$00\$00\$00\
2574
+ \$ff\$00\$00\$01\$03\$00\$00\$00\$00\$02\$ff\$ff\$00\$01\$02\$00\$00\$00\$00\$01\$ff\$ff\$00\$01\$01\$00\$00\$00\$00\$00\$00\$00\
2575
+ \$00\$02\$04\$00\$00\$00\$00\$01\$ff\$ff\$00\$00\$00\$ff\$00\$00\$01\$01\$00\$00\$00\$00\$02\$ff\$ff\$00\$01\$02\$00\$00\$00\$00\
2576
+ \$04\$ff\$66\$00\$00\$03\$ff\$ff\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$00\$00\$00\$00\$00\$1e\$04\$ff\$ff\$00\$00\$03\$ff\
2577
+ \$00\$00\$00\$01\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\$ff\$00\$00\$01\$02\$00\$00\$00\
2578
+ \$01\$00\$00\$00\$00\$01\$03\$ff\$00\$00\$01\$03\$00\$00\$00\$00\$02\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$02\$00\$00\$00\$00\$01\
2579
+ \$ff\$00\$00\$01\$04\$00\$00\$00\$00\$01\$00\$00\$00\$01\$00\$00\$00\$00\$01\$04\$ff\$ff\$00\$01\$00\$ff\$ff\$ff\$03\$00\$00\$00\
2580
+ \$00\$01\$01\$ff\$00\$00\$01\$01\$00\$00\$00\$00\$02\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$04\$00\$00\$00\$00\$02\$00\$00\$00\$00\
2581
+ \$03\$ff\$00\$00\$01\$03\$00\$00\$00\$01\$00\$00\$00\$00\$01\$02\$ff\$00\$00\$01\$02\$00\$00\$00\$00\$03\$ff\$00\$00\$00\$01\$ff\
2582
+ \$00\$00\$00\$00\$ff\$ff\$ff\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\$ff\$00\$00\$01\$02\$00\$00\$00\$01\$00\$00\$00\$00\
2583
+ \$01\$03\$ff\$00\$00\$00\$02\$ff\$00\$00\$00\$01\$ff\$00\$00\$01\$03\$00\$00\$00\$00\$02\$00\$00\$00\$00\$01\$00\$00\$00\$00\$00\
2584
+ \$ff\$ff\$ff\$02\$04\$ff\$ff\$00\$00\$03\$ff\$00\$00\$00\$01\$ff\$00\$00\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$00\$00\$00\
2585
+ \$00\$00\$02\$ff\$00\$00\$01\$02\$00\$00\$00\$01\$00\$ff\$ff\$ff\$03\$00\$00\$00\$00\$01\$04\$00\$00\$00\$01\$03\$ff\$00\$00\$00\
2586
+ \$00\$ff\$ff\$ff\$01\$03\$00\$00\$00\$00\$04\$ff\$ff\$00\$00\$02\$ff\$00\$00\$01\$02\$00\$00\$00\$00\$01\$ff\$00\$00\$01\$01\$00\
2587
+ \$00\$00\$00\$00\$00\$00\$00\$02\$01\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$01\$00\$00\$00\$00\$02\$ff\$00\$00\$01\$02\$00\$00\$00\
2588
+ \$00\$03\$ff\$00\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$00\$00\$00\$00\$00\$02\$00\$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\
2589
+ \$00\$00\$00\$00\$03\$00\$00\$00\$00\$04\$00\$00\$00"::
2590
+ "\$00\$04\$ff\$ff\$00\$00\$03\$ff\$00\$00\$00\$01\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\
2591
+ \$ff\$00\$00\$01\$02\$00\$00\$00\$01\$00\$00\$00\$00\$01\$03\$ff\$00\$00\$01\$03\$00\$00\$00\$00\$02\$ff\$00\$00\$00\$00\$ff\$ff\
2592
+ \$ff\$01\$02\$00\$00\$00\$00\$01\$ff\$00\$00\$01\$04\$00\$00\$00\$00\$01\$00\$00\$00\$01\$00\$00\$00\$00\$01\$04\$ff\$ff\$00\$01\
2593
+ \$00\$ff\$ff\$ff\$03\$00\$00\$00\$00\$01\$01\$ff\$00\$00\$01\$01\$00\$00\$00\$00\$02\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$04\$00\
2594
+ \$00\$00\$00\$02\$00\$00\$00\$00\$03\$ff\$00\$00\$01\$03\$00\$00\$00\$01\$00\$00\$00\$00\$01\$02\$ff\$00\$00\$01\$02\$00\$00\$00\
2595
+ \$00\$03\$ff\$00\$00\$00\$01\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\$ff\$00\$00\$01\$02\
2596
+ \$00\$00\$00\$01\$00\$00\$00\$00\$01\$03\$ff\$00\$00\$00\$02\$ff\$00\$00\$00\$01\$ff\$00\$00\$01\$03\$00\$00\$00\$00\$02\$00\$00\
2597
+ \$00\$00\$01\$00\$00\$00\$00\$00\$ff\$ff\$ff\$02\$04\$ff\$ff\$00\$00\$03\$ff\$00\$00\$00\$01\$ff\$00\$00\$01\$03\$00\$00\$00\$00\
2598
+ \$01\$00\$00\$00\$00\$00\$00\$00\$00\$00\$02\$ff\$00\$00\$01\$02\$00\$00\$00\$01\$00\$ff\$ff\$ff\$03\$00\$00\$00\$00\$01\$04\$00\
2599
+ \$00\$00\$01\$03\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$03\$00\$00\$00\$00\$04\$ff\$ff\$00\$00\$02\$ff\$00\$00\$01\$02\$00\$00\$00\
2600
+ \$00\$01\$ff\$00\$00\$01\$01\$00\$00\$00\$00\$00\$00\$00\$00\$02\$01\$ff\$00\$00\$00\$00\$ff\$ff\$ff\$01\$01\$00\$00\$00\$00\$02\
2601
+ \$ff\$00\$00\$01\$02\$00\$00\$00\$00\$03\$ff\$00\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$00\$00\$00\$00\$00\$06\$04\$ff\$00\
2602
+ \$00\$00\$03\$ff\$ff\$ff\$00\$01\$ff\$ff\$ff\$00\$00\$ff\$ff\$00\$01\$02\$ff\$ff\$ff\$01\$00\$00\$00\$00\$01\$03\$00\$00\$00\$00\
2603
+ \$01\$00\$00\$00\$01\$02\$00\$00\$00\$01\$03\$ff\$ff\$ff\$01\$04\$00\$00\$00\$00\$02\$ff\$ff\$ff\$00\$00\$ff\$ff\$00\$01\$01\$ff\
2604
+ \$ff\$ff\$01\$03\$00\$00\$00\$00\$00\$00\$00\$00\$01\$02\$00\$00\$00\$01\$01\$00\$00\$00\$00\$04\$ff\$00\$00\$02\$00\$ff\$ff\$00\
2605
+ \$01\$01\$ff\$ff\$ff\$01\$00\$00\$00\$00\$00\$02\$ff\$ff\$ff\$01\$03\$ff\$ff\$ff\$01\$01\$00\$00\$00\$01\$04\$00\$00\$00\$00\$02\
2606
+ \$00\$00\$00\$01\$03\$00\$00\$00\$00\$00\$ff\$ff\$00\$01\$02\$ff\$ff\$ff\$01\$00\$00\$00\$00\$00\$03\$ff\$ff\$ff\$00\$01\$ff\$ff\
2607
+ \$ff\$01\$04\$ff\$00\$00\$01\$02\$00\$00\$00\$01\$02\$ff\$ff\$ff\$01\$00\$ff\$ff\$00\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$01\
2608
+ \$02\$00\$00\$00\$00\$00\$00\$00\$00\$02\$04\$00\$00\$00\$02\$03\$ff\$ff\$ff\$00\$02\$ff\$ff\$ff\$00\$01\$ff\$ff\$ff\$00\$00\$ff\
2609
+ \$ff\$00\$01\$04\$ff\$00\$00\$01\$00\$00\$00\$00\$01\$03\$00\$00\$00\$00\$02\$00\$00\$00\$00\$01\$00\$00\$00\$03\$00\$ff\$ff\$00\
2610
+ \$02\$04\$00\$00\$00\$00\$00\$00\$00\$00\$00\$01\$ff\$ff\$ff\$01\$02\$ff\$ff\$ff\$01\$03\$ff\$ff\$ff\$01\$01\$00\$00\$00\$01\$02\
2611
+ \$00\$00\$00\$00\$00\$ff\$ff\$00\$01\$03\$00\$00\$00\$01\$00\$00\$00\$00\$01\$03\$ff\$ff\$ff\$01\$02\$ff\$ff\$ff\$01\$01\$ff\$ff\
2612
+ \$ff\$01\$03\$00\$00\$00\$00\$00\$ff\$ff\$00\$01\$02\$00\$00\$00\$01\$01\$00\$00\$00\$00\$00\$00\$00\$00\$00\$04\$ff\$00\$00\$03\
2613
+ \$03\$ff\$ff\$ff\$00\$01\$ff\$ff\$ff\$01\$02\$ff\$ff\$ff\$00\$00\$ff\$ff\$00\$02\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$00\$00\
2614
+ \$00\$00\$01\$04\$00\$00\$00\$00\$02\$00\$00\$00\$03\$00\$ff\$ff\$00\$01\$04\$ff\$00\$00\$00\$03\$ff\$ff\$ff\$00\$01\$ff\$ff\$ff\
2615
+ \$01\$00\$00\$00\$00\$00\$02\$ff\$ff\$ff\$02\$03\$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$01\$00\$ff\$ff\$00\$02\$04\
2616
+ \$00\$00\$00\$00\$00\$00\$00\$00\$04\$00\$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\$00\$00\$00\$00\$03\$00\$00\$00\$00\$04\$00\$00\
2617
+ \$00"::
2618
+ "\$00\$04\$ff\$00\$00\$00\$03\$ff\$ff\$ff\$00\$01\$ff\$ff\$ff\$00\$00\$ff\$ff\$00\$01\$02\$ff\$ff\$ff\$01\$00\$00\$00\$00\$01\$03\
2619
+ \$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$01\$03\$ff\$ff\$ff\$01\$04\$00\$00\$00\$00\$02\$ff\$ff\$ff\$00\$00\$ff\$ff\
2620
+ \$00\$01\$01\$ff\$ff\$ff\$01\$03\$00\$00\$00\$00\$00\$00\$00\$00\$01\$02\$00\$00\$00\$01\$01\$00\$00\$00\$00\$04\$ff\$00\$00\$02\
2621
+ \$04\$00\$00\$00\$42\$04\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$00\$00\$ff\$00\$00\$01\$02\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$03\$ff\
2622
+ \$cc\$00\$02\$01\$00\$00\$00\$00\$04\$ff\$cc\$00\$01\$02\$00\$00\$00\$00\$00\$00\$00\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\
2623
+ \$01\$00\$ff\$00\$00\$01\$04\$ff\$cc\$00\$00\$03\$ff\$cc\$00\$01\$02\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$01\$ff\$cc\$00\$01\$03\
2624
+ \$00\$00\$00\$01\$02\$00\$00\$00\$00\$00\$00\$00\$00\$01\$01\$00\$00\$00\$01\$00\$ff\$00\$00\$01\$01\$ff\$cc\$00\$01\$04\$ff\$cc\
2625
+ \$00\$00\$02\$ff\$cc\$00\$01\$03\$ff\$cc\$00\$01\$04\$00\$00\$00\$01\$01\$00\$00\$00\$00\$00\$00\$00\$00\$01\$02\$00\$00\$00\$00\
2626
+ \$04\$ff\$cc\$00\$01\$03\$00\$00\$00\$00\$00\$ff\$00\$00\$01\$04\$00\$00\$00\$01\$03\$ff\$cc\$00\$01\$04\$ff\$cc\$00\$00\$02\$ff\
2627
+ \$cc\$00\$01\$01\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$00\$00\$00\$00\$00\$01\$02\$00\$00\$00\$01\$01\$00\$00\$00\
2628
+ \$00\$00\$ff\$00\$00\$04\$04\$ff\$cc\$00\$00\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$01\$00\$00\$00\$00\$00\$02\$ff\$cc\$00\$01\$04\
2629
+ \$00\$00\$00\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$00\$ff\$00\$00\$01\$02\$00\$00\$00\$00\$04\$ff\$cc\$00\$01\$03\$ff\$cc\
2630
+ \$00\$00\$01\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$02\$ff\$cc\$00\$02\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2631
+ \$04\$ff\$cc\$00\$01\$02\$00\$00\$00\$01\$04\$00\$00\$00\$00\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$00\$00\$ff\$00\$00\$01\$02\$ff\
2632
+ \$cc\$00\$02\$03\$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$01\$00\$00\$00\$00\$00\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\
2633
+ \$01\$04\$ff\$cc\$00\$00\$02\$ff\$cc\$00\$01\$00\$ff\$00\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\
2634
+ \$00\$00\$00\$01\$04\$ff\$cc\$00\$00\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$01\$02\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$00\$00\$00\
2635
+ \$00\$01\$03\$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$00\$04\$ff\$cc\$00\$00\$00\$ff\$00\$00\$01\$03\$ff\$cc\$00\$00\
2636
+ \$01\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$02\$ff\$cc\$00\$02\$03\$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$00\$00\$00\
2637
+ \$00\$00\$02\$00\$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\$00\$00\$00\$00\$03\$00\$00\$00\$00\$04\$00\$00\$00"::
2638
+ "\$00\$04\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$00\$00\$ff\$00\$00\$01\$02\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$03\$ff\$cc\$00\$02\$01\
2639
+ \$00\$00\$00\$00\$04\$ff\$cc\$00\$01\$02\$00\$00\$00\$00\$00\$00\$00\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$01\$00\$ff\$00\
2640
+ \$00\$01\$04\$ff\$cc\$00\$00\$03\$ff\$cc\$00\$01\$02\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$01\$ff\$cc\$00\$01\$03\$00\$00\$00\$01\
2641
+ \$02\$00\$00\$00\$00\$00\$00\$00\$00\$01\$01\$00\$00\$00\$01\$00\$ff\$00\$00\$01\$01\$ff\$cc\$00\$01\$04\$ff\$cc\$00\$00\$02\$ff\
2642
+ \$cc\$00\$01\$03\$ff\$cc\$00\$01\$04\$00\$00\$00\$01\$01\$00\$00\$00\$00\$00\$00\$00\$00\$01\$02\$00\$00\$00\$00\$04\$ff\$cc\$00\
2643
+ \$01\$03\$00\$00\$00\$00\$00\$ff\$00\$00\$01\$04\$00\$00\$00\$01\$03\$ff\$cc\$00\$01\$04\$ff\$cc\$00\$00\$02\$ff\$cc\$00\$01\$01\
2644
+ \$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$00\$00\$00\$00\$00\$01\$02\$00\$00\$00\$01\$01\$00\$00\$00\$00\$00\$ff\$00\
2645
+ \$00\$04\$04\$ff\$cc\$00\$00\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$01\$00\$00\$00\$00\$00\$02\$ff\$cc\$00\$01\$04\$00\$00\$00\$01\
2646
+ \$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$00\$ff\$00\$00\$01\$02\$00\$00\$00\$00\$04\$ff\$cc\$00\$01\$03\$ff\$cc\$00\$00\$01\$ff\
2647
+ \$cc\$00\$01\$04\$00\$00\$00\$00\$02\$ff\$cc\$00\$02\$03\$00\$00\$00\$00\$01\$00\$00\$00\$00\$00\$00\$00\$00\$00\$04\$ff\$cc\$00\
2648
+ \$01\$02\$00\$00\$00\$01\$04\$00\$00\$00\$00\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$00\$00\$ff\$00\$00\$01\$02\$ff\$cc\$00\$02\$03\
2649
+ \$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$01\$00\$00\$00\$00\$00\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$01\$04\$ff\$cc\
2650
+ \$00\$00\$02\$ff\$cc\$00\$01\$00\$ff\$00\$00\$01\$04\$00\$00\$00\$00\$03\$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$01\
2651
+ \$04\$ff\$cc\$00\$00\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\$01\$02\$ff\$cc\$00\$01\$04\$00\$00\$00\$00\$00\$00\$00\$00\$01\$03\$00\
2652
+ \$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$00\$04\$ff\$cc\$00\$00\$00\$ff\$00\$00\$01\$03\$ff\$cc\$00\$00\$01\$ff\$cc\$00\
2653
+ \$01\$04\$00\$00\$00\$00\$02\$ff\$cc\$00\$02\$03\$00\$00\$00\$00\$01\$00\$00\$00\$01\$02\$00\$00\$00\$00\$00\$00\$00\$00\$02\$00\
2654
+ \$00\$00\$00\$00\$01\$00\$00\$00\$00\$02\$00\$00\$00\$00\$03\$00\$00\$00\$00\$04\$00\$00\$00"::
2655
+ nil;;
2656
+
2657
+ var midi_1noteA4=
2658
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2659
+ \$72\$6b\$00\$00\$00\$2a\$00\$ff\$03\$07\$31\$6e\$6f\$74\$65\$41\
2660
+ \$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\$08\
2661
+ \$00\$c0\$09\$14\$90\$51\$78\$82\$4a\$80\$51\$49\$00\$ff\$2f\$00";;
2662
+ var midi_1noteB5=
2663
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2664
+ \$72\$6b\$00\$00\$00\$2a\$00\$ff\$03\$07\$31\$6e\$6f\$74\$65\$42\
2665
+ \$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\$08\
2666
+ \$00\$c0\$09\$0a\$90\$5f\$76\$82\$5d\$80\$5f\$4d\$00\$ff\$2f\$00";;
2667
+ var midi_1noteBb4=
2668
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2669
+ \$72\$6b\$00\$00\$00\$2b\$00\$ff\$03\$08\$31\$6e\$6f\$74\$65\$42\
2670
+ \$62\$34\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\
2671
+ \$08\$00\$c0\$09\$14\$90\$52\$64\$82\$7a\$80\$52\$49\$00\$ff\$2f\
2672
+ \$00";;
2673
+ var midi_1noteC5=
2674
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2675
+ \$72\$6b\$00\$00\$00\$2a\$00\$ff\$03\$07\$31\$6e\$6f\$74\$65\$43\
2676
+ \$36\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\$08\
2677
+ \$00\$c0\$09\$0d\$90\$54\$7a\$83\$39\$80\$54\$76\$00\$ff\$2f\$00";;
2678
+ var midi_1noteE4=
2679
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2680
+ \$72\$6b\$00\$00\$00\$29\$00\$ff\$03\$06\$4e\$6f\$74\$65\$31\$41\
2681
+ \$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\$08\$00\
2682
+ \$c0\$09\$11\$90\$4c\$7f\$82\$56\$80\$4c\$76\$00\$ff\$2f\$00";;
2683
+ var midi_1noteF4=
2684
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2685
+ \$72\$6b\$00\$00\$00\$2b\$00\$ff\$03\$08\$31\$6e\$6f\$74\$65\$46\
2686
+ \$23\$34\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\
2687
+ \$08\$00\$c0\$09\$12\$90\$4e\$6e\$82\$46\$80\$4e\$49\$00\$ff\$2f\
2688
+ \$00";;
2689
+ var midi_1noteF5=
2690
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2691
+ \$72\$6b\$00\$00\$00\$2a\$00\$ff\$03\$07\$31\$6e\$6f\$74\$65\$46\
2692
+ \$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\$08\
2693
+ \$00\$c0\$09\$12\$90\$59\$70\$81\$7f\$80\$59\$49\$00\$ff\$2f\$00";;
2694
+ var midi_1noteG5=
2695
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2696
+ \$72\$6b\$00\$00\$00\$2a\$00\$ff\$03\$07\$31\$6e\$6f\$74\$65\$47\
2697
+ \$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\$08\
2698
+ \$00\$c0\$09\$0f\$90\$5b\$7b\$82\$20\$80\$5b\$4d\$00\$ff\$2f\$00";;
2699
+ var midi_2notesC6C4=
2700
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2701
+ \$72\$6b\$00\$00\$00\$34\$00\$ff\$03\$0a\$32\$6e\$6f\$74\$65\$73\
2702
+ \$43\$36\$43\$34\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\
2703
+ \$02\$18\$08\$00\$c0\$09\$11\$90\$60\$63\$81\$06\$48\$53\$82\$0a\
2704
+ \$80\$60\$4d\$5e\$48\$76\$00\$ff\$2f\$00";;
2705
+ var midi_2notesC6F5=
2706
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2707
+ \$72\$6b\$00\$00\$00\$34\$00\$ff\$03\$0b\$32\$6e\$6f\$74\$65\$73\
2708
+ \$43\$36\$46\$23\$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\
2709
+ \$04\$02\$18\$08\$00\$c0\$09\$14\$90\$60\$5d\$38\$5a\$67\$02\$80\
2710
+ \$60\$6a\$81\$23\$5a\$6f\$00\$ff\$2f\$00";;
2711
+ var midi_2notesD4A5=
2712
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2713
+ \$72\$6b\$00\$00\$00\$33\$00\$ff\$03\$0a\$32\$6e\$6f\$74\$65\$73\
2714
+ \$44\$34\$41\$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\
2715
+ \$02\$18\$08\$00\$c0\$09\$45\$90\$4a\$5b\$81\$70\$5d\$69\$06\$80\
2716
+ \$4a\$49\$78\$5d\$52\$00\$ff\$2f\$00";;
2717
+ var midi_2notesD4G4=
2718
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2719
+ \$72\$6b\$00\$00\$00\$36\$00\$ff\$03\$0a\$32\$6e\$6f\$74\$65\$73\
2720
+ \$44\$34\$47\$34\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\
2721
+ \$02\$18\$08\$00\$c0\$09\$15\$90\$4a\$62\$84\$15\$80\$4a\$49\$10\
2722
+ \$90\$4f\$71\$84\$33\$80\$4f\$76\$00\$ff\$2f\$00";;
2723
+ var midi_2notesD5G4=
2724
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2725
+ \$72\$6b\$00\$00\$00\$32\$00\$ff\$03\$0a\$32\$6e\$6f\$74\$65\$73\
2726
+ \$44\$35\$47\$34\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\
2727
+ \$02\$18\$08\$00\$c0\$09\$08\$90\$56\$5f\$3d\$4f\$5a\$0e\$80\$56\
2728
+ \$78\$49\$4f\$6c\$00\$ff\$2f\$00";;
2729
+ var midi_2notesE5A5=
2730
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2731
+ \$72\$6b\$00\$00\$00\$33\$00\$ff\$03\$0a\$32\$6e\$6f\$74\$65\$73\
2732
+ \$41\$35\$45\$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\
2733
+ \$02\$18\$08\$00\$c0\$09\$14\$90\$58\$59\$81\$03\$5d\$58\$22\$80\
2734
+ \$58\$6f\$7f\$5d\$52\$00\$ff\$2f\$00";;
2735
+ var midi_2notesE5C6=
2736
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2737
+ \$72\$6b\$00\$00\$00\$32\$00\$ff\$03\$0a\$32\$6e\$6f\$74\$65\$73\
2738
+ \$45\$35\$43\$36\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\
2739
+ \$02\$18\$08\$00\$c0\$09\$02\$90\$58\$5a\$43\$60\$62\$08\$80\$58\
2740
+ \$78\$61\$60\$54\$00\$ff\$2f\$00";;
2741
+ var midi_2notesE5E4=
2742
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2743
+ \$72\$6b\$00\$00\$00\$33\$00\$ff\$03\$0a\$32\$6e\$6f\$74\$65\$73\
2744
+ \$45\$35\$45\$34\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\
2745
+ \$02\$18\$08\$00\$c0\$09\$02\$90\$58\$5a\$2c\$4c\$62\$1f\$80\$58\
2746
+ \$78\$83\$76\$4c\$49\$00\$ff\$2f\$00";;
2747
+ var midi_3notesA4G5G5=
2748
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2749
+ \$72\$6b\$00\$00\$00\$3c\$00\$ff\$03\$0c\$33\$6e\$6f\$74\$65\$73\
2750
+ \$41\$34\$47\$35\$47\$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\
2751
+ \$04\$04\$02\$18\$08\$00\$c0\$09\$11\$90\$51\$62\$6c\$5b\$52\$57\
2752
+ \$80\$5b\$6c\$54\$90\$5b\$62\$46\$80\$5b\$54\$56\$51\$49\$00\$ff\
2753
+ \$2f\$00";;
2754
+ var midi_3notesB5A5F5=
2755
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2756
+ \$72\$6b\$00\$00\$00\$3c\$00\$ff\$03\$0c\$33\$6e\$6f\$74\$65\$73\
2757
+ \$42\$35\$41\$35\$46\$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\
2758
+ \$04\$04\$02\$18\$08\$00\$c0\$09\$10\$90\$5f\$49\$27\$5d\$62\$13\
2759
+ \$80\$5f\$6a\$2b\$90\$59\$5a\$08\$80\$5d\$54\$44\$59\$78\$00\$ff\
2760
+ \$2f\$00";;
2761
+ var midi_3notesB5D5C6=
2762
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2763
+ \$72\$6b\$00\$00\$00\$3c\$00\$ff\$03\$0c\$33\$6e\$6f\$74\$65\$73\
2764
+ \$42\$35\$44\$35\$43\$36\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\
2765
+ \$04\$04\$02\$18\$08\$00\$c0\$09\$14\$90\$5f\$62\$28\$56\$52\$10\
2766
+ \$80\$5f\$54\$32\$90\$60\$5a\$15\$80\$56\$6c\$46\$60\$6a\$00\$ff\
2767
+ \$2f\$00";;
2768
+ var midi_3notesD4E4G4=
2769
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2770
+ \$72\$6b\$00\$00\$00\$3c\$00\$ff\$03\$0c\$33\$6e\$6f\$74\$65\$73\
2771
+ \$44\$34\$45\$34\$47\$34\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\
2772
+ \$04\$04\$02\$18\$08\$00\$c0\$09\$03\$90\$4a\$5a\$28\$4c\$52\$23\
2773
+ \$80\$4a\$78\$01\$90\$4f\$62\$33\$80\$4c\$6c\$13\$4f\$54\$00\$ff\
2774
+ \$2f\$00";;
2775
+ var midi_3notesE5A5C6=
2776
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2777
+ \$72\$6b\$00\$00\$00\$41\$00\$ff\$03\$0c\$33\$6e\$6f\$74\$65\$73\
2778
+ \$45\$35\$41\$35\$43\$36\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\
2779
+ \$04\$04\$02\$18\$08\$00\$c0\$09\$02\$90\$58\$5a\$4b\$80\$58\$78\
2780
+ \$81\$01\$90\$5d\$49\$3a\$80\$5d\$6a\$82\$22\$90\$60\$58\$81\$77\
2781
+ \$80\$60\$4d\$00\$ff\$2f\$00";;
2782
+ var midi_3notesE5C6D5=
2783
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2784
+ \$72\$6b\$00\$00\$00\$3d\$00\$ff\$03\$0c\$33\$6e\$6f\$74\$65\$73\
2785
+ \$45\$35\$43\$36\$44\$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\
2786
+ \$04\$04\$02\$18\$08\$00\$c0\$09\$02\$90\$58\$5a\$43\$60\$62\$08\
2787
+ \$80\$58\$78\$26\$90\$56\$48\$18\$80\$60\$54\$82\$3b\$56\$76\$00\
2788
+ \$ff\$2f\$00";;
2789
+ var midi_3notesE5D5A5=
2790
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2791
+ \$72\$6b\$00\$00\$00\$3e\$00\$ff\$03\$0c\$33\$6e\$6f\$74\$65\$73\
2792
+ \$45\$35\$44\$35\$41\$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\
2793
+ \$04\$04\$02\$18\$08\$00\$c0\$09\$0b\$90\$58\$40\$36\$56\$58\$6b\
2794
+ \$80\$58\$52\$54\$90\$5d\$48\$81\$72\$80\$56\$4d\$81\$5c\$5d\$76\
2795
+ \$00\$ff\$2f\$00";;
2796
+ var midi_3notesF5C6G5=
2797
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2798
+ \$72\$6b\$00\$00\$00\$3c\$00\$ff\$03\$0c\$33\$6e\$6f\$74\$65\$73\
2799
+ \$46\$35\$43\$36\$47\$35\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\
2800
+ \$04\$04\$02\$18\$08\$00\$c0\$09\$04\$90\$59\$5a\$41\$60\$62\$0a\
2801
+ \$80\$59\$78\$2f\$90\$5b\$52\$0d\$80\$60\$54\$4a\$5b\$6c\$00\$ff\
2802
+ \$2f\$00";;
2803
+
2804
+ var midi_startrecord=
2805
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$03\$c0\$4d\$54\
2806
+ \$72\$6b\$00\$00\$00\$9f\$00\$c0\$11\$00\$b0\$0a\$40\$00\$b0\$65\
2807
+ \$00\$00\$b0\$64\$02\$00\$b0\$06\$40\$00\$b0\$65\$00\$00\$b0\$64\
2808
+ \$01\$00\$b0\$06\$40\$00\$b0\$26\$00\$00\$b0\$65\$00\$00\$b0\$64\
2809
+ \$00\$00\$b0\$06\$02\$00\$b0\$26\$00\$00\$ff\$51\$03\$09\$27\$c0\
2810
+ \$1e\$90\$4f\$7f\$00\$b0\$0b\$7f\$00\$e0\$00\$3f\$1e\$b0\$0b\$7a\
2811
+ \$00\$e0\$00\$40\$1e\$b0\$0b\$52\$1e\$b0\$0b\$69\$3c\$80\$4f\$7b\
2812
+ \$00\$90\$51\$7b\$00\$b0\$0b\$7f\$00\$e0\$00\$3b\$1e\$b0\$0b\$65\
2813
+ \$00\$e0\$00\$3c\$1e\$b0\$0b\$5d\$00\$e0\$00\$40\$1e\$e0\$00\$3d\
2814
+ \$3c\$80\$51\$5b\$1e\$b0\$0b\$7f\$00\$e0\$00\$3e\$1e\$b0\$0b\$5e\
2815
+ \$00\$e0\$00\$40\$1e\$b0\$0b\$34\$00\$90\$54\$7f\$83\$60\$80\$54\
2816
+ \$00\$00\$ff\$2f\$00";;
2817
+ var midi_endrecord=
2818
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
2819
+ \$72\$6b\$00\$00\$00\$61\$00\$ff\$03\$07\$52\$65\$63\$46\$69\$6e\
2820
+ \$31\$00\$ff\$51\$03\$10\$59\$42\$00\$ff\$58\$04\$04\$02\$18\$08\
2821
+ \$00\$c0\$71\$00\$90\$48\$7f\$1a\$80\$48\$40\$04\$90\$4a\$72\$1a\
2822
+ \$80\$4a\$40\$04\$90\$4d\$7b\$1a\$80\$4d\$40\$04\$90\$4f\$7f\$1a\
2823
+ \$80\$4f\$40\$04\$90\$51\$76\$1a\$80\$51\$40\$04\$90\$53\$7b\$1a\
2824
+ \$80\$53\$40\$04\$90\$54\$7f\$1a\$80\$54\$40\$22\$91\$24\$01\$54\
2825
+ \$81\$24\$40\$00\$ff\$2f\$00";;
2826
+
2827
+
2828
+ var mp3_startrecord=
2829
+ "\$49\$44\$33\$03\$00\$00\$00\$00\$00\$00\$ff\$f3\$66\$c0\$00\$00\
2830
+ \$00\$02\$58\$01\$40\$00\$00\$16\$83\$41\$61\$80\$07\$fe\$b1\$30\
2831
+ \$32\$63\$6c\$84\$ff\$fe\$9b\$81\$51\$83\$99\$ff\$ff\$0c\$b4\$cc\
2832
+ \$c9\$41\$7b\$2d\$c0\$28\$60\$19\$06\$80\$70\$8d\$7d\$48\$20\$07\
2833
+ \$81\$10\$18\$d5\$20\$04\$ec\$00\$8c\$fd\$66\$e9\$98\$1a\$01\$9f\
2834
+ \$26\$25\$c0\$14\$9c\$2f\$98\$03\$0f\$fc\$d0\$cc\$dc\$dd\$08\$2c\
2835
+ \$90\$21\$18\$06\$b0\$a0\$1e\$79\$60\$6d\$d6\$81\$9d\$03\$fd\$9e\
2836
+ \$d6\$82\$88\$01\$b6\$62\$de\$07\$fb\$00\$1c\$47\$00\$6b\$03\$01\
2837
+ \$91\$4b\$ff\$5a\$6e\$ab\$3b\$20\$06\$bd\$08\$2c\$2c\$01\$94\$00\
2838
+ \$28\$b0\$1a\$0e\$06\$b0\$20\$06\$87\$02\$40\$ff\$f3\$66\$c0\$84\
2839
+ \$3e\$64\$2a\$7a\$21\$9b\$a0\$00\$c0\$cb\$10\$ff\$f5\$a6\$9a\$ad\
2840
+ \$be\$c0\$63\$08\$00\$12\$40\$35\$af\$c0\$e8\$c9\$03\$56\$0c\$0d\
2841
+ \$31\$c0\$32\$c4\$80\$38\$c0\$19\$11\$60\$61\$c1\$85\$8f\$80\$30\
2842
+ \$8f\$ff\$f5\$bb\$aa\$df\$6f\$17\$08\$f6\$06\$94\$88\$36\$3e\$1b\
2843
+ \$78\$05\$0c\$14\$a1\$04\$0b\$2b\$25\$ce\$81\$ae\$28\$24\$a5\$70\
2844
+ \$b9\$c0\$c0\$1f\$ff\$ff\$ff\$7f\$ff\$c3\$a4\$03\$0e\$0c\$0c\$08\
2845
+ \$30\$1a\$06\$06\$80\$90\$0a\$00\$10\$00\$0c\$c9\$b0\$33\$a4\$c0\
2846
+ \$b0\$30\$6d\$40\$6c\$80\$c1\$00\$34\$0d\$02\$2e\$5f\$70\$00\$6a\
2847
+ \$01\$6a\$23\$6f\$fe\$ac\$8f\$f9\$98\$4f\$ff\$81\$ff\$f3\$66\$c0\
2848
+ \$0e\$1d\$4a\$9b\$06\$7f\$c1\$a0\$00\$18\$7e\$c0\$61\$c1\$81\$be\
2849
+ \$30\$28\$12\$aa\$53\$15\$bb\$cd\$52\$06\$dc\$13\$24\$ab\$35\$28\
2850
+ \$97\$4d\$56\$62\$89\$aa\$57\$30\$1c\$e3\$64\$92\$49\$96\$8a\$28\
2851
+ \$b2\$4a\$33\$3e\$74\$d5\$03\$22\$f4\$88\$93\$a4\$44\$8a\$97\$59\
2852
+ \$12\$88\$b9\$cc\$4d\$4c\$8d\$9d\$03\$62\$91\$06\$36\$75\$22\$2b\
2853
+ \$53\$1d\$66\$a3\$a4\$70\$9a\$ae\$a7\$55\$bf\$f4\$46\$74\$bc\$92\
2854
+ \$49\$25\$d1\$fa\$df\$ff\$eb\$41\$27\$5a\$06\$ff\$ff\$2b\$ff\$f5\
2855
+ \$80\$b8\$83\$56\$e0\$00\$44\$60\$c6\$3b\$45\$c6\$ab\$cc\$96\$7a\
2856
+ \$c3\$58\$de\$26\$fe\$2d\$b8\$52\$63\$ef\$63\$a1\$24\$ff\$f3\$66\
2857
+ \$c0\$1c\$18\$4b\$7a\$ce\$ec\$7c\$d4\$d8\$80\$ac\$43\$94\$5f\$e8\
2858
+ \$a2\$80\$5f\$e2\$b5\$9b\$fd\$4d\$29\$08\$54\$d9\$05\$37\$f3\$23\
2859
+ \$f5\$b2\$92\$73\$86\$a6\$44\$55\$47\$19\$82\$81\$4a\$7d\$fd\$85\
2860
+ \$a1\$f7\$88\$e2\$d9\$df\$4f\$fe\$75\$d7\$e4\$63\$8f\$ff\$ff\$fe\
2861
+ \$84\$d6\$ff\$ff\$fe\$83\$e7\$ff\$ff\$ff\$c4\$91\$37\$ff\$c8\$80\
2862
+ \$a5\$54\$67\$80\$00\$00\$cc\$26\$49\$01\$81\$40\$83\$3b\$db\$5d\
2863
+ \$34\$4e\$3d\$ee\$b3\$13\$57\$55\$66\$c6\$28\$1d\$14\$08\$0b\$dc\
2864
+ \$04\$53\$42\$d8\$17\$52\$f6\$94\$48\$80\$a9\$3f\$fe\$a2\$f2\$44\
2865
+ \$90\$29\$c2\$f8\$58\$39\$a2\$1f\$a9\$26\$ea\$52\$6a\$48\$ff\$f3\
2866
+ \$66\$c0\$3e\$18\$9a\$2a\$b7\$04\$5d\$1a\$b4\$9a\$a7\$ac\$ba\$81\
2867
+ \$2c\$75\$77\$e8\$f8\$fa\$4a\$f5\$92\$21\$c2\$53\$fd\$2f\$ff\$ea\
2868
+ \$e3\$b4\$71\$3f\$ff\$d8\$a2\$bf\$f9\$52\$3f\$fe\$b3\$bf\$fd\$40\
2869
+ \$73\$44\$78\$80\$00\$01\$93\$98\$42\$0e\$6e\$bf\$b7\$3c\$e3\$5d\
2870
+ \$4d\$38\$60\$89\$c9\$48\$83\$13\$29\$11\$60\$f8\$40\$34\$2c\$06\
2871
+ \$4f\$74\$01\$a6\$02\$c0\$61\$80\$00\$c7\$99\$2e\$ce\$a5\$13\$41\
2872
+ \$8c\$8b\$5d\$1f\$d7\$93\$22\$95\$22\$a4\$44\$5b\$c0\$6c\$1d\$ea\
2873
+ \$43\$ea\$5a\$15\$2c\$b6\$69\$62\$8b\$2f\$ac\$ba\$6a\$64\$6e\$64\
2874
+ \$9e\$82\$1a\$8a\$c4\$db\$e8\$92\$a2\$3b\$10\$e6\$57\$ff\$ff\$ff\
2875
+ \$f3\$66\$c0\$5f\$19\$f2\$2e\$9f\$00\$5d\$60\$b4\$a6\$d9\$88\$62\
2876
+ \$93\$e7\$ff\$f8\$90\$96\$98\$8a\$90\$00\$04\$13\$78\$e2\$2d\$c6\
2877
+ \$94\$d1\$62\$e1\$82\$36\$b3\$ac\$6e\$4b\$5d\$df\$7f\$fb\$bf\$c7\
2878
+ \$19\$53\$58\$30\$32\$a3\$4f\$2e\$18\$83\$36\$b4\$53\$25\$01\$70\
2879
+ \$38\$ce\$eb\$63\$94\$dc\$38\$e6\$53\$f3\$0e\$ff\$ff\$ff\$ff\$7d\
2880
+ \$92\$49\$33\$51\$25\$24\$84\$98\$5e\$18\$73\$e5\$c6\$7f\$74\$d6\
2881
+ \$cc\$c7\$51\$ab\$ea\$7a\$92\$9f\$a6\$82\$06\$2b\$43\$5a\$24\$80\
2882
+ \$48\$c9\$77\$ff\$ff\$ff\$50\$54\$87\$21\$df\$fe\$54\$b9\$bb\$9c\
2883
+ \$c0\$00\$04\$11\$66\$be\$9c\$56\$3c\$66\$f1\$5f\$ea\$d7\$f6\$89\
2884
+ \$ff\$f3\$66\$c0\$7b\$19\$f2\$2e\$a7\$00\$7e\$da\$b4\$1a\$f5\$b2\
2885
+ \$cf\$9f\$ff\$ff\$fa\$7f\$9d\$b6\$04\$2a\$14\$d0\$17\$35\$b4\$8c\
2886
+ \$20\$b0\$c2\$8d\$a3\$b3\$7e\$c6\$9e\$25\$c6\$1c\$70\$cd\$06\$31\
2887
+ \$2a\$cd\$8a\$90\$e4\$e5\$fc\$79\$6d\$5e\$ee\$ff\$f6\$cd\$38\$d0\
2888
+ \$5c\$00\$c0\$04\$0e\$c3\$02\$5c\$c3\$19\$68\$ba\$2b\$73\$ee\$e6\
2889
+ \$29\$e7\$9e\$7a\$22\$38\$e9\$73\$75\$53\$98\$03\$8c\$cf\$14\$10\
2890
+ \$4f\$ff\$fe\$a0\$36\$82\$b1\$b8\$97\$48\$8b\$b0\$00\$06\$91\$4f\
2891
+ \$30\$8d\$e6\$5f\$fe\$64\$5d\$38\$44\$d7\$9e\$94\$c6\$e7\$37\$ff\
2892
+ \$ff\$ff\$f5\$72\$8c\$dc\$7e\$d9\$a1\$83\$8a\$15\$80\$3a\$ea\$6a\
2893
+ \$ed\$ff\$f3\$66\$c0\$97\$1b\$6a\$3e\$ab\$00\$7e\$8e\$b4\$2d\$76\
2894
+ \$94\$a1\$e8\$aa\$82\$c9\$38\$62\$63\$46\$12\$28\$6a\$70\$46\$8e\
2895
+ \$da\$64\$0c\$c6\$bc\$8c\$02\$50\$62\$76\$d8\$64\$ea\$2f\$a2\$9a\
2896
+ \$d3\$8e\$72\$15\$25\$15\$4a\$11\$b9\$9f\$ea\$61\$3b\$51\$48\$47\
2897
+ \$a5\$05\$a1\$e9\$09\$31\$84\$af\$d1\$d4\$84\$dd\$47\$a1\$24\$45\
2898
+ \$a2\$ff\$ff\$e7\$51\$c2\$72\$40\$75\$76\$69\$90\$00\$04\$60\$a9\
2899
+ \$14\$11\$ad\$c8\$ea\$22\$61\$6d\$3a\$68\$ed\$a7\$73\$f8\$63\$ff\
2900
+ \$ff\$ff\$72\$ac\$a6\$55\$02\$3e\$ab\$04\$e4\$af\$66\$c5\$49\$4d\
2901
+ \$01\$bb\$31\$56\$94\$ed\$30\$b6\$40\$8c\$4f\$c0\$c0\$59\$96\$13\
2902
+ \$98\$41\$ff\$f3\$66\$c0\$ad\$1c\$92\$3e\$9f\$00\$7e\$d4\$b4\$79\
2903
+ \$b5\$4e\$98\$d3\$b1\$b0\$8b\$87\$07\$a8\$30\$a6\$81\$be\$04\$99\
2904
+ \$41\$1c\$fb\$24\$b4\$14\$8d\$34\$92\$44\$87\$09\$b8\$82\$95\$d9\
2905
+ \$ff\$69\$1a\$93\$7f\$5a\$27\$4c\$9d\$6a\$a0\$df\$a2\$b1\$d2\$33\
2906
+ \$1a\$6f\$ff\$ff\$5a\$46\$c3\$4d\$40\$f6\$db\$e1\$40\$01\$f1\$0e\
2907
+ \$8a\$89\$b1\$26\$0c\$88\$98\$bc\$8f\$7c\$2e\$70\$94\$bf\$85\$65\
2908
+ \$4e\$74\$81\$9a\$1c\$27\$8d\$8b\$a3\$9a\$66\$70\$77\$13\$23\$a4\
2909
+ \$d4\$4a\$22\$95\$24\$88\$30\$84\$63\$32\$2e\$21\$08\$40\$58\$68\
2910
+ \$1a\$02\$20\$60\$12\$80\$11\$c0\$24\$58\$04\$39\$04\$88\$81\$85\
2911
+ \$88\$06\$90\$ff\$f3\$66\$c0\$be\$1c\$da\$4a\$93\$00\$66\$e2\$b4\
2912
+ \$20\$72\$85\$a2\$60\$8a\$1a\$37\$f4\$52\$91\$c2\$e6\$1c\$4c\$99\
2913
+ \$06\$1a\$0b\$f6\$59\$75\$16\$4f\$fa\$27\$ba\$5a\$2f\$e9\$51\$38\
2914
+ \$6c\$99\$44\$ac\$87\$ff\$fd\$68\$98\$a0\$3a\$4a\$e9\$80\$56\$08\
2915
+ \$70\$88\$08\$80\$00\$00\$00\$00\$04\$46\$2c\$26\$18\$12\$07\$a7\
2916
+ \$b2\$58\$62\$a5\$4e\$2b\$65\$5c\$aa\$6c\$89\$5a\$a6\$6a\$56\$20\
2917
+ \$63\$2e\$32\$7c\$b2\$a2\$54\$d1\$12\$a9\$4c\$bd\$4a\$b2\$70\$4f\
2918
+ \$84\$b8\$74\$45\$13\$eb\$28\$9b\$90\$64\$4c\$52\$78\$0b\$05\$03\
2919
+ \$58\$d0\$0e\$31\$70\$b9\$92\$4a\$20\$80\$00\$9c\$03\$66\$4c\$36\
2920
+ \$21\$a6\$6e\$3e\$ff\$f3\$66\$c0\$ce\$1d\$ca\$56\$8a\$61\$49\$a0\
2921
+ \$00\$84\$a4\$23\$14\$51\$45\$69\$13\$44\$d1\$bd\$65\$c5\$32\$8a\
2922
+ \$c6\$86\$6a\$49\$2a\$28\$cc\$9e\$9e\$7f\$28\$bd\$6e\$83\$6b\$45\
2923
+ \$49\$25\$52\$52\$c9\$08\$8f\$d4\$34\$b4\$0b\$ac\$ee\$d9\$80\$f4\
2924
+ \$c9\$d5\$fa\$96\$8f\$ff\$fd\$34\$d9\$6b\$41\$06\$7d\$34\$dd\$0d\
2925
+ \$15\$24\$97\$a2\$8f\$ff\$ff\$ff\$98\$17\$0d\$09\$f3\$74\$d6\$5f\
2926
+ \$37\$22\$85\$c6\$02\$19\$cb\$65\$40\$0c\$04\$04\$2a\$aa\$c6\$5f\
2927
+ \$db\$aa\$a7\$55\$57\$8c\$db\$35\$ff\$0c\$b5\$0c\$2c\$74\$87\$20\
2928
+ \$d4\$e2\$45\$69\$9a\$43\$90\$6a\$74\$c0\$2a\$00\$60\$16\$1e\$0e\
2929
+ \$80\$04\$17\$07\$c7\$ff\$f3\$66\$c0\$da\$2b\$53\$be\$83\$07\$8f\
2930
+ \$a0\$00\$35\$f0\$51\$d0\$1d\$07\$c7\$5a\$d3\$0b\$2e\$cc\$d7\$22\
2931
+ \$a2\$b6\$48\$aa\$c3\$5a\$8a\$b6\$aa\$bc\$33\$53\$33\$6b\$50\$d5\
2932
+ \$b7\$ff\$ff\$ff\$ff\$ff\$ff\$f0\$cd\$2a\$2a\$05\$05\$4b\$3c\$37\
2933
+ \$c1\$a2\$c1\$df\$c1\$55\$86\$bf\$06\$94\$1d\$e4\$b1\$2f\$2c\$78\
2934
+ \$44\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2935
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2936
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2937
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2938
+ \$00\$00\$00\$00\$00\$00\$ff\$f3\$66\$c0\$b0\$1a\$ba\$65\$e4\$01\
2939
+ \$c3\$40\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2940
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2941
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2942
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2943
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2944
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2945
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2946
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2947
+ \$00\$00\$00\$00\$00\$00\$00\$ff\$f3\$66\$c0\$c9\$00\$00\$02\$58\
2948
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2949
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2950
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2951
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2952
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2953
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2954
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2955
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2956
+ \$00\$00\$00\$00\$00\$00\$00\$00\$ff\$f3\$66\$c0\$ff\$00\$00\$02\
2957
+ \$58\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2958
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2959
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2960
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2961
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2962
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2963
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2964
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2965
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$ff\$f3\$66\$c0\$ff\$00\$00\
2966
+ \$02\$58\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2967
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2968
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2969
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2970
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2971
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2972
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2973
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2974
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$ff\$f3\$66\$c0\$ff\$00\
2975
+ \$00\$02\$58\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2976
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2977
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2978
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2979
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2980
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2981
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2982
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2983
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$ff\$f3\$66\$c0\$ff\
2984
+ \$00\$00\$02\$58\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2985
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2986
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2987
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2988
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2989
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2990
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2991
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2992
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$ff\$f3\$66\$c0\
2993
+ \$ff\$00\$00\$02\$58\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2994
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2995
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2996
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2997
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2998
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
2999
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3000
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3001
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$ff\$f3\$66\
3002
+ \$c0\$ff\$00\$00\$02\$58\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3003
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3004
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3005
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3006
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3007
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3008
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3009
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3010
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$ff\$f3\
3011
+ \$66\$c0\$ff\$00\$00\$02\$58\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3012
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3013
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3014
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3015
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3016
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3017
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3018
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\
3019
+ \$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$00\$ff\
3020
+ \$f3\$66\$c0\$ff\$00\$00\$02\$58\$00\$00\$00\$00\$00\$00\$00\$00\
3021
+ \$00\$00\$00\$00\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\
3022
+ \$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\
3023
+ \$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\
3024
+ \$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\
3025
+ \$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\
3026
+ \$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\
3027
+ \$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\
3028
+ \$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\
3029
+ \$ff\$f3\$66\$c0\$ff\$00\$00\$02\$58\$00\$00\$00\$00\$00\$20\$00\
3030
+ \$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\
3031
+ \$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\
3032
+ \$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\
3033
+ \$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\
3034
+ \$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\
3035
+ \$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\
3036
+ \$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\
3037
+ \$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\$20\$00\
3038
+ \$00";;
3039
+
3040
+ var midi_RFIDok=
3041
+ "\$4d\$54\$68\$64\$00\$00\$00\$06\$00\$00\$00\$01\$01\$e0\$4d\$54\
3042
+ \$72\$6b\$00\$00\$00\$3c\$00\$ff\$03\$06\$52\$46\$49\$44\$6f\$6b\
3043
+ \$00\$ff\$51\$03\$07\$a1\$20\$00\$ff\$58\$04\$04\$02\$18\$08\$00\
3044
+ \$c9\$00\$0c\$99\$47\$79\$03\$45\$7f\$02\$52\$79\$67\$89\$47\$00\
3045
+ \$04\$45\$00\$01\$52\$00\$24\$99\$18\$01\$47\$89\$18\$00\$00\$ff\
3046
+ \$2f\$00";;
3047
+
3048
+ var midilist;;
3049
+
3050
+ fun getmidilist=
3051
+ if midilist==nil then set midilist=
3052
+ {midi_1noteA4 midi_1noteB5 midi_1noteBb4 midi_1noteC5 midi_1noteE4 midi_1noteF4
3053
+ midi_1noteF5 midi_1noteG5 midi_2notesC6C4 midi_2notesC6F5 midi_2notesD4A5
3054
+ midi_2notesD4G4 midi_2notesD5G4 midi_2notesE5A5 midi_2notesE5C6 midi_2notesE5E4
3055
+ midi_3notesA4G5G5 midi_3notesB5A5F5 midi_3notesB5D5C6 midi_3notesD4E4G4 midi_3notesE5A5C6
3056
+ midi_3notesE5C6D5 midi_3notesE5D5A5 midi_3notesF5C6G5};
3057
+ midilist;;
3058
+
3059
+ fun controlsound s=
3060
+ wavstartlocal s::nil;
3061
+ 0;;
3062
+
3063
+ var buttonlast;;
3064
+ var buttontime;;
3065
+ var buttonevent;;
3066
+ var buttonclicn;;
3067
+
3068
+ var BUTTON_CLIC=1;;
3069
+ var BUTTON_DCLIC=2;;
3070
+ var BUTTON_LCLIC=3;;
3071
+ var BUTTON_DLCLIC=4;;
3072
+ var T_DCLIC=500;;
3073
+ var T_LCLIC=1500;;
3074
+
3075
+
3076
+ fun buttonloop=
3077
+ let button2 -> b in
3078
+ if b!=buttonlast then
3079
+ (
3080
+ set buttonlast=b;
3081
+ if b then
3082
+ (
3083
+ if buttontime==nil then
3084
+ (
3085
+ set buttonclicn=1;
3086
+ set buttontime=time_ms
3087
+ )
3088
+ else
3089
+ (
3090
+ set buttonclicn=buttonclicn+1;
3091
+ set buttontime=time_ms
3092
+ )
3093
+ )
3094
+ else if buttontime!=nil then set buttontime=time_ms
3095
+ )
3096
+ else if (buttontime!=nil) then
3097
+ (
3098
+ if ((time_ms-buttontime)>=T_LCLIC) then
3099
+ (
3100
+ if buttonlast then set buttonevent=if buttonclicn==1 then BUTTON_LCLIC else BUTTON_DLCLIC;
3101
+ set buttontime=nil
3102
+ )
3103
+ else if ((time_ms-buttontime)>=T_DCLIC)&&!buttonlast then
3104
+ (
3105
+ set buttonevent=if buttonclicn==1 then BUTTON_CLIC else BUTTON_DCLIC;
3106
+ set buttontime=nil
3107
+ )
3108
+ );;
3109
+
3110
+ fun buttongetevent=
3111
+ let buttonevent -> ev in
3112
+ (
3113
+ set buttonevent=nil;
3114
+ ev
3115
+ );;
3116
+
3117
+ proto loop 0;;
3118
+ fun buttoncheckevent=
3119
+ buttonloop;
3120
+ if buttonevent!=nil then loop;
3121
+ 0;;
3122
+
3123
+ //var netMac="00904B8C540D";;
3124
+ fun _webmac key i=
3125
+ if i<strlen key then (ctoh strget key i)::_webmac key i+1;;
3126
+
3127
+ fun webmac key=strcatlist _webmac key 0;;
3128
+
3129
+ fun configurl=strcatlist confGetServerUrl::"/locate.jsp?sn="::(webmac netMac)::"&h="::(itoa HARDWARE)::nil;;
3130
+
3131
+ fun mktramenumber t= if t==MSG_IDLE then "7fffffff" else if t==MSG_ASLEEP then "7ffffffe" else itoh t;;
3132
+ fun pingurl=strcatlist pingsrv::"/vl/p4.jsp?sn="::(webmac netMac)::"&v="::(itoa FIRMWARE)::"&st=1&sd="::(itoh senddata)::
3133
+ "&tc="::(mktramenumber currenttrame)::"&h="::(itoa HARDWARE)::nil;;
3134
+
3135
+ fun recordurl mode=strcatlist pingsrv::"/vl/record.jsp?sn="::(webmac netMac)::"&v="::(itoa FIRMWARE)::"&h="::(itoa HARDWARE)::"&m="::(itoa mode)::nil;;
3136
+ fun rfidurl tag=strcatlist pingsrv::"/vl/rfid.jsp?sn="::(webmac netMac)::"&v="::(itoa FIRMWARE)::"&h="::(itoa HARDWARE)::"&t="::(webmac tag)::nil;;
3137
+
3138
+ fun runinit=
3139
+ set run=configstartRun;;
3140
+
3141
+
3142
+ fun filterconfig_word s=
3143
+ let strstr s " " 0 -> i in
3144
+ if i!=nil then [strsub s 0 i strsub s i+1 nil]
3145
+ else [s nil];;
3146
+
3147
+ fun filterconfig_line s i=
3148
+ let strstr s "\10" i-> j in
3149
+ if j!=nil then (filterconfig_word strsub s i j-i)::filterconfig_line s j+1
3150
+ else if i<strlen s then (filterconfig_word strsub s i nil)::nil;;
3151
+
3152
+ fun filterconfig s i0=
3153
+ let strreplace s "\13" "" -> s in
3154
+ filterconfig_line s i0;;
3155
+
3156
+ fun dumpconfig l=
3157
+ Secholn "##dumpconfig :";
3158
+ for l=l;l!=nil;tl l do let hd l->[key val] in
3159
+ (
3160
+ Secho key; Secho " = "; Secholn val
3161
+ );
3162
+ l;;
3163
+
3164
+ fun _configcbhttp http res=
3165
+ Secholn "config=";
3166
+ let filterconfig Secholn httpgetcontent res 0-> conf in
3167
+ (
3168
+ set pingsrv=listswitchstr conf "ping";
3169
+ set broadcasturl=listswitchstr conf "broad";
3170
+ if pingsrv!=nil && broadcasturl!=nil then set run=pingstartRun;
3171
+ 0
3172
+ );;
3173
+
3174
+ fun runconfigstart=
3175
+ if netState==RT2501_S_CONNECTED && wavrunning==0 then set run=configwaitRun httprequest "GET" Secholn configurl nil #_configcbhttp HTTP_NORMAL;
3176
+ 0;;
3177
+
3178
+ fun runconfigwait http=
3179
+ // check timeout and retry
3180
+ if (httpinactive http)>10000 then
3181
+ (
3182
+ Secholn "##timeout on configwait";
3183
+ httpabort http;
3184
+ set run=configstartRun
3185
+ );
3186
+
3187
+ 0;;
3188
+
3189
+
3190
+ fun bintoi3 s x=((strget s x)<<16)+((strget s x+1)<<8)+(strget s x+2);;
3191
+
3192
+ fun pingextract_ s i res=
3193
+ if i<strlen s then
3194
+ let (strget s i)-> code in
3195
+ if code==255 then res
3196
+ else if code>=0 && code<=10 then
3197
+ let bintoi3 s i+1 -> len in
3198
+ if len>=0 then pingextract_ s i+4+len [code strsub s i+4 len]::res;;
3199
+
3200
+ fun pingextract s=
3201
+ if (strget s 0)==0x7f then pingextract_ s 1 nil;;
3202
+
3203
+ fun srcextract s i=
3204
+ if s!=nil && i<strlen s then [strget s i strget s i+1]::srcextract s i+2;;
3205
+
3206
+
3207
+ fun rscfilterurl url=
3208
+ if 0==strstr url BROADCAST_KEYWORD 0 then strcat broadcasturl strsub url strlen BROADCAST_KEYWORD nil
3209
+ else url;;
3210
+
3211
+ fun rscfrommsg l=
3212
+ if l!=nil then let hd l->[key val] in
3213
+ if (!strcmp key "MU") || (!strcmp key "CH") then [val /*nil*/300000]::rscfrommsg tl l
3214
+ else if (!strcmp key "MC") then [val SIGNCUTSIZE]::rscfrommsg tl l
3215
+ else rscfrommsg tl l;;
3216
+
3217
+ fun msgInit msg=
3218
+ Secholn "####################msgInit";
3219
+ let atoi listswitchstr msg "ID" -> id in
3220
+ (
3221
+ Secholn itoh id;
3222
+ if id==MSG_IDLE then
3223
+ (
3224
+ if currenttrame==MSG_IDLE then
3225
+ (
3226
+ earGo 0 extleft 0;
3227
+ earGo 1 extright 0;
3228
+ waitRun time+pingdelay
3229
+ )
3230
+ else
3231
+ (
3232
+ set currenttrame=id;
3233
+ Secholn "-> idle";
3234
+ setleds 0xff00ff;
3235
+ earReset;
3236
+ idlewaitRun
3237
+ )
3238
+ )
3239
+ else if id==MSG_ASLEEP then
3240
+ (
3241
+ set currenttrame=id;
3242
+ Secholn "-> asleep";
3243
+ setleds 0xff00ff;
3244
+ earReset;
3245
+ asleepRun
3246
+ )
3247
+ else
3248
+ (
3249
+ // TODO : tester si le message est d�j� en m�moire
3250
+ set msgtoplay=msg;
3251
+ set rsctoget=rscfrommsg msg;
3252
+ set rscloaded=nil;
3253
+ msgloadstartRun
3254
+ )
3255
+ );;
3256
+
3257
+ fun _msgloadcbhttp http res size=
3258
+ if recording then
3259
+ (
3260
+ httpabort http;
3261
+ nil
3262
+ )
3263
+ else if res!=nil then
3264
+ (
3265
+ // Secholn res;
3266
+ set rsctmp=res::rsctmp;
3267
+ if size!=nil && (slistlen rsctmp)>size then
3268
+ (
3269
+ httpabort http;
3270
+ _msgloadcbhttp http nil nil
3271
+ );
3272
+ 0
3273
+ )
3274
+ else
3275
+ (
3276
+ let hd rsctoget ->[url _] in
3277
+ set rscloaded=[url tl rev rsctmp nil]::rscloaded;
3278
+ set rsctoget=tl rsctoget;
3279
+ set run=msgloadstartRun;
3280
+ 0
3281
+ );;
3282
+
3283
+ fun msgstart=
3284
+ setleds 0xff0000;
3285
+ earReset;
3286
+ set palette=tabnew 8 0xff;
3287
+ set run=msginitwaitRun;
3288
+ set currenttrame=atoi listswitchstr msgtoplay "ID";
3289
+ 0;;
3290
+
3291
+ fun runmsgloadstart=
3292
+ let hd rsctoget -> [url size] in
3293
+ if url==nil then
3294
+ (
3295
+ Secholn "Ready to run !";
3296
+ msgstart;
3297
+ 0
3298
+ )
3299
+ else if nil!=listswitchstr rscloaded url then
3300
+ (
3301
+ set rsctoget=tl rsctoget;
3302
+ runmsgloadstart
3303
+ )
3304
+ else
3305
+ (
3306
+ set rsctmp=nil;
3307
+ set run=msgloadwaitRun httprequest "GET" Secholn rscfilterurl url nil fixarg3 #_msgloadcbhttp size HTTP_STREAM;
3308
+ 0
3309
+ );;
3310
+
3311
+ fun runmsgloadwait http=
3312
+ if (httpinactive http)>10000 then
3313
+ (
3314
+ Secholn "##timeout on msgload";
3315
+ httpabort http;
3316
+ set run=msgloadstartRun
3317
+ );
3318
+ 0;;
3319
+
3320
+
3321
+ fun runmsginitwait=
3322
+ // check timeout (oreille bloqu�e)
3323
+ if earReady then
3324
+ (
3325
+ setleds 0;
3326
+ set msgtimestart=time;
3327
+ set run=msgRun 0
3328
+ );
3329
+ 0;;
3330
+
3331
+ fun _controlsend val=
3332
+ if val!=nil then set senddata=val;
3333
+ set run=pingsendwaitRun httprequest "GET" Secholn pingurl nil #_pingcbhttp HTTP_NORMAL;
3334
+ 0;;
3335
+
3336
+ fun runpingsendwait http=
3337
+ for i=1;i<4 do let osc time_ms-i*50 -> v in led i v*257;
3338
+ // check timeout and retry
3339
+ if (httpinactive http)>10000 then
3340
+ (
3341
+ Secholn "##timeout on pingsendwait";
3342
+ httpabort http;
3343
+ _controlsend nil
3344
+ );
3345
+
3346
+ 0;;
3347
+
3348
+
3349
+
3350
+
3351
+ fun msgend=
3352
+ _controlsend 2;
3353
+ 0;;
3354
+
3355
+ var recordtimestart;;
3356
+ var recordmode;;
3357
+ var recorddata;;
3358
+ var recordreq;;
3359
+ var recordretry;;
3360
+ var recordplayend;;
3361
+
3362
+ fun uploading = recordreq!=nil;;
3363
+
3364
+ fun runrecordstart=
3365
+ if !wavrunning then
3366
+ (
3367
+ led 0 0xff0000;//if time_ms&64 then 0xff0000 else 0;
3368
+ // setleds 0;
3369
+ unforcevol;
3370
+ recstart;
3371
+ set recordtimestart=time_ms;
3372
+ set run=recordRun
3373
+ );;
3374
+
3375
+ fun _controlrecord mode=
3376
+ setleds 0x00;
3377
+ wavstop;
3378
+ motorset 0 0;
3379
+ motorset 1 0;
3380
+ forcevol 64;
3381
+ wavstartlocalEx mp3_startrecord::nil 100;
3382
+ set recordmode=mode;
3383
+ set run=recordStartRun;
3384
+ 0;;
3385
+
3386
+ fun _cbrecordhttp http res=
3387
+ set recorddata=nil;
3388
+ set recordreq=nil;
3389
+ Secholn res;
3390
+ setleds 0x00;
3391
+ if recordplayend!=nil then
3392
+ (
3393
+ set recordplayend=nil;
3394
+ wavstartlocal midi_endrecord::nil
3395
+ );
3396
+ set run=waitRun time+recorddelay;
3397
+ 0;;
3398
+
3399
+ fun uploadtimeout=
3400
+ if uploading then
3401
+ (
3402
+ if recordplayend!=nil && ((recordplayend-time_ms)<0) then
3403
+ (
3404
+ set recordplayend=nil;
3405
+ wavstartlocal midi_endrecord::nil
3406
+ );
3407
+ if (httpinactive recordreq)>10000 then
3408
+ (
3409
+ Secholn "##timeout on upload";
3410
+ httpabort recordreq;
3411
+ set recordreq=nil;
3412
+ if recordretry>0 then
3413
+ (
3414
+ set recordretry=recordretry-1;
3415
+ set recordreq=httprequest "POST" Secholn recordurl recordmode recorddata #_cbrecordhttp HTTP_NORMAL;
3416
+ nil
3417
+ )
3418
+ else
3419
+ (
3420
+ set recorddata=nil;
3421
+ set run=waitRun time+1
3422
+ )
3423
+ )
3424
+ );;
3425
+
3426
+ fun runrecord=
3427
+ // led 0 if time_ms&1024 then 0xff0000 else 0;
3428
+ if !button2 || ((time_ms-recordtimestart)>8000)then
3429
+ (
3430
+ recstop;
3431
+ setleds 0x00;
3432
+ let recriff -> wavfile in
3433
+ (
3434
+ set recorddata=strcatlist wavfile;
3435
+ set recordretry=3;
3436
+ set recordplayend=time_ms+400;
3437
+ set recordreq=httprequest "POST" Secholn recordurl recordmode recorddata #_cbrecordhttp HTTP_NORMAL;
3438
+ set run=waitRun time+recorddelay
3439
+ )
3440
+ );;
3441
+
3442
+ var chordata;;
3443
+ var chorindex;;
3444
+ var chortimescale;;
3445
+ var chornexttime;;
3446
+ var chorrandom;;
3447
+ var chortaichimotor;;
3448
+
3449
+ fun msgstartchor chor i0=
3450
+ set chordata=strcatlist chor;
3451
+ set chorindex=4+1; // on saute le header et la premi�re attente
3452
+ set chortimescale=0;
3453
+ set chornexttime=time_ms;
3454
+ set run=msgchorRun i0;
3455
+ 0;;
3456
+
3457
+ fun taichistart =
3458
+ Secho "taichistart ";
3459
+ set chorrandom=((Iecholn rand&255)*6)>>8;
3460
+ set chortaichimotor={rand&1 rand&1};
3461
+ earUndetect;
3462
+ msgstartchor taichi::nil nil;
3463
+ 0;;
3464
+
3465
+ fun msgendchor i0=
3466
+ set chornexttime=nil;
3467
+ if i0==nil then
3468
+ (
3469
+ earDetect;
3470
+ set run=waitRun time+pingdelay
3471
+ )
3472
+ else set run=msgRun i0+1;
3473
+ 0;;
3474
+
3475
+
3476
+ fun setpalette p=
3477
+ Secho "############setpalette ";Iecholn p&7;
3478
+ let palettes.(p&7) -> p in
3479
+ for i=0;i<8 do let i*3 -> j in set palette.i=((p.(j))<<16)+((p.(j+1))<<8)+p.(j+2);;
3480
+
3481
+ fun setcolor i val=
3482
+ Secho "############setcolor ";Iecho i; Secho " = $";Secholn itoh val;
3483
+ set palette.i=val;;
3484
+
3485
+
3486
+ fun runmsgchor i0=
3487
+ // Secho "runmsgchor i:";Iecho chorindex; Secho " t:";Iecholn chornexttime;
3488
+ if chornexttime-time_ms<=0 then
3489
+ (
3490
+ if chorindex>=strlen chordata then msgendchor i0
3491
+ else let strget chordata chorindex -> code in
3492
+ set chorindex=chorindex+2+
3493
+ if code==CH_frame_duration then
3494
+ (
3495
+ set chortimescale=10*strget chordata chorindex+1;
3496
+ 1 //nb de param�tres
3497
+ )
3498
+ else if code==CH_set_motor then
3499
+ (
3500
+ earGo (strget chordata chorindex+1) (strget chordata chorindex+2) (strget chordata chorindex+3);
3501
+ 3
3502
+ )
3503
+ else if code==CH_set_led_color then
3504
+ (
3505
+ // Secho "set_led_color ";
3506
+ led 4-strget chordata chorindex+1 ((strget chordata chorindex+2)<<16)+((strget chordata chorindex+3)<<8)+(strget chordata chorindex+4);
3507
+ 6
3508
+ )
3509
+ else if code==CH_set_led_palette then
3510
+ (
3511
+ // Secho "set_led_palette ";
3512
+ led 4-strget chordata chorindex+1 palette.(7&strget chordata chorindex+2);
3513
+ 2
3514
+ )
3515
+ else if code==CH_randmidi then
3516
+ (
3517
+ Secholn "randmidi";
3518
+ let getmidilist -> t in
3519
+ let tablen t -> n in
3520
+ if n>0 then let t.(Iecholn ((rand&255)*n)>>8) -> music in
3521
+ wavstartlocal music::nil;
3522
+ 0
3523
+ )
3524
+ else if code==CH_avance then
3525
+ (
3526
+ Secholn "avance";
3527
+ let (strget chordata chorindex+1) -> i in
3528
+ let (strget chordata chorindex+2) -> delta in
3529
+ earGo i (earTarget i)+if chortaichimotor.i then -delta else delta chortaichimotor.i;
3530
+ 2
3531
+ )
3532
+ else if code==CH_ifne then
3533
+ (
3534
+ Secho "ifne ";Iecholn chorrandom;
3535
+ if chorrandom==(Iecholn strget chordata chorindex+1) then 3
3536
+ else 3+((strget chordata chorindex+2)<<8)+(strget chordata chorindex+3)
3537
+ )
3538
+ else if code==CH_attend then
3539
+ (
3540
+ Secholn "attend";
3541
+ if earComplete && wavrunning==0 then 0
3542
+ else -2
3543
+ )
3544
+ else
3545
+ (
3546
+ msgendchor i0;
3547
+ 0
3548
+ );
3549
+ if chornexttime!=nil then
3550
+ (
3551
+ set chornexttime=chornexttime+(strget chordata chorindex-1)*chortimescale;
3552
+ runmsgchor i0
3553
+ )
3554
+ );;
3555
+
3556
+ fun _pingcbstreaming http res lastid=
3557
+ Secholn "streaming ping";
3558
+ if !recording then
3559
+ let nil->msg in
3560
+ (
3561
+ let pingextract httpgetcontent res -> ltrame in
3562
+ (
3563
+ for l=ltrame;l!=nil;tl l do let hd l-> [code val] in
3564
+ (
3565
+ if code==10 then
3566
+ (
3567
+ uncrypt val 1 nil 0x47 47;
3568
+ set msg=dumpconfig filterconfig val 1;
3569
+ 0
3570
+ );
3571
+ 0
3572
+ )
3573
+ );
3574
+ if msg!=nil then
3575
+ let atoi listswitchstr msg "ID" -> id in
3576
+ if id!=currenttrame && currenttrame==lastid then
3577
+ (
3578
+ wavstop;
3579
+ 0
3580
+ )
3581
+ );
3582
+ 0;;
3583
+
3584
+
3585
+ var chorst_data;;
3586
+ var chorst_index;;
3587
+ var chorst_tempo;;
3588
+ var chorst_repeat;;
3589
+ var chorst_nexttime;;
3590
+
3591
+ fun dochorstream=
3592
+ if chorst_data==nil || ((chorst_index>=strlen chorst_data)&&(chorst_repeat<1)) then
3593
+ (
3594
+ Secho "Start Chor Stream ";
3595
+ set chorst_data=listnth chorstream Iecholn rand&3;
3596
+ set chorst_index=1;
3597
+ Secho "tempo "; Iecholn set chorst_tempo=160+(((rand&255)*90)>>8);
3598
+ Secho "repeat "; Iecholn set chorst_repeat=3+(((rand&255)*18)>>8);
3599
+ set chorst_nexttime=time_ms
3600
+ );
3601
+ while (chorst_index<strlen chorst_data) && time_ms-chorst_nexttime > 0 do
3602
+ (
3603
+ led strget chorst_data chorst_index
3604
+ ((strget chorst_data chorst_index+1)<<16) +
3605
+ ((strget chorst_data chorst_index+2)<<8) +
3606
+ ((strget chorst_data chorst_index+3));
3607
+ set chorst_index=chorst_index+5;
3608
+ let strget chorst_data chorst_index-1 -> delay in
3609
+ if delay!=nil then set chorst_nexttime=chorst_nexttime+delay*chorst_tempo
3610
+ );
3611
+ if (chorst_index>=strlen chorst_data) then
3612
+ (
3613
+ set chorst_index=1;
3614
+ Secho "repeat "; Iecholn set chorst_repeat=chorst_repeat-1;
3615
+ set chorst_nexttime=time_ms
3616
+ );
3617
+ 0;;
3618
+
3619
+ fun runmsgchorstreaming z=
3620
+ let z->[i0 t0 ping0] in
3621
+ if wavrunning==0 then
3622
+ (
3623
+ motorset 0 0;
3624
+ motorset 1 0;
3625
+ set run=msgRun i0+1;
3626
+ nil
3627
+ )
3628
+ else
3629
+ (
3630
+ if wav_buffering then
3631
+ (
3632
+ led 0 if time_ms&256 then 0xff00ff else 0
3633
+ )
3634
+ else dochorstream;
3635
+
3636
+ if (time-msgtimestart)>STREAMING_MOTORSTOP then
3637
+ (
3638
+ motorset 0 0;
3639
+ motorset 1 0;
3640
+ 0
3641
+ )
3642
+ else
3643
+ (
3644
+ let (osc ((time_ms*(3))>>8))>>6 -> i0 in
3645
+ motorset 0 if i0==3 then 1 else if i0==1 then (-1) else 0;
3646
+ let (osc ((time_ms*(5))>>8))>>6 -> i0 in
3647
+ motorset 1 if i0==3 then 1 else if i0==1 then (-1) else 0
3648
+ );
3649
+ if (time-ping0)>STREAMING_PING then
3650
+ (
3651
+ update z with [_ _ time];
3652
+ httprequest "GET" Secholn pingurl nil fixarg3 #_pingcbstreaming currenttrame HTTP_NORMAL
3653
+ );
3654
+ 0
3655
+ );;
3656
+
3657
+ fun runmsg i0=
3658
+ // Secho "runmsg ";Iecholn i0;
3659
+ let listnth msgtoplay i0 -> [key val] in
3660
+ if (Secholn key)==nil then
3661
+ (
3662
+ msgend;
3663
+ 0
3664
+ )
3665
+ else if (!strcmp key "MU") || (!strcmp key "MC") then
3666
+ (
3667
+ Secholn "###########Start music";
3668
+ let listswitchstr rscloaded Secholn val -> music in
3669
+ if music==nil then Secholn "###nilmusic";
3670
+ wavstartlocal listswitchstr rscloaded val;
3671
+ set run=msgRun i0+1;
3672
+ 0
3673
+ )
3674
+ else if !strcmp key "ST" then
3675
+ (
3676
+ Secholn "###########Start streaming music";
3677
+ //IPecho netdns 0 1;
3678
+ //startdnsclient;
3679
+ set chorst_data=nil;
3680
+ let rscfilterurl val -> music in wavstarthttp music;
3681
+ set run=msgchorstreamRun [i0 time time];
3682
+ 0
3683
+ )
3684
+ else if !strcmp key "MW" then
3685
+ (
3686
+ if wavrunning==0 then set run=msgRun i0+1;
3687
+ 0
3688
+ )
3689
+ else if !strcmp key "CH" then
3690
+ (
3691
+ msgstartchor listswitchstr rscloaded val i0;
3692
+ 0
3693
+ )
3694
+ else
3695
+ (
3696
+ if !strcmp key "PL" then setpalette atoi val;
3697
+ if !strcmp key "CL" then
3698
+ let atoi val -> x in setcolor (x>>24) x&0xffffff;
3699
+ set run=msgRun i0+1;
3700
+ runmsg i0+1
3701
+ );;
3702
+
3703
+ fun runasleep=
3704
+ if earReady then
3705
+ (
3706
+ setleds 0;
3707
+ earGo 0 8 0;
3708
+ earGo 1 8 0;
3709
+ set run=waitRun time+pingdelay;
3710
+ 0
3711
+ );;
3712
+
3713
+ var nexttaichi;;
3714
+
3715
+ fun dotaichinow=
3716
+ Secho "checktaichi ";
3717
+ let Iecholn infoGet TYPE_taichi -> v in
3718
+ if v then
3719
+ let if nexttaichi!=nil then time-nexttaichi>0 else 0 -> now in
3720
+ (
3721
+ if now || nexttaichi==nil then set nexttaichi=time+((v*60*((rand&127)+64))>>7);
3722
+ now
3723
+ )
3724
+ else
3725
+ (
3726
+ set nexttaichi=nil;
3727
+ 0
3728
+ );;
3729
+
3730
+ fun _pingcbhttp http res=
3731
+ Secholn "ping=";
3732
+ if !recording then
3733
+ let nil->msg in
3734
+ (
3735
+ let pingextract dump httpgetcontent res -> ltrame in
3736
+ (
3737
+ if ltrame!=nil then set senddata=0; // acquittement implicite de l'envoi de donn�es
3738
+ for l=ltrame;l!=nil;tl l do let hd l-> [code val] in
3739
+ (
3740
+ Iecho code; Secho " : ";
3741
+ if code==3 then set pingdelay=Iecholn (strget val 0)*1;
3742
+ if code==4 then
3743
+ (
3744
+ // set sources=srcextract dump strsub val 4 nil 0;
3745
+ infoUpdate strsub val 4 nil;
3746
+ let strget val 20 -> newleft in
3747
+ let strget val 21 -> newright in
3748
+ (
3749
+ if (extleft!=nil) &&((newleft!=extleft) || (newright!=extright)) then
3750
+ (
3751
+ controlsound midi_communion
3752
+ );
3753
+ set extleft=newleft;
3754
+ set extright=newright
3755
+ )
3756
+ );
3757
+ if code==10 then
3758
+ (
3759
+ uncrypt val 1 nil 0x47 47;
3760
+ set msg=dumpconfig filterconfig val 1;
3761
+ 0
3762
+ );
3763
+ if code==9 then
3764
+ (
3765
+ reboot 0x0407FE58 0x13fb6754;
3766
+ 0
3767
+ );
3768
+ 0
3769
+ )
3770
+ );
3771
+ if msg==nil then
3772
+ (
3773
+ if currenttrame==MSG_IDLE then
3774
+ (
3775
+ earGo 0 extleft 0;
3776
+ earGo 1 extright 0;
3777
+ if dotaichinow then (taichistart;nil)
3778
+ else set run=waitRun time+pingdelay
3779
+ )
3780
+ else set run=waitRun time+pingdelay
3781
+ )
3782
+ else
3783
+ set run=msgInit msg
3784
+ );
3785
+ 0;;
3786
+
3787
+ fun runpingstart=
3788
+ if netState==RT2501_S_CONNECTED then set run=pingwaitRun httprequest "GET" Secholn pingurl nil #_pingcbhttp HTTP_NORMAL;
3789
+ 0;;
3790
+
3791
+ fun runpingwait http=
3792
+ // check timeout and retry
3793
+ if (httpinactive http)>10000 then
3794
+ (
3795
+ Secholn "##timeout on pingwait";
3796
+ httpabort http;
3797
+ set run=waitRun time+pingdelay
3798
+ );
3799
+ 0;;
3800
+
3801
+ fun runwait t=
3802
+ if t-time<0 then set run=pingstartRun;
3803
+ 0;;
3804
+
3805
+
3806
+ fun runidlewait=
3807
+ // check timeout (oreille bloqu�e)
3808
+ if earReady then
3809
+ (
3810
+ earDetect;
3811
+ setleds 0;
3812
+ earGo 0 extleft 0;
3813
+ earGo 1 extright 0;
3814
+ set run=waitRun time+pingdelay
3815
+ );
3816
+ 0;;
3817
+
3818
+ fun bottomled=
3819
+ if !earDetecting then
3820
+ let (time-lasthttpevent)>LED_TIMEOUT -> offline in
3821
+ let uploading | match run with (msgloadwaitRun _-> 2)|(_->0) -> download in
3822
+ let osc time_ms>>(4-download) -> v in
3823
+ led 4 if !offline then v*0x10001 else 0xff00ff;
3824
+ 0;;
3825
+
3826
+ var lastrfid;;
3827
+
3828
+ fun _cbrfidhttp http res=
3829
+ Secholn res;
3830
+ 0;;
3831
+
3832
+ fun dumprfid l0=
3833
+ for l=l0;l!=nil;tl l do let hd l->x in Secholn webmac x;
3834
+ l0;;
3835
+
3836
+ fun controlrfid=
3837
+ // let hd dumprfid rfidGetList -> rfid in
3838
+ let rfidGet -> rfid in
3839
+ if strcmp rfid lastrfid then
3840
+ (
3841
+ set lastrfid=rfid;
3842
+ if rfid!=nil then
3843
+ (
3844
+ /* let IPecho rfidRead rfid 2 0 1 -> val in
3845
+ let netSeqAdd val 1 -> val2 in
3846
+ Iecholn rfidWrite rfid 2 val2;
3847
+ 0
3848
+ */
3849
+ controlsound midi_RFIDok;
3850
+ httprequest "GET" rfidurl rfid nil #_cbrfidhttp HTTP_NORMAL
3851
+ )
3852
+ );
3853
+ 0;;
3854
+
3855
+ fun controlplay=
3856
+ let buttongetevent -> ev in
3857
+ if ev!=nil then
3858
+ (
3859
+ Secholn "controlplay";
3860
+ wavstop;
3861
+ earStop;
3862
+ if ev==BUTTON_CLIC then (controlsound midi_abort;_controlsend 5) //pause
3863
+ else if ev==BUTTON_DCLIC then (controlsound midi_ack;_controlsend 1) //ackall
3864
+ else if ev==BUTTON_LCLIC then _controlsend 5 //pause ou record ?
3865
+ )
3866
+ ;;
3867
+
3868
+ fun controlwait=
3869
+ let buttongetevent -> ev in
3870
+ let if ev==nil then eargetevent else ev -> ev in
3871
+ if ev!=nil then
3872
+ (
3873
+ Secholn "controlwait";
3874
+ wavstop;
3875
+ earStop;
3876
+ if ev==BUTTON_CLIC then _controlsend 3 //relire
3877
+ else if ev==BUTTON_DCLIC then (controlsound midi_ack;_controlsend 1) //ackall
3878
+ else if ev==BUTTON_LCLIC then _controlrecord 0 // _controlsend 4 //back ou record
3879
+ else if ev==BUTTON_DLCLIC then _controlrecord 1 // _controlsend 4 //back ou record
3880
+ else if ev&0x8000 then (controlsound midi_acquired;_controlsend ev)
3881
+ );
3882
+ controlrfid
3883
+ ;;
3884
+
3885
+
3886
+
3887
+ var CONTROL_WAIT=1;;
3888
+ var CONTROL_PLAY=2;;
3889
+
3890
+ fun loop=
3891
+ //Secho "l";
3892
+ wifiRun;
3893
+
3894
+ if netState==RT2501_S_IDLE then
3895
+ match wifi with
3896
+ (initW -> nil)
3897
+ |(_ ->
3898
+ Secholn "######### wifi lost";
3899
+ set wifi=reconnectW;
3900
+ 0
3901
+ );
3902
+
3903
+ buttonloop;
3904
+ // buttongetevent;
3905
+ let match run with
3906
+ ( configstartRun -> earRun;bottomled;runconfigstart;0 )|
3907
+ ( configwaitRun http -> earRun;bottomled;runconfigwait http ; 0)|
3908
+ ( pingstartRun -> earRun;if currenttrame!=MSG_ASLEEP then bottomled;runpingstart;0)|
3909
+ ( pingwaitRun http -> earRun; if currenttrame!=MSG_ASLEEP then (infoRun;bottomled);runpingwait http;if currenttrame!=MSG_ASLEEP then CONTROL_WAIT)|
3910
+ ( waitRun t -> earRun;if currenttrame!=MSG_ASLEEP then (infoRun;bottomled);runwait t; if currenttrame!=MSG_ASLEEP then CONTROL_WAIT)|
3911
+ ( msgloadstartRun -> earRun;infoRun;bottomled;runmsgloadstart; CONTROL_WAIT)|
3912
+ ( msgloadwaitRun http-> earRun;infoRun;bottomled;runmsgloadwait http;CONTROL_WAIT)|
3913
+ ( msginitwaitRun -> earRun;runmsginitwait;CONTROL_PLAY)|
3914
+ ( msgRun i-> earRun;runmsg i;CONTROL_PLAY)|
3915
+ ( msgchorRun i-> earRun;runmsgchor i;CONTROL_PLAY)|
3916
+ ( msgchorstreamRun i->runmsgchorstreaming i;CONTROL_PLAY)|
3917
+ ( idlewaitRun -> earRun;runidlewait;CONTROL_WAIT)|
3918
+ ( pingsendwaitRun http->bottomled;runpingsendwait http;0)|
3919
+ ( recordRun -> runrecord; 0)|
3920
+ ( asleepRun ->earRun;runasleep;0) |
3921
+ ( recordStartRun -> runrecordstart; 0) |
3922
+ (_->0) -> keymanager in
3923
+ if keymanager==CONTROL_WAIT then controlwait
3924
+ else if keymanager==CONTROL_PLAY then controlplay
3925
+ else buttongetevent;
3926
+ uploadtimeout;
3927
+
3928
+
3929
+ // Iecholn netRssi;
3930
+
3931
+ // Secholn ":loop";
3932
+
3933
+ // rfidtest;
3934
+ wavtime;
3935
+
3936
+
3937
+ updatevol;
3938
+ 0;;
3939
+
3940
+ fun main=
3941
+ MACecho netMac 0 1;
3942
+ set master=0;
3943
+ Secholn ":started";
3944
+ confInit;
3945
+ wifiInit 0;
3946
+ loopcb #loop;
3947
+ earInit;
3948
+ infoInit;
3949
+ netstart;
3950
+ startdnsclient;
3951
+ Secholn ":done";
3952
+ srand time_ms;
3953
+ updatevol;
3954
+ // wavstartlocal midi_endrecord::nil;
3955
+ dumpscan wifiscans;
3956
+ runinit;
3957
+ 0;;
3958
+
3959
+ }