Network disconnection reconnection internet of things device firmware upgrading method based on lightweight MQTT protocol

By employing a dynamic block adjustment and intelligent reconnection strategy based on the lightweight MQTT protocol, the efficiency and reliability issues of firmware upgrades for IoT devices in unstable network environments are resolved, enabling efficient firmware upgrades in complex network environments.

CN120151196BActive Publication Date: 2026-03-31SHANGHAI LINGZE INFORMATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-31
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

Existing firmware upgrade methods for IoT devices are difficult to achieve efficient and reliable firmware upgrades under conditions of network instability and limited device resources. Furthermore, they lack effective management of network fluctuations and the ability to dynamically adapt to device resources, resulting in delays and uncertainties in the upgrade process.

Method used

Based on the lightweight MQTT protocol, by collecting device and network information, an adaptive algorithm is used to build a dynamic block adjustment strategy and a time series prediction model to adjust the firmware block size and download order in real time, restore the connection when the network fluctuates, optimize the reconnection timing, and ensure the integrity and efficiency of transmission.

Benefits of technology

It significantly improves the continuity and success rate of firmware upgrades, especially in complex and ever-changing network environments, improving transmission efficiency and reducing network resource waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120151196B_ABST
    Figure CN120151196B_ABST
Patent Text Reader

Abstract

The application discloses a network disconnection reconnection Internet of Things device firmware upgrading method based on a lightweight MQTT protocol, relates to the technical field of Internet of Things, and collects a device information set and a network information set, uses an adaptive algorithm to construct a dynamic block adjustment strategy for determining the size and download priority of firmware blocks based on the device information set and the network information set, uses a time sequence prediction model to construct an intelligent reconnection strategy for adjusting reconnection time based on the device information set and the network information set, uses the dynamic block adjustment strategy to intelligently block transmission firmware, so as to adjust the size and download order of the transmission firmware block in real time, and uses the intelligent reconnection strategy to restore connection and continue downloading when the network fluctuates, receives and checks the transmission firmware block, generates a check information set, and checks the integrity of the transmission firmware block. The continuity and success rate of firmware upgrading are significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Internet of Things (IoT) technology, specifically to a firmware upgrade method for IoT devices that reconnect after network disconnection based on the lightweight MQTT protocol. Background Technology

[0002] MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol widely used for communication between Internet of Things (IoT) devices. It was designed to provide reliable message delivery in low-bandwidth and unstable network environments. Firmware upgrades for IoT devices are crucial for fixing vulnerabilities, adding functionality, and improving performance, ensuring device security and enabling feature updates. However, in practice, because IoT devices are typically distributed across various complex network environments, firmware upgrades face numerous challenges, such as network instability, transmission interruptions, and limited device resources. This makes efficient and reliable firmware upgrades a pressing issue that needs to be addressed.

[0003] Existing firmware upgrade methods for IoT devices typically rely on simple download and update mechanisms, lacking effective management of network fluctuations and dynamic adaptation to device resources. These methods often cannot cope with transmission failures or data corruption caused by continuous network outages. Furthermore, traditional methods usually transmit the entire firmware package at once during the download process, failing to consider specific bandwidth and device status, easily leading to excessive device load or wasted network resources. In addition, the lack of predictive ability for network fluctuations prevents devices from immediately and efficiently restarting the download when the network recovers, resulting in delays and uncertainties in the upgrade process. These shortcomings limit the upgrade efficiency and reliability of IoT devices in dynamic network environments.

[0004] Chinese patent application CN103347095A discloses a wireless firmware update method in a vehicle-to-everything (V2X) system. In this method, a remote server sends firmware file information to a smart terminal. The smart terminal initializes a file block number index area according to the set data block length based on the firmware file information sent by the remote server, and returns the data block length to the remote server. The remote server then segments the firmware into blocks according to the returned block length. The smart terminal requests data packets from the remote server based on the block number index area, returns a firmware reception completion instruction to the remote server, and writes a firmware update record. The smart ride-hailing terminal writes an upgrade flag and then automatically restarts the terminal. The terminal bootloader detects the upgrade flag; if an upgrade is needed, it writes the sent firmware to the program space. After writing the firmware, the upgrade flag is erased, and the terminal automatically restarts. However, this method cannot automatically adjust the block size, making it difficult to guarantee transmission efficiency when network fluctuations are significant.

