Iot gateway solution design based on Android platform

Source: Internet
Author: User
Design Time of Iot gateway solution based on Android: 2013-03-20 12:58:07 Source: Electronic Design Engineering Author: Qiao lei, Lei Bin, du Jianying


Abstract:An Iot gateway solution based on the Android platform is proposed. The gateway transmits data between the central node of the wireless sensor network (WSN) in IOT and the android gateway through Bluetooth serial communication, on the Android platform, you can manage the information of the nodes in the sensor network and access the Internet through the network resources of Android. In this way, you can build a transparent data transmission channel between the sensor network and the Internet, completes remote and real-time monitoring and control of wireless node data.
Keywords:Iot, WSN, and gateway



China has become the largest mobile Internet market and has a broad market in mobile internet and Iot. This will allow Iot applications to go deep into various fields through mobile Internet platforms to achieve ubiquitous access. Currently, the most common embedded operating systems on mobile Internet platforms are Linux, WindowsCE, meego, Android, and palm. Android systems have high network integration, it is recognized as a Linux kernel-based operating system for mobile devices.
It is of great significance for mobile terminals to integrate Iot. the bottleneck of Iot access to the Internet is gateway. This article proposes a gateway solution based on Android platform and connected to IOT through Bluetooth, this effectively avoids the development bottleneck of Iot gateway.



1 Overview of Wireless Network Gateway Based on Android platform
The Measurement and Control System of Xingyun is a distributed measurement and control system composed of one primary node of the sensor network and multiple measurement and control nodes of the sensor network. It is used for temporary and long-term measurement in the field, bridge detection and transient testing of large structures. Figure 1 shows the structure of the Xingyun Measurement and Control (WSN) gateway based on Bluetooth serial communication on the Android platform:






The gateway uses an Android-based smart tablet with Bluetooth and Wi-Fi/WLAN functions, and uses Bluetooth to connect to the worker W-based sensor network monitoring and control system master node; the Gateway provides functions such as display, storage, human-computer interaction, remote communication, and network communication. The gateway software runs in the android2.3 operating system,ProgramDeveloped in Android eclipse. The working process is roughly as follows: pairing, connecting, and transmitting the gateway Bluetooth with the ZigBee master node Bluetooth, and connecting the gateway to a remote terminal through the same LAN wifi, display, storage, and control of Zigbee network measurement and control information, realize gateway communication and management, and complete two-way data transmission and control between the WSN and the Internet.



2. Design of Iot gateway on Android platform
The gateway communicates with the central node of the sensor network through a Bluetooth serial port. On the Android platform, the gateway manages information about the nodes of the sensor network and implements Internet access through the network resources of the andrid, therefore, a transparent data transmission channel is established between the wireless sensor network (WSN) and the Internet to implement remote and real-time monitoring and control of data on wireless nodes. Figure 2 shows the design diagram of the Gateway Based on the Android platform. To implement the IOT gateway software on the Android platform, complete the following steps:
(1) set Bluetooth and Wi-Fi;
(2) A paired or nearby bluetooth device is found;
(3) connecting devices;
(4) data transmission between different devices;
(5) Use Wi-Fi to connect to the same wireless LAN through the wireless south, and establish network communication based on TCP/IP protocol through socket.
(6) The Gateway manages the WSN.






Figure 3 shows the gateway workflow. The Iot gateway of Android is designed to implement the following functions: enable Bluetooth, enable Wi-Fi, enable visibility of Bluetooth devices, search for Bluetooth, pairing and connection of Bluetooth devices, Bluetooth serial communication, and network communication and gateway management.



3. Bluetooth serial communication and network communication of Android Gateway
3.1 Bluetooth serial communication of Android Gateway
"Bluetooth" is a standard of short-distance wireless connection technology. Its essence is to establish public standards for general radio air interfaces and their control software. The "Bluetooth" technology can effectively simplify the communication between devices in mobile communication terminals, and can also successfully simplify the communication between devices and the Internet, so that data transmission becomes faster and more efficient, broaden the road for wireless communication. Android's Bluetooth protocol stack uses bluez (Linux's Official Bluetooth Stack) to support gap, SDP, RFCOMM, and other application specifications, and has obtained sig certification. Bluez RFCOMM provides serial simulation on Bluetooth, which enables serial port applications and protocols to run on Bluetooth without modification. The rfc omm module and the background process in user mode Dund implement a Bluetooth dial-up network. Bluetooth specifications support UART (Universal Asynchronous Receiver/transmitter) and USB transmission mechanisms for Bluetooth HCI data groups. The bluz Stack also supports these two transmission mechanisms (Drivers/Bluetooth /). Figure 4 shows the relationship diagram of the android Bluetooth part.



 






