Device upgrading method and device, computer device and computer readable storage medium

By using a remote upgrade method between the gateway and the device, and utilizing the data packets in the upgrade package file to upgrade the device, the problem of low upgrade efficiency in existing technologies is solved, and a highly efficient device upgrade process is achieved.

CN116009908BActive Publication Date: 2026-06-02RUINA INTELLIGENT EQUIP CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
RUINA INTELLIGENT EQUIP CO LTD
Filing Date
2022-12-16
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

In existing technologies, upgrading equipment in industrial settings is inefficient, requires manual intervention, and is time-consuming and labor-intensive, thus affecting work efficiency.

Method used

The system connects to the device via a gateway, divides the upgrade package file into multiple data packets, and performs remote batch upgrades using upgrade start commands and transmission commands. The device automatically verifies and completes the upgrade without manual intervention.

Benefits of technology

It enables remote batch upgrades of equipment, improves upgrade efficiency, reduces the impact on industrial site operations, and enhances user satisfaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116009908B_ABST
    Figure CN116009908B_ABST
Patent Text Reader

Abstract

The application discloses a device upgrading method and device, computer equipment and computer readable storage medium, the method comprises the following steps: receiving the upgrading start instruction sent by the gateway; if the target device type matches the device type of the current device, the target device version matches the device version of the current device, and the target upgrade package version is higher than the upgrade package version of the current device, it is determined that the current device is a device that needs to be upgraded; receiving the upgrade transmission instruction sent by the gateway; in the case that it is determined that a plurality of data packets obtained by dividing the upgrade package file are received based on the upgrade transmission instruction, the current device is upgraded by using the upgrade package file. Thus, without manual intervention in the industrial field, remote batch upgrading of devices meeting the conditions can be realized, and the efficiency of device upgrading can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of remote upgrade technology, and in particular to a device upgrade method, apparatus, computer equipment, and computer-readable storage medium. Background Technology

[0002] Equipment manufacturers often need to upgrade industrial field equipment in order to improve its performance and extend its lifespan.

[0003] In related technologies, upgrades typically require specialized engineers to go to the industrial site, disassemble the equipment casing, and use a programmer to reprogram the equipment. This method is time-consuming and inefficient. Summary of the Invention

[0004] This invention aims to at least partially solve one of the technical problems in related technologies. Therefore, the first objective of this invention is to provide a method for upgrading equipment that enables remote, batch upgrades of qualified equipment without manual intervention in industrial settings, thereby effectively improving the efficiency of equipment upgrades.

[0005] The second objective of this invention is to provide a device upgrade method for gateways.

[0006] The third objective of this invention is to provide a device for upgrading equipment.

[0007] The fourth objective of this invention is to provide a device upgrade apparatus for use in gateways.

[0008] The fifth objective of this invention is to provide a computer device.

[0009] The sixth object of the present invention is to provide a computer-readable storage medium.

[0010] To achieve the above objectives, a first aspect of the present invention provides a device upgrade method. The device is connected to a gateway via a bus, and the gateway stores an upgrade package file for device upgrades, the upgrade package file being divided into several data packets. The method includes: receiving an upgrade initiation command sent by the gateway; wherein the upgrade initiation command includes a target device type, a target device version, and a target upgrade package version; if the target device type matches the current device type, the target device version matches the current device version, and the target upgrade package version is higher than the current device's upgrade package version, then the current device is determined to be a device requiring upgrade; receiving an upgrade transmission command sent by the gateway; and, if the upgrade transmission command determines that the several data packets have been received, upgrading the current device using the upgrade package file.

[0011] According to one embodiment of the present invention, before receiving the upgrade transmission instruction sent by the gateway, the device upgrade method further includes: erasing the flash memory space of the current device and clearing the data reception flag in the random access storage space of the current device, so that the current device enters the state of receiving upgrade package files.

[0012] According to one embodiment of the present invention, the upgrade transmission instruction further includes the sequence number of the current data packet, a data packet length threshold, the packet length of the current data packet, and the packet data of the current data packet; determining that the plurality of data packets have been received based on the upgrade transmission instruction includes: storing the packet data of the current data packet in the flash memory space based on the sequence number of the current data packet, and filling the random access memory space with the current reception flag of the current data packet; if the packet length of the current data packet is less than the data packet length threshold, determining that the plurality of data packets have been received based on the reception flag filled in the random access memory space.

[0013] According to one embodiment of the present invention, the upgrade start command further includes the upgrade package file length and upgrade package file verification data; the step of upgrading the current device using the upgrade package file includes: if the package data in the flash memory space passes the verification of the upgrade package file length and the upgrade package file verification data, upgrading the current device based on the package data in the flash memory space.

[0014] According to one embodiment of the present invention, the upgrade startup instruction further includes a file identifier; the process of upgrading the current device using the upgrade package file includes: if an upgrade flag is detected in the storage space of the current device, executing the startup program of the current device; erasing the application area corresponding to the file identifier during the execution of the startup program; writing the upgrade package file into the application area; and restarting the current device to upgrade the current device.

[0015] According to one embodiment of the present invention, receiving the upgrade start instruction sent by the gateway includes: receiving the upgrade start instruction sent multiple times by the gateway according to a first preset delay; receiving the upgrade transmission instruction sent by the gateway includes: receiving the upgrade transmission instruction sent multiple times by the gateway according to a second preset delay.

[0016] According to one embodiment of the present invention, the current device is in a message receiving state; the current device does not respond to or confirm the upgrade initiation command and upgrade transmission command sent to the gateway.

[0017] To achieve the above objectives, a second aspect of the present invention provides a device upgrade method applied to a gateway, wherein the gateway is connected to at least one device via a bus; the gateway stores an upgrade package file for device upgrades, the upgrade package file being divided into several data packets; the device upgrade method includes: sending an upgrade initiation command to the at least one device; wherein the upgrade initiation command includes a target device type, a target device version, and a target upgrade package version; the upgrade initiation command is used to determine that the current device is a device requiring a device upgrade if the target device type matches the current device's device type, the target device version matches the current device's device version, and the target upgrade package version is higher than the current device's upgrade package version; and sending an upgrade transmission command to the current device; wherein the upgrade transmission command is used to instruct the current device to perform a device upgrade using the upgrade package file if the several data packets have been received based on the upgrade transmission command.

[0018] According to one embodiment of the present invention, the device upgrade method further includes: receiving a device upgrade instruction; wherein the device upgrade instruction includes a target device type, a target device version, a target upgrade package version, and an upgrade package access address; and downloading the upgrade package file according to the target device type, the target device version, the target upgrade package version, and the upgrade package access address.

[0019] To achieve the above objectives, a third aspect of the present invention provides a device upgrade apparatus. The device is connected to a gateway via a bus, and the gateway stores an upgrade package file for device upgrades, the upgrade package file being divided into several data packets. The apparatus includes: an upgrade start command receiving module, configured to receive an upgrade start command sent by the gateway; wherein the upgrade start command includes a target device type, a target device version, and a target upgrade package version; a device determination module, configured to determine that the current device is a device requiring upgrade if the target device type matches the current device type, the target device version matches the current device version, and the target upgrade package version is higher than the current device's upgrade package version; an upgrade transmission command receiving module, configured to receive an upgrade transmission command sent by the gateway; and a device upgrade module, configured to upgrade the current device using the upgrade package file after determining that the several data packets have been received based on the upgrade transmission command.

