Data update method, device, storage medium, and electronic device

By recording the data information and its time stamps transmitted by Bluetooth devices and comparing them with historical data information, the problem of limited broadcast data size of Bluetooth devices is solved, accurate judgment of new and old data is achieved, and data timeliness and user experience is improved.

CN115734204BActive Publication Date: 2025-06-27QINGDAO HAIER TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110991379.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-26
Publication Date
2025-06-27
Estimated Expiration
2041-08-26

AI Technical Summary

Technical Problem

The broadcast data size of Bluetooth devices is limited, and it is impossible to determine the old and new data without affecting the service data.

Method used

By acquiring the first data information and its time stamp transmitted by the Bluetooth device, recording and comparing it with the timestamp of the historical data information stored on the terminal, whether to update the data information is determined based on the timestamp difference value and the preset threshold relationship.

Benefits of technology

It realizes accurate judgment of new and old data without affecting business data, improves the timeliness of data information received by the terminal, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115734204B_ABST
    Figure CN115734204B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for updating data, a storage medium, and an electronic device. Among them, the method includes: obtaining first data information transmitted by a Bluetooth device and recording a first timestamp for obtaining the first data information, where the first data information includes: a first serial number, and the first serial number is used to indicate the upload times of the first data information corresponding to the Bluetooth device; determining the difference between the first timestamp and a second timestamp corresponding to second data information stored on the terminal, where the second data information is stored on the terminal and is the data information received from the Bluetooth device most recently before receiving the first data information; determining whether to update the second data information according to the first data information according to the magnitude relationship between the difference and a preset threshold, which solves the problems in the related art that the broadcast data size of the Bluetooth device is limited and it is impossible to determine new and old data without affecting service data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular, to a method and device for updating data, a storage medium, and an electronic device. Background Art

[0002] Nowadays, in the era of Internet of Everything, many small household appliances at home, such as thermometers, weighing scales, and body fat scales, can also be connected to the mobile phone APP as smart home appliances. Thus, the latest data of the devices can be received on the mobile phone APP, and historical data can be displayed, etc. However, these devices are often battery-powered, and for reasons such as low power consumption and cost, a Bluetooth chip is added to broadcast the data in the form of Bluetooth. Moreover, in the case of having a gateway proxy device at home, the data broadcast in the form of Bluetooth can be reported to the mobile phone through two channels: Method 1: The mobile phone directly searches for the Bluetooth broadcast in the form of Bluetooth broadcast. Method 2: The gateway device receives the Bluetooth broadcast data, reports it to the cloud, and the cloud pushes it to the mobile phone. That is, the same packet of data can be reported to the mobile phone through two channels. When the device broadcasts two pieces of data within a short period of time, Data 1 (old data) and Data 2 (new data), and the mobile phone receives Data 2 through the broadcast, and at this time the cloud pushes Data 1 again, it will occur that without distinguishing between new and old data, Data 1 will overwrite Data 2.

[0003] In addition, when the gateway proxy device does not exist, communication with the cloud cannot be established, and the timestamp cannot be obtained. Moreover, since the size of the Bluetooth broadcast data is very limited, the SN code used to distinguish new and old data is usually identified by an 8-byte long integer field, which causes the business data to be insufficient after adding the SN code to the Bluetooth broadcast data, affecting the transmission of business data.

[0004] In view of the problems in the related art that the size of the broadcast data of Bluetooth devices is limited and it is impossible to determine new and old data without affecting business data, no effective solution has been proposed yet. Summary of the Invention

[0005] Embodiments of the present invention provide a method and device for updating data, a storage medium, and an electronic device, so as to at least solve the problems in the related art that the size of the broadcast data of Bluetooth devices is limited and it is impossible to determine new and old data without affecting business data.

[0006] According to an embodiment of the present invention, a method for updating data is provided, including: obtaining first data information transmitted by a Bluetooth device and recording a first timestamp when the first data information is obtained, where the first data information includes: a first serial number, and the first serial number is used to indicate the number of uploads of the first data information corresponding to the Bluetooth device; determining a difference between the first timestamp and a second timestamp corresponding to second data information stored on the terminal, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information; determining whether to update the second data information according to the first data information based on the magnitude relationship between the difference and a preset threshold.

[0007] In an exemplary embodiment, determining whether to update the second data information according to the first data information based on the magnitude relationship between the difference and a preset threshold includes: in the case where the difference is less than the preset threshold, comparing the first serial number in the first data information and the second serial number in the second data information according to a preset algorithm to determine whether to update the second data information according to the first data information; in the case where the difference is greater than the preset threshold, determining to update the second data information according to the first data information.

