Create a magical smart home gateway and system solution

A home gateway is an intelligent network that connects a computer Internet to an autonomously built home network. It can realize the unified and intelligent management of the home terminal. The user can retrieve the working status information of the home appliance in real time through simple operation through the GUI interface, and can control the home terminal. At the same time, the intelligent home gateway has automatic control function and can handle Some work that does not require manual work.

The purpose of the project is as follows

The basic functions to be implemented are:

The home terminal device can be remotely controlled by accessing the home gateway through the external network.

The intelligent home gateway has a certain degree of autonomous processing capability, and can automatically control the operation of some terminal devices without manual intervention.

The features that are expected to be extensible after the project are:

The successful and low-cost smart home gateway product is produced. The gateway includes an embedded operating system and has a friendly interface. It can be used as a physical interface for all external networks to access the home network.

The Smart Home Gateway assigns internal, unique, unique IP addresses to devices within the home, and has routing capabilities and Network Address Translation (NAT) capabilities.

The intelligent home gateway can transmit audio and video streams inside the home network, support video on demand (VOD), video sharing, etc., to create a friendly and comfortable multimedia environment.

By adding a wireless control module, various terminal devices do not need to use a transmission line to connect to the gateway, but use wireless control to enhance flexibility.

Project research significance

The home gateway plays an important role in the home network. With the existing computer network technology, the home appliances and devices inside the home are connected to the network, providing people with rich, diverse, personalized, convenient, comfortable and safe. And efficient service. In the aspect of home appliance control, users can configure home appliances according to their own needs, so that they can remotely control home appliances conveniently; in video surveillance, by remotely capturing video information captured by monitoring devices installed at home, users can be clear in time. In order to understand the situation at home, in case of abnormal situation, timely alarm; in the multimedia access, through the home digital set-top box, users can not only watch high-definition digital programs, but also interactively on-demand programs and browse web pages, realizing multimedia in the home. In terms of information services, by interconnecting smart home networks with other network systems, users can get timely services such as after-sales and health. Home gateway has become an indispensable part of people's daily life. Therefore, it is of great significance to study low-cost, safe and reliable home gateways.

Project application prospects and academic value

With the improvement of people's quality of life, there are more and more electronic products inside the home. The use of intelligent home gateways for centralized control and management will bring great convenience to people's lives. Therefore, the application of the home gateway will be a large number. In the past, small network routers that existed within the home had limited functions. The application was to share a broadband network access simultaneously with multiple PCs in the home. It can only control PC terminals, and it can't do anything else for home appliances such as refrigerators and air conditioners. The Smart Home Gateway not only provides broadband access, but also controls the management of various appliances within the home. For example, in the case of web applications, children in the home can access the Web to learn the course of the school, while another family member can shop online. Multiple people can perform network operations at the same time without waiting for others to complete the operation; in multimedia applications, the home gateway not only manages high-speed Internet access, but also for increasingly rich multimedia applications such as video on demand (VOD), video sharing, Videophones that mix video and audio streams, as well as other interactive forms of entertainment services, such as online games, provide more user-friendly management services; in addition, in the control and management of home electronic terminals, the home gateway can intelligently control home appliances. The video monitors the family situation, and is connected with the residential property to facilitate receiving instant service information, intelligently copying electricity meters, water meters, etc., providing great convenience for daily life. Therefore, its application prospects will be very broad.

The research on smart home gateway is gradually maturing in China, but it is still relatively backward in this respect relative to foreign countries. It is embodied in the backwardness of technical equipment and high manufacturing costs. At present, many home gateway products are technical solutions using a PC as a server or a single chip as a core chip, which has high power consumption and cost, and is not flexible enough. Through the design of low-cost, secure and reliable intelligent home gateway, participate in the research and development discussion of current home gateway, familiar with and master the design of UDP protocol content, data encryption and decryption algorithm, network address translation (NAT) and GUI user interactive interface. A true understanding of the workflow of the entire home gateway can also provide some technical references for other designers and vendors.

Existing research basis and conditions

Technical basis for project development:

The 1UDP protocol is one of the main transport protocols. The improved UDP protocol improves the reliability of data transmission to a certain extent and meets the transmission needs of the smart home gateway;

2 Data encryption and decryption algorithm uses RC4 algorithm, which can effectively improve the security of data information;

3 Using network address translation (NAT) can transform the intranet address and the external network address, making the home gateway a bridge connecting the computer Internet and the home internal network;

4 GUI interface design makes the user's operation simple, clear and convenient.

(2) The work foundation of the project team

Mastery of 1C and C++ languages, with some embedded development experience;

2 has a certain foundation in the UDP transmission protocol.

Research objectives

Within the expected time limit of the project, the basic functions of the smart home gateway are designed and tested, that is, the control information can be sent through the external network to manage the internal terminal devices of the home; and the automatic control function of the home gateway is completed, that is, the application without manual control is completed. Automatically coordinate the opening, closing and other adjustments of household electrical equipment.

After completing the basic functions, if there is time, continue to complete the extended functions, including routing address translation, operating system migration, video on demand and sharing, and wireless control.

The key issue to be solved is to assign a unique address to each home end device and implement routing functions to control different devices using the gateway.

Research methods, technical routes and feasibility analysis

Throughout the development of smart home gateways at home and abroad, there are three technical solutions that represent the technical characteristics of smart gateways in different development periods: the intelligent control system of PC architecture appears in the burgeoning stage of China's smart home gateway, basically staying at the user. The concept stage of the smart home gateway is not strong, and it belongs to the first generation. At present, many intelligent home control systems developed by smart home gateway manufacturers at home and abroad have a very good control system in terms of practicability, ease of use and professionalism. The improvement to a large extent belongs to the second generation; the development of home intelligence systems based on embedded systems is also in its infancy in China. With the wider application of embedded technologies and the gradual reduction of costs, China’s smart home gateway will eventually Going to the embedded.