[0020] To achieve the above objectives, a fourth aspect of the present invention provides a device upgrade apparatus applied to a gateway, the gateway being connected to at least one device via a bus; the gateway storing an upgrade package file for device upgrades, the upgrade package file being divided into several data packets; the apparatus comprising: an upgrade start command sending module, configured to send an upgrade start command to the at least one device; wherein the upgrade start command includes a target device type, a target device version, and a target upgrade package version; the upgrade start command is configured to determine that the current device is a device requiring a device upgrade if the target device type matches the current device's device type, the target device version matches the current device's device version, and the target upgrade package version is higher than the current device's upgrade package version; and an upgrade transmission command sending module, configured to send an upgrade transmission command to the current device; wherein the upgrade transmission command is configured to instruct the current device, upon determining that the several data packets have been received based on the upgrade transmission command, to perform a device upgrade using the upgrade package file.

[0021] To achieve the above objectives, a fifth aspect of the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described in any of the foregoing embodiments.

[0022] To achieve the above objectives, a sixth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the method described in any of the preceding embodiments.

[0023] According to various embodiments of the present invention, a gateway sends upgrade initiation commands and upgrade transmission commands to multiple connected devices. The devices receive the upgrade initiation commands and upgrade transmission commands, and perform corresponding verification and upgrades based on the received commands. The upgrade initiation commands can be used to filter and select devices to be upgraded, and the upgrade transmission commands are used to transmit upgrade package files to the devices to be upgraded. After confirming that the upgrade package file has been received, the devices to be upgraded can use the upgrade package file to perform device upgrades. This invention enables remote batch upgrades of eligible devices without manual intervention in industrial settings, effectively improving the efficiency of device upgrades.

[0024] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0025] Figure 1a This is a schematic diagram illustrating an application scenario of a device upgrade method provided according to one embodiment of this specification.

[0026] Figure 1b This is a schematic diagram illustrating the process of a gateway receiving and sending instructions according to one embodiment of this specification.

[0027] Figure 1c This is a schematic flowchart of a device upgrade method provided according to one embodiment of this specification.

[0028] Figure 1d This is a schematic diagram illustrating the process of determining a plurality of data packets to complete the reception according to one embodiment of this specification.

[0029] Figure 2 This is a schematic flowchart of a device upgrade method provided according to one embodiment of this specification.

[0030] Figure 3 This is a schematic flowchart of a device upgrade method provided according to one embodiment of this specification.

[0031] Figure 4a This is a schematic flowchart of a device upgrade method provided according to one embodiment of this specification.

[0032] Figure 4b This is a schematic diagram of the cloud platform software, gateway, and device provided according to one embodiment of this specification.

[0033] Figure 5 This is a structural block diagram of an equipment upgrade apparatus provided according to one embodiment of this specification.

[0034] Figure 6 This is a structural block diagram of an equipment upgrade apparatus provided according to one embodiment of this specification.

[0035] Figure 7 This is a structural block diagram of a computer device provided according to one embodiment of this specification. Detailed Implementation

[0036] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.

[0037] With the substantial investment in national infrastructure and the development of the industrial sector, the application of industrial equipment is becoming increasingly widespread. Because industrial equipment has a long service life, and the demands on industrial sites are often constantly changing, equipment manufacturers frequently need to upgrade their equipment to improve its performance and extend its lifespan.

[0038] In related technologies, when industrial equipment needs upgrading, such as when its proprietary software or programs need to be upgraded, on-site upgrades and remote upgrades are commonly used. On-site upgrades require a professional engineer to go to the site, disassemble the equipment, and reprogram it using a programmer. This method consumes significant manpower and resources. Furthermore, to avoid inconsistencies in operation or usage before and after the upgrade, the equipment needs to be shut down until the engineer completes the upgrade, thus impacting work efficiency in the industrial setting.

[0039] In related technologies, remote upgrade methods typically involve upgrading devices one-to-one, such as through a host computer or gateway. Since the host computer or gateway usually connects to multiple industrial field devices, this one-to-one upgrade method can only upgrade one device at a time, and other devices cannot be upgraded until the current device is upgraded, resulting in low upgrade efficiency. If a large number of devices need to be upgraded, it consumes significant time, severely impacting user experience and industrial field work efficiency.

[0040] To effectively improve the efficiency of equipment upgrades in industrial settings, it is necessary to propose an equipment upgrade method, apparatus, computer equipment, and computer-readable storage medium. The method involves sending upgrade initiation and transmission commands to multiple connected devices via a gateway's equipment upgrade service. Each device receives these commands and performs corresponding verification and upgrades based on the received instructions. The upgrade initiation command can be used to filter and select devices, identifying those meeting matching criteria as upgrade candidates. These candidates can then receive the upgrade transmission command, which transmits multiple data packets derived from a segmented upgrade package file. After verifying the correctness and integrity of the received data packets, the upgrade candidate can restart to complete the upgrade process. By pre-agreed upgrade rules between the gateway and the devices, remote batch upgrades of eligible devices can be achieved without manual intervention in the industrial setting, effectively improving upgrade efficiency. Furthermore, during the upgrade process, the devices only need to restart for a few seconds to complete the upgrade, minimizing the impact on industrial site efficiency and significantly improving user satisfaction.

[0041] Figure 1a The diagram shown illustrates an application scenario of a device upgrade method provided in this specification. Taking a smart heating pipeline system including a cloud platform, gateway, and field equipment as an example, refer to... Figure 1aAs shown, the cloud platform can connect to several gateways via mobile communication networks, wireless LANs, or Ethernet. Each gateway can be connected to field devices via a fieldbus. These field devices can include several electricity meters, several water meters, and several valves. Each device includes information such as its type, version, and upgrade package version. By default, the devices are in a state where they can receive messages.

[0042] In this scenario example, when a program upgrade is required for on-site equipment, a device upgrade command is sent to the gateway via the cloud platform. This command includes information such as the target device type, target device version, target upgrade package version, and upgrade package access address. Upon receiving the upgrade command, the gateway downloads the corresponding upgrade package file from the cloud platform via a file transfer protocol and then decompresses it. If decompression is successful, the gateway initiates the device upgrade service. Based on data such as the target device type, target device version, target upgrade package version, the decompressed upgrade package file, upgrade package file length, upgrade package file CRC value, and file identifier, the device upgrade service generates an upgrade start command according to the message format used for communication between the gateway and the device, and broadcasts the upgrade start command to the bus. Each device connected to the gateway receives the upgrade start command transmitted from the bus and, according to pre-agreed rules, matches its own device type with the target device type, matches its own device version with the target device version, and compares its own upgrade package version with the target upgrade package version. The device whose device type and version are the same as the target device type and version, but whose upgrade package version is lower than the target upgrade package version, is the device to be upgraded. The device to be upgraded can receive upgrade transmission commands. The device to be upgraded erases its flash memory space and clears data reception flags, etc., to enable the device to receive upgrade package files.

[0043] For example, continue to refer to Figure 1aAs shown, several electricity meters connected to Gateway 1 have the same meter version and meter reading program version, requiring an upgrade to the meter reading program of the meters connected to Gateway 1. An electricity meter upgrade command is sent to Gateway 1 via the cloud platform. Upon receiving the command, Gateway 1 downloads the corresponding upgrade package file from the cloud platform via Hypertext Transfer Protocol and then decompresses it. If decompression is successful, Gateway 1 initiates the device upgrade service. The upgrade service generates an upgrade start command based on information such as meter type, meter version, and meter reading program upgrade package version, and broadcasts the command to the bus. The electricity meters, water meters, and valves connected to Gateway 1 receive the upgrade start command transmitted from the bus and perform corresponding matching. The electricity meter type and version must match the command, and the meter reading program version must be lower than the command's upgrade package version. The water meters and valves cannot match the command's meter type. Therefore, the electricity meters connected to Gateway 1 are the devices to be upgraded. The meters erase their flash memory to receive the upgrade transmission command. Water meters and valves that do not match will not receive upgrade transmission commands and will be discarded directly.

