![Teracom TCW280 User Manual Download Page 26](http://html1.mh-extra.com/html/teracom/tcw280/tcw280_user-manual_1088221026.webp)
TCW280_R1.2 – February 2019
Page 26
Read Digital Out 2 Description
03
2032
64 bytes UTF-8
Read Digital Out 3 Description
03
2064
64 bytes UTF-8
Read Digital Out 4 Description
03
2096
64 bytes UTF-8
Read Analog Out 1 Description 03
4000
64 bytes UTF-8
Read Analog Out 2 Description
03
4032
64 bytes UTF-8
7.3.
HTTP API
7.3.1.
HTTP Post
TCW280 can send HTTP Post to upload XML/JSON file to a dedicated server.
This functionality is very useful if the controller is behind the router without public IP address or
the user don’t have access to router configuration. The server should have a public IP address.
The typical monitoring application is shown in the picture below:
HTTP post can be sent periodically or periodically plus on an alarm condition. As an answer, the
server can send HTTP Get with appropriate command – see
7.3.3. HTTP commands
To test HTTP Post follow the steps below:
•
Save following code like post.php:
<?php
define("FILENAME", 'status.xml');
define("FOLDER", '');
define("SEPARATOR", '');
define("STR_SUCCESS", 'set FIN');
define("STR_ERROR", 'error');
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$datePrefix = date('YmdHis', strtotime('now'));
$pathname = FOLDER.SEPARATOR.$datePrefix.'_'.FILENAME;
$postdata = file_get_contents("php://input");
$handle = fopen($pathname, 'w+');
$content = var_export($postdata, true);
fwrite($handle, substr($content, 1, strlen($content)-2));
fclose($handle);
echo (($handle === false) ? STR_ERROR : STR_SUCCESS)."\r\n";
}
else {
echo "The PHP script is working!";
}
?>
•
Copy the post.php file on a public web server with PHP support. To verify that the script is
working properly, you can type the URL ( for example www.yourserverURL.com/post.php )
in your web browser. If all is OK, a web page with “The PHP script is working!” will be
shown.
Summary of Contents for TCW280
Page 1: ......
Page 34: ...TCW280_R1 2 February 2019 Page 34 Fig 1 Fig 2...