Off-network reconnection Internet of Things equipment firmware upgrading method based on lightweight MQTT protocol
By adopting a firmware upgrade method based on the lightweight MQTT protocol in IoT devices, and using dynamic block adjustment strategies and intelligent reconnection strategies, the problems of network instability and device resource limitation during firmware upgrades in the existing technology are solved, and efficient and reliable firmware upgrades are achieved.
Patent Information
- Application Number
- CN202510390236.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-31
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2045-03-31
AI Technical Summary
When existing IoT device firmware upgrade methods face problems such as network instability, transmission interruption and device resource constraints, it is difficult to achieve efficient and reliable firmware upgrades, resulting in delays and uncertainties in the upgrade process.
The firmware upgrade method of disconnection and reconnection of IoT devices based on the lightweight MQTT protocol is adopted. By collecting device information and network information, dynamic block adjustment strategies and intelligent reconnection strategies are built using adaptive algorithms, the size and download order of transmission firmware blocks are adjusted in real time, and the connection is restored to continue downloading when the network fluctuates.
It significantly improves the continuity and success rate of firmware upgrades, especially in complex and changeable network environments, improves transmission efficiency, reduces the waste of network resources, and optimizes the timing and order of reconnection of equipment.
Smart Images

Figure CN120151196A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of the Internet of Things, and specifically to a method for firmware upgrade of Internet of Things devices with network disconnection and reconnection based on the lightweight MQTT protocol. Background Art
[0002] The MQTT (Message Queuing Telemetry Transport) protocol is a lightweight message transmission protocol widely used in the communication between Internet of Things (IoT) devices. Its original design purpose is to provide reliable message delivery in low-bandwidth and unstable network environments. Firmware upgrade of IoT devices is a key link to repair vulnerabilities, add functions, and improve performance, which ensures the security and functional update of the devices. However, in practice, since IoT devices are usually distributed in various complex network environments, the firmware upgrade process faces many challenges, such as unstable network, transmission interruption, limited device resources, etc., which makes efficient and reliable firmware upgrade an urgent problem to be solved.
[0003] Existing methods for firmware upgrade of IoT devices usually rely on simple download and update mechanisms, lacking effective management of network fluctuations and dynamic adaptation capabilities for device resources. These methods often cannot handle transmission failures or data corruption caused by continuous network interruptions. In addition, traditional methods usually transmit the entire firmware package at one time during the download process, without considering the specific bandwidth and device status, which easily leads to excessive device load or waste of network resources. Moreover, the lack of the ability to predict network fluctuation conditions makes the device unable to start downloading efficiently immediately when the network resumes, resulting in delays and uncertainties in the upgrade process. These deficiencies limit the upgrade efficiency and reliability of IoT devices in a dynamic network environment.
[0004] Chinese patent application with publication number CN103347095A discloses a method for wireless firmware update in a vehicle networking system. The firmware file information is sent to the intelligent terminal at the remote server side. The intelligent terminal initializes the file block number index area according to the data block length set by the remote server and returns the data block length to the remote server. The remote server cuts the firmware into blocks according to the returned block length. The intelligent terminal applies to the remote server for sending data packets according to the block number index area, returns a firmware reception completion instruction to the remote server, and writes a firmware update record. The intelligent car-hailing terminal writes an upgrade flag and then automatically restarts the terminal. The terminal bootloader detects the upgrade flag. If it needs to be upgraded, the sent firmware is written 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, and it is difficult to ensure the transmission efficiency when the network fluctuates greatly.
[0005] To this end, the present invention proposes a method for firmware upgrade of Internet of Things devices with network disconnection and reconnection based on the lightweight MQTT protocol. Summary of the Invention
[0006] The present invention aims to solve at least one of the technical problems existing in the prior art. To this end, the present invention proposes a method for firmware upgrade of Internet of Things devices with network disconnection and reconnection based on the lightweight MQTT protocol, which significantly improves the continuity and success rate of firmware upgrade.
[0007] To achieve the above object, a method for firmware upgrade of Internet of Things devices with network disconnection and reconnection based on the lightweight MQTT protocol is proposed, including the following steps:
[0008] Step 1: Collect the device information set and the network information set;
[0009] Step 2: Based on the device information set and the network information set, use 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, use a time series prediction model to construct an intelligent reconnection strategy for adjusting the reconnection time;
[0010] Step 3: Use the dynamic block adjustment strategy to intelligently divide the transmitted firmware into blocks to adjust the size and download order of the transmitted firmware blocks in real time; and use the intelligent reconnection strategy to restore the connection and continue downloading when there is network fluctuation;
[0011] Step 4: Receive and verify the transmitted firmware blocks, generate a verification information set, and verify the integrity of the transmitted firmware blocks.
[0012] The collection method of the device information set is as follows:
[0013] Use the built-in hardware sensors of the device to collect the external parameters of the device, and collect the device status parameters through the interfaces provided by the operating system of the device;
[0014] The external parameters of the device and the device status parameters form the device information set.
[0015] The collection method of the network information set is as follows:
[0016] Collect the parameter values of various network parameters of the device during past firmware upgrades in real time through the network analysis tool installed on the device side;
[0017] Collect historical upgrade information through the data block transmission logs automatically recorded by the operating system of the device during past firmware upgrades;
[0018] The parameter values of the various network parameters and the historical upgrade information form the network information set.
[0019] The dynamic block adjustment strategy for determining the size and download priority of firmware chunks using an adaptive algorithm based on the device information set and the network information set includes the following steps:
[0020] Step 21: From the historical upgrade information in the network information set, filter out the firmware chunks that were successfully transmitted each time as successful chunk samples;
[0021] Step 22: During past firmware upgrades, at every preset transmission time interval, filter out all the successful chunk samples within that transmission time interval, and use the size of the successful chunk sample with the largest data volume among them as the chunk 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 the network information set, and the chunk size label for that transmission time interval, train a machine learning model for predicting the firmware chunk size;
[0023] The method for training the machine learning model for predicting the firmware chunk size is as follows:
[0024] For each transmission time interval, divide the various parameters in the device information set and the network information set according to whether they are fixed values. For the non-fixed value parameters, calculate the various statistical parameters of the parameter within that transmission time interval; combine the fixed value parameters with the various statistical parameters of the non-fixed values to form the feature vector for that transmission time interval;
[0025] Construct a machine learning model. The machine learning model takes the feature vector of each transmission time interval as input, takes the predicted value of the chunk size within that transmission time interval as output, takes the chunk size label within the transmission time interval as the prediction target, and takes the mean square error between the predicted value of the chunk size and the chunk size label as the loss function.
[0026] Step 24: According to the device information set and the network information set, calculate the chunk size adjustment factor BSF for each transmission time interval;
[0027] Step 25: Based on the chunk size adjustment factor BSF and the predicted value of the chunk size output by the machine learning model, calculate the recommended chunk size;
[0028] Step 26: For each firmware chunk, preset an importance coefficient BI for it; based on the importance coefficient and the network information set, calculate the priority coefficient of the firmware chunk; the dynamic block adjustment strategy includes setting the size of the firmware chunks within that transmission time interval to the recommended chunk size at the beginning of each transmission time interval, and setting the transmission priority of each firmware chunk within the transmission time interval to the priority coefficient.
[0029] The method for constructing an intelligent reconnection strategy for adjusting the reconnection time using a time series prediction model based on the device information set and the network information set is as follows:
[0030] In the device information set and the network information set, the past firmware upgrade process is segmented into multiple time series segments, such that each time series segment contains a specific network state and a device state;
[0031] Using statistical principles, various statistical parameters of the network state and the device state within each time series segment are statistically calculated as the reconnection features within that time series segment;
[0032] Using a data annotation tool to perform state type annotation on the network state and the device state in each time series segment, where the state types include connection interruption events and connection recovery events;
[0033] The time between any adjacent connection interruption event and connection recovery event is represented as a disconnection time period. Calculate the number of time series segments included in the duration of each disconnection time period, and use the duration of this disconnection time period as the duration label for this disconnection time period. In this disconnection time period, the various reconnection features of each time series segment are used to form a feature sequence according to the time series as the reconnection feature sequence;
[0034] Use the time series prediction model to receive the reconnection feature sequence as input. 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 durations and the duration labels 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 of the intelligent reconnection strategy.
[0036] The method for real-time adjusting the size of the transmitted firmware block is as follows:
[0037] When actually performing firmware upgrade on a device through the Internet of Things, at the beginning of each transmission time interval, statistically calculate the fixed-value parameters and various statistical parameters of non-fixed values in the device information set and the network information set in the previous transmission time interval to form an actual feature vector;
[0038] 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;
[0039] Calculate the block size adjustment coefficient for the previous transmission time interval;
[0040] Based on the predicted value of the block size and the block size adjustment coefficient, calculate the firmware block size for the next transmission time interval;
[0041] According to the calculated firmware block size, the subsequent firmware upgrade data packets are segmented to obtain multiple transmission firmware blocks;
[0042] At each unit time during the subsequent transmission of the transmission firmware blocks, calculate the priority coefficient of each transmission firmware block, and select the transmission firmware block with the largest priority coefficient 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] During the transmission of the transmission firmware blocks, after a connection interruption occurs:
[0045] Every other time series segment, collect the network status and device status, and obtain the corresponding reconnection features. Concatenate the reconnection features collected after the connection interruption occurs in chronological order to obtain the corresponding actual reconnection feature sequence;
[0046] Use the time series prediction model to predict the actual reconnection feature sequence to obtain the predicted reconnection duration of the output;
[0047] Before the predicted reconnection time, re-sort the transmission order of the transmission firmware blocks according to the importance coefficient;
[0048] Before reaching the predicted reconnection duration, perform reconnection attempts according to the preset reconnection period. When reaching the predicted reconnection duration, reduce the reconnection period by a preset ratio.
[0049] The method of receiving and verifying the transmission firmware blocks, generating a set of verification information, and verifying the integrity of the transmission firmware blocks is as follows:
[0050] Determine the verification algorithm to be used to detect data integrity;
[0051] After the device receives each transmission firmware block, calculate the corresponding verification code through the verification algorithm;
[0052] Compare the calculated verification code with the expected verification code attached from the sending end of the transmission firmware block. If the comparison result is consistent, judge that the transmission firmware block is complete; otherwise, judge that the transmission firmware block is incomplete;
[0053] Generate a verification information record for each transmission firmware block, including the block number, expected verification code, and actual verification code;
[0054] For the transmission firmware blocks determined to be incomplete, request retransmission, and verify again after receiving again until successful;
[0055] For the transmitted firmware blocks determined to be complete, save them in the device and update the progress log, recording the time of successful transmission, the number of verification attempts, and the number of retransmissions;
[0056] After all transmitted firmware blocks are completed, perform a secondary verification of the overall firmware package to ensure integrity; the method of the secondary verification is such as overall hash value verification.
[0057] An electronic device is proposed, including: a processor and a memory, wherein, a computer program for the processor to call is stored in the memory;
[0058] The processor executes the above-mentioned firmware upgrade method for the Internet of Things device with network disconnection and reconnection 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] The present invention collects a set of device information and a set of network information, and based on the set of device information and the set of network information, uses an adaptive algorithm to construct a dynamic block adjustment strategy for determining the size and download priority of firmware blocks; and based on the set of device information and the set of network information, uses a time series prediction model to construct an intelligent reconnection strategy for adjusting the reconnection time, uses the dynamic block adjustment strategy to intelligently divide the transmitted firmware into blocks to real-time adjust the size and download order of the transmitted firmware blocks; and uses the intelligent reconnection strategy to restore the connection and continue downloading when the network fluctuates, receive and verify the transmitted firmware blocks, generate a set of verification information, and verify the integrity of the transmitted firmware blocks; by proposing a dynamic block adjustment strategy to real-time monitor the network and device status, dynamically adjust the size of the transmitted data blocks to adapt to the current network conditions and device load, thereby improving the transmission efficiency and reducing the waste of network resources. The proposed intelligent reconnection strategy uses a time series prediction model to predict the network interruption and recovery timing, optimize the reconnection timing and order of the device, so that the device can quickly resume downloading after the network fluctuates. The combination of these two strategies can significantly improve the continuity and success rate of firmware upgrade, especially in a complex and changeable network environment. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 It is a flowchart of the firmware upgrade method for the Internet of Things device with network disconnection and reconnection based on the lightweight MQTT protocol in the present invention;
[0062] Figure 2 It is a schematic diagram of the steps of the dynamic block adjustment strategy in the present invention. DETAILED DESCRIPTION OF THE INVENTION
[0063] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative work belong to the scope of protection of the present invention.
[0064] As Figure 1 shown, the method for firmware upgrade of an Internet of Things device with network disconnection and reconnection based on the lightweight MQTT protocol includes the following steps:
[0065] Step 1: Collect the device information set and the network information set;
[0066] Step 2: Based on the device information set and the network information set, use 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, use a time series prediction model to construct an intelligent reconnection strategy for adjusting the reconnection time;
[0067] Step 3: Use the dynamic block adjustment strategy to intelligently divide the transmitted firmware into blocks to adjust the size and download order of the transmitted firmware blocks in real time; and use the intelligent reconnection strategy to restore the connection and continue downloading when the network fluctuates;
[0068] Step 4: Receive and verify the transmitted firmware blocks, generate a verification information set, and verify the integrity of the transmitted firmware blocks.
[0069] Among them, the collection method of the device information set is:
[0070] Use the built-in hardware sensors of the device to collect external device parameters, and collect device status parameters through the interfaces provided by the device's operating system;
[0071] The external device parameters and the device status parameters form the device information set.
[0072] Specifically, the external device parameters may include the GPS positioning of the device to provide the location of the device when the network signal strength considering the geographical location is required for the device;
[0073] And specifically, the device status parameters and their collection methods include:
[0074] The firmware version read from the system file when the device is started, the CPU and memory usage rates regularly collected through the interfaces provided by the operating system, the remaining storage space regularly checked and collected through the file system interface before and during the firmware update, and the battery status obtained through the power management interface of the device.
[0075] Furthermore, the collection method of the network information set is:
[0076] Collect the parameter values of various network parameters of the device during past firmware upgrade processes in real time through a network analysis tool installed on the device side;
[0077] Collect historical upgrade information through the data block transfer logs automatically recorded by the device's operating system during past firmware upgrade processes;
[0078] The parameter values of the various network parameters and the historical upgrade information form a network information set.
[0079] Specifically, the network parameters and their collection methods include:
[0080] Regularly measure network bandwidth and latency using a network speed test tool or the built-in speed test function of an application;
[0081] Obtain the signal strength through the network interface of the device's operating system;
[0082] Obtain the network jitter frequency by continuously measuring the change in network latency and calculating its standard deviation;
[0083] Record the logs of network status changes in the network management module, and obtain the network disconnection frequency and historical recovery time by analyzing the log data;
[0084] The historical upgrade information includes the size of each firmware block transferred each time, the success and failure situations of the transfer, the transfer time, the number of retry attempts, etc. during each firmware upgrade process.
[0085] Such as Figure 2 As shown in the schematic diagram of the steps of the dynamic block adjustment strategy in, the dynamic block adjustment strategy for determining the size and download priority of firmware blocks by using an adaptive algorithm based on the device information set and the network information set includes the following steps:
[0086] Step 21: From the historical upgrade information in the network information set, screen out the firmware blocks that are successfully transferred each time as successful block samples;
[0087] Step 22: During past firmware upgrade processes, at every preset transmission time interval, screen out all the successful block samples within that transmission time interval, and use the size of the successful block sample with the largest data volume among them as the block size label for that transmission time interval; It can be understood that the block size label is the size of the largest firmware block that can be transferred 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 the network information set and the block size label for that transmission time interval, train a machine learning model for predicting the firmware block size;
[0089] Specifically, the method for training and predicting the firmware block size of the machine learning model is as follows:
[0090] For each transmission time interval, the parameters in the device information set and the network information set are divided according to whether they are fixed values. For the non-fixed value parameters, various statistical parameters of the parameter within the transmission time interval are statistically calculated; the fixed value parameters and the various statistical parameters of the non-fixed values together form the feature vector of the transmission time interval.
[0091] Specifically, the statistical parameters include the average value, standard deviation, etc.; the non-fixed value parameters are, for example, network speed, signal strength, etc.
[0092] Build a machine learning model. The machine learning model takes the feature vector of each transmission time interval as the input, takes the predicted value of the block size of the firmware block within the transmission time interval as the output, takes the block size label within 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.
[0093] Step 24: Calculate the block size adjustment factor BSF for each transmission time interval according to the device information set and the network information set.
[0094] Specifically, the calculation method of the block size adjustment factor BSF is as follows:
[0095] Mark the mean value of the available network bandwidth in each transmission time interval as BW.
[0096] Mark the mean value of the network delay in each transmission time interval as LT.
[0097] Mark the mean value of the network jitter in each transmission time interval as JT.
[0098] Mark the mean value of the CPU usage rate of the device in each transmission time interval as CU.
[0099] Mark the mean value of the memory usage rate of the device in each transmission time interval as MU.
[0100] Mark the mean value of the battery power level in each transmission time interval as BL.
[0101] Then the calculation formula of the block size adjustment factor BSF is:
[0102] Among them, a1, a2, a3, a4, a5, and a6 are all preset proportionality coefficients; it should be noted that in the calculation formula of the block size adjustment factor BSF, bandwidth, latency, and jitter are used to measure the network transmission capacity. In the case of high bandwidth, low latency, and low jitter, the data transmission efficiency is higher. Therefore, the block size can be increased. In the case of high loads on both the CPU and memory of the device, the block size should be reduced to reduce the processing pressure and memory occupancy. When the battery power is sufficient, the block size can be appropriately increased to accelerate the transmission;
[0103] Step 25: Calculate the recommended block size based on the block size adjustment factor BSF and the predicted value of the block size output by the machine learning model;
[0104] Specifically, the method for the recommended block size is as follows:
[0105] Mark the recommended block size as BS;
[0106] Mark the predicted value of the block size output by the machine learning model as PBS;
[0107] Then the calculation formula for the recommended block 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 factor combines information on the real-time network and device state. 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, preset an importance coefficient BI for it; calculate the priority coefficient of the firmware block based on the importance coefficient and the network information set;
[0110] The dynamic block adjustment strategy includes setting the size of the firmware block within the transmission time interval to the recommended 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.
[0111] Specifically, the importance coefficient is generally determined according to the actual content within the firmware block. Generally, key data blocks in the firmware upgrade program require a higher importance coefficient to be transmitted first;
[0112] Furthermore, the method for calculating the priority coefficient of the firmware block is as follows:
[0113] Mark the priority coefficient as PR; mark the network signal strength when sending the firmware block as SG, and mark the network latency when sending the firmware block as LTR;
[0114] The calculation formula for the priority coefficient is as follows: It should be noted that this formula evaluates the current network conditions by combining the ratio of signal strength and delay. When the signal strength is high and the delay is low, the transmission conditions are good, so important firmware blocks can be preferentially transmitted.
[0115] Furthermore, the method of constructing an intelligent reconnection strategy for adjusting the reconnection time based on the device information set and the network information set using a time series prediction model is as follows:
[0116] In the device information set and the network information set, the past firmware upgrade process is segmented into multiple time series segments, so that each time series segment contains specific network states and device states; specifically, the network states and device states include ideal network states such as high bandwidth and low latency, and device load states such as high CPU usage and low battery power, etc.;
[0117] Using statistical principles, various statistical parameters of the network state and device state within each time series segment are statistically calculated as the reconnection features within that time series segment;
[0118] Using a data annotation tool to label the state types of the network state and device state in each time series segment, and the state types include connection interruption events and connection restoration events;
[0119] The time between any adjacent connection interruption event and connection restoration event is represented as a disconnection time period, the number of time series segments included in the duration of each disconnection time period is calculated, and the duration of this disconnection time period is used as the duration label of this disconnection time period. In this disconnection time period, the various reconnection features of each time series segment are used to form a feature sequence according to the time series as the reconnection feature sequence;
[0120] Using a time series prediction model to receive the reconnection feature sequence as input, the time series prediction model takes the predicted reconnection duration as output, uses the duration label as the prediction target, and uses the mean square error between the predicted reconnection durations and the duration labels of all disconnection time periods as the loss function to train the time series prediction model; specifically, the time series prediction model includes an LSTM model, an RNN model, or a GRU model, etc.;
[0121] The predicted reconnection duration output by the time series prediction model after training is the adjustment window of the intelligent reconnection strategy.
[0122] Furthermore, the method of adjusting the size of the transmitted firmware block in real time is as follows:
[0123] When actually performing firmware upgrade on a device through the Internet of Things, at the beginning of each transmission time interval, the statistical parameters of the fixed-value parameters and non-fixed-value parameters in the device information set and the network information set in the previous transmission time interval are counted to form an actual feature vector. Since the network changes little in a short period of time, therefore, the data of the most recent previous transmission time interval is considered as the basis for making various decisions in the next transmission time interval.
[0124] Input the actual feature vector into a machine learning model to obtain the predicted value of the block size output by the machine learning model.
[0125] Calculate the block size adjustment coefficient of the previous transmission time interval.
[0126] Based on the predicted value of the block size and the block size adjustment coefficient, calculate the firmware block size of the next transmission time interval.
[0127] According to the calculated firmware block size, divide the subsequent firmware upgrade data packets into blocks to obtain multiple transmission firmware blocks.
[0128] At each unit time during the subsequent transmission of the transmission firmware blocks, calculate the priority coefficient of each transmission firmware block, and select the transmission firmware block with the largest priority coefficient 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] During the transmission of the transmission firmware blocks, after a connection interruption occurs:
[0131] Every other time series segment, collect the network status and the device status once, and obtain the corresponding reconnection features. Concatenate the reconnection features collected after the connection interruption occurs in chronological order to obtain the corresponding actual reconnection feature sequence.
[0132] Use a time series prediction model to predict the actual reconnection feature sequence to obtain the predicted reconnection duration of the output.
[0133] Before the predicted reconnection time, re-sort the transmission order of the transmission firmware blocks according to the importance coefficient to ensure that the key data blocks are preferentially prepared for transmission.
[0134] Before reaching the predicted reconnection duration, perform reconnection attempts according to a preset reconnection period. When reaching the predicted reconnection duration, reduce the reconnection period by a preset ratio. It can be understood that before reaching the predicted reconnection duration, since the possibility of reconnection is small, the reconnection can be initiated at a lower frequency to save network resources and enable the Internet of Things device to efficiently restore the connection during network fluctuations.
[0135] Further, the method for receiving and verifying the transmitted firmware block, generating a set of verification information, and verifying the integrity of the transmitted firmware block is as follows:
[0136] Determine the verification algorithm to be used to detect data integrity; the verification algorithms include CRC32, MD5, SHA-256, etc.;
[0137] After the device receives each transmitted firmware block, calculate the corresponding verification code through the verification algorithm;
[0138] Compare the calculated verification code with the expected verification code attached by the sender of the transmitted firmware block. If the comparison result is consistent, it is determined that the transmitted firmware block is complete; otherwise, it is determined that the transmitted firmware block is incomplete;
[0139] Generate a verification information record for each transmitted firmware block, including the block number, the expected verification code, and the actual verification code;
[0140] For the transmitted firmware block determined to be incomplete, request retransmission. After re-receiving, perform verification again until successful;
[0141] For the transmitted firmware block determined to be complete, save it in the device and update the progress log, recording the time of successful transmission, the number of verification times, and the number of retransmission times;
[0142] After all transmitted firmware blocks are transmitted, perform a secondary verification of the overall firmware package to ensure integrity; the method of the secondary verification is such as overall hash value verification.
[0143] In addition, parts of the above technical solutions provided in the embodiments of the present application that are consistent with the corresponding technical solutions in the prior art in terms of implementation principles are not described in detail to avoid excessive elaboration.
[0144] As described above in the specific embodiments, the purpose, technical solutions, and beneficial effects of the present invention are further described in detail. It should be understood that the above are only specific embodiments of the present invention and are not used to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.
[0145] The above preset parameters or preset thresholds are all set by those skilled in the art according to the actual situation or obtained through a large amount of data simulation.
[0146] The above embodiments are only used to illustrate the technical method of the present invention and not to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical method of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical method of the present invention.
Claims
1. A method for upgrading the firmware of an IoT device after disconnection and reconnection based on the lightweight MQTT protocol, characterized in that: The following steps are involved: Step 1: Collect device information set and network information set; Step 2: Based on the device information set and the network information set, an adaptive algorithm is used to build a dynamic block adjustment strategy for determining the size and download priority of the firmware block; and based on the device information set and the network information set, an intelligent reconnection strategy for adjusting the reconnection time is built using a time series prediction model; Step 3: Use dynamic block adjustment strategy to intelligently divide the transmission firmware into blocks to adjust the size and download order of the transmission firmware blocks in real time; And use intelligent reconnection strategy to restore connection and continue downloading when network fluctuations occur; Step 4: Receive and verify the transmission firmware block, generate a verification information set, and verify the integrity of the transmission firmware block.
2. The method for upgrading the firmware of an IoT device based on the lightweight MQTT protocol after disconnection and reconnection according to claim 1, characterized in that: The device information set is collected in the following manner: Use the device's built-in hardware sensors to collect device external parameters, and use the interface provided by the device's operating system to collect device status parameters; The device external parameters and device status parameters constitute a device information set.
3. The method for upgrading the firmware of an IoT device based on the lightweight MQTT protocol after disconnection and reconnection according to claim 2 is characterized in that: The network information set is collected in the following manner: The network analysis tool installed on the device collects the parameter values of various network parameters of the device in real time during the past firmware upgrade process; Collect historical upgrade information by automatically recording the data block transfer logs generated during past firmware upgrades from the device's operating system; The parameter values of the various network parameters and the historical upgrade information constitute a network information set.
4. The method for upgrading the firmware of an IoT device based on the lightweight MQTT protocol after disconnection and reconnection according to claim 3 is characterized in that: The method of constructing a dynamic block adjustment strategy for determining the size and download priority of firmware blocks based on a device information set and a network information set using an adaptive algorithm comprises the following steps: Step 21: Filter out the firmware blocks that are successfully transmitted each time from the historical upgrade information of the network information set as successful block samples; Step 22: During the past firmware upgrade process, at every preset transmission time interval, all successful block samples within the transmission time interval are screened out, and the size of the successful block sample with the largest data volume is used as the block size label of the transmission time interval; Step 23: Based on the parameters corresponding to each transmission time interval and the block size label of the transmission time interval in the device information set and the network information set, training a machine learning model for predicting the firmware block size; Step 24: Calculate a block size adjustment factor BSF in each transmission time interval according to the device information set and the network information set; Step 25: Calculate the recommended block size based on the block size adjustment factor BSF and the predicted value of the block size output by the machine learning model; Step 26: For each firmware block, set the importance coefficient BI 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 includes setting the size of the firmware block within the transmission time interval to the recommended 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.
5. The method for upgrading the firmware of an IoT device based on the lightweight MQTT protocol after disconnection and reconnection according to claim 4 is characterized in that: The method of training the machine learning model for predicting firmware block size is: For each transmission time interval, the parameters in the device information set and the network information set are divided according to whether they are fixed values. For parameters with non-fixed values, various statistical parameters of the parameters within the transmission time interval are counted; the fixed value parameters and the various statistical parameters with non-fixed values are combined to form a characteristic vector of the transmission time interval; A machine learning model is constructed. The machine learning model takes the feature vector of each transmission time interval as input, takes the predicted value of the block size of the firmware block within the transmission time interval as output, takes the block size label within 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.
6. The method for upgrading the firmware of an IoT device after disconnection and reconnection based on the lightweight MQTT protocol according to claim 5, characterized in that: The method of constructing an intelligent reconnection strategy for adjusting the reconnection time based on the device information set and the network information set using the time series prediction model is as follows: The past firmware upgrade process in the device information set and the network information set is divided into multiple time series segments, so that each time series segment contains a specific network state and device state; Use statistical principles to count various statistical parameters of network status and device status in each time series segment as the reconnection features in the time series segment; Use data annotation tools to annotate the network status and device status in each time series segment with the status type; The time between any adjacent connection interruption event and connection recovery event is represented as a disconnection time period, the number of time series segments contained in the duration of each disconnection time period is calculated, and the duration of the disconnection time period is used 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 series segment according to the time series is used as the reconnection feature sequence; Using a time series prediction model to receive a reconnection feature sequence as input, the time series prediction model uses a predicted reconnection duration as output, uses a duration label as a prediction target, uses a mean square error between the predicted reconnection duration and the duration label for all disconnection time periods as a loss function, and trains the time series prediction model; The predicted reconnection duration output by the time series prediction model after training is the adjustment window of the intelligent reconnection strategy.
7. The method for upgrading the firmware of an IoT device based on the lightweight MQTT protocol after disconnection and reconnection according to claim 6, characterized in that: The method of adjusting the size of the transmission firmware block in real time is: When the firmware of a device is actually upgraded through 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 the network information set in the previous transmission time interval are counted to form an actual feature vector; Input the actual feature vector into the machine learning model to obtain a predicted value of the block size output by the machine learning model; calculating a block size adjustment factor for a previous transmission time interval; Calculate the firmware block size for the next transmission time interval based on the predicted value of the block size and the block size adjustment coefficient; According to the calculated firmware block size, the subsequent firmware upgrade data packet is divided into blocks to obtain multiple transmission firmware blocks; In each unit time of the subsequent transmission of the transmission firmware blocks, the priority coefficient of each transmission firmware block is calculated, and the transmission firmware block with the largest priority coefficient is selected for transmission.
8. The method for upgrading the firmware of an IoT device based on the lightweight MQTT protocol after disconnection and reconnection according to claim 7, characterized in that: The method of using the intelligent reconnection strategy to restore the connection and continue downloading when the network fluctuates is as follows: When a connection is interrupted during the transfer of a transfer firmware block: The network status and device status are collected once every time series segment, and the corresponding reconnection features are obtained. The reconnection features collected after the connection interruption occurs are spliced in chronological order to obtain the corresponding actual reconnection feature sequence; Use the time series prediction model to predict the actual reconnection feature sequence and obtain the output predicted reconnection duration; Before the predicted reconnection time, re-sort the transmission order of the transmission firmware blocks according to the importance coefficients; Before the predicted reconnection duration is reached, a reconnection attempt is performed according to a preset reconnection period, and when the predicted reconnection duration is reached, the reconnection period is reduced according to a preset ratio.
9. The method for upgrading the firmware of an IoT device based on the lightweight MQTT protocol after disconnection and reconnection according to claim 8, characterized in that: The receiving and verifying transmission firmware blocks, generating a verification information set, and verifying the integrity of the transmission firmware blocks are performed in the following manner: Determine the verification algorithm used to check data integrity; After receiving each transmission firmware block, the device calculates the corresponding checksum through the checksum algorithm; Compare the calculated checksum with the expected checksum attached from the sender of the transmission firmware block, if the comparison result is consistent, the transmission firmware block is judged to be complete, otherwise, the transmission firmware block is judged to be incomplete; Generate a checksum information record for each transfer firmware block, including a block number, an expected checksum, and an actual checksum; For the transmission firmware block that is judged to be incomplete, re-request the transmission, re-receive and re-check until it succeeds; For the firmware blocks that are judged to be complete, they are saved in the device and the progress log is updated to record the time of successful transmission, the number of verifications and the number of retransmissions; After all the firmware blocks have been transferred, a secondary check is performed on the entire firmware package to ensure integrity.
10. An electronic device, characterized in that: include: processor and memory, wherein The memory stores a computer program for the processor to call; The processor executes the method for upgrading the firmware of an IoT device based on the lightweight MQTT protocol after disconnection and reconnection as described in any one of claims 1 to 9 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
Time series anomaly prediction and alert
CN115220940A
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
Enhanced broadcast concurrent OTA firmware upgrade method based on bluetooth mesh
US20230179668A1
Cited By
Upload control method and device for refueling information of hydrogen refueling station and electronic equipment
CN120332650A
A method, device and electronic device for controlling the upload of hydrogen filling station filling information
CN120332650B
MCU low-power-consumption firmware upgrading method and system based on energy self-adaption
CN120631410A
Energy-adaptive mcu low-power firmware upgrade method and system
CN120631410B
Large-scale equipment trunking communication method
CN120729918A