[0044] The gateway's device upgrade service divides the decompressed upgrade package file into several data packets according to a data packet length threshold. Based on the sequence number, data packet length threshold, data packet length, and data packet content, it generates corresponding upgrade transmission instructions according to the message format used for communication between the gateway and the device. The gateway's device upgrade service sends the upgrade transmission instructions sequentially according to the data packet sequence number until all data packets have been sent. After receiving the upgrade transmission instruction, the device to be upgraded stores the data packet content attached to the instruction in the flash memory and fills the receive flag bit corresponding to the data packet sequence number in the RAM memory, so that the device to be upgraded can determine whether all the data packets corresponding to the upgrade package file have been received.

[0045] In this scenario example, the device to be upgraded compares the data packet length threshold attached to the received upgrade transmission command with the packet length of the data packet. When the packet length is found to be less than the data packet length threshold, the device to be upgraded considers this data packet to be the last data packet corresponding to the upgrade package file. After receiving the last data packet corresponding to the upgrade package file, the device to be upgraded can determine whether all data packets corresponding to the upgrade package file have been received, based on the sequence number of the data packets in the RAM memory and their corresponding receive flag bits.

[0046] In this example scenario, the device receives the upgrade initiation command and upgrade transmission command using a receive-only, no-acknowledgement method. Considering the potential for packet loss during communication between the gateway and the device via the fieldbus, to ensure the device fully receives the commands sent by the gateway and the accompanying data, the gateway's device upgrade service retransmits the upgrade initiation command and upgrade transmission command multiple times. For example, Figure 1b This is a flowchart illustrating the process of receiving device upgrade commands, sending upgrade initiation commands, and upgrading transmission commands through a gateway. (Reference) Figure 1b As shown, the cloud platform sends a device upgrade command to the gateway. After receiving the command, the gateway downloads the compressed upgrade package from the cloud platform and decompresses it. If decompression fails, it indicates a download failure, and the gateway reports this failure to the cloud platform. If decompression is successful, the gateway starts the device upgrade service. The gateway's device upgrade service sends the first upgrade start command to the device, with a 1-second delay; sends the second command, with a 1-second delay; and sends the third command, with a 1-second delay. The gateway's device upgrade service then sends the first upgrade transmission command to the device, sequentially sending commands from the first packet according to their sequence number. After each data packet's corresponding transmission command is sent, there is a 1-second delay before sending the next command, continuing this process until all commands are sent, with a 1-second delay. The second transmission command is sent in the same manner, with a 1-second delay, and the third transmission command is sent in the same manner, continuing this process until all commands are sent. Afterward, the gateway can exit the device upgrade service.

[0047] Accordingly, the device to be upgraded can repeatedly receive upgrade transmission commands. After receiving the last data packet corresponding to the upgrade package file, the device to be upgraded determines whether all data packets corresponding to the upgrade package file have been received, and continues to receive upgrade transmission commands. Each time the device to be upgraded receives an upgrade transmission command, it can determine whether the data packet corresponding to the sequence number of the data packet attached to the upgrade transmission command has been received based on the sequence number of the data packet in the RAM memory and its corresponding receive flag bit. If it has been received, it is discarded directly; if it has not been received, the device to be upgraded stores the packet data of the data packet attached to the upgrade transmission command in the flash memory space and fills the corresponding receive flag bit in the RAM.

[0048] In this scenario example, after confirming that all data packets corresponding to the upgrade package file have been received, the device to be upgraded calculates the length and CRC value of the packet data in the flash memory space. This is then compared with the upgrade package file length and CRC value attached to the upgrade startup command to verify the correctness and integrity of the packet data. After successful verification, the device to be upgraded sets an upgrade flag in the flash memory space to instruct it to restart. When the startup program of the device to be upgraded executes, it locates the packet data in the flash memory space based on the upgrade flag, erases the application area corresponding to the file identifier in the device to be upgraded, writes the packet data from the flash memory space into that application area, then clears the packet data and the upgrade flag from the flash memory space, and restarts again. When the startup program executes again, it can jump to application execution. At this point, the device to be upgraded completes the upgrade process.

[0049] This specification provides a device upgrade method. The device is connected to a gateway via a bus. The gateway stores an upgrade package file for device upgrades, and the upgrade package file is divided into several data packets. (See reference...) Figure 1c As shown, the method may include the following steps.

[0050] S110: Receive the upgrade start command sent by the gateway. The upgrade start command includes the target device type, target device version, and target upgrade package version.

[0051] The upgrade package files can be partitioned at the gateway. The upgrade initiation command is generated based on the message format used for communication between the gateway and the device, and can be used to filter and select target devices that need to be upgraded. The target device type refers to the type of device that needs to be upgraded, such as heat meters, electricity meters, water meters, valves, controllers, etc., and can be used to filter and select different devices connected to the same gateway bus. The target device version refers to the device version corresponding to the target device type, and can be used to filter and select different device versions corresponding to the same target device type. The target upgrade package version can be used to filter and select the upgrade package version of the corresponding program in the device.

[0052] Understandably, due to the characteristics of the communication protocol, the data transmitted between the gateway and the device needs to strictly conform to the message format corresponding to the communication protocol. Therefore, the upgrade startup command is generated based on the message format used for communication between the gateway and the device.

[0053] In some cases, gateways typically connect to multiple types of devices. Devices of the same type may have multiple different versions, and different versions of the same type of device may have different functionalities. Furthermore, devices of the same type and version may have different application or file versions. For example, some smart meters of the same type and version may have been installed earlier, and their meter reading programs or font files are not the latest versions, while other smart meters may have been recently installed and have the latest version of their meter reading programs or font files. When the gateway cannot directly identify the target device that needs upgrading and send the upgrade package file to the corresponding target device, rules can be agreed upon between the gateway and the devices to filter and select target devices.

[0054] Specifically, rules for device upgrades can be pre-agreed between the gateway and the device, including the rules for generating upgrade startup commands, the function of the upgrade startup commands, and the operations that the device needs to perform after receiving the upgrade startup commands. Based on these rules, when a device upgrade is required, an upgrade startup command for the target device can be generated according to the message format used for communication between the gateway and the device, based on data such as the target device type, target device version, and target upgrade package version.

[0055] For example, the message format may include a start character, address field, function code, length field, data field, checksum, and end character. Based on the rules agreed upon between the gateway and the device, data such as the target device type, target device version, and target upgrade package version can be filled into the data field of the message format to generate the corresponding upgrade initiation command message.

[0056] In some embodiments, the gateway can broadcast the upgrade start command to the bus. By default, the device is in the state of receiving communication messages. Therefore, any device connected to the gateway can obtain the upgrade start command from the bus for subsequent filtering and screening.

[0057] S120. If the target device type matches the current device type, the target device version matches the current device version, and the target upgrade package version is higher than the current device upgrade package version, then the current device is determined to be the device that needs to be upgraded.

[0058] The current device is the one that received the upgrade initiation command. The upgrade package version can include application version, file version, etc. The device that needs to be upgraded is designated as the device to be upgraded.

[0059] Specifically, the current device contains information such as its device type, device version, and upgrade package version. After receiving the upgrade initiation command, the current device matches its device type with the target device type in the command, matches its device version with the target device version, and compares its upgrade package version with the target upgrade package version. If the current device's device type and version are the same, and its upgrade package version is lower than the target version, then the current device can be identified as the device to be upgraded and can enter the state of receiving the upgrade package file, allowing it to receive subsequent upgrade transmission commands.

