An agricultural greenhouse measurement and control system based on Hongmeng system and OTA technology
By introducing the Hongmeng system and OTA technology into the agricultural greenhouse measurement and control system, remote firmware upgrades of IoT devices are realized, solving the problems of low flexibility in equipment upgrades and high maintenance costs, improving intelligence and enhancing security.
Patent Information
- Application Number
- CN202311089583.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-28
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2043-08-28
AI Technical Summary
Existing agricultural greenhouse IoT equipment has low firmware upgrade flexibility and high maintenance costs, resulting in insufficient intelligence.
The agricultural greenhouse measurement and control system based on Hongmeng system and OTA technology is used to collect environmental information data through the perception layer, and the OTA firmware upgrade function is added. The wireless network is used to remotely upgrade the terminal equipment, and the signature verification of the MQTT server and RSA algorithm is combined to realize the equipment information transfer and data interaction.
It improves the flexibility of system maintenance, reduces the maintenance cost of IoT devices, improves the intelligence of agricultural greenhouses, and ensures the integrity and security of OTA files through signature verification.
Smart Images

Figure CN117170706B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of agricultural greenhouse environmental data monitoring and control, and in particular, relates to an agricultural greenhouse measurement and control system based on Hongmeng system and OTA technology. Background Art
[0002] Crops need a suitable environment to grow, and different crops have different suitable growth conditions. Deploying agricultural IoT devices in agricultural greenhouses to monitor environmental parameters in real time is an important way to solve the problem. Existing technical solutions for smart agricultural greenhouses have achieved certain results in collecting and regulating environmental parameters for crop growth, but rarely involve the OTA firmware upgrade function of agricultural IoT devices. There are problems such as low flexibility in IoT terminal firmware upgrades and high maintenance costs.
[0003] When deploying agricultural IoT solutions, IoT devices need to run customized system software to collect data or perform operations. However, as requirements change, the system software may also need to be updated and improved, including software bug fixes, new feature additions, and system security enhancements. Usually, multiple IoT devices need to be deployed in a dispersed manner in a large agricultural greenhouse planting base. If the equipment needs maintenance and upgrades, it is necessary to manually go to the site to recycle and upgrade these devices, or IoT technicians need to go to the site to upgrade, resulting in high equipment maintenance costs and difficulty in upgrading. Summary of the invention
[0004] The present invention proposes an agricultural greenhouse measurement and control system based on the Hongmeng system and OTA technology to solve the problems existing in the above-mentioned prior art, such as low flexibility in firmware upgrade of agricultural greenhouse Internet of Things terminals, high maintenance cost, and low level of intelligence in greenhouse environmental monitoring.
[0005] To achieve the above objectives, the present invention provides an agricultural greenhouse measurement and control system based on Hongmeng system and OTA technology, including: a perception layer, a network layer and an application layer;
[0006] The perception layer is used to collect environmental information data in the agricultural greenhouse and add an OTA firmware upgrade function;
[0007] The network layer is used to transmit the environmental information data to the application layer via a wireless network;
[0008] The application layer is used to receive the environmental information data and forward it to the Web device management system, and based on the OTA firmware upgrade function, realize the interaction between the user and the terminal device in the agricultural greenhouse.
[0009] Preferably, the terminal device is several types of sensors.
[0010] Preferably, the perception layer includes: a main program and a sensor acquisition subprogram;
[0011] The main program is used to establish a wireless network connection, report the sensor measurement data and process remote control commands through the wireless network;
[0012] The sensor acquisition subroutine is used to read and update the sensor measurement data;
[0013] The perception layer uses Hi3861 hardware equipped with Hongmeng system.
[0014] Preferably, the application layer adopts an MQTT server, and the MQTT server is used to send an OTA upgrade request to the terminal device.
[0015] Preferably, an OTA firmware upgrade function is added to the main program, and the OTA firmware upgrade function is used to perform OTA firmware upgrade on the terminal device through a wireless network based on the OTA upgrade request, generate an OTA file, and based on the OTA file, call the upgrade interface of the Hongmeng system to complete the upgrade.
[0016] Preferably, in the OTA firmware upgrade function, the terminal device side is used as the client side, the OTA service side is used as the server side, a client / server architecture is adopted, and information transmission and data interaction are realized through socket.
[0017] Preferably, it also includes: upgrade file signature verification, which is used to generate a signed OTA file based on the RSA algorithm and verify the signature successfully.
[0018] Compared with the prior art, the present invention has the following advantages and technical effects:
[0019] The present invention provides an agricultural greenhouse measurement and control system based on the Hongmeng system and OTA technology, which collects environmental information data in the agricultural greenhouse through the perception layer; transmits the environmental information data to the application layer through the network layer using a wireless network; receives the environmental information data through the application layer and forwards it to the Web device management system, thereby realizing interaction between users and terminal devices in the agricultural greenhouse.
[0020] The present invention adds an OTA firmware upgrade function to the agricultural greenhouse measurement and control system based on the Hongmeng system, which realizes the remote updating of the terminal system firmware through the network, thereby improving the flexibility of system maintenance, reducing the maintenance cost of IoT equipment, and improving the intelligence level of agricultural greenhouses. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0022] Figure 1 A schematic diagram of a system hierarchy structure of an embodiment of the present invention;
[0023] Figure 2 It is a main program flow chart of an embodiment of the present invention;
[0024] Figure 3 This is the signing process of the OTA file in the embodiment of the present invention;
[0025] Figure 4 This is the signature verification process of the OTA file in an embodiment of the present invention;
[0026] Figure 5 This is a flowchart of an OTA firmware upgrade according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0028] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0029] Embodiment 1
[0030] like Figure 1 As shown, this embodiment provides an agricultural greenhouse measurement and control system based on the Hongmeng system and OTA technology. This embodiment uses MQTT (Message Queuing Telemetry Transport) as the transmission protocol. The agricultural greenhouse measurement and control system is logically divided into three layers, namely, the perception layer, network layer and application layer from bottom to top.
[0031] The perception layer uses Hi3861 hardware equipped with Hongmeng system, which is responsible for collecting greenhouse environmental parameters, such as measuring air temperature and humidity, light intensity, carbon dioxide concentration and other environmental information data, and then transmits it to the application layer MQTT server through the network layer WiFi wireless network, and then the MQTT server forwards the information to the Web device management system. The Web device management system provides Web services, and users can interact with terminal devices in agricultural greenhouses through browsers.
[0032] 1. Device-side programming
[0033] This embodiment uses Hi3861 hardware equipped with the Hongmeng system based on the OpenHarmony3.0 source code, and embeds a program customized by the device developer in the Hongmeng system. After the device is powered on, the Hongmeng system is initialized first, and then the customized program is entered, including the main program and the sensor acquisition subroutine. The main program is used to establish a network connection, report sensor measurement data, and process remote control commands; the sensor acquisition subroutine is used to read and update sensor data. The main program flow is as follows: Figure 2 shown.
[0034] After initializing WiFi and establishing a network connection, initialize the MQTT client, set the message callback function address, establish a connection with the MQTT server according to its IP address and port number, and subscribe to the MQTT message of the specified topic; then update the sensor data regularly and determine whether it needs to be uploaded. If it needs to be uploaded, encapsulate the sensor data in JSON (JavaScript Object Notation) format and report the information through MQTT; if a message is received from the MQTT server, the system will execute the message callback function. When processing MQTT messages, first parse the content of the message to obtain the remote command type, and then perform related operations according to the command type. If the command type is a device control command, further parse the command parameters of the device control, and control the state of the LED or motor according to the parameters. If the command type is an OTA upgrade command, further parse the command parameters to obtain the IP address and port number of the OTA server, then connect to the OTA server according to the IP address and port number, request and download the upgrade file and verify its signature. After the verification is passed, call the upgrade interface of the Hi3861 system for upgrade.
[0035] 2. OTA file signature and verification scheme design
[0036] During the transmission of OTA files on the network, they may be maliciously tampered or attacked. To ensure the legitimacy of OTA files, this embodiment customizes a file signing and verification method based on the RSA algorithm to sign and verify OTA files during the OTA firmware upgrade process to ensure the integrity and security of OTA file data. The OTA file signing and verification method has a certain degree of universality and can be used to sign other files.
[0037] The custom file signature format is:
[0038] (1) Signature file = original file + signature information
[0039] (2) Signature information = signature header information (44 bytes) + signature data (256 bytes)
[0040] (3) Signature header information = magic word (4 bytes) + key fingerprint (16 bytes) + signature time (7 bytes) + reserved (17 bytes); the magic word is defined as 0x3C4D5E6F as a signature mark, which can be used to quickly determine whether a file contains a signature; the key fingerprint is the MD5 value based on the public key data; the signature time is the signing time of the file; the reserved field is for future expansion.
[0041] The signature principle of the file:
[0042] Perform SHA-256 operation on the original file to obtain a hash value; use the PKCS#1 (v1.5) standard to fill the hash value into a 256-byte data block; use the RSA private key to perform RSA encryption operation on the filled data block to obtain 256-byte signature data; generate signature information according to the custom signature format, and append the signature information to the end of the original file to obtain the final signature file. The signing process of the OTA file is as follows: Figure 3 shown.
[0043] Document verification principle:
[0044] Read the signature information from the end of the file to determine whether there is a signature mark. If there is no signature mark, the signature verification fails. If there is a signature mark, continue the signature verification process; take out the 256-byte ciphertext signature data and use the RSA public key to perform RSA decryption operation. If the decryption fails, the signature verification fails. If the decryption succeeds, continue the signature verification process; take out the 32-byte hash value HASH1 from the decrypted plaintext data; use the same method as the signature process to perform SHA-256 operation on the file content without the signature information to obtain the hash value HASH2; compare HASH1 and HASH2. If they are different, the signature verification fails. If they are the same, the signature verification succeeds. The signature verification process of the OTA file is as follows: Figure 4 shown.
[0045] 3. Implementation method of OTA firmware upgrade function
[0046] OTA (Over the Air) upgrade, that is, air upgrade, provides the ability to remotely upgrade devices, helps hardware devices to quickly update and expand functions, and its essence is to upgrade the system firmware through the network. The OTA firmware upgrade function of this embodiment is completed by the agricultural greenhouse IoT device end and the OTA server end, where the OTA server program is embedded in the Web device management system developed based on Django. Users can log in to the system through a browser to view the greenhouse meteorological environment data, can control the greenhouse facilities accordingly, and can perform OTA firmware upgrades on terminal devices. It adopts a client / server (C / S) architecture, with the device end as the client and the OTA server end as the server end. Communication between the two processes is achieved through sockets, thereby realizing information transmission and data interaction. The OTA firmware upgrade process is as follows: Figure 5 shown.
[0047] The user enters the OTA upgrade page of the Web device management system through a Web browser, enters the IP address and port number of the OTA server, selects the OTA file version to be upgraded, and then initiates an upgrade request through HTTP. The Web device management system parses the parameters of the HTTP request, then encapsulates the upgrade parameters in JSON data format, and then sends the OTA upgrade request to the device through MQTT. After receiving the upgrade request, the device parses the message to obtain the IP address and port number of the OTA server, establishes a socket connection with the OTA server, and then requests the OTA server to download the upgrade file. After receiving the socket request, the OTA server selects the signed OTA file of the corresponding version according to the request parameters, then reads the OTA file data and sends it to the device. After the device downloads the upgrade file, it verifies the signature of the file. After the verification passes, it calls the system's upgrade interface for upgrade, and finally restarts the device to complete the upgrade.
[0048] Beneficial effects of this embodiment:
[0049] This embodiment adds an OTA firmware upgrade function to the agricultural greenhouse measurement and control system based on the Hongmeng system, which enables remote updating of the terminal system firmware through the network, thereby improving the flexibility of system maintenance, reducing the maintenance cost of IoT equipment, and improving the intelligence level of agricultural greenhouses.
[0050] At the same time, this embodiment customizes a file signing and verification method based on the RSA algorithm, and signs and verifies the OTA file during the OTA firmware upgrade process, ensuring the integrity and legitimacy of the OTA file data and enhancing the security of the system. The file signing and verification method has a certain universality and can be used for signing other files.
[0051] The above is only a preferred specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An agricultural greenhouse measurement and control system based on Hongmeng system and OTA technology, characterized in that: include: Perception layer, network layer and application layer; The perception layer is used to collect environmental information data in the agricultural greenhouse; The network layer is used to transmit the environmental information data to the application layer via a wireless network; The application layer is used to receive the environmental information data and forward it to the Web device management system, wherein the Web device management system includes an OTA server, and based on the OTA server, the terminal device in the agricultural greenhouse is upgraded by OTA firmware; The perception layer uses Hi3861 hardware equipped with Hongmeng system; The application layer uses an MQTT server, the MQTT server receives the environmental information data and forwards it to the Web device management system, selects upgrade parameters on the OTA upgrade page of the Web device management system, and based on the upgrade parameters, the MQTT server sends an OTA upgrade instruction to the terminal device; During the OTA firmware upgrade process, the device terminal receives the OTA upgrade instruction and parses it to obtain the IP address and port number of the OTA server. Based on the IP address and port number, the device terminal requests the OTA server to download the upgrade file. The OTA server downloads the upgrade file and sends it to the device terminal. The upgrade interface of the Hongmeng system is called at the device terminal to complete the upgrade. In the OTA firmware upgrade function, the terminal device is used as the client, the OTA server is used as the server, and the client / server architecture is adopted to realize information transmission and data interaction through socket; The OTA firmware upgrade process specifically includes: The user enters the OTA upgrade page of the Web device management system through a Web browser, enters the IP address and port number of the OTA server, then selects the OTA file version to be upgraded, and then initiates an upgrade request through HTTP; the Web device management system parses the parameters of the HTTP request, then encapsulates the upgrade parameters in JSON data format, and then sends the OTA upgrade request to the device through MQTT; after receiving the upgrade request, the device parses the message to obtain the IP address and port number of the OTA server, establishes a socket connection with the OTA server, and then requests the OTA server to download the upgrade file; after receiving the socket request, the OTA server selects the signed OTA file of the corresponding version according to the request parameters, then reads the OTA file data and sends it to the device; after downloading the upgrade file, the device verifies the signature of the file, and after the verification passes, calls the system's upgrade interface to upgrade, and finally restarts the device to complete the upgrade; After the OTA server downloads the upgrade file, it also includes: upgrade file signature verification, which is used to sign the OTA file based on the RSA private key, and is also used to verify the signature mark of the OTA file based on the RSA public key; The file signature format is: Signature file = original file + signature information; signature information = signature header information + signature data; signature header information = magic word + key fingerprint + signature time + reserved; the magic word is 0x3C4D5E6F as a signature mark, which is used to quickly determine whether the file contains a signature; the key fingerprint is the MD5 value based on the public key data; the signature time is the signing time of the file; the reserved field is for future expansion; The terminal device includes several sensors; The perception layer includes: a main program and a sensor acquisition subroutine; The main program is used to establish a wireless network connection, report the sensor measurement data and process remote control commands through the wireless network, and the remote control commands include: device control instructions and OTA upgrade instructions; The main program flow includes: After initializing WiFi and establishing a network connection, initialize the MQTT client, set the message callback function address, establish a connection with the MQTT server according to its IP address and port number, and subscribe to the MQTT message of the specified topic; then update the sensor data regularly and determine whether it needs to be uploaded. If it needs to be uploaded, encapsulate the sensor data in JSON format and report the information through MQTT; if a message is received from the MQTT server, the system will execute the message callback function; when processing the MQTT message, first parse the content of the message to obtain the remote command type, and then perform related operations according to the command type; if the command type is a device control command, further parse the command parameters of the device control, and control the state of the LED or motor according to the parameters; if the command type is an OTA upgrade command, further parse the command parameters to obtain the IP address and port number of the OTA server, and then connect to the OTA server according to the IP address and port number, request and download the upgrade file and verify its signature. After the verification passes, call the upgrade interface of the Hi3861 system for upgrade; The sensor acquisition subroutine is used to read and update the sensor measurement data.