[0005] To address this, the present invention proposes a firmware upgrade method for IoT devices that reconnect after network disconnection based on the lightweight MQTT protocol. Summary of the Invention

[0006] This invention aims to address at least one of the technical problems existing in the prior art. To this end, this invention proposes a firmware upgrade method for IoT devices that allows for reconnection after network outages based on the lightweight MQTT protocol, significantly improving the continuity and success rate of firmware upgrades.

[0007] To achieve the above objectives, a firmware upgrade method for IoT devices that reconnect after network disconnection is proposed based on the lightweight MQTT protocol, including the following steps:

[0008] Step 1: Collect device information and network information sets;

[0009] Step 2: Based on the device information set and network information set, use an adaptive algorithm to construct a dynamic block adjustment strategy to determine the size of firmware blocks and download priority; and based on the device information set and network information set, use a time series prediction model to construct an intelligent reconnection strategy to adjust the reconnection time.

[0010] Step 3: Use a dynamic block adjustment strategy to intelligently divide the transmitted firmware into blocks, so as to adjust the size and download order of the transmitted firmware blocks in real time; and use an intelligent reconnection strategy to restore the connection and continue downloading when the network fluctuates.

[0011] Step 4: Receive and verify the transmitted firmware block, generate a verification information set, and verify the integrity of the transmitted firmware block.

[0012] The method for collecting the device information set is as follows:

[0013] The device collects external parameters using its built-in hardware sensors and collects device status parameters through interfaces provided by the device's operating system.

[0014] The device's external parameters and device status parameters together form a set of device information.

[0015] The method for collecting the network information set is as follows:

[0016] By using network analysis tools installed on the device, the parameter values ​​of various network parameters of the device are collected in real time during past firmware upgrades;

[0017] Historical upgrade information is collected by automatically recording data block transfer logs generated during past firmware upgrades from the device's operating system.

[0018] The parameter values ​​of each network parameter and historical upgrade information constitute a network information set.

[0019] The dynamic block adjustment strategy, which uses an adaptive algorithm to determine the size and download priority of firmware blocks based on device information sets and network information sets, includes the following steps:

[0020] Step 21: Select firmware blocks that were successfully transmitted each time from the historical upgrade information of the network information set as successful block samples;

[0021] Step 22: In the past firmware upgrade process, at each preset transmission time interval, all successful block samples within that transmission time interval were selected, and the size of the successful block sample with the largest data volume was used as the block size label for that transmission time interval.

[0022] Step 23: Based on the parameters corresponding to each transmission time interval in the device information set and network information set, as well as the block size label of that transmission time interval, train a machine learning model to predict the firmware block size;

[0023] The method for training the machine learning model to predict firmware block size is as follows:

[0024] For each transmission time interval, the parameters in the device information set and network information set are divided according to whether they are fixed values. For parameters with non-fixed values, the statistical parameters of the parameter within the transmission time interval are counted. The parameters with fixed values ​​and the statistical parameters with non-fixed values ​​are combined to form the feature vector of the transmission time interval.

[0025] A machine learning model is constructed. The machine learning model takes the feature vector of each transmission time interval as input, the predicted value of the block size of the firmware block within the transmission time interval as output, the block size label within the transmission time interval as the prediction target, and the mean square error between the predicted value of the block size and the block size label as the loss function.

[0026] Step 24: Calculate the block size adjustment factor (BSF) for each transmission time interval based on the device information set and the network information set;

[0027] Step 25: Calculate the block size proposal based on the block size adjustment factor (BSF) and the predicted block size output by the machine learning model;

[0028] Step 26: For each firmware block, pre-set an importance coefficient BI; based on the importance coefficient and the network information set, calculate the priority coefficient of the firmware block; the dynamic block adjustment strategy includes setting the size of the firmware block within each transmission time interval to the suggested block size at the beginning of each transmission time interval, and setting the transmission priority of each firmware block within the transmission time interval to the priority coefficient.

[0029] The method for constructing an intelligent reconnection strategy that adjusts the reconnection time using a time series prediction model based on device information sets and network information sets is as follows:

[0030] The firmware upgrade process in the device information set and network information set is divided into multiple time series segments, so that each time series segment contains specific network status and device status;

[0031] Statistical principles are used to analyze various statistical parameters of network status and device status within each time series segment, which are used as reconnection characteristics within that time series segment.

[0032] The network and device states in each time series segment are labeled with state types using a data labeling tool. The state types include connection interruption events and connection recovery events.