[0060] In some embodiments, if the device type of the current device is different from the target device type in the upgrade initiation command, or the device version of the current device is different from the target device version in the upgrade initiation command, or the upgrade package version of the current device is not lower than the target upgrade package version in the upgrade initiation command, then the current device is not the device to be upgraded. The current device can directly discard the received upgrade initiation command and upgrade transmission command.

[0061] In other embodiments, the target device version may not be explicitly specified in the upgrade startup command. For example, if the target device version is not explicitly specified, then the target device version can be 0, and all versions of the device corresponding to the target device type can be successfully matched with the target device version.

[0062] S130: Receive upgrade transmission instructions sent by the gateway.

[0063] The upgrade transmission command is generated based on the message format used for communication between the gateway and the device, and can be used to transmit data packets.

[0064] Specifically, the upgrade transmission command may include the current data packet sequence number and the packet data of the current data packet. The message format used for communication between the gateway and the device may include a start character, address field, function code, length field, data field, checksum, and end character. Based on the rules agreed upon between the gateway and the device, and in the order of the data packets, the corresponding current data packet sequence number and packet data can be filled into the data field of the message format to generate the upgrade transmission command message corresponding to each data packet. The gateway sends the upgrade transmission commands in sequence according to the data packet sequence number until transmission is complete.

[0065] In some embodiments, the gateway can broadcast upgrade transmission instructions to the bus, and the devices are in a state of receiving communication messages by default. Therefore, any device connected to the gateway can obtain upgrade transmission instructions from the bus, but only the device identified as the one to be upgraded can receive and store the relevant data in the upgrade transmission instructions; other devices can discard the received upgrade transmission instructions directly.

[0066] S140. If several data packets have been received based on the upgrade transmission command, upgrade the current device using the upgrade package file.

[0067] The current device is the one awaiting upgrade. Confirmation of successful data packet reception can be determined using the corresponding reception flag on the data packet.

[0068] In some cases, after the gateway has sent the upgrade transmission command, the device to be upgraded needs to determine whether the received data packets are complete, i.e., whether there was any packet loss during the transmission of the upgrade command. If the device to be upgraded determines that the received data packets are complete, it can use the received data packets to perform the device upgrade.

[0069] Specifically, the current device can set a corresponding reception flag for each received data packet. After receiving the upgrade transmission command, the current device stores the packet data of the current data packet contained in the upgrade transmission command. The current device can also fill the reception flag corresponding to the current data packet with "received" and store it for subsequent determination of whether the data packet has been completely received. When the gateway has finished sending the upgrade transmission command, that is, after the current device receives the last data packet corresponding to the upgrade package file, the current device can determine whether all data packets corresponding to the upgrade package file have been completely received based on the stored data packets and their reception flags. If it is determined that all data packets have been completely received, the current device can use the received data packets to perform the corresponding upgrade.

[0070] It should be noted that the upgrade package file can be divided into at least one data packet. Therefore, the current device can determine whether at least one data packet has been successfully received based on the upgrade transmission command.

[0071] In some embodiments, the current device may repeatedly receive upgrade transmission instructions along with data packets corresponding to the upgrade package file. After receiving the last data packet corresponding to the upgrade package file, the current device determines, based on the stored data packets and their reception flags, whether all data packets corresponding to the upgrade package file have been received, and may continue to receive upgrade transmission instructions. Upon receiving any subsequent upgrade transmission instruction, the current device determines whether all data packets corresponding to the upgrade package file have been successfully received.

[0072] In the above implementation, based on the rules for device upgrades pre-agreed between the gateway and the device, the devices are filtered and screened through the upgrade initiation command to determine the devices to be upgraded; the upgrade package file is transmitted to the devices to be upgraded through the upgrade transmission command, which cannot be received by other devices, thereby enabling remote batch upgrades of devices that meet the conditions without the need for manual intervention in the industrial field, which can effectively improve the efficiency of device upgrades.

[0073] In some implementations, before receiving the upgrade transmission instruction sent by the gateway, the device upgrade method may further include: erasing the flash memory space of the current device and clearing the data reception flag in the random access storage space of the current device, so that the current device enters the state of receiving upgrade package files.

[0074] The flash memory space can be a storage unit with electronically erasable programmable capabilities. The random access memory space can be a data storage medium with read / write capabilities at any time. Data reception flags can include data packet reception flags, the number of data packets received, etc.

[0075] Specifically, after confirming that the current device is the device to be upgraded, it erases its flash memory space to prepare for receiving and storing packet data of the data packets attached to the upgrade transmission command. The device also clears the data reception flags in the random access memory (RAM) space to facilitate reading, writing, and storing the corresponding reception flags and other data during the reception and storage of packet data. At this point, the device has the storage space to receive data packets and enters the state of receiving upgrade package files. This allows the device to store the packet data of the data packets attached to the upgrade transmission command into the flash memory space and fill the corresponding reception flags into the RAM space after receiving the upgrade transmission command.

[0076] Understandably, for devices that are not the device to be upgraded, the corresponding flash memory space will not be erased, nor will the data reception flag in the random access storage space be cleared, thus preventing them from entering the state of receiving the upgrade package file. Even if these devices receive the upgrade transmission command, they cannot store the relevant data in the upgrade transmission command, thereby ensuring that only the device to be upgraded can be upgraded.

[0077] In some implementations, the upgrade transmission command also includes the sequence number of the current data packet, the data packet length threshold, the packet length of the current data packet, and the packet data of the current data packet. (See reference) Figure 1d As shown, determining the completion of receiving several data packets based on the upgrade transmission command may include the following steps.

[0078] S142. Based on the sequence number of the current data packet, store the packet data of the current data packet in the flash memory space, and fill the current reception flag of the current data packet in the random access memory space.

[0079] The sequence number of the data packet is the corresponding sequence number assigned to each data packet after the upgrade package file is divided into several data packets, and the sequence numbers of the data packets have an order relationship. The data packet length threshold is the length of the data packets used to divide the upgrade package file into data packets. The packet length is the length of the packet data of the current data packet contained in the upgrade transmission command. The current reception flag may include the sequence number of the current data packet and the reception flag bit.

[0080] Specifically, the upgrade transmission command may include the sequence number of the current data packet, the data packet length threshold, the packet length of the current data packet, and the packet data of the current data packet. The gateway sends the upgrade transmission command sequentially according to the sequence number of the data packets until all packets have been sent. After receiving the upgrade transmission command, the current device can store the corresponding packet data of the current data packet in the flash memory space based on the sequence number of the current data packet attached to the upgrade transmission command, and fill the receive flag bit in the random access memory space with the sequence number of the received current data packet to indicate that the current data packet has been received.

[0081] Understandably, since the upgrade transmission command message undergoes correctness verification based on the checksum attached to the message during transmission, the receive flag can be used to indicate whether the data packet with the corresponding sequence number has been correctly received. Once the device receives the current data packet attached to the upgrade transmission command and fills in the current receive flag for that data packet, it can indicate that the current data packet has been correctly received.

[0082] In some embodiments, the receive flag can be a single bit, which can be 1 to indicate that the data packet with the corresponding sequence number has been received, and 0 to indicate that the data packet with the corresponding sequence number has not been received.

[0083] S144. If the length of the current data packet is less than the data packet length threshold, determine several data packets to complete the reception based on the reception flags filled in the random access storage space.

