2016-03-21 4 views
1

nur das DFrobot Relais bekam und versuchte, mit ihm unter Verwendung von json Befehle pdf zu kommunizieren, ist hereRLY-8 POE-Relais mit json

jede Hilfe bitte, wie ein Ein/Aus-Befehl von Terminal zu schicken?

Antwort

0

überprüfen Sie bitte: https://github.com/Dzduino/DFRobot-RLY-8-Web-Control/blob/master/index.php

Sie PHP Sockel wie unten in einer HTML oder PHP-Seite verwenden können, bitte beachten Sie, dass einige lokale PHP-Server verwenden (zB: XAMPP) testen:

<?php 
    $addr = "192.168.1.10";  // RLY-8 Default Adress 
    $port = 2000;    // RLY-8 Default port 
    $timeout = 30;    // Connection Time out in Sec 

    if (isset($_POST["cmd"])){ // check if a submit was done, otherwise the communicatino will start after page loading 
     $cmd = $_POST["cmd"] ; // Capture the input Command 
     $fp = fsockopen ($addr, $port, $errno, $errstr, $timeout); // initiate a socket connection 
     if (!$fp) { 
      echo "($errno) $errstr\n"; // return the error if no connection was established 
     } else { 
      fwrite ($fp, $cmd);   // Send the command to the connected device 
      echo fread($fp, 128);  // Echo the return string from the device 
      fclose ($fp);    // close the connection 
     } 
    } 
?> 
0

das ist ziemlich einfach, öffnen Sie einfach eine Telnet auf das Gerät, das ein Beispiel:

telnet 192.168.1.10 2000 

und kopieren Sie eine der JSON Paste-Befehle von ihren pdf docum wie:

{"relay1":"on","relay2":"on","relay3":"off","relay4":"off","relay5":"off", "relay6":"off","relay7":"off","relay8":"off"} 

und drücken Sie die Eingabetaste. Falls Sie mehr als Telnet-Befehle wünschen, können Sie das Github-Projekt this überprüfen.