Method and system for upgrading water meter

The FOTA upgrade of the water meter is achieved through the Bluetooth broadcast channel, which solves the upgrade failure and time-consuming problems caused by poor wireless network signals, and realizes efficient and low-power multi-device upgrades in remote areas.

CN120343541APending Publication Date: 2025-07-18NINGBO WATER METER (GRP) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510394042.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-31
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

The existing water meter upgrade method can easily lead to data loss or update failure in remote areas with poor wireless network signals, which takes a long time and is cumbersome.

Method used

The Bluetooth broadcast channel is used to upgrade FOTA, and the device broadcasts the upgrade request command through Bluetooth, generates the target format differential data and sends the upgrade packet. The Bluetooth receiving device receives and verifies the upgrade packet, realizing the connectionless control upgrade of multiple devices.

Benefits of technology

In areas without base stations or poor signal, resource consumption is reduced, upgrade time is simplified, upgrade process is improved, upgrade efficiency is improved, and power consumption is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120343541A_ABST
    Figure CN120343541A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a water meter upgrading method and system, and the method comprises the steps: Bluetooth transmitting equipment broadcasts an upgrading request command to inform Bluetooth receiving equipment to prepare for upgrading; the Bluetooth receiving equipment determines an equipment mode as an upgrading mode based on the upgrading request command; the Bluetooth sending device generates target format differential data based on the original version data and the upgraded version data; generating an upgrade package based on the target format differential data; sending an upgrade package to the Bluetooth receiving device through a broadcast channel; the Bluetooth receiving device receives the upgrade package through the broadcast channel, so that one Bluetooth sending device can control one or more Bluetooth receiving devices to achieve FOTA upgrade, especially in a remote area without a base station or with poor signals, the FOTA upgrade of the multiple Bluetooth receiving devices can be achieved without specially enhancing signals or establishing a base station, and the FOTA upgrade efficiency is improved. And time resources consumed by upgrading the Bluetooth receiving equipment are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of Bluetooth technology, and particularly to an upgrade method for water meters. Background Art

[0002] When a water meter has no Bluetooth module, the general method for upgrading data is to use infrared for one-to-one upgrading, but this method is time-consuming. Or, data interaction is combined with a platform (the water meter is registered on the platform, and the upgrade time is sent) to implement firmware over-the-air (FOTA) firmware data upgrade. The process of the water meter using FOTA upgrade combined with platform interaction is as follows: obtain the txt file upgrade package; on the table-side integrated platform, select the corresponding protocol according to different telecom operators and mobile operators, and then register the water meter according to the IMEI and meter number. After successful registration, upload the upgrade package through the integrated platform, wait for the table-side to report data, and the platform to send commands to query the version and upgrade time. The table-side responds to the corresponding commands. When the upgrade time arrives, the water meter starts to upgrade. During the upgrade process, the table-side interacts with the platform. If the wireless network signal is poor and the platform does not receive a response from the water meter within the specified time, it is necessary to wait for a period of time before continuing the upgrade. If there is no wireless network, the upgrade fails.

[0003] This upgrade process is relatively cumbersome, and when the network signal is poor during the upgrade process, it is necessary to wait repeatedly. Especially in remote areas without base stations or areas with poor signals, there is a high probability of data loss or update failure, increasing the time resources consumed for water meter upgrade. Summary of the Invention

[0004] In view of this, the embodiments of this specification provide an upgrade method for water meters. One or more embodiments of this specification also relate to an upgrade system for water meters to solve the technical defects existing in the prior art.

[0005] According to the first aspect of the embodiments of this specification, an upgrade method for a water meter is provided. The method includes:

[0006] The Bluetooth sending device broadcasts an upgrade request command to notify the Bluetooth receiving device to prepare for upgrade;

[0007] Based on the upgrade request command, the Bluetooth receiving device determines that the device mode is the upgrade mode;

[0008] The Bluetooth sending device generates target format differential data based on the original version data and the upgrade version data; generates an upgrade package based on the target format differential data; and sends the upgrade package to the Bluetooth receiving device through the broadcast channel;

[0009] The Bluetooth receiving device receives the upgrade package through the broadcast channel.

[0010] In a possible implementation, the upgrade package includes a broadcast packet; generating the target format differential data based on the original version data and the upgraded version data includes:

[0011] The Bluetooth sending device generates differential data based on the original version data and the upgraded version data through a differential algorithm;

[0012] Based on the differential data, the target format differential data is generated through a constructor.

[0013] In a possible implementation, the upgrade package includes a verification broadcast packet; the Bluetooth sending device generating the upgrade package based on the target format differential data includes:

[0014] The Bluetooth sending device determines verification data from the target format differential data based on a byte threshold;

[0015] Based on the verification data, a first verification result is generated through a verification algorithm;

[0016] Based on the byte threshold, a target broadcast packet sequence number matching the byte threshold is determined;

[0017] Based on the first verification result and the target format differential data, a verification broadcast packet corresponding to the target broadcast packet sequence number is generated.

[0018] In a possible implementation, the upgrade package includes a verification broadcast packet. After the Bluetooth receiving device receives the upgrade package through the broadcast channel, it further includes:

[0019] The Bluetooth receiving device obtains verification data and a first verification result based on the verification broadcast packet;

[0020] Based on the verification data, a second verification result is generated through a verification algorithm;

[0021] Based on the first verification result being the same as the second verification result, verification success is determined; or, based on the first verification result being different from the second verification result, the device mode is determined to be the running mode.

[0022] In a possible implementation, the upgrade package includes multiple broadcast packets, and the broadcast packet includes a broadcast packet sequence number. After the Bluetooth receiving device receives the upgrade package through the broadcast channel, it further includes:

[0023] The Bluetooth receiving device determines packet loss based on multiple broadcast packet sequence numbers and broadcasts packet loss broadcast information;

[0024] The Bluetooth sending device receives the packet loss broadcast information sent by the Bluetooth receiving device; determines a target packet loss broadcast packet based on the packet loss broadcast information; and sends the target packet loss broadcast packet to the Bluetooth receiving device through the broadcast channel;

[0025] The Bluetooth receiving device receives the target packet loss broadcast packet corresponding to the packet loss broadcast information.

[0026] In a possible implementation, the upgrade package includes firmware upgrade data; after the Bluetooth sending device sends the upgrade package to the Bluetooth receiving device through the broadcast channel, it further includes:

[0027] The Bluetooth sending device generates a third verification result based on the firmware upgrade data through a verification algorithm;

[0028] Generates a notification verification packet based on the third verification result;

[0029] Broadcasts the notification verification packet.

[0030] In a possible implementation, the upgrade package includes firmware upgrade data; after the Bluetooth receiving device receives the upgrade package through the broadcast channel, it further includes:

[0031] The Bluetooth receiving device receives the notification verification packet and parses out the third verification result from the notification verification packet;

[0032] Parses out the firmware upgrade data based on the upgrade package;

[0033] Generates a fourth verification result based on the firmware upgrade data through a verification algorithm;

[0034] Determines that the verification is successful based on the third verification result being the same as the fourth verification result; or determines that the device mode is the running mode based on the third verification result being different from the fourth verification result.

[0035] In a possible implementation, the target format differential data includes differential data in the ArrayBuffer data format and parsed in hexadecimal.

[0036] In a possible implementation, after the Bluetooth sending device sends the upgrade package to the Bluetooth receiving device through the broadcast channel, it further includes:

[0037] The Bluetooth sending device broadcasts an upgrade end command;

[0038] The Bluetooth receiving device receives the upgrade end command; and upgrades according to the upgrade package based on the upgrade end command.

[0039] In a second aspect, an upgrade system for a water meter is provided, and the system includes a Bluetooth sending device and the Bluetooth receiving device;

[0040] The Bluetooth sending device is used to broadcast an upgrade request command to notify the Bluetooth receiving device to prepare for upgrade;

[0041] The Bluetooth receiving device is used to determine the device mode as the upgrade mode based on the upgrade request command;

[0042] The Bluetooth sending device is further used to generate target format differential data based on the original version data and the upgrade version data; generate an upgrade package based on the target format differential data; and send the upgrade package to the Bluetooth receiving device through a broadcast channel;

[0043] The Bluetooth receiving device is further used to receive the upgrade package through the broadcast channel.

[0044] An embodiment of this specification implements an upgrade method and system for a water meter. The method includes: The Bluetooth sending device broadcasts an upgrade request command to notify the Bluetooth receiving device to prepare for upgrade; The Bluetooth receiving device determines the device mode as the upgrade mode based on the upgrade request command; The Bluetooth sending device generates target format differential data based on the original version data and the upgrade version data; generates an upgrade package based on the target format differential data; sends the upgrade package to the Bluetooth receiving device through a broadcast channel; The Bluetooth receiving device receives the upgrade package through the broadcast channel. Thus, one Bluetooth sending device can control one or more Bluetooth receiving devices to achieve FOTA upgrade. Especially in remote areas without base stations or with poor signals, multiple Bluetooth receiving devices can achieve FOTA upgrade without specifically enhancing the signal or establishing a base station, reducing the time resources consumed for the upgrade of the Bluetooth receiving device. Description of the Drawings

[0045] Figure 1 is a flowchart of an upgrade method for a water meter provided by an embodiment of this specification;

[0046] Figure 2 is a communication schematic diagram provided by an embodiment of this specification;

[0047] Figure 3 is a schematic diagram of obtaining a broadcast packet provided by an embodiment of this specification;

[0048] Figure 4 is a flowchart of a broadcast provided by an embodiment of this specification;

[0049] Figure 5 is an upgrade flowchart provided by an embodiment of this specification;

[0050] Figure 6 is a schematic structural diagram of an upgrade system for a water meter provided by an embodiment of this specification. Detailed Embodiments

[0051] Numerous specific details are set forth in the following description in order to provide a thorough understanding of this specification. However, this specification can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the connotation of this specification. Therefore, this specification is not limited by the specific implementations disclosed below.

[0052] The terms used in one or more embodiments of this specification are for the purpose of describing specific embodiments only and are not intended to limit one or more embodiments of this specification. The singular forms "a" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and encompasses any or all possible combinations of one or more of the associated listed items.

[0053] It should be understood that although the terms first, second, etc. may be used in one or more embodiments of this specification to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".

[0054] In this specification, a method for upgrading a water meter is provided. This specification also relates to a water meter upgrade system and a Bluetooth receiving device, which will be described in detail one by one in the following embodiments.

[0055] Figure 1 is a flowchart of a method for upgrading a water meter provided by an embodiment of this specification. As Figure 1 shown, the method includes:

[0056] Step 101, the Bluetooth sending device broadcasts an upgrade request command to notify the Bluetooth receiving device to prepare for upgrading.

[0057] In some embodiments, the Bluetooth sending device includes, but is not limited to, a laptop computer, a desktop computer, a mobile phone, a tablet or a wearable device, etc. The Bluetooth sending device has a Bluetooth function, and the Bluetooth receiving device also has a Bluetooth function. For example, the Bluetooth sending device is a mobile phone with a Bluetooth function, and the Bluetooth receiving device is a smart water meter with a Bluetooth function.

[0058] The upgrade request command includes the software upgrade version number. The Bluetooth sending device first broadcasts an upgrade request command including the software upgrade version number to notify the Bluetooth receiving device to prepare for the upgrade. The Bluetooth receiving device automatically enters the upgrade mode based on the upgrade request command. However, if the Bluetooth receiving device does not scan the upgrade request command, it does not enter the upgrade mode and operates normally, waiting for the next upgrade.

[0059] The Bluetooth sending device can make at least one Bluetooth receiving device enter the upgrade mode by broadcasting the upgrade request command, and the Bluetooth sending device communicates and connects with at least one Bluetooth receiving device. Figure 2 It is a communication schematic diagram provided by an embodiment of this specification. As Figure 2 shown, the Bluetooth sending device communicates and connects with n Bluetooth receiving devices through broadcasting, where n is an integer greater than or equal to 1, and BLE represents the Bluetooth function. For example, the mobile phone broadcasts the upgrade request command through the Bluetooth function, and multiple intelligent water meters automatically enter the upgrade mode based on the upgrade request command and wait for the mobile phone to send the upgrade package available for upgrade.

[0060] To improve the sending efficiency, after the Bluetooth sending device sends the upgrade request command, it does not need to check the response signal generated and sent by the Bluetooth receiving device according to the upgrade request command, and directly executes step 103. Thus, the Bluetooth sending device and the Bluetooth receiving device do not need to establish a connection, saving the cumbersome steps such as pairing and connecting.

[0061] Step 201: The Bluetooth receiving device determines that the device mode is the upgrade mode based on the upgrade request command.

[0062] In some embodiments, the Bluetooth receiving device includes an intelligent water meter. The Bluetooth receiving device is powered on and configured in the mode of broadcasting while scanning. If it scans the upgrade request command, it parses the software upgrade version number from the upgrade request command and determines the local version number. When the local version number is lower than the software upgrade version number, it enters the upgrade mode. Or, the upgrade request command includes the software upgrade version number and the version number to be upgraded, and the version number to be upgraded is the version number before the upgrade. The Bluetooth receiving device compares whether the version number to be upgraded is the same as the local version number. When the version number to be upgraded is the same as the local version number, it enters the upgrade mode.

[0063] After the Bluetooth receiving device receives the upgrade request command, it directly determines whether to change the device mode to the upgrade mode without replying to the upgrade request command. Thus, the Bluetooth sending device and the Bluetooth receiving device do not need to establish a connection, saving the cumbersome steps such as pairing and connecting.

[0064] Step 102: The Bluetooth sending device generates the target format differential data based on the original version data and the upgrade version data; generates the upgrade package based on the target format differential data; and sends the upgrade package to the Bluetooth receiving device through the broadcast channel.

[0065] In some embodiments, the original version data is the software data before the upgrade, the upgraded version data is the software data after the upgrade, the original version data corresponds to the version number to be upgraded, and the upgraded version data corresponds to the software upgrade version number. The target format differential data includes the ArrayBuffer data format and the differential data parsed in hexadecimal. The broadcast channel includes at least one channel available for broadcasting. The upgrade package is a data packet for the Bluetooth receiving device to perform an upgrade.

[0066] The upgrade package includes at least one broadcast packet. When there are multiple broadcast packets, the Bluetooth transmitting device sends the current broadcast packet in the preset broadcast time period in the order of packet arrangement; after waiting for the preset interval time period, it then sends the next broadcast packet in the order of packet arrangement in the preset broadcast time period.

[0067] For example, the broadcast channels include channels 37, 38, and 39, and the Bluetooth transmitting device sends broadcast packets on channels 37, 38, and 39 respectively. When there are multiple broadcast packets, the preset broadcast time period is 100 ms, and the preset interval time period is 20 ms, the Bluetooth transmitting device sends the current broadcast packet on channels 37, 38, and 39 respectively within 100 ms in the order of packet arrangement; waits for 20 ms, and then sends the next broadcast packet on channels 37, 38, and 39 respectively within 100 ms in the order of packet arrangement until all the broadcast packets are sent.

[0068] Step 202: The Bluetooth receiving device receives the upgrade package through the broadcast channel.

[0069] In some embodiments, the upgrade package includes at least one broadcast packet, and the Bluetooth receiving device scans the broadcast packets sent by the WeChat mini-program item by item for upgrading.

[0070] An upgrade method for a water meter provided by an embodiment of this specification. The Bluetooth transmitting device broadcasts an upgrade request command to notify the Bluetooth receiving device to prepare for the upgrade; the Bluetooth receiving device determines the device mode as the upgrade mode based on the upgrade request command; the Bluetooth transmitting device generates target format differential data based on the original version data and the upgraded version data; generates an upgrade package based on the target format differential data; sends the upgrade package to the Bluetooth receiving device through the broadcast channel; the Bluetooth receiving device receives the upgrade package through the broadcast channel, so that 1 Bluetooth transmitting device can control 1 or more Bluetooth receiving devices to achieve FOTA upgrade. Especially in remote areas without base stations or with poor signals, it is possible to achieve FOTA upgrade for multiple Bluetooth receiving devices without specifically enhancing the signal or establishing a base station, reducing the time resources consumed for the upgrade of the Bluetooth receiving device.

[0071] The following is further described in conjunction with the attached Figure 1 , taking the upgrade method of the water meter provided by this specification as an example.

[0072] In a possible implementation, the upgrade package includes broadcast packets; in step 102, the Bluetooth sending device generates differential data in a target format based on the original version data and the upgraded version data, including: step 1021, the Bluetooth sending device generates differential data based on the original version data and the upgraded version data through a differential algorithm; step 1022, the Bluetooth sending device generates differential data in the target format based on the differential data through a constructor.

[0073] In some embodiments, the Bluetooth sending device has control upgrade software, which can be an application (APP), a web page, a mini-program, etc., providing a function to control the upgrade of the Bluetooth receiving device. The mini-program includes a WeChat mini-program. The Bluetooth sending device can enter the operation interface of the control upgrade software, analyze the differential data required for FOTA through a differential algorithm. The control upgrade software provides a constructor, and through the constructor of the control upgrade software, the format of the differential data is converted, and the data format of the differential data is converted into a target format to generate differential data in the target format. Then, the differential data in the target format is divided to generate at least one broadcast packet. The data length of the differential data in the target format is used as the total data length, and the length of the differential data in the broadcast packet is used as the packet differential data length.

[0074] The broadcast packet includes a broadcast packet serial number, and may also include at least one of the differential data in the target format, the first verification result, reserved data, and padding data. The reserved data is the data reserved in the broadcast packet for the improvement of future broadcast packets. For example, the data length of the reserved data is 3 bytes; the padding data is the data filled in the broadcast packet. Since the maximum broadcast packet data length of the broadcast packet is 31 bytes, the information such as the data length and data type is removed from the broadcast packet.

[0075] The target format includes the ArrayBuffer data format, and then hexadecimal parsing is performed. Figure 3 It is a schematic diagram of obtaining a broadcast packet provided by an embodiment of this specification, as Figure 3 shown. The original version data includes the original version bin data, and the upgraded version data includes the new version bin data; the Bluetooth sending device analyzes the original version bin data and the new version bin data through a differential algorithm to analyze the differential firmware bin data required for the Bluetooth receiving device to upgrade. The differential data includes the differential firmware bin data. The Bluetooth receiving device stores the differential firmware bin data in the storage space of the WeChat mini-program. The WeChat mini-program obtains and parses the differential firmware bin data. The Bluetooth receiving device converts the data format of the differential firmware bin data into the ArrayBuffer data format through the constructor provided by the WeChat mini-program and performs hexadecimal parsing to obtain at least one broadcast packet.

[0076] Step 102 further includes: Step 1023, the Bluetooth sending device generates a broadcast packet based on the target format differential data; Step 1024, sends the broadcast packet to the Bluetooth receiving device through the broadcast channel. Step 1021 to Step 1023 may be executed before Step 101 or after Step 101.

[0077] In a possible implementation, the upgrade packet includes at least one broadcast packet, and the broadcast packet includes a verification broadcast packet; Step 1023 includes: the Bluetooth sending device determines verification data from the target format differential data based on the byte threshold; through a verification algorithm, generates a first verification result based on the verification data; based on the byte threshold, determines a target broadcast packet sequence number matching the byte threshold; generates a verification broadcast packet corresponding to the target broadcast packet sequence number based on the first verification result and the target format differential data.

[0078] In some embodiments, the byte threshold may be a preset threshold, and the verification algorithm includes the CRC16 algorithm. For example, the byte threshold is 128 bytes, indicating that verification is performed every 128 bytes. For example, the 128-byte target format differential data sent most recently is verified.

[0079] The broadcast packet includes a broadcast packet sequence number, and may further include at least one of the target format differential data, the first verification result, reserved data, and padding data. When the maximum length of the broadcast packet data of each broadcast packet is 31 bytes, the maximum length of the packet differential data of the target format differential data in each broadcast packet is 22 bytes, and the byte threshold is 128 bytes, it is set that 128 bytes of the target format differential data must be included within 6 consecutive broadcast packets in order; however, in some cases, the total data length of the target format differential data is less than 128 bytes. At this time, the Bluetooth sending device will automatically supplement padding data in the broadcast packet so that 128 bytes of the target format differential data and padding data must be included within 6 consecutive broadcast packets in order. The Bluetooth sending device will perform verification every 6 broadcast packets. Assuming that 6 consecutive broadcast packets include 128 bytes of the target format differential data, the Bluetooth sending device will verify the 128-byte target format differential data through the verification algorithm to obtain a first verification result; or, assuming that 6 consecutive broadcast packets include 128 bytes of the target format differential data and padding data, the Bluetooth sending device will verify the 128-byte target format differential data and padding data through the verification algorithm to obtain a first verification result. For example, if the Bluetooth sending device verifies 128 bytes of verification data from 6m - 5 to 6m through the verification algorithm to generate a first verification result, the Bluetooth sending device places the first verification result in the 6m-th broadcast packet, where m is an integer greater than or equal to 1, indicating that the first verification result will be placed in the broadcast packet whose sequence number is a multiple of 6. The first verification result can be placed after the target format differential data or the padding data.

[0080] For example, when the total data length of the target format differential data is less than 128 bytes, it indicates that the Bluetooth sending device will only broadcast 6 broadcast packets; place the target format differential data and the padding data 0xFF in the broadcast packets so that the 6 broadcast packets include 128 bytes of the target format differential data and the padding data 0xFF; the Bluetooth sending device performs a checksum on the 128 bytes of the target format differential data and 0xFF to obtain a first checksum result; place the first checksum result after the padding data in the 6th broadcast packet; broadcast the 6th broadcast packet.

[0081] In a possible implementation, the upgrade package includes a checksum broadcast packet. After step 202, it further includes: the Bluetooth receiving device obtains the checksum data and the first checksum result based on the checksum broadcast packet; generates a second checksum result based on the checksum data through a checksum algorithm; determines that the checksum is successful based on the first checksum result and the second checksum result being the same; or determines that the device mode is the running mode based on the first checksum result and the second checksum result being different.

[0082] In some embodiments, as described above, every 6 broadcast packets are checked, and the broadcast packet number of the checksum broadcast packet is an integer multiple of 6. For example, when the 6th broadcast packet is received, the first checksum result is parsed from the 6th broadcast packet, and the checksum data is obtained from the 1st to the 6th broadcast packets. The data length of the checksum data is equal to the byte threshold, the data length of the checksum data is 128 bytes, and the checksum data includes the target format differential data, or the checksum data includes the target format differential data and the padding data. The checksum broadcast packet performs a CRC16 checksum on the 128 bytes of the checksum data to generate a second checksum result; determines whether the second checksum result is the same as the first checksum result. If they are the same, it indicates that the received broadcast packet is correct and there are no situations such as byte loss or byte change; if they are different, it indicates that the received broadcast packet is incorrect, exits the upgrade model, and the Bluetooth receiving device abandons the current upgrade and continues to operate normally.

[0083] In a possible implementation, the upgrade package includes firmware upgrade data; after step 102, it further includes: generating a third checksum result based on the firmware upgrade data through a checksum algorithm; generating a notification checksum packet based on the third checksum result; broadcasting the notification checksum packet.

[0084] In some embodiments, the data length of the firmware upgrade data is an integer multiple of 128 bytes. When the upgrade package only includes the target format differential data and does not include the padding data, a CRC16 checksum is performed on the target format differential data to obtain a third checksum result; when the upgrade package includes the target format differential data and the padding data, a CRC16 checksum is performed on the target format differential data and the padding data to obtain a third checksum result. After the Bluetooth sending device finishes sending the upgrade package, it will also send a notification checksum packet, and the notification checksum packet includes the third checksum result.

[0085] Figure 4 It is a flowchart of a broadcast provided by an embodiment of this specification. As Figure 4 shown, the Bluetooth sending device is powered on, enters the WeChat mini-program interface, selects the required differential firmware bin data, parses and processes the obtained bin data into a hexadecimal file, obtaining multiple broadcast packets, where the number of broadcast packets is an integer multiple of 6; broadcasts the first upgrade request command and sets i = 1; broadcasts the i-th packet of the upgrade firmware information. At this time, the first broadcast packet is broadcast; determines whether a packet loss command response from the Bluetooth receiving device is received. If a packet loss command response from the Bluetooth receiving device is received, re-broadcasts the lost broadcast packet. If a packet loss command response from the Bluetooth receiving device is not received, determines whether there are still broadcast packets not sent. If there are broadcast packets not sent, sets i = i + 1; determines whether the remainder of i divided by 6 is 0; when the remainder is not 0, executes the step of "broadcasting the i-th packet of the upgrade firmware information". At this time, the second broadcast packet is broadcast. Until after the fifth broadcast packet is broadcast, the value of i is 6, i % 6 == 0. When the remainder is 0, a CRC16 check is performed every 6 packets. Through the CRC16 check algorithm, the 128-byte data in the first packet to the sixth broadcast packet is checked to obtain a first check result, and the first check result is placed in the sixth broadcast packet; if there are only 6 broadcast packets, determines that i will not increase further, broadcasts the sixth broadcast packet, and finishes broadcasting all the target format differential data; if a packet loss command response from the Bluetooth receiving device is not received, performs a CRC16 check on the entire upgrade firmware data again. At this time, the first check result is used as the third check result, and a notification check packet is broadcast, where the notification check packet includes the third check result; sends an upgrade end command, and the upgrade ends. If there are 12 broadcast packets, determines that i will increase further, executes the step of "broadcasting the i-th packet of the upgrade firmware information". At this time, the sixth broadcast packet is broadcast. Until the 12th broadcast packet is broadcast, all the target format differential data is finished broadcasting; if a packet loss command response from the Bluetooth receiving device is not received, performs a CRC16 check on the entire firmware upgrade data again. At this time, the data from the first broadcast packet to the 12th broadcast packet is checked by the CRC16 check algorithm, that is, the 254-byte firmware upgrade data is checked by the CRC16 check algorithm to obtain a third check result; broadcasts a notification check packet, where the notification check packet includes the third check result; sends an upgrade end command, and the upgrade ends.

[0086] In a possible implementation, after step 202, it further includes: receiving a notification check packet; parsing the third check result from the notification check packet; parsing the firmware upgrade data based on the upgrade packet; generating a fourth check result based on the firmware upgrade data through a check algorithm; determining that the check is successful based on the third check result being the same as the fourth check result; or determining that the device mode is the running mode based on the third check result being different from the fourth check result.

[0087] In some embodiments, after receiving the notification verification packet, the Bluetooth receiving device will parse out the third verification result from the notification verification packet. Referring to the above content, the Bluetooth receiving device will also perform a CRC16 verification on the firmware upgrade data to obtain a fourth verification result; when the third verification result is the same as the fourth verification result, it indicates that the received upgrade packet is correct and the upgrade is performed; when the third verification result is different from the fourth verification result, it indicates that the received upgrade packet is incorrect, and the upgrade model is exited. The Bluetooth receiving device abandons the current upgrade and continues to operate normally.

[0088] Figure 5 is an upgrade flow chart provided by an embodiment of this specification, as Figure 5As shown, power on the Bluetooth receiving device; configure the Bluetooth receiving device to broadcast and scan simultaneously, and listen for WeChat Mini Program broadcast messages in real time; when the WeChat Mini Program upgrade request command is not received, execute the step of "listening for WeChat Mini Program broadcast messages in real time"; when the WeChat Mini Program upgrade request command is received, enter the Bluetooth water meter FOTA upgrade mode, start receiving the broadcast packets sent by the WeChat Mini Program, and set i = 1; continuously receive the i-th broadcast packet, i++, at this time, receive the first broadcast packet and set i = 2. Determine whether the remainder of (i - 1) divided by 6 is 0; when the remainder of (i - 1) divided by 6 is not 0, then determine whether i is consecutive with the packet sending sequence number; when i is not consecutive with the packet sending sequence number, it indicates that a packet is lost, broadcast the packet sequence number of the current lost packet to the WeChat Mini Program, and execute the step of "receiving the i-th broadcast packet, i++". When the remainder of (i - 1) divided by 6 is 0, it indicates that the 128-byte verification data is included in the 6 broadcast packets received in sequence, and a CRC16 verification is performed every time 128 bytes of verification data are received; perform CRC16 verification based on the 128-byte verification data to obtain the second verification result, and parse the first verification result from the broadcast packet where the 128-byte verification data is located; determine whether the 128-byte verification passes based on the first verification result and the second verification result. When the first verification result is the same as the second verification result, it is determined that the 128-byte verification passes, otherwise, it does not pass. When the 128-byte verification passes, continue to receive broadcast packets; when the 128-byte verification fails, execute the step of "listening for WeChat Mini Program broadcast messages in real time" to wait for the next upgrade. When i is consecutive with the packet sending sequence number, determine whether the upgrade end response sent by the WeChat Mini Program is received. The upgrade end response refers to the upgrade end command; when the upgrade end response is not received, execute the step of "receiving the i-th broadcast packet, i++"; when the upgrade end response is received, it indicates that the data reception is completed, perform CRC16 verification on the entire firmware upgrade data again to obtain the fourth verification result; receive the notification verification packet, and parse the third verification result from the notification verification packet. The third verification result is the result obtained by the Bluetooth sending device performing CRC16 verification on the firmware upgrade data; determine whether the CRC16 verification passes based on the third verification result and the fourth verification result; when the CRC16 verification passes, fuse the differential file and the original firmware, overwrite the new firmware data to the Flash address where the old firmware data is stored, and restart for the update; when the CRC16 verification fails, execute the step of "listening for WeChat Mini Program broadcast messages in real time".

[0089] In a possible implementation, the upgrade package includes multiple broadcast packets, and each broadcast packet includes a broadcast packet sequence number. After step 102, the following steps are further included: The Bluetooth receiving device determines lost packets based on the multiple broadcast packet sequence numbers and broadcasts lost packet broadcast information. The Bluetooth transmitting device receives the lost packet broadcast information sent by the Bluetooth receiving device, determines the target lost packet broadcast packet based on the lost packet broadcast information, and sends the target lost packet broadcast packet to the Bluetooth receiving device through the broadcast channel. The Bluetooth receiving device receives the target lost packet broadcast packet corresponding to the lost packet broadcast information.

[0090] In some embodiments, the Bluetooth transmitting device exchanges data with the Bluetooth receiving device in the form of broadcasting and scanning, and the Bluetooth transmitting device has the function of scanning. The broadcast packet includes a broadcast packet sequence number. The Bluetooth receiving device monitors in real time the broadcast packet sequence numbers received by itself and the broadcast packet sequence numbers sent by the Bluetooth transmitting device. If a packet is lost, it immediately broadcasts lost packet broadcast information to inform the Bluetooth transmitting device to re-send the target lost packet broadcast packet. The lost packet broadcast information includes the target broadcast packet sequence number of the lost packet. When the Bluetooth transmitting device receives the lost packet broadcast information, it immediately determines the lost broadcast packet based on the target broadcast packet sequence number of the lost packet and uses the lost broadcast packet as the target lost packet broadcast packet, and re-broadcasts the target lost packet broadcast packet corresponding to the target broadcast packet sequence number. For example, if the multiple broadcast packet sequence numbers received by the Bluetooth receiving device are 1, 2, and 4 respectively, then when receiving the broadcast packet with the sequence number of 4, it determines that a packet is lost, and the target broadcast packet sequence number of the lost broadcast packet is 3. At the same time, it can also be set in the Bluetooth receiving device that the number of all received broadcast packets is an integer multiple of 6 to prevent the Bluetooth receiving device from losing the last broadcast packet.

[0091] As Figure 4 shown, the lost packet command response of the Bluetooth receiving device refers to the lost packet broadcast information.

[0092] In a possible implementation, after step 102, the following steps are further included: The Bluetooth transmitting device broadcasts an upgrade end command. The Bluetooth receiving device receives the upgrade end command and performs an upgrade based on the upgrade package according to the upgrade end command.

[0093] In some embodiments, the upgrade end command indicates the end of the upgrade. The Bluetooth receiving device parses the target format differential data from the upgrade package, generates upgrade data based on the target format differential data and the local version data through a differential reduction algorithm, runs the upgrade data, and updates the software version number based on the upgrade request command.

[0094] For example, the Bluetooth receiving device stores the upgrade data at the storage address where the local version data is located and runs the upgrade data. At the same time, the upgrade request command includes the software upgrade version number, and the local version data corresponds to the local version number. The local version number is updated to the software upgrade version number, thus realizing the Bluetooth FOTA firmware data upgrade without establishing a connection.

[0095] As Figure 4 shown, the new firmware data refers to the upgrade data.

[0096] In this application, the byte threshold, the number of broadcast packets, the length of broadcast packet data, the length of packet differential data, the total data length, and the padding data are not limited.

[0097] An upgrade method for a water meter provided by an embodiment of this specification includes: a Bluetooth sending device broadcasts an upgrade request command to notify a Bluetooth receiving device to prepare for upgrade; the Bluetooth receiving device determines the device mode as the upgrade mode based on the upgrade request command; the Bluetooth sending device generates target format differential data based on the original version data and the upgrade version data; generates an upgrade packet based on the target format differential data; sends the upgrade packet to the Bluetooth receiving device through a broadcast channel; the Bluetooth receiving device receives the upgrade packet through the broadcast channel, so that one Bluetooth sending device can control one or more Bluetooth receiving devices to achieve FOTA upgrade. Especially in remote areas without base stations or with poor signals, it is possible to achieve FOTA upgrade for multiple Bluetooth receiving devices without specially enhancing the signal or establishing a base station, which reduces the time resources consumed by the Bluetooth receiving device for upgrade, and there is no need for the Bluetooth sending device and the Bluetooth receiving device to establish a connection, saving cumbersome steps such as pairing and connection; and the operation is simple, which can save the time wasted due to unstable connection. Especially when controlling multiple Bluetooth receiving devices for upgrade, the upgrade efficiency is improved and the power consumption required for upgrade is reduced.

[0098] Corresponding to the above-mentioned embodiment of the upgrade method for a water meter, this specification also provides an embodiment of an upgrade system for a water meter. Figure 6 It is a schematic structural diagram of an upgrade system for a water meter provided by an embodiment of this specification. As Figure 6 shown, the device includes: a Bluetooth sending device 601 and a Bluetooth receiving device 602; the Bluetooth sending device 601 is connected to the Bluetooth receiving device 602.

[0099] The Bluetooth sending device 601 is used to broadcast an upgrade request command to notify the Bluetooth receiving device 602 to prepare for upgrade; the Bluetooth receiving device 602 is used to determine the device mode as the upgrade mode based on the upgrade request command; the Bluetooth sending device 601 is also used to generate target format differential data based on the original version data and the upgrade version data; generate an upgrade packet based on the target format differential data; send the upgrade packet to the Bluetooth receiving device 602 through a broadcast channel; the Bluetooth receiving device 602 is also used to receive the upgrade packet through the broadcast channel.

[0100] In a possible implementation, the upgrade packet includes a broadcast packet; the Bluetooth sending device 601 is specifically used to generate differential data based on the original version data and the upgrade version data through a differential algorithm; and generate target format differential data based on the differential data through a constructor.

[0101] In a possible implementation, the upgrade package includes a verification broadcast packet; the Bluetooth sending device 601 is specifically configured to determine verification data from the target format differential data based on a byte threshold; generate a first verification result based on the verification data through a verification algorithm; determine a target broadcast packet sequence number matching the byte threshold based on the byte threshold; and generate a verification broadcast packet corresponding to the target broadcast packet sequence number based on the first verification result and the target format differential data.

[0102] In a possible implementation, the upgrade package includes a verification broadcast packet, and the Bluetooth receiving device 602 is further configured to obtain verification data and a first verification result based on the verification broadcast packet; generate a second verification result based on the verification data through a verification algorithm; determine that the verification is successful based on the first verification result being the same as the second verification result; or determine that the device mode is the running mode based on the first verification result being different from the second verification result.

[0103] In a possible implementation, the upgrade package includes multiple broadcast packets, and the broadcast packets include broadcast packet sequence numbers; the Bluetooth receiving device 602 is further configured to determine lost packets based on the multiple broadcast packet sequence numbers and broadcast lost packet broadcast information; the Bluetooth sending device 601 is further configured to receive the lost packet broadcast information sent by the Bluetooth receiving device 602; determine a target lost packet broadcast packet based on the lost packet broadcast information; send the target lost packet broadcast packet to the Bluetooth receiving device 602 through a broadcast channel; and the Bluetooth receiving device 602 is further configured to receive the target lost packet broadcast packet corresponding to the lost packet broadcast information.

[0104] In a possible implementation, the upgrade package includes firmware upgrade data; the Bluetooth sending device 601 is further configured to generate a third verification result based on the firmware upgrade data through a verification algorithm; generate a notification verification packet based on the third verification result; and broadcast the notification verification packet.

[0105] In a possible implementation, the upgrade package includes firmware upgrade data; the Bluetooth receiving device 602 is further configured to receive the notification verification packet and parse out the third verification result from the notification verification packet; parse out the firmware upgrade data based on the upgrade package; generate a fourth verification result based on the firmware upgrade data through a verification algorithm; determine that the verification is successful based on the third verification result being the same as the fourth verification result; or determine that the device mode is the running mode based on the third verification result being different from the fourth verification result.

[0106] In a possible implementation, the target format differential data includes ArrayBuffer data format and differential data parsed in hexadecimal.

[0107] In a possible implementation, the Bluetooth sending device 601 is further configured to broadcast an upgrade end command; the Bluetooth receiving device 602 is further configured to receive the upgrade end command; and based on the upgrade end command, perform an upgrade according to the upgrade package.

[0108] The upgrade system of the water meter provided by an embodiment of this specification includes a Bluetooth sending device and a Bluetooth receiving device; the Bluetooth sending device is configured to broadcast an upgrade request command to notify the Bluetooth receiving device to prepare for an upgrade; the Bluetooth receiving device is configured to determine that the device mode is an upgrade mode based on the upgrade request command; the Bluetooth sending device is further configured to generate target format differential data based on the original version data and the upgrade version data; generate an upgrade package from the target format differential data; send the upgrade package to the Bluetooth receiving device through a broadcast channel; the Bluetooth receiving device is further configured to receive the upgrade package through the broadcast channel, so that one Bluetooth sending device can control one or more Bluetooth receiving devices to implement FOTA upgrade. Especially in remote areas without base stations or with poor signals, it is possible to implement FOTA upgrade for multiple Bluetooth receiving devices without specifically enhancing the signal or establishing a base station, reducing the time resources consumed for the upgrade of the Bluetooth receiving device.

[0109] It should be noted that for the foregoing method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the embodiments of this specification are not limited by the described action sequences, because according to the embodiments of this specification, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments of this specification.

[0110] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0111] The preferred embodiments of this specification disclosed above are only used to help explain this specification. The alternative embodiments do not elaborate on all the details and do not limit the invention to the specific embodiments described. Obviously, many modifications and variations can be made according to the content of the embodiments of this specification. The embodiments selected and specifically described in this specification are for better explaining the principles and practical applications of the embodiments of this specification, so that those skilled in the art can well understand and utilize this specification. This specification is only limited by the claims and their full scope and equivalents.

Claims

1. A method for upgrading a water meter, characterized in that, The method includes: The Bluetooth sending device broadcasts an upgrade request command to notify the Bluetooth receiving device to prepare for upgrade; Based on the upgrade request command, the Bluetooth receiving device determines that the device mode is the upgrade mode; The Bluetooth sending device generates target format differential data based on the original version data and the upgrade version data; generates an upgrade package based on the target format differential data; and sends the upgrade package to the Bluetooth receiving device through a broadcast channel; The Bluetooth receiving device receives the upgrade package through the broadcast channel.

2. The method according to claim 1, characterized in that, The upgrade package includes a broadcast packet; the generating of the target format differential data based on the original version data and the upgrade version data includes: The Bluetooth sending device generates differential data based on the original version data and the upgrade version data through a differential algorithm; Through a constructor, the target format differential data is generated based on the differential data.

3. The method according to claim 1, characterized in that The upgrade package includes a verification broadcast packet; the generating of the upgrade package by the Bluetooth sending device based on the target format differential data includes: The Bluetooth sending device determines verification data from the target format differential data based on a byte threshold; Generates a first verification result based on the verification data through a verification algorithm; Based on the byte threshold, determines a target broadcast packet sequence number that matches the byte threshold; Generates a verification broadcast packet corresponding to the target broadcast packet sequence number based on the first verification result and the target format differential data.

4. The method according to claim 1, wherein The upgrade package includes a verification broadcast packet. After the Bluetooth receiving device receives the upgrade package through the broadcast channel, it further includes: The Bluetooth receiving device obtains verification data and a first verification result based on the verification broadcast packet; Generates a second verification result based on the verification data through a verification algorithm; Based on the first verification result and the second verification result being the same, determines that the verification is successful; or, based on the first verification result and the second verification result being different, determines that the device mode is the running mode.

5. The method according to claim 1, characterized in that, The upgrade package includes multiple broadcast packets, and the broadcast packet includes a broadcast packet sequence number; After the Bluetooth receiving device receives the upgrade package through the broadcast channel, it further includes: The Bluetooth receiving device determines packet loss based on multiple broadcast packet sequence numbers and broadcasts packet loss broadcast information; The Bluetooth sending device receives the packet loss broadcast information sent by the Bluetooth receiving device; determines a target packet loss broadcast packet based on the packet loss broadcast information; and sends the target packet loss broadcast packet to the Bluetooth receiving device through the broadcast channel; The Bluetooth receiving device receives the target packet loss broadcast packet corresponding to the packet loss broadcast information.

6. The method according to claim 1, characterized in that, The upgrade package includes firmware upgrade data; After the Bluetooth sending device sends the upgrade package to the Bluetooth receiving device through the broadcast channel, it further includes: The Bluetooth sending device generates a third verification result based on the firmware upgrade data through a verification algorithm; Generates a notification verification packet based on the third verification result; Broadcasts the notification verification packet.

7. The method according to claim 1, characterized in that, The upgrade package includes firmware upgrade data; After the Bluetooth receiving device receives the upgrade package through the broadcast channel, it further includes: The Bluetooth receiving device receives the notification verification packet and parses out the third verification result from the notification verification packet; Parse the firmware upgrade data from the upgrade package; Generate a fourth verification result based on the firmware upgrade data through a verification algorithm; Based on the third verification result being the same as the fourth verification result, determine that the verification is successful; or, based on the third verification result being different from the fourth verification result, determine that the device mode is the operating mode.

8. The method according to any one of claims 1-7, characterized in that, The target format differential data includes differential data in the ArrayBuffer data format and parsed in hexadecimal.

9. The method according to claim 1, characterized in that After the Bluetooth sending device sends the upgrade package to the Bluetooth receiving device through the broadcast channel, it further includes: The Bluetooth sending device broadcasts an upgrade end command; The Bluetooth receiving device receives the upgrade end command; and upgrades according to the upgrade package based on the upgrade end command.

10. An upgrade system for a water meter, characterized in that, The system includes a Bluetooth sending device and the Bluetooth receiving device; The Bluetooth sending device is used to broadcast an upgrade request command to notify the Bluetooth receiving device to prepare for the upgrade; The Bluetooth receiving device is used to determine that the device mode is the upgrade mode based on the upgrade request command; The Bluetooth sending device is further used to generate target format differential data based on the original version data and the upgrade version data; Generate an upgrade package based on the target format differential data; and send the upgrade package to the Bluetooth receiving device through the broadcast channel; The Bluetooth receiving device is further used to receive the upgrade package through the broadcast channel.

Citation Information

Cited By

  • Network system with group software upgrading function and method thereof

    CN120881569A