[0084] In some cases, after dividing the upgrade package file into at least one data packet according to a data packet length threshold, the last data packet may not be a full packet, meaning its length is less than the threshold. This can be used to determine whether the data packets corresponding to the upgrade package file have been transmitted completely. Therefore, rules can be agreed upon between the gateway and the device, including the generation rules for upgrade transmission commands and their functions. Upon receiving an upgrade transmission command, the device can compare the data packet length threshold attached to the command with the length of the current data packet to determine if the current data packet in the command is the last data packet corresponding to the upgrade package file. This allows for further determination of whether the upgrade package file has been transmitted completely, enabling the device to ascertain whether all data packets corresponding to the upgrade package file have been received.

[0085] Specifically, after identifying the current device as the device to be upgraded, the current device receives the upgrade transmission command sent by the gateway. The current device compares the data packet length threshold attached to the command with the packet length of the current data packet. If the packet length of the current data packet is less than the data packet length threshold, the current device can determine that the current data packet is the last data packet corresponding to the upgrade package file. The current device can determine whether all data packets corresponding to the upgrade package file have been received completely based on the stored data packets and their reception flags. If it is determined that all data packets have been received completely, the current device can perform the corresponding upgrade using the stored packet data.

[0086] It should be noted that the packet length threshold can be set according to the connection method between the gateway and the device. For example, if the gateway and the device are connected wirelessly, a relatively small packet length threshold can be set; if the gateway and the device are connected wiredly, a relatively large packet length threshold can be set.

[0087] In some embodiments, the length of the upgrade package file can be an integer multiple of the data packet length threshold. After dividing the upgrade package file according to the data packet length threshold, the length of the last data packet obtained is the same as the data packet length threshold. The current device cannot determine that this data packet is the last data packet according to the above comparison rules. At this time, corresponding rules can be set in the gateway so that the gateway can determine the length of the last data packet obtained from the division. If the length of this data packet is the same as the data packet length threshold, the gateway can send an upgrade transmission command corresponding to an empty data packet after sending the upgrade transmission command corresponding to this data packet. This allows the current device to determine that the empty data packet is the last data packet according to the above comparison rules, thereby enabling subsequent actions.

[0088] Furthermore, the current device can repeatedly receive upgrade transmission commands. If the length of the current data packet is less than the data packet length threshold, the current device determines that the current data packet is the last data packet corresponding to the upgrade package file that needs to be received. The current device can continue to repeatedly receive upgrade transmission commands, each containing relevant data for each data packet corresponding to the upgrade package file, and after each subsequent receipt of any upgrade transmission command, it determines whether all data packets corresponding to the upgrade package file have been received based on the reception flag in the random access storage space.

[0089] For example, if the upgrade package file is 14,500 bytes long, dividing it into 1,500-byte segments results in 10 data packets with sequence numbers 1 through 10. The data packet with sequence number 10 has a length of 1,000 bytes. Upon receiving the upgrade transmission instructions corresponding to sequence numbers 1 through 10, the device stores the packet data of the data packets attached to the transmission instructions in the flash memory and fills the corresponding receive flag bits (1 through 10) in the random access memory (RAM) to indicate that all 10 data packets have been correctly received. If the length of the data packet with sequence number 10 is less than the 1,500-byte data packet length threshold, the device determines that this is the last data packet. Based on the receive flags in the RAM, the device can confirm that all 10 data packets have been successfully received. Furthermore, the device can continue receiving upgrade transmission instructions and, upon receiving any subsequent data packet corresponding to sequence numbers 1 through 10, can confirm that all 10 data packets have been successfully received. Once it is confirmed that all data has been received, the current device can be prepared for upgrade.

[0090] If one of the 10 data packets is not received, for example, the second data packet is not received, then the receive flag corresponding to data packet sequence number 2 in the random access memory is set to 0. If the current device compares the packet length of data packet sequence number 10 and finds it to be less than the data packet length threshold of 1500 bytes, it determines that this data packet is the last data packet. Based on the receive flag in the random access memory, the current device can determine that not all 10 data packets have been correctly received. Furthermore, the current device can continue to receive upgrade transmission commands, and upon receiving an upgrade transmission command with data packet sequence number 1 or any data packet sequence number 3 to 10, it can determine, based on the receive flag in the random access memory, that not all 10 data packets have been correctly received. Upon receiving an upgrade transmission command with data packet sequence number 2, the current device stores the packet data of the corresponding data packet in the flash memory and fills the receive flag corresponding to data packet sequence number 2 in the random access memory with 1, thus the current device can immediately determine that all 10 data packets have been successfully received.

[0091] In some embodiments, the flash memory space may be Flash, and the random access memory space may be RAM.

[0092] In some implementations, the upgrade initiation command also includes the upgrade package file length and upgrade package file verification data. Upgrading the current device using the upgrade package file may include: if the package data in the flash memory space passes the verification of the upgrade package file length and upgrade package file verification data, upgrading the current device based on the package data in the flash memory space.

[0093] The upgrade package file length can be used to verify the integrity of the package data. The upgrade package file checksum can be used to verify the correctness and integrity of the package data.

[0094] Specifically, the upgrade initiation command may include the target device type, target device version, target upgrade package version, upgrade package file length, and upgrade package file verification data. After determining that the current device is the device to be upgraded, the current device can save the upgrade package file length and upgrade package file verification data from the upgrade initiation command. If the current device determines that all data packets corresponding to the upgrade package file have been received, it can calculate the length of all packet data stored in the flash memory space and compare it with the previously saved upgrade package file length to verify the integrity of the received packet data. The current device can also calculate the verification data of all packet data stored in the flash memory space and compare it with the previously saved upgrade package file verification data to verify the correctness and integrity of the received packet data. If the packet data in the flash memory space passes the verification of the upgrade package file length and upgrade package file verification data, the current device can prepare for the upgrade, using the packet data in the flash memory space to upgrade the device. In some embodiments, the verification data may be a CRC checksum.

[0095] In some implementations, the upgrade startup command also includes a file identifier. (See reference) Figure 2 As shown, upgrading the current device using an upgrade package file can include the following steps.

[0096] S210. If an upgrade flag is detected in the storage space of the current device, execute the startup procedure of the current device.

[0097] The file identifier can be used to indicate the target application region on the current device. The upgrade flag can be used to indicate that the upgrade package file on the current device is ready, prompting the device to reboot. The detection of the upgrade flag can be achieved through the bootloader on the device.

[0098] Specifically, after the package data in the flash memory has been verified by the upgrade package file length and the upgrade package file checksum, the current device can set an upgrade flag in the storage space. This upgrade flag can be detected and read by the bootloader in the current device, thereby causing the current device to restart and execute the boot program to perform the upgrade. In some embodiments, the storage space can be flash memory, and the bootloader can be a boot program.

[0099] S220. Erase the application area corresponding to the file identifier during the execution of the startup program.

[0100] Specifically, during the device reboot process, a boot program is executed. During this process, firstly, the boot program detects the existence of the upgrade package file corresponding to the upgrade package file in the flash memory based on the upgrade flag; secondly, the boot program erases the application in the application area corresponding to the file identifier in order to write the package data corresponding to the upgrade package file.

[0101] It should be noted that the application in the application area corresponding to the file identifier can be a program of application software or a file used to store data or information.

[0102] S230. Write the upgrade package file to the application area and restart the current device to upgrade it. Specifically, after the bootloader erases the program in the application area corresponding to the file identifier, it writes the package data for upgrading the current device from the flash memory to that application area as a new application, and clears the upgrade flag and the package data in the flash memory. The device restarts a second time and executes the bootloader again. When the bootloader executes again, since the upgrade flag and the package data in the flash memory have been cleared, the bootloader can jump to the newly written application for execution. At this point, the current device can complete the upgrade.