[0008] In an exemplary embodiment, before comparing the first serial number in the first data information and the second serial number in the second data information according to a preset algorithm in the case where the difference is less than the preset threshold, the above method further includes: obtaining a first device identifier carried by the first data information and a second device identifier carried by the second data information; in the case where the first device identifier and the second device identifier are the same, determining a broadcast frequency threshold of the Bluetooth device corresponding to the first device identifier and a maximum value of the increment of the first serial number; updating a rollback parameter in the preset algorithm according to the broadcast frequency threshold and the maximum value, where the rollback parameter is used to indicate a maximum value for rollback updating of the first serial number.

[0009] In an exemplary embodiment, comparing the first serial number in the first data information and the second serial number in the second data information according to a preset algorithm to determine whether to update the second data information according to the first data information includes: in the case where a first difference between the first serial number and the second serial number is greater than a first threshold, determining to update the second data information according to the first data information; in the case where the first difference between the first serial number and the second serial number is less than the first threshold and a difference between the maximum value and the first difference is less than the broadcast frequency threshold, determining to update the second data information according to the first data information; in the case where the first difference between the first serial number and the second serial number is less than the first threshold and a difference between the maximum value and the first difference is greater than the broadcast frequency threshold, deleting the first data information.

[0010] In an exemplary embodiment, after obtaining the first device identifier carried in the first data information and the second device identifier carried in the second data information, the method further includes: in a case where the first device identifier is different from the second device identifier, re-obtaining the second data information stored in the terminal by the Bluetooth device; in a case where the second data information does not exist in the terminal, sending a prompt message, where the prompt message is used to prompt whether to establish a stored file.

[0011] In an exemplary embodiment, before determining whether to update the second data information according to the first data information according to the magnitude relationship between the difference value and a preset threshold, the method further includes: determining a delay time for pushing the first data information between the terminal and the Bluetooth device, where the delay time is used to indicate, in a case where the network fluctuation is large, the difference between the pushing time from the terminal to the Internet of Things cloud for receiving the first data information and a preset standard pushing time; determining the preset threshold according to the delay time.

[0012] According to another embodiment of the present invention, there is also provided a data update device, including: an acquisition module, configured to acquire first data information transmitted by a Bluetooth device and record a first time stamp for acquiring the first data information, where the first data information includes: a first serial number, and the first serial number is used to indicate the upload times of the first data information corresponding to the Bluetooth device; a difference module, configured to determine a difference between the first time stamp and a second time stamp corresponding to second data information stored on the terminal, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information; a determination module, configured to determine whether to update the second data information according to the first data information according to the magnitude relationship between the difference value and a preset threshold.

[0013] In an exemplary embodiment, the determination module is further configured to, in a case where the difference value is less than the preset threshold, compare the first serial number in the first data information with the second serial number in the second data information according to a preset algorithm to determine whether to update the second data information according to the first data information; in a case where the difference value is greater than the preset threshold, determine to update the second data information according to the first data information.

[0014] In an exemplary embodiment, the determination module further includes: an acquisition unit, configured to acquire a first device identifier carried in the first data information and a second device identifier carried in the second data information; a determination unit, configured to, in a case where the first device identifier is the same as the second device identifier, determine a broadcast frequency threshold of the Bluetooth device corresponding to the first device identifier and a maximum value of the increment of the first serial number; updating a rollback parameter in the preset algorithm according to the broadcast frequency threshold and the maximum value, where the rollback parameter is used to indicate a maximum value for rollback updating of the first serial number.

[0015] In an exemplary embodiment, the above-mentioned determination module is further configured to determine to update the second data information according to the first data information when the first difference between the first serial number and the second serial number is greater than the first threshold; to determine to update the second data information according to the first data information when the first difference between the first serial number and the second serial number is less than the first threshold and the difference between the maximum value and the first difference is less than the broadcast frequency threshold; and to delete the first data information when the first difference between the first serial number and the second serial number is less than the first threshold and the difference between the maximum value and the first difference is greater than the broadcast frequency threshold.

[0016] In an exemplary embodiment, the above-mentioned determination module further includes: a prompt unit, configured to re-obtain the second data information stored in the terminal by the Bluetooth device when the first device identifier is different from the second device identifier; and to send a prompt message when the second data information does not exist in the terminal, where the prompt message is used to prompt whether to establish a storage file.

[0017] In an exemplary embodiment, the above-mentioned device further includes: a time module, configured to determine the delay time for pushing the first data information between the terminal and the Bluetooth device, where the delay time is used to indicate the difference between the push time from the terminal to the Internet of Things cloud receiving the first data information and the preset standard push time under the condition of large network fluctuations; and to determine a preset threshold according to the delay time.

[0018] According to another embodiment of the present invention, there is also provided a computer-readable storage medium, in which a computer program is stored, where the computer program is set to execute the steps in any one of the above method embodiments when running.

[0019] According to another embodiment of the present invention, there is also provided an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is set to run the computer program to execute the steps in any one of the above method embodiments.

[0020] Through the present invention, first data information transmitted by a Bluetooth device is obtained, and a first timestamp when the first data information is obtained is recorded. The first data information includes: a first serial number, which is used to indicate the number of uploads of the first data information corresponding to the Bluetooth device; a difference between the first timestamp and a second timestamp corresponding to second data information stored on the terminal is determined, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information; whether to update the second data information according to the first data information is determined according to the magnitude relationship between the difference and a preset threshold, that is, when the terminal obtains the data information sent by the Bluetooth device, the terminal records the corresponding acquisition timestamp and compares it with the historical data information stored in the terminal to preliminarily determine whether the first data information is new data, solving the problems in the related art that the size of the broadcast data of the Bluetooth device is limited and it is impossible to determine new and old data without affecting service data. By recording timestamps at the terminal and determining the serial number of a single byte in the data information, new and old judgments are made on the data information reported on multiple channels, realizing deduplication of the data information in the Bluetooth broadcast data with the least resources, improving the timeliness of the data information received by the terminal, and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The illustrative embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0022] Figure 1 is a hardware structure block diagram of a mobile terminal for a data update method according to an embodiment of the present invention;

[0023] Figure 2 is a flowchart of a data update method according to an embodiment of the present invention;

[0024] Figure 3 is an interactive process schematic diagram of data uploaded by a Bluetooth device according to an optional embodiment of the present invention;

[0025] Figure 4 is a structural block diagram (I) of a data update device according to an embodiment of the present invention;

[0026] Figure 5 is a structural block diagram (II) of a data update device according to an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0027] The present invention will be described in detail below with reference to the drawings and in conjunction with the embodiments. It should be noted that, without conflict, the embodiments in this application and the features in the embodiments can be combined with each other.

[0028] It should be noted that the terms "first", "second", etc. in the description, claims and the above-mentioned drawings of the present invention are used to distinguish similar objects, and do not necessarily need to describe a specific order or sequence.

[0029] The method embodiments provided by the embodiments of the present application can be executed in a computer terminal, a mobile terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 is a hardware structure block diagram of a mobile terminal for a data update method according to an embodiment of the present invention. As Figure 1 shown, the mobile terminal may include one or more ( Figure 1 only one is shown in Figure 1 figures) processors 102 (the processor 102 may include, but is not limited to, processing devices such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. In an exemplary embodiment, the above-mentioned mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may further include more or fewer components than Figure 1 shown in Figure 1 figures, or have different configurations with the same functions as

[0030] shown in

[0031] Figure 1 shown or more functions than

[0030] the functions shown in

[0031] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to the data update method in the embodiments of the present invention. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, that is, implements the above-mentioned method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories may be connected to the mobile terminal through a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0031] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of a mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, abbreviated as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0032] In this embodiment, a method for updating data is provided, which is applied to the above-mentioned mobile terminal. Figure 2 It is a flowchart of the method for updating data according to an embodiment of the present invention. The process includes the following steps:

[0033] Step S202, obtain the first data information transmitted by the Bluetooth device, and record the first timestamp when the first data information is obtained. Among them, the first data information includes: a first serial number, and the first serial number is used to indicate the upload times of the first data information corresponding to the Bluetooth device.

[0034] Step S204, determine the difference between the first timestamp and the second timestamp corresponding to the second data information stored on the terminal. Among them, the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information.

[0035] Step S206, determine whether to update the second data information according to the first data information according to the magnitude relationship between the difference and a preset threshold.

[0036] Through the above technical solution, the first data information transmitted by the Bluetooth device is obtained, and the first timestamp when the first data information is obtained is recorded. The first data information includes: a first serial number, which is used to indicate the upload times of the first data information corresponding to the Bluetooth device; the difference between the first timestamp and the second timestamp corresponding to the second data information stored on the terminal is determined, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information; whether to update the second data information according to the first data information is determined according to the magnitude relationship between the difference and a preset threshold. That is, when the terminal obtains the data information sent by the Bluetooth device, the terminal records the corresponding acquisition timestamp and compares it with the historical data information stored in the terminal to preliminarily determine whether the first data information is new data, solving the problems in the related art that the broadcast data size of the Bluetooth device is limited and it is impossible to determine new and old data without affecting the service data. By recording timestamps at the terminal and determining the serial number of a single byte in the data information, new and old judgments are made on the data information reported on multiple channels, realizing deduplication of the data information in the Bluetooth broadcast data with the least resources, improving the timeliness of the data information received by the terminal, and enhancing the user experience.

[0037] In an exemplary embodiment, determining whether to update the second data information according to the first data information according to the magnitude relationship between the difference and a preset threshold includes: in the case where the difference is less than the preset threshold, comparing the first serial number in the first data information with the second serial number in the second data information according to a preset algorithm to determine whether to update the second data information according to the first data information; in the case where the difference is greater than the preset threshold, it is determined to update the second data information according to the first data information.

[0038] For example, each time the mobile phone receives the data uploaded by the Bluetooth device, it records the current upload timestamp, and compares the current timestamp with the timestamp of the previous upload data of the Bluetooth device in the cached data in the mobile phone, and determines the magnitude relationship between the difference between the front and back timestamps and the set preset threshold. In the case where the difference is greater than the preset threshold, it is determined that the currently uploaded data is new data, otherwise, a re-judgment is made by comparing the corresponding serial numbers.

[0039] In an exemplary embodiment, before comparing the first serial number in the first data information with the second serial number in the second data information according to a preset algorithm when the difference is less than a preset threshold, the method further includes: obtaining a first device identifier carried in the first data information and a second device identifier carried in the second data information; when the first device identifier is the same as the second device identifier, determining a broadcast frequency threshold of the Bluetooth device corresponding to the first device identifier and a maximum value of the increment of the first serial number; updating a rollback parameter in the preset algorithm according to the broadcast frequency threshold and the maximum value, where the rollback parameter is used to indicate a maximum value for rollback updating of the first serial number.

[0040] In other words, according to the broadcast frequency threshold and the maximum value of the increment of the first serial number, a rollback parameter for data duplication of the first serial number can be determined. According to the rollback parameter, the number of times the first serial number is updated in a byte of a specified size and the maximum value of the update frequency can be determined, thereby ensuring that the serial numbers corresponding to the data information are different at different time points. When the predetermined time period is exceeded, data information carrying different content information with the same first serial number will appear, and then the first data information and the second data information are compared according to the preset algorithm to determine whether the current first data information is new data information.

[0041] For example, when it is determined that the device is a weighing scale through the device identifier, the broadcast frequency of the weighing scale can be determined to be once every 250 milliseconds according to the corresponding standard table. Then, within a preset threshold of 30 seconds, it will broadcast 120 times, and the SN will change 120 times. The broadcast frequency threshold can be set to 120. In addition, when the size of the SN field used by the weighing scale to indicate the serial number is 1 byte, the value range of SN can only be 0 - 255. When it broadcasts 256 times, SN is exhausted, and when broadcasting again, it needs to roll back to 0 and start over. At this time, the maximum value of the increment of SN is 255.

[0042] In an exemplary embodiment, comparing the first serial number in the first data information with the second serial number in the second data information according to a preset algorithm to determine whether to update the second data information according to the first data information includes: when a first difference between the first serial number and the second serial number is greater than a first threshold, determining to update the second data information according to the first data information; when the first difference between the first serial number and the second serial number is less than the first threshold, and the difference between the maximum value and the first difference is less than the broadcast frequency threshold, determining to update the second data information according to the first data information; when the first difference between the first serial number and the second serial number is less than the first threshold, and the difference between the maximum value and the first difference is greater than the broadcast frequency threshold, deleting the first data information.

[0043] For example, let: the first serial number be x, the second serial number be y, the maximum value of the increment of the first serial number be z, and the broadcast frequency threshold for indicating the Bluetooth device be n.

[0044] 1) x - y > 0; the received first data message is new data.

[0045] 2) x - y < 0 and z - |x - y| < n; the received first data message is new data.

[0046] In an exemplary embodiment, after obtaining the first device identifier carried in the first data message and the second device identifier carried in the second data message, the above method further includes: in the case where the first device identifier and the second device identifier are different, re-obtaining the second data message stored in the terminal by the Bluetooth device; in the case where the second data message does not exist in the terminal, sending a prompt message, where the prompt message is used to prompt whether to establish a storage file.

[0047] In an exemplary embodiment, before determining whether to update the second data message according to the difference value and the preset threshold, the above method further includes: determining the delay time for pushing the first data message between the terminal and the Bluetooth device, where the delay time is used to indicate the difference between the push time from the terminal to the Internet of Things cloud receiving and the preset standard push time of the first data message in the case of large network fluctuations; determining the preset threshold according to the delay time.

[0048] To better understand the process of the above data update method, the following describes the data update method flow in combination with optional embodiments, but does not limit the technical solutions of the embodiments of the present invention.

[0049] As an optional implementation manner, in the reported data, a timestamp is usually added or an 8-byte long type (long integer) SN (Serial Number, SN code, simply referred to as SN) field is used to determine new and old data through the timestamp or SN. However, the resources in the Bluetooth broadcast data are very limited, and the service data will occupy a large amount of data. It is impossible to allocate too much space for the SN field.

[0050] For the above application scenario, an optional embodiment of the present invention proposes a method for judging new and old data, which realizes the judgment of new and old data by setting two conditional rules on the mobile phone side, including:

[0051] The first rule: Time filtering is used to indicate that each time the mobile device receives data uploaded by a Bluetooth device, record the current upload timestamp, and compare the current timestamp with the timestamp of the previous upload data of the Bluetooth device in the cached data on the mobile device, and determine the size relationship between the difference of the front and back timestamps and the set preset threshold. When the difference is greater than the preset threshold, it is determined that the currently uploaded data is new data, otherwise, it is judged again through the second rule.

[0052] For example, set the preset threshold to 30 seconds. Data within 30 seconds is judged using the second rule. Data outside 30 seconds is directly treated as new data.

[0053] It should be noted that the number 30 seconds is determined by simulating a large network fluctuation and a timeout for normal data push delay from the cloud, and it can also be adjusted according to the test situation.

[0054] The second rule: Compare the SN field of 1 byte before and after. In the broadcast data of the Bluetooth device, add a SN field of 1 byte, and SN + 1 each time broadcast data. Since the size of the SN field is only 1 byte. That is to say, the value range of SN can only be 0 - 255. When broadcasting 256 times, SN is exhausted, and when broadcasting again, it needs to roll back to 0 and start over. When the mobile device judges the new and old data through SN, it needs to use a preset algorithm. Even if SN rolls back to 0, the new and old data can be judged according to a threshold.

[0055] Optionally, the preset algorithm includes: when the difference between the currently received data SN and the SN in the mobile device cache is greater than zero, it is determined that the data is new data; when the difference between the currently received data SN and the SN in the mobile device cache is less than zero, and the difference between the maximum value of the SN value and the difference is less than the threshold indicating the broadcast frequency of the Bluetooth device, it is determined that the data is new data; when the above conditions are not met, it is determined that the data is old data.

[0056] For example, let: the SN of the data received by the mobile device be x, the SN of the data cached in the mobile device be y, the maximum value of SN be z, and the threshold indicating the broadcast frequency of the Bluetooth device be n.

[0057] 1) x - y > 0; the received data is new data.

[0058] 2) x - y < 0 and z - |x - y| < n; the received data is new data.

[0059] It should be noted that the thresholds for different Bluetooth devices are also different. The threshold is mainly calculated according to the broadcast frequency of the Bluetooth device, and since the broadcast data of the Bluetooth device contains service data, the device information of the Bluetooth device can be quickly determined.

[0060] For example, for a thermometer hygrometer, the normal broadcast frequency is once per second. Then, within 30 seconds, it will broadcast 30 times, which means the SN will change 30 times. Therefore, the threshold can be set to 30.

[0061] For a weighing scale, the broadcast frequency is once every 250 milliseconds. Then, within 30 seconds, it will broadcast 120 times, and the SN will change 120 times. The broadcast frequency threshold can be set to 120.

[0062] Optionally, an alternative embodiment of the present invention provides a condition for judging the newness and oldness of the data uploaded by the thermometer hygrometer. Specifically, when the SN increases and the SN of the data uploaded by the thermometer hygrometer received is greater than the SN of the thermometer hygrometer data in the mobile phone terminal cache data, it is considered new data. When the SN rolls back, the maximum value of SN is z = 256, the threshold is n = 30, the mobile phone terminal cache data is y = 255, and the newly received data is x = 3. It meets the judgment condition of x - y < 0 and z - |x - y| < n. Therefore, it is determined that the data uploaded by the thermometer hygrometer at this time is new data.

[0063] As an alternative implementation, as Figure 3 shown in the schematic diagram of the interaction process of the data uploaded by the Bluetooth device, specifically as follows:

[0064] Step 1: If the Bluetooth device has data, perform Bluetooth data broadcasting;

[0065] Step 2: The gateway receives the data and sends the corresponding received data information to the cloud.

[0066] Step 3: After receiving the data information, the cloud pushes it to the mobile phone APP;

[0067] Step 4: The mobile phone can receive the data broadcast by the Bluetooth device and the data pushed from the cloud. Since the data pushed from the cloud may be delayed due to reasons such as the network, the mobile phone APP needs to judge whether the currently received data is the latest according to the above first rule and second rule.

[0068] Step 5: The Bluetooth device performs Bluetooth data broadcasting and the mobile phone APP directly searches for it.

[0069] In an alternative embodiment of the present invention, the mobile phone terminal records the timestamp of the data uploaded by the Bluetooth device and performs arithmetic judgment on the SN of one byte in the data through a preset algorithm, thereby solving the problems of data redundancy and timing disorder caused by the multi-channel data reporting of these small Bluetooth devices in the smart home. With the least resources, it solves the problem of judging the newness and oldness of the data, ensuring that users can see the latest data. That is, using the least resources plus the set algorithm, it solves the problem of deduplicating Bluetooth broadcast data and judging the newness and oldness, improving the deduplication efficiency of Bluetooth broadcast data.

[0070] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in various embodiments of the present invention.

[0071] In this embodiment, a data update device is further provided. This device is used to implement the above embodiments and preferred implementation manners, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0072] Figure 4 is a structural block diagram of a data update device according to an embodiment of the present invention; as Figure 4 shown, it includes:

[0073] An acquisition module 42, configured to acquire first data information transmitted by a Bluetooth device and record a first timestamp for acquiring the first data information. Wherein, the first data information includes: a first serial number, and the first serial number is used to indicate the upload times of the first data information corresponding to the Bluetooth device;

[0074] A difference module 44, configured to determine a difference between the first timestamp and a second timestamp corresponding to second data information stored on the terminal, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information;

[0075] A determination module 46, configured to determine whether to update the second data information according to the first data information according to a magnitude relationship between the difference and a preset threshold.

[0076] Through the above technical solution, the first data information transmitted by the Bluetooth device is obtained, and the first timestamp when the first data information is obtained is recorded. The first data information includes: a first serial number, which is used to indicate the number of uploads of the first data information corresponding to the Bluetooth device; the difference between the first timestamp and the second timestamp corresponding to the second data information stored on the terminal is determined, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information; whether to update the second data information according to the first data information is determined according to the magnitude relationship between the difference and the preset threshold, that is, when the terminal obtains the data information sent by the Bluetooth device, the terminal records the corresponding acquisition timestamp and compares it with the historical data information stored in the terminal to preliminarily determine whether the first data information is new data, solving the problems in the related art that the size of the broadcast data of the Bluetooth device is limited and it is impossible to determine new and old data without affecting the service data. By recording timestamps at the terminal and determining the serial number of a single byte in the data information, the new and old judgment of the data information reported on multiple channels is realized, and the data information in the Bluetooth broadcast data is realized with the least resources.

[0077] In an exemplary embodiment, the above determination module is further configured to, when the difference is less than the preset threshold, compare the first serial number in the first data information with the second serial number in the second data information according to a preset algorithm to determine whether to update the second data information according to the first data information; when the difference is greater than the preset threshold, determine to update the second data information according to the first data information.

[0078] For example, each time the mobile phone receives the data uploaded by the Bluetooth device, it records the current upload timestamp, and compares the current timestamp with the timestamp of the previous upload data of the Bluetooth device in the cached data in the mobile phone, and determines the magnitude relationship between the difference between the front and back timestamps and the set preset threshold. When the difference is greater than the preset threshold, it is determined that the currently uploaded data is new data, otherwise, a re-judgment is made by comparing the corresponding serial numbers.

[0079] In an exemplary embodiment, the above determination module further includes: an acquisition unit, configured to acquire a first device identifier carried in the first data information and a second device identifier carried in the second data information; a determination unit, configured to, when the first device identifier is the same as the second device identifier, determine a broadcast frequency threshold of the Bluetooth device corresponding to the first device identifier and a maximum value of the increment of the first serial number; update a rollback parameter in the preset algorithm according to the broadcast frequency threshold and the maximum value, where the rollback parameter is used to indicate a maximum value for rollback update of the first serial number.

[0080] In other words, according to the broadcast frequency threshold and the maximum value of the increment of the first serial number, the rollback parameter for data duplication of the first serial number can be determined. According to the rollback parameter, the number of times the first serial number is updated in a specified number of bytes and the maximum value of the update frequency can be determined, thereby ensuring that the serial numbers corresponding to data information are different at different time points. Only after exceeding the predetermined time period will there be data information carrying different content information with the same first serial number. Further, the first data information and the second data information are compared according to a preset algorithm to determine whether the current first data information is new data information.

[0081] For example, when it is determined that the device is a weighing scale through the device identifier, the broadcast frequency of the weighing scale can be determined to be once every 250 milliseconds according to the corresponding standard table. Then, within the preset threshold of 30 seconds, it will be broadcast 120 times, and the SN will change 120 times. The broadcast frequency threshold can be set to 120. In addition, when the size of the SN field used to indicate the serial number of the weighing scale is 1 byte, the value range of SN can only be 0 - 255. When it is broadcast 256 times, SN is exhausted, and when broadcasting again, it needs to roll back to 0 and start over. At this time, the maximum value of the increment of SN is 255.

[0082] In an exemplary embodiment, the above-mentioned determining module is further configured to determine to update the second data information according to the first data information when the first difference between the first serial number and the second serial number is greater than the first threshold; to determine to update the second data information according to the first data information when the first difference between the first serial number and the second serial number is less than the first threshold and the difference between the maximum value and the first difference is less than the broadcast frequency threshold; and to delete the first data information when the first difference between the first serial number and the second serial number is less than the first threshold and the difference between the maximum value and the first difference is greater than the broadcast frequency threshold.

[0083] For example, let: the first serial number be x, the second serial number be y, the value of the maximum increment of the first serial number be z, and the broadcast frequency threshold for indicating the Bluetooth device be n.

[0084] 1) x - y > 0; the received first data information is new data.

[0085] 2) x - y < 0 and z - |x - y| < n; the received first data information is new data.

[0086] In an exemplary embodiment, the above-mentioned determining module further includes: a prompting unit, configured to re-obtain the second data information stored in the terminal by the Bluetooth device when the first device identifier is different from the second device identifier; and to send a prompting message when there is no second data information in the terminal, where the prompting message is used to prompt whether to establish a storage file.

[0087] Figure 5 is a structural block diagram of another data update device according to an embodiment of the present invention; as Figure 5 shown, in addition to including Figure 4 the modules that already exist in

[0088] In an exemplary embodiment, the above device further includes: a time module, configured to determine the delay time for pushing the first data information between the terminal and the Bluetooth device, where the delay time is used to indicate the difference between the pushing time from the terminal to the Internet of Things cloud receiving the first data information and the preset standard pushing time in the case of large network fluctuations; determine a preset threshold according to the delay time.

[0089] An embodiment of the present invention further provides a storage medium, which includes a stored program, where the above program executes the method of any one of the above when running.

[0090] In an exemplary embodiment, in this embodiment, the above storage medium can be set to store a computer program for executing the following steps:

[0091] S1, obtain the first data information transmitted by the Bluetooth device, and record the first timestamp for obtaining the first data information, where the first data information includes: a first serial number, and the first serial number is used to indicate the upload times of the first data information corresponding to the Bluetooth device;

[0092] S2, determine the difference between the first timestamp and the second timestamp corresponding to the second data information stored on the terminal, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information; S3, determine whether to update the second data information according to the first data information according to the magnitude relationship between the difference and the preset threshold.

[0093] In an exemplary embodiment, in this embodiment, the above storage medium may include, but is not limited to: various media such as a USB flash drive, a read-only memory (ROM for short), a random access memory (RAM for short), a mobile hard disk, a magnetic disk, or an optical disc that can store computer programs.

[0094] An embodiment of the present invention further provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0095] In an exemplary embodiment, the above electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the above processor, and the input / output device is connected to the above processor.

[0096] In an exemplary embodiment, in this embodiment, the above processor may be configured to perform the following steps by a computer program:

[0097] S1. Obtain first data information transmitted by a Bluetooth device, and record a first timestamp for obtaining the first data information, wherein the first data information includes: a first serial number, and the first serial number is used to indicate the upload times of the first data information corresponding to the Bluetooth device;

[0098] S2. Determine the difference between the first timestamp and a second timestamp corresponding to second data information stored on the terminal, wherein the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information;

[0099] S3. Determine whether to update the second data information according to the first data information according to the magnitude relationship between the difference and a preset threshold.

[0100] In an exemplary embodiment, specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation manners, and will not be elaborated herein.

[0101] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed on a network composed of multiple computing devices. In an exemplary embodiment, they can be implemented by program codes executable by a computing device, so that they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order than here, or they can be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them can be fabricated into a single integrated circuit module to implement. Thus, the present invention is not limited to any specific combination of hardware and software.

[0102] The above are only the preferred embodiments of the present invention and are not used to limit the present invention. For those skilled in the art, the present invention can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for updating data, characterized in that, Including: Obtain first data information transmitted by a Bluetooth device, and record a first timestamp for obtaining the first data information, where the first data information includes: a first serial number, and the first serial number is used to indicate the upload times of the first data information corresponding to the Bluetooth device; Determine a difference between the first timestamp and a second timestamp corresponding to second data information stored on the terminal, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information; Determine whether to update the second data information according to the first data information according to a magnitude relationship between the difference and a preset threshold; Among them, determining whether to update the second data information according to the first data information according to a magnitude relationship between the difference and a preset threshold includes: When the difference is less than the preset threshold, compare the first serial number in the first data information with the second serial number in the second data information according to a preset algorithm; When the comparison result indicates that a first difference between the first serial number and the second serial number is greater than a first threshold, determine to update the second data information according to the first data information; When the comparison result indicates that the first difference between the first serial number and the second serial number is less than the first threshold, and a difference between a maximum value of the increment of the first serial number and the first difference is less than a broadcast frequency threshold, determine to update the second data information according to the first data information.

2. The data update method according to claim 1, wherein Determining whether to update the second data information according to the first data information according to a magnitude relationship between the difference and a preset threshold further includes: When the difference is greater than the preset threshold, determine to update the second data information according to the first data information.

3. The data update method according to claim 1, wherein Before comparing the first serial number in the first data information with the second serial number in the second data information according to a preset algorithm when the difference is less than the preset threshold, the method further includes: Obtain a first device identifier carried by the first data information and a second device identifier carried by the second data information; When the first device identifier is the same as the second device identifier, determine a broadcast frequency threshold of the Bluetooth device corresponding to the first device identifier and a maximum value of the increment of the first serial number; Update a rollback parameter in the preset algorithm according to the broadcast frequency threshold and the maximum value, where the rollback parameter is used to indicate a maximum value for rollback updating of the first serial number.

4. The method for updating data according to claim 1, wherein Comparing the first serial number in the first data information with the second serial number in the second data information according to a preset algorithm includes: When the comparison result indicates that the first difference between the first serial number and the second serial number is less than the first threshold, and a difference between the maximum value and the first difference is greater than the broadcast frequency threshold, delete the first data information.

5. The data update method according to claim 3, wherein After obtaining the first device identifier carried by the first data information and the second device identifier carried by the second data information, the method further includes: When the first device identifier is different from the second device identifier, re-obtain the second data information stored by the Bluetooth device in the terminal; When the second data information does not exist in the terminal, send a prompt message, where the prompt message is used to prompt whether to establish a storage file.

6. The data update method according to claim 1, wherein Before determining whether to update the second data information according to the first data information based on the magnitude relationship between the difference value and a preset threshold, the method further includes: Determine the delay time for pushing the first data information between the terminal and the Bluetooth device, where the delay time is used to indicate, in the case of large network fluctuations, the difference between the pushing time from the terminal to the Internet of Things cloud receiving the first data information and the preset standard pushing time; Determine the preset threshold according to the delay time.

7. An apparatus for updating data, characterized in that, Include: An acquisition module, configured to acquire the first data information transmitted by the Bluetooth device and record the first timestamp for acquiring the first data information, where the first data information includes: a first serial number, and the first serial number is used to indicate the upload times of the first data information corresponding to the Bluetooth device; A difference module, configured to determine the difference between the first timestamp and the second timestamp corresponding to the second data information stored on the terminal, where the second data information is the data information stored on the terminal and is the most recent data information received from the Bluetooth device before receiving the first data information; A determination module, configured to determine whether to update the second data information according to the first data information based on the magnitude relationship between the difference value and a preset threshold; The determination module is further configured to, when the difference value is less than the preset threshold, compare the first serial number in the first data information and the second serial number in the second data information according to a preset algorithm; when the comparison result indicates that the first difference between the first serial number and the second serial number is greater than a first threshold, determine to update the second data information according to the first data information; when the comparison result indicates that the first difference between the first serial number and the second serial number is less than the first threshold, and the difference between the maximum value of the increment of the first serial number and the first difference is less than the broadcast frequency threshold, determine to update the second data information according to the first data information.

8. The data updating device according to claim 7, wherein The determination module is further configured to, when the difference value is greater than the preset threshold, determine to update the second data information according to the first data information.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, where the program, when running, executes the method described in any one of claims 1 to 6 above.

10. An electronic device, comprising a memory and a processor, characterized in that, A computer program is stored in the memory, and the processor is configured to execute the method described in any one of claims 1 to 6 through the computer program.

Citation Information

Patent Citations

  • Task duplicate prevention method and device, computer device and storage medium

    CN109766349A

  • Data transmission method and device, electronic equipment and computer readable storage medium

    CN111698176A