Sat, 14 Nov 2015 17:00:37 +0100
Fixed compiling on a raspberry
207 | 1 | <?php |
2 | /***************************************************************************** | |
3 | * Copyright (C) 2014 | |
4 | * | |
5 | * Michiel Broek <mbroek at mbse dot eu> | |
6 | * | |
7 | * This file is part of ThermFerm | |
8 | * | |
9 | * This is free software; you can redistribute it and/or modify it | |
10 | * under the terms of the GNU General Public License as published by the | |
11 | * Free Software Foundation; either version 2, or (at your option) any | |
12 | * later version. | |
13 | * | |
14 | * ThermFerm is distributed in the hope that it will be useful, but | |
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with ThermFerm; see the file COPYING. If not, write to the Free | |
21 | * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
22 | *****************************************************************************/ | |
23 | ||
24 | require_once('utilities.php'); | |
25 | ||
26 | ||
27 | $answer = send_cmd('GLOBAL GET'); | |
28 | $arr = explode("\r\n", $answer); | |
29 | ||
30 | $temp_value = "NA"; | |
31 | $temp_state = "NA"; | |
32 | $hum_value = "NA"; | |
33 | $hum_state = "NA"; | |
34 | ||
35 | if (startsWith($arr[0], "213")) { | |
36 | $j = 1; | |
37 | while (1) { | |
38 | if (strcmp($arr[$j], ".") == 0) | |
39 | break; | |
40 | $f = explode(",", $arr[$j]); | |
41 | ||
42 | if ($f[0] == "TEMP_STATE") | |
43 | $temp_state = $f[1]; | |
44 | if (($f[0] == "TEMP_VALUE") && ($temp_state == "OK")) | |
208
934d45d9751d
Added room temperature and humidity to the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
45 | $temp_value = $f[1].' °C'; |
207 | 46 | if ($f[0] == "HUM_STATE") |
47 | $hum_state = $f[1]; | |
48 | if (($f[0] == "HUM_VALUE") && ($hum_state == "OK")) | |
208
934d45d9751d
Added room temperature and humidity to the web interface
Michiel Broek <mbroek@mbse.eu>
parents:
207
diff
changeset
|
49 | $hum_value = $f[1].' %'; |
207 | 50 | $j++; |
51 | } | |
52 | } | |
53 | ||
54 | ||
55 | $reply = array ( | |
56 | 'temperature' => $temp_value, | |
57 | 'humidity' => $hum_value | |
58 | ); | |
59 | ||
60 | ||
61 | echo json_encode($reply); | |
62 | ?> |