1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @copyright Copyright (C) 2020 Elphel, Inc.
* SPDX-License-Identifier: GPL-3.0-or-later
*
* @author Oleg Dzhimiev <oleg@elphel.com>
* @brief Access info or perform actions using GET requests
*/
include "include/elphel_functions_include.php";
$cmd = "donothing";
if (isset($_GET['cmd']))
$cmd = $_GET['cmd'];
else if (isset($argv[1]))
$cmd = $argv[1];
// allow CORS
header('Access-Control-Allow-Origin: *');
switch($cmd){
case "sensors":
print(cmd_sensors());
break;
default:
print("OK");
}
function cmd_sensors(){
$p0 = 2323;
$sensors = get_sensors();
$res = "\t<camera ip='".$_SERVER['SERVER_ADDR']."'>\n";
foreach($sensors as $i => $sensor){
$p = $p0+$i;
$res .= "\t\t<port index='$i' port='$p'>$sensor</port>\n";
}
$res .= "\t</camera>\n";
$xml = "<?xml version='1.0' standalone='yes'?>\n";
$xml .= "<Document>\n";
$xml .= $res;
$xml .= "</Document>\n";
return $xml;
}
?>