Android includes support for the Bluetooth protocol stack, which enables Bluetooth devices to wirelessly connect to other Bluetooth devices for data exchange. The Android Application Framework provides APIs for accessing the Bluetooth function to implement point-to-point or point-to-point wireless interaction. Using the Bluetooth API, an android application can implement the following functions: scan other Bluetooth devices, query local Bluetooth adapters for pairing Bluetooth devices, establish RFCOMM channels, connect to other devices through service discovery, data communication, and manage multiple connections. Figure 5 shows the flowchart of the Bluetooth serial communication. Enables you to enable, display, search, and manage connections to Bluetooth devices.






 



3.2 Android Network Communication
Android fully supports JDK's TCP and UDP network communication APIs. You can use seversocket and socket to establish network communication based on the TCP/IP protocol, you can also use mongoramsocket, mongorampacket, and multicastsocket to establish UDP network communication. This design uses the TCP/IP protocol to achieve network communication, as shown in figure 6.



 






This design only implements client programming, and the server uses sockettool TCP/IP communication debugging tool v2.2 to establish on the PC end. The steps for using socket to implement the client are as follows:
(1) instantiate the socket through the IP address and port and request to connect to the server.
(2) obtain the stream on the socket for reading and writing.
(3) package the stream into the bufferedreader instance.
(4) read and write socket
(5) Close the process of hacking.
KeyCodeAs follows:



4. Gateway management functions and implementation
The gateway manages the wireless sensor network (WSN) at the application layer, including security authentication, unified time, monitoring , node locating, and remote transmission, so as to implement real-time on-site control and management. The function is designed as follows:
(1) Security Authentication: the coordination node sends the ID of the applied node to the Gateway in Security Authentication. The Gateway searches for the authorized inbound node in the configuration table. If the node ID is in the table, the notification coordination node allows inbound traffic. Otherwise, inbound traffic is not allowed. At the same time, the gateway can display, add, or modify authorized inbound nodes in the node configuration table.
As shown in 8-1, the gateway inserts the configuration table information. The experiment consists of four nodes in the ZigBee network. The node numbers are 0080e102001bc94d, 0080e102001bce91, 0080e102001bc204 and 0080e102001bcf51. The wireless sensor network composed of ZigBee enables point-to-point communication. The Gateway can collect node data and use a green light to display the point-to-point communication between node 1 and node 3, the red light indicates that it is not working.



(2) unified time: In the process of unified time, the gateway is first school through the NTP protocol, and the time is sent to the Coordinator node based on the time, in this way, the time of the Coordination node and the time of the internal subnode are calibrated to ensure the time consistency of nodes in the network. As shown in (a), the bottom of the gateway shows the NTP protocol.



 






 network.
(4) node positioning: The ZigBee network uses the HTTP flood method to locate the node. The Gateway collects the node's HTTP flood value to calculate the approximate node location.
(5) storage of monitoring data: receives node monitoring data and regularly saves it to the local SD card in the form of files. 8-2 get the data transmitted from the data stored on the sdks, And the name is maid.



5 test results
The hardware platform required by the system is Android tablet, BMX bluetooth module, and PC. The Software Platform required for this experiment is sscom32 serial port debugging assistant, socket tool network debugging, TCP/UDP Development Kit, ecplise Java development environment, and Android SDK. The IP address for network communication is 192.168.0.190 and the port number is 30000.






Main result 8 is displayed. Figure 8 (a) shows the device connection interface, which enables Bluetooth and network connections. The device list is displayed when the device Search button is triggered. Click the desired device name to establish a Bluetooth connection. Trigger the WiFi button to establish a network connection. Trigger the test button to test whether the communication channel is established. If the connection is established successfully, "Success connection" is displayed ". The gateway implements two-way data transmission and gateway management, 8 (B), 8 (c ). The transmission process is divided into the following three situations:
(1) The Bluetooth device sends data to the android gateway and remote terminal. The Android gateway and remote terminal display "Xi 'anqiical universitv" indicates that the test is successful.
(2) The Android gateway sends data to Bluetooth devices and remote terminals. "I am Lei Bin" is displayed on Bluetooth devices and remote terminals, indicating that the test is successful.
(3) the remote terminal sends data to the android gateway, and the andiroid gateway displays "success of socket communication", indicating that the test is successful. Network Communication result 8 (d) is shown.



6 conclusion
Because Bluetooth serial communication technology is used to connect to IOT, hardware development on the Android platform is avoided, this makes it possible to achieve wireless sensor network management and data transmission between the Internet without the need for hardware transformation and writing underlying drivers for existing Android smart platforms, greatly reducing the difficulty and cost of Iot Gateway applications.
Based on this design, real-time control of wireless sensor networks can be further implemented, which makes it possible to integrate Iot applications on mobile terminals.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.