30 { |
30 { |
31 global $my_style; |
31 global $my_style; |
32 |
32 |
33 $outstr = ''; |
33 $outstr = ''; |
34 $air_state = $beer_state = 1; |
34 $air_state = $beer_state = 1; |
35 |
35 $answer = send_cmd("UNIT GET ".$unit); |
36 $sock = open_socket(); |
|
37 if ($sock == false) { |
|
38 return ''; |
|
39 } |
|
40 |
|
41 socket_write($sock, "UNIT GET ".$unit, 4096); |
|
42 $answer = ""; |
|
43 while (1) { |
|
44 $line = socket_read($sock, 4096); |
|
45 if ($line === '') |
|
46 break; |
|
47 $answer .= $line; |
|
48 } |
|
49 socket_close($sock); |
|
50 $arr = explode("\r\n", $answer); |
36 $arr = explode("\r\n", $answer); |
51 |
37 |
52 if (startsWith($arr[0], "213")) { |
38 if (startsWith($arr[0], "213")) { |
53 |
39 |
54 $set_temperature = "NA"; |
40 $set_temperature = "NA"; |
233 } |
219 } |
234 if ($mode == "PROFILE") { |
220 if ($mode == "PROFILE") { |
235 /* |
221 /* |
236 * First, load a list with available profiles. |
222 * First, load a list with available profiles. |
237 */ |
223 */ |
238 $sock = open_socket(); |
224 $answer = send_cmd("PROFILE LIST"); |
239 if ($sock == true) { |
225 $reply = explode("\r\n", $answer); |
240 socket_write($sock, "PROFILE LIST", 4096); |
|
241 $answer = ""; |
|
242 while (1) { |
|
243 $line = socket_read($sock, 4096); |
|
244 if ($line === '') |
|
245 break; |
|
246 $answer .= $line; |
|
247 } |
|
248 socket_close($sock); |
|
249 $reply = explode("\r\n", $answer); |
|
250 } |
|
251 |
226 |
252 /* |
227 /* |
253 * Show loaded profile. |
228 * Show loaded profile. |
254 */ |
229 */ |
255 if ($profile == "(null)") { |
230 if ($profile == "(null)") { |
377 |
352 |
378 function liveview() |
353 function liveview() |
379 { |
354 { |
380 $outstr = PHP_EOL; |
355 $outstr = PHP_EOL; |
381 |
356 |
382 $sock = open_socket(); |
357 $answer = send_cmd("LIST"); |
383 if ($sock !== false) { |
358 if (strlen($answer)) { |
384 socket_write($sock, "LIST", 4096); |
|
385 |
|
386 /* |
|
387 * Multiple reads until the remote closed the connection |
|
388 */ |
|
389 $answer = ""; |
|
390 while (1) { |
|
391 $line = socket_read($sock, 4096); |
|
392 if ($line === '') |
|
393 break; |
|
394 $answer .= $line; |
|
395 } |
|
396 socket_close($sock); |
|
397 $arr = explode("\r\n", $answer); |
359 $arr = explode("\r\n", $answer); |
398 |
360 |
399 $outstr .= ' <div id="jqxTabs">'.PHP_EOL; |
361 $outstr .= ' <div id="jqxTabs">'.PHP_EOL; |
400 $outstr .= ' <ul>'.PHP_EOL; |
362 $outstr .= ' <ul>'.PHP_EOL; |
401 if (startsWith($arr[0], "212")) { |
363 if (startsWith($arr[0], "212")) { |