A device remote upgrade method

Through RabbitMQ cluster and MQTT protocol, combined with delayed tasks and device Queue, the problem of upgrade server downtime and message contention during remote device upgrade is solved, and efficient and accurate device upgrade and real-time status monitoring are achieved.

CN115426261BActive Publication Date: 2024-10-18江阴市富仁智能科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210976267.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-15
Publication Date
2024-10-18
Estimated Expiration
2042-08-15

AI Technical Summary

Technical Problem

Existing remote device upgrade methods can easily lead to upgrade server downtime, network congestion, contention for message delivery, and reduced accuracy when there are a large number of terminals. It is impossible to understand the device upgrade status in real time, and the upgrade task may not be completed.

Method used

Adopt RabbitMQ cluster and MQTT protocol, separate the file storage service and upgrade service, use delayed tasks and the Queue queue of a single device to ensure accurate message delivery and concurrent upgrades, and monitor the upgrade status in real time in conjunction with the device's MQTT message callback notification.

Benefits of technology

It improves the concurrency and accuracy of device upgrades, avoids message contention, ensures efficient completion of device upgrade tasks and real-time status monitoring, and reduces the risk of abnormal upgrade services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115426261B_ABST
    Figure CN115426261B_ABST
Patent Text Reader

Abstract

The present invention relates to a device remote upgrade method, comprising the steps of: uploading APK, creating an upgrade task, configuring the upgrade task, establishing a RabbitMQ cluster, sending an upgrade instruction, upgrading the device, updating the task status, and ending the upgrade task. The present invention adds RabbitMQ cluster management and MQTT message transmission mode to the remote upgrade of the device, greatly improving the convenience, high efficiency and high accuracy of the remote upgrade of the device service function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a device remote upgrading method, belonging to the technical field of Internet. Background Art

[0002] With the change of business or the upgrade of production, the business functions corresponding to the industrial equipment terminals need to be constantly updated and iterated. However, the equipment is often spread across various provinces and cities, which makes it inconvenient to perform frequent manual APK package upgrades. Remote upgrades of the equipment are required. Existing remote upgrades are often performed by the equipment terminal downloading the upgrade APK file package from the upgrade server for upgrade, or by the upgrade server sending the upgrade APK file package to the equipment terminal for upgrade. When there are a large number of terminal devices, the number of concurrent file accesses is too high, which can easily cause the upgrade server to crash and network congestion, resulting in upgrade failures; the message transmission between the equipment terminal and the upgrade server is prone to contention, resulting in errors in message transmission, and the accuracy of message transmission is reduced; it is impossible to dynamically understand the upgrade status of the equipment in real time; when there is no upgrade feedback due to reasons such as the network or equipment hardware processing speed, the upgrade task often cannot be completed. Summary of the invention

[0003] The purpose of the present invention is to overcome the above-mentioned shortcomings and provide a device remote upgrade method with high device upgrade concurrency, stable and convenient acquisition of APK upgrade files, avoidance of message competition, high message transmission accuracy, real-time dynamic understanding of device upgrade status, and efficient device remote upgrade.

[0004] The object of the present invention is achieved in that:

[0005] A device remote upgrade method comprises the following steps:

[0006] Step 1: Upload APK, upload the new version APK package to the file storage service, and obtain the file download address;

[0007] Step 2: Create an upgrade task. Create a remote upgrade task in the background of the upgrade server. After the creation is completed, start the upgrade task and update the task status in the database DB.

[0008] Step 3: Configure the upgrade task. The upgrade server arranges the task body into a delayed task for a single device according to the configuration of the upgrade task, and then encapsulates the delayed task into a corresponding single device upgrade instruction message.

[0009] Step 4: Establish a RabbitMQ cluster. Use multiple RabbitMQ servers to form a RabbitMQ cluster through network connection. The RabbitMQ server is equipped with an Exchange switch that is bound and connected to the device to be upgraded.

[0010] Step 5: Send the upgrade command. The upgrade server sends the single device upgrade command message encapsulated in step 3 to the RabbitMQ cluster. Then, based on the device information in the single device upgrade command message, the Exchange switch pushes it point-to-point to the corresponding device to be upgraded.

