54 ); |
54 ); |
55 |
55 |
56 |
56 |
57 if (isset($_POST['update'])) { |
57 if (isset($_POST['update'])) { |
58 |
58 |
|
59 $cmd = "DEVICE PUT " . $_POST['uuid'] . "\r\n"; |
|
60 $cmd .= "TYPE," . $_POST['type'] . "\r\n"; |
|
61 $cmd .= "DIRECTION," . $_POST['direction'] . "\r\n"; |
|
62 $cmd .= "VALUE," . $_POST['value'] . "\r\n"; // Only for outputs |
|
63 $cmd .= "OFFSET," . $_POST['offset'] . "\r\n"; // Only analog |
|
64 $cmd .= "PRESENT," . $_POST['present'] . "\r\n"; |
|
65 $cmd .= "ADDRESS," . $_POST['address'] . "\r\n"; // Not for auto detected |
|
66 $cmd .= "SUBDEVICE," . $_POST['subdevice'] . "\r\n"; // Not for auto detected |
|
67 $cmd .= "GPIOPIN," . $_POST['gpiopin'] . "\r\n"; |
|
68 $cmd .= "DESCRIPTION," . $_POST['description'] . "\r\n"; |
|
69 $cmd .= "COMMENT," . $_POST['comment'] . "\r\n"; |
|
70 $cmd .= "."; |
|
71 $answer = send_cmd($cmd); |
|
72 $arr = explode("\r\n", $answer); |
|
73 if (! startsWith($arr[0], "219")) { |
|
74 $response['error'] = true; |
|
75 $response['msg'] = $arr[0]; |
|
76 } |
|
77 exit(json_encode($response)); |
|
78 |
59 } else if (isset($_POST['add'])) { |
79 } else if (isset($_POST['add'])) { |
60 |
80 |
61 $answer = send_cmd("DEVICE ADD " . $_POST['type']); |
81 $answer = send_cmd("DEVICE ADD " . $_POST['type']); |
62 $arr = explode("\r\n", $answer); |
82 $arr = explode("\r\n", $answer); |
63 if (! startsWith($arr[0], "211")) { |
83 if (! startsWith($arr[0], "211")) { |