This design adopts the intelligent home gateway technology scheme based on the improved UDP protocol, and adopts the single chip PIC to control the Ethernet module, without operating system support, to meet the requirements of project expectation and low cost, low power consumption, good real-time and strong scalability.

The basic functions of the project are realized in the two main control chip PIC MCU and Ethernet network interface, using the improved UDP protocol to complete most of the control information transmission.

Project hardware design

The microcontroller PIC is mainly responsible for reading, writing and resetting the Etnernet network interface. Ethernet is a highly integrated Ethernet chip that can be easily plug and play and compatible with NE2000 and power down. It processes the encapsulated Ethernet frames and transmits them over the network interface and twisted pair. Ethernet has reset and read/write control pins. It is necessary to configure the registers in the Ethernet through the corresponding address port and data port to realize the transmission and reception of network data. In the actual hardware connection, P0.8-P0.12 is used as the address port, P0.16-P0.23 is used as the data port, P0.7 is used as the reset pin to reset the RTL8019, and P0.13 is used as the read pin to control the Ethernet. The network module reads data from the corresponding data port, and P0.14 acts as a write pin to control the Ethernet module to write data to the corresponding data port.

Project software design

The software was designed in Agilent's ADS 1.2 development environment. The most important part is to complete the sending, processing and receiving of UDP packets. Since the content of the UDP packet is used as the control information, the data portion of the packet needs to be redefined. The definition is as follows:

The operation type occupies 1 byte, 00h represents initial establishment of handshake request, 01h represents initialization to establish handshake response, 02h represents transmission request, 03h represents transmission response, and other values ​​are reserved by default. The operation object occupies 2 bytes. On the server side, the operation object in the UDP datagram content it receives is the port number of the corresponding client; on the client, the operation object in the UDP datagram content it receives is Its own port number. The operation content is a specific implementation operation, occupying 40 bytes.

For the security of data content, the RC4 algorithm is used to encrypt and decrypt the data content. It is a stream key with variable key length and byte-oriented operation. The basic idea is to first initialize an S array of length 256: S[0], S[1],...,S[255] Assign an 8-bit value from 0 to 255, enter a variable length key, and create a temporary array T based on the key content and length. Then replace the S array according to the contents of the array T; finally, convert the S array into a key stream q in a certain way. At the transmitting end, the original data "data" is XORed according to the key stream q, that is, encrypted. At the receiving end, input the same key as the transmitting end, and use the same algorithm as the transmitting end to generate the same key stream to XOR the encrypted data “datam”, that is, complete the data decryption.

The package process of the packet is shown in the figure. Layer (1) represents a UDP datagram. You need to set a different port number for each terminal as the source port number. The destination port number is fixed to the server port number. The message length is the data length plus the UDP header length. The checksum is the pseudo IP header and the slave UDP header and data. The sum of the verifications obtained, the data is the encrypted data. Layer (2) indicates that the UDP datagram is converted into an IP datagram after being encapsulated once. Each terminal needs to be assigned an IP address, the protocol type is set to UDP protocol, and the length is the IP header length plus the UDP datagram length. Layer (3) is represented as an IP datagram that is then converted to an Ethernet frame after the last encapsulation.

Create a magical smart home gateway and system solution

The parsing process of the data packet is the reverse process of the encapsulation. After receiving the Ethernet data frame, the system first checks its checksum. If the checksum is faulty, the data packet is discarded and the sender is resent. Otherwise, it continues to judge the type of the data packet. After determining that it is an IP datagram, it further checks according to the format of the datagram. Finally, the content of the UDP datagram is obtained by unpacking to determine the next work, and an acknowledgement packet is sent.

The overall software design process of the project is shown in Figure 4. The data processing part of the application layer of the transmitting end is that the data collected from the terminal is processed according to a predetermined data format and then encrypted. The data encapsulation part defines three functions: put_ether(), put_ip(), and put_udp(). The functions are to encapsulate Ethernet frames, IP datagrams, and UDP datagrams. The network driver part needs to be controlled by the microcontroller PIC to control the Ethernet Ethernet module, and the Ethernet frame is sent to the receiving end. After the receiving end receives the Ethernet frame, it performs data unpacking. The data unpacking part defines three functions, get_ether(), get_ip(), and get_udp(), which implement the functions of checking and parsing Ethernet frames, IP datagrams, and UDP datagrams. Finally, the data is decrypted at the application layer to control the terminal.

Create a magical smart home gateway and system solution

Project feasibility analysis

This project adopts the latest intelligent home gateway technology solution and appropriately tailors the solution to reduce complexity and cost. For example, the hardware platform of the project adopts single-chip PIC and Ethernet Ethernet modules, which has low price, low power consumption and can fully meet the system processing needs; software design is to improve the UDP protocol, avoid complicated TCP protocol, data encryption, encapsulation and demolition. The packet flow is clear and simple, and the use of UDP protocol increases the real-time performance of signaling and data information transmission.

Project innovation

The innovation of this project is that the UDP protocol has been improved to make it more suitable for transmitting signaling information. The RC4 algorithm is used to encrypt the data, which ensures the security of data transmission to a certain extent. Finally, a low-cost, low-power, low-complexity, high-security control scheme is proposed, and the designed home gateway is suitable for ordinary family residences. Specifically, the data portion of the UDP packet is further divided to define different data formats and types to control different terminal devices. At the same time, the gateway also has an automatic control function, which can automatically and timely handle some operations that do not require manual intervention, which increases the usability.

Other household electric appliance

tcl , https://www.tclgroupss.com