Data transmission method and device between edge gateway and cloud server
The heartbeat packet mechanism is used to optimize data transmission between edge gateways and cloud servers, reduce the number of connections and network traffic, solve the problems of data transmission delay and network instability of IoT devices in remote areas, and improve network efficiency and maintainability of terminal equipment. .
Patent Information
- Application Number
- CN202210107049.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-28
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-01-28
AI Technical Summary
When IoT devices are deployed in remote areas, the data transmission delay and network bandwidth usage of edge gateways and cloud servers are high, and the unstable network environment causes connection interruptions, affecting the real-time data transmission and maintenance efficiency of the equipment.
The heartbeat packet mechanism is used to reduce the number of connections between the edge gateway and the cloud server. Connections are only established when there is data transmission, online status information is transmitted first, and information to be uploaded is stored offline for regular uploading, reducing network traffic and storage usage.
It reduces network delays and network costs, improves network usage efficiency, ensures real-time data reporting and maintenance of IoT terminal devices, and reduces the probability of failures.
Smart Images

Figure CN114401167B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of Internet of Things device control, and specifically relates to a data transmission method and device between an edge gateway and a cloud server. Background Art
[0002] At present, the development of the Internet of Things has entered the cloud era, which integrates the Internet of Things with the Internet. In this integrated comprehensive network, there are server clusters with super powerful computing capabilities, which can control and manage the Internet of Things terminal devices.
[0003] Although this type of network brings great convenience, it also generates massive amounts of data in the cloud server due to the large number of edge gateways and terminal devices, which slows down the network response speed. If the generated data is processed in the cloud server, the network load will increase greatly and the data will be delayed. Therefore, at the edge of the network, edge computing is needed to generate, analyze, and process data, which is edge computing.
[0004] Unlike the mature and widely used deployment environment of the traditional Internet, the Internet of Things is often deployed in remote areas where there is no network signal or the signal is unstable. At this time, wireless solutions cannot meet such network environments or wireless signals are easily interfered with, resulting in intermittent network connections and freezes, which in turn affects the Internet of Things' ability to perceive the working status of network terminal devices.
[0005] For example, the integrated pole box is an infrastructure that integrates wireless communication, smart lighting, video surveillance, traffic management, environmental monitoring and other functions. The integrated pole box operation and maintenance system adopts the deployment method of edge gateway and edge computing. The number of integrated pole boxes is large and the relative density is large. The many edge gateways of the integrated pole box operation and maintenance system have a large amount of data every day because of the various types of terminal devices mounted on them and the high data volume. Therefore, the network of the integrated pole box operation and maintenance system has a large amount of data that is processed and analyzed by the edge gateway and then uploaded to the cloud server. At the same time, the cloud server has new update operations and sends them to the edge gateway through the same network. In addition, the regular maintenance content of the edge gateway of the integrated pole box operation and maintenance system also includes the reduction or increase of terminal devices mounted on the gateway, as well as the upload and download functions of the edge gateway and the cloud server in daily work, so that the gateway can allow the backup of configuration information when it is allowed, and download cloud server data. The edge gateway contacts the cloud server every once in a while to report the online status and working condition of the edge gateway of the cloud server. Therefore, the edge gateway should check the status of the subordinate equipment and the working condition of the edge gateway every once in a while and report it to the cloud server. The cloud server issues a maintenance work order according to the working condition uploaded by the specific gateway. After connecting to the edge gateway, the cloud server receives the terminal device data reported by the edge gateway, fills it into the database, and displays, alarms, and prompts maintenance personnel, including the device host, device name, device type, inspection time, inspection results, and device status, which correspond to the edge gateway name, terminal device name, and device type respectively; the inspection time is the time reported by the edge gateway, the inspection results are closed or pop-up status, and the device status is normal or abnormal, so as to issue a maintenance work order for the edge gateway. However, the previous information records of this edge gateway are generally not deleted so that the information of this edge gateway can be rolled back.
[0006] However, due to subjective and objective factors, the edge gateway often cannot ensure that it can be online all the time. For example, tripping due to extreme weather, lightning strikes, human theft and other working conditions may occur. At the same time, because the deployment location and position of the edge gateway are often difficult to access the network or the network environment is unstable, the edge gateway cannot maintain the ability to stay online at any time, which also makes it impossible to fully guarantee the data transmission from the cloud server to the edge gateway or from the edge gateway to the cloud server. This invention is here. Summary of the invention
[0007] In view of the above-mentioned technical problems, the purpose of the present invention is to provide a data transmission method and device between an edge gateway and a cloud server, which reduces the number of connections between the edge gateway and the cloud server during the data transmission process, reduces network traffic, and makes the edge gateway not need too much network guarantee time, thereby additionally reducing network bandwidth occupancy and network costs, reducing network delays, and improving network utilization efficiency.
[0008] The technical solution of the present invention is:
[0009] A data transmission method between an edge gateway and a cloud server, comprising the following steps:
[0010] S01: The edge gateway sends a heartbeat packet to connect to the cloud server;
[0011] S02: When the cloud server has data to send to the edge gateway, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the edge gateway that there is data to send, and the edge gateway establishes a data transmission connection with the cloud server to download the data from the cloud server;
[0012] S03: When the edge gateway has information to upload to the cloud server, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the cloud server that there is information to upload, and the edge gateway establishes a data transmission connection with the cloud server; if the cloud server has no data to be sent, the edge gateway uploads the information to the cloud server; if the cloud server has data to be sent, the edge gateway first pauses uploading information and downloads the data from the cloud server. After the data download is completed, the edge gateway uploads the information;
[0013] S04: When the cloud server has no data to be sent and the edge gateway has no information to be uploaded, when the edge gateway sends a heartbeat packet to connect to the cloud server to inform that there is no data to be sent or uploaded, the communication connection is interrupted.
[0014] In the preferred technical solution, after the downloading of data in step S03 is completed, the downloaded data is compared with the information to be uploaded. If it is rollback information, the edge gateway stops uploading information and deletes the information to be uploaded; if it is not rollback information, the edge gateway uploads the information.
[0015] In the preferred technical solution, in step S03, the current information to be uploaded is stored in the gateway device online status information table. If the edge gateway fails to upload the information, the edge gateway stores the current information that failed to be uploaded in the edge gateway device online historical status information table.
[0016] In the preferred technical solution, when the edge gateway uploads information, it first transmits the data in the online status information table of the gateway device, and then uploads the data in the online historical status information table of the gateway device.
[0017] In the preferred technical solution, after the edge gateway establishes a data transmission connection with the cloud server, it detects whether the edge gateway is online. If the time for the cloud server to establish a communication connection with the edge gateway is greater than a threshold, the edge gateway is determined to be offline. When the edge gateway is offline, the information to be uploaded is stored in the gateway device online historical status information table.
[0018] In the preferred technical solution, the edge gateway periodically deletes normal maintenance information stored in the online historical status information table of the edge gateway device, and retains abnormal information.
[0019] The present invention also discloses a data transmission device between an edge gateway and a cloud server, comprising at least one edge gateway connected to the cloud server, the edge gateway being connected to at least one terminal device, and the edge gateway comprising:
[0020] Heartbeat packet sending module, used by the edge gateway to send heartbeat packets to connect to the cloud server;
[0021] Data transmission module, used to download or upload data;
[0022] A comparison module compares the downloaded data with the information to be uploaded;
[0023] The cloud server comprises:
[0024] Data transmission connection module, the edge gateway establishes a data transmission connection with the cloud server;
[0025] Analysis and processing module: when the cloud server has data to send to the edge gateway, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the edge gateway that there is data to send, and the edge gateway establishes a data transmission connection with the cloud server to download the data from the cloud server;
[0026] When the edge gateway has information to upload to the cloud server, it sends a heartbeat packet to connect to the cloud server to inform the cloud server that there is information to upload, and the edge gateway establishes a data transmission connection with the cloud server; if the cloud server has no data to be sent, the edge gateway uploads the information to the cloud server; if the cloud server has data to be sent, the edge gateway first pauses uploading information and downloads the data from the cloud server. After the data download is completed, the edge gateway uploads the information;
[0027] When the cloud server has no data to be sent and the edge gateway has no information to be uploaded, when the edge gateway sends a heartbeat packet to connect to the cloud server to inform that there is no data to be sent or uploaded, the communication connection is interrupted.
[0028] In the preferred technical solution, the edge gateway also includes a storage module, which stores the current information to be uploaded in the gateway device online status information table. If the edge gateway fails to upload the information, the edge gateway stores the current information that failed to be uploaded in the edge gateway device online historical status information table.
[0029] In the preferred technical solution, when the edge gateway uploads information, it first transmits the data in the online status information table of the gateway device, and then uploads the data in the online historical status information table of the gateway device.
[0030] In the preferred technical solution, after the edge gateway establishes a data transmission connection with the cloud server, it detects whether the edge gateway is online. If the time for the cloud server to establish a communication connection with the edge gateway is greater than a threshold, the edge gateway is determined to be offline. When the edge gateway is offline, the information to be uploaded is stored in the gateway device online historical status information table.
[0031] Compared with the prior art, the present invention has the following beneficial effects:
[0032] 1. The edge gateway of the present invention establishes a connection with the cloud server only when there is data transmission. No connection is established when there is no data to be transmitted. Therefore, the number of connections between the gateway and the cloud server is reduced in the data transmission process between the edge gateway and the cloud server. This subjectively reduces network traffic and objectively conforms to the reality that the edge gateway cannot keep the network online at all times.
[0033] 2. If the edge gateway fails to upload information, that is, the real-time information of the edge gateway is not uploaded to the cloud server, it will be transferred to the online historical status information table of the gateway device and wait for the cloud server to connect to the edge gateway before transmitting. This design enables the edge gateway to play an effective role in data transmission between the edge gateway and the cloud server when the network online time cannot be guaranteed, so that daily gateway and terminal equipment maintenance work and equipment change information of the gateway terminal can be reported to the cloud server in real time. In terms of system design, the edge gateway does not need too much network guarantee time, thereby additionally reducing network bandwidth occupancy and network costs, reducing network latency, and improving network utilization efficiency.
[0034] 3. In addition, the deletion judgment mechanism of the gateway's historical information is to delete the normal maintenance information (because the normal maintenance information has no retention value, and relatively speaking, the normal maintenance value of the gateway is the majority), and retain the fault information (relatively speaking, the maintenance fault value of the gateway is a minority), which reduces the edge gateway's occupation of storage space and improves the efficiency and speed of gateway operation. At the same time, saving and reporting the fault information to the cloud server improves the maintenance and statistical efficiency of the IoT terminal equipment, which can further reduce the occurrence of network terminal equipment failures in a targeted manner, and also supports the use of statistical data for the maintainability design of the terminal equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The present invention will be further described below in conjunction with the accompanying drawings and embodiments:
[0036] Figure 1 It is a flow chart of the data transmission method between the edge gateway and the cloud server of the present invention;
[0037] Figure 2 It is a working diagram of the data transmission device between the edge gateway and the cloud server of the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. In addition, in the following description, the description of well-known structures and technologies is omitted to avoid unnecessary confusion of the concept of the present invention.
[0039] Example
[0040] like Figure 1 As shown, a data transmission method between an edge gateway and a cloud server includes the following steps:
[0041] S01: The edge gateway sends a heartbeat packet to connect to the cloud server;
[0042] S02: When the cloud server has data to send to the edge gateway, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the edge gateway that there is data to send, and the edge gateway establishes a data transmission connection with the cloud server to download the data from the cloud server;
[0043] S03: When the edge gateway has information to upload to the cloud server, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the cloud server that there is information to upload, and the edge gateway establishes a data transmission connection with the cloud server; if the cloud server has no data to be sent, the edge gateway uploads the information to the cloud server; if the cloud server has data to be sent, the edge gateway first pauses uploading information and downloads the data from the cloud server. After the data download is completed, the edge gateway uploads the information;
[0044] S04: When the cloud server has no data to be sent and the edge gateway has no information to be uploaded, when the edge gateway sends a heartbeat packet to connect to the cloud server to inform that there is no data to be sent or uploaded, the communication connection is interrupted.
[0045] In a preferred embodiment, after the download of data in step S03 is completed, the downloaded data is compared with the information to be uploaded. If it is rollback information, the edge gateway stops uploading the information and deletes the information to be uploaded; if it is not rollback information, the edge gateway uploads the information, and then determines whether the information needs to be uploaded after the rollback information takes effect.
[0046] In a preferred embodiment, in step S03, the current information to be uploaded is stored in the gateway device online status information table. If the edge gateway fails to upload the information, the edge gateway stores the current information that failed to be uploaded in the edge gateway device online historical status information table.
[0047] In a preferred embodiment, when the edge gateway uploads information, it first transmits the data in the online status information table of the gateway device, and then uploads the data in the online historical status information table of the gateway device.
[0048] In a preferred embodiment, after the edge gateway establishes a data transmission connection with the cloud server, it detects whether the edge gateway is online. If the time for the cloud server to establish a communication connection with the edge gateway is greater than a threshold, the edge gateway is determined to be offline. When the edge gateway is offline, the information to be uploaded is stored in the gateway device online historical status information table.
[0049] In a preferred embodiment, the edge gateway periodically deletes normal maintenance information stored in the online historical status information table of the edge gateway device and retains abnormal information.
[0050] In another embodiment, the present invention further discloses a data transmission device between an edge gateway and a cloud server, comprising at least one edge gateway connected to the cloud server, the edge gateway being connected to at least one terminal device, and the edge gateway comprising:
[0051] Heartbeat packet sending module, used by the edge gateway to send heartbeat packets to connect to the cloud server;
[0052] Data transmission module, used to download or upload data;
[0053] A comparison module compares the downloaded data with the information to be uploaded;
[0054] The cloud server comprises:
[0055] Data transmission connection module, the edge gateway establishes a data transmission connection with the cloud server;
[0056] Analysis and processing module: when the cloud server has data to send to the edge gateway, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the edge gateway that there is data to send, and the edge gateway establishes a data transmission connection with the cloud server to download the data from the cloud server;
[0057] When the edge gateway has information to upload to the cloud server, it sends a heartbeat packet to connect to the cloud server to inform the cloud server that there is information to upload, and the edge gateway establishes a data transmission connection with the cloud server; if the cloud server has no data to be sent, the edge gateway uploads the information to the cloud server; if the cloud server has data to be sent, the edge gateway first suspends uploading information and downloads the data from the cloud server. After the data is downloaded, the downloaded data is compared with the information to be uploaded. If it is rollback information, the edge gateway stops uploading information; if it is not rollback information, the edge gateway uploads information;
[0058] When the cloud server has no data to be sent and the edge gateway has no information to be uploaded, when the edge gateway sends a heartbeat packet to connect to the cloud server to inform that there is no data to be sent or uploaded, the communication connection is interrupted.
[0059] like Figure 2As shown, the specific working process of the data transmission device is as follows:
[0060] A. The gateway sends a detection message heartbeat packet to the cloud server.
[0061] B. The cloud server looks for the Mac address of the gateway that sent the heartbeat packet.
[0062] C. If the cloud server contains the Mac address of the gateway that sends the heartbeat packet, connect to the cloud server, otherwise determine whether the cloud server has registered the Mac address of the gateway that sends the heartbeat packet.
[0063] D. If the connection to the cloud server is successful or the gateway Mac address for sending heartbeat packets is registered, the gateway determines whether there is instant information. If the connection to the cloud server fails or the cloud server does not register the gateway Mac address for sending heartbeat packets, the program ends.
[0064] E. If the gateway has instant information, it will send the instant information. If the sending is successful, the gateway device online status information table will be marked as uploaded successfully (the Mark field is assigned a value of 1). The gateway will then determine whether there is any historical information to be sent. If the gateway has no instant information to send, it will also determine whether there is any historical information to be sent.
[0065] F. If the gateway has instant information but fails to send it, the instant information will be retained in the gateway database; if it is determined that there is no historical information to be sent, the program ends.
[0066] G. If the gateway has historical information to send but fails to send, the historical information will still be saved in the gateway database, and the program will end; if the historical information is sent successfully, the mark field in the gateway device online historical status information table will be marked as uploaded successfully (the Mark field is assigned a value of 1), and then the historical information records with normal daily maintenance information in the database will be deleted, and the program will end.
[0067] Specific:
[0068] 1. System gateway determines the purpose of maintenance
[0069] Due to changes in the working status of the IoT sensor devices under the edge gateway, offline (disconnected) and other factors, the edge gateway also needs to contact the cloud server at regular intervals to report the online status and working conditions of the edge gateway to the cloud server. Therefore, the edge gateway needs to check the status of the subordinate devices and the working conditions of the edge gateway at regular intervals and report to the cloud server. The cloud server issues a maintenance work order based on the working conditions uploaded by the specific gateway.
[0070] After connecting to the edge gateway, the cloud server receives the terminal device data reported by the edge gateway, fills it into the database, and displays, alarms, and prompts maintenance personnel, including the device host, device name, device type, inspection time, inspection results, and device status, which correspond to the edge gateway name, terminal device name, and device type respectively; the inspection time is the time reported by the edge gateway, the inspection results are closed or pop-up status, and the device status is normal or abnormal, so as to issue a maintenance work order for the edge gateway.
[0071] 2. If the operation and maintenance is to reduce the number of terminal devices, the gateway that reduces the devices should determine whether the amount of data collected by it has stopped. If so, it should report to the cloud server gateway that the terminal devices have been reduced. If the operation and maintenance is to increase or replace the terminal devices, it should determine whether the collected data of the gateway that increases or replaces the devices is consistent. If so, it should upload to the cloud server gateway that the terminal devices have been added. If not, it should return to the gateway to determine the purpose of maintenance (i.e. the previous step).
[0072] After the edge gateway successfully connects to the cloud server, the gateway reports the terminal device change information, and the cloud server records the changed information of the edge gateway into the database, but does not delete the previous information record of this edge gateway so that the information of this edge gateway can be rolled back.
[0073] 3. Synchronize to the server.
[0074] The MQTT protocol is used to synchronize the gateway to the cloud server. The priority of edge gateway data generation is 1, gateway preset strategy execution method 2, device parameter update method 3, and gateway log generation method.
[0075] If a terminal device fails, the edge gateway will record the timestamp, normal and abnormal information of the failure, and form a gateway log. These logs will be uploaded to the cloud server platform and play an active and important role in subsequent maintenance and troubleshooting. The gateway log is recorded in the gateway operation log table, which records the main field information such as the id of the control device, the type of device operated, the name of the device operated, the type of operation, the source of the operation, and the content involved in the operation; the operation source of the log includes both the automatic strategy of the gateway at this level, the instructions issued by the cloud platform and the user's on-site access control. Regardless of the operation mode and whether the operation is successful, the database will record the operation content and record it in the database log note information (status field information), record whether the execution is successful, and upload it to the cloud server. Whenever the gateway issues an operation instruction to the terminal device or performs normal device terminal maintenance, regardless of whether the operation is successful, the gateway will record the operation content accordingly and upload it to the cloud server.
[0076] The data transmission process between the gateway and the cloud server is as follows:
[0077] The data transmission between the gateway and the cloud server is divided into three stages: gateway physical address registration preparation stage, heartbeat packet waiting stage and data transmission stage.
[0078] ① Gateway physical address registration preparation stage
[0079] The preparation stage for gateway physical address registration is mainly that the gateway first reports the gateway Mac address to the cloud server, and then the cloud server registers the gateway's Mac physical address information. After the cloud server records the gateway's Mac address and connects for communication, the gateway collects the collected terminal device information and sends it to the cloud server, thereby achieving the purpose of data upload between the gateway and the cloud server.
[0080] For example, the gateway's Mac address is 45-32-E3-64-4E-F5.
[0081] You can define a variable string gatewayMac= 45-32-E3-64-4E-E5; the gateway reports the local Mac address of the cloud server as gatewayMac. If the cloud server allows communication with it, it stores the gatewayMac address information. Later, the cloud server and the gateway with the Mac address of gatewayMac will automatically establish an MQTT protocol connection.
[0082] ②Heartbeat packet waiting stage (determining whether the gateway is online)
[0083] The gateway sends a detection message heartbeat packet to the cloud server at regular intervals to detect whether it can connect to the cloud server and whether the cloud server has any data modification operations. The time interval between sending a detection message heartbeat packet and sending the next detection message heartbeat packet is called the heartbeat packet waiting phase. The length of the heartbeat packet waiting phase can be set in the gateway according to the timeliness requirements of data transmission. It is generally set to a few minutes. This system adopts manual dynamic input of the heartbeat packet time interval.
[0084] In addition, due to the large number of edge gateways, the edge gateways cannot communicate with the server frequently, otherwise it will occupy network resources and generate a lot of network bandwidth costs. In addition, due to network networking environment issues, it is impossible to guarantee that the edge gateway is always online. Therefore, each time the gateway detects the establishment of a heartbeat packet communication connection, the gateway actively initiates it, so that the edge gateway contacts the cloud server after the network is restored or the heartbeat packet waiting phase ends to inform the cloud server that the edge gateway is online.
[0085] ③Data connection transmission method
[0086] If the cloud server has data to send, the data is first stored in the cloud server operation log, and the heartbeat packet waiting phase is over. When the gateway sends a detection message heartbeat packet to connect to the cloud server, it informs the edge gateway that there is information to send. At this time, the edge gateway first stops uploading the information it wants to upload, establishes a connection with the cloud server, and prepares to download the configuration information of the cloud server. After downloading the information, it compares it with the information it wants to upload. If it is rollback information, the edge gateway deletes the information it wants to upload (no need to upload it again), and waits for the rollback information to take effect before judging whether the information needs to be uploaded. If the cloud server has information to send and the edge gateway has not sent a detection message heartbeat packet for a long time or cannot establish a connection, first judge the network problem. If there is no network problem, it can be judged that the edge gateway is offline or faulty.
[0087] The configuration information in the edge gateway is that the field staff will enter the data change information of the terminal device collected into the gateway database gateway device information table in a timely manner. If the edge gateway has new information to upload to the cloud server, the data is also stored in the gateway operation log first. When the edge gateway sends a detection message heartbeat packet to the cloud server, it informs the cloud server that there is information to upload. The edge gateway establishes a connection with the cloud server. If the cloud server has no information to send, the edge gateway uploads the cloud server information. If the cloud server has information to send, the edge gateway will suspend uploading information according to the above, and then determine whether to upload after comparing the downloaded cloud server information.
[0088] If the cloud server and the edge gateway have no data to send or upload, the edge gateway will inform each other that there is no data to send or upload when sending a detection message heartbeat packet to the cloud server. At this time, no data transmission connection is established and the communication is directly interrupted until the next detection message heartbeat packet is sent to determine whether there is data transmission.
[0089] Since there is no need for data transmission between the cloud server and the edge gateway most of the time, this design can effectively reduce the communication time and connection times between the cloud server and the edge gateway.
[0090] ④Data transmission
[0091] When the heartbeat packet waiting phase is over, if the cloud server or gateway has data to send or upload, the cloud server establishes a connection with the edge gateway for data transmission. The cloud server sends the operation parameter data configuration information to the gateway configuration parameter table, and then the edge gateway uploads the information data to the cloud server. For the deletion of routine maintenance information, the gateway deletes the normal data information and retains and uploads the fault information.
[0092] Transmission process: When data transmission starts, the edge gateway first establishes a connection with the cloud server through the MQTT protocol; after the connection is established, the edge gateway first downloads and obtains the data modification operation of the cloud server. If the gateway data still needs to be uploaded after comparison, the edge gateway will upload the parameter configuration data information marked as not uploaded (the Mark field is assigned a value of 0) according to the mark field in the online status information table of the collected gateway device to the cloud server. After the upload is successful, the mark field (Mark field) is assigned a value of 1. After the data transmission is completed, the edge gateway disconnects from the cloud server until the gateway's heartbeat packet waiting time expires and then sends a detection message heartbeat packet again to determine whether there is data transmission.
[0093] When collecting data information, it is necessary to consider the offline situation, so the system's breakpoint resume function is particularly important to ensure data continuity, especially when the network signal is not stable. The basic idea is:
[0094] A. Gateway offline is determined based on the interaction with the cloud server using the MQTT protocol, so it can detect whether the edge gateway is online or offline. However, due to the network connection status, there are intervals in data transmission, so the data transmission is unstable.
[0095] B. The parameter configuration data stored in the online status information table of the gateway device is real-time, while the parameter configuration data stored in the online historical status information table of the gateway device is the historical parameter configuration data that has not been uploaded to the cloud server. Therefore, the parameter configuration data to be transmitted must be stored in the online status information table of the gateway device first. If the connection time between the gateway and the cloud server ends, the gateway automatically goes offline. At this time, the gateway stores the parameter configuration data that has not been uploaded in the online historical status information table of the gateway device. This information field in the online historical status information table of the gateway device is marked as not uploaded (the Mark field is assigned a value of 0), and the online status information table of the gateway device only stores the parameter configuration data of the current time. The next time the gateway establishes a connection with the cloud server, the real-time parameter configuration data in the online status information table of the gateway device is still transmitted first. If the gateway is still offline, the parameter configuration data of the current time is stored in the online historical status information table of the gateway device again, and the Mark field is assigned a value of 0, marking it as not uploaded, and so on.
[0096] The gateway device online status information table (gate_devonline) is as follows:
[0097] Name Data Type Code OnLineID INT Device online record ID dcode VARCHAR(32) Device physical address code UpperCount VARCHAR(32) Trigger limit times UpperThresHealthy VARCHAR(32) Trigger upper threshold health UpperThreshold VARCHAR(32) Upper threshold reference value LowerCount VARCHAR(32) Trigger lower limit times LowerThresHealthy VARCHAR(32) Trigger lower threshold health LowerThreshold VARCHAR(32) Lower threshold reference value DevAddr VARCHAR(32) Device physical address OnlineName VARCHAR(32) Device sampling value SamplingTimeInterval VARCHAR(32) The time interval between the sampling interval and the last sampling interval, in milliseconds OnlineTime VARCHAR(32) Last online time DevStyle VARCHAR(32) Device Type DevValue VARCHAR(32) Device sampling value DevUnit VARCHAR(32) Sampling data unit OnlineHealthy VARCHAR(32) Equipment online health value MaintainStatus VARCHAR(32) Maintenance Information Mark INT Is the information uploaded? Remarks VARCHAR(32) Equipment Notes CREATED_BY VARCHAR(32) Founder CREATED_TIME DATETIME Creation time
[0098] The online history status information of the gateway device (gate_devonlinehistory) is as follows:
[0099] Name Data Type Code OnLineID INT Device online record ID dcode VARCHAR(32) Device physical address code UpperCount VARCHAR(32) Trigger limit times UpperThresHealthy VARCHAR(32) Trigger upper threshold health UpperThreshold VARCHAR(32) Upper threshold reference value LowerCount VARCHAR(32) Trigger lower limit times LowerThresHealthy VARCHAR(32) Trigger lower threshold health LowerThreshold VARCHAR(32) Lower threshold reference value DevAddr VARCHAR(32) Device physical address OnlineName VARCHAR(32) Device sampling value SamplingTimeInterval VARCHAR(32) The time interval between the sampling interval and the last sampling interval, in milliseconds OnlineTime VARCHAR(32) Last online time DevStyle VARCHAR(32) Device Type DevValue VARCHAR(32) Device sampling value DevUnit VARCHAR(32) Sampling data unit OnlineHealthy VARCHAR(32) Equipment online health value MaintainStatus VARCHAR(32) Maintenance Information Mark INT Historical information upload mark Remarks VARCHAR(32) Equipment Notes CREATED_BY VARCHAR(32) Founder CREATED_TIME DATETIME Creation time
[0100] C. When the edge gateway changes from offline to online, the parameter configuration data stored in the edge gateway is uploaded and reported together with the detection message heartbeat packet. The real-time parameter configuration data in the online status information table of the gateway device is uploaded first. After the upload is successful, the uploaded parameter configuration data is dumped into the online status information table of the gateway device, and the Mark field is assigned a value of 1, marking it as uploaded. Then the historical parameter configuration data in the online historical status information table of the gateway device is uploaded. At the same time, the uploaded information record Mark field is assigned a value of 1, marking it as uploaded. If there is new modified configuration operation data in the cloud server operation record, the edge gateway will download the modified parameter configuration data in the cloud server operation record after the parameter configuration data upload is completed. If the transmission is interrupted or the network is disconnected, the cloud server determines that the transmission has failed and resends it at the next connection. When the gateway enters the next heartbeat packet waiting phase, if the terminal device connected to the gateway has parameter configuration data changes, the gateway will back up the parameter configuration data.
[0101] D. If human error occurs during the maintenance of the edge gateway, the edge gateway will frequently display error prompts when monitoring the data of the terminal device. In this case, the edge gateway will upload error prompt information to the cloud server, and the cloud server will issue a work order. After confirmation by the on-site personnel, the rollback instruction will be input to the edge gateway. The edge gateway will upload the rollback request information to the cloud server. The cloud server will dump the previous information in the stored edge gateway configuration information to the cloud server operation log, and wait for the edge gateway to send a detection message heartbeat packet to download this configuration information and reconfigure it.
[0102] E. Define the integer variable regular as int regular = 10, define the integer variable heartbeat as intheartbeat = 240, and define the integer variable cycleT as int cycleT = 3;
[0103] If the gateway loses power, the gateway timer will be cleared. After power-on, the gateway timer will re-time the heartbeat packet by subtracting the regular (seconds) duration from the heartbeat packet waiting phase duration. When the gateway re-detects the cloud server after the regular (seconds) duration, the cloud server determines whether the gateway is online. If it is online, it will connect and send data. If the heartbeat packet waiting phase duration is set within the heartbeat (seconds) duration, and the cloud server cannot contact the gateway for cycleT heartbeat packet waiting phase time periods, the cloud server determines that the gateway is offline. If the cloud server loses power, the gateway will send a detection message after the heartbeat packet waiting phase ends. At this time, the cloud server cannot respond to the gateway, and the gateway and the cloud server cannot connect, and then enter the next heartbeat packet waiting phase until the cloud server is powered on.
[0104] 4. The program ends.
[0105] It should be understood that the above specific embodiments of the present invention are only used to illustrate or explain the principles of the present invention, and do not constitute a limitation of the present invention. Therefore, any modifications, equivalent substitutions, improvements, etc. made without departing from the spirit and scope of the present invention should be included in the protection scope of the present invention. In addition, the appended claims of the present invention are intended to cover all changes and modifications that fall within the scope and boundaries of the appended claims, or the equivalent forms of such scope and boundaries.
Claims
1. A data transmission method between an edge gateway and a cloud server, characterized in that: The following steps are involved: S01: The edge gateway sends a heartbeat packet to connect to the cloud server. The edge gateway sends a detection message heartbeat packet to the cloud server at regular intervals to detect whether it can connect to the cloud server and whether the cloud server has any data modification operations. Each time the detection message heartbeat packet communication connection is established, it is actively initiated by the edge gateway. S02: When the cloud server has data to send to the edge gateway, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the edge gateway that there is data to send, and the edge gateway establishes a data transmission connection with the cloud server to download the data from the cloud server; S03: When the edge gateway has information to upload to the cloud server, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the cloud server that there is information to upload, and the edge gateway establishes a data transmission connection with the cloud server; if the cloud server has no data to be sent, the edge gateway uploads the information to the cloud server; If the cloud server has data to send, the edge gateway will first suspend uploading information and download the data from the cloud server. After the data download is completed, the edge gateway will upload the information; S04: When the cloud server has no data to be sent and the edge gateway has no information to be uploaded, when the edge gateway sends a heartbeat packet to connect to the cloud server to inform that there is no data to be sent or uploaded, the communication connection is interrupted; In the step S03, the current information to be uploaded is stored in the gateway device online status information table. If the edge gateway fails to upload the information, the edge gateway stores the information that failed to be uploaded in the edge gateway device online historical status information table; The gateway device online status information table is: The gateway device online historical status information table is: The parameter configuration data stored in the online status information table of the gateway device is real-time, and the historical parameter configuration data in the online historical status information table of the gateway device is the historical parameter configuration data that has not been uploaded to the cloud server. Therefore, the parameter configuration data to be transmitted must be stored in the online status information table of the gateway device first. If the connection time between the gateway and the cloud server ends, the gateway automatically goes offline. At this time, the gateway stores the parameter configuration data that has not been uploaded in the online historical status information table of the gateway device. The Mark field in the online historical status information table of the gateway device is assigned a value of 0, and the online status information table of the gateway device only stores the current parameter configuration data. The next time the gateway establishes a connection with the cloud server, the real-time parameter configuration data in the online status information table of the gateway device is still transmitted first. If the gateway is still offline, the current parameter configuration data is stored in the online historical status information table of the gateway device again, and the Mark field is assigned a value of 0, marking it as not uploaded, and so on. When the edge gateway changes from an offline state to an online state, the parameter configuration data stored in the edge gateway is uploaded and reported together with the detection message heartbeat packet. The real-time parameter configuration data in the online status information table of the gateway device is uploaded first. After the upload is successful, the uploaded parameter configuration data is dumped into the online status information table of the gateway device, and the Mark field is assigned a value of 1, marking it as uploaded. Then, the historical parameter configuration data in the online historical status information table of the gateway device is uploaded. At the same time, the Mark field of the uploaded information record is assigned a value of 1, marking it as uploaded. If there is new modified configuration operation data in the cloud server operation record, the edge gateway downloads the modified parameter configuration data in the cloud server operation record after the parameter configuration data is uploaded. If the transmission is interrupted or the network is disconnected, the cloud server determines that the transmission fails and resends it at the next connection. When the gateway enters the next heartbeat packet waiting phase, if the terminal device connected to the gateway has parameter configuration data changes, the gateway backs up the parameter configuration data.
2. The data transmission method between the edge gateway and the cloud server according to claim 1, characterized in that: After the downloading of data in step S03 is completed, the downloaded data is compared with the information to be uploaded. If it is rollback information, the edge gateway stops uploading information and deletes the information to be uploaded; if it is not rollback information, the edge gateway uploads the information.
3. The data transmission method between the edge gateway and the cloud server according to claim 1, characterized in that: After the edge gateway establishes a data transmission connection with the cloud server, it detects whether the edge gateway is online. If the time for the cloud server to establish a communication connection with the edge gateway is greater than a threshold, the edge gateway is determined to be offline. When the edge gateway is offline, the information to be uploaded is stored in the gateway device online historical status information table.
4. The data transmission method between the edge gateway and the cloud server according to claim 1, characterized in that: The edge gateway periodically deletes normal maintenance information stored in the edge gateway device online historical status information table and retains abnormal information.
5. A data transmission device between an edge gateway and a cloud server, characterized in that: The device comprises at least one edge gateway connected to a cloud server, the edge gateway being connected to at least one terminal device, and the edge gateway comprising: The heartbeat packet sending module is used for the edge gateway to send heartbeat packets to connect to the cloud server; the edge gateway sends a detection message heartbeat packet to the cloud server at regular intervals to detect whether it can connect to the cloud server and whether the cloud server has any data modification operations. Each time the detection message heartbeat packet communication connection is established, it is actively initiated by the edge gateway; Data transmission module, used to download or upload data; A comparison module compares the downloaded data with the information to be uploaded; The cloud server comprises: Data transmission connection module, the edge gateway establishes a data transmission connection with the cloud server; Analysis and processing module: when the cloud server has data to send to the edge gateway, the edge gateway sends a heartbeat packet to connect to the cloud server to inform the edge gateway that there is data to send, and the edge gateway establishes a data transmission connection with the cloud server to download the data from the cloud server; When the edge gateway has information to upload to the cloud server, it sends a heartbeat packet to connect to the cloud server to inform the cloud server that there is information to upload, and the edge gateway establishes a data transmission connection with the cloud server; if the cloud server has no data to be sent, the edge gateway uploads the information to the cloud server; if the cloud server has data to be sent, the edge gateway first pauses uploading information and downloads the data from the cloud server. After the data download is completed, the edge gateway uploads the information; When the cloud server has no data to be sent and the edge gateway has no information to be uploaded, when the edge gateway sends a heartbeat packet to connect to the cloud server to inform that there is no data to be sent or uploaded, the communication connection is interrupted; The edge gateway also includes a storage module, which stores the current information to be uploaded in the gateway device online status information table. If the edge gateway fails to upload the information, the edge gateway stores the information that failed to be uploaded in the edge gateway device online historical status information table; The gateway device online status information table is: The online historical status information of the gateway device is: The parameter configuration data stored in the online status information table of the gateway device is real-time, and the historical parameter configuration data in the online historical status information table of the gateway device is the historical parameter configuration data that has not been uploaded to the cloud server. Therefore, the parameter configuration data to be transmitted must be stored in the online status information table of the gateway device first. If the connection time between the gateway and the cloud server ends, the gateway automatically goes offline. At this time, the gateway stores the parameter configuration data that has not been uploaded in the online historical status information table of the gateway device. The Mark field in the online historical status information table of the gateway device is assigned a value of 0, and the online status information table of the gateway device only stores the current parameter configuration data. The next time the gateway establishes a connection with the cloud server, the real-time parameter configuration data in the online status information table of the gateway device is still transmitted first. If the gateway is still offline, the current parameter configuration data is stored in the online historical status information table of the gateway device again, and the Mark field is assigned a value of 0, marking it as not uploaded, and so on. When the edge gateway changes from an offline state to an online state, the parameter configuration data stored in the edge gateway is uploaded and reported together with the detection message heartbeat packet. The real-time parameter configuration data in the online status information table of the gateway device is uploaded first. After the upload is successful, the uploaded parameter configuration data is dumped into the online status information table of the gateway device, and the Mark field is assigned a value of 1, marking it as uploaded. Then, the historical parameter configuration data in the online historical status information table of the gateway device is uploaded. At the same time, the Mark field of the uploaded information record is assigned a value of 1, marking it as uploaded. If there is new modified configuration operation data in the cloud server operation record, the edge gateway downloads the modified parameter configuration data in the cloud server operation record after the parameter configuration data is uploaded. If the transmission is interrupted or the network is disconnected, the cloud server determines that the transmission fails and resends it at the next connection. When the gateway enters the next heartbeat packet waiting phase, if the terminal device connected to the gateway has parameter configuration data changes, the gateway backs up the parameter configuration data.
6. The data transmission device between the edge gateway and the cloud server according to claim 5, characterized in that: After the edge gateway establishes a data transmission connection with the cloud server, it detects whether the edge gateway is online. If the time for the cloud server to establish a communication connection with the edge gateway is greater than a threshold, the edge gateway is determined to be offline. When the edge gateway is offline, the information to be uploaded is stored in the gateway device online historical status information table.
Citation Information
Patent Citations
Data breakpoint resuming scheme based on Mqtt protocol
CN111770143A
Meter reading data transmission method and system, slave equipment, and storage medium
CN112669591A
Industrial system for data acquisition and edge calculation
CN112671893A
Data transmission method and device and computer readable storage medium
CN113691591A
