Bluetooth-based information synchronization methods, computer-readable storage media, and electronic devices
By using a Bluetooth-based decentralized information synchronization method, a unique message identifier is generated and Bluetooth broadcasting and connection are utilized, which solves the problems of high cost and limited range of information synchronization between multiple devices, and realizes low-cost and wide-range information synchronization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-07
- Publication Date
- 2026-03-06
AI Technical Summary
Existing technologies suffer from high costs, limited scope, and low real-time requirements when synchronizing information between multiple devices. In particular, the needs for convenience and low cost in information synchronization have not been met in analog walkie-talkies, digital walkie-talkies, public network walkie-talkies, and satellite communication products.
A decentralized information synchronization method based on Bluetooth is adopted. By generating a unique message identifier, information synchronization between multiple devices is achieved through Bluetooth broadcasting and connection. This includes the message identifier generation, broadcasting, connection and verification process. The message identifier is generated using the attribute information of the Bluetooth device and the message content, and the message is transmitted through Bluetooth communication.
It enables low-cost, wide-range multi-device information synchronization. The equipment cost is low, it does not rely on satellites or signal towers, and the addition or removal of Bluetooth devices does not affect the synchronization process, thus making up for the limitation of Bluetooth transmission distance.
Smart Images

Figure CN116684432B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of wireless communication technology, and more particularly to a Bluetooth-based information synchronization method, a computer-readable storage medium, and an electronic device. More specifically, it provides a Bluetooth-based decentralized information synchronization method, a computer-readable storage medium, and an electronic device. Background Technology
[0002] With the advancement of electronic science and technology, synchronous information transmission has provided great convenience to people. This non-real-time distribution and synchronization of information among several devices (groups) wirelessly has gradually become a common communication need.
[0003] For example, in products such as analog walkie-talkies, digital walkie-talkies, public network walkie-talkies, cellular mobile stations (phones), and satellite-based communication (maritime telephones), the physical distance between multiple devices is usually far, requiring each message to be transmitted to every device. These types of devices have very low requirements for the real-time performance of message transmission and allow for a certain delay.
[0004] However, analog walkie-talkies only support real-time voice communication, and messages cannot be reviewed; only some digital walkie-talkies support data services and playback; moreover, walkie-talkie products must comply with amateur radio laws and regulations, so their use cases are easily limited. Public network walkie-talkies require a certain cost to use, and their usage range is limited by cellular network coverage; while satellite communication-based products have high equipment and operating costs.
[0005] In view of this, those skilled in the art are eager to develop a low-cost, multi-device information synchronization technology solution that is easier to promote and use. Summary of the Invention
[0006] This invention provides a Bluetooth-based information synchronization method, a computer-readable storage medium, and an electronic device to achieve information synchronization between multiple devices through low-cost Bluetooth communication.
[0007] The first aspect of this invention provides a Bluetooth-based information synchronization method, characterized in that it includes:
[0008] When there are messages to be published, according to the device attribute information of this device and the content of the messages to be published, a message identifier corresponding to each message to be published is generated according to a predetermined algorithm, and the messages to be published and their corresponding message identifiers are recorded in the message dictionary;
[0009] Periodically select no more than a predetermined number of message identifiers from the message dictionary, and broadcast the selected message identifiers via Bluetooth.
[0010] When a connection request is received from another device, a Bluetooth connection is established with the other device, a message request containing the message identifier is received, and the message to be published corresponding to the message identifier in the message dictionary is sent to the other device.
[0011] In a preferred embodiment of the present invention, the method further includes:
[0012] According to the deletion instruction containing the specified message identifier, delete the message corresponding to the specified message identifier from the message dictionary.
[0013] In a preferred embodiment of the present invention, the method further includes:
[0014] According to the output command of the message list, output the message identifier in the message dictionary, or...
[0015] According to the output instructions of the message list, output the message corresponding to the message identifier in the message dictionary.
[0016] In a preferred embodiment of the present invention, the message to be published is a byte stream including the user identifier of the device and the message content, or...
[0017] The message to be published includes the message content entered by the user.
[0018] Before generating a message identifier corresponding to each of the messages to be published according to a predetermined algorithm based on the device attribute information of the device and the content of the messages to be published, the method further includes:
[0019] Generate a byte stream including the user identifier of this device and the message content.
[0020] Replace the generated byte stream with the message to be published.
[0021] In a further preferred embodiment of the present invention, the step of generating a message identifier corresponding to each of the messages to be published according to a predetermined algorithm based on the device attribute information of the device and the content of the messages to be published includes:
[0022] Extract the user identifier and message content from the message to be published.
[0023] Based on the user identifier and message content, a message identifier corresponding to each of the messages to be published is generated according to a predetermined algorithm.
[0024] A second aspect of the present invention also provides a Bluetooth-based information synchronization method, characterized in that it includes:
[0025] When one or more first message identifiers are received via Bluetooth broadcast, a second message identifier that cannot be matched from the known message set is obtained from the one or more first message identifiers received, a Bluetooth connection is established with the sender of the Bluetooth broadcast, and a message corresponding to the second message identifier is requested from the sender of the Bluetooth broadcast.
[0026] When a publish message is received from the sender of the Bluetooth broadcast, the publish message is verified according to the second message identifier, the second message identifier is recorded in the known message set, the Bluetooth connection is disconnected, and a new message arrival event is reported.
[0027] In a preferred embodiment of the present invention, the published message is a byte stream including the user identifier of the sender of the Bluetooth broadcast and the message content.
[0028] The step of verifying the published message based on the second message identifier includes:
[0029] The byte stream is parsed to obtain the user identifier and message content.
[0030] Based on the user identifier and message content, a third message identifier corresponding to each published message is generated according to a predetermined algorithm.
[0031] The third message identifier and the second message identifier are matched to determine the verification result of the received published message.
[0032] In a preferred embodiment of the present invention, requesting the sender of the Bluetooth broadcast to publish the message corresponding to the second message identifier includes:
[0033] The Bluetooth General Attribute Specification (GATT) service requests a publish message corresponding to the second message identifier from the sender of the Bluetooth broadcast.
[0034] In a preferred embodiment of the present invention, the method further includes:
[0035] The received message and its corresponding second message identifier are recorded in the message dictionary.
[0036] In a further preferred embodiment of the present invention, the method further includes:
[0037] The message identifiers in the message dictionary are periodically broadcast via Bluetooth.
[0038] A third aspect of the present invention also provides a Bluetooth-based information synchronization method, characterized in that it includes:
[0039] When there is a message to be published, according to the device attribute information of this device and the content of the message to be published, a first message identifier corresponding to each message to be published is generated according to a predetermined algorithm, and the message to be published and its corresponding first message identifier are recorded in the message dictionary;
[0040] Periodically select no more than a predetermined number of second message identifiers from the message dictionary, and broadcast the selected second message identifiers via Bluetooth.
[0041] When a connection request is received from another device, a Bluetooth connection is established with the other device, a message request containing the third message identifier is received, and the message to be published corresponding to the third message identifier in the message dictionary is sent to the other device.
[0042] Periodically scan Bluetooth broadcasts;
[0043] When one or more fourth message identifiers are received via Bluetooth broadcast, the fifth message identifier that cannot be matched from the known message set among the one or more fourth message identifiers received is obtained, a Bluetooth connection is established with the sender of the Bluetooth broadcast, and a message corresponding to the fifth message identifier is requested from the sender of the Bluetooth broadcast.
[0044] When a publish message is received from the sender of the Bluetooth broadcast, the publish message is verified according to the fifth message identifier, the fifth message identifier is recorded in the known message set, the Bluetooth connection is disconnected, and a new message arrival event is reported.
[0045] A fourth aspect of the present invention also provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores computer program instructions, which, when executed by a processor, are used to implement the Bluetooth-based information synchronization method described in any one of the first, second, or third aspects.
[0046] A fifth aspect of the present invention also provides an electronic device, characterized in that it comprises: a processor and a memory;
[0047] The memory is used to store at least one executable instruction that causes the processor to execute the Bluetooth-based information synchronization method as described in any one of the first, second, or third aspects.
[0048] The technical solution provided in this invention utilizes the features of Bluetooth broadcasting, Bluetooth connection, and Bluetooth service. Based on a uniquely identified message identifier generated by combining each message to be sent with the attribute information of the Bluetooth device, message synchronization is achieved among multiple devices via Bluetooth communication, providing a Bluetooth-based message grouping mechanism. This invention has at least the following significant advantages:
[0049] 1. A decentralized design for information interaction is implemented in a Bluetooth-based network system, providing a Bluetooth-based message grouping mechanism with advantages of low equipment cost and wide application range; moreover, Bluetooth transmission does not require the use of satellites, signal towers or other equipment, and there are no subsequent network usage costs.
[0050] 2. Through this decentralized design, the processing flow will not be affected when Bluetooth devices are added or removed in the information synchronization system.
[0051] Furthermore, the Bluetooth-based information synchronization scheme provided in this embodiment of the invention can also achieve information synchronization over a larger geographical area through an improved forwarding mechanism, thus compensating for the limitation of Bluetooth transmission distance. Attached Figure Description
[0052] Figure 1 This is a schematic diagram of a Bluetooth information synchronization system composed of multiple Bluetooth devices provided in Embodiment 1 of the present invention;
[0053] Figure 2 This is a flowchart of a Bluetooth-based information synchronization method provided in Embodiment 2 of the present invention;
[0054] Figure 3 A flowchart of another Bluetooth-based information synchronization method provided in Embodiment 3 of the present invention;
[0055] Figure 4 A flowchart of another Bluetooth-based information synchronization method provided in Embodiment 3 of the present invention;
[0056] Figure 5 A structural block diagram of a Bluetooth device provided in an embodiment of the present invention;
[0057] Figures 6-12 This is a schematic diagram illustrating message transmission between multiple Bluetooth devices using a Bluetooth-based information synchronization method according to an embodiment of the present invention.
[0058] Figure 13 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0059] The following detailed description of the embodiments of the present invention, in conjunction with the accompanying drawings, will provide a thorough understanding of how the present invention uses technical means to solve technical problems and achieve technical effects, enabling its implementation. It should be noted that these specific descriptions are merely intended to facilitate a clearer understanding of the present invention by those skilled in the art, and are not intended to limit the scope of the invention. Furthermore, as long as there is no conflict, the various embodiments and features within each embodiment can be combined with each other, and the resulting technical solutions are all within the protection scope of the present invention.
[0060] Furthermore, the steps shown in the flowchart in the accompanying drawings can be performed in a control system such as a set of controller-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be performed in a different order than that shown here.
[0061] The Bluetooth devices mentioned in this application can be Bluetooth devices that only support Bluetooth communication, such as Bluetooth headsets, Bluetooth walkie-talkies, Bluetooth vehicle devices, etc., or devices that simultaneously support Bluetooth communication and at least one communication method different from Bluetooth communication, such as Wi-Fi, cellular communication, and satellite communication, such as smartphones and smart displays. The "first," "second," and "third" prefixes before "Bluetooth device" in the following text are merely for distinguishing the recipient of message transmission in different states or scenarios, and are not restrictions on specific terminals. Those skilled in the art should know that "first," "second," and "third" can be interchanged, and the same Bluetooth device can be replaced by different serial numbers in different scenarios or solution descriptions.
[0062] The technical solution of the present invention will now be described in detail with reference to the accompanying drawings and specific embodiments:
[0063] Example 1
[0064] Figure 1 This illustration shows a schematic diagram of a Bluetooth information synchronization system composed of multiple Bluetooth devices, provided by an embodiment of the present invention.
[0065] like Figure 1As shown, the multiple Bluetooth devices provided in this embodiment form a Bluetooth information synchronization system, which can transmit messages between at least two of the first Bluetooth device 100, the second Bluetooth device 200, and the third Bluetooth device 300, and synchronously transmit and / or display the messages to be transmitted among multiple devices. It should be noted that in this embodiment, the first Bluetooth device 100, the second Bluetooth device 200, and the third Bluetooth device 300 can be Bluetooth headsets, Bluetooth walkie-talkies, Bluetooth vehicle-mounted devices, or Bluetooth-enabled smartphones, smart displays, and other Bluetooth devices, respectively. The information synchronization mentioned in this embodiment is not limited to simultaneous transmission and display time, but rather allows multiple different devices to receive and / or display the messages to be transmitted under predetermined conditions.
[0066] Furthermore, the first Bluetooth device 100, the second Bluetooth device 200, and the third Bluetooth device 300 can also communicate and synchronize information with other Bluetooth devices not in the same Bluetooth network. For example, they can connect to a Bluetooth smart device 400 via Bluetooth communication. The Bluetooth smart device 400 can receive messages to be transmitted via a non-Bluetooth protocol, and then transmit them to the first Bluetooth device 100, the second Bluetooth device 200, and / or the third Bluetooth device 300 via Bluetooth broadcast according to the Bluetooth communication protocol. Therefore, this embodiment achieves multi-device message synchronization through low-cost Bluetooth communication (e.g., Bluetooth Low Energy communication), which can be widely used in many scenarios. Specifically, based on the existing Bluetooth protocol, each message to be sent is combined with the attribute information of the Bluetooth device, and a uniquely identifiable message identifier is generated according to a predetermined algorithm. The message to be transmitted is then distributed among multiple devices via Bluetooth communication, thereby achieving information synchronization between multiple devices.
[0067] The following will refer to Figures 2-4 The process of the information synchronization method applicable to any of the foregoing Bluetooth devices according to embodiments of the present invention is described in detail.
[0068] Example 2
[0069] Reference Figure 2 In step S110, when there is a message to be published, according to the device attribute information of this device and the content of the message to be published, a message identifier corresponding to each message to be published is generated according to a predetermined algorithm, and the message to be published and its corresponding message identifier are recorded in the message dictionary.
[0070] Specifically, when an instruction is received or detected that the application layer of the Bluetooth device wants to publish one or more messages, the aforementioned step S110 is executed. First, using the device attribute information of this device (such as device name, username in the application, etc.) and the content of the message to be published (such as text content, image content, etc.), a corresponding message identifier is generated for each message to be published according to a predetermined algorithm. This message identifier is used to uniquely identify each message to be published in the aforementioned Bluetooth information synchronization system. In the process of generating the message identifier, based on some or all of the information in the device attribute information and some or all of the content in the message to be published, a hash value is calculated on the data according to the algorithm logic, which serves as the message identifier. The specific algorithm can be a hash algorithm or other custom algorithms. Each message to be published can be uniquely identified during the message processing before sending, and the message sender (including the direct sender and / or indirect sender) can identify the content to be processed by the receiver after receiving the message identifier. For example, the format of the message identifier ID can meet the requirements of the algorithm that can be parsed, or the message identifier can generate parameters that meet the algorithm requirements corresponding to the algorithm and decryption parameters defined by the sender; alternatively, after the sender generates the message identifier according to a hash algorithm or other algorithm, the message ID itself can be directly identified by the receiver without the need for secondary calculation using a decryption algorithm. These different implementation methods are all within the protection scope of the embodiments of this invention.
[0071] Subsequently, the message to be published and its corresponding message identifier are recorded in the message dictionary for broadcasting during subsequent execution of step S120.
[0072] In step S120, a predetermined number of message identifiers are periodically selected from the message dictionary and broadcast via Bluetooth. For example, message identifiers to be broadcast can be selected based on the order of the publication times of the messages to be published, generating a broadcast message including the selected message identifiers, and then broadcasting the generated broadcast message via Bluetooth. Since the broadcast data of a Bluetooth broadcast message has a length limit, the number of message identifiers K to be sent can be determined based on the maximum length of the broadcast data. If the number of messages in the message dictionary does not exceed K, all message identifiers in the message dictionary can be selected to generate a broadcast message and broadcast via Bluetooth on the Bluetooth network of the Bluetooth device. For example, in... Figure 1 In the Bluetooth information synchronization system shown, when the first Bluetooth device 100 sends a Bluetooth broadcast, the second Bluetooth device 200 and the third Bluetooth device 300 may scan for the Bluetooth broadcast message.
[0073] In step S130, when a connection request is received from another device, a Bluetooth connection is established with the other device, a message request containing a message identifier is received, and the message to be published corresponding to the message identifier in the message dictionary is sent to the other device.
[0074] In this embodiment, the other device mentioned is any Bluetooth device that received the aforementioned Bluetooth broadcast (e.g., the second Bluetooth device 200 or the third Bluetooth device 300, etc.). According to the information synchronization method of this embodiment, when the other device receives a broadcast message containing one or more message identifiers and parses these message identifiers, it may want to obtain the corresponding message. At this time, the other device will send a connection request to itself and attempt to obtain one or more messages (see the description in Embodiment 3). When this device receives a connection request from the other device, it establishes a Bluetooth connection with the other device, receives a message request containing message identifiers, and sends the message to be published corresponding to the message identifier in the message dictionary to the other device. Thus, the synchronization of the message to be published between multiple Bluetooth devices is completed.
[0075] It should be noted that each of the aforementioned steps S110 to S130 has a trigger condition. The same Bluetooth device can execute the corresponding steps according to the corresponding trigger condition, rather than executing these steps in the order described above.
[0076] In an optional embodiment of the present invention, in step S110, the generated message identifier may also be recorded in a ready message set, which is used to manage the message identifiers corresponding to all messages to be published by the device. In step S120, the ready message set is used to generate a broadcast message, which is then broadcast externally via Bluetooth.
[0077] Based on the aforementioned steps S110~S130, this information synchronization method can also provide other functions for message maintenance.
[0078] According to another optional embodiment of the present invention, the information synchronization method further includes: deleting the message corresponding to the specified message identifier from the message dictionary according to a deletion instruction containing the specified message identifier, thereby deleting the processed message. The deletion instruction for the specified message identifier may be that the message to be published has been successfully published or displayed, or that the user has confirmed receipt of the message to be published, or that the user has performed a predetermined operation on the Bluetooth device, such as pressing a message button to display the message without requiring further prompting.
[0079] According to another optional embodiment of the present invention, the information synchronization method further includes: outputting message identifiers in the message dictionary according to the output instruction of the message list, and / or outputting the message corresponding to the message identifier in the message dictionary according to the output instruction of the message list. For example, when a user wants to browse published and received messages, they can input an instruction to browse the message list; at this time, the corresponding message information is output through the aforementioned processing.
[0080] Furthermore, according to an exemplary embodiment of the present invention, the message to be published is a byte stream including the user identifier of the device and message content, or the message to be published includes message content input by the user. Accordingly, in the processing of step S110, before generating a message identifier corresponding to each message to be published according to a predetermined algorithm based on the device attribute information of the device and the content of the message to be published, the following processing is also performed: generating a byte stream including the user identifier of the device and message content, and replacing the generated byte stream with the message to be published; in the process of generating message identifiers, extracting the user identifier and message content from the message to be published, and generating a message identifier corresponding to each message to be published according to a predetermined algorithm based on the user identifier and message content.
[0081] Example 3
[0082] In the Bluetooth information synchronization system according to an embodiment of the present invention, each Bluetooth device also periodically performs Bluetooth broadcast scans to obtain messages broadcast by other Bluetooth devices. Accordingly, the execution... Figure 3 The processing is shown.
[0083] Reference Figure 3 In step S210, when one or more first message identifiers are received via Bluetooth broadcast, a second message identifier that cannot be matched from the known message set among the one or more first message identifiers is obtained, a Bluetooth connection is established with the sender of the Bluetooth broadcast, and a message corresponding to the second message identifier is requested from the sender of the Bluetooth broadcast.
[0084] According to the Bluetooth-based information synchronization method of the present invention, each Bluetooth device maintains a local known message set, which is used to record the message identifiers of published messages that it has received. Furthermore, the known message set may also record the message identifiers of the following messages: messages that already exist locally, messages that have been successfully parsed, messages that have been reported, or messages that meet other conditions set by the controller that the device already knows about the message, but are not limited to these.
[0085] When a broadcast message containing one or more first message identifiers is detected via Bluetooth broadcast, the first message identifier in the broadcast message is matched with the local known message set. If there is a second message identifier that cannot be matched, a Bluetooth connection is established with the sender of the Bluetooth broadcast, and a message corresponding to the second message identifier is requested from the sender of the Bluetooth broadcast.
[0086] It should be noted that if a second message identifier can be matched from the known message set, the current message identifier can be either not received or received and then directly deleted; these different implementation methods are all within the protection scope of this embodiment.
[0087] Subsequently, in step S220, when a publish message is received from the sender of the Bluetooth broadcast, the publish message is verified according to the second message identifier, the second message identifier is recorded in the known message set, the Bluetooth connection is disconnected, and a new message arrival event is reported.
[0088] In this embodiment, a similar process to that used in step S110 of Example 1 to generate the message identifier for the received message can be employed to calculate the message identifier for the received message. The calculated message identifier is then matched with the second message identifier to determine the verification result. Specifically, the second message identifier can be analyzed to determine whether it can be recognized by the second Bluetooth device (for example, by using a hash algorithm to determine if the calculated parameter value meets the requirements, or by using a decryption algorithm to determine if the decryption parameters corresponding to the message identifier meet the requirements). Of course, the timeliness of the message identifier can also be verified. These different implementation methods all fall within the scope of protection of this embodiment.
[0089] As described above, according to an optional embodiment of the present invention, the published message is a byte stream including the user identifier of the Bluetooth broadcast sender and the message content. Accordingly, in the process of verifying the published message based on the second message identifier, the byte stream is parsed to obtain the user identifier and the message content; based on the user identifier and the message content, a third message identifier corresponding to each published message is generated according to a predetermined algorithm; the third message identifier and the second message identifier are matched to determine the verification result of the received published message.
[0090] After successful verification, the second message identifier is recorded in the known message set, and the Bluetooth connection is disconnected. Specifically, the connection can be disconnected based on receiving this published message, or it can be determined before disconnection whether there are other new published messages. If so, the Bluetooth connection is disconnected only after all published messages have been received.
[0091] In addition, in the process of requesting the publication message corresponding to the second message identifier from the sender of the Bluetooth broadcast, the existing Bluetooth General Attribute Specification (GATT) service can be used to request the publication message corresponding to the second message identifier from the sender of the Bluetooth broadcast.
[0092] In a preferred embodiment of this example, the method further includes: recording the received message and its corresponding second message identifier in a local message dictionary to maintain processed (published and received) published messages.
[0093] Furthermore, the information synchronization method may also include: periodically broadcasting message identifiers from the message dictionary via Bluetooth, which can be performed with reference to step S120 in Embodiment 1. In this embodiment, periodically broadcasting message identifiers from the message dictionary via Bluetooth can further enable the forwarding of received published messages, allowing other devices in the local Bluetooth network to scan for published messages from other Bluetooth networks.
[0094] Example 4
[0095] It should be noted that in the Bluetooth information synchronization system provided in this embodiment of the invention, each Bluetooth device is on an equal footing; that is, it can both publish and broadcast messages and perform Bluetooth scanning to obtain messages published by other Bluetooth devices. The following will refer to... Figure 4 This describes a Bluetooth-based information synchronization method.
[0096] Reference Figure 4 In step S310, when there is a message to be published, the device attribute information of the device and the content of the message to be published are used to generate a first message identifier corresponding to each message to be published according to a predetermined algorithm, and the message to be published and its corresponding first message identifier are recorded in the message dictionary.
[0097] In step S320, no more than a predetermined number of second message identifiers are periodically selected from the message dictionary, and the selected second message identifiers are broadcast via Bluetooth.
[0098] In step S330, when a connection request is received from another device, a Bluetooth connection is established with the other device, a message request containing a third message identifier is received, and the message to be published corresponding to the third message identifier in the message dictionary is sent to the other device.
[0099] In step S340, Bluetooth broadcasts are periodically scanned.
[0100] In step S350, when one or more fourth message identifiers are received via Bluetooth broadcast, the fifth message identifier that cannot be matched from the known message set among the one or more fourth message identifiers is obtained, a Bluetooth connection is established with the sender of the Bluetooth broadcast, and a message corresponding to the fifth message identifier is requested from the sender of the Bluetooth broadcast.
[0101] In step S360, when a publish message is received from the sender via Bluetooth broadcast, the publish message is verified according to the fifth message identifier, the fifth message identifier is recorded in the known message set, the Bluetooth connection is disconnected, and a new message arrival event is reported.
[0102] In the embodiments provided in this example, the first, second, third, fourth, and fifth methods are merely for distinguishing message objects in different steps and / or different subjects. The message identifiers corresponding to these different steps and execution subjects may themselves be the same message identifier. These methods are only used to make the above embodiments easier to understand for those skilled in the art. The predetermined algorithms, message identifiers, message dictionaries, and other technical solutions mentioned in the above embodiments are the same as the implementation methods corresponding to the aforementioned embodiments two and three, and will not be repeated here.
[0103] Example 5
[0104] Figure 5 The diagram illustrates a structural block diagram of a Bluetooth device provided by an embodiment of the present invention. This Bluetooth device is applicable to the Bluetooth information synchronization system in Embodiment 1 and is used to execute any of the Bluetooth-based information synchronization methods described in Embodiments 2 to 4.
[0105] Reference Figure 5 A Bluetooth device includes:
[0106] The display screen 110 is used to display the received information; the display screen 110 can be a display device of LED, LCD, OLED or other types, or it can be a message display device that works in conjunction with a video display module, a voice prompt module or other similar devices.
[0107] The device controller 120 is connected to the display screen 110 and the button 150 respectively, so that the operation of Bluetooth message transmission, Bluetooth message sending and / or Bluetooth message display can be initiated through the button 150; the button 150 can be a physical button or a touch screen button, etc.; the device controller 120 can select different controllers according to the specific type of device and application, and the controller type can be one or more different types of combination such as microcontroller, SoC, FPGA, etc.
[0108] The Bluetooth communication module 140 includes an antenna and Bluetooth chip for receiving, forwarding, and sending Bluetooth messages.
[0109] The Bluetooth message processor 130 is used to perform message reception, transmission and parsing as mentioned below. The Bluetooth message processor 130 may be integrated with the device controller 120 or it may be a separate device. These different implementations are all within the protection scope of this invention. Moreover, the Bluetooth device provided in this embodiment may also include only the Bluetooth message processor and the Bluetooth communication module 140, while other modules are another independent electronic device, or it may be an entire electronic device integrated with other modules.
[0110] The following is combined Figure 5 Bluetooth devices described in Figures 6-12 The corresponding schematic diagram for message transmission between multiple Bluetooth devices further explains the technical solution provided in this embodiment.
[0111] like Figure 5 As shown, in the Bluetooth device provided in this embodiment, the device controller 120 is responsible for implementing the user interface (display, key input, etc.) and calling various interfaces provided in this embodiment according to the user's instructions.
[0112] Specifically, this embodiment provides the following operation interfaces (or functions):
[0113] 1. Publish a message (POST_MSG):
[0114] This interface is used to synchronize a message to all devices in a group (for example, a user interface in a Bluetooth device receives a message input by the user and then publishes it through this interface). The parameter of the interface is a message M.
[0115] 2. Read message (READ_MSG):
[0116] Read a message (for example, the interface program in the device obtains the message content through this interface and then displays it). The parameter of this interface is a message ID.
[0117] 3. Delete Message (abbreviated as DEL_MSG): Deletes the cached message. The parameter of this interface is a message ID;
[0118] 4. Message List (LIST_MSG): Lists currently cached messages.
[0119] The Bluetooth device provided in this embodiment can actively report the following events: New message arrival (EVENT_NEW_MSG): For example, after receiving a new message, the present invention reports the event to the interface program in the device, and then the interface program notifies the user; the parameter of the event is a message ID.
[0120] This embodiment requires two message ID sets: KNOWN_SET (also known as the first message set or known message set) and DATA_READY_SET (also known as the second message set or data-ready message set). Elements in both sets will be dynamically added or removed, but DATA_READY_SET will always be a subset of KNOWN_SET. During initialization, both sets are initialized to empty sets. This invention also uses a message storage unit (MSG_DICT) to store the messages themselves according to their message IDs.
[0121] The specific steps for using the "Publish Message (POST_MSG)" operation interface are as follows:
[0122] Step 1.1: Calculate the hash value of the input parameter M, denoted as ID;
[0123] Step 1.2: If the ID already exists in KNOWN_SET, output an error message (such as "Message already exists"), and then end;
[0124] Step 1.3: Add the ID to the KNOWN_SET;
[0125] Step 1.4: Store ID and M in MSG_DICT.
[0126] The specific steps for the operation interface "Read Message (READ_MSG)" are as follows:
[0127] Step 2.1: If the input parameter ID is not in KNOWN_SET, output an error message (such as "Message ID unknown").
[0128] Step 2.2: If the input parameter ID is not in DATA_READY_SET, output an error message (such as "Message data is temporarily unavailable"), and then end;
[0129] Step 2.3: Obtain the message corresponding to the ID from MSG_DICT and output it.
[0130] The specific steps for the "Delete Message (DEL_MSG)" operation interface are as follows:
[0131] Step 3.1: If the input parameter ID is not in KNOWN_SET, output an error message (such as "Message ID unknown").
[0132] Step 3.2: If the input parameter ID is in DATA_READY_SET, delete the ID from DATA_READY_SET;
[0133] Step 3.3: Delete the message corresponding to the ID from MSG_DICT.
[0134] The specific steps for operating the "Message List (LIST_MSG)" interface are as follows:
[0135] Step 5.1: Output each ID in MSG_DICT.
[0136] The Bluetooth device provided in this embodiment continuously sends Bluetooth broadcasts, including DATA_READY_SET, under predetermined conditions. When this set changes, the broadcast data is updated accordingly. This invention continuously sends connectable Bluetooth broadcasts, waiting to be connected by a central device. After establishing a Bluetooth connection, this invention provides the following interfaces through the GATT layer:
[0137] Bluetooth read message (BLE_READ_MSG):
[0138] Read a message;
[0139] The parameter of this interface is a message ID.
[0140] The Bluetooth device provided in this embodiment will also periodically update DATA_READY_SET under predetermined conditions. Since the broadcast data length is limited, assuming a maximum of K message IDs can be sent, then:
[0141] Step 6.1: If the number of messages in MSG_DICT does not exceed K, then use the IDs of all messages in MSG_DICT to form DATA_READY_SET; End;
[0142] Step 6.2: Select K messages from MSG_DICT and combine their IDs to form DATA_READY_SET (the selection process should ensure that each message has the same probability of being selected).
[0143] The Bluetooth device provided in this embodiment will continuously scan for Bluetooth broadcasts under predetermined conditions. After receiving the DATA_READY_SET information carried in the broadcast data, it will perform the following steps (the DATA_READY_SET carried in the received broadcast data will be denoted as DATA_READY_SET_FROM_ADV):
[0144] Step 4.1: Calculate Ω = {id | id ∈ DATA_READY_SET_FROM_ADV and id KNOWN_SET}
[0145] Step 4.2: If Ω = Φ (empty set), end;
[0146] Step 4.3: Attempt to connect to the sender of the broadcast; if the connection fails, end the process.
[0147] Step 4.4: For each message ID within Ω:
[0148] Step 4.4.1: Read the corresponding message data M through the "Bluetooth Read Message (BLE_READ_MSG)" interface; if an error occurs during reading, proceed to process the next message ID;
[0149] Step 4.4.2: Optionally, after receiving message data M, verify whether the message ID matches; if they do not match, an error is considered to have occurred.
[0150] Step 4.4.3: Add the ID to the KNOWN_SET;
[0151] Step 4.4.4: Store ID and M in MSG_DICT
[0152] Step 4.4.5: Report the "New Message Arrived (EVENT_NEW_MSG)" event, with the parameter being the ID;
[0153] Step 4.5: Disconnect.
[0154] The specific implementation method for calculating the message ID is as follows:
[0155] Considering the limited supported message length, the results of existing hash algorithms can be truncated as IDs, for example:
[0156] The first 8 bytes of ID=SM3(M) refer to SM3, a cryptographic hash function standard released by the State Cryptography Administration of China on December 17, 2010. The relevant standard is "GM / T 0004-2012 《SM3 Cryptographic Hash Algorithm》".
[0157] The first 8 bytes of ID=SHA-256(M) are used here. SHA-256 is one of the cryptographic hash function algorithm standards released by the National Institute of Standards and Technology (NIST) in 2001.
[0158] Specific implementation of the broadcast sending method for DATA_READY_SET:
[0159] The data structure of the broadcast data item "Manufacturer Specific Data" as defined in the Bluetooth specification is as follows:
[0160]
[0161] Specific implementation methods of GATT services:
[0162]
[0163] The GATT client first writes the message ID to be read into MSG_ID, then reads STATUS to check for errors. If no errors are found, it waits for the server to report message data via MSG_DATA. Optionally, upon receiving message data, it verifies whether the message ID matches; if they do not match, an error is considered to have occurred.
[0164] The low-power Bluetooth module in the Bluetooth device provided in this embodiment is used to implement various Bluetooth functions. Other modules (such as power supply, buzzer, etc.) can also be set in the Bluetooth device, and a microphone module can also be added to the Bluetooth device to support voice message input.
[0165] The main user interaction methods and functions of this Bluetooth device are implemented as follows:
[0166] 1. Sending messages:
[0167] a) The user enters the message to be sent by pressing the key and then presses the send key;
[0168] b) The control module publishes messages through the "Publish Message (POST_MSG)" interface.
[0169] 2. Message playback and query:
[0170] a) The control module obtains each message ID through the "Message List (LIST_MSG)" interface and displays it on the screen;
[0171] b) The user selects a message based on the display screen;
[0172] c) The control module reads message content through the "READ_MSG" interface;
[0173] d) The control module displays the message content on the screen.
[0174] 3. New Message Notification – When the control module receives the “New Message Arrived (EVENT_NEW_MSG)” event reported by this invention:
[0175] a) The control module sends new message notifications to the user (such as issuing a beep);
[0176] b) The user presses the button to view the new message;
[0177] c) The control module reads message content through the "READ_MSG" interface;
[0178] d) The control module displays the message content on the screen.
[0179] The following is based on Figures 2-11 Taking the four corresponding Bluetooth devices as an example, this embodiment illustrates the specific operation of multiple Bluetooth devices.
[0180] These four Bluetooth devices are named Bluetooth Device A, Bluetooth Device B, Bluetooth Device C, and Bluetooth Device D (for simplicity, they will be referred to as A, B, C, and D respectively below). Their geographical locations are as follows: Figures 4-11 As shown, A and D are far apart, exceeding the communication range of Bluetooth Low Energy (BLE). However, the distance between two adjacent devices is relatively close, allowing BLE to communicate normally.
[0181] like Figure 6 As shown, the four Bluetooth devices are in their initial state, and the set of data ready messages corresponding to the Bluetooth broadcast in each Bluetooth device is empty.
[0182] like Figure 7 As shown, a user of Bluetooth device A published a message "It's raining". The ID calculated for this message is denoted as ID0. The data ready message set corresponding to the Bluetooth broadcast in the other three Bluetooth devices is an empty set.
[0183] like Figure 8 As shown, when Bluetooth device B in the vicinity of Bluetooth device A detects Bluetooth device A's broadcast during scanning, it executes all or part of the information synchronization method in the Bluetooth information synchronization method described above. At this time, the broadcast status of each Bluetooth device becomes: the set of data ready messages corresponding to the broadcast in Bluetooth device B is ID0, while the set of data ready messages corresponding to the Bluetooth broadcast in Bluetooth devices C and D is empty. Moreover, Bluetooth device B will read the message data corresponding to ID0 and record it in MSG_DICT, and report "New message arrived (EVENT_NEW_MSG)" to the device controller of Bluetooth device B. The device controller controls the display to show "A said: It's raining".
[0184] like Figure 9 As shown, Bluetooth device C and Bluetooth device D also read message ID0 and displayed it to the user in turn. At this time, the broadcast status of each Bluetooth device becomes: the broadcast corresponding data ready message set is ID0.
[0185] like Figure 10 As shown, assuming Bluetooth device D scans the data broadcast by other devices and performs a deletion operation, the set of ready data messages corresponding to the broadcast by Bluetooth device D is empty, and the broadcast status of each device becomes... Figure 10 The diagram is shown in the image.
[0186] like Figure 11 As shown, if a user of Bluetooth device D publishes a message "It's hailing," the ID calculated for this message is denoted as ID1. At this point, the broadcast status of each device becomes as follows: Figure 11 The diagram shown is shown in the image.
[0187] like Figure 12 As shown, if Bluetooth device C detects a broadcast from Bluetooth device D during scanning, it executes the aforementioned information synchronization method. It reads and records the message data corresponding to ID1 in MSG_DICT, and reports "New message arrived (EVENT_NEW_MSG)" to the device controller of Bluetooth device C. The device controller then controls the display to show "D said: It's hailing." Similarly, Bluetooth devices A and B also read message ID1 and display it to the user. At this point, the broadcast status of each device becomes... Figure 12 The corresponding diagram is shown in the image.
[0188] Based on the above Figures 6-12 In the corresponding application scenario, suppose Bluetooth device E moves from a distance to near Bluetooth device D. Upon detecting a broadcast from Bluetooth device D, it executes the Bluetooth information synchronization method described above, reading the message data corresponding to ID1 and reporting it to the device controller of Bluetooth device E. At this point, the ID1 message has been successfully distributed to 5 Bluetooth devices, but the ID0 message has not yet reached device E. If Bluetooth device E then moves closer to Bluetooth device C, and the proximity is sufficient to receive a Bluetooth broadcast from Bluetooth device C, the information synchronization method described above can be executed again, reading the message data corresponding to ID0 and reporting it to the device controller in Bluetooth device E. In this way, the ID0 message is also successfully distributed to all 5 devices.
[0189] Based on the above description, the technical solution provided in this embodiment can achieve at least the following beneficial effects:
[0190] 1. A decentralized design for information interaction is implemented in a Bluetooth-based network system, providing a Bluetooth-based message grouping mechanism with advantages of low equipment cost and wide application range; moreover, Bluetooth transmission does not require the use of satellites, signal towers or other equipment, and there are no subsequent network usage costs.
[0191] 2. Through this decentralized design, the processing flow will not be affected when Bluetooth devices are added or removed in the information synchronization system.
[0192] 3. Each Bluetooth device also acts as a relay, enabling messages to be transmitted over greater distances (such as message ID0 from Bluetooth device A to Bluetooth device D), achieving information synchronization over a wider geographical area and compensating for the limitation of Bluetooth transmission distance.
[0193] This invention also provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores computer program instructions, which, when executed by a processor, are used to implement the Bluetooth-based information synchronization method as provided above.
[0194] This invention also provides an electronic device, comprising: a processor and a memory; the memory is used to store at least one executable instruction, which causes the processor to perform a Bluetooth-based information synchronization method as provided above.
[0195] Specifically, such as Figure 13 This is a schematic diagram illustrating the structure of an electronic device 600 according to an embodiment of the present invention. The electronic device 600 may be, for example, a mobile terminal, a personal computer (PC), a tablet computer, a server, etc.
[0196] like Figure 13 As shown, electronic device 600 may include memory and processor. Specifically, electronic device 600 includes one or more processors, communication elements, etc. The one or more processors include, for example, one or more central processing units (CPUs) 601, and / or one or more GPUs 613, etc. The processors can perform various appropriate actions and processes according to executable instructions stored in read-only memory (ROM) 602 or executable instructions loaded from storage portion 608 into random access memory (RAM) 603. The communication elements include communication component 612 and / or communication interface 609. The communication component 612 may include, but is not limited to, a network interface card (NIC), which may include, but is not limited to, an Infiniband (IB) NIC. The communication interface 609 includes the communication interface of a network interface card such as a LAN card or modem, and the communication interface 609 performs communication processing via a network such as the Internet.
[0197] The processor can communicate with the read-only memory 602 and / or random access memory 603 to execute executable instructions, connect to the communication component 612 via the communication bus 604, and communicate with other target devices via the communication component 612, thereby completing any of the Bluetooth-based information synchronization methods provided in the embodiments of the present invention.
[0198] In addition, RAM 603 may also store various programs and data required for device operation. CPU 601 or GPU 613, ROM 602, and RAM 603 are interconnected via communication bus 604. With RAM 603 present, ROM 602 is an optional module. RAM 603 stores executable instructions, or executable instructions are written to ROM 602 during runtime. These executable instructions cause the processor to perform operations corresponding to the aforementioned communication method. Input / output (I / O) interface 605 is also connected to communication bus 604. Communication component 612 can be integrated or configured with multiple sub-modules (e.g., multiple IB network cards) linked on the communication bus.
[0199] The following components are connected to I / O interface 605: input section 606 including keyboard, mouse, etc.; output section 607 including cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; storage section 608 including hard disk, etc.; and communication interface 609 including network interface card, such as LAN card, modem, etc. Drive 610 is also connected to I / O interface 605 as needed. Removable media 611, such as disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 610 as needed so that computer programs read from them can be installed into storage section 608 as needed.
[0200] It needs to be explained, such as Figure 13 The architecture shown is only one optional implementation. In practice, the above can be modified according to actual needs. Figure 13 The number and type of components can be selected, deleted, added, or replaced; different functional components can also be implemented by separate or integrated configurations. For example, the GPU and CPU can be set separately or the GPU can be integrated on the CPU; communication components can be set separately or integrated on the CPU or GPU, and so on. All these alternative implementation methods fall within the protection scope of this invention.
[0201] The electronic device in this embodiment of the invention can be used to implement the corresponding Bluetooth information synchronization method in the above embodiments. Each device in the electronic device can be used to execute each step in the above method embodiments. For example, the Bluetooth-based information synchronization method described above can be implemented by the processor of the electronic device calling the relevant instructions stored in the memory. For the sake of brevity, it will not be described again here.
[0202] The methods, apparatuses, electronic devices, and storage media of the present invention may be implemented in many ways. For example, the methods, apparatuses, electronic devices, and storage media of embodiments of the present invention may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the method is for illustrative purposes only, and the steps of the method of the embodiments of the present invention are not limited to the order specifically described above, unless otherwise specifically stated. Furthermore, in some embodiments, the present invention may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to embodiments of the present invention. Therefore, the present invention also covers recording media storing programs for performing methods according to embodiments of the present invention.
[0203] The description of the embodiments of the present invention is provided for illustrative and descriptive purposes only, and is not intended to be exhaustive or to limit the invention to the forms disclosed. Many modifications and variations will be apparent to those skilled in the art. The embodiments were chosen and described in order to better illustrate the principles and practical application of the invention, and to enable those skilled in the art to understand the invention and design various embodiments with various modifications suitable for a particular purpose.
Claims
1. A Bluetooth-based information synchronization method, characterized by, The method comprises: When there are messages to be published, according to the device attribute information of the device and the content of the messages to be published, message identifiers corresponding to each of the messages to be published are generated according to a predetermined algorithm, and the messages to be published and the corresponding message identifiers are recorded in a message dictionary, the message identifier being used to uniquely identify the corresponding message to be published; Periodically, no more than a predetermined number of message identifiers are selected from the message dictionary, and the selected message identifiers are sent through Bluetooth broadcast; When a connection request from another device is received, a Bluetooth connection with the other device is established, a message request containing the message identifier is received, and the message to be published corresponding to the message identifier in the message dictionary is sent to the other device.
2. The method of claim 1, wherein, The method further comprises: According to a deletion instruction containing a specified message identifier, the message corresponding to the specified message identifier is deleted from the message dictionary.
3. The method of claim 1, wherein, The method further comprises: According to a message list output instruction, the message identifier in the message dictionary is output, or According to a message list output instruction, the message corresponding to the message identifier in the message dictionary is output.
4. The method according to any one of claims 1 to 3, characterized in that, The message to be published is a byte stream comprising a user identifier of the device and message content, or The message to be published comprises user input message content, Before generating the message identifier corresponding to each of the messages to be published according to the device attribute information of the device and the content of the messages to be published, the method further comprises: generating a byte stream comprising a user identifier of the device and the message content, replacing the generated byte stream with the message to be published.
5. The method of claim 4, wherein, The method of generating the message identifier corresponding to each of the messages to be published according to the device attribute information of the device and the content of the messages to be published comprises: extracting the user identifier and message content from the message to be published, generating the message identifier corresponding to each of the messages to be published according to the user identifier and message content according to a predetermined algorithm.
6. A Bluetooth-based information synchronization method, characterized by, The method comprises: When one or more first message identifiers are received through Bluetooth broadcast, a second message identifier that fails to match from a known message set among the received one or more first message identifiers is obtained, a Bluetooth connection with the sender of the Bluetooth broadcast is established, a published message corresponding to the second message identifier is requested from the sender of the Bluetooth broadcast, the first message identifier and the second message identifier are both message identifiers generated by the sender of the Bluetooth broadcast according to a predetermined algorithm according to the device attribute information of the device and the content of the messages to be published, the message identifier being used to uniquely identify each of the messages to be published; When a published message from the sender of the Bluetooth broadcast is received, the published message is verified according to the second message identifier, the second message identifier is recorded in the known message set, the Bluetooth connection is disconnected, and a new message arrival event is reported.
7. The method of claim 6, wherein, The published message is a byte stream comprising a user identifier of the sender of the Bluetooth broadcast and message content, The method of verifying the published message according to the second message identifier comprises: parsing the byte stream to obtain the user identifier and message content, According to the user identifier and the message content, a third message identifier corresponding to each of the published messages is generated according to a predetermined algorithm, The third message identifier and the second message identifier are matched to determine a verification result of the received published message.
8. The method according to claim 6 or 7, characterized in that, The method further comprises: The method further comprises:
9. The method according to claim 6 or 7, characterized in that, The received message and the corresponding second message identifier are recorded in a message dictionary. The method further comprises:
10. The method of claim 9, wherein, The message identifiers in the message dictionary are periodically sent through Bluetooth broadcasting. The method further comprises:
11. A method for synchronizing information based on Bluetooth, characterized by, When there are messages to be published, a first message identifier corresponding to each of the messages to be published is generated according to a predetermined algorithm based on device attribute information of the device and content of the messages to be published, and the messages to be published and the corresponding first message identifiers are recorded in a message dictionary, wherein the first message identifier is used to uniquely identify the corresponding message to be published; A second message identifier is selected from the message dictionary periodically, and the selected second message identifier is sent through Bluetooth broadcasting, wherein the second message identifier is used to uniquely identify the corresponding message to be published; When a connection request from another device is received, a Bluetooth connection with the other device is established, a message request containing a third message identifier is received, and a message to be published corresponding to the third message identifier in the message dictionary is sent to the other device; Bluetooth broadcasting is periodically scanned; When one or more fourth message identifiers are received through Bluetooth broadcasting, a fifth message identifier that fails to match from a known message set among the received one or more fourth message identifiers is obtained, a Bluetooth connection with a sender of the Bluetooth broadcasting is established, and a message to be published corresponding to the fifth message identifier is requested from the sender of the Bluetooth broadcasting; When a published message from the sender of the Bluetooth broadcasting is received, the published message is verified according to the fifth message identifier, the fifth message identifier is recorded in the known message set, the Bluetooth connection is disconnected, and a new message arrival event is reported. The computer readable storage medium stores computer program instructions, which are executed by a processor to implement the Bluetooth-based information synchronization method according to any one of claims 1-11.
12. A computer-readable storage medium, characterized in that, The method further comprises:
13. An electronic device, comprising: A processor and a memory; The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the Bluetooth-based information synchronization method according to any one of claims 1-11.
Citation Information
Patent Citations
Networking protocol based on Bluetooth communication
CN108540502A
Bluetooth connection method, terminal device and communication system
CN114554473A