#!/usr/bin/php -q Local software is running - ".$errstr; elseif ($errno == 113) echo "No Connection - ".$errstr; else echo $errno." Connection Error - ".$errstr; } else { socket_set_blocking($fp,false); #sleep(1); $finished = 0; $jetzt = time(); $buff = ""; while (!feof($fp) && time() < $jetzt+20 && $finished == 0) { $line = fgets($fp); if (strpos($line,"L:") !== false) $finished = 1; if ($line != "") $buff .= $line."\n"; //sleep(1); } fclose($fp); if ($finished != 1) echo "\nNo Connection"; else { ob_start(); $arr = explode("\n\n",$buff); echo '
'; foreach ($arr as $v) { if (substr($v,0,2) == "M:") { $arr2 = explode(',',$v); $str = base64_decode($arr2[2]); $pos = 0; $readlen = 1; $data["meta"]["?1"] = dechex(ord(substr($str,$pos,1))).""; $pos += $readlen; $readlen = 1; $data["meta"]["?2"] = dechex(ord(substr($str,$pos,1))).""; $pos += $readlen; $readlen = 1; $data["meta"]["RoomCount"] = dechex(ord(substr($str,$pos,1))).""; $pos += $readlen; for($j = 1 ; $j <= $data["meta"]["RoomCount"] ; $j++) { $readlen = 1; $RoomID = dechex(ord(substr($str,$pos,1))).""; $pos += $readlen; $readlen = 1; $data["rooms"][$RoomID]["RoomNameLength"] = htmlentities(ord(substr($str,$pos,1))).""; $pos += $readlen; $readlen = $data["rooms"][$RoomID]["RoomNameLength"]; for($i = $pos; $i < $readlen+$pos ; $i++) $data["rooms"][$RoomID]["RoomName"] .= htmlentities(substr($str,$i,1)).""; $pos += $readlen; $readlen = 3; for($i = $pos; $i < $readlen+$pos ; $i++) $data["rooms"][$RoomID]["RFAdress(?)"] .= str_pad(dechex(ord(substr($str,$i,1))),2,"0",STR_PAD_LEFT).""; $pos += $readlen; } $readlen = 1; $data["meta"]["DevCount"] = dechex(ord(substr($str,$pos,1))).""; $pos += $readlen; } if (substr($v,0,2) == "L:") { $v = substr($v,2,strlen($v)); $str = base64_decode($v); $pos = 0; for($j = 1 ; $j <= $data["meta"]["DevCount"]; $j++) { unset($hilf); $readlen = 1; $hilf["ReadLength"] = htmlentities(ord(substr($str,$pos,1))).""; $pos += $readlen; $readlen = 3; for($i = $pos; $i < $readlen+$pos ; $i++) $hilf["RFAdress"] .= str_pad(dechex(ord(substr($str,$i,1))),2,"0",STR_PAD_LEFT).""; $pos += $readlen; $readlen = 1; $hilf["?1"] = dechex(ord(substr($str,$pos,1))).""; $pos += $readlen; $readlen = 1; $hilf["Data1"] .= str_pad(decbin(ord(substr($str,$pos,1))),8,"0",STR_PAD_LEFT).""; $pos += $readlen; $readlen = 1; $hilf["Data2"] .= str_pad(decbin(ord(substr($str,$pos,1))),8,"0",STR_PAD_LEFT).""; $pos += $readlen; if($hilf["ReadLength"] == 11) { $readlen = 1; $hilf["?2"] = dechex(ord(substr($str,$pos,1))).""; $pos += $readlen; $readlen = 1; $hilf["Temperature"] = (ord(substr($str,$pos,1))/2).""; $pos += $readlen; $readlen = 2; for($i = $pos; $i < $readlen+$pos ; $i++) $hilf["DateUntil"] .= str_pad(decbin(ord(substr($str,$i,1))),8,"0",STR_PAD_LEFT).""; $pos += $readlen; $readlen = 1; $hilf["TimeUntil"] = (ord(substr($str,$pos,1))*0.5).""; $pos += $readlen; } switch (substr($hilf["Data2"],6,2)) { case "00" : $deviceconf[$hilf["RFAdress"]]["Mode"] = "auto"; break; case "01" : $deviceconf[$hilf["RFAdress"]]["Mode"] = "manu"; break; case "10" : $deviceconf[$hilf["RFAdress"]]["Mode"] = "vacation"; break; case "11" : $deviceconf[$hilf["RFAdress"]]["Mode"] = "boost"; break; } $deviceconf[$hilf["RFAdress"]]["LiveDataX"] = $hilf["Data3"]; echo "\n"; } //echo $v; } } $ob = ob_get_contents(); ob_end_clean(); if ($deviceconf['005bfb']['Mode']=="auto" && $deviceconf['004bb8']['Mode'] =="auto" ) echo "0\n"; else echo "1\n"; } } ?>