[0103] In the above embodiments, the device to be upgraded can complete the upgrade process by executing a startup program based on an upgrade flag, utilizing the package data corresponding to the upgrade package file in the flash memory. The device to be upgraded will only be unable to operate for a short period of time during the restart to complete the upgrade process; its use before and after the restart will not be affected. Typically, the time for restarting to complete the upgrade is within a few seconds; therefore, this device upgrade method has minimal impact on the efficiency of the equipment and the industrial site.

[0104] In some implementations, receiving an upgrade initiation command from the receiving gateway may include receiving an upgrade initiation command sent multiple times by the receiving gateway according to a first preset delay. Receiving an upgrade transmission command from the receiving gateway may include receiving an upgrade transmission command sent multiple times by the receiving gateway according to a second preset delay.

[0105] In some situations, communication via the bus may result in a certain packet loss rate. To improve the success rate of communication on the bus, the gateway can repeatedly send upgrade start commands and upgrade transmission commands. The number of retransmissions can be set based on an assessment of the bus's packet loss rate.

[0106] Specifically, the number of times the gateway repeatedly sends the instruction is set based on the bus packet loss rate. The gateway sends the upgrade start instruction for the first time and waits for a first preset delay until completion; the gateway sends the upgrade start instruction for the second time and waits for completion for the first preset delay; the gateway sends the upgrade start instruction for the third time and waits for completion for the first preset delay... This method continues until the gateway sends the upgrade start instruction the set number of times.

[0107] After the upgrade initiation command is sent, the gateway sends the corresponding upgrade transmission command in the first pass according to the data packet sequence number until the transmission is complete, and then waits for a second preset delay. The gateway then sends the corresponding upgrade transmission command in the second pass according to the data packet sequence number until the transmission is complete, and then waits for a second preset delay. The gateway then sends the corresponding upgrade transmission command in the third pass according to the data packet sequence number until the transmission is complete, and then waits for a second preset delay... This process continues until the gateway has sent the upgrade transmission command in the first pass according to the data packet sequence number a predetermined number of repetitions has been reached. In some embodiments, the first preset delay and the second preset delay can be set according to the bus transmission rate, etc., and the first preset delay can be equal to the second preset delay.

[0108] Furthermore, since the number of upgrade transmission commands corresponds to the number of data packets divided in the upgrade package file, the gateway also needs to wait for a certain preset delay when sending upgrade transmission commands corresponding to adjacent data packet sequence numbers. Specifically, the gateway sends the upgrade transmission command corresponding to the first data packet in the first pass according to the data packet sequence number, and waits for the preset delay; the gateway sends the upgrade transmission command corresponding to the second data packet in the first pass according to the data packet sequence number, and waits for the preset delay; the gateway sends the upgrade transmission command corresponding to the third data packet in the first pass according to the data packet sequence number, and waits for the preset delay... until the gateway sends the upgrade transmission command corresponding to the last data packet in the first pass according to the data packet sequence number, the first pass of the upgrade transmission commands is completed, and then the gateway waits for a second preset delay. The gateway sends the upgrade transmission command corresponding to the first data packet for the second time according to the data packet sequence number, and waits for a preset delay; the gateway sends the upgrade transmission command corresponding to the second data packet for the second time according to the data packet sequence number, and waits for a preset delay; the gateway sends the upgrade transmission command corresponding to the third data packet for the second time according to the data packet sequence number, and waits for a preset delay... until the gateway sends the upgrade transmission command corresponding to the last data packet for the second time according to the data packet sequence number, the second round of sequential transmission of upgrade transmission commands is completed, and then the gateway waits for a second preset delay. This method continues until the gateway sends the upgrade transmission commands sequentially according to the data packet sequence number a set number of repetitions is reached. In some embodiments, the preset delay for waiting to send upgrade transmission commands corresponding to adjacent data packet sequence numbers can be equal to the first preset delay and the second preset delay.

[0109] In some implementations, the current device is in a message receiving state. The current device does not respond to or acknowledge the upgrade initiation command and upgrade transmission command sent to the gateway.

[0110] In some situations, the number of devices connected to the gateway may be large. If each device sends a corresponding response confirmation message to the gateway after receiving the instruction, it may consume a significant amount of bus communication resources, leading to communication anomalies on the bus and a higher packet loss rate. The gateway may also fail to receive the correct response confirmation message. Therefore, devices can adopt a receive-only approach to receive upgrade initiation instructions and upgrade transmission instructions without responding.

[0111] Specifically, by default, the device is in a message receiving state so that all devices connected to the gateway can receive the upgrade initiation command sent by the gateway. The current device receives the upgrade initiation command and matches it, without responding to the upgrade initiation command sent by the gateway. If the current device matches successfully, it can be identified as the device to be upgraded, and then the current device can enter the state of receiving the upgrade package file as described above.

[0112] In some embodiments, when the gateway sends the upgrade start command in a repeated manner, the current device that has already entered the state of receiving the upgrade package file can directly discard the subsequently received upgrade start command.

[0113] Once the current device enters the state of receiving upgrade package files, it can receive upgrade transmission commands. If the gateway sends upgrade transmission commands using a multiple-retransmission method, the current device can repeatedly receive the corresponding upgrade transmission commands multiple times. Specifically, if the packet length of the current data packet attached to the upgrade transmission command is less than a data packet length threshold, the current device determines whether all data packets corresponding to the upgrade package file have been received and can continue receiving upgrade transmission commands. When the current device subsequently receives any upgrade transmission command, if it finds that the receive flag for the sequence number of the current data packet attached to the command in the random access storage space is already received, it discards the upgrade transmission command to avoid repeatedly storing the packet data of the current data packet in the flash memory space. Simultaneously, the current device determines whether all data packets corresponding to the upgrade package file have been received based on the receive flags in the random access storage space. If the current device finds that the receive flag for the sequence number of the current data packet attached to the command in the random access storage space is not received, it stores the packet data of the current data packet attached to the upgrade transmission command and fills the random access storage space with the current receive flag of the current data packet. Simultaneously, the device determines whether all data packets corresponding to the upgrade package file have been received based on the receive flags in the random access storage space. Following this method, if all receive flags ultimately indicate that all data packets have been received, the device determines that all data packets have been received, and the device can then use the upgrade package file to perform the corresponding upgrade.

[0114] For example, if the upgrade package file is 14,500 bytes long, dividing it into 1,500-byte segments results in 10 data packets with sequence numbers 1 through 10. The data packet with sequence number 10 has a length of 1,000 bytes. The gateway sends the corresponding upgrade transmission instructions in sequence from 1 to 10 in the first pass, until completion. After a 2-second delay, the gateway sends the instructions in sequence from 1 to 10 in the second pass, and so on. After a 2-second delay, the gateway sends the instructions in sequence from 1 to 10 in the third pass, until completion.

[0115] Furthermore, when the current device receives data packet with sequence number 10 from the first round of upgrade transmission commands, it can determine that this data packet is the last one by comparison. The current device should determine whether all 10 data packets have been received completely based on the reception flags (including the sequence number and its reception flag bit) corresponding to each data packet with sequence numbers 1 to 10. The current device receives upgrade transmission commands sent by the gateway in the second and third rounds in the order of data packet sequence numbers 1 to 10, and determines whether all 10 data packets have been received completely after each upgrade transmission command is received. If there are unreceived data packets, such as the second data packet, when the current device receives the upgrade transmission command corresponding to data packet sequence number 1 sent by the gateway in the second round, since the reception flag bit corresponding to data packet sequence number 1 is 1, indicating that the data packet has been received completely, the current device directly discards the upgrade transmission command to avoid repeatedly receiving and storing data packets. At the same time, the current device determines whether all 10 data packets have not been received completely based on the reception flags corresponding to each data packet with sequence numbers 1 to 10. After receiving the upgrade transmission command corresponding to sequence number 2 of the data packet sent by the gateway in the second transmission, the current device receives and stores the packet data of the data packet attached to the command, since the receive flag corresponding to data packet sequence number 2 is 0, and fills the receive flag corresponding to data packet sequence number 2 with 1. At this time, the current device can immediately determine that all 10 data packets have been received based on the receive flags corresponding to data packets with sequence numbers 1 to 10, and the current device can prepare for the upgrade.

