MQTT protocol is used to communicate between acquisition terminal and server
[3]. It is a publish/subscribe protocol based on TCP/IP for mobile terminal nodes.
After the initialization is completed, the acquisition terminal packs and sends the
data to server. Meanwhile, the acquisition terminal continuously receives information
from server and then performs corresponding control operations after parsing. Once the
acquisition terminal finds out that the smoke value is abnormal and has not received
any operation instructions from server, it will automatically turn on the ventilator.
4.2 Software Design of Sever
The server is served by Raspberry Pi, an embedded system. The software program of
server is written in Java language and uses eclipse as the development platform. The
functions of server include the interaction with the acquisition terminal, app and
database.
When server communicates with app, it first declares a ServerSocket object and
specifies the port number, then calls accept() method to listen for the connection
request, and returns a Socket object after receiving the request [4]. After the connection
is successful, the output and input streams are obtained through the getInputStream()
and getOutputStream() methods of the Socket object.
The server-side database uses MYSQL lightweight relational database. The “region,” “node,” and “timing_task” database table is established according to the
requirements of the system. After the connection between Java program and database is
established by JDBC, the data in the database can be added, deleted, and modified by
using SQL statement.
4.3 Software Design of Android Terminal
The software design of Android uses Android studio as the development environment
and Java object-oriented language as the development language. The main program
mainly includes: XML page layout, server connection, data transfer, etc. The software
design flow chart is shown in Fig. 8.
XML layout combines multiple controls with multiple layout managers to generates
the login interface, the region interface, node interface, node details interface, timing
task interface, and so on [5]. By monitoring the login button of the login interface, the
submitted login information is sent to server. If the validation success message from
server is received, it will enter the next interface through the startActivity() method.
The interface of node and node details request the server every 10 s through the
postDelayed (task, 10,000) method of Handler to refresh the monitoring information
regularly. When activity calls the onStop () method, the timer is closed through the
removeCallbacks (task) method of Handler.
Android as a client connects to server through Socket based on TCP/IP protocol.
Every time Android establishes a connection with the server, it is necessary to specify
the IP address and port number of the server, then call getOutputStream() and getInputStream() methods to obtain the output stream and input stream.
348
J. Zhang et al.
[3]. It is a publish/subscribe protocol based on TCP/IP for mobile terminal nodes.
After the initialization is completed, the acquisition terminal packs and sends the
data to server. Meanwhile, the acquisition terminal continuously receives information
from server and then performs corresponding control operations after parsing. Once the
acquisition terminal finds out that the smoke value is abnormal and has not received
any operation instructions from server, it will automatically turn on the ventilator.
4.2 Software Design of Sever
The server is served by Raspberry Pi, an embedded system. The software program of
server is written in Java language and uses eclipse as the development platform. The
functions of server include the interaction with the acquisition terminal, app and
database.
When server communicates with app, it first declares a ServerSocket object and
specifies the port number, then calls accept() method to listen for the connection
request, and returns a Socket object after receiving the request [4]. After the connection
is successful, the output and input streams are obtained through the getInputStream()
and getOutputStream() methods of the Socket object.
The server-side database uses MYSQL lightweight relational database. The “region,” “node,” and “timing_task” database table is established according to the
requirements of the system. After the connection between Java program and database is
established by JDBC, the data in the database can be added, deleted, and modified by
using SQL statement.
4.3 Software Design of Android Terminal
The software design of Android uses Android studio as the development environment
and Java object-oriented language as the development language. The main program
mainly includes: XML page layout, server connection, data transfer, etc. The software
design flow chart is shown in Fig. 8.
XML layout combines multiple controls with multiple layout managers to generates
the login interface, the region interface, node interface, node details interface, timing
task interface, and so on [5]. By monitoring the login button of the login interface, the
submitted login information is sent to server. If the validation success message from
server is received, it will enter the next interface through the startActivity() method.
The interface of node and node details request the server every 10 s through the
postDelayed (task, 10,000) method of Handler to refresh the monitoring information
regularly. When activity calls the onStop () method, the timer is closed through the
removeCallbacks (task) method of Handler.
Android as a client connects to server through Socket based on TCP/IP protocol.
Every time Android establishes a connection with the server, it is necessary to specify
the IP address and port number of the server, then call getOutputStream() and getInputStream() methods to obtain the output stream and input stream.
348
J. Zhang et al.
