关注官方微信

中文.

Products

Products

IOT Gateway Support Communication with Web Servers

Published Time: 2017-05-10 Author: Shanghai ZLAN Views: 5582
1. Summary

With the development of the Internet of things, more and more devices need to be connected to the cloud. The devices are various instrumentation, industrial equipment, collection devices, sensors, these devices are in the majority with a serial port (RS232 and RS485), so it can send data to the cloud via Internet gateway such as serial port to TCP, a serial port to Wifi. However, due to different protocols, developers need to develop various background programs to coordinate data transformation and storage.

New "Internet of things of supporting communicate with Web server" gateway can directly use POST, GET command to communicate with the Web server and users only need to write PHP code it can achieve data conversion and storage to simplify the development of the IOT upper device interface.

The greatest advantage of such an IoT gateway is that it saves development complexity, and the gateway can communicate directly with the GET/POST command and the cloud server.

2. Principle

Here is how the gateway is used and how it works. We know that when we enter the following link in the browser, we submit the data to the Web server in a GET instruction.

The data content submitted is:

The data content will be sent directly to the 80 port of the Web server (the server IP is 192.168.1.180). The PHP program running on the web server can read data like data=123456 correctly.

But the problems with the traditional pass-through IOT gateway are:
1) The data sent from various instruments to the IOT gateway is not standard GET instruction, so the IOT gateway needs to perform a data transformation, such as the increase of data GET /1.php?data= before the data, add data as HTTP/1.1 later.
2) The data sent by various instruments is hexadecimal data, but the web server is easy to handle string data, so the hexadecimal system needs to be converted into a string.

3. Usage

ZLAN5143, ZLAN8343N and other products can realize the above functions. The steps are as follows:

1) Write a configuration file on the computer, the content is as follows, and download it to the IoT gateway.

Take care of the sign $ here said the data received by the serial port, IoT gateway will replace the $ by data received of serial port after receiving the data, then upload this configuration file content to web server, so that the web server can receive serial port data according to the GET command format.

2) If you need to convert the data format from hexadecimal to string first, use the # symbol instead of the $symbol to write the configuration file.

From here we can see the implementation of the gateway is not only the support for GET instructions of the Web server, but also can be flexible design, it is a kind of common method with flexible increasing prefix, suffix in front and after.

4. Web server issuing

The above method only realizes the function of serial port hex data transforming to GET command when data from serial port to network. But if the Web server need to issue data according to the GET command, here also need to transfer one part data to the serial port. For example, when a Web server send GET command to 8080 port of IoT gateway (IP address 192.168.0.200), the effective data of the GET command (here 61626364656667) is converted to hexadecimal data (abcdefg) and output from the serial port of the gateway, send to the controller, actuator, as show in the figure below:

The implementation method is to increase “NFL: data=# HTTP/1.1” in the first line of the original configuration file, the IoT gateway will search the prefix data and suffixes HTTP/1.1 when received any network data, pick up the middle part, and translated into hexadecimal output from the serial port.

The implementation of the Web server issuing function is also due to the fact that it can also be used as a TCP server to receive the issuing connection and data of Web server when it uploads data as TCP Client.

5. Summary

The IoT gateway can directly communicate with Web server by GET command — including the issue and upload— it can significantly reduce the development work for cloud application, this kind IoT gateway take convenient for IoT device integration and access.