[0033] The time between any two adjacent connection interruption events and connection recovery events is represented as a disconnection period. The number of time series segments contained in the duration of each disconnection period is calculated, and the duration of the disconnection period is used as the duration label of the disconnection period. In the disconnection period, the reconnection features of each time series segment are used as the reconnection feature sequence according to the feature sequence composed of the time series.

[0034] The time series prediction model receives the reconnection feature sequence as input, takes the predicted reconnection duration as output, takes the duration label as the prediction target, and uses the mean square error between the predicted reconnection duration and duration label of all disconnection time periods as the loss function to train the time series prediction model.

[0035] The predicted reconnection duration output by the time series prediction model after training is the adjustment window for the intelligent reconnection strategy.

[0036] The method for adjusting the size of the transmission firmware block in real time is as follows:

[0037] When performing firmware upgrades on devices via the Internet of Things, at the beginning of each transmission time interval, the fixed-value parameters and non-fixed-value statistical parameters in the device information set and network information set of the previous transmission time interval are statistically analyzed to form an actual feature vector.

[0038] The actual feature vector is input into the machine learning model to obtain the predicted value of the block size output by the machine learning model;

[0039] Calculate the block size adjustment factor for the previous transmission time interval;

[0040] Based on the predicted block size and the block size adjustment factor, the firmware block size for the next transmission time interval is calculated.

[0041] Based on the calculated firmware block size, the subsequent firmware upgrade data packets are divided into blocks to obtain multiple transmission firmware blocks;

[0042] In each unit of time during subsequent transmission of firmware blocks, the priority coefficient of each firmware block is calculated, and the firmware block with the highest priority coefficient is selected for transmission.

[0043] The method of using the intelligent reconnection strategy to restore the connection and continue downloading during network fluctuations is as follows:

[0044] If a connection interruption occurs during the transmission of the firmware block:

[0045] At each time series segment, network status and device status are collected once, and the corresponding reconnection features are obtained. The reconnection features collected after the connection interruption occurs are concatenated in chronological order to obtain the corresponding actual reconnection feature sequence.

[0046] The time series prediction model is used to predict the actual reconnection feature sequence and the predicted reconnection duration is obtained.

[0047] Before the predicted reconnection time, the transmission order of the transmitted firmware blocks is reordered according to their importance coefficient.

[0048] Before the predicted reconnection time is reached, reconnection attempts are made according to the preset reconnection cycle. When the predicted reconnection time is reached, the reconnection cycle is reduced by a preset ratio.

[0049] The method for receiving and verifying the transmitted firmware block, generating a verification information set, and verifying the integrity of the transmitted firmware block is as follows:

[0050] Determine the verification algorithm to be used to check data integrity;

[0051] After receiving each transmitted firmware block, the device calculates the corresponding checksum using a verification algorithm.

[0052] Compare the calculated checksum with the expected checksum attached from the sending end of the transmitted firmware block. If the comparison results match, the transmitted firmware block is considered complete; otherwise, the transmitted firmware block is considered incomplete.

[0053] A verification information record is generated for each transport firmware block, including the block number, expected checksum, and actual checksum.

[0054] For firmware blocks that are determined to be incomplete, re-request transmission, re-receive and re-verify until successful;

[0055] For firmware blocks that are determined to be complete, save them in the device and update the progress log to record the time of successful transmission, the number of verifications, and the number of retransmissions.

[0056] After all firmware blocks have been transmitted, a second verification of the entire firmware package is performed to ensure its integrity; the second verification method is similar to overall hash value verification.

[0057] An electronic device is proposed, comprising: a processor and a memory, wherein the memory stores a computer program for the processor to call;

[0058] The processor executes the aforementioned method for firmware upgrade of IoT devices based on the lightweight MQTT protocol by calling the computer program stored in the memory.

[0059] Compared with the prior art, the beneficial effects of the present invention are:

[0060] This invention collects device and network information sets. Based on these sets, it uses an adaptive algorithm to construct a dynamic block adjustment strategy that determines the size and download priority of firmware blocks. Furthermore, based on the device and network information sets, it uses a time series prediction model to construct an intelligent reconnection strategy that adjusts reconnection time. The dynamic block adjustment strategy intelligently segments the transmitted firmware into blocks to adjust the size and download order of these blocks in real time. The intelligent reconnection strategy restores the connection and continues downloading during network fluctuations, receiving and verifying transmitted firmware blocks, generating a verification information set, and verifying the integrity of the transmitted firmware blocks. By proposing a dynamic block adjustment strategy that monitors network and device status in real time and dynamically adjusts the size of transmitted data blocks to adapt to current network conditions and device load, it improves transmission efficiency and reduces network resource waste. The intelligent reconnection strategy utilizes a time series prediction model to predict network interruption and recovery times, optimizing the reconnection timing and order of devices, enabling devices to quickly resume downloading after network fluctuations. The combination of these two strategies significantly improves the continuity and success rate of firmware upgrades, especially in complex and changing network environments. Attached Figure Description

[0061] Figure 1 This is a flowchart of the firmware upgrade method for IoT devices based on the lightweight MQTT protocol after network disconnection and reconnection in this invention.

[0062] Figure 2 This is a schematic diagram illustrating the steps of the dynamic block adjustment strategy in this invention. Detailed Implementation

[0063] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0064] like Figure 1 As shown, the method for firmware upgrade of IoT devices based on the lightweight MQTT protocol after network disconnection and reconnection includes the following steps:

[0065] Step 1: Collect device information and network information sets;

[0066] Step 2: Based on the device information set and network information set, use an adaptive algorithm to construct a dynamic block adjustment strategy to determine the size of firmware blocks and download priority; and based on the device information set and network information set, use a time series prediction model to construct an intelligent reconnection strategy to adjust the reconnection time.

[0067] Step 3: Use a dynamic block adjustment strategy to intelligently divide the transmitted firmware into blocks, so as to adjust the size and download order of the transmitted firmware blocks in real time; and use an intelligent reconnection strategy to restore the connection and continue downloading when the network fluctuates.

[0068] Step 4: Receive and verify the transmitted firmware block, generate a verification information set, and verify the integrity of the transmitted firmware block.

[0069] The method for collecting the device information set is as follows:

[0070] The device collects external parameters using its built-in hardware sensors and collects device status parameters through interfaces provided by the device's operating system.

[0071] The device's external parameters and device status parameters together form a set of device information.

[0072] Specifically, the external parameters of the device may include the device's GPS positioning to provide the device's location when the device needs to consider the network signal strength of the geographical location;

[0073] The specific device status parameters and their collection methods include:

[0074] The firmware version is read from the system file when the device starts up, CPU and memory usage are collected periodically using the interface provided by the operating system, remaining storage space is checked periodically through the file system interface before and during firmware updates, and battery status is obtained using the device's power management interface.

[0075] Furthermore, the method for collecting the network information set is as follows:

[0076] By using network analysis tools installed on the device, the parameter values ​​of various network parameters of the device are collected in real time during past firmware upgrades;

[0077] Historical upgrade information is collected by automatically recording data block transfer logs generated during past firmware upgrades from the device's operating system.

[0078] The parameter values ​​of each network parameter and historical upgrade information constitute a network information set.

[0079] The specific network parameters and their collection methods include:

[0080] Regularly measure network bandwidth and latency using network speed test tools or the built-in speed test function of applications;

[0081] Signal strength is obtained through the network interface of the device's operating system;

[0082] Network jitter frequency is obtained by continuously measuring network latency changes and calculating its standard deviation;

[0083] The network management module records logs of network status changes, and analyzes the log data to obtain the frequency of network outages and historical recovery times.

[0084] The historical upgrade information includes the size of the firmware block transmitted each time during each firmware upgrade process, the success or failure of the transmission, the transmission time, the number of retries, etc.

[0085] like Figure 2 The schematic diagram of the dynamic block adjustment strategy is shown. The dynamic block adjustment strategy, which uses an adaptive algorithm to construct the size of firmware blocks and download priority based on device information sets and network information sets, includes the following steps:

[0086] Step 21: Select firmware blocks that were successfully transmitted each time from the historical upgrade information of the network information set as successful block samples;

[0087] Step 22: In the past firmware upgrade process, at each preset transmission time interval, all successful block samples within that transmission time interval were selected, and the size of the successful block sample with the largest data volume was used as the block size label for that transmission time interval; it can be understood that the block size label is the largest firmware block size that can be transmitted under the corresponding network environment conditions and device status conditions within that transmission time interval.

[0088] Step 23: Based on the parameters corresponding to each transmission time interval in the device information set and network information set, as well as the block size label of that transmission time interval, train a machine learning model to predict the firmware block size;