[0116] This specification provides a device upgrade method applied to a gateway, wherein at least one device is connected to the gateway via a bus; the gateway stores an upgrade package file for device upgrades, the upgrade package file being divided into several data packets. (See reference) Figure 3 As shown, the device upgrade method may include the following steps.

[0117] S310. Send an upgrade start command to at least one device. The upgrade start command includes the target device type, target device version, and target upgrade package version.

[0118] The upgrade start command is used to determine that the current device needs to be upgraded if the target device type matches the current device type, the target device version matches the current device version, or the target upgrade package version is higher than the current device's upgrade package version.

[0119] S320. Send an upgrade transmission command to the current device. The upgrade transmission command instructs the current device to upgrade itself using an upgrade package file, provided that several data packets have been received according to the upgrade transmission command.

[0120] It should be noted that for the description of the device upgrade method applied to the gateway in the above embodiments, please refer to the description of the device upgrade method in this specification, which will not be repeated here.

[0121] In some embodiments, the gateway can send an upgrade initiation command through the device upgrade service, and divide the upgrade package file into at least one data packet and send an upgrade transmission command through the device upgrade service.

[0122] In some implementations, reference Figure 4a As shown, the equipment upgrade method may also include the following steps.

[0123] S410, Receive device upgrade command. The device upgrade command includes the target device type, target device version, target upgrade package version, and upgrade package access address.

[0124] The device upgrade command can be sent via a cloud server. The upgrade package access address can be the access address of the upgrade package file stored on the cloud server, enabling the gateway to retrieve the corresponding upgrade package file from the cloud server.

[0125] Specifically, the gateway can connect to the cloud server via a network. When an upgrade is needed for a specific target device connected to the gateway, the cloud server can send a device upgrade command to the gateway.

[0126] S420: Download the upgrade package file based on the target device type, target device version, target upgrade package version, and upgrade package access address.

[0127] Specifically, the gateway can request the corresponding upgrade package file from the cloud server via a file transfer protocol, based on the target device type, target device version, target upgrade package version, and upgrade package access address. After obtaining the upgrade package file, the gateway can initiate the subsequent device upgrade process.

[0128] In some embodiments, the device upgrade instruction may be sent through cloud platform software on a cloud server, and the upgrade package file may be stored in the cloud platform software in the form of a compressed package.

[0129] For example, a device upgrade command is sent to the gateway via the cloud platform software. Upon receiving the upgrade command, the gateway downloads the corresponding upgrade package file (compressed file) from the cloud platform software via HTTP (Hypertext Transfer Protocol) based on the target device type, target device version, target upgrade package version, and upgrade package access address. The gateway decompresses the downloaded upgrade package file. If decompression is successful, the download is successful; if decompression fails, the download fails, and the gateway reports the failure to the cloud platform software. If decompression is successful, the gateway uses the target device type, target device version, target upgrade package version, and the decompressed upgrade package file from the upgrade command to generate a corresponding upgrade initiation command and sends it to the device to start the upgrade process. The gateway also divides the decompressed upgrade package file into at least one data packet to generate an upgrade transmission command, which is then sent to the device for the upgrade.

[0130] In some embodiments, the cloud platform software may include an upgrade service module and several business service modules. The gateway may be an intermediate layer device for connecting the device and the cloud server, and may include a 4G / 5G network maintenance module, an Ethernet maintenance module, a web page service module, a protocol processing module, a device upgrade module, etc. The gateway can connect to the cloud server via 4G / 5G mobile communication networks, Wi-Fi wireless LANs, Ethernet, etc. The device may include a startup program module, an application module, etc., and is typically connected to the gateway via a wired connection. (Reference) Figure 4b As shown, the cloud platform software connects to the gateway, enabling the cloud platform software to send device upgrade commands to the gateway, and the gateway to download the corresponding upgrade package file from the cloud platform software. The gateway connects to the device, enabling the gateway to send upgrade initiation commands and upgrade transmission commands to the device.

[0131] This specification provides a device upgrade apparatus. The device is connected to a gateway via a bus. The gateway stores upgrade package files for device upgrades, and the upgrade package files are divided into several data packets. (See reference) Figure 5 As shown, the device upgrade device 500 may include: an upgrade start command receiving module 510, a device determination module 520, an upgrade transmission command receiving module 530, and a device upgrade module 540.

[0132] The upgrade startup command receiving module 510 is used to receive the upgrade startup command sent by the gateway; wherein the upgrade startup command includes the target device type, target device version, and target upgrade package version.

[0133] The device determination module 520 is used to determine the current device as the device that needs to be upgraded if the target device type matches the current device type, the target device version matches the current device version, or the target upgrade package version is higher than the current device upgrade package version.

[0134] The upgrade transmission instruction receiving module 530 is used to receive upgrade transmission instructions sent by the gateway.

[0135] The device upgrade module 540 is used to upgrade the current device using an upgrade package file when several data packets have been received based on the upgrade transmission command.

[0136] This specification also provides a device upgrade apparatus applied to a gateway, wherein at least one device is connected to the gateway via a bus; the gateway stores an upgrade package file for device upgrades, the upgrade package file being divided into several data packets. (See reference) Figure 6 As shown, the device upgrade apparatus 600 may include: an upgrade start command sending module 610 and an upgrade transmission command sending module 620.

[0137] The upgrade start command sending module 610 is used to send an upgrade start command to at least one device; wherein, the upgrade start command includes the target device type, the target device version, and the target upgrade package version; the upgrade start command is used to determine that the current device is the device that needs to be upgraded if the target device type matches the current device's device type, the target device version matches the current device's device version, and the target upgrade package version is higher than the current device's upgrade package version.

[0138] The upgrade transmission instruction sending module 620 is used to send an upgrade transmission instruction to the current device; wherein, the upgrade transmission instruction is used to instruct the current device to upgrade the current device using an upgrade package file after determining that a number of data packets have been received based on the upgrade transmission instruction.

[0139] Specific limitations regarding the equipment upgrade device can be found in the limitations of the equipment upgrade method described above, and will not be repeated here. Each module in the aforementioned equipment upgrade device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0140] This specification also provides a computer device, see embodiments thereof. Figure 7As shown, the computer device 700 includes a memory 710, a processor 720, and a computer program 730 stored in the memory 710 and executable on the processor 720. When the processor 720 executes the computer program 730, it implements the device upgrade method of any of the aforementioned embodiments.

[0141] Embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the device upgrade method of any of the foregoing embodiments.

[0142] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0143] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: logic gate circuits having logic functions for implementing data signals.

[0144] Discrete logic circuits, application-specific integrated circuits with suitable combinational logic gates, programmable gate arrays (PGAs), and field-programmable gate arrays (FPGAs), etc.

[0145] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms are not necessarily...

[0146] This refers to the same embodiments or examples. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0147] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0148] 5. In this invention, unless otherwise expressly specified and limited, the terms "installation," "connection," "linking," and "fixing" are used interchangeably.

