A low-power bluetooth network optimization method, electronic equipment and storage medium
By constructing an initial network connection graph and generating a minimum spanning tree, the Bluetooth Low Energy network is optimized, solving the problems of limited transmission distance and unstable communication quality, and achieving resource conservation and improved network stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MOBILE TECH COMPANY CHINA TRAVELSKY HLDG
- Filing Date
- 2025-01-24
- Publication Date
- 2026-07-07
AI Technical Summary
Bluetooth Low Energy networks suffer from limited transmission distance, unstable communication quality, network congestion, and excessive resource consumption in complex environments.
By constructing an initial network connectivity graph and generating a minimum spanning tree, the routing table is updated to optimize the Bluetooth Low Energy network, dynamically adjusting network connectivity and routing strategies to reduce unnecessary communication connections.
While maintaining communication quality, it reduces resource consumption, improves network stability and work efficiency, and reduces the negative impact of transmission distance limitations and communication equipment connections.
Smart Images

Figure CN119946595B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network optimization technology, and in particular to a low-power Bluetooth network optimization method, electronic device, and storage medium. Background Technology
[0002] Bluetooth Low Energy (BLE) is a wireless personal area network (PAN) technology specifically designed for mobile communications and the Internet of Things (IoT). It aims to provide similar communication range and functionality to traditional Bluetooth with lower power consumption. In a BLE network, the network topology typically adopts a star structure, including several communication devices, one master device and one or more non-master devices (slave devices). The master device is responsible for initiating and managing connections with non-master devices and coordinating data transmission. Non-master devices respond to requests from the master device, providing data or services. However, in complex environments such as smart homes, industrial automation, and aerospace, multiple master devices and a large number of non-master devices may form a more complex network structure. However, the effective transmission distance of BLE is typically around 10 meters, and this distance is further reduced in the presence of obstacles, potentially affecting communication quality and leading to unstable data transmission or data loss. Furthermore, the limited number of communication devices in a BLE network increases the risk of network congestion, potentially causing communication conflicts and increased latency. More communication connections also significantly increase the power consumption of communication devices, thus shortening the usage time of battery-powered devices. Summary of the Invention
[0003] To address the aforementioned technical problems, the technical solution adopted by this invention is as follows:
[0004] According to a first aspect of the present invention, a method for optimizing a low-power Bluetooth network is provided. The method is applied to a communication device and includes the following steps:
[0005] S1. If it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has not been optimized, then in response to a new communication device joining the Bluetooth Low Energy network, it obtains the current number of devices DQ. DQ is the number of communication devices in the current Bluetooth Low Energy network. The Bluetooth Low Energy network includes several communication devices, and the communication devices establish and maintain communication connections based on the Bluetooth Low Energy protocol.
[0006] S2. If DQ ≥ YS, then optimize the Bluetooth Low Energy (BLE) network according to the initial routing table corresponding to the BLE network, where YS is the preset number of devices; optimizing the BLE network according to the initial routing table corresponding to the BLE network includes the following steps S21-S23:
[0007] S21. Construct an initial network connection graph corresponding to the Bluetooth Low Energy network based on the initial routing table of the Bluetooth Low Energy network. The initial network connection graph includes several nodes and edges. Nodes represent communication devices in the Bluetooth Low Energy network, and edges represent direct communication between the two communication devices corresponding to the nodes at both ends of the edge. Each edge is attached with the total communication quality weight of the two communication devices corresponding to the nodes at both ends of the edge. The total communication quality weight is used to measure the communication quality between the two communication devices.
[0008] S22. Copy the initial network connection graph as the historical network connection graph, and use the minimum spanning tree corresponding to the initial network connection graph as the new initial network connection graph to update the initial network connection graph. The minimum spanning tree corresponding to the initial network connection graph contains all nodes in the initial network connection graph and the edges connecting these nodes, and the sum of the total communication quality weights attached to all edges is minimized.
[0009] S23. Generate an intermediate routing table based on the new initial network connection graph and send the intermediate routing table to all communication devices in the Bluetooth Low Energy network except itself. The communication devices that receive the intermediate routing table can determine whether to disconnect their communication connection with other communication devices based on the communication connection relationship recorded in the intermediate routing table, so as to optimize the Bluetooth Low Energy network. At the same time, the intermediate routing table is used as the initial routing table corresponding to the Bluetooth Low Energy network. The intermediate routing table records the communication connection relationship between the communication devices corresponding to each node in the initial network connection graph.
[0010] According to a second aspect of the present invention, a non-transitory computer-readable storage medium is provided, wherein a computer program is stored in the storage medium, and the computer program is loaded and executed by a processor to implement the aforementioned method.
[0011] According to a third aspect of the present invention, an electronic device is provided, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the aforementioned method.
[0012] The present invention has at least the following beneficial effects:
[0013] This invention provides a method, electronic device, and storage medium for optimizing a Bluetooth Low Energy (BLE) network. The method is applied to a communication device. If the device is the master device of the BLE network and the BLE network has not been optimized, in response to a new communication device joining the BLE network, the current number of devices is obtained. If the current number of devices is not less than a preset number, the BLE network is optimized according to the initial routing table corresponding to the BLE network. Specifically, an initial network connection graph corresponding to the BLE network is constructed based on the initial routing table. The minimum spanning tree corresponding to the initial network connection graph is used as a new initial network connection graph to update the initial network connection graph. An intermediate routing table is generated based on the new initial network connection graph and sent to all communication devices in the BLE network except the device itself. Each communication device receiving the intermediate routing table determines whether to disconnect its communication connection with other communication devices based on the communication connection relationships recorded in the intermediate routing table, thereby achieving optimization of the BLE network. As can be seen, this invention uses the minimum spanning tree corresponding to the initial network connection graph as the new initial network connection graph, generates an intermediate routing table based on the initial network connection graph, and sends the intermediate routing table to all communication devices in the Bluetooth Low Energy network except itself to optimize the Bluetooth Low Energy network. It can dynamically adjust the network connection relationship and routing strategy, reduce unnecessary communication connections while maintaining communication quality, thereby reducing resource consumption, effectively improving the working efficiency and stability of the Bluetooth Low Energy network, and reducing the negative impacts caused by the Bluetooth Low Energy transmission distance limitation and too many communication device connections. Attached Figure Description
[0014] 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.
[0015] Figure 1 A flowchart illustrating a low-power Bluetooth network optimization method provided in an embodiment of the present invention;
[0016] Figure 2 This is the initial network connection diagram in step S21 provided in the embodiment of the present invention;
[0017] Figure 3 The new initial network connection diagram in step S22 provided in the embodiment of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. 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.
[0019] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar tasks and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or server that comprises a series of steps or units is not necessarily limited to those explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.
[0020] Embodiments of the present invention provide a low-power Bluetooth network optimization method, which is applied to a communication device and includes the following steps: Figure 1 , Figure 2 and Figure 3 As shown:
[0021] S1. If it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has not been optimized, then in response to a new communication device joining the Bluetooth Low Energy network, it obtains the current number of devices DQ. DQ is the number of communication devices in the current Bluetooth Low Energy network. The Bluetooth Low Energy network includes several communication devices, and the communication devices establish and maintain communication connections based on the Bluetooth Low Energy protocol.
[0022] Specifically, in a Bluetooth Low Energy (BLE) network, when a new communication device joins the BLE network, the new communication device maintains communication connections with all other communication devices that can establish communication connections with it. At the same time, the maintained communication connections are stored in the initial routing table corresponding to the BLE network.
[0023] In one specific embodiment, the initial routing table corresponding to the Bluetooth Low Energy network records the communication connection relationship between each communication device in the Bluetooth Low Energy network and all other communication devices. The communication connection relationship includes connection status, which includes a kept-connection status and a disconnected connection status.
[0024] Furthermore, if the connection status in the communication connection relationship between two communication devices is a "maintain connection" status, it indicates that the two communication devices communicate directly. Direct communication means that the two communication devices can communicate without going through other devices. For example, communication device 1 and communication device 2 communicate directly without going through other communication devices.
[0025] Furthermore, if the connection status in the communication connection relationship between two communication devices is disconnected, it indicates that the two communication devices do not directly communicate. For example, communication device 1 and communication device 2 communicate through communication device 3.
[0026] S2. If DQ≥YS, then optimize the Bluetooth Low Energy network according to the initial routing table corresponding to the Bluetooth Low Energy network. Here, YS is the preset number of devices. The preset number of devices is the number of devices that are preset by those skilled in the art according to actual needs, such as 10, 20, or 30, which will not be elaborated here.
[0027] Specifically, optimizing the Bluetooth Low Energy (BLE) network based on the initial routing table corresponding to the BLE network includes the following steps S21-S23:
[0028] S21. Construct an initial network connection graph corresponding to the Bluetooth Low Energy network based on the initial routing table of the Bluetooth Low Energy network. The initial network connection graph includes several nodes and edges. Nodes represent communication devices in the Bluetooth Low Energy network, and edges represent direct communication between the two communication devices corresponding to the nodes at both ends of the edge. Each edge is attached with the total communication quality weight of the two communication devices corresponding to the nodes at both ends of the edge. The total communication quality weight is used to measure the communication quality between the two communication devices.
[0029] Specifically, the smaller the total weight of communication quality, the better the communication quality between the two corresponding communication devices.
[0030] Specifically, step S2 also includes: if DQ < YS, then no processing is performed.
[0031] Specifically, step S21 includes the following steps S211-S215: obtaining the total communication quality weights of the two communication devices corresponding to the nodes at both ends of the edge.
[0032] S211. Take the two communication devices corresponding to the nodes at both ends of the edge as the first initial device and the second initial device, respectively.
[0033] S212. Obtain the first power level, the first RSSI signal strength, the second power level, and the second RSSI signal strength, wherein the first power level is the power level of the first initial device, the first RSSI signal strength is the RSSI signal strength of the first initial device, the second power level is the power level of the second initial device, and the second RSSI signal strength is the RSSI signal strength of the second initial device.
[0034] S213. According to the first preset weight influence value mapping list, obtain the first power weight influence value corresponding to the first power level and the second power weight influence value corresponding to the second power level. The first preset weight influence value mapping list includes several preset power level ranges and the first preset weight influence values corresponding to the preset power level ranges. When the first power level belongs to a certain preset power level range, the first preset weight influence value corresponding to the preset power level range to which the first power level belongs is used as the first power weight influence value corresponding to the first power level. When the second power level belongs to a certain preset power level range, the first preset weight influence value corresponding to the preset power level range to which the second power level belongs is used as the second power weight influence value corresponding to the second power level. Those skilled in the art know that the first preset weight influence value mapping list is a list pre-set by those skilled in the art according to actual needs, and will not be described in detail here.
[0035] Specifically, the larger the preset battery range, the greater the influence value of its corresponding first battery weight. For example, the preset battery ranges are [0%, 20%), [20%, 40%), [40%, 60%), and [60%, 100%]; the first preset weight influence value is 0 for [0%, 20%), 1 for [20%, 40%), 2 for [40%, 60%), and 3 for [60%, 100%].
[0036] S214. According to the second preset weight influence value mapping list, obtain the first RSSI signal strength weight influence value corresponding to the first RSSI signal strength and the second RSSI signal strength weight influence value corresponding to the second RSSI signal strength. The second preset weight influence value mapping list includes several preset RSSI signal strength intervals and the second preset weight influence values corresponding to the preset RSSI signal strength intervals. When the first RSSI signal strength belongs to a certain preset RSSI signal strength interval, the second preset weight influence value corresponding to the preset RSSI signal strength interval to which the first RSSI signal strength belongs is used as the first RSSI signal strength weight influence value corresponding to the first RSSI signal strength. When the second RSSI signal strength belongs to a certain preset RSSI signal strength interval, the second preset weight influence value corresponding to the preset RSSI signal strength interval to which the second RSSI signal strength belongs is used as the second RSSI signal strength weight influence value corresponding to the second RSSI signal strength. Those skilled in the art know that the second preset weight influence value mapping list is a list pre-set by those skilled in the art according to actual needs, and will not be described in detail here.
[0037] Specifically, the larger the preset RSSI signal strength range, the greater the corresponding second power weight influence value. For example, the preset power ranges are (-∞, -120), [-120, -90), [-90, -60), [-60, 0]; the second preset weight influence value is 0 for (-∞, -120), 1 for [-120, -90), 2 for [-90, -60), and 3 for [-60, 0].
[0038] S215. The sum of the communication quality weights corresponding to the first initial device and the second initial device is used as the total communication quality weight representing the communication quality between the first initial device and the second initial device. The communication quality weight corresponding to the first initial device is the difference obtained by subtracting the influence value of the first power weight and the influence value of the first RSSI signal strength weight from the preset communication quality weight. The communication quality weight corresponding to the second initial device is the difference obtained by subtracting the influence value of the second power weight and the influence value of the second RSSI signal strength weight from the preset communication quality weight.
[0039] Specifically, the preset communication quality weight used to obtain the communication quality weight corresponding to the first initial device is the same as the preset communication quality weight used to obtain the communication quality weight corresponding to the second initial device. As those skilled in the art know, the preset communication quality weight is a weight that is preset by those skilled in the art according to actual needs, and will not be elaborated here.
[0040] Through the above steps, the total weight of the communication quality of the first and second initial devices is obtained by quantifying their battery levels and RSSI signal strength. The lower the battery level, the worse the communication quality. Furthermore, excessively low battery levels may indicate that the communication device is about to lose power or that the user is actively leaving the Bluetooth Low Energy network. Similarly, a lower RSSI signal strength also indicates poorer communication quality, and users may actively leave the Bluetooth Low Energy network when the RSSI signal strength is low, directly affecting the communication capabilities of the devices. Therefore, obtaining the total weight of the communication quality of the first and second initial devices based on their battery levels and RSSI signal strength takes into account the key factors that actually affect communication quality, more accurately reflecting the communication quality status between devices and providing a basis for optimizing the Bluetooth Low Energy network.
[0041] S22. Copy the initial network connection graph as the historical network connection graph, and use the minimum spanning tree corresponding to the initial network connection graph as the new initial network connection graph to update the initial network connection graph. The minimum spanning tree corresponding to the initial network connection graph contains all nodes in the initial network connection graph and the edges connecting these nodes, and the sum of the total communication quality weights attached to all edges is minimized.
[0042] S23. Generate an intermediate routing table based on the new initial network connection graph and send the intermediate routing table to all communication devices in the Bluetooth Low Energy network except itself. The communication devices that receive the intermediate routing table can determine whether to disconnect their communication connection with other communication devices based on the communication connection relationship recorded in the intermediate routing table, so as to optimize the Bluetooth Low Energy network. At the same time, the intermediate routing table is used as the initial routing table corresponding to the Bluetooth Low Energy network. The intermediate routing table records the communication connection relationship between the communication devices corresponding to each node in the initial network connection graph.
[0043] Specifically, step S1 further includes: if the device itself is a non-master device in the Bluetooth Low Energy network, when it receives an intermediate routing table, it determines whether to disconnect its communication connection with other communication devices according to the communication connection relationship between itself and other communication devices recorded in the intermediate routing table, so as to optimize the Bluetooth Low Energy network. Specifically, if it communicates directly with a certain communication device in the Bluetooth Low Energy network, but the intermediate routing table does not record the communication connection relationship, then it is set to disconnect its communication connection with the communication device. For example, in the Bluetooth Low Energy network, if communication device 1 and communication device 2 communicate directly, but the intermediate routing table received by communication device 1 does not record the communication connection relationship between communication device 1 and communication device 2, or the connection status of the communication connection relationship between communication device 1 and communication device 2 recorded in the intermediate routing table received by communication device 1 is a disconnected connection, then communication device 1 is set to disconnect its communication connection with communication device 2.
[0044] Through the above steps, an initial network connection graph corresponding to the Bluetooth Low Energy (BLE) network is constructed based on the initial routing table. The minimum spanning tree corresponding to the initial network connection graph is used as the new initial network connection graph to update the initial network connection graph. An intermediate routing table is generated based on the new initial network connection graph and sent to all communication devices in the BLE network except for itself. The communication devices that receive the intermediate routing table determine whether to disconnect their communication connections with other communication devices based on the communication connection relationships recorded in the intermediate routing table. This optimizes the BLE network, dynamically adjusts network connection relationships and routing strategies, reduces unnecessary communication connections while maintaining communication quality, thereby reducing resource consumption and effectively improving the working efficiency and stability of the BLE network. At the same time, it reduces the negative impact of BLE transmission distance limitations and excessive communication device connections.
[0045] In one specific embodiment, the method further includes step S10:
[0046] S10. If it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has been optimized, then in response to a new communication device joining the Bluetooth Low Energy network, it obtains the current device identifier list and optimizes the Bluetooth Low Energy network based on the current device identifier list. The current device identifier list includes several current device identifiers, which are the identity identifiers of communication devices in the current Bluetooth Low Energy network.
[0047] Specifically, in step S10, optimizing the Bluetooth Low Energy network based on the current device identifier list includes the following steps S11-S13:
[0048] S11. Obtain the target device identifier list and the target optimization time point. The target device identifier list includes several target device identifiers. The target optimization time point is the time point when the Bluetooth Low Energy network was last optimized. The target device identifier is the identity identifier of the communication device in the Bluetooth Low Energy network at the target optimization time point.
[0049] S12. Take the symmetric difference between the current device identifier list and the target device identifier list as the intermediate device identifier list. The intermediate device identifier list includes several intermediate device identifiers.
[0050] S13, When ZJ > YS 0 If A / B > C, the Bluetooth Low Energy (BLE) network is optimized based on the initial routing table corresponding to the BLE network, where ZJ is the time difference between the current time point and the target optimization time point, and YS... 0 For the preset time difference, A is the number of intermediate device identifiers in the intermediate device identifier list, B is the number of current device identifiers in the current device identifier list, and C is the preset device quantity change ratio. As those skilled in the art know, the preset time difference is a time difference preset by those skilled in the art according to actual needs, such as 10 minutes. The preset device quantity change ratio is a value preset by those skilled in the art according to actual needs, such as 0.2, which will not be elaborated here.
[0051] Through the above steps, when Bluetooth Low Energy (BLE) has already been optimized, the current device identifier list, the target device identifier list, and the target optimization time point are obtained. The symmetric difference between the current device identifier list and the target device identifier list is used as the intermediate device identifier list. When the time difference between the current time point and the target optimization time point is not less than a preset time difference, or when the quotient of the number of intermediate device identifiers in the intermediate device identifier list divided by the number of current device identifiers in the current device identifier list is not less than a preset device quantity change ratio, the BLE network is optimized according to the initial routing table corresponding to the BLE network. Combining the change ratio (addition and exit) of communication devices in the BLE network with the time difference, it is determined whether the network needs to be re-optimized. This avoids the extra computation and communication overhead caused by frequent optimization, reduces unnecessary communication connections while maintaining communication quality, thereby reducing resource consumption. This not only improves optimization efficiency but also reduces the power consumption of communication devices, effectively improving the working efficiency and stability of the BLE network.
[0052] Specifically, step S13 also includes: when ZJ≤YS 0 When A / B≤C, no processing is performed.
[0053] In one specific embodiment, the method further includes the following steps S20-S70:
[0054] S20. If it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has been optimized, then when the communication device leaves the Bluetooth Low Energy network, the communication device that leaves the Bluetooth Low Energy network will be regarded as the key device and the number of node connections corresponding to the key device will be obtained. The number of node connections is the number of other nodes directly connected to the node corresponding to the key device through the edge in the initial network connection relationship graph.
[0055] Specifically, if the device itself is a non-master device in the Bluetooth Low Energy (BLE) network, then if it does not receive a heartbeat signal from the communication device with which it is directly communicating for D seconds, it determines that the communication device with which it is directly communicating has exited the BLE network. At this time, it sends the identity of the communication device with which it is directly communicating and network exit information to the master device of the BLE network. The network exit information indicates that the communication device has exited the BLE network. Here, D is a preset heartbeat signal transmission interval. Those skilled in the art know that the preset heartbeat signal transmission interval is a duration preset by those skilled in the art according to actual needs, and will not be elaborated here.
[0056] S30. If the number of nodes connected to the critical device is greater than 1, then delete the nodes connected to the critical device and the edges connecting the nodes from the historical network connection graph to obtain the first critical network connection graph, and delete the nodes connected to the critical device and the edges connecting the nodes from the initial network connection graph to obtain the second critical network connection graph; if the number of connected nodes connected to the critical device is equal to 1, then no processing is performed.
[0057] S40. Mark the edges that exist in the first key network connection graph but not in the second key network connection graph as candidate edges. For example: if the first key network connection graph includes nodes 1, 2, and 3, and nodes 1 and 2 are connected by an edge, nodes 1 and 3 are connected by an edge, and nodes 2 and 3 are connected by an edge, and the second key network connection graph includes nodes 1, 2, and 3, and nodes 1 and 2 are connected by an edge, and nodes 2 and 3 are connected by an edge, then the edge connecting nodes 1 and 3 is an edge that exists in the first key network connection graph but not in the second key network connection graph.
[0058] S50. Mark the candidate edge with the smallest total communication quality weight among all candidate edges as the target edge.
[0059] S60. The communication devices corresponding to the nodes at both ends of the target edge in the first key network connection diagram are respectively designated as the first intermediate device and the second intermediate device corresponding to the first intermediate device.
[0060] S70. Send the second intermediate device connection information to the first intermediate device, so that the first intermediate device can establish a communication connection with the corresponding second intermediate device when it receives the second intermediate device connection information, so as to optimize the low power Bluetooth network.
[0061] Through the above steps, if the device is the master device of the Bluetooth Low Energy (BLE) network and the BLE network has been optimized, then in response to a communication device leaving the BLE network, the communication device leaving the BLE network is designated as a key device, and the number of node connections corresponding to the key device is obtained. Based on the number of node connections corresponding to the key device, when the number of node connections corresponding to the key device is greater than 1, a first key network connection graph and a second key network connection graph are obtained. Edges existing in the first key network connection graph but not in the second key network connection graph are marked as candidate edges. The candidate edge with the smallest total communication quality weight among all candidate edges is marked as the target edge. The communication devices corresponding to the nodes at both ends of the target edge in the first key network connection graph are respectively designated as the first... The intermediate device and the corresponding second intermediate device of the first intermediate device send the second intermediate device connection information to the first intermediate device, so that the first intermediate device can establish a communication connection with its corresponding second intermediate device when it receives the second intermediate device connection information. This optimizes the Bluetooth Low Energy network and can react quickly when the communication device drops out, avoiding communication interruption or network instability caused by the sudden disconnection of the communication device. Furthermore, by constructing a first key network connection relationship graph and a second key network connection relationship graph, and marking candidate edges and target edges, the first intermediate device and the second intermediate device are determined according to the target edge. This enables the first intermediate device to establish a communication connection with its corresponding second intermediate device when it receives the second intermediate device connection information, and can intelligently select the optimal alternative path to ensure the continuity of network connection and communication quality.
[0062] In one specific embodiment, after step S30 and before step S60, the following steps S40-S50 are included:
[0063] S40. Obtain the minimum spanning tree corresponding to the first key network connection graph. The minimum spanning tree corresponding to the first key network connection graph contains all nodes in the first key network connection graph and the edges connecting these nodes, and the sum of the total weights of the communication quality attached to all edges is the minimum.
[0064] S50. Mark the edges that exist in the minimum spanning tree corresponding to the first key network connection graph but not in the second key network connection graph as target edges; for example: if the minimum spanning tree corresponding to the first key network connection graph includes nodes 1, 2 and 3, nodes 1 and 2 are connected by an edge, nodes 1 and 3 are connected by an edge, and nodes 2 and 3 are connected by an edge, and the second key network connection graph includes nodes 1, 2 and 3, nodes 1 and 2 are connected by an edge, and nodes 2 and 3 are connected by an edge, then the edge connecting nodes 1 and 3 is an edge that exists in the minimum spanning tree corresponding to the first key network connection graph but not in the second key network connection graph.
[0065] Through the above steps, the target edge is obtained by using the minimum spanning tree corresponding to the first key network connection graph and the second key network connection graph. The first intermediate device and the second intermediate device are determined based on the target edge. When the first intermediate device receives the connection information of the second intermediate device, it establishes a communication connection with the corresponding second intermediate device. It can intelligently select the optimal alternative path, ensure the continuity of network connection and communication quality, and avoid communication interruption or network instability caused by sudden disconnection of communication devices.
[0066] Specifically, step S20 also includes: if it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has not been optimized, then no processing is performed when the communication device leaves the Bluetooth Low Energy network.
[0067] In one specific embodiment, the following steps S001-S003 are included before step S1:
[0068] S001. When the device is the master device of the Bluetooth Low Energy (BLE) network and responds to a new communication device joining the BLE network, it obtains the master device determination score corresponding to itself and the master device determination score corresponding to the new communication device and proceeds to step S002. When the device is a non-master device of the BLE network and responds to a master device of the BLE network leaving the BLE network, it obtains the master device determination scores corresponding to all communication devices in the current BLE network and proceeds to step S003. The master device determination score corresponding to the communication device is obtained based on the number of other communication devices that directly communicate with the communication device in the current BLE network, the battery level of the current communication device, and the RSSI signal strength of the current communication device.
[0069] Specifically, step S001 further includes: when the device is a non-master device in the Bluetooth Low Energy network and receives master device confirmation information, setting itself as the master device in the Bluetooth Low Energy network.
[0070] S002. When the score of the master device corresponding to itself is less than the score of the master device corresponding to the new communication device, it sets itself as a non-master device of the Bluetooth Low Energy network and sends master device confirmation information to the new communication device so that the new communication device sets itself as the master device of the Bluetooth Low Energy network when it receives the master device confirmation information. Otherwise, no processing is performed.
[0071] S003. When the score of the master device corresponding to itself is the maximum value among the scores of the master devices corresponding to all communication devices in the current Bluetooth Low Energy network, then it is set as the master device of the Bluetooth Low Energy network; otherwise, it is set as a non-master device of the Bluetooth Low Energy network.
[0072] Through the above steps, the master device determination score for the communication device is obtained based on the number of other communication devices directly communicating with the current communication device in the Bluetooth Low Energy network, the battery level of the current communication device, and the RSSI signal strength of the current communication device. When determining the master device, the number of other communication devices directly communicating with the current communication device, the battery level of the current communication device, and the RSSI signal strength of the current communication device are considered. When the current communication device is the master device of the Bluetooth Low Energy network and responds to a new communication device joining the Bluetooth Low Energy network, the master device determination score of the current communication device is compared with the master device determination score of the new communication device to select a more suitable communication device as the master device. When a non-master device in a Bluetooth Low Energy (BLE) network leaves the BLE network, the most suitable device is dynamically selected as the master device by comparing the master device determination scores of various communication devices. When a new communication device joins or an existing master device leaves, the communication device with the higher master device determination score is selected as the master device, ensuring that the master role is assumed by the most suitable communication device. This helps improve the overall performance and stability of the BLE network. Furthermore, when changes occur in the BLE network, the master device can be automatically, quickly, and efficiently re-determined, reducing communication interruption time caused by the absence of a master device and improving the overall performance and resource utilization of the network.
[0073] Specifically, the steps preceding step S001 include the following steps S01-S02:
[0074] S01. When a Bluetooth Low Energy network join command is received, a Bluetooth signal search is performed.
[0075] S02. When no Bluetooth signal is found, establish a Bluetooth Low Energy network and set itself as the master device of the Bluetooth Low Energy network, while continuing to search for Bluetooth signals; when a Bluetooth signal is found, join the Bluetooth Low Energy network and set itself as a non-master device of the Bluetooth Low Energy network.
[0076] Through the above steps, when no Bluetooth signal is found, a Bluetooth Low Energy (BLE) network is established and the device is set as the master device of the BLE network. At the same time, the device continues to search for Bluetooth signals. When a Bluetooth signal is found, the device joins the BLE network and sets itself as a non-master device of the BLE network. This allows the communication device to quickly determine whether it is the master device of the BLE network based on the current network environment, and avoids the unnecessary creation of new networks, which is beneficial to the stability and connectivity of the BLE network.
[0077] In one specific embodiment, the following steps S010-S040 are included before step S001:
[0078] S010. When a Bluetooth Low Energy network join command is received, a Bluetooth signal search is performed.
[0079] S020. When no Bluetooth signal can be found, establish a Bluetooth Low Energy network; when a Bluetooth signal can be found, join the Bluetooth Low Energy network.
[0080] S030. If DQ < YS, then set itself as a non-master device in the Bluetooth Low Energy network; if DQ = YS, then obtain the master device determination score corresponding to all communication devices in the current Bluetooth Low Energy network.
[0081] S040. If the score of the master device corresponding to itself is the maximum value among the master device scores of all communication devices in the current Bluetooth Low Energy network, then set itself as the master device of the Bluetooth Low Energy network; otherwise, set itself as a non-master device of the Bluetooth Low Energy network.
[0082] Through the above steps, when the current number of devices is less than the preset number of devices, it indicates that there are relatively few communication devices in the Bluetooth Low Energy network. In this case, even without setting a master device, the working efficiency and stability of the Bluetooth Low Energy network can be guaranteed, reducing unnecessary resource consumption. When the current number of devices is equal to the preset number of devices, the most suitable device is dynamically selected as the master device by comparing the scores of the master devices of each communication device. This ensures that the master role is undertaken by the most suitable communication device, which is conducive to improving the overall performance and resource utilization of the Bluetooth Low Energy network.
[0083] Specifically, the process of determining the score of the master control device corresponding to the communication device based on the number of other communication devices directly communicating with the communication device in the current low-power Bluetooth network, the battery level of the current communication device, and the RSSI signal strength of the current communication device includes the following steps S0011-S0014:
[0084] S0011. Obtain the current number of connected devices E corresponding to the communication device, where E is the number of other communication devices that directly communicate with the communication device in the current Bluetooth Low Energy network.
[0085] S0012. Based on the preset power score mapping list F, obtain the current power score G corresponding to the communication device, where F = {F1, F2, ..., F...} i , ..., F m}, F i =(F i1 F i2 ), F i For the i-th preset battery score mapping combination, where i ranges from 1 to m, and m is the number of preset battery score mapping combinations, F i1 For F i The preset power range, F i2 For F i1 The corresponding preset battery score, when F i11 ≤H≤F i12 At that time, F i1 As G, where F i11 For F i1 The minimum value of F i12 For F i1 The maximum value of H is the current battery level of the communication device; in a specific embodiment, the preset battery score mapping list is a list pre-set by those skilled in the art according to actual needs, and will not be described in detail here.
[0086] Specifically, F i12 <F (i+1)11 F i2 =F (i+1)2 -1, F (i+1)11 For F (i+1)1 The minimum value of F (i+1)1 For F i+1 The preset power range, F i+1 For the (i+1)th preset power score mapping combination, F (i+1)2 For F (i+1)1 The corresponding preset battery score.
[0087] S0013. Based on the preset RSSI signal strength score mapping list R, obtain the current RSSI signal strength score J corresponding to the communication device, where R = {R1, R2, ..., R...} j , ..., R n}, R j =(R j1 R j2 ), R jThis is the j-th preset RSSI signal strength score mapping combination, where j ranges from 1 to n, and n is the number of preset RSSI signal strength score mapping combinations. R j1 For R j The preset RSSI signal strength range, R j2 For R j1 The corresponding preset RSSI signal strength score, when R j11 <K≤R j12 At that time, R j2 As J, where R j11 For R j1 The minimum value of R j12 For R j1 The maximum value of K is the current RSSI signal strength of the communication device. In a specific embodiment, the preset RSSI signal strength score mapping list is a list pre-set by those skilled in the art according to actual needs, and will not be described in detail here.
[0088] Specifically, R j12 <R (j+1)11 R j2 =R (j+1)2 -1, R (j+1)11 For R (j+1)1 The minimum value of R (j+1)1 For R j+1 The preset RSSI signal strength range, R j+1 For the (j+1)th preset RSSI signal strength score mapping combination, R (j+1)2 For R (j+1)1 The corresponding preset RSSI signal strength score.
[0089] S0014. Determine the score FZ based on the main control device corresponding to the communication device obtained from E, G, and J. FZ meets the following conditions:
[0090] FZ = E + G + J.
[0091] Specifically, F m2 =R n2 =ZD, where ZD is the maximum number of effective communication connections that a communication device can maintain simultaneously, F m2 For F m1 The corresponding preset battery score, F m1 For F m The preset power range, F m For the m-th preset power score mapping combination, R n2 For R n1 The corresponding preset RSSI signal strength score, R n1 For R n The preset RSSI signal strength range, R nThis is the nth preset RSSI signal strength score mapping combination.
[0092] Specifically, F 12 =R 12 =0,F 12 For F 11 The corresponding preset battery score, F 11 F1 represents the preset battery range in F1, where F1 is the first preset battery score mapping combination, and R... 12 For R 11 The corresponding preset RSSI signal strength score, R 11 R1 represents the preset RSSI signal strength range, where R1 is the first preset RSSI signal strength score mapping combination.
[0093] Specifically, the higher the score of the master control device corresponding to the communication device, the greater the likelihood that the communication device is the master control device of a Bluetooth Low Energy network.
[0094] Through the above steps, the master control device determination score is obtained based on the current number of connected devices, current battery level, and current RSSI signal strength score of the communication device. This provides a more comprehensive evaluation standard, ensuring that the selection of the master control device is not based on a single factor but takes into account multiple factors. This provides a more accurate basis for master control device selection. Selecting the communication device with the highest master control device determination score as the master control device can be understood as: selecting the communication device with a larger battery level, a stronger RSSI signal strength, and a larger number of other communication devices directly communicating with it as the master control device. This is beneficial for improving the connectivity and stability of the Bluetooth Low Energy network.
[0095] In one specific embodiment, the method further includes the following steps to obtain F 11 F 21 , ..., F i1 , ..., F m1 :
[0096] Get the preset battery usage time mapping list L = {L1, L2, ..., L...} e , ..., L f}, L e =(L e1 L e2 ), where L e This is the e-th preset battery usage time mapping combination, where e ranges from 1 to f, f is the number of preset battery usage time mapping combinations, and L e1 For the e-th preset battery level, L e2 The power of the communication device is L e1 At that time, the estimated duration for which the communication equipment can continue to be used.
[0097] Specifically, L e <L e+1 L e+1 This is the e+1th preset battery level.
[0098] When L (e-1)2 <M<L e2 At that time, let F m11 =L e1 , making F m12 =100, where L (e-1)2 The power of the communication device is L (e-1)1 At that time, the estimated duration for which the communication equipment can continue to be used, L (e-1)1 For the (e-1)th preset battery level, F m11 For F m1 The minimum value of F m12 For F m1 The maximum value of M is the duration between the current time and the end time of Bluetooth Low Energy network use. In a specific application scenario, the end time of Bluetooth Low Energy network use can be understood as the end time of the flight, and M can be understood as the remaining time of the flight. For example, if there are 120 minutes left before the end of Bluetooth Low Energy network use, then the value of M is 120; if there are 120 minutes left of the flight time, then the value of M is 120.
[0099] The closed interval [0, F] m11 -1] is divided into F m2 -1 closed intervals are respectively used as F 11 F 21 , ..., F i1 , ..., F (m-1)1 As those skilled in the art will know, any method in the prior art that divides a closed interval into several closed intervals is within the scope of protection of this invention, such as average division, which will not be elaborated here.
[0100] By following the steps above, based on the preset battery level, the estimated duration that the communication device can continue to be used, and the duration between the current time and the end time of the Bluetooth Low Energy network usage, the preset battery level range in the preset battery level score mapping combination is determined. This allows for flexible determination of the preset battery level range according to the actual situation, which helps to improve the accuracy of determining the preset battery level range.
[0101] In one specific embodiment, the method further includes the following steps S100-S600:
[0102] S100: If it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has been optimized, it obtains DQ when a new communication device joins the Bluetooth Low Energy network.
[0103] S200. When Q > ZK, obtain Q clustering core devices; when Q ≤ ZK, perform no processing. Here, Q is the device multiplier, ZK is the number of master devices in the current Bluetooth Low Energy network, and Q meets the following conditions:
[0104] Q = floor(DQ / YS), where floor() is the floor function.
[0105] S300: The identity identifiers corresponding to the Q clustering core devices are respectively used as the Q cluster centers in the k-means clustering algorithm. The total communication quality weight between the communication devices in the Bluetooth Low Energy network and the clustering core devices corresponding to the cluster centers is used as the distance between the identity identifier of the communication device and the cluster center. Based on the k-means clustering algorithm, the identity identifiers of all communication devices in the current Bluetooth Low Energy network are clustered to obtain Q clusters and several discrete identity identifiers. Each cluster includes several clustered identity identifiers.
[0106] Specifically, discrete identity can be understood as: among the identity identifiers of all communication devices in a Bluetooth Low Energy network, there are no identity identifiers that are clustered together.
[0107] S400: The network consisting of communication devices corresponding to all clustered identity identifiers in a single cluster is taken as a single Bluetooth Low Energy sub-network to obtain Q Bluetooth Low Energy sub-networks.
[0108] Specifically, the method further includes: sending full connection information to the communication device corresponding to the discrete identity, so that when the communication device corresponding to the discrete identity receives the full connection information, it maintains a communication connection with all other communication devices in the Bluetooth Low Energy network that can establish a communication connection with it.
[0109] S500: When it is a clustering core device, it sets itself as the master device of its own Bluetooth Low Energy subnetwork and sends master device confirmation information to other clustering core devices. This allows other clustering core devices to set themselves as the master device of the Bluetooth Low Energy network and also as the master device of their own Bluetooth Low Energy subnetwork when they receive the master device confirmation information. When it is not a clustering core device, it sets itself as a non-master device of the Bluetooth Low Energy network and sends master device confirmation information to all clustering core devices. This allows other clustering core devices to set themselves as the master device of the Bluetooth Low Energy network and also as the master device of their own Bluetooth Low Energy subnetwork when they receive the master device confirmation information.
[0110] S600. When it is the master device of the Bluetooth Low Energy sub-network, it optimizes the Bluetooth Low Energy sub-network according to the initial routing table corresponding to the Bluetooth Low Energy sub-network. The initial routing table corresponding to the Bluetooth Low Energy sub-network records the communication connection relationship between each communication device in the Bluetooth Low Energy sub-network and all other communication devices. The optimization of the Bluetooth Low Energy sub-network is carried out in the same way as the optimization of the Bluetooth Low Energy sub-network according to the initial routing table corresponding to the Bluetooth Low Energy sub-network in steps S21-S23.
[0111] Through the above steps, if it is the master device of the Bluetooth Low Energy (BLE) network and the BLE network has been optimized, then in response to a new communication device joining the BLE network, it obtains the current number of devices, calculates the device multiplier based on the current number of devices, and determines the cluster core device when the device multiplier is greater than the number of master devices in the current BLE network. Based on the k-means algorithm, it clusters the identities of all communication devices in the BLE network, obtains the cluster corresponding to each core device, and takes the network of communication devices corresponding to all cluster identities in a single cluster as a single BLE sub-network. The core device is then set as the master device of both the BLE network and the BLE sub-network. When acting as the master device of a Bluetooth Low Energy (BLE) subnetwork, the device optimizes the BLE subnetwork based on its initial routing table. Optimization only occurs when a new communication device is added and the device multiplier is greater than the number of master devices in the current BLE network, avoiding resource waste caused by frequent optimization. The BLE network optimization uses the k-means algorithm to dynamically divide the network into several BLE subnetworks based on the communication quality weights between communication devices. This allows for flexible adaptation to changes in network topology and simultaneous optimization of BLE subnetworks, enabling rapid optimization and improving BLE network performance and optimization efficiency.
[0112] In one specific embodiment, the following steps S110-S160 are included after step S600:
[0113] S110. When it is the master device of the Bluetooth Low Energy sub-network and the Bluetooth Low Energy sub-network has been optimized, it takes the Bluetooth Low Energy sub-network it is in as the first sub-network and the other Bluetooth Low Energy sub-networks other than the first sub-network as the second sub-network.
[0114] S120. Obtain the first designated device identifier list X = {X1, X2, ..., X} corresponding to the first sub-network. a ..., X cThe set of second designated device identifiers Y = {Y1, Y2, ..., Y} corresponding to X and X is also known as X. a , ..., Y c}, Y a ={Y a1 Y a2 , ..., Y ab , ..., Y ad}, where X a Let Y be the a-th first designated device identifier corresponding to the first sub-network, where a ranges from 1 to c, and c is the number of first designated device identifiers corresponding to the first sub-network. The first designated device identifier is the identity identifier of the first designated device, and the first designated device is the communication device in the first sub-network that directly communicates with the communication device in the second sub-network. a For X a The corresponding second designated device identifier list, Y ab For X a The corresponding b-th second designated device identifier, where b takes values from 1 to d, and d is X. a The corresponding number of second designated device identifiers, where the second designated device identifier is the identity identifier of the second designated device, and the second designated device is the communication device in the second sub-network that communicates directly with the first designated device.
[0115] S130, X a The corresponding first designated device and Y ab The total communication quality weight of the corresponding second designated device is used as Y. ab The corresponding first specified weight, wherein X is obtained by using the same method as in steps S211-S215 for obtaining the total communication quality weight of the two communication devices corresponding to the nodes at both ends of the edge. a The corresponding first designated device and Y ab The corresponding communication quality weight of the second designated device.
[0116] S140. Send disconnection information to all first designated devices, so that the first designated devices disconnect the communication connection with the corresponding second designated device when they receive the disconnection information.
[0117] S150. The second designated device corresponding to the second designated device identifier corresponding to the minimum first designated weight is taken as the third designated device, and the first designated device corresponding to the first designated device identifier corresponding to the minimum first designated weight is taken as the fourth designated device corresponding to the third designated device. The minimum first designated weight is the minimum value among the first designated weights corresponding to all second designated device identifiers in the list of all second designated device identifiers.
[0118] S160. Send the connection information of the third designated device to the fourth designated device, so that when the fourth designated device receives the connection information of the third designated device, it establishes a communication connection with the corresponding third designated device.
[0119] Through the above steps, a first sub-network and a second sub-network are determined. Based on the first designated device in the first sub-network and the second designated device corresponding to the first designated device in the second sub-network, a third designated device and a fourth designated device are determined. Disconnection information is sent to all first designated devices, causing each first designated device to disconnect its communication connection with its corresponding second designated device upon receiving the disconnection information. A third designated device connection information is sent to the fourth designated device, causing the fourth designated device to establish a communication connection with its corresponding third designated device upon receiving the third designated device connection information. This ensures that all communication devices in the first sub-network communicate with all communication devices in the second sub-network only indirectly through the third and fourth designated devices, reducing unnecessary communication connections, thereby reducing resource consumption and effectively improving the working efficiency and stability of the Bluetooth Low Energy network.
[0120] Specifically, step S200 also includes the following steps S210-S270: obtaining Q clustering core devices:
[0121] S210. Obtain the score of the master control device corresponding to each communication device in the current Bluetooth Low Energy network.
[0122] S220. Select Q from all communication devices in the current Bluetooth Low Energy network according to the descending order of scores determined by the master control device. 0 One communication device was selected as the first candidate device, Q 0 To determine the quantity of the candidate equipment, Q 0 The following conditions must be met: Q 0 = 2 × Q.
[0123] S230. Obtain the second candidate device identifier combination list T = {T1, T2, ..., T...} g , ..., T h}, T g For the g-th second candidate device identifier combination, where g ranges from 1 to h, and h is the number of second candidate device identifier combinations, T g This includes Q second candidate device identifiers, where each second candidate device identifier is an identity identifier for a second candidate device. Specifically, Q... 0 From the first candidate devices, any Q first candidate devices are selected as the second candidate devices corresponding to the Q second candidate device identifiers in a combination of second candidate device identifiers.
[0124] S240, from T g Choose any two second candidate device identifiers as Tg To obtain T, two third candidate device identifiers are selected from a combination of third candidate device identifiers. g The corresponding third candidate device identifier combination list U g ={U g1 U g2 , ..., U gr , ..., U gs}, where U gr For T g The corresponding r-th third candidate device identifier combination, where r ranges from 1 to s, and s is T. g The corresponding third candidate device identifier combination, the third candidate device identifier is the identity identifier of the third candidate device.
[0125] S250, Obtain U gr The total communication quality weight W between the two third candidate device identifiers corresponding to the third candidate devices in the data. gr .
[0126] S260, according to W gr Get T g The corresponding second intermediate weight N g N g Meets the following conditions:
[0127] N g =∑ s r=1 W gr .
[0128] S270, N1, N2, ..., N g , ..., N h The Q candidate devices corresponding to the Q candidate device identifiers in the list of the second candidate device identifiers with the largest second intermediate weight are taken as the Q clustering core devices.
[0129] Through the above steps, the master control device determination score corresponding to each communication device in the current Bluetooth Low Energy network is obtained. Based on the master control device determination score, the first candidate device is determined. Based on the first candidate device, a list of second candidate device identifier combinations is obtained. Further, the third candidate device identifier combination corresponding to the second candidate device identifier combination is obtained. The total communication quality weight between the third candidate devices corresponding to the two third candidate device identifiers in the third candidate device identifier combination is obtained. Further, the second intermediate weight corresponding to the second candidate device identifier combination is obtained. The second candidate device corresponding to the second candidate device identifier in the list of second candidate device identifier combinations with the largest second intermediate weight among all second candidate device identifier combinations is used as the clustering core device. This ensures that the finally selected clustering core device not only has a high master control device determination score, but also has the best communication quality.
[0130] Specifically, step S250 includes the following steps S251-S254:
[0131] S251, If U gr If the two third candidate device identifiers in the diagram correspond to two third candidate devices that communicate directly, then the total communication quality weight of the two third candidate devices will be used as W. gr The total communication quality weight of the two third candidate devices is obtained by using the same method as in steps S211-S215 for obtaining the total communication quality weight of the two communication devices corresponding to the nodes at both ends of the edge.
[0132] S252, if U gr If two third candidate device identifiers correspond to two third candidate devices that communicate indirectly, then the two third candidate device identifiers and the identity identifiers of other communication devices that act as relays in the indirect communication process are used as U. gr The corresponding fourth candidate device identifier in the fourth candidate device identifier list, to obtain U gr The corresponding fourth candidate device identifier list set V gr ={V gr1 V gr2 , ..., V grx , ..., V grp}, V grx ={V grx1 V grx2 , ..., V grxy , ..., V grxq}, V grx For U gr The corresponding x-th fourth candidate device identifier list, where x ranges from 1 to p, and p is U gr The corresponding number of fourth candidate device identifiers, V grxy For Vgrx The y-th fourth candidate device identifier in the list, where y ranges from 1 to q, and q is the number of fourth candidate device identifiers in the list.
[0133] Specifically, indirect communication refers to two communication devices needing to communicate through one or more other communication devices that act as relays; for example, if communication device 1 and communication device 2 communicate through communication device 3, communication device 4 and communication device 5, then communication device 1 and communication device 2 communicate indirectly, and communication device 3, communication device 4 and communication device 5 act as relays in the indirect communication process.
[0134] Specifically, V grxy The corresponding fourth candidate device and V grx(y+1) The corresponding fourth candidate device communicates directly, V grx(y+1) For V grx The (y+1)th fourth candidate device identifier in the array.
[0135] S253, Obtain V grx The corresponding first intermediate weight V 0 grx V 0 grx Meets the following conditions:
[0136] V 0 grx =∑ q-1 y=1 V 1 grxy V 1 grxy For V grxy The corresponding fourth candidate device and V grx(y+1) The corresponding total communication quality weight of the fourth candidate device is obtained by using the same method as in steps S211-S215 to obtain the total communication quality weight of the two communication devices corresponding to the nodes at both ends of the edge, to obtain V. grxy The corresponding fourth candidate device and V grx(y+1) The total weight of the communication quality of the corresponding fourth candidate device.
[0137] S254, V 0 grx1 V 0 grx2 , ..., V 0 grxy , ..., V 0 grxq The smallest first intermediate weight is used as W gr .
[0138] Through the above steps, if the two third candidate devices corresponding to the two third candidate device identifiers in the third candidate device identifier combination communicate directly, the total communication quality weight of the two third candidate devices is used as the total communication quality weight between the two third candidate devices. If the two third candidate devices corresponding to the two third candidate device identifiers in the third candidate device identifier combination communicate indirectly, a set of fourth candidate device identifier lists corresponding to the third candidate device identifier combination is obtained. Based on the total communication quality weight of the fourth candidate devices corresponding to the two adjacent fourth candidate device identifiers in the fourth candidate device identifier list, the first intermediate weight corresponding to the fourth candidate device identifier list is obtained. The minimum value among the first intermediate weights corresponding to all fourth candidate device identifier lists is used as the total communication quality weight of the two third candidate devices and the total communication quality weight between the two third candidate devices. The communication quality of each communication path is accurately quantified, providing a basis for selecting the optimal clustering core device.
[0139] In one specific embodiment, the method further includes the following steps S1000-S6000:
[0140] S1000: If it is the master device of the Bluetooth Low Energy network, it will obtain the current device identifier list when a new communication device joins the Bluetooth Low Energy network.
[0141] S2000: Obtain several direct communication device identifiers corresponding to each current device identifier. The direct communication device identifier is the identity identifier of the communication device that directly communicates with the communication device corresponding to the current device identifier in the Bluetooth Low Energy network.
[0142] S3000, take the total communication quality weight of the communication device corresponding to the current device identifier and the communication device corresponding to the direct communication device identifier as the first stability weight corresponding to the current device identifier. In this case, the same method as in steps S211-S215 for obtaining the total communication quality weight of the two communication devices corresponding to the nodes at both ends of the edge is used to obtain the total communication quality weight of the communication device corresponding to the current device identifier and the communication device corresponding to the direct communication device identifier.
[0143] S4000: Take the minimum value among all the first stability weights corresponding to the current device identifier as the second stability weight corresponding to the current device identifier.
[0144] Specifically, the smaller the second stability weight corresponding to the current device identifier, the more stable the network that directly communicates with the communication device corresponding to the current device identifier.
[0145] S5000: Obtain the number of stable devices WD, where WD is the number of current device identifiers whose corresponding second stability weight is less than the preset stability weight. As those skilled in the art know, the preset stability weight is a weight preset by those skilled in the art according to actual needs, and will not be described in detail here.
[0146] S6000, if DQ≥YS and WD≥WD 0 If the Bluetooth Low Energy (BLE) network has not been optimized, it will be optimized based on the initial routing table corresponding to the BLE network. If the BLE network has already been optimized, it will be optimized based on the current device identifier list. (WD...) 0 The preset stable device ratio is known to those skilled in the art. The preset stable device ratio is set by those skilled in the art according to actual needs, and will not be described in detail here.
[0147] Through the above steps, when a new communication device joins the Bluetooth Low Energy (BLE) network, a first stability weight corresponding to the current device identifier is obtained based on the total communication quality weight between the current communication device and other devices it directly communicates with. The minimum value among all first stability weights corresponding to the current device identifier is taken as the second stability weight corresponding to the current device identifier. The number of current device identifiers whose corresponding second stability weight is less than a preset stability weight is taken as the number of stable devices. If the number of current devices is less than the preset number of devices, it means that there are too few communication devices in the BLE network and optimization is not necessary. If the number of stable devices is less than the preset stable device ratio, it means that the BLE network is not stable enough and is not suitable for optimization. Therefore, the BLE network is only optimized when the number of current devices is not less than the preset number of devices and the number of stable devices is not less than the preset stable device ratio. This allows for dynamic adjustment of the optimization strategy, and optimization is only performed when certain conditions are met, avoiding unnecessary optimization, reducing resource consumption, ensuring the necessity and effectiveness of optimization operations, reducing the impact on existing communication, and ensuring the efficient operation and stability of the BLE network.
[0148] Embodiments of the present invention also provide a non-transitory computer-readable storage medium that can be disposed in an electronic device to store a computer program related to implementing a method in the method embodiments, the computer program being loaded and executed by the processor to implement the method provided in the above embodiments.
[0149] Embodiments of the present invention also provide an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method provided in the above embodiments.
[0150] Embodiments of the present invention also provide a computer program product including program code, which, when the program product is run on an electronic device, causes the electronic device to perform the steps of the methods described above in various exemplary embodiments of the present invention.
[0151] This invention provides a method, electronic device, and storage medium for optimizing a Bluetooth Low Energy (BLE) network. The method is applied to a communication device. If the device is the master device of the BLE network and the BLE network has not been optimized, in response to a new communication device joining the BLE network, the current number of devices is obtained. If the current number of devices is not less than a preset number, the BLE network is optimized according to the initial routing table corresponding to the BLE network. Specifically, an initial network connection graph corresponding to the BLE network is constructed based on the initial routing table. The minimum spanning tree corresponding to the initial network connection graph is used as a new initial network connection graph to update the initial network connection graph. An intermediate routing table is generated based on the new initial network connection graph and sent to all communication devices in the BLE network except the device itself. Each communication device receiving the intermediate routing table determines whether to disconnect its communication connection with other communication devices based on the communication connection relationships recorded in the intermediate routing table, thereby achieving optimization of the BLE network. As can be seen, this invention uses the minimum spanning tree corresponding to the initial network connection graph as the new initial network connection graph, generates an intermediate routing table based on the initial network connection graph, and sends the intermediate routing table to all communication devices in the Bluetooth Low Energy network except itself to optimize the Bluetooth Low Energy network. It can dynamically adjust the network connection relationship and routing strategy, reduce unnecessary communication connections while maintaining communication quality, thereby reducing resource consumption, effectively improving the working efficiency and stability of the Bluetooth Low Energy network, and reducing the negative impacts caused by the Bluetooth Low Energy transmission distance limitation and too many communication device connections.
[0152] While specific embodiments of the invention have been described in detail by way of examples, those skilled in the art should understand that the examples are for illustrative purposes only and are not intended to limit the scope of the invention. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the invention.
Claims
1. A method for optimizing a low-power Bluetooth network, characterized in that, The method is applied to a communication device, and the method includes the following steps: S1. If it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has not been optimized, then when a new communication device joins the Bluetooth Low Energy network, it obtains the current number of devices DQ. DQ is the number of communication devices in the current Bluetooth Low Energy network. The Bluetooth Low Energy network includes several communication devices, and the communication devices establish and maintain communication connections based on the Bluetooth Low Energy protocol. S2. If DQ ≥ YS, then optimize the Bluetooth Low Energy (BLE) network according to the initial routing table corresponding to the BLE network, where YS is the preset number of devices; optimizing the BLE network according to the initial routing table corresponding to the BLE network includes the following steps S21-S23: S21. Construct an initial network connection graph corresponding to the Bluetooth Low Energy network based on the initial routing table of the Bluetooth Low Energy network. The initial network connection graph includes several nodes and edges. Nodes represent communication devices in the Bluetooth Low Energy network, and edges represent direct communication between the two communication devices corresponding to the nodes at both ends of the edge. Each edge is attached with the total communication quality weight of the two communication devices corresponding to the nodes at both ends of the edge. The total communication quality weight is used to measure the communication quality between the two communication devices. S22. Copy the initial network connection graph as the historical network connection graph, and use the minimum spanning tree corresponding to the initial network connection graph as the new initial network connection graph so as to update the initial network connection graph. The minimum spanning tree corresponding to the initial network connection graph contains all the nodes in the initial network connection graph and the edges connecting these nodes, and the sum of the total communication quality weights attached to all edges is minimized. S23. Generate an intermediate routing table based on the new initial network connection graph and send the intermediate routing table to all communication devices in the Bluetooth Low Energy network except itself. The communication devices that receive the intermediate routing table can determine whether to disconnect their communication connection with other communication devices based on the communication connection relationship recorded in the intermediate routing table, so as to optimize the Bluetooth Low Energy network. At the same time, the intermediate routing table is used as the initial routing table corresponding to the Bluetooth Low Energy network. The intermediate routing table records the communication connection relationship between the communication devices corresponding to each node in the initial network connection graph. Step S21 includes the following steps S211-S215: obtaining the total communication quality weights of the two communication devices corresponding to the nodes at both ends of the edge. S211. Take the two communication devices corresponding to the nodes at both ends of the edge as the first initial device and the second initial device, respectively. S212. Obtain the first power level, the first RSSI signal strength, the second power level, and the second RSSI signal strength, wherein the first power level is the power level of the first initial device, the first RSSI signal strength is the RSSI signal strength of the first initial device, the second power level is the power level of the second initial device, and the second RSSI signal strength is the RSSI signal strength of the second initial device. S213. According to the first preset weight influence value mapping list, obtain the first power weight influence value corresponding to the first power and the second power weight influence value corresponding to the second power. The first preset weight influence value mapping list includes several preset power intervals and the first preset weight influence value corresponding to the preset power intervals. When the first power belongs to a certain preset power interval, the first preset weight influence value corresponding to the preset power interval to which the first power belongs is used as the first power weight influence value corresponding to the first power. When the second power belongs to a certain preset power interval, the first preset weight influence value corresponding to the preset power interval to which the second power belongs is used as the second power weight influence value corresponding to the second power. S214. According to the second preset weight influence value mapping list, obtain the first RSSI signal strength weight influence value corresponding to the first RSSI signal strength and the second RSSI signal strength weight influence value corresponding to the second RSSI signal strength. The second preset weight influence value mapping list includes several preset RSSI signal strength intervals and the second preset weight influence values corresponding to the preset RSSI signal strength intervals. When the first RSSI signal strength belongs to a certain preset RSSI signal strength interval, the second preset weight influence value corresponding to the preset RSSI signal strength interval to which the first RSSI signal strength belongs is used as the first RSSI signal strength weight influence value corresponding to the first RSSI signal strength. When the second RSSI signal strength belongs to a certain preset RSSI signal strength interval, the second preset weight influence value corresponding to the preset RSSI signal strength interval to which the second RSSI signal strength belongs is used as the second RSSI signal strength weight influence value corresponding to the second RSSI signal strength. S215. The sum of the communication quality weights corresponding to the first initial device and the second initial device is used as the total communication quality weight representing the communication quality between the first initial device and the second initial device. The communication quality weight corresponding to the first initial device is the difference obtained by subtracting the influence value of the first power weight and the influence value of the first RSSI signal strength weight from the preset communication quality weight. The communication quality weight corresponding to the second initial device is the difference obtained by subtracting the influence value of the second power weight and the influence value of the second RSSI signal strength weight from the preset communication quality weight. The preset communication quality weight used to obtain the communication quality weight corresponding to the first initial device is the same as the preset communication quality weight used to obtain the communication quality weight corresponding to the second initial device.
2. The low-power Bluetooth network optimization method according to claim 1, characterized in that, The initial routing table for a Bluetooth Low Energy (BLE) network records the communication connections between each communication device in the BLE network and all other communication devices.
3. The low-power Bluetooth network optimization method according to claim 1, characterized in that, In a Bluetooth Low Energy (BLE) network, when a new communication device joins the BLE network, the new communication device maintains communication connections with all other communication devices that can establish communication connections with it. At the same time, the maintained communication connections are stored in the initial routing table corresponding to the BLE network.
4. The low-power Bluetooth network optimization method according to claim 1, characterized in that, The smaller the total weight of communication quality, the better the communication quality between the two corresponding communication devices.
5. The low-power Bluetooth network optimization method according to claim 1, characterized in that, The method further includes step S10: S10. If it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has been optimized, then in response to a new communication device joining the Bluetooth Low Energy network, it obtains the current device identifier list and optimizes the Bluetooth Low Energy network based on the current device identifier list. The current device identifier list includes several current device identifiers, which are the identity identifiers of communication devices in the current Bluetooth Low Energy network.
6. The low-power Bluetooth network optimization method according to claim 5, characterized in that, In step S10, optimizing the Bluetooth Low Energy network based on the current device identifier list includes the following steps S11-S13: S11. Obtain the target device identifier list and the target optimization time point. The target device identifier list includes several target device identifiers. The target optimization time point is the time point when the Bluetooth Low Energy network was last optimized. The target device identifier is the identity identifier of the communication device in the Bluetooth Low Energy network at the target optimization time point. S12. Take the symmetric difference between the current device identifier list and the target device identifier list as the intermediate device identifier list, which includes several intermediate device identifiers. S13, When ZJ > YS 0 If A / B > C, the Bluetooth Low Energy (BLE) network is optimized based on the initial routing table corresponding to the BLE network, where ZJ is the time difference between the current time point and the target optimization time point, and YS... 0 The preset time difference is defined as follows: A represents the number of intermediate device identifiers in the intermediate device identifier list; B represents the number of current device identifiers in the current device identifier list; and C represents the preset device quantity change ratio.
7. The low-power Bluetooth network optimization method according to claim 1, characterized in that, The method further includes the following steps S20-S70: S20. If it is the master device of the Bluetooth Low Energy network and the Bluetooth Low Energy network has been optimized, then when the communication device leaves the Bluetooth Low Energy network, the communication device that leaves the Bluetooth Low Energy network will be regarded as the key device and the number of node connections corresponding to the key device will be obtained. The number of node connections is the number of other nodes directly connected to the node corresponding to the key device through the edge in the initial network connection relationship graph. S30. If the number of nodes connected to the critical device is greater than 1, then delete the nodes corresponding to the critical device and the edges connecting the nodes from the historical network connection graph to obtain the first critical network connection graph, and delete the nodes corresponding to the critical device and the edges connecting the nodes from the initial network connection graph to obtain the second critical network connection graph. S40. Mark the edges that exist in the first key network connection graph but not in the second key network connection graph as candidate edges; S50. Mark the candidate edge with the smallest total communication quality weight among all candidate edges as the target edge. S60. The communication devices corresponding to the nodes at both ends of the target edge in the first key network connection diagram are respectively designated as the first intermediate device and the second intermediate device corresponding to the first intermediate device. S70. Send the second intermediate device connection information to the first intermediate device, so that the first intermediate device can establish a communication connection with the corresponding second intermediate device when it receives the second intermediate device connection information, so as to optimize the low power Bluetooth network.
8. A non-transitory computer-readable storage medium, characterized in that, The storage medium stores a computer program, which is loaded and executed by a processor to implement the low-power Bluetooth network optimization method as described in any one of claims 1-7.
9. An electronic device, comprising: A processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that, when the processor executes the computer program, it implements the low-power Bluetooth network optimization method as described in any one of claims 1-7.