[0089] Specifically, the method for training the machine learning model to predict firmware block size is as follows:

[0090] For each transmission time interval, the parameters in the device information set and network information set are divided according to whether they are fixed values. For parameters with non-fixed values, the statistical parameters of the parameter within the transmission time interval are counted. The parameters with fixed values ​​and the statistical parameters with non-fixed values ​​are combined to form the feature vector of the transmission time interval.

[0091] Specifically, the statistical parameters include the average value, standard deviation, etc.; non-fixed value parameters include network speed, signal strength, etc.

[0092] A machine learning model is constructed. The machine learning model takes the feature vector of each transmission time interval as input, the predicted value of the block size of the firmware block within the transmission time interval as output, the block size label within the transmission time interval as the prediction target, and the mean square error between the predicted value of the block size and the block size label as the loss function.

[0093] Step 24: Calculate the block size adjustment factor (BSF) for each transmission time interval based on the device information set and the network information set;

[0094] Specifically, the block size adjustment factor (BSF) is calculated as follows:

[0095] The average available network bandwidth within each transmission time interval is denoted as BW;

[0096] The average network delay within each transmission time interval is denoted as LT;

[0097] The average network jitter over each transmission time interval is denoted as JT;

[0098] The average CPU utilization of the device within each transmission time interval is denoted as CU;

[0099] The average memory usage of the device within each transmission time interval is denoted as MU;

[0100] The average battery charge level within each transmission time interval is denoted as BL;

[0101] The formula for calculating the block size adjustment factor (BSF) is as follows:

[0102] Where a1, a2, a3, a4, a5, and a6 are preset scaling factors; it should be noted that the calculation formula for the block size adjustment factor (BSF) uses bandwidth, latency, and jitter to measure network transmission capacity. Under conditions of high bandwidth, low latency, and low jitter, data transmission efficiency is higher, so the block size can be increased. However, when both the device's CPU and memory are under high load, the block size should be decreased to reduce processing pressure and memory usage. Conversely, when power is sufficient, the block size can be appropriately increased to accelerate transmission.

[0103] Step 25: Calculate the block size proposal based on the block size adjustment factor (BSF) and the predicted block size output by the machine learning model;

[0104] Specifically, the proposed block size is determined as follows:

[0105] Mark the block suggestion size as BS;

[0106] The predicted block size output by the machine learning model is labeled as PBS;

[0107] The formula for calculating the block suggestion size BS is: BS = PBS × BSF;

[0108] It should be noted that the block size predicted by the machine learning model is the optimal block size predicted based on historical data and the current state, while the block size adjustment coefficient combines information on real-time network and device status. Therefore, through comprehensive calculation, the block size is dynamically adjusted to ensure better transmission efficiency under different network and device conditions.

[0109] Step 26: For each firmware block, pre-set its importance coefficient BI; based on the importance coefficient and the network information set, calculate the priority coefficient of the firmware block;

[0110] The dynamic block adjustment strategy includes setting the size of the firmware block to the suggested block size at the beginning of each transmission time interval, and setting the transmission priority of each firmware block to a priority coefficient during the transmission time interval.

[0111] Specifically, the importance coefficient is generally determined based on the actual content within the firmware block. Generally, critical data blocks in the firmware upgrade program require a higher importance coefficient to be transmitted with priority.

[0112] Furthermore, the method for calculating the priority coefficient of firmware blocks is as follows:

[0113] The priority coefficient is marked as PR; the network signal strength when transmitting firmware blocks is marked as SG; and the network delay when transmitting firmware blocks is marked as LTR.

[0114] The formula for calculating the priority coefficient is: It should be noted that this formula expresses a priority formula for evaluating current network conditions by combining the ratio of signal strength to latency. When signal strength is high and latency is low, transmission conditions are good, and therefore important firmware blocks can be transmitted first.

[0115] Furthermore, the method for constructing an intelligent reconnection strategy that adjusts the reconnection time using a time series prediction model based on device information sets and network information sets is as follows:

[0116] The firmware upgrade process in the device information set and network information set is divided into multiple time series segments, so that each time series segment contains specific network status and device status; specifically, the network status and device status include ideal network status such as high bandwidth and low latency, and device load status such as high CPU utilization and low power consumption.

[0117] Statistical principles are used to analyze various statistical parameters of network status and device status within each time series segment, which are used as reconnection characteristics within that time series segment.