[0149] The terms "connection" and "internal connection" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components, unless otherwise explicitly defined. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.

[0150] 0 Although embodiments of the invention have been shown and described above, it is to be understood that the above embodiments are exemplary.

[0151] This should not be construed as a limitation of the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for upgrading equipment, characterized in that, The device is connected to a gateway via a bus, and the gateway stores upgrade package files for device upgrades, the upgrade package files being divided into several data packets; the method includes: Receive the upgrade start command sent by the gateway; wherein the upgrade start command includes the target device type, target device version, and target upgrade package version; If the target device type matches the current device type, the target device version matches the current device version, and the target upgrade package version is higher than the current device upgrade package version, then the current device is determined to be a device that needs to be upgraded. Receive the upgrade transmission command sent by the gateway; If the received data packets are determined to be complete based on the upgrade transmission instruction, the current device is upgraded using the upgrade package file; Before receiving the upgrade transmission instruction sent by the gateway, the method further includes: Erase the flash memory space of the current device and clear the data reception flag in the random access memory space of the current device to enable the current device to enter the state of receiving upgrade package files; The upgrade transmission instruction also includes the sequence number of the current data packet, the data packet length threshold, the packet length of the current data packet, and the packet data of the current data packet; the step of determining that the plurality of data packets have been received based on the upgrade transmission instruction includes: Based on the sequence number of the current data packet, the packet data of the current data packet is stored in the flash memory space, and the current reception flag of the current data packet is filled in the random access memory space; If the length of the current data packet is less than the data packet length threshold, the reception of the plurality of data packets is determined based on the reception flags filled in the random access storage space.

2. The method according to claim 1, characterized in that, The upgrade start command also includes the upgrade package file length and upgrade package file verification data; the process of upgrading the current device using the upgrade package file includes: If the package data in the flash memory space passes the verification of the upgrade package file length and the upgrade package file check data, the current device is upgraded based on the package data in the flash memory space.

3. The method according to claim 1, characterized in that, The upgrade initiation command also includes a file identifier; the process of upgrading the current device using the upgrade package file includes: If an upgrade flag is detected in the storage space of the current device, execute the startup procedure of the current device; During the execution of the startup program, the application area corresponding to the file identifier is erased; Write the upgrade package file to the application area and restart the current device to upgrade the current device.

4. The method according to any one of claims 1 to 3, characterized in that, The step of receiving the upgrade start command sent by the gateway includes: Receive upgrade start commands sent multiple times by the gateway according to a first preset delay; The step of receiving the upgrade transmission instruction sent by the gateway includes: Receive upgrade transmission instructions sent multiple times by the gateway according to a second preset delay.

5. The method according to any one of claims 1 to 3, characterized in that, The current device is in the message receiving state; the current device does not respond to or confirm the upgrade start command and upgrade transmission command sent to the gateway.

6. A method for upgrading equipment, characterized in that, Applied to a gateway, wherein the gateway is connected to at least one device via a bus; The gateway stores an upgrade package file for device upgrades, and the upgrade package file is divided into several data packets; the method includes: Send an upgrade start command to the at least one device; wherein the upgrade start command includes a target device type, a target device version, and a target upgrade package version; the upgrade start command is used to determine that the current device is a device that needs to be upgraded if the target device type matches the current device type, the target device version matches the current device version, and the target upgrade package version is higher than the current device's upgrade package version; Send an upgrade transmission instruction to the current device; wherein, the upgrade transmission instruction is used to instruct the current device to upgrade the current device using the upgrade package file after determining that the plurality of data packets have been received based on the upgrade transmission instruction; Before receiving the upgrade transmission instruction sent by the gateway, the method further includes: Erase the flash memory space of the current device and clear the data reception flag in the random access memory space of the current device to enable the current device to enter the state of receiving upgrade package files; The upgrade transmission instruction also includes the sequence number of the current data packet, the data packet length threshold, the packet length of the current data packet, and the packet data of the current data packet; the step of determining that the plurality of data packets have been received based on the upgrade transmission instruction includes: Based on the sequence number of the current data packet, the packet data of the current data packet is stored in the flash memory space, and the current reception flag of the current data packet is filled in the random access memory space; If the length of the current data packet is less than the data packet length threshold, the reception of the plurality of data packets is determined based on the reception flags filled in the random access storage space.

7. The method according to claim 6, characterized in that, The method further includes: Receive device upgrade instructions; wherein, the device upgrade instructions include target device type, target device version, target upgrade package version, and upgrade package access address; Download the upgrade package file according to the target device type, the target device version, the target upgrade package version, and the upgrade package access address.

8. An equipment upgrade device, characterized in that, The device is connected to a gateway via a bus, and the gateway stores upgrade package files for device upgrades, the upgrade package files being divided into several data packets; the device includes: The upgrade startup command receiving module is used to receive the upgrade startup command sent by the gateway; wherein the upgrade startup command includes the target device type, target device version, and target upgrade package version; The device determination module is used to determine that the current device is a device that needs to be upgraded if the target device type matches the current device type, the target device version matches the current device version, and the target upgrade package version is higher than the current device upgrade package version. An upgrade transmission instruction receiving module is used to receive upgrade transmission instructions sent by the gateway; The device upgrade module is used to upgrade the current device using the upgrade package file when the upgrade transmission instruction determines that the plurality of data packets have been received. Before receiving the upgrade transmission instruction sent by the gateway, the flash memory space of the current device is erased, and the data reception flag in the random access storage space of the current device is cleared, so that the current device can enter the state of receiving the upgrade package file; The upgrade transmission instruction also includes the sequence number of the current data packet, the data packet length threshold, the packet length of the current data packet, and the packet data of the current data packet; the step of determining that the plurality of data packets have been received based on the upgrade transmission instruction includes: Based on the sequence number of the current data packet, the packet data of the current data packet is stored in the flash memory space, and the current reception flag of the current data packet is filled in the random access memory space; If the length of the current data packet is less than the data packet length threshold, the reception of the plurality of data packets is determined based on the reception flags filled in the random access storage space.

9. An equipment upgrade device, characterized in that, Applied to a gateway, wherein the gateway is connected to at least one device via a bus; The gateway stores upgrade package files for device upgrades, and the upgrade package files are divided into several data packets; the device includes: An upgrade start command sending module is used to send an upgrade start command to the at least one device; wherein, the upgrade start command includes a target device type, a target device version, and a target upgrade package version; the upgrade start command is used to determine that the current device is a device that needs to be upgraded if the target device type matches the current device's device type, the target device version matches the current device's device version, and the target upgrade package version is higher than the current device's upgrade package version; An upgrade transmission instruction sending module is used to send an upgrade transmission instruction to the current device; wherein, the upgrade transmission instruction is used to instruct the current device to upgrade the current device using the upgrade package file after determining that the plurality of data packets have been received based on the upgrade transmission instruction; Before receiving the upgrade transmission instruction sent by the gateway, the flash memory space of the current device is erased, and the data reception flag in the random access storage space of the current device is cleared, so that the current device can enter the state of receiving the upgrade package file; The upgrade transmission instruction also includes the sequence number of the current data packet, the data packet length threshold, the packet length of the current data packet, and the packet data of the current data packet; the step of determining that the plurality of data packets have been received based on the upgrade transmission instruction includes: Based on the sequence number of the current data packet, the packet data of the current data packet is stored in the flash memory space, and the current reception flag of the current data packet is filled in the random access memory space; If the length of the current data packet is less than the data packet length threshold, the reception of the plurality of data packets is determined based on the reception flags filled in the random access storage space.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.