Link auf Syntax und RSSI " . "
"; ?>

Gardena R40Li




Uhrzeit: :

= 0; $i--) { $HexString = $HexString . $Delimiter . $HexArray[$i]; $Delimiter = " "; } $HexString = str_replace(' ', '', $HexString); // " " (Leerzeichen) durch "" (nix) ersetzen $OutBinStr = HexToBin($HexString); $CRC = array_fill(0,8,0); $OutBinArr = array_reverse(str_split($OutBinStr)); foreach($OutBinArr AS $i) { $CRCTemp = $CRC[0] ^ $i; $CRC[0] = $CRC[1]; $CRC[1] = $CRC[2]; $CRC[2] = $CRC[3] ^ $CRCTemp; $CRC[3] = $CRC[4] ^ $CRCTemp; $CRC[4] = $CRC[5]; $CRC[5] = $CRC[6]; $CRC[6] = $CRC[7]; $CRC[7] = $CRCTemp; } $CRC = array_reverse($CRC); return dechex(bindec(implode('', $CRC))); } // **************************************************************** // *** EchoAnswer ************************************************* // **************************************************************** function EchoAnswer($WebAnswer) { $WebAnswerArray = explode("-", $WebAnswer); // Teil für CRC-Berechnung extrahieren... $CRCinput = ""; $Delimiter = ""; for($i = 1; $i < (sizeof($WebAnswerArray) - 2); $i++) { $CRCinput = $CRCinput . $Delimiter . $WebAnswerArray[$i]; $Delimiter = "-"; } $Fehler = 0; for($i = 0; $i < sizeof($WebAnswerArray); $i++) { echo "Zeichen " . str_pad($i, 2 , "0", STR_PAD_LEFT) . " = 0x" . strtoupper($WebAnswerArray[$i]); // erstes Zeichen ausgeben und prüfen... if ($i == 0) { echo " = immer 0x02"; if (strcmp($WebAnswerArray[$i], "02") <> 0) { echo " => FEHLER!!!
"; $Fehler = $Fehler + 1; } else echo " => passt
"; } // zweites Zeichen ausgeben... else if ($i == 1) echo " = Kommandobyte
"; // drittes Zeichen ausgeben und prüfen... else if ($i == 2) { echo " = Längenbyte = " . hexdec($WebAnswerArray[$i]) . " Datenbytes"; if ((int)hexdec($WebAnswerArray[$i]) <> sizeof($WebAnswerArray) - 5) { echo " => FEHLER!!!
"; $Fehler = $Fehler + 1; } else echo " => passt
"; } // vorletztes Zeichen ausgeben und CRC prüfen... else if ($i == (sizeof($WebAnswerArray) - 2)) { echo " = Checksumme = 0x" . strtoupper(CreateHash($CRCinput)); if (strcmp($WebAnswerArray[$i], str_pad(CreateHash($CRCinput), 2, "0", STR_PAD_LEFT)) <> 0) // 2016-06-19: "str_pad" eingefügt { echo " => FEHLER!!!
"; $Fehler = $Fehler + 1; } else echo " => passt (".strtoupper(str_pad(CreateHash($CRCinput), 2, "0", STR_PAD_LEFT)).")
"; } // letztes Zeichen ausgeben und prüfen... else if ($i == (sizeof($WebAnswerArray) - 1)) { echo " = immer 0x03"; if (strcmp($WebAnswerArray[$i], "03") <> 0) { echo " => FEHLER!!!
"; $Fehler = $Fehler + 1; } else echo " => passt
"; } // alle restliche Zeichen ausgeben... else echo " = Datenbyte " . str_pad($i-2, 2 , "0", STR_PAD_LEFT) . "
"; } if ($Fehler > 0) echo "
" . "Es ist/sind " . $Fehler . " Fehler aufgetreten!" . "
"; echo "
"; } // **************************************************************** // *** AnalyseTime ************************************************ // **************************************************************** function AnalyseTime($WebAnswer, $StartByte) { $WebAnswerArray = explode("-", $WebAnswer); $hex = "0x". strtoupper($WebAnswerArray[$StartByte+3] . $WebAnswerArray[$StartByte+2] . $WebAnswerArray[$StartByte+1] . $WebAnswerArray[$StartByte]); if (hexdec($hex) <> 0) echo "Unix-Zeit = ". $hex . " - 2h => " . date("d.m.Y H:i", hexdec($hex) - (2*60*60)) . ", Status = AUTO" . "
"; else echo "Unix-Zeit = ". $hex . " => Status = MAN" . "
"; } // **************************************************************** // *** AnalyseBytes *********************************************** // **************************************************************** function AnalyseBytes($WebAnswer, $StartByte, $Bytes) { $WebAnswerArray = explode("-", $WebAnswer); $hex = "0x"; for ($i=0; $i<$Bytes; $i++) $hex = $hex . $WebAnswerArray[$StartByte+$Bytes-$i-1]; $dec = hexdec($hex); $bin = pack("S", $dec); // Umwandlung mit "S" = vorzeichenloser Short-Typ $ray = unpack("s", $bin); // Umwandlung mit "s" = vorzeichenbehafteter Short-Typ $Number = $ray[1]; if ($Bytes >= 2) echo "Bytes " . str_pad($StartByte, 2 , "0", STR_PAD_LEFT) . "-" . str_pad(($StartByte+$Bytes-1), 2 , "0", STR_PAD_LEFT) ." = " . strtoupper($hex) . " = " . $Number . " => "; else echo "Byte " . str_pad($StartByte, 2 , "0", STR_PAD_LEFT) . " = " . strtoupper($hex) . " = " . $Number . " => "; return $Number; } // **************************************************************** // *** POST auswerten ********************************************* // **************************************************************** if(htmlentities($_POST['stop']) && !is_array($_POST['stop'])) { $WebCmd = "02-0E-01-00-30-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Stop => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); } else if(htmlentities($_POST['start']) && !is_array($_POST['start'])) { $WebCmd = "02-0E-01-01-6E-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Start => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); } else if(htmlentities($_POST['home']) && !is_array($_POST['home'])) { $WebCmd = "02-0E-01-02-8C-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "HOME => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); } else if(htmlentities($_POST['man']) && !is_array($_POST['man'])) { $WebCmd = "02-0E-01-03-D2-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "MAN => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); } else if(htmlentities($_POST['auto']) && !is_array($_POST['auto'])) { $WebCmd = "02-0E-01-04-51-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "AUTO => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); } else if(htmlentities($_POST['nextstarttime']) && !is_array($_POST['nextstarttime'])) { $WebCmd = "02-06-01-05-2A-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "nächste Startzeit => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); AnalyseTime($WebAnswer, 9); } else if(htmlentities($_POST['status']) && !is_array($_POST['status'])) { $WebCmd = "02-12-01-01-9F-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Status => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); AnalyseTime($WebAnswer, 10); echo "
"; switch (AnalyseBytes($WebAnswer, 4, 1)) { case 1: echo "Parken" . "
"; break; case 2: echo "Mäher aktiv" . "
"; break; case 4: echo "Laden" . "
"; break; case 5: echo "Mäher sucht" . "
"; break; case 7: echo "Fehler" . "
"; break; default: echo "Unbekannt" . "
"; } } else if(htmlentities($_POST['uhrzeit']) && !is_array($_POST['uhrzeit'])) { $WebCmd = "02-02-01-00-8B-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Uhrzeit => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo $hh = AnalyseBytes($WebAnswer, 4, 1); echo "
"; echo $mm = AnalyseBytes($WebAnswer, 5, 1); echo "
"; echo $ss = AnalyseBytes($WebAnswer, 6, 1); echo "
"; echo "=> Uhrzeit: " . str_pad($hh, 2 , "0", STR_PAD_LEFT) . ":" . str_pad($mm, 2 , "0", STR_PAD_LEFT) . ":" . str_pad($ss, 2 , "0", STR_PAD_LEFT). "Uhr"; } else if(htmlentities($_POST['uhrstellen']) && !is_array($_POST['uhrstellen'])) { $Stunde = dechex(htmlentities($_POST['Stunde'])); $Minute = dechex(htmlentities($_POST['Minute'])); // String für CRC-Berechnung zusammensetzen, ohne erstes Byte!!! $CRCinput = "02-04-80-" . strtoupper(str_pad($Stunde, 2 , "0", STR_PAD_LEFT)) . "-" . strtoupper(str_pad($Minute, 2 , "0", STR_PAD_LEFT)) . "-00"; // Kommando zusammensetzen, mit erstem Byte!!! $WebCmd = "02-" . $CRCinput . "-" . strtoupper(CreateHash($CRCinput)) . "-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Uhrzeit stellen => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo $hh = AnalyseBytes($WebAnswer, 4, 1); echo "
"; echo $mm = AnalyseBytes($WebAnswer, 5, 1); echo "
"; echo $ss = AnalyseBytes($WebAnswer, 6, 1); echo "
"; echo "=> Uhrzeit: " . str_pad($hh, 2 , "0", STR_PAD_LEFT) . ":" . str_pad($mm, 2 , "0", STR_PAD_LEFT) . ":" . str_pad($ss, 2 , "0", STR_PAD_LEFT). "Uhr"; } else if(htmlentities($_POST['battery']) && !is_array($_POST['battery'])) { $WebCmd = "02-14-01-01-4E-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Batterie-Status => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo "U = " . (AnalyseBytes($WebAnswer, 4, 2)/1000.0) . "V" . "
"; echo "Q = " . AnalyseBytes($WebAnswer, 6, 2) . "mAh" . "
"; echo "I = " . AnalyseBytes($WebAnswer, 8, 2) . "mA" . "
"; echo "T = " . (AnalyseBytes($WebAnswer, 10, 1)/10.0 + AnalyseBytes($WebAnswer, 11, 1)*25.5) . "°C" . "
"; } else if(htmlentities($_POST['wheeldrive']) && !is_array($_POST['wheeldrive'])) { $WebCmd = "02-14-01-02-AC-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Radmotor-Status => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo "P_links = " . AnalyseBytes($WebAnswer, 4, 2) . "%" . "
"; echo "n_links = " . AnalyseBytes($WebAnswer, 6, 2) . "U/min" . "
"; echo "I_links = " . AnalyseBytes($WebAnswer, 8, 2) . "mA" . "
"; echo "P_rechts = " . AnalyseBytes($WebAnswer, 10, 2) . "%" . "
"; echo "n_rechts = " . AnalyseBytes($WebAnswer, 12, 2) . "U/min" . "
"; echo "I_rechts = " . AnalyseBytes($WebAnswer, 14, 2) . "mA" . "
"; } else if(htmlentities($_POST['mowerdrive']) && !is_array($_POST['mowerdrive'])) { $WebCmd = "02-14-01-03-F2-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Mähmotor-Status => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo "n = " . AnalyseBytes($WebAnswer, 4, 2) . "U/min" . "
"; echo "I = " . AnalyseBytes($WebAnswer, 6, 2) . "mA" . "
"; } else if(htmlentities($_POST['sensor']) && !is_array($_POST['sensor'])) { $WebCmd = "02-14-01-04-71-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Sensor-Status => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); switch (AnalyseBytes($WebAnswer, 4, 1)) { case 0: echo "kein Stoss" . "
"; break; case 3: echo "Stoss" . "
"; break; default: echo "Unbakannt" . "
"; } switch (AnalyseBytes($WebAnswer, 5, 1)) { case 0: echo "nicht angehoben" . "
"; break; case 3: echo "angehoben" . "
"; break; default: echo "Unbakannt" . "
"; } echo "X = " . (AnalyseBytes($WebAnswer, 6, 2)/10) . "°" . "
"; echo "Y = " . (AnalyseBytes($WebAnswer, 8, 2)/10) . "°" . "
"; echo "Z = " . (AnalyseBytes($WebAnswer, 10, 2)/10) . "°" . "
"; switch (AnalyseBytes($WebAnswer, 12, 1)) { case 0: echo "Normalposition" . "
"; break; case 1: echo "Keine Normalposition" . "
"; break; default: echo "Unbakannt" . "
"; } } else if(htmlentities($_POST['flap']) && !is_array($_POST['flap'])) { $WebCmd = "02-14-01-05-2F-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Klappen-Status => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); switch (AnalyseBytes($WebAnswer, 6, 1)) { case 0: echo "Klappe geschlossen" . "
"; break; case 1: echo "Klappe offen" . "
"; break; default: echo "Unbakannt" . "
"; } } else if(htmlentities($_POST['t1start']) && !is_array($_POST['t1start'])) { $WebCmd = "02-06-02-01-01-DC-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Time 1 start => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo $hh = AnalyseBytes($WebAnswer, 5, 1); echo "
"; echo $mm = AnalyseBytes($WebAnswer, 7, 1); echo "
"; echo AnalyseBytes($WebAnswer, 8, 1); echo "
" . "
"; echo "=> Timer 1 start: " . str_pad($hh, 2 , "0", STR_PAD_LEFT) . ":" . str_pad($mm, 2 , "0", STR_PAD_LEFT) . "Uhr"; } else if(htmlentities($_POST['t1stop']) && !is_array($_POST['t1stop'])) { $WebCmd = "02-06-02-01-81-50-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Time 1 stop => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo $hh = AnalyseBytes($WebAnswer, 5, 1); echo "
"; echo $mm = AnalyseBytes($WebAnswer, 7, 1); echo "
"; echo AnalyseBytes($WebAnswer, 8, 1); echo "
" . "
"; echo "=> Timer 1 stop: " . str_pad($hh, 2 , "0", STR_PAD_LEFT) . ":" . str_pad($mm, 2 , "0", STR_PAD_LEFT) . "Uhr"; } else if(htmlentities($_POST['t2start']) && !is_array($_POST['t2start'])) { $WebCmd = "02-06-02-01-02-3E-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Time 2 start => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo $hh = AnalyseBytes($WebAnswer, 5, 1); echo "
"; echo $mm = AnalyseBytes($WebAnswer, 7, 1); echo "
"; echo AnalyseBytes($WebAnswer, 8, 1); echo "
" . "
"; echo "=> Timer 2 start: " . str_pad($hh, 2 , "0", STR_PAD_LEFT) . ":" . str_pad($mm, 2 , "0", STR_PAD_LEFT) . "Uhr"; } else if(htmlentities($_POST['t2stop']) && !is_array($_POST['t2stop'])) { $WebCmd = "02-06-02-01-82-B2-03"; $WebAnswer = implode('', file("http://192.168.x.y/send?cmd=".$WebCmd)); echo "Command => ". $WebCmd . "
"; echo "Time 2 stop => " . strtoupper($WebAnswer) . "
" . "
"; EchoAnswer($WebAnswer); echo $hh = AnalyseBytes($WebAnswer, 5, 1); echo "
"; echo $mm = AnalyseBytes($WebAnswer, 7, 1); echo "
"; echo AnalyseBytes($WebAnswer, 8, 1); echo "
" . "
"; echo "=> Timer 2 stop: " . str_pad($hh, 2 , "0", STR_PAD_LEFT) . ":" . str_pad($mm, 2 , "0", STR_PAD_LEFT) . "Uhr"; } ?>