[0011] Step 6: Device upgrade: After receiving the upgrade message, the device terminal parses the message and downloads the upgrade APK package. After the APK package is downloaded, the device terminal performs a silent APK upgrade in idle time. After the upgrade is completed, the upgrade status is reported and the upgraded version information is notified to the background.

[0012] Step 7: Update the task status. The background cancels the corresponding delayed task according to the feedback upgrade status, and updates the device APK update result in the database DB;

[0013] Step 8: End the upgrade task. When all delayed tasks arranged in step 2 are canceled, the upgrade task is ended, and the task status and execution results are updated in the database DB.

[0014] Furthermore, the file storage service end is a network file storage service provided by a separate ECS service, Alibaba Cloud OSS or Huawei Cloud OBS.

[0015] Furthermore, the RabbitMQ server creates an Exchange switch when starting the service. After startup, the device to be upgraded actively connects to RabbitMQ and creates a unique Queue queue and names it with the uniquely distinguishable industrial computer serial number of the device, and binds the queue to the Exchange switch through the specified RoutingKey.

[0016] Furthermore, in step five, the encapsulated device upgrade instruction message is an MQ message, which is sent to the Exchange switch by RabbitMQ in an asynchronous manner, and the Exchange switch then pushes the MQ message to the device terminal through the MQTT protocol.

[0017] Furthermore, the MQ message format includes: {"devSerialNum":"111111","ipcSerialNum":"123123","taskid":123123,"fileUrl":http: / / xxxx,"executeTime":25648965745}, exchange:dev.apk.upgrade, routingkey:dev-apk-update-device industrial computer serial number.

[0018] Furthermore, after the device terminal is upgraded in step six, the upgrade status is reported through the MQTT protocol, and the reported MQTT message content includes: {'deviceid':"1223121","devSerialNum":"111111","ipcSerialNum":"123123","msgType":1,"apkVerNo":"123123","taskid":123123}.

[0019] Furthermore, in step seven, after receiving the APK upgrade completion, the background compares the version number to see if it is the current upgrade task version number. If the two version numbers are consistent, the delayed task corresponding to the device upgrade task is canceled, and the upgrade task success count is increased by 1, and the device APK update result is updated in the database DB; after receiving the report of upgrade failure, the background cancels the delayed task, increases the upgrade task failure count by 1, and updates the device APK update result in the database DB; the background directly considers the task execution failure of the device that has not been reported within the time limit, cancels the delayed task, increases the upgrade task failure count by 1, and updates the device APK update result in the database DB.

[0020] Furthermore, when a new device is connected, the APK update task needs to be determined by the newly connected device terminal at the update time node.

[0021] Compared with the prior art, the present invention has the following beneficial effects:

[0022] The present invention avoids message contention and improves the accuracy of message consumption by adding RabbitMQ cluster and independent Queue of a single device; the device upgrade status can be dynamically understood in real time by combining the MQTT message callback notification of the device; the point-to-point transmission mode of RabbitMQ cluster and MQTT protocol can improve the concurrency of device upgrade; the file service and the upgrade service are separated to avoid abnormalities of the upgrade service due to the concurrency of the file service; the use of delayed tasks can facilitate compensation operations for the task that cannot be completed due to the failure of the device upgrade, and can ensure that the device upgrade task is in the end state after the timeout; the convenience, high efficiency and high accuracy of the remote upgrade of the device business function are greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 The present invention is a working principle diagram of a device remote upgrade method.

[0024] Figure 2 This is a new device upgrade flow chart of a device remote upgrade method of the present invention. DETAILED DESCRIPTION

[0025] See also Figure 1~2 The present invention relates to a device remote upgrade method, comprising the following steps:

[0026] Step 1: Upload APK. Upload the new version APK package to the file storage service and obtain the file download address "http: / / xxxx". The file storage service is a network file storage service provided by a separate ECS service, Alibaba Cloud OSS or Huawei Cloud OBS.

[0027] Step 2: Create an upgrade task. Create a remote upgrade task in the background of the upgrade server. After the creation is completed, start the upgrade task and update the task status in the database DB.

[0028] Step 3: Configure the upgrade task. The upgrade server arranges the task body into a delayed task for a single device according to the configuration of the upgrade task, the device type, the number of devices, the device ID, and the device upgrade interval configured in the task, and then encapsulates the delayed task into a corresponding single device upgrade instruction message.