[0118] The network and device states in each time series segment are labeled with state types using a data labeling tool. The state types include connection interruption events and connection recovery events.

[0119] The time between any two adjacent connection interruption events and connection recovery events is represented as a disconnection period. The number of time series segments contained in the duration of each disconnection period is calculated, and the duration of the disconnection period is used as the duration label of the disconnection period. In the disconnection period, the reconnection features of each time series segment are used as the reconnection feature sequence according to the feature sequence composed of the time series.

[0120] The time series prediction model receives the reconnection feature sequence as input, and the time series prediction model outputs the predicted reconnection duration, uses the duration label as the prediction target, and uses the mean square error between the predicted reconnection duration and the duration label of all disconnection time periods as the loss function to train the time series prediction model; specifically, the time series prediction model includes LSTM model, RNN model or GRU model, etc.

[0121] The predicted reconnection duration output by the time series prediction model after training is the adjustment window for the intelligent reconnection strategy.

[0122] Furthermore, the method for adjusting the size of the transmission firmware block in real time is as follows:

[0123] When performing firmware upgrades on devices via the Internet of Things, at the beginning of each transmission interval, the fixed-value parameters and non-fixed-value statistical parameters in the device information set and network information set of the previous transmission interval are statistically analyzed to form an actual feature vector. Since the network changes little in a short period of time, the data from the most recent transmission interval is used as the basis for various decisions in the next transmission interval.

[0124] The actual feature vector is input into the machine learning model to obtain the predicted value of the block size output by the machine learning model;

[0125] Calculate the block size adjustment factor for the previous transmission time interval;

[0126] Based on the predicted block size and the block size adjustment factor, the firmware block size for the next transmission time interval is calculated.

[0127] Based on the calculated firmware block size, the subsequent firmware upgrade data packets are divided into blocks to obtain multiple transmission firmware blocks;

[0128] In each unit of time during subsequent transmission of firmware blocks, the priority coefficient of each firmware block is calculated, and the firmware block with the highest priority coefficient is selected for transmission.

[0129] Furthermore, the method of using the intelligent reconnection strategy to restore the connection and continue downloading during network fluctuations is as follows:

[0130] If a connection interruption occurs during the transmission of the firmware block:

[0131] At each time series segment, network status and device status are collected once, and the corresponding reconnection features are obtained. The reconnection features collected after the connection interruption occurs are concatenated in chronological order to obtain the corresponding actual reconnection feature sequence.

[0132] The time series prediction model is used to predict the actual reconnection feature sequence and the predicted reconnection duration is obtained.

[0133] Before the predicted reconnection time, the transmission order of the firmware blocks is reordered according to their importance coefficient to ensure that critical data blocks are prepared for transmission first.

[0134] Before the predicted reconnection duration is reached, reconnection attempts are made according to the preset reconnection cycle. When the predicted reconnection duration is reached, the reconnection cycle is reduced by a preset ratio. It can be understood that before the predicted reconnection duration is reached, since the possibility of reconnection is small, reconnection can be initiated at a lower frequency to save network resources and enable IoT devices to efficiently restore connection during network fluctuations.

[0135] Furthermore, the method for receiving and verifying the transmitted firmware block, generating a verification information set, and verifying the integrity of the transmitted firmware block is as follows:

[0136] The verification algorithm to be used is determined to check data integrity; the verification algorithm includes CRC32, MD5, SHA-256, etc.

[0137] After receiving each transmitted firmware block, the device calculates the corresponding checksum using a verification algorithm.

[0138] Compare the calculated checksum with the expected checksum attached from the sending end of the transmitted firmware block. If the comparison results match, the transmitted firmware block is considered complete; otherwise, the transmitted firmware block is considered incomplete.

[0139] A verification information record is generated for each transport firmware block, including the block number, expected checksum, and actual checksum.

[0140] For firmware blocks that are determined to be incomplete, re-request transmission, re-receive and re-verify until successful;

[0141] For firmware blocks that are determined to be complete, save them in the device and update the progress log to record the time of successful transmission, the number of verifications, and the number of retransmissions.

[0142] After all firmware blocks have been transmitted, a second verification of the entire firmware package is performed to ensure its integrity; the second verification method is similar to overall hash value verification.

