www-thermferm/devices.php

changeset 196
4d7a96c5d1ff
parent 174
244de612c572
child 209
c5b1dfd83e81
equal deleted inserted replaced
195:b34a1b2421fb 196:4d7a96c5d1ff
21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *****************************************************************************/ 22 *****************************************************************************/
23 23
24 require_once('utilities.php'); 24 require_once('utilities.php');
25 25
26
27 $sock = open_socket();
28 if ($sock == false) {
29 echo "";
30 return;
31 }
32
33 socket_write($sock, "DEVICE LIST", 4096);
34 $answer = "";
35 while (1) {
36 $line = socket_read($sock, 4096);
37 if ($line === '')
38 break;
39 $answer .= $line;
40 }
41 socket_close($sock);
42
43 /* 26 /*
44 * $arr contains the complete reply of the LIST BUS command 27 * $arr contains the complete reply of the LIST BUS command
45 */ 28 */
29 $answer = send_cmd("DEVICE LIST");
46 $arr = explode("\r\n", $answer); 30 $arr = explode("\r\n", $answer);
47 31
48 32
49 if (isset($_GET['action'])) { 33 if (isset($_GET['action'])) {
50 switch ($_GET['action']) { 34 switch ($_GET['action']) {
122 function device_update() { 106 function device_update() {
123 /* 107 /*
124 * Build the update command 108 * Build the update command
125 */ 109 */
126 if ($_POST['key'] == 'Delete') { 110 if ($_POST['key'] == 'Delete') {
127 $sock = open_socket(); 111 send_cmd("DEVICE DEL ".$_POST['UUID']);
128 if ($sock != false) {
129 socket_write($sock, "DEVICE DEL ".$_POST['UUID'], 4096);
130 /* Absorb response */
131 while (1) {
132 $line = socket_read($sock, 4096);
133 if ($line === '')
134 break;
135 }
136 socket_close($sock);
137 }
138 } 112 }
139 113
140 if ($_POST['key'] == 'Save') { 114 if ($_POST['key'] == 'Save') {
141 $sock = open_socket(); 115 $sock = open_socket();
142 if ($sock != false) { 116 if ($sock != false) {
308 * @param string $heading Page heading title. 282 * @param string $heading Page heading title.
309 * @Param string $error_message Blank or previous error. 283 * @Param string $error_message Blank or previous error.
310 */ 284 */
311 function edit_screen($UUID, $command, $heading, $error_message) { 285 function edit_screen($UUID, $command, $heading, $error_message) {
312 286
313 $sock = open_socket(); 287 $answer = send_cmd("DEVICE GET ".$UUID);
314 if ($sock == false) {
315 load('devices.php');
316 }
317
318 socket_write($sock, "DEVICE GET ".$UUID, 4096);
319 $answer = "";
320 while (1) {
321 $line = socket_read($sock, 4096);
322 if ($line === '')
323 break;
324 $answer .= $line;
325 }
326 socket_close($sock);
327 $reply = explode("\r\n", $answer); 288 $reply = explode("\r\n", $answer);
328 289
329 $outstr = build_header($heading); 290 $outstr = build_header($heading);
330 $outstr .= ' <div id="errors">'.PHP_EOL; 291 $outstr .= ' <div id="errors">'.PHP_EOL;
331 $outstr .= ' '.$error_message.PHP_EOL; 292 $outstr .= ' '.$error_message.PHP_EOL;

mercurial