[0029] Step 4: Establish a RabbitMQ cluster, using multiple RabbitMQ servers to form a RabbitMQ cluster through network connection. The RabbitMQ server is equipped with an Exchange switch that is bound to the device to be upgraded. The RabbitMQ server creates an Exchange switch when starting the service. After startup, the device to be upgraded actively connects to RabbitMQ and creates a unique Queue named with the device's uniquely distinguishable industrial computer serial number. At the same time, the queue is bound to the Exchange switch through the specified routing key RoutingKey;

[0030] RabbitMQ is an open source message broker software (also known as message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). The RabbitMQ server is written in Erlang. RabbitMQ cluster is mainly used to achieve high availability and load balancing:

[0031] High availability: If some RabbitMQ servers in the cluster are unavailable, the client can still connect to other MQ servers without affecting the business;

[0032] Load balancing: In high-concurrency scenarios, a single RabbitMQ server can only process a limited number of messages, which can be distributed to multiple servers to reduce message latency.

[0033] Step 5: Send the upgrade instruction. The upgrade server sends the single device upgrade instruction message that has been packaged in step 3 to the RabbitMQ cluster. Then, based on the device information in the single device upgrade instruction message, the Exchange switch pushes it point-to-point to the corresponding device to be upgraded. Specifically, the packaged device upgrade instruction message is an MQ message, which is sent to the Exchange switch asynchronously by RabbitMQ, and the Exchange switch pushes the MQ message to the device terminal through the MQTT protocol. The MQ message format includes: {"devSerialNum":"111111","ipcSerialNum":"123123","taskid":123123,"fileUrl":http: / / xxxx,"executeTime":25648965745}, exchange:dev.apk.upgrade, routingkey:dev-apk-update-device industrial computer serial number;

[0034] The MQTT protocol is a message queue transmission protocol that uses a subscription and publishing mechanism. Subscribers only receive data they have subscribed to, and do not receive non-subscribed data. This ensures the exchange of necessary data and avoids the storage and processing of invalid data.

[0035] Step 6, device upgrade. After receiving the upgrade message, the device terminal parses the message and downloads the upgrade APK package through background broadcast in order to avoid affecting the current business. After the APK package is downloaded, the silent APK upgrade is performed in idle time. After the upgrade is completed, the upgrade status is reported through the MQTT protocol, and the upgraded version information is notified to the background. The reported MQTT message content includes: {'deviceid':"1223121","devSerialNum":"111111","ipcSerialNum":"123123","msgType":1,"apkVerNo":"123123","taskid":123123};

[0036] Step 7. Update the task status. The background cancels the corresponding delayed task according to the feedback upgrade status, and updates the device APK update result in the database DB: After receiving the APK upgrade completion, the background compares the version number to see if it is the current upgrade task version number. If the two version numbers are consistent, the delayed task corresponding to the device upgrade task is canceled, and the upgrade task success count is increased by 1, and the device APK update result is updated in the database DB; after receiving the report of upgrade failure, the background cancels the delayed task, increases the upgrade task failure count by 1, and updates the device APK update result in the database DB; the background directly considers the device that has not been reported within the time limit as a task failure, cancels the delayed task, increases the upgrade task failure count by 1, and updates the device APK update result in the database DB; in this way, the device upgrade progress can be understood in real time;

[0037] Step 8: End the upgrade task. When all delayed tasks arranged in step 2 are canceled, the upgrade task is ended, and the task status and execution results are updated in the database DB.

[0038] When new devices are connected, the APK update task needs to be decided by the newly connected device terminal at the update time node. It can be updated immediately (within three hours) or scheduled (12:00 am at night); and according to the number of newly connected devices, local small-scale device update or large-scale device update (more than 30 devices) can be selected; when updating a small number of local devices, the upgrade server will encapsulate the upgrade command message and send it to all devices. When updating a large area of ​​devices, the upgrade server will encapsulate the upgrade command message and send it to the devices in multiple batches.

[0039] The present invention avoids message contention and improves the accuracy of message consumption by adding a RabbitMQ cluster and an independent Queue of a single device; the device upgrade status can be dynamically understood in real time by combining the MQTT message callback notification of the device; the point-to-point transmission mode of the RabbitMQ cluster and the MQTT protocol can improve the concurrency of device upgrades; the file service and the upgrade service are separated to avoid abnormalities in the upgrade service caused by the concurrency of the file service; the use of delayed tasks can facilitate compensation operations for the task that cannot be completed due to the failure of the device upgrade, and can ensure that the device upgrade task is in a completed state after the timeout.

[0040] In addition: It should be noted that the above specific implementation is only an optimization scheme of this patent. Any changes or improvements made by technicians in this field based on the above concept are within the scope of protection of this patent.

Claims

1. A device remote upgrade method, characterized in that: The following steps are involved: Step 1: Upload APK, upload the new version APK package to the file storage service client, and obtain the file download address; Step 2: Create an upgrade task. Create a remote upgrade task in the background of the upgrade server. After the creation is completed, start the upgrade task and update the task status in the database DB. Step 3: Configure the upgrade task. The upgrade server arranges the task body into a delayed task for a single device according to the configuration of the upgrade task, and then encapsulates the delayed task into a corresponding single device upgrade instruction message. Step 4: Establish a RabbitMQ cluster. Use multiple RabbitMQ servers to form a RabbitMQ cluster through network connection. The RabbitMQ server is equipped with an Exchange switch that is bound and connected to the device to be upgraded. Step 5: Send the upgrade command. The upgrade server sends the single device upgrade command message packaged in step 3 to the RabbitMQ cluster, and then the Exchange switch pushes it point-to-point to the corresponding device to be upgraded based on the device information in the single device upgrade command message. The packaged device upgrade command message is an MQ message, which is sent to the Exchange switch asynchronously by RabbitMQ, and the Exchange switch pushes the MQ message to the device terminal through the MQTT protocol; the MQ message format includes: {"devSerialNum":"111111","ipcSerialNum": "123123","taskid":123123,"fileUrl":http: / / xxxx,"executeTime":25648965745},exchange:dev.apk.upgrade,routingkey:dev-apk-update-device industrial computer serial number; Step 6: Device upgrade. After receiving the upgrade message, the device terminal parses the message and downloads the upgrade APK package. After the APK package is downloaded, the device terminal performs a silent APK upgrade in idle time. After the upgrade is completed, the upgrade status is reported and the upgraded version information is notified to the background. After the upgrade is completed, the device terminal reports the upgrade status through the MQTT protocol. The reported MQTT message content includes: {'deviceid':"1223121","devSerialNum":"111111","ipcSerialNum":"123123","msgType":1,"apkVerNo":"123123","taskid":123123}. Step 7: Update the task status. The background cancels the corresponding delayed task according to the feedback upgrade status, and updates the device APK update result in the database DB; Step 8: End the upgrade task. When all delayed tasks arranged in step 2 are canceled, the upgrade task is ended, and the task status and execution results are updated in the database DB.

2. The device remote upgrade method according to claim 1, characterized in that: The file storage service end is a network file storage service provided by a separate ECS service, Alibaba Cloud OSS or Huawei Cloud OBS.

3. The device remote upgrade method according to claim 1, characterized in that: The RabbitMQ server creates an Exchange switch when starting the service. After startup, the device to be upgraded actively connects to RabbitMQ and creates a unique Queue queue named after the device's uniquely distinguishable industrial computer serial number, and binds the queue to the Exchange switch through the specified RoutingKey.

4. The device remote upgrade method according to claim 1, characterized in that: In step 7, after receiving the APK upgrade completion, the background compares the version number to see if it is the current upgrade task version number. If the two version numbers are consistent, the delayed task corresponding to the device upgrade task is canceled, and the upgrade task success count is increased by 1, and the device APK update result is updated in the database DB; after receiving the report of upgrade failure, the background cancels the delayed task, increases the upgrade task failure count by 1, and updates the device APK update result in the database DB; the background directly considers the task execution failure of the device that has not been reported within the time limit, cancels the delayed task, increases the upgrade task failure count by 1, and updates the device APK update result in the database DB.

5. The device remote upgrade method according to claim 1, characterized in that: When a new device is connected, the APK update task must be determined by the newly connected device terminal at the update time node.

Citation Information

Patent Citations

  • Method and a device for upgrading equipment firmware

    CN109656587A

  • System and method for dynamically configuring upgrade package to realize specified upgrade of intelligent equipment

    CN114697214A