[0143] In addition, the parts of the technical solutions provided in the embodiments of this application that are consistent with the implementation principles of the corresponding technical solutions in the prior art have not been described in detail, so as to avoid excessive elaboration.

[0144] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the invention. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

[0145] The preset parameters or preset thresholds mentioned above are all set by those skilled in the art based on actual conditions or obtained through large-scale data simulation.

[0146] The above embodiments are only used to illustrate the technical methods of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical methods of the present invention without departing from the spirit and scope of the technical methods of the present invention.

Claims

1. A firmware upgrade method for IoT devices that reconnect after network disconnection based on the lightweight MQTT protocol, characterized in that, The method comprises the following steps: Step 1: collecting a device information set and a network information set; Step 2: based on the device information set and the network information set, using an adaptive algorithm to construct a dynamic block adjustment strategy for determining the size and download priority of firmware blocks, and based on the device information set and the network information set, using a time series prediction model to construct an intelligent reconnection strategy for adjusting the reconnection time; Step 3: using the dynamic block adjustment strategy, intelligently block the transmission firmware to adjust the size and download order of the transmission firmware block in real time; And using the intelligent reconnection strategy to recover the connection and continue downloading when the network fluctuates; Step 4: receiving and verifying the transmission firmware block, generating a verification information set, and verifying the integrity of the transmission firmware block; The method of using an adaptive algorithm to construct a dynamic block adjustment strategy for determining the size and download priority of firmware blocks based on the device information set and the network information set comprises the following steps: Step 21: from the historical upgrade information of the network information set, filter out the firmware blocks that are successfully transmitted each time as successful block samples; Step 22: in the past firmware upgrade process, every preset transmission time interval, filter out all successful block samples within the transmission time interval, and take the size of the successful block sample with the largest data volume as the block size label of the transmission time interval; Step 23: based on the parameters corresponding to each transmission time interval in the device information set and the network information set and the block size label of the transmission time interval, train a machine learning model for predicting the size of the firmware block; Step 24: calculate the block size adjustment factor BSF within each transmission time interval according to the device information set and the network information set; Step 25: based on the block size adjustment factor BSF and the predicted value of the block size output by the machine learning model, calculate the block suggestion size; Step 26: for each firmware block, set an importance coefficient BI for it in advance; based on the importance coefficient and the network information set, calculate the priority coefficient of the firmware block; the dynamic block adjustment strategy comprises setting the size of the firmware block within each transmission time interval to the block suggestion size at the beginning of each transmission time interval, and setting the transmission priority of each firmware block within the transmission time interval to the priority coefficient; The way to adjust the size of the transmission firmware block in real time is: When actually upgrading the firmware of the device through the Internet of Things, at the beginning of each transmission time interval, the fixed value parameters and the statistical parameters of each non-fixed value in the device information set and the network information set in the last transmission time interval are counted to form an actual feature vector; Input the actual feature vector into the machine learning model to obtain the predicted value of the block size output by the machine learning model; Calculate the block size adjustment factor of the last transmission time interval; Based on the predicted value of the block size and the block size adjustment factor, the firmware block size of the next transmission time interval is calculated; According to the calculated firmware block size, block the subsequent firmware upgrade data packet to obtain a plurality of transmission firmware blocks; In each unit time when the firmware blocks are transmitted subsequently, the priority coefficient of each firmware block is calculated, and the firmware block with the largest priority coefficient is selected for transmission.

2. The lightweight MQTT protocol based off-network reconnection Internet of Things device firmware upgrade method according to claim 1, characterized in that, The device information set is collected in the following manner: Device external parameters are collected by using the hardware sensors built in the device, and device state parameters are collected through the interface provided by the operating system of the device. The device external parameters and the device state parameters form the device information set.

3. The lightweight MQTT protocol based off-network reconnection Internet of Things device firmware upgrade method according to claim 2, characterized in that, The network information set is collected in the following manner: The parameter values of various network parameters of the device in the past firmware upgrade process are collected in real time by using the network analysis tool installed on the device side; The historical upgrade information is collected from the data block transmission log generated in the past firmware upgrade process and automatically recorded by the operating system of the device. The parameter values of the various network parameters and the historical upgrade information form the network information set.

4. The lightweight MQTT protocol based off-network reconnection Internet of Things device firmware upgrade method according to claim 1, characterized in that, The machine learning model for predicting the firmware block size is trained in the following manner: For each transmission time interval, the various parameters in the device information set and the network information set are divided into fixed values and non-fixed values, and for the non-fixed value parameters, the statistical parameters of the parameters in the transmission time interval are calculated; the fixed value parameters and the statistical parameters of the non-fixed value parameters together form the feature vector of the transmission time interval; A machine learning model is constructed, which takes the feature vector of each transmission time interval as input, takes the predicted value of the block size of the firmware block in the transmission time interval as output, takes the block size label in the transmission time interval as the prediction target, and takes the mean square error between the predicted value of the block size and the block size label as the loss function.

5. The lightweight MQTT protocol based off-network reconnection Internet of Things device firmware upgrade method according to claim 4, characterized in that, The intelligent reconnection strategy for adjusting the reconnection time based on the device information set and the network information set is constructed in the following manner: The past firmware upgrade process in the device information set and the network information set is divided into multiple time sequence segments, so that each time sequence segment contains a specific network state and device state; The statistical parameters of the network state and the device state in each time sequence segment are calculated using statistical principles as the reconnection features in the time sequence segment; The network state and the device state in each time sequence segment are labeled by a state type using a data labeling tool; The time between any adjacent connection interruption event and connection recovery event is represented as a disconnection time period, the number of time sequence segments contained in the duration of each disconnection time period is calculated, and the duration of the disconnection time period is taken as the duration label of the disconnection time period; in the disconnection time period, the feature sequence composed of the reconnection features of each time sequence segment in time sequence is taken as the reconnection feature sequence; A time sequence prediction model receives the reconnection feature sequence as input, the time sequence prediction model takes the predicted reconnection duration as output, takes the duration label as the prediction target, and takes the mean square error between the predicted reconnection duration of all disconnection time periods and the duration label as the loss function to train the time sequence prediction model; the predicted reconnection duration output by the trained time sequence prediction model is the adjustment window of the intelligent reconnection strategy. 6.The lightweight MQTT protocol based off-network reconnection Internet of Things device firmware upgrade method according to claim 1, characterized in that, The method for resuming connection and continuing downloading during network fluctuation using the intelligent reconnection strategy is: During the transmission of the firmware blocks, after the occurrence of the connection interruption: Every other time sequence segment, the network state and the device state are collected, and the corresponding reconnection features are obtained. The reconnection features collected after the occurrence of the connection interruption are sequentially spliced in time sequence to obtain a corresponding actual reconnection feature sequence; The time sequence prediction model is used to predict the actual reconnection feature sequence to obtain an output predicted reconnection duration; Before the predicted reconnection time, the transmission order of the firmware blocks is re-sequenced according to the importance coefficients; Before the predicted reconnection duration is reached, a reconnection attempt is made according to a preset reconnection period, and when the predicted reconnection duration is reached, the reconnection period is reduced by a preset proportion.

7. The lightweight MQTT protocol based off-network reconnection Internet of Things device firmware upgrade method according to claim 6, characterized in that, The method for receiving and verifying the firmware blocks, generating a verification information set, and verifying the integrity of the firmware blocks is: Determining the verification algorithm used to detect data integrity; After the device receives each firmware block, the corresponding verification code is calculated by the verification algorithm; The calculated verification code is compared with the expected verification code attached from the sending end of the firmware block. If the comparison result is consistent, the firmware block is determined to be complete, otherwise, the firmware block is determined to be incomplete; A verification information record is generated for each firmware block, including the block number, the expected verification code, and the actual verification code; For the firmware block determined to be incomplete, the transmission is re-requested, and after re-receiving, the verification is performed again until success; For the firmware block determined to be complete, it is saved in the device, and the progress log is updated to record the time of successful transmission, the verification times, and the retransmission times; After all the firmware blocks are transmitted, a secondary verification of the overall firmware package is performed to ensure the integrity.

8. An electronic device, comprising: It comprises: a processor and a memory, wherein, the memory stores a computer program for calling by the processor; the processor executes the network connection reconnection-based Internet of Things device firmware upgrade method based on the lightweight MQTT protocol in the background by calling the computer program stored in the memory.

Citation Information

Patent Citations

  • Wireless firmware updating method used in vehicle networking system

    CN103347095A

  • Optical network unit equipment upgrading method and system based on continuous data transmission capability

    CN118555190A

  • Multi-channel firmware upgrading method and system supporting breakpoint resume

    CN119556960A

  • Method for predicting faults in electrical equipment based on multi-dimension time series

    WO2015176565A1