Communication method and apparatus based on bluetooth broadcasting
By optimizing the MAC address processing of instrument devices through Bluetooth broadcast communication, the problems of long communication time and low success rate between instrument devices are solved, and efficient device pairing and communication are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-19
- Publication Date
- 2026-03-31
AI Technical Summary
In existing technologies, the Bluetooth pairing process between instruments and devices takes a long time and has a low success rate, requiring manual intervention to wake up the communication module.
A Bluetooth broadcast-based communication method is adopted. After receiving the broadcast data from the sub-device, the master device modifies the MAC address and sends a third MAC address to the sub-device. The sub-device executes the command control operation after determining that the identification information matches, thus optimizing the communication process between devices.
It improves the communication efficiency and success rate of the pairing process between devices, reduces manual intervention, and simplifies the communication process of instruments and equipment.
Smart Images

Figure CN116709270B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and in particular to a communication method and apparatus based on Bluetooth broadcasting. Background Technology
[0002] With the popularization of the Internet of Things (IoT), enterprises in the water supply industry and other related sectors are placing increasingly higher demands on instrument products. They require instruments to provide configuration communication modules to enable device updates, parameter settings, and firmware updates. However, considering the installation location of the instruments and the power consumption of the communication modules, Bluetooth modules are generally used. Currently, activating the instrument's communication module requires manual intervention, such as using infrared, touch, or magnets to wake it up. This results in long communication times and low success rates during pairing between instrument devices. This paper presents a Bluetooth broadcast-based communication method and device to solve the problems of long communication times and low success rates in the pairing process between instrument devices in existing technologies. Summary of the Invention
[0003] This invention provides a Bluetooth broadcast-based communication method and apparatus, which can improve communication efficiency and communication success rate between devices during the pairing process.
[0004] To address the aforementioned technical problems, the first aspect of this invention discloses a communication method based on Bluetooth broadcasting, the method being applied to an Internet of Things (IoT) system, the IoT system including a master device and a slave device, the method comprising:
[0005] When the master device receives broadcast data from the sub-device, the master device modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the sub-device, and obtains the third MAC address of the master device;
[0006] The master device sends the third MAC address to the sub-device to trigger the sub-device to determine whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device. When it is determined that the identification information in the third MAC address matches the compressed first MAC address of the sub-device, the sub-device executes an instruction control operation that matches the instruction information in the third MAC address.
[0007] As an optional implementation, in a first aspect of the invention, before the master device receives broadcast data sent from the sub-device, the method includes:
[0008] The master device detects whether it has received broadcast data from the slave device;
[0009] The broadcast data sent by the sub-device refers to the broadcast data sent by the sub-device based on the transmission interval determined by the sub-device based on its current remaining battery power.
[0010] As an optional implementation, in the first aspect of the present invention, the first MAC address, the second MAC address, and the second MAC address are all six bytes in length.
[0011] Before the master device modifies the second MAC address of the master device based on the first MAC address in the broadcast data sent by the sub-device to obtain the third MAC address of the master device, the method further includes:
[0012] The master device determines the distance between the sub-device and the master device based on the Bluetooth signal strength of the sub-device, and determines whether the current distance between the master device and the sub-device is less than or equal to a preset distance threshold.
[0013] The Bluetooth signal strength of the sub-device is inversely related to the distance between the sub-device and the master device.
[0014] The master device modifies its second MAC address based on the first MAC address in the broadcast data sent by the slave device to obtain the master device's third MAC address, including:
[0015] When it is determined that the distance between the current sub-device and the master device is less than or equal to the preset distance threshold, the master device compresses the first MAC address in the broadcast data sent by the sub-device according to a preset algorithm to obtain a four-byte MAC address, and modifies the four-byte MAC address to the high four bytes of the master device's second MAC address;
[0016] The master device modifies the two-byte control instruction to the lower two bytes of the master device's second MAC address;
[0017] The master device integrates the high four bytes and the low two bytes of the second MAC address to obtain the third MAC address of the master device;
[0018] The third MAC address includes: a high four-byte and a low two-byte. The high four bytes of the third MAC address are used to determine the identification information of the third MAC address, and the low two bytes of the third MAC address are used to determine the instruction information of the third MAC address.
[0019] As an optional implementation, in a first aspect of the present invention, the sub-device executes an instruction control operation matching the instruction information in the third MAC address, including:
[0020] The sub-device parses the lower two bytes of the third MAC address to obtain the instruction information in the third MAC address, and executes a control operation that matches the control instruction type according to the control instruction type in the instruction information;
[0021] The instruction information includes at least one control instruction number and at least one control instruction type, wherein the control instruction number and the control instruction type correspond one-to-one.
[0022] As an optional implementation, in a first aspect of the present invention, the step of performing a control operation matching the control instruction type according to the control instruction type in the instruction information includes:
[0023] The sub-device determines the type of control instruction in the instruction information;
[0024] When the sub-device determines that the control command type is read data, the sub-device sends broadcast data containing the sub-device's software version and serial number information to the master device;
[0025] When the master device receives broadcast data from the sub-device containing the software version and serial number information of the sub-device, the master device determines whether the software version and serial number information of the sub-device match the currently adapted software version and serial number information.
[0026] When it is determined that the software version and serial number information of the sub-device do not match the currently adapted software version and serial number information, the master device updates the third MAC address and sends the updated third MAC address to the sub-device. The updated third MAC address includes instruction information of the control instruction type being configuration data.
[0027] When the sub-device receives the updated third MAC address sent by the master device, the sub-device re-executes the instruction control operation that matches the instruction information in the updated third MAC address;
[0028] When the sub-device determines that the control command type is configuration data, the sub-device stops sending broadcast data and checks whether it has received configuration data sent from the master device within a preset duration threshold.
[0029] When the sub-device receives configuration data from the master device within a preset time threshold, the sub-device updates its software version and serial number information according to the configuration data.
[0030] When the sub-device does not receive configuration data from the master device within a preset time threshold, the sub-device stops receiving broadcast data and re-executes the operation of sending broadcast data according to the sending interval.
[0031] As an optional implementation, in the first aspect of the present invention, after determining whether the distance between the current sub-device and the master device is less than or equal to a preset distance threshold based on the Bluetooth signal strength of the sub-device, the method further includes:
[0032] When it is determined that the distance between at least one target sub-device and the main device is less than or equal to the preset distance threshold, the main device determines the distance between each target sub-device and the main device based on the Bluetooth signal strength of each target sub-device.
[0033] The master device sorts the distance values between all target sub-devices and the master device from smallest to largest, obtains the target sub-device with the smallest distance value, and modifies the master device's second MAC address based on the first MAC address in the broadcast data sent by the target sub-device with the smallest distance value, to obtain the master device's third MAC address. The master device then sends the third MAC address to the target sub-device with the smallest distance value to trigger the target sub-device to perform the operation of judging whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device.
[0034] A second aspect of this invention discloses a communication method based on Bluetooth broadcasting, the method being applied to a sub-device of an Internet of Things (IoT) system, the method comprising:
[0035] The sub-device sends broadcast data to the master device. When the master device receives the broadcast data sent by the sub-device, it modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the sub-device to obtain the third MAC address of the master device.
[0036] When the sub-device receives the third MAC address sent from the master device, the sub-device determines whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device.
[0037] When it is determined that the identification information in the third MAC address matches the compressed first MAC address of the sub-device, the sub-device executes an instruction control operation that matches the instruction information in the third MAC address.
[0038] A third aspect of the present invention discloses a communication device based on Bluetooth broadcasting, the device being applied to a master device in an Internet of Things (IoT) system, the device comprising:
[0039] The modification module is used to modify the second MAC address of the master device according to the first MAC address in the broadcast data sent by the sub-device when the master device receives broadcast data from the sub-device, so as to obtain the third MAC address of the master device;
[0040] The first sending module is used to send the third MAC address modified by the modification module to the sub-device, so as to trigger the sub-device to determine whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device. When it is determined that the identification information in the third MAC address matches the compressed first MAC address of the sub-device, the sub-device executes the instruction control operation that matches the instruction information according to the instruction information in the third MAC address.
[0041] As an optional implementation, in a third aspect of the invention, before the master device receives broadcast data sent from the sub-device, the apparatus includes:
[0042] The detection module is used to detect whether broadcast data sent from the sub-device has been received;
[0043] The broadcast data sent by the sub-device refers to the broadcast data sent by the sub-device based on the transmission interval determined by the sub-device based on its current remaining battery power.
[0044] As an optional implementation, in a third aspect of the present invention, the first MAC address, the second MAC address, and the second MAC address are all six bytes in length.
[0045] Before the modification module modifies the second MAC address of the master device based on the first MAC address in the broadcast data sent by the sub-device to obtain the third MAC address of the master device, the device further includes:
[0046] A determination module is used by the master device to determine the distance between the sub-device and the master device based on the Bluetooth signal strength of the sub-device;
[0047] The first judgment module is used to determine whether the distance value between the current master device and the sub-device determined by the determination module is less than or equal to a preset distance threshold.
[0048] The Bluetooth signal strength of the sub-device is inversely related to the distance between the sub-device and the master device.
[0049] The modification module modifies the second MAC address of the master device based on the first MAC address in the broadcast data sent by the sub-device, and obtains the third MAC address of the master device in the following specific way:
[0050] When the first judgment module determines that the distance between the current sub-device and the master device is less than or equal to the preset distance threshold, it compresses the first MAC address in the broadcast data sent by the sub-device according to the preset algorithm to obtain a four-byte MAC address, and modifies the four-byte MAC address to the high four bytes of the second MAC address of the master device.
[0051] Modify the two-byte control instruction to the lower two bytes of the second MAC address of the master device;
[0052] The third MAC address of the master device is obtained by combining the high four bytes of the second MAC address with the low two bytes of the second MAC address;
[0053] The third MAC address includes: a high four-byte and a low two-byte. The high four bytes of the third MAC address are used to determine the identification information of the third MAC address, and the low two bytes of the third MAC address are used to determine the instruction information of the third MAC address.
[0054] As an optional implementation, in a third aspect of the present invention, the specific manner in which the sub-device executes an instruction control operation matching the instruction information in the third MAC address is as follows:
[0055] The sub-device parses the lower two bytes of the third MAC address to obtain the instruction information in the third MAC address, and executes a control operation that matches the control instruction type according to the control instruction type in the instruction information;
[0056] The instruction information includes at least one control instruction number and at least one control instruction type, wherein the control instruction number and the control instruction type correspond one-to-one.
[0057] As an optional implementation, in a third aspect of the present invention, the specific manner in which the control operation matching the control instruction type is executed according to the control instruction type in the instruction information is as follows:
[0058] The sub-device determines the type of control instruction in the instruction information;
[0059] When the sub-device determines that the control command type is read data, the sub-device sends broadcast data containing the sub-device's software version and serial number information to the master device;
[0060] When the master device receives broadcast data from the sub-device containing the software version and serial number information of the sub-device, the master device determines whether the software version and serial number information of the sub-device match the currently adapted software version and serial number information.
[0061] When it is determined that the software version and serial number information of the sub-device do not match the currently adapted software version and serial number information, the master device updates the third MAC address and sends the updated third MAC address to the sub-device. The updated third MAC address includes instruction information of the control instruction type being configuration data.
[0062] When the sub-device receives the updated third MAC address sent by the master device, the sub-device re-executes the instruction control operation that matches the instruction information in the updated third MAC address;
[0063] When the sub-device determines that the control command type is configuration data, the sub-device stops sending broadcast data and checks whether it has received configuration data sent from the master device within a preset duration threshold.
[0064] When the sub-device receives configuration data from the master device within a preset time threshold, the sub-device updates its software version and serial number information according to the configuration data.
[0065] When the sub-device does not receive configuration data from the master device within a preset time threshold, the sub-device stops receiving broadcast data and re-executes the operation of sending broadcast data according to the sending interval.
[0066] As an optional implementation, in a third aspect of the invention, after the first determining module determines whether the distance between the current sub-device and the master device is less than or equal to a preset distance threshold based on the Bluetooth signal strength of the sub-device, the device further includes:
[0067] The determining module is further configured to determine the distance between each target sub-device and the main device based on the Bluetooth signal strength of each target sub-device when the first determining module determines that the distance between at least one target sub-device and the main device is less than or equal to the preset distance threshold.
[0068] The sorting module is used to sort all the distance values between the target sub-devices and the main device identified by the determining module from small to large, and obtain the target sub-device with the smallest distance value.
[0069] The modification module is further configured to modify the second MAC address of the master device based on the first MAC address in the broadcast data sent by the target sub-device with the smallest distance value obtained by the sorting module, so as to obtain the third MAC address of the master device.
[0070] The first sending module is further configured to send the third MAC address obtained by the sorting module to the target sub-device with the smallest distance value, so as to trigger the target sub-device to perform the operation of judging whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device.
[0071] A fourth aspect of the present invention discloses a communication device based on Bluetooth broadcasting, the device being applied to a sub-device of an Internet of Things (IoT) system, the device comprising:
[0072] The second sending module is used to send broadcast data to the master device. When the master device receives the broadcast data sent by the second sending module, it causes the master device to modify the second MAC address of the master device according to the first MAC address in the broadcast data sent by the second sending module, so as to obtain the third MAC address of the master device.
[0073] The second judgment module is used to determine whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device when the third MAC address sent from the master device is received.
[0074] The execution module is used to execute an instruction control operation that matches the instruction information in the third MAC address when the second judgment module determines that the identification information in the third MAC address matches the compressed first MAC address of the sub-device.
[0075] The fifth aspect of this invention discloses another communication device based on Bluetooth broadcasting, the device comprising:
[0076] Memory containing executable program code;
[0077] A processor coupled to the memory;
[0078] The processor calls the executable program code stored in the memory to execute the Bluetooth broadcast-based communication method disclosed in the first and second aspects of the present invention.
[0079] The sixth aspect of the present invention discloses a computer storage medium storing computer instructions, which, when invoked, are used to execute the Bluetooth broadcast-based communication method disclosed in the first and second aspects of the present invention.
[0080] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0081] A Bluetooth broadcast-based communication method and apparatus are provided. When a master device receives broadcast data from a slave device, it modifies the master device's second MAC address based on the first MAC address in the broadcast data to obtain the master device's third MAC address. Then, it executes a command control operation matching the command information in the third MAC address. This includes compressing the MAC addresses of the master and slave devices for communication, which improves communication efficiency during device pairing; and triggering the slave device to determine whether the identification information in the third MAC address matches the compressed first MAC address of the slave device. When the identification information in the third MAC address matches the compressed first MAC address of the slave device, the slave device executes a command control operation matching the command information in the third MAC address. This allows for verification based on the compressed MAC addresses of the master device and each slave device to complete the control operation for each slave device, thereby improving communication efficiency and communication success rate during device pairing. Attached Figure Description
[0082] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0083] Figure 1 This is a flowchart illustrating a Bluetooth broadcast-based communication method disclosed in an embodiment of the present invention.
[0084] Figure 2 This is a flowchart illustrating another Bluetooth broadcast-based communication method disclosed in an embodiment of the present invention;
[0085] Figure 3This is a flowchart illustrating another Bluetooth broadcast-based communication method disclosed in an embodiment of the present invention;
[0086] Figure 4 This is a schematic diagram of the structure of a Bluetooth broadcast-based communication device disclosed in an embodiment of the present invention;
[0087] Figure 5 This is a schematic diagram of another Bluetooth broadcast-based communication device disclosed in an embodiment of the present invention;
[0088] Figure 6 This is a schematic diagram of the structure of another Bluetooth broadcast-based communication device disclosed in an embodiment of the present invention;
[0089] Figure 7 This is a schematic diagram of the structure of another Bluetooth broadcast-based communication device disclosed in an embodiment of the present invention. Detailed Implementation
[0090] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0091] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or end that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or ends.
[0092] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0093] This invention discloses a communication method and apparatus based on Bluetooth broadcasting. The method includes: when a master device receives broadcast data from a slave device, the master device modifies its second MAC address according to a first MAC address in the broadcast data sent by the slave device to obtain a third MAC address, and sends the third MAC address to the slave device to trigger the slave device to determine whether the identification information in the third MAC address matches the compressed first MAC address of the slave device. When it is determined that the identification information in the third MAC address matches the compressed first MAC address of the slave device, the slave device executes a command control operation matching the command information according to the command information in the third MAC address. Implementing this invention enables communication between the master device and slave devices through compressed MAC addresses, and completes control operations on each slave device by verifying the compressed MAC addresses of the master device and each slave device. This is beneficial for improving communication efficiency and success rate in the pairing process between devices. Detailed descriptions follow.
[0094] Example 1
[0095] Please see Figure 1 , Figure 1 This is a flowchart illustrating a communication method based on Bluetooth broadcasting disclosed in an embodiment of the present invention. Wherein, Figure 1 The described Bluetooth broadcast-based communication method can be applied to Bluetooth broadcast-based communication devices, and these devices can be applied to smart devices in the Internet of Things (IoT) (e.g., smart grids, smart water networks, smart gas networks, express logistics networks, etc.). This method can be applied to the main device of the IoT, which can be a mobile terminal device (e.g., mobile phone, tablet computer, wireless update device, etc.), or to the sub-devices of the IoT (e.g., smart water meters, smart electricity meters, smart gas meters, etc.). This invention does not limit the scope of the application. Figure 1 As shown, the Bluetooth broadcast-based communication method may include the following operations:
[0096] 101. When the master device receives broadcast data from the slave device, the master device modifies the master device's second MAC address based on the first MAC address in the broadcast data sent by the slave device to obtain the master device's third MAC address.
[0097] In this embodiment of the invention, optionally, the MAC address is represented as a Media Access Control Address, or it can be represented as an Ethernet Address or a Physical Address, consisting of six bytes of hexadecimal numbers (e.g., "00-16-EA-AE-3C-40", where each two hexadecimal numbers constitute one byte), used to determine the location of the network device. Broadcast data sent by the sub-device can be transmitted by the Bluetooth communication module on the sub-device. The Bluetooth communication module can use Bluetooth Low Energy, and when multiple sub-devices exist, the Bluetooth communication modules of each sub-device can form a Bluetooth Mesh network; this embodiment of the invention does not impose any limitations.
[0098] In this embodiment of the invention, optionally, the master device modifies the master device's second MAC address based on the first MAC address in the broadcast data sent by the slave device to obtain the master device's third MAC address, which may include:
[0099] The master device compresses the first MAC address in the broadcast data sent by the sub-device according to a preset algorithm to obtain a four-byte MAC address, and modifies the four-byte MAC address into the high four bytes of the master device's second MAC address;
[0100] The master device modifies the two-byte control command into the lower two bytes of the master device's second MAC address;
[0101] The master device integrates the high four bytes and the low two bytes of the second MAC address to obtain the master device's third MAC address;
[0102] The first MAC address, the second MAC address, and the third MAC address are all six bytes long. The third MAC address may include four high bytes and two low bytes. Further, the two low bytes of the third MAC address can be the first two bytes from left to right (e.g., "00-16" in "00-16-EA-AE-3C-40"), and the four high bytes of the third MAC address can be the last four bytes from left to right (e.g., "EA-AE-3C-40" in "00-16-EA-AE-3C-40"). The four high bytes of the third MAC address are used to determine the identification information of the third MAC address, and the two low bytes are used to determine the instruction information of the third MAC address.
[0103] As can be seen, when the master device receives broadcast data from the slave device, it modifies the first MAC address in the broadcast data to obtain the master device's third MAC address, so that the master device and the slave device can communicate with each other through the processed MAC address. This helps to improve the communication efficiency and the success rate of communication between devices during the pairing process. Moreover, the richer and more detailed the information stored in the MAC address, the better it is for improving the success rate of communication between devices.
[0104] 102. The master device sends a third MAC address to the slave device to trigger the slave device to determine whether the identification information in the third MAC address matches the compressed first MAC address of the slave device. When it is determined that the identification information in the third MAC address matches the compressed first MAC address of the slave device, the slave device executes the instruction control operation that matches the instruction information according to the instruction information in the third MAC address.
[0105] In this embodiment of the invention, optionally, the identification information in the third MAC address can be represented as a connection request frame with the high four bytes, and the compressed first MAC address of the sub-device can be represented as the first MAC address in the broadcast data compressed according to a preset algorithm, with the compressed first MAC address having a byte length of four bytes. The preset algorithm can be a MAC address compression algorithm (such as an address mapping algorithm using the MD5 algorithm).
[0106] In this embodiment of the invention, optionally, the sub-device executes an instruction control operation matching the instruction information in the third MAC address, which may include:
[0107] The sub-device parses the lower two bytes of the third MAC address to obtain the instruction information in the third MAC address, and executes a control operation that matches the control instruction type according to the control instruction type in the instruction information;
[0108] The instruction information includes at least one control instruction number and at least one control instruction type. There is a one-to-one correspondence between the control instruction number and the control instruction type. For example, when the lower two bytes of the third MAC address are "01-08", the corresponding control instruction number is "01" and the corresponding control instruction type is "0x01 0x08". By integrating the compressed four-byte first MAC address with the two-byte control instruction into the master device's third MAC address, the instruction information of this third MAC address includes the instruction number and instruction control type. This allows for communication between the master device and the slave device, and for controlling the slave device. This improves communication efficiency and success rate during device pairing. Furthermore, matching the master device and slave device using the third MAC address reduces matching errors, thus further improving the success rate of device communication.
[0109] In this embodiment of the invention, optionally, executing a control operation matching the control instruction type according to the control instruction type in the instruction information may include:
[0110] The sub-device determines the type of control command in the instruction information.
[0111] When the sub-device determines that the control command type is read data (for example, when the control command type code is 0x010x08, the control command type is read data), the sub-device sends broadcast data containing the sub-device's software version and serial number information to the master device.
[0112] When the master device receives broadcast data from the slave device containing the slave device's software version and serial number information, the master device determines whether the slave device's software version and serial number information match the currently adapted software version and serial number information.
[0113] When it is determined that the software version and serial number information of the sub-device do not match the currently adapted software version and serial number information, the master device updates the third MAC address by modifying the instruction information of the third MAC address, and sends the updated third MAC address to the sub-device. The updated third MAC address includes instruction information of the control instruction type of configuration data.
[0114] When the sub-device receives the updated third MAC address from the master device, it re-executes the instruction control operation that matches the instruction information in the updated third MAC address.
[0115] When the sub-device determines that the control command type is configuration data (for example, when the code of the control command type is 0x020x08, its control command type is configuration data), the sub-device stops sending broadcast data and checks whether it receives configuration data sent from the master device within a preset duration threshold (for example, the duration threshold is 50ms).
[0116] When the sub-device receives configuration data from the master device within a preset time threshold, it updates the software version and serial number information of the sub-device according to the configuration data.
[0117] When a sub-device does not receive configuration data from the master device within a preset time threshold, it stops receiving broadcast data and re-executes the operation of sending broadcast data according to the sending interval. This allows the sub-device to determine different control command types in the instruction information and perform different control operations based on these command types, improving the communication control efficiency between the master device and the sub-device. When the control command type is determined to be reading data, the master device can also determine whether the software version and serial number information of the sub-device match to decide whether to upgrade the firmware. It then communicates with the sub-device using the updated control command type to perform the update operation, improving the update efficiency and success rate. Furthermore, when the sub-device determines whether it has received data from the master device within a preset time, it can intelligently switch between broadcast and receive modes based on the data sent by the master device. This helps reduce the power consumption of each sub-device and decreases maintenance costs, thereby improving the communication efficiency and success rate between the master and sub-devices.
[0118] In an optional embodiment, before the master device receives broadcast data from the sub-device, the method may further include the following operations:
[0119] The master device detects whether it has received broadcast data from the slave device;
[0120] The broadcast data sent by the sub-device refers to the broadcast data sent by the sub-device at intervals determined by the sub-device based on the current remaining power of the sub-device.
[0121] In this optional embodiment, the broadcast data transmitted by the sub-device based on the transmission interval determined by the sub-device's current remaining battery power can be represented as follows:
[0122] The sub-device determines whether its current remaining battery power is lower than a preset battery power threshold. When it determines that the current remaining battery power is lower than the preset battery power threshold, it adjusts the interval for sending broadcast data according to a preset transmission interval corresponding to the preset battery power threshold. For example, when the current remaining battery power of the sub-device is lower than 50% of the total battery power, the transmission interval of the sub-device is increased from sending broadcast data once every 5 seconds to sending broadcast data once every 10 seconds. This embodiment does not impose a limitation.
[0123] As can be seen, this optional embodiment can adjust the transmission interval of broadcast data according to the current remaining power of the sub-device, which is conducive to further reducing the power consumption of each sub-device, effectively extending the power life of the sub-device, reducing the maintenance cost of the sub-device, and thus improving the communication efficiency and communication success rate between the master device and the sub-device.
[0124] In another optional embodiment, before the master device modifies the master device's second MAC address based on the first MAC address in the broadcast data sent by the sub-device to obtain the master device's third MAC address, the method further includes the following operations:
[0125] The master device determines the distance between the master device and the slave device based on the Bluetooth signal strength of the slave device, and determines whether the current distance between the master device and the slave device is less than or equal to a preset distance threshold.
[0126] When it is determined that the distance between the current sub-device and the master device is less than or equal to a preset distance threshold, the operation of modifying the master device's second MAC address based on the first MAC address in the broadcast data sent by the sub-device is performed to obtain the master device's third MAC address.
[0127] The Bluetooth signal strength of the sub-device is inversely related to the distance between the sub-device and the master device. That is, the stronger the Bluetooth signal strength of the sub-device, the smaller the distance between the sub-device and the master device. For example, when the Bluetooth signal strength (RSSI value) of the sub-device is -40dBm, the distance between the sub-device and the master device is 30cm.
[0128] As can be seen, this optional embodiment can perform communication control operations on the sub-device when it is determined that the distance between the sub-device and the master device is less than a preset distance threshold, so as to reduce the power consumption of each sub-device outside the necessary communication range, effectively extend the power life of the sub-device, reduce the maintenance cost of the sub-device, and thus help improve the communication efficiency and communication success rate between the master device and the sub-device.
[0129] It is evident that implementation Figure 1The described method enables a master device to modify its second MAC address based on the first MAC address in the broadcast data sent by the sub-device when the master device receives broadcast data from the sub-device, thereby obtaining a third MAC address and sending the third MAC address to the sub-device. This allows for compressed communication between the master and sub-device MAC addresses, improving communication efficiency during device pairing. Furthermore, it triggers the sub-device to determine if the identification information in the third MAC address matches the sub-device's compressed first MAC address. When a match is found, the sub-device executes a control operation matching the instruction information in the third MAC address. This verification process, based on the compressed MAC addresses of the master and each sub-device, completes the control operation for each sub-device, further enhancing communication efficiency and success rate during device pairing.
[0130] Example 2
[0131] Please see Figure 2 , Figure 2 This is a flowchart illustrating another Bluetooth broadcast-based communication method disclosed in an embodiment of the present invention. Wherein, Figure 2 The described Bluetooth broadcast-based communication method can be applied to Bluetooth broadcast-based communication devices, and these devices can be applied to smart devices in the Internet of Things (IoT) (e.g., smart grids, smart water networks, smart gas networks, express logistics networks). This method can be applied to the master device of the IoT, which can be a mobile terminal device (e.g., mobile phone, tablet computer, wireless update device, etc.), but this embodiment of the invention is not limited thereto. Figure 2 As shown, the Bluetooth broadcast-based communication method may include the following operations:
[0132] 201. The master device checks whether it has received broadcast data sent from the slave device.
[0133] In this embodiment of the invention, the broadcast data sent by the sub-device includes at least the sub-device's current remaining battery power information and Bluetooth signal strength information.
[0134] 202. When the master device receives broadcast data from at least one sub-device, the master device determines the distance value between the master device and each sub-device based on the Bluetooth signal strength of the sub-device, and determines whether the current distance value between the master device and each sub-device is less than or equal to a preset distance threshold. When it is determined that there is at least one target sub-device whose distance value between the master device and the master device is less than or equal to the preset distance threshold, step 203 can be executed.
[0135] In this embodiment of the invention, when it is determined that the distance between the sub-device and the main device is greater than a preset distance threshold, step 201 is executed again.
[0136] 203. The master device determines the distance between each target sub-device and the master device based on the Bluetooth signal strength of each target sub-device.
[0137] 204. The master device sorts the distance values between all target sub-devices and the master device from smallest to largest, obtains the target sub-device with the smallest distance value, and modifies the master device's second MAC address based on the first MAC address in the broadcast data sent by the target sub-device with the smallest distance value, thus obtaining the master device's third MAC address.
[0138] 205. The master device sends the third MAC address to the target sub-device with the smallest distance value to trigger the target sub-device to determine whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device. When it is determined that the identification information in the third MAC address matches the compressed first MAC address of the sub-device, the sub-device executes the instruction control operation that matches the instruction information according to the instruction information in the third MAC address.
[0139] In this embodiment of the invention, after performing step 201, the method may further include the following operations:
[0140] When the master device receives broadcast data from the slave device, it determines whether the current remaining power of the slave device is less than the preset power threshold.
[0141] When it is determined that at least one target sub-device has a current remaining power of less than a preset power threshold, the master device sorts all the target sub-devices according to their current remaining power in ascending order, and obtains the target sub-device with the smallest current remaining power. The master device first modifies the second MAC address of the master device based on the first MAC address in the broadcast data sent by the target sub-device with the smallest current remaining power, and obtains the third MAC address of the master device. The master device then prompts the user with voice and / or text to replace the power supply of the sub-device or to charge the power supply.
[0142] Voice prompts can be implemented through the main device's voice module, while text prompts can be implemented through the main device's display module.
[0143] The master device sends the third MAC address to the target sub-device with the smallest distance value to trigger the target sub-device to determine whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device. When it is determined that the identification information in the third MAC address matches the compressed first MAC address of the sub-device, the sub-device executes the instruction control operation that matches the instruction information in the third MAC address.
[0144] In this embodiment of the invention, it should be noted that for the relevant descriptions of steps 201-202, please refer to the detailed description of step 101 and optional embodiments in Embodiment 1. This embodiment of the invention will not repeat the descriptions.
[0145] As can be seen, the embodiments of the present invention can also determine whether the distance between the sub-device and the main device is less than or equal to a preset distance threshold based on the Bluetooth signal strength of the sub-device when the main device receives broadcast data from the sub-device. When there is at least one target sub-device whose distance from the main device is less than the preset distance threshold, the communication control operation is preferentially performed on the target sub-device with the smallest distance value in order to optimize the way the main device sends data, thereby improving the communication efficiency and communication success rate between the main device and the sub-device.
[0146] It is evident that implementation Figure 2 The described method enables the master device to determine whether the distance between the master device and the sub-device is less than or equal to a preset distance threshold based on the Bluetooth signal strength of the sub-device when the master device receives broadcast data from the sub-device. When at least one target sub-device is less than the preset distance threshold, communication control operations are prioritized for the target sub-device with the smallest distance value to optimize the way the master device sends data, thereby improving the communication efficiency and success rate between the master device and the sub-device. Furthermore, when at least one target sub-device has a remaining battery level less than a preset battery threshold, communication is prioritized for the target sub-device with the smallest remaining battery level, and the user is notified. This further reduces the power consumption of each sub-device, effectively extends the power life of the sub-devices, reduces the maintenance costs of the sub-devices, and thus improves the communication efficiency and success rate between the master device and the sub-device.
[0147] Example 3
[0148] Please see Figure 3 , Figure 3 This is a flowchart illustrating another communication method based on Bluetooth broadcasting disclosed in an embodiment of the present invention. Wherein, Figure 3The described Bluetooth broadcast-based communication method can be applied to Bluetooth broadcast-based communication devices, and these devices can be applied to smart devices in the Internet of Things (IoT) (e.g., smart grids, smart water networks, smart gas networks, express logistics networks, etc.). Specifically, this method can be applied to sub-devices of the IoT (e.g., smart water meters, smart electricity meters, smart gas meters, etc.), and this embodiment of the invention is not limited thereto. Figure 3 As shown, the Bluetooth broadcast-based communication method may include the following operations:
[0149] 301. The sub-device sends broadcast data to the master device. When the master device receives the broadcast data sent by the sub-device, it causes the master device to modify its second MAC address based on the first MAC address in the broadcast data sent by the sub-device, thereby obtaining the master device's third MAC address.
[0150] 302. When the sub-device receives a third MAC address sent from the master device, the sub-device determines whether the identification information in the third MAC address matches the sub-device's compressed first MAC address. When it is determined that the identification information in the third MAC address matches the sub-device's compressed first MAC address, step 303 can be executed.
[0151] In this embodiment of the invention, when it is determined that the identification information in the third MAC address does not match the compressed first MAC address of the sub-device, step 301 is re-executed.
[0152] 303. The sub-device executes instruction control operations that match the instruction information in the third MAC address.
[0153] It is evident that implementation Figure 3 The described method can send broadcast data. When the master device receives broadcast data from the slave device, it modifies its second MAC address based on the first MAC address in the broadcast data to obtain a third MAC address. This allows for compression of the MAC addresses of the master and slave devices, improving communication efficiency during device pairing. Furthermore, the method can determine whether the identification information in the third MAC address matches the compressed first MAC address of the slave device. If a match is found, the method executes a control operation matching the instruction information in the third MAC address. This verification is performed between the compressed MAC addresses of the master and each slave device to control each slave device, further improving communication efficiency and success rate during device pairing.
[0154] Example 4
[0155] Please see Figure 4 , Figure 4 This is a schematic diagram of a communication device based on Bluetooth broadcasting disclosed in an embodiment of the present invention. Wherein, Figure 4 The described Bluetooth broadcast-based communication device can execute the aforementioned Bluetooth broadcast-based communication method, and this device can be applied to smart devices in the Internet of Things (e.g., smart grids, smart water networks, smart gas networks, express logistics networks, etc.). Specifically, this device can be applied to the master device of the Internet of Things, which can be a mobile terminal device (e.g., mobile phone, tablet computer, wireless update device, etc.), but this embodiment of the invention is not limited thereto. Figure 4 As shown, the device may include: a modification module 401 and a first sending module 402, wherein:
[0156] The modification module 401 is used to modify the second MAC address of the master device according to the first MAC address in the broadcast data sent by the sub-device when the master device receives broadcast data from the sub-device, so as to obtain the third MAC address of the master device.
[0157] The first sending module 402 is used to send the third MAC address modified by the modification module 401 to the sub-device to trigger the sub-device to determine whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device. When it is determined that the identification information in the third MAC address matches the compressed first MAC address of the sub-device, the sub-device executes the instruction control operation that matches the instruction information according to the instruction information in the third MAC address.
[0158] It is evident that implementation Figure 4 The described Bluetooth broadcast-based communication device, upon receiving broadcast data from a sub-device, modifies the master device's second MAC address based on the first MAC address in the broadcast data to obtain the master device's third MAC address, and sends the third MAC address to the sub-device. This compresses the MAC addresses of the master and sub-devices for communication, improving communication efficiency during device pairing. Furthermore, it triggers the sub-device to determine if the identification information in the third MAC address matches the sub-device's compressed first MAC address. When a match is found, the sub-device executes a control operation matching the instruction information in the third MAC address. This verification process, based on the compressed MAC addresses of the master and each sub-device, completes the control operation for each sub-device, further improving communication efficiency and success rate during device pairing.
[0159] In an optional embodiment, such as Figure 5As shown, before the master device receives broadcast data sent from the slave device, the device further includes:
[0160] The detection module 403 is used to detect whether broadcast data sent from the sub-device has been received.
[0161] The broadcast data sent by the sub-device refers to the broadcast data sent by the sub-device at intervals determined by the sub-device based on the current remaining power of the sub-device.
[0162] It is evident that implementation Figure 5 The described Bluetooth broadcast-based communication device can adjust the transmission interval of broadcast data according to the remaining power of the sub-device, which helps to further reduce the power consumption of each sub-device, effectively extend the power life of the sub-device, reduce the maintenance cost of the sub-device, and thus improve the communication efficiency and communication success rate between the master device and the sub-device.
[0163] In another alternative embodiment, the first MAC address, the second MAC address, and the second MAC address are all six bytes in length.
[0164] And, such as Figure 5 As shown, before the modification module 401 modifies the second MAC address of the master device based on the first MAC address in the broadcast data sent by the sub-device to obtain the third MAC address of the master device, the device further includes:
[0165] The determination module 404 is used by the master device to determine the distance between the sub-device and the master device based on the Bluetooth signal strength of the sub-device.
[0166] The first judgment module 405 is used to determine whether the distance value between the current master device and the slave device determined by the determination module 404 is less than or equal to a preset distance threshold.
[0167] The Bluetooth signal strength of the sub-device is inversely related to the distance between the current sub-device and the master device.
[0168] The modification module 401 modifies the master device's second MAC address based on the first MAC address in the broadcast data sent by the sub-device, and obtains the master device's third MAC address in the following specific way:
[0169] When the first judgment module 405 determines that the distance between the current sub-device and the master device is less than or equal to the preset distance threshold, it compresses the first MAC address in the broadcast data sent by the sub-device according to the preset algorithm to obtain a four-byte MAC address, and modifies the four-byte MAC address into the high four bytes of the second MAC address of the master device.
[0170] Modify the two-byte control instruction into the lower two bytes of the master device's second MAC address.
[0171] The high four bytes of the second MAC address are combined with the low two bytes of the second MAC address to obtain the third MAC address of the master device.
[0172] The third MAC address consists of four high bytes and two low bytes. The four high bytes of the third MAC address are used to determine the identification information of the third MAC address, and the two low bytes of the third MAC address are used to determine the instruction information of the third MAC address.
[0173] It is evident that implementation Figure 5 The described Bluetooth broadcast-based communication device can perform communication control operations on the sub-device when it determines that the distance between the sub-device and the master device is less than a preset distance threshold. This reduces the power consumption of each sub-device outside the necessary communication range, effectively extends the power life of the sub-device, and reduces the maintenance cost of the sub-device. Furthermore, it can integrate the compressed four-byte first MAC address with the two-byte control command into the master device's third MAC address. This allows the master device to communicate with the sub-device and control the sub-device through the command information, thereby improving communication efficiency and the success rate of communication between devices during the pairing process.
[0174] In yet another optional embodiment, the specific method by which the sub-device executes an instruction control operation matching the instruction information in the third MAC address is as follows:
[0175] The sub-device parses the lower two bytes of the third MAC address to obtain the instruction information in the third MAC address, and executes a control operation that matches the control instruction type according to the control instruction type in the instruction information;
[0176] The instruction information includes: at least one control instruction number and at least one control instruction type, with a one-to-one correspondence between the control instruction number and the control instruction type.
[0177] It is evident that implementation Figure 5 The described Bluetooth broadcast-based communication device can pair master and slave devices via a third MAC address. This third MAC address includes instruction information such as an instruction number and instruction control type, enabling communication between the master and slave devices and control of the slave device. This reduces the occurrence of pairing errors and improves communication efficiency and success rate during device pairing.
[0178] In yet another optional embodiment, the specific method for executing a control operation matching the control instruction type based on the control instruction type in the instruction information is as follows:
[0179] The sub-device determines the type of control command in the instruction information;
[0180] When the sub-device determines that the control command type is read data, the sub-device sends broadcast data containing the sub-device's software version and serial number information to the master device.
[0181] When the master device receives broadcast data from the slave device containing the slave device's software version and serial number information, the master device determines whether the slave device's software version and serial number information match the currently adapted software version and serial number information.
[0182] When it is determined that the software version and serial number information of the sub-device do not match the currently adapted software version and serial number information, the master device updates the third MAC address and sends the updated third MAC address to the sub-device. The updated third MAC address includes instruction information of the control instruction type configuration data.
[0183] When the sub-device receives the updated third MAC address from the master device, it re-executes the instruction control operation that matches the instruction information in the updated third MAC address.
[0184] When the sub-device determines that the control command type is configuration data, the sub-device stops sending broadcast data and checks whether it has received configuration data from the master device within a preset duration threshold.
[0185] When the sub-device receives configuration data from the master device within a preset time threshold, it updates the software version and serial number information of the sub-device according to the configuration data.
[0186] When a sub-device does not receive configuration data from the master device within a preset time threshold, the sub-device stops receiving broadcast data and re-executes the operation of sending broadcast data according to the sending interval.
[0187] It is evident that implementation Figure 5The described Bluetooth broadcast-based communication device can determine different control command types in the instruction information through the sub-device and perform different control operations according to the control command type, which helps improve the communication control efficiency of the master device to the sub-device. When the control command type is determined to be reading data, the master device can also determine whether the software version and serial number information of the sub-device match to decide whether to upgrade the firmware of the sub-device, and communicate with the sub-device through the updated control command type to update the sub-device, which helps improve the update efficiency and success rate of the master device to the sub-device. Furthermore, when the sub-device determines whether it has received data sent by the master device within a preset time, it can intelligently switch between broadcast and receive modes according to the data sent by the master device, which helps reduce the power consumption of each sub-device and reduce the maintenance cost of the sub-device, thereby improving the communication efficiency and communication success rate between the master device and the sub-device.
[0188] In yet another alternative embodiment, such as Figure 5 As shown, after the first judgment module 405 determines whether the distance between the current sub-device and the master device is less than or equal to a preset distance threshold based on the Bluetooth signal strength of the sub-device, the device further includes:
[0189] The determining module 404 is further configured to determine the distance between each target sub-device and the main device based on the Bluetooth signal strength of each target sub-device when the first determining module 405 determines that the distance between at least one target sub-device and the main device is less than or equal to a preset distance threshold.
[0190] The sorting module 406 is used to sort all the distance values between the target sub-devices and the master device identified by the determining module 404 from smallest to largest, and obtain the target sub-device with the smallest distance value.
[0191] Modification module 401 is also used to modify the second MAC address of the master device based on the first MAC address in the broadcast data sent by the target sub-device with the smallest distance value obtained by sorting module 406, so as to obtain the third MAC address of the master device.
[0192] The first sending module 402 is also used to send the third MAC address modified by the modification module 401 to the target sub-device with the smallest distance value, so as to trigger the target sub-device to perform an operation to determine whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device.
[0193] It is evident that implementation Figure 5The described Bluetooth broadcast-based communication device can perform communication control operations on the sub-device when it determines that the distance between the sub-device and the master device is less than a preset distance threshold. This reduces the power consumption of each sub-device outside the necessary communication range, effectively extends the power life of the sub-device, reduces the maintenance cost of the sub-device, and thus helps to improve the communication efficiency and communication success rate between the master device and the sub-device.
[0194] Example 5
[0195] Please see Figure 6 , Figure 6 This is a schematic diagram of another Bluetooth broadcast-based communication device disclosed in an embodiment of the present invention. Figure 6 The described Bluetooth broadcast-based communication device can execute the aforementioned Bluetooth broadcast-based communication method, and this device can be applied to smart devices in the Internet of Things (e.g., smart grids, smart water networks, smart gas networks, express logistics networks, etc.). Specifically, this device can be applied to sub-devices of the Internet of Things (e.g., smart water meters, smart electricity meters, smart gas meters, etc.), and this embodiment of the invention does not limit its application. Figure 6 As shown, the device may include: a second sending module 501, a second judging module 502, and an execution module 503, wherein:
[0196] The second sending module 501 is used to send broadcast data to the master device. When the master device receives the broadcast data sent by the second sending module 501, it causes the master device to modify its second MAC address according to the first MAC address in the broadcast data sent by the second sending module 501, so as to obtain the third MAC address of the master device.
[0197] The second judgment module 502 is used to determine whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device when it receives the third MAC address modified and sent by the master device according to the second sending module 501.
[0198] The execution module 503 is used to execute an instruction control operation that matches the instruction information in the third MAC address when the second judgment module 502 determines that the identification information in the third MAC address matches the compressed first MAC address of the sub-device.
[0199] It is evident that implementation Figure 6The described apparatus is capable of transmitting broadcast data. When a master device receives broadcast data from a slave device, it modifies its second MAC address based on the first MAC address in the broadcast data to obtain a third MAC address. This allows for compression of the MAC addresses of the master and slave devices for communication, improving communication efficiency during device pairing. Furthermore, the apparatus can determine whether the identification information in the third MAC address matches the compressed first MAC address of the slave device. If a match is found, the apparatus executes a control operation matching the instruction information in the third MAC address. This allows for verification between the compressed MAC addresses of the master and each slave device to complete control operations on each slave device, thereby improving communication efficiency and communication success rate during device pairing.
[0200] Example 6
[0201] Please see Figure 7 , Figure 7 This is a schematic diagram of another Bluetooth broadcast-based communication device disclosed in an embodiment of the present invention. Figure 7 As shown, the Bluetooth broadcast-based communication device may include:
[0202] Memory 601 storing executable program code;
[0203] Processor 602 coupled to memory 601;
[0204] Furthermore, it may also include an input interface 603 and an output interface 604 coupled to the processor 602;
[0205] The processor 602 calls the executable program code stored in the memory 601 to execute the steps in the Bluetooth broadcast-based communication method described in Embodiment 1, Embodiment 2 or Embodiment 3 of the present invention.
[0206] Example 7
[0207] This invention discloses a computer storage medium storing computer instructions. When these computer instructions are invoked, they are used to execute the steps in the Bluetooth broadcast-based communication method described in Embodiment 1, Embodiment 2, or Embodiment 3 of this invention.
[0208] Example 8
[0209] This invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform the steps in the Bluetooth broadcast-based communication method described in Embodiment 1, Embodiment 2 or Embodiment 3.
[0210] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0211] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0212] Finally, it should be noted that the Bluetooth broadcast-based communication method and apparatus disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A Bluetooth broadcast based communication method, characterized in that, The method is applied to an Internet of Things system comprising a master device and a slave device, and comprises the following steps: When the master device receives broadcast data sent by the slave device, the master device modifies a second MAC address of the master device according to a first MAC address in the broadcast data sent by the slave device, to obtain a third MAC address of the master device; The master device sends the third MAC address to the slave device, to trigger the slave device to determine whether identification information in the third MAC address matches the compressed first MAC address of the slave device, and when it is determined that the identification information in the third MAC address matches the compressed first MAC address of the slave device, the slave device executes an instruction control operation matching the instruction information in the third MAC address according to the instruction information in the third MAC address; The first MAC address, the second MAC address and the third MAC address each have a byte length of six bits; Before the master device modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the slave device, to obtain the third MAC address of the master device, the method further comprises the following steps: The master device determines a distance value between the slave device and the master device according to a Bluetooth signal strength of the slave device, and determines whether the distance value between the slave device and the master device is less than or equal to a preset distance threshold value; The Bluetooth signal strength of the slave device and the distance value between the slave device and the master device are in an inverse relationship; The master device modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the slave device, to obtain the third MAC address of the master device, and comprises the following steps: When it is determined that the distance value between the slave device and the master device is less than or equal to the preset distance threshold value, the master device compresses the first MAC address in the broadcast data sent by the slave device according to a preset algorithm, to obtain a MAC address with a byte length of four bits, and modifies the MAC address with the byte length of four bits as the high four bytes in the second MAC address of the master device; The master device modifies a control instruction with a byte length of two bits as the low two bytes in the second MAC address of the master device; The master device integrates the high four bytes in the second MAC address and the low two bytes in the second MAC address, to obtain the third MAC address of the master device; The third MAC address comprises high four bytes and low two bytes, the high four bytes in the third MAC address are used to determine identification information of the third MAC address, and the low two bytes in the third MAC address are used to determine instruction information of the third MAC address.
2. The Bluetooth broadcast based communication method of claim 1, wherein, Before the master device receives the broadcast data sent by the slave device, the method comprises the following steps: The master device detects whether the broadcast data sent by the slave device is received; The broadcast data sent by the sub-device is broadcast data sent by the sub-device according to a sending interval time length determined by the sub-device according to a current residual power of the sub-device.
3. The Bluetooth broadcast based communication method of claim 2, wherein, The sub-device executes an instruction control operation matched with the instruction information in the third MAC address according to the instruction information in the third MAC address, including: The sub-device parses the low two bytes in the third MAC address to obtain the instruction information in the third MAC address, and executes a control operation matched with a control instruction type in the instruction information according to the control instruction type. The instruction information includes at least one control instruction number and at least one control instruction type, and the control instruction number and the control instruction type are one-to-one corresponding.
4. The Bluetooth broadcast-based communication method of claim 3, wherein, The sub-device executes a control operation matched with a control instruction type in the instruction information according to the control instruction type, including: The sub-device determines the control instruction type in the instruction information. When the sub-device determines that the control instruction type is reading data, the sub-device sends broadcast data containing software version and serial number information of the sub-device to the master device. When the master device receives the broadcast data containing software version and serial number information of the sub-device sent by the sub-device, the master device judges whether the software version and serial number information of the sub-device match the currently adapted software version and serial number information. When it is judged that the software version and serial number information of the sub-device do not match the currently adapted software version and serial number information, the master device updates the third MAC address and sends the updated third MAC address to the sub-device, and the updated third MAC address includes instruction information with a control instruction type of configuring data. When the sub-device receives the updated third MAC address sent by the master device, the sub-device re-executes an instruction control operation matched with the instruction information in the updated third MAC address according to the instruction information in the updated third MAC address. When the sub-device determines that the control instruction type is configuring data, the sub-device stops sending broadcast data and detects whether configuration data sent by the master device is received within a preset time threshold. When the sub-device receives the configuration data sent by the master device within the preset time threshold, the sub-device updates software version and serial number information of the sub-device according to the configuration data. When the sub-device does not receive the configuration data sent by the master device within the preset time threshold, the sub-device stops receiving broadcast data and re-executes the operation of sending broadcast data according to the sending interval time length.
5. The Bluetooth broadcast based communication method according to any of claims 2, 3, 4, characterized in that, After the master device judges whether a distance value between the sub-device and the master device is less than or equal to a preset distance threshold according to the Bluetooth signal strength of the sub-device, the method further includes: When it is judged that the distance value between at least one target sub-device and the master device is less than or equal to the preset distance threshold, the master device determines the distance value between each target sub-device and the master device according to the Bluetooth signal strength of each target sub-device; The master device sorts the distance values between all target sub-devices and the master device from small to large, obtains a target sub-device with the smallest distance value, and preferentially modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the target sub-device with the smallest distance value to obtain a third MAC address of the master device, and sends the third MAC address to the target sub-device with the smallest distance value to trigger the target sub-device to perform the operation of judging whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device.
6. A communication method based on Bluetooth broadcasting, characterized by, The method is applied to a sub-device of an Internet of Things system, and the method comprises: The sub-device sends broadcast data to a master device, so that the master device modifies a second MAC address of the master device according to a first MAC address in the broadcast data sent by the sub-device to obtain a third MAC address of the master device when the master device receives the broadcast data sent by the sub-device; When the sub-device receives the third MAC address sent by the master device, the sub-device judges whether the identification information in the third MAC address matches the compressed first MAC address of the sub-device; When it is judged that the identification information in the third MAC address matches the compressed first MAC address of the sub-device, the sub-device performs an instruction control operation matched with the instruction information according to the instruction information in the third MAC address; The byte length of the first MAC address, the second MAC address and the third MAC address is six bytes; Before the master device modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the sub-device to obtain the third MAC address of the master device, the master device is further configured to determine the distance value between the sub-device and the master device according to the Bluetooth signal strength of the sub-device, and judge whether the distance value between the current master device and the sub-device is less than or equal to a preset distance threshold; The Bluetooth signal strength of the sub-device and the distance value between the current sub-device and the master device are in an inverse relationship; The specific way in which the master device modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the sub-device to obtain the third MAC address of the master device is as follows: When it is judged that the distance value between the current sub-device and the master device is less than or equal to the preset distance threshold, the master device compresses the first MAC address in the broadcast data sent by the sub-device according to a preset algorithm to obtain a MAC address with a four-byte number, and modifies the four high bytes of the MAC address with the four-byte number as the second MAC address of the master device. modifying a two-byte number of control instructions to be low two bytes in the second MAC address of the master device; integrating high four bytes in the second MAC address and low two bytes in the second MAC address to obtain a third MAC address of the master device.
7. A Bluetooth broadcast based communication apparatus, characterized by The device is applied to a master device of an Internet of Things system, and the device comprises: a modifying module, configured to modify a second MAC address of the master device according to a first MAC address in broadcast data sent by a slave device to obtain a third MAC address of the master device when the master device receives the broadcast data sent by the slave device; a first sending module, configured to send the third MAC address obtained by the modifying module to the slave device to trigger the slave device to judge whether identification information in the third MAC address matches the compressed first MAC address of the slave device, and when it is judged that the identification information in the third MAC address matches the compressed first MAC address of the slave device, the slave device executes an instruction control operation matched with instruction information in the third MAC address according to the instruction information; the first MAC address, the second MAC address and the third MAC address have a byte length of six bytes; before the modifying module modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the slave device to obtain the third MAC address of the master device, the device further comprises: a determining module, configured to determine a distance value between the slave device and the master device according to a Bluetooth signal strength of the slave device by the master device; a first judging module, configured to judge whether the distance value between the slave device and the master device determined by the determining module is less than or equal to a preset distance threshold value; wherein the Bluetooth signal strength of the slave device and the distance value between the slave device and the master device are in an inverse relationship; the specific manner in which the modifying module modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the slave device to obtain the third MAC address of the master device is as follows: when the first judging module judges that the distance value between the slave device and the master device is less than or equal to the preset distance threshold value, compressing the first MAC address in the broadcast data sent by the slave device according to a preset algorithm to obtain a MAC address with a four-byte number, and modifying the MAC address with the four-byte number to be high four bytes in the second MAC address of the master device; modifying a two-byte number of control instructions to be low two bytes in the second MAC address of the master device; integrating high four bytes in the second MAC address and low two bytes in the second MAC address to obtain a third MAC address of the master device. The third MAC address comprises high four bytes and low two bytes, the high four bytes in the third MAC address are used to determine identification information of the third MAC address, and the low two bytes in the third MAC address are used to determine instruction information of the third MAC address.
8. A Bluetooth broadcast based communication apparatus, characterized by The device is applied to a sub-device of an Internet of Things system, and the device comprises: a second sending module, configured to send broadcast data to a master device, so that the master device modifies a second MAC address of the master device according to a first MAC address in the broadcast data sent by the second sending module, to obtain a third MAC address of the master device; a judging module, configured to judge whether identification information in the third MAC address matches the compressed first MAC address of the sub-device when the third MAC address sent by the master device is received; an executing module, configured to execute an instruction control operation matched with instruction information in the third MAC address according to the instruction information when the judging module judges that the identification information in the third MAC address matches the compressed first MAC address of the sub-device. The first MAC address, the second MAC address and the third MAC address have a byte length of six bits. Before the master device modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the second sending module, to obtain the third MAC address of the master device, the master device is further configured to determine a distance value between the sub-device and the master device according to a Bluetooth signal strength of the sub-device, and judge whether the distance value between the master device and the sub-device at present is less than or equal to a preset distance threshold value. The Bluetooth signal strength of the sub-device and the distance value between the master device and the sub-device at present are in an inverse relationship. The master device modifies the second MAC address of the master device according to the first MAC address in the broadcast data sent by the sub-device, to obtain the third MAC address of the master device, in the following specific manner: When it is judged that the distance value between the master device and the sub-device at present is less than or equal to the preset distance threshold value, the master device compresses the first MAC address in the broadcast data sent by the sub-device according to a preset algorithm, to obtain a MAC address with a byte length of four bits, and modifies the MAC address with the byte length of four bits as the high four bytes in the second MAC address of the master device; modifies a control instruction with a byte length of two bits as the low two bytes in the second MAC address of the master device; integrates the high four bytes in the second MAC address and the low two bytes in the second MAC address, to obtain the third MAC address of the master device.
9. A Bluetooth broadcast based communication apparatus, characterized by The device comprises: a memory storing executable program codes; a processor coupled with the memory; the processor invokes the executable program codes stored in the memory, to execute the method for communication based on Bluetooth broadcast according to any one of claims 1-6.
Citation Information
Patent Citations
Bluetooth device control method, client, computer device and readable storage medium
CN113271579A
Water meter reading method based on Bluetooth communication, storage medium and computer equipment
CN114615568A
Information processing apparatus, control method, and storage medium
US20150234622A1