A bluetooth connection method and system
By acquiring device identification and environmental information, constructing a three-dimensional verification matrix, calculating device coordinates and interference factors, and dynamically adjusting Bluetooth connection steps, the problem of signal instability and low efficiency in complex environments of traditional Bluetooth connection methods is solved, achieving a significant improvement in stability and success rate.
Patent Information
- Application Number
- CN202510298239.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-13
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2045-03-13
AI Technical Summary
Traditional Bluetooth connection methods suffer from unstable signals, pairing failures, and low connection efficiency in complex environments, lacking flexibility and adaptability, especially in scenarios where multiple devices are connected simultaneously, failing to meet user needs.
By acquiring device identification and environmental information, a three-dimensional verification matrix is constructed, device coordinates and interference factors are calculated, the operation sequence is dynamically adjusted, the pairing step sequence is optimized, the optimal connection strategy is selected, and multiple rounds of verification and iterative optimization are carried out in combination with historical data to ensure data consistency and signal stability.
It significantly improves the stability and success rate of Bluetooth connections, ensuring high efficiency and reliability of connections in complex environments, and overcoming problems such as weak signals, unstable connections, and pairing failures.
Smart Images

Figure CN120201398B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Bluetooth technology, specifically to a Bluetooth connection method and system. Background Technology
[0002] With the widespread application of Bluetooth technology, especially in wireless headphones, smart home devices, and other smart devices, Bluetooth connectivity has become a common wireless communication method. However, despite its widespread use in short-range wireless communication, Bluetooth stability and efficiency remain significant technical challenges.
[0003] Traditional Bluetooth pairing methods typically rely on fixed steps and processes. In different devices and environments, factors such as signal interference and device movement can lead to poor connection quality, pairing failures, or slow connection speeds. To address these issues, some existing technologies have proposed optimization strategies based on device information or environmental characteristics. However, these strategies still lack flexibility and adaptability, especially in complex environments or scenarios with multiple devices connected simultaneously, where the efficiency and stability of Bluetooth connections often fail to meet user needs.
[0004] Furthermore, existing Bluetooth connection methods have relatively simplified verification steps during the pairing process, typically only checking basic signal strength or whether pairing was successful, lacking in-depth analysis of data consistency between devices and sources of environmental interference. Therefore, these methods cannot effectively self-adjust and optimize when faced with complex or variable connection conditions. Summary of the Invention
[0005] This invention provides a Bluetooth connection method and system, the purpose of which is to solve the problems of unstable signal, pairing failure and low connection efficiency of traditional Bluetooth connection methods in complex environments.
[0006] To achieve the above objectives, the first aspect of the present invention provides a Bluetooth connection method, comprising the following steps:
[0007] Obtain the Bluetooth connection information of the headphones, which includes the headphone device identifier and the source device identifier;
[0008] Based on the headphone device identifier and the source device identifier, various corresponding connection strategies are extracted from a preset Bluetooth connection database. Each connection strategy includes multiple Bluetooth pairing steps.
[0009] For each Bluetooth pairing step in the connection strategy, calculate the relative device coordinates, signal strength range, and influence factors of known interference sources between each pair of steps.
[0010] Data consistency verification is performed for each Bluetooth pairing step. The data consistency verification includes constructing a three-dimensional verification matrix, comparing protocol data units, monitoring the Bluetooth frequency hopping sequence matching degree, and dynamically adjusting the operation order according to the verification results.
[0011] The comprehensive weight value of each step is calculated based on the signal strength, pairing success rate and interference risk value. The effective steps are prioritized based on the comprehensive weight value to generate a preliminary optimized pairing step sequence.
[0012] The initial optimized sequence is divided into multiple subsequences for cross-validation. The weights of interference factors are adjusted and the order of steps is rearranged by combining historical connection data. Through multiple rounds of validation and iterative optimization, a corrected paired step sequence is generated.
[0013] The mean signal strength, pairing success rate, and interference factor fluctuation variance were collected from multiple rounds of testing. A normalized fitness function was constructed and each connection strategy was scored.
[0014] The connection strategy with the highest fitness function score is selected as the final target strategy, and the pairing step sequence of that strategy is executed to complete the Bluetooth connection operation.
[0015] Furthermore, the connection strategy includes:
[0016] The source device and the headphone device are selected as the preferred connection group, and the selection is based on the historical connection stability of the devices and the current environmental status.
[0017] Select a communication frequency band that minimizes interference from known interference sources;
[0018] Adjust Bluetooth transmission power based on real-time monitored signal strength;
[0019] Encryptive authentication is performed based on device fingerprint and protocol handshake, and the authentication method is selected by combining historical pairing information;
[0020] Adjust the execution timing of the pairing steps based on the device idle time window and the connection queue length;
[0021] If pairing fails, restart the process and optimize the parameters; if it fails multiple times, switch to a new strategy.
[0022] Furthermore, the relative positions of the devices, the signal strength range, and the influence factors of known interference sources are calculated between each pair of steps, including:
[0023] The relative positions of the equipment coordinates between steps are calculated using a three-dimensional coordinate difference algorithm.
[0024]
[0025] Where, x i yi z i The device coordinates for step i; x j y j z j The device coordinates for step j;
[0026] Calculate the signal strength range using a radio frequency propagation model:
[0027]
[0028] Among them, P t For transmission power, G r Here, d represents the receiver gain, λ represents the device spacing, and λ represents the wavelength.
[0029] The influence factor of the interference source was calculated using the interference superposition model.
[0030]
[0031] Among them, I i,j A represents the interference factor between pairing step i and pairing step j. k Let τ represent the intensity of the k-th interference source, and τ be the distance attenuation coefficient. k Let n be the distance between the interference source and the device, and n be the total number of interference sources.
[0032] Furthermore, methods for performing data consistency verification include:
[0033] Based on the communication timestamp, signal strength fluctuation value, and data packet type parameters of the current Bluetooth pairing step, a three-dimensional verification matrix is constructed, wherein the three dimensions of the three-dimensional verification matrix are respectively mapped to the timestamp interval, the signal strength gradient interval, and the data packet type encoding interval.
[0034] Extract the protocol data units transmitted in the steps, generate the hash value sequence of the corresponding data packet header field, and compare it bit by bit with the standard hash template stored in the preset Bluetooth protocol specification library, and record the hash consistency rate;
[0035] The actual frequency distribution of the Bluetooth frequency hopping sequence is captured in real time, and the standard deviation of its frequency matching with the theoretical frequency hopping sequence within a preset time window is calculated. The theoretical frequency hopping sequence is dynamically generated based on the Bluetooth MAC address and clock offset.
[0036] When the hash consistency rate is lower than the first preset threshold and the frequency point matching standard deviation exceeds the second preset threshold, a dynamic adjustment mechanism is triggered to rearrange the order of unfinished operations in the current step, prioritize the execution of the sub-operation with the highest protocol data unit verification pass rate, and mark the communication frequency band with the lowest frequency point matching degree as a disabled interval.
[0037] Furthermore, the method for calculating the comprehensive weight value for each step based on signal strength, pairing success rate, and interference risk value includes:
[0038] For each Bluetooth pairing step, extract the average signal strength from its historical connection records, the current real-time signal strength sample value, and the preset signal strength attenuation coefficient, and calculate the normalized signal strength index using the following formula:
[0039]
[0040] Among them, S real For real-time signal strength, S hist The historical average is given, α is the attenuation coefficient, and σ is the environmental noise compensation value.
[0041] The ratio of the number of successful pairings to the total number of attempts within a preset time period is obtained as the pairing success rate. An interference risk value is calculated based on the type of interference source, interference intensity, and duration, where:
[0042] R isk =Σ(I type ×I intensity ×T duration )
[0043] Among them, I type For the interference source type weight, I intensity T is the strength coefficient. duration The duration of the interference;
[0044] Set the weighting coefficient W for signal strength, pairing success rate, and interference risk value. s W p W r Calculate the comprehensive weight value W according to the formula. total :
[0045] W total =(S norm ×W s )+(P rate ×W p )-(R isk ×W r )
[0046] The combined weight values of all steps under the same connection strategy are normalized so that the sum of the combined weight values is 1, thus generating a weight distribution vector.
[0047] Furthermore, prioritizing effective steps based on comprehensive weight values and generating a preliminary optimized sequence of paired steps includes the following steps:
[0048] All steps in the same connection strategy are sorted in descending order according to the normalized comprehensive weight value, and steps with weight values higher than the preset effective threshold are selected as the set of effective steps.
[0049] Traverse the set of valid steps and construct a directed acyclic graph based on the device operation dependencies between steps, where nodes represent steps and edges represent the execution order constraints of steps;
[0050] An initial sequence is generated based on the topological sorting result of the directed acyclic graph, and Bluetooth protocol switching conflicts between adjacent steps in the initial sequence are detected. If a conflict exists, a protocol adaptation buffer step is inserted.
[0051] Based on the weight distribution vector of the steps, the steps in the sequence whose continuous weight difference exceeds the preset fluctuation threshold are locally rearranged, and the high-weight steps are concentrated in the time interval with the highest average signal strength.
[0052] The rearranged sequence is matched with the historical best sequence in the Bluetooth connection database using the longest common subsequence. A dynamic priority boosting flag is applied to the non-matching segments to generate a preliminary optimized pairing step sequence.
[0053] Furthermore, dividing the initially optimized sequence into multiple subsequences for cross-validation and generating the corrected pairing step sequence includes the following steps:
[0054] Based on the protocol switching point and device operation type, the preliminary optimization sequence is divided into at least three consecutive subsequences, each containing 3-5 steps and covering the complete protocol interaction cycle;
[0055] Perform cross-validation on adjacent subsequences, swap the step groups of the first and last subsequences and inject test data packets, monitor the protocol response latency and packet loss rate of the swapped subsequences, and calculate the cross-matching score;
[0056] Extract interference scenario records that match the current device identifier from the historical connection database, calculate the actual interference factor deviation value of each step under the same interference source, and adjust the current interference factor weight according to the formula.
[0057]
[0058] Among them, W r D represents the initial weighting coefficient of the interference factor. hist D is the historical deviation mean. current T represents the current measured deviation. action The duration of the interference is the percentage, and ∈ is the smoothing coefficient;
[0059] Based on the adjusted interference factor weights, the steps of subsequences with matching scores below the threshold in cross-validation are reorganized. A greedy algorithm is used to prioritize the replacement of high-interference-risk steps while maintaining topological dependence.
[0060] The recombined subsequences are reassembled according to the original split points, and multiple rounds of conflict detection iterations are performed. After each round of iteration, the steps that cause protocol conflicts are deleted and the backup steps in the historical best sequence are added to generate a corrected pairing step sequence.
[0061] Furthermore, constructing a normalized fitness function and scoring each connection strategy includes the following steps:
[0062] Collect the average signal strength μ of each connection strategy in multiple rounds of testing. s Matching success rate P rate and the variance of the interference factor Extract the extreme values [μ] of the corresponding metrics from the historical best connection records. max ,μ min ]、
[0063] [P max ,P min ]、
[0064] For each indicator, range normalization is performed using the following formula:
[0065]
[0066] Where S′ represents the normalized signal strength index, μ max and μ min These represent the maximum and minimum signal strength values in the historical best connection records, respectively; P′ represents the normalized pairing success rate index, and R′ represents the normalized interference stability index.
[0067] Set signal strength weight W s ′、 Matching success rate weight W p ′、Disturbance stability weight W r ', Calculate the fitness function value F according to the formula:
[0068] F=(S′×W s ′)+(P′×W p ′)+(R′×W r ′)
[0069] The fitness function values of all test rounds under the same connection strategy are weighted and averaged. The weight is the spectral similarity coefficient between the test environment of each round and the current real-time environment. The final strategy score is generated and sorted in descending order.
[0070] To achieve the above objectives, a second aspect of the present invention provides a Bluetooth connection system, comprising the following modules:
[0071] The acquisition unit is used to acquire Bluetooth connection information of the headphones, the Bluetooth connection information including headphone device identifier and source device identifier;
[0072] The database unit is used to extract various corresponding connection strategies from a preset Bluetooth connection database based on the headphone device identifier and the source device identifier. Each connection strategy includes multiple Bluetooth pairing steps.
[0073] The calculation unit is used to calculate the relative device coordinates, signal strength range, and influence factors of known interference sources between each pair of steps for the Bluetooth pairing steps in each connection strategy.
[0074] The data consistency verification unit is used to perform data consistency verification for each Bluetooth pairing step. The data consistency verification includes constructing a three-dimensional verification matrix, comparing protocol data units, monitoring the Bluetooth frequency hopping sequence matching degree, and dynamically adjusting the operation order according to the verification results.
[0075] The weight calculation unit is used to calculate the comprehensive weight value of each step based on the signal strength, pairing success rate and interference risk value, prioritize the effective steps based on the comprehensive weight value, and generate a preliminary optimized pairing step sequence.
[0076] The validation unit is used to divide the initial optimized sequence into multiple subsequences for cross-validation, adjust the weight of interference factors and rearrange the step order by combining historical connection data, and generate a corrected paired step sequence through multiple rounds of validation iteration optimization.
[0077] The scoring unit is used to collect the mean signal strength, pairing success rate and interference factor fluctuation variance in multiple rounds of testing, construct a normalized fitness function and score each connection strategy;
[0078] The strategy selection unit is used to select the connection strategy with the highest fitness function score as the final target strategy, and execute the pairing step sequence of the strategy to complete the Bluetooth connection operation.
[0079] Furthermore, the database unit is used to store Bluetooth connection information and corresponding connection strategies between different devices; the data consistency verification unit is used to verify the Bluetooth pairing steps through real-time communication with the devices to ensure the correctness and consistency of device information during the pairing process; the scoring unit is used to comprehensively evaluate the performance of each connection strategy based on signal strength, pairing success rate, and interference factor fluctuation variance, and to rank them according to the evaluation results; the verification unit is used to iteratively optimize the results of multiple rounds of cross-validation to gradually improve the success rate and stability of Bluetooth connections.
[0080] The beneficial effects of this invention are:
[0081] Compared with existing technologies, the Bluetooth connection method and system provided by this invention introduces a multi-strategy extraction and dynamic optimization mechanism, which can flexibly adjust the pairing steps of Bluetooth connection according to the specific device identifier, environmental factors, and the influence of interference sources. By extracting multiple connection strategies from a preset Bluetooth connection database and calculating a comprehensive weight value based on parameters such as device coordinates, signal strength, pairing success rate, and interference factor, effective steps are prioritized, significantly improving connection stability and success rate. Simultaneously, this invention ensures data consistency in the pairing process through a three-dimensional verification matrix and frequency hopping sequence matching degree monitoring, dynamically adjusting the operation order to avoid failures caused by fixed procedures. Multi-round cross-validation and iterative optimization further eliminate the negative impact of interference sources on the connection, and finally selects the optimal strategy through fitness function scoring, ensuring the efficiency and reliability of the connection process. Therefore, this invention can significantly improve Bluetooth connection performance in complex environments, overcoming problems such as weak signal, unstable connection, and pairing failure in existing technologies. Attached Figure Description
[0082] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below.
[0083] Figure 1 This is a flowchart of a Bluetooth connection method disclosed in an embodiment of the present invention.
[0084] Figure 2 This is an organizational framework diagram of a connection strategy disclosed in an embodiment of the present invention.
[0085] Figure 3 This is a flowchart of a data consistency verification method disclosed in an embodiment of the present invention.
[0086] Figure 4 This is a flowchart of a priority sorting and preliminary optimization pairing step sequence disclosed in an embodiment of the present invention.
[0087] Figure 5 This is a framework diagram of a Bluetooth connection system disclosed in an embodiment of the present invention.
[0088] Figure 6 This is a comparison chart of connection latency and packet loss rate in a simulated experimental environment disclosed in an embodiment of the present invention. Detailed Implementation
[0089] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. The terms "and / or" in the various embodiments of this specification mean at least one of the preceding and following terms.
[0090] like Figure 1 As shown, the present invention provides a Bluetooth connection method, which can be executed by a terminal device; in other words, the method can be executed by software or hardware installed on the terminal device. The method includes the following steps:
[0091] Step S100: Obtain the Bluetooth connection information of the headphones, wherein the Bluetooth connection information includes the headphone device identifier and the source device identifier;
[0092] During the pairing process between Bluetooth devices, there are often situations where device identification is unclear or cannot be accurately identified, which can lead to delays or failures in the connection process. Especially in a multi-device environment, accurate acquisition of device identification is crucial for subsequent pairing and connection operations. This step is the initialization phase of the Bluetooth connection, which requires collecting the identification information of the headset and the source device (such as a mobile phone or computer). The device identification is stored in the form of key-value pairs.
[0093] Headphone device identifier: including Bluetooth MAC address, firmware version number, device type (such as TWS headphones), etc., which is read from the headphone chip through the HCI_Read_BD_ADDR command of the Bluetooth protocol stack.
[0094] Source device identifier: This includes the source device's Bluetooth address, operating system type (such as Android / iOS), Bluetooth protocol version (such as Bluetooth 5.3), etc., which can be obtained through system APIs (such as Android's BluetoothAdapter.getAddress()).
[0095] Step S200: Based on the headphone device identifier and the source device identifier, extract the corresponding multiple connection strategies from the preset Bluetooth connection database. Each connection strategy includes multiple Bluetooth pairing steps.
[0096] In practical applications, different Bluetooth devices face varying environmental conditions during connection, such as signal strength, distance between devices, and interference sources. Traditional Bluetooth pairing methods typically rely on fixed pairing steps, neglecting device characteristics and environmental changes. This leads to low stability and efficiency in connection processes under certain complex environments. Furthermore, the historical connection stability between devices is also a significant factor affecting connection quality. The lack of flexible connection strategies prevents the connection process from effectively adjusting to changes in devices and the environment.
[0097] In this step, by extracting multiple connection strategies from a preset Bluetooth connection database and combining them with the headphone device identifier and the source device identifier, the optimal pairing strategy can be flexibly selected based on the actual device's historical connection status and the current environmental conditions. This allows the connection process to adaptively adjust to different environmental conditions, improving connection success rate and stability. In complex wireless environments, this invention can significantly reduce connection failures and inefficient connections, optimize the pairing process between Bluetooth devices, and enhance the user experience.
[0098] Step S300: For the Bluetooth pairing steps in each connection strategy, calculate the relative device coordinates, signal strength range, and influence factors of known interference sources between each pair of steps;
[0099] In existing technologies, most Bluetooth pairing methods rely solely on signal strength and basic pairing algorithms, neglecting changes in the relative positions of devices and the impact of interference sources on signal transmission. In step S300 of this invention, for each Bluetooth pairing step in each connection strategy, the relative positions of the devices, the signal strength range, and the influence factors of known interference sources are calculated between each pair of steps. By incorporating the relative positions of the devices and environmental interference factors, the communication quality between devices during each pairing step can be more accurately evaluated, and dynamic adjustments can be made based on these factors. For example, the relative positions of devices affect signal attenuation, and the presence of interference sources introduces noise.
[0100] Step S400: Perform data consistency verification for each Bluetooth pairing step. The data consistency verification includes constructing a three-dimensional verification matrix, comparing protocol data units, monitoring the Bluetooth frequency hopping sequence matching degree, and dynamically adjusting the operation order according to the verification results.
[0101] In this step, the three-dimensional verification matrix is used to represent and verify multiple communication parameters between devices, including the combined effects of factors such as the relative position of the devices, signal strength, and interference sources. By analyzing these factors in a matrix form, multi-dimensional analysis is performed to ensure data consistency during the pairing process.
[0102] The protocol data unit comparison checks whether the information between devices is consistent during the protocol handshake process, ensuring that the data exchange between devices conforms to the Bluetooth protocol specification and avoiding pairing failures or connection problems caused by protocol inconsistencies.
[0103] Monitoring Bluetooth frequency hopping sequence matching involves synchronizing Bluetooth frequency hopping between devices. Bluetooth devices frequently hop frequencies during communication, and ensuring the matching of the frequency hopping sequence can reduce the impact of interference sources and maintain stable signal transmission. Therefore, these three verifications can comprehensively ensure communication quality and data consistency during Bluetooth pairing, avoiding connection failures due to protocol incompatibility or environmental interference.
[0104] Step S500: Calculate the comprehensive weight value of each step based on the signal strength, pairing success rate and interference risk value, prioritize the effective steps based on the comprehensive weight value, and generate a preliminary optimized pairing step sequence;
[0105] The overall weight value is a quantitative assessment of the importance and effectiveness of each Bluetooth pairing step. It is calculated based on multiple factors, including signal strength, pairing success rate, and interference risk. These factors affect the stability and success rate of the pairing steps; therefore, by assigning a weight value to each factor, the system can comprehensively evaluate the priority of each step. For example, steps with stronger signal strength are given higher weights, while steps with higher interference risk are given lower weights. Ultimately, the overall weight value helps the system determine which steps are more critical and which should be prioritized, thereby optimizing the pairing process and improving overall pairing efficiency and success rate.
[0106] Step S600: Divide the initial optimized sequence into multiple subsequences for cross-validation, adjust the interference factor weights and rearrange the step order based on historical connection data, and generate the corrected paired step sequence through multiple rounds of validation and iteration optimization.
[0107] The optimized pairing step sequence is divided into multiple segments (subsequences), and each subsequence is independently validated. Cross-validation allows for the evaluation of the performance of different subsequences and analysis of each subsequence's behavior in the actual pairing process. This helps identify potential optimization problems or interference between steps, ensuring the reliability and stability of the pairing process under different conditions. The results of cross-validation help identify which subsequences or steps perform best under specific conditions, further optimizing the entire pairing process.
[0108] Adjusting the interference factor weights and rearranging the step order refers to dynamically adjusting the weights of interference factors (such as environmental interference, device distance, signal attenuation, etc.) in each step based on the results of cross-validation. By analyzing the fluctuations of interference factors in the test results and their impact on the pairing effect, it is possible to more accurately assess which steps are more susceptible to interference. After adjusting the interference factor weights, the system will rearrange the order of the pairing steps, prioritizing those steps with less interference and higher efficiency.
[0109] Step S700: Collect the mean signal strength, pairing success rate and interference factor fluctuation variance in multiple rounds of testing, construct a normalized fitness function and score each connection strategy;
[0110] The normalized fitness function is used to uniformly score multiple connectivity strategies. This function standardizes multiple factors, such as mean signal strength, pairing success rate, and interference factor variance, ensuring uniformity in the dimensions of each evaluation metric. This makes comparisons between different strategies fairer and more consistent. The normalization process converts parameters of different magnitudes into relative values, eliminating inherent differences between parameters and ensuring that the final fitness score reflects the overall merits of each connectivity strategy. The score is then assigned to each strategy based on the normalized fitness function; a higher score indicates that the strategy provides a more stable and efficient Bluetooth connection in the current environment. This scoring mechanism quantifies the performance of each connectivity strategy, ultimately selecting the optimal one.
[0111] Step S800: Select the connection strategy with the highest fitness function score as the final target strategy, and execute the pairing step sequence of the strategy to complete the Bluetooth connection operation.
[0112] In this embodiment, as described in step S200 above, the connection strategy (see...) Figure 2 )include:
[0113] Step S201: Select the preferred connection device group for the source device and the headphone device. The selection is based on the historical connection stability of the devices and the current environmental status.
[0114] Step S202: Select a communication frequency band that minimizes interference with known interference sources;
[0115] Step S203: Adjust the Bluetooth transmission power based on the real-time monitored signal strength;
[0116] Step S204: Perform encrypted authentication based on device feature fingerprint and protocol handshake, and select an authentication method in combination with historical pairing information;
[0117] Step S205: Adjust the execution sequence of the pairing steps according to the device idle time window and the connection queue length;
[0118] Step S206: Restart the process and optimize parameters if pairing fails. If it fails multiple times, switch to a new strategy.
[0119] In this embodiment, as described in step S300 above, calculating the relative position of device coordinates, signal strength range, and influence factors of known interference sources between each pair of steps includes:
[0120] The relative positions of the equipment coordinates between steps are calculated using a three-dimensional coordinate difference algorithm.
[0121]
[0122] Where, x i y i z i The device coordinates for step i; x j y j z j The device coordinates for step j;
[0123] Calculate the signal strength range using a radio frequency propagation model:
[0124]
[0125] Among them, P t For transmission power, G r Here, d represents the receiver gain, λ represents the device spacing, and λ represents the wavelength.
[0126] The influence factor of the interference source was calculated using the interference superposition model.
[0127]
[0128] Among them, I i,j A represents the interference factor between pairing step i and pairing step j. k Let τ represent the intensity of the k-th interference source, and τ be the distance attenuation coefficient. k Let n be the distance between the interference source and the device, and n be the total number of interference sources.
[0129] In this embodiment, as described in step S400 above, data consistency verification is performed (see...). Figure 3 The methods include:
[0130] Step S401: Based on the communication timestamp, signal strength fluctuation value and data packet type parameters of the current Bluetooth pairing step, construct a three-dimensional verification matrix, wherein the three dimensions of the three-dimensional verification matrix are respectively mapped to the timestamp interval, the signal strength gradient interval and the data packet type encoding interval;
[0131] Step S402: Extract the protocol data units transmitted in the previous step, generate the hash value sequence of the corresponding data packet header field, and compare it bit by bit with the standard hash template stored in the preset Bluetooth protocol specification library, and record the hash consistency rate.
[0132] Step S403: Real-time capture of the actual frequency distribution of the Bluetooth frequency hopping sequence, and calculation of the standard deviation of its frequency matching with the theoretical frequency hopping sequence within a preset time window. The theoretical frequency hopping sequence is dynamically generated based on the Bluetooth MAC address and clock offset.
[0133] Step S404: When the hash consistency rate is lower than the first preset threshold and the frequency point matching standard deviation exceeds the second preset threshold, a dynamic adjustment mechanism is triggered to rearrange the order of operations that have not been completed in the current step, prioritize the execution of the sub-operation with the highest protocol data unit verification pass rate, and mark the communication frequency band with the lowest frequency point matching degree as a disabled interval.
[0134] Understandably, the three dimensions of the three-dimensional verification matrix correspond to key factors that may affect data consistency during Bluetooth pairing: communication time, signal strength, and data packet type. The first dimension is the timestamp interval, which records the time of each pairing step and helps analyze temporal fluctuations during pairing. The second dimension is the signal strength gradient interval, representing changes in signal strength during pairing and used to analyze trends of signal attenuation or enhancement. The third dimension is the data packet type encoding interval, used to distinguish different types of data packets, ensuring that different data transmission processes follow the expected protocol. By mapping these three dimensions to the matrix, the stability of each pairing step can be comprehensively evaluated, and dynamic optimization can be performed based on this multi-dimensional information.
[0135] The hash sequence in the data packet header field is an encrypted processing of the header content of the transmitted data packets. By generating a hash sequence, it is ensured that information is not tampered with or lost during data transmission. Each data packet generates a unique hash value during the Bluetooth pairing process. This hash value contains the data packet's identity and content characteristics. The process of comparing the hash value bit by bit with the standard hash template stored in the preset Bluetooth protocol specification library is used to ensure that the data transmitted by the devices during pairing conforms to the Bluetooth protocol specification. If the hash value in the data packet header does not match the standard template, it indicates that there has been a deviation or error in the data transmission. Therefore, bit by bit comparison is performed to ensure that the data transmission in each step of the pairing process is completely consistent and conforms to the protocol requirements.
[0136] Frequency matching standard deviation is a statistical value that measures the deviation between the actual and theoretical frequency points of a Bluetooth device during frequency hopping. In Bluetooth communication, devices transmit signals according to specific frequency hopping patterns. The theoretical frequency hopping sequence is dynamically generated based on the Bluetooth MAC address and the device clock offset to ensure that devices avoid mutual interference. By calculating the frequency matching standard deviation, the degree of matching between the actual and theoretical frequency points can be determined. If the standard deviation is too large, it indicates that the device's frequency hopping sequence has not been accurately synchronized with the theoretical sequence, which may lead to frequency conflicts or interference, thereby affecting connection stability.
[0137] Based on the communication timestamp, signal strength fluctuation value, and data packet type parameters of the current Bluetooth pairing step, construct a three-dimensional verification matrix according to the following steps:
[0138] First, define the three dimensions of a three-dimensional matrix:
[0139] Timestamp range: Based on the timestamp of each pairing step in the Bluetooth pairing process, set an appropriate time window (e.g., at the second or millisecond level) to divide the timestamps in the pairing process into multiple time periods.
[0140] Signal strength gradient range: Based on the changes in signal strength during the pairing process, the minimum and maximum values of the signal strength are set and divided into multiple gradient ranges (e.g., low, medium, high).
[0141] Data packet type encoding range: Based on different data packet types in the Bluetooth protocol (such as synchronization, data, acknowledgment packets, etc.), their encoding values are divided into multiple categories or ranges.
[0142] During the pairing process, relevant communication data is collected in real time. Each time a pairing step is executed, the timestamp, signal strength, and data packet type are recorded. Each recorded timestamp, signal strength, and data packet type is mapped to the aforementioned defined range. For example, if the timestamp is 10ms, the signal strength is -50dBm, and the data packet type is "acknowledgment packet," then it is mapped to the corresponding time interval, signal gradient, and data packet type encoding range, respectively.
[0143] Based on the timestamp, signal strength, and data packet type of each pairing step, the data is mapped to the corresponding position in a three-dimensional matrix. For example, if the timestamp belongs to the range [0-100ms], the signal strength belongs to the range [-60dBm, -50dBm], and the data packet type belongs to the "data packet" category, then a value is filled in the corresponding position in the matrix (e.g., 1 indicates valid data, 0 indicates invalid data). The corresponding signal strength, timestamp, and data packet type are recorded in each matrix element, and the entire three-dimensional matrix is gradually filled.
[0144] A three-dimensional verification matrix can be used to verify the matching degree and consistency between different time periods, signal strengths, and data packet types. If the verification value of a certain matrix area is abnormal (e.g., abnormal changes in signal strength or mismatched data packet types), analysis is required to identify possible sources of interference or errors, and then adjust the pairing steps accordingly.
[0145] In this embodiment, as described in step S500 above, the method for calculating the comprehensive weight value for each step based on signal strength, pairing success rate, and interference risk value includes:
[0146] For each Bluetooth pairing step, extract the average signal strength from its historical connection records, the current real-time signal strength sample value, and the preset signal strength attenuation coefficient, and calculate the normalized signal strength index using the following formula:
[0147]
[0148] Among them, S real For real-time signal strength, S hist The historical average is given, α is the attenuation coefficient, and σ is the environmental noise compensation value.
[0149] The ratio of the number of successful pairings to the total number of attempts within a preset time period is obtained as the pairing success rate. An interference risk value is calculated based on the type of interference source, interference intensity, and duration, where:
[0150] R isk =∑(I type ×I intensity ×T duration )
[0151] Among them, I type For the interference source type weight, I intensity T is the strength coefficient. duration The duration of the interference;
[0152] Set the weighting coefficient W for signal strength, pairing success rate, and interference risk value. s W p W r Calculate the comprehensive weight value W according to the formula. total :
[0153] W total =(S norm ×W s )+(P rate ×W p )-(R isk ×W r )
[0154] The combined weight values of all steps under the same connection strategy are normalized so that the sum of the combined weight values is 1, thus generating a weight distribution vector.
[0155] In this embodiment, as described in step S500 above, the effective steps are prioritized based on the comprehensive weight value, and a preliminary optimized sequence of paired steps is generated (see...). Figure 4 This includes the following steps:
[0156] Step S501: Sort all steps in the same connection strategy in descending order according to the normalized comprehensive weight value, and select the steps with weight values higher than the preset effective threshold as the effective step set.
[0157] Step S502: Traverse the set of valid steps and construct a directed acyclic graph based on the device operation dependencies between steps, where nodes represent steps and edges represent the execution order constraints of steps;
[0158] Step S503: Generate an initial sequence based on the topological sorting result of the directed acyclic graph, and detect Bluetooth protocol switching conflicts between adjacent steps in the initial sequence. If a conflict exists, insert a protocol adaptation buffer step.
[0159] Step S504: Based on the weight distribution vector of the steps, the step segments in the sequence whose continuous weight difference exceeds the preset fluctuation threshold are locally rearranged, and the high-weight steps are concentrated in the time interval with the highest average signal strength.
[0160] Step S505: Match the rearranged sequence with the historical best sequence in the Bluetooth connection database using the longest common subsequence, apply a dynamic priority boosting flag to the non-matching segments, and generate a preliminary optimized pairing step sequence.
[0161] Understandably, a Directed Acyclic Graph (DAG) is used to represent the dependencies and execution order between Bluetooth pairing steps. Each pairing step is considered a node in the graph, and the dependencies between steps are represented by directed edges, where each edge indicates that one step must be executed before another. Since the execution of some steps in the Bluetooth pairing process depends on the results of preceding steps, these dependencies form a directed graph. Furthermore, to avoid cyclic dependencies in the execution order (i.e., the inability to form a clear execution order), the graph is required to be acyclic. By constructing a DAG, the system can clearly show the sequential relationships between pairing steps, ensuring that steps are executed in the correct order and avoiding pairing failures or inefficiencies due to step conflicts or improper order.
[0162] In this embodiment, as described in step S600 above, dividing the initial optimized sequence into multiple sub-sequences for cross-validation and generating the corrected pairing step sequence includes the following steps:
[0163] Step S601: Based on the protocol switching point and device operation type, divide the preliminary optimization sequence into at least three consecutive subsequences. Each subsequence contains 3-5 steps and covers the complete protocol interaction cycle.
[0164] Step S602: Perform cross-validation on adjacent subsequences, swap the step groups of the first and last subsequences and inject test data packets, monitor the protocol response latency and packet loss rate of the swapped subsequences, and calculate the cross-matching score.
[0165] Step S603: Extract interference scene records that match the current device identifier from the historical connection database, calculate the actual interference factor deviation value of each step under the same interference source, and adjust the current interference factor weight according to the formula.
[0166]
[0167] Among them, W r D represents the initial weighting coefficient of the interference factor. hist D is the historical deviation mean. current T represents the current measured deviation. action The duration of the interference is the percentage, and ∈ is the smoothing coefficient;
[0168] Step S604: Based on the adjusted interference factor weights, the subsequences with matching scores below the threshold in cross-validation are reorganized. A greedy algorithm is used to prioritize the replacement of high-interference-risk steps while maintaining topological dependence.
[0169] Step S605: Reassemble the recombined subsequences according to the original split points, perform multiple rounds of conflict detection iterations, delete the steps that cause protocol conflicts after each iteration, and supplement the backup steps in the historical best sequence to generate a corrected pairing step sequence.
[0170] In step S604, the greedy algorithm, based on the adjusted interference factor weights, prioritizes moving steps with high interference risk to less sensitive positions while maintaining the topological dependencies between steps. Specifically, the algorithm assesses the interference risk of each step and selects those steps with higher interference factors, replacing them with steps that have a smaller impact on the system, thereby reducing the negative impact of these steps on the pairing process.
[0171] In this embodiment, as described in step S700 above, constructing the normalized fitness function and scoring each connection strategy includes the following steps:
[0172] Collect the average signal strength μ of each connection strategy in multiple rounds of testing. s Matching success rate P rate and the variance of the interference factor Extract the extreme values [μ] of the corresponding metrics from the historical best connection records. max ,μ min ]、
[0173] [P max ,P min ]、
[0174] For each indicator, range normalization is performed using the following formula:
[0175]
[0176] Where S′ represents the normalized signal strength index, μ max and μ min These represent the maximum and minimum signal strength values in the historical best connection records, respectively; P′ represents the normalized pairing success rate index, and R′ represents the normalized interference stability index.
[0177] Set signal strength weight W s ′、 Matching success rate weight W p ′、Disturbance stability weight W r ', Calculate the fitness function value F according to the formula:
[0178] F=(S′×W s ′)+(P′×W p ′)+(R′×W r ′)
[0179] The fitness function values of all test rounds under the same connection strategy are weighted and averaged. The weight is the spectral similarity coefficient between the test environment of each round and the current real-time environment. The final strategy score is generated and sorted in descending order.
[0180] In one embodiment, such as Figure 5 As shown, a Bluetooth connectivity system is provided, including:
[0181] The acquisition unit 100 is used to acquire Bluetooth connection information of the earphone, the Bluetooth connection information including earphone device identifier and source device identifier;
[0182] Database unit 200 is used to extract various corresponding connection strategies from a preset Bluetooth connection database based on the headphone device identifier and the source device identifier, each connection strategy including multiple Bluetooth pairing steps;
[0183] The calculation unit 300 is used to calculate the relative device coordinates, signal strength range, and influence factors of known interference sources between each pair of steps for the Bluetooth pairing steps in each connection strategy.
[0184] The data consistency verification unit 400 is used to perform data consistency verification for each Bluetooth pairing step. The data consistency verification includes constructing a three-dimensional verification matrix, comparing protocol data units, monitoring the Bluetooth frequency hopping sequence matching degree, and dynamically adjusting the operation order according to the verification results.
[0185] The weight calculation unit 500 is used to calculate the comprehensive weight value of each step based on the signal strength, pairing success rate and interference risk value, prioritize the effective steps based on the comprehensive weight value, and generate a preliminary optimized pairing step sequence.
[0186] The verification unit 600 is used to divide the initial optimized sequence into multiple subsequences for cross-validation, adjust the weight of interference factors and rearrange the step order by combining historical connection data, and generate a corrected paired step sequence through multiple rounds of verification iteration optimization.
[0187] The scoring unit 700 is used to collect the mean signal strength, pairing success rate and interference factor fluctuation variance in multiple rounds of testing, construct a normalized fitness function and score each connection strategy;
[0188] The strategy selection unit 800 is used to select the connection strategy with the highest fitness function score as the final target strategy, and execute the pairing step sequence of the strategy to complete the Bluetooth connection operation.
[0189] To verify the superiority of the proposed Bluetooth connection method over existing technologies, experiments were conducted in a simulated environment. First, two devices supporting the Bluetooth 5.0 protocol were selected as experimental subjects: a source device and an earphone device. The source device was a Huawei P40 (a mobile phone running Android 10 and supporting Bluetooth 5.0), and the earphone device was a Sony WH-1000XM4 (Bluetooth earphone, supporting Bluetooth 5.0). Tests were conducted in normal, weak signal, and high interference environments.
[0190] Normal environment: The test was conducted in a normal indoor environment without any sources of interference, simulating a common home or office environment.
[0191] Weak signal environment: By increasing the distance between devices, an environment with a weak Bluetooth signal is simulated.
[0192] High-interference environment: By introducing multiple Wi-Fi signals, microwave ovens, and other devices, a high-interference wireless environment is simulated to increase potential interference sources during Bluetooth connection.
[0193] In each environment, Bluetooth pairing was performed using the source device and the earphone device. For the control group (existing technology), conventional Bluetooth pairing methods were used directly, while the experimental group adopted the Bluetooth connection method proposed in this invention.
[0194] Record data such as Bluetooth pairing success rate, connection latency, signal strength fluctuation, and packet loss rate for each pairing. Perform 30 pairing tests in each test environment, and collect and record the results.
[0195] During the experiment, all experimental data were monitored using the device's Bluetooth debugging tool to ensure data accuracy.
[0196] Through the above experimental steps, the performance of different technical methods in different environments can be compared, verifying the superiority of the method of the present invention.
[0197] The following are some of the data obtained from the experiment. The experiment was conducted multiple times in both normal and interference environments. The pairing process for each experimental group involved 30 measurements. The results are shown in the table below:
[0198] Table 1. 30 tests under normal and interference environments.
[0199]
[0200] Experimental data shows that the method of this invention has a higher pairing success rate compared to existing technologies. In a simulated interference environment, the pairing success rate of existing technologies drops to 85%, while the method of this invention, through dynamic adjustment of pairing steps and interference factor optimization, increases the pairing success rate to 98%. This difference indicates that the method of this invention can more effectively address signal attenuation and interference problems in complex environments, thereby improving the probability of successful pairing.
[0201] Based on the connection latency data, the method of this invention significantly reduces the pairing completion time. In interference environments, the connection latency of existing technologies is 3.5 seconds, while the method of this invention reduces the connection latency to 2.1 seconds by optimizing the step sequencing and adjusting the connection strategy in real time, representing an improvement of 40%. This result demonstrates that the method of this invention can complete the Bluetooth pairing process more efficiently, especially in complex wireless environments, reducing latency caused by unnecessary steps and waiting times.
[0202] In signal strength tests, the method of this invention demonstrated significantly stronger signal strength. Existing technologies perform poorly in environments with weak signal strength, while the method of this invention maintains higher signal strength by dynamically adjusting Bluetooth transmit power and interference factor optimization, thereby improving connection stability. Experimental data shows that the method of this invention improves signal strength by 10 dBm, which has a significant effect on improving connection stability and data transmission speed.
[0203] Experimental results on packet loss rate also show that the method of the present invention can better cope with environmental interference and reduce packet loss during data transmission. The packet loss rate of the prior art is 12%, while the method of the present invention reduces it to 3%. This improvement is mainly due to the monitoring of the matching degree of Bluetooth frequency hopping sequence, the optimization of interference factor, and the improvement of signal strength, thereby significantly reducing packet loss in data transmission.
[0204] Figure 6 This is a comparison of connection latency and packet loss rate under simulated experimental conditions. The left side of the graph shows the connection latency comparison in normal, weak signal, and high interference environments. The experimental group has a significantly lower latency than the control group, indicating that the method of this invention can effectively reduce connection latency. The right side of the graph shows the packet loss rate comparison under different environments. The packet loss rate of the experimental group is much lower than that of the control group, proving that the method of this invention has a significant advantage in reducing packet loss.
[0205] Analysis of experimental data and simulation results leads to the conclusion that the Bluetooth connection method proposed in this invention exhibits significant advantages over existing technologies in key performance indicators such as pairing success rate, connection latency, signal strength, and packet loss rate. Particularly in complex interference environments, this method effectively reduces pairing failures and connection latency, improving the stability and efficiency of Bluetooth connections. Therefore, this method has high practical value and can significantly enhance the connection performance between Bluetooth devices.
[0206] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0207] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0208] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0209] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0210] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A Bluetooth connection method, characterized by, The method comprises the following steps: Obtaining Bluetooth connection information of the earphone, the Bluetooth connection information comprising an earphone device identifier and a source device identifier; Based on the earphone device identifier and the source device identifier, extracting corresponding connection strategies from a preset Bluetooth connection database, each connection strategy comprising a plurality of Bluetooth pairing steps; For each Bluetooth pairing step in each connection strategy, calculating the relative position of the device coordinates, the signal strength range and the influence factor of the known interference source between each pair of steps; Performing data consistency verification on each Bluetooth pairing step, the data consistency verification comprising constructing a three-dimensional verification matrix, comparing protocol data units, monitoring the matching degree of the Bluetooth frequency hopping sequence, and dynamically adjusting the operation sequence according to the verification result; According to the signal strength, the pairing success rate and the interference risk value, calculating the comprehensive weight value of each step, prioritizing the effective steps based on the comprehensive weight value, and generating a preliminary optimized pairing step sequence; Dividing the preliminary optimized pairing step sequence into a plurality of sub-sequences for cross-validation, adjusting the interference factor weight and rearranging the step sequence in combination with historical connection data, and generating a corrected pairing step sequence through multiple rounds of verification iteration optimization; Collecting the mean value of the signal strength, the pairing success rate and the interference factor fluctuation variance in multiple rounds of testing, constructing a normalized fitness function and scoring each connection strategy; Selecting the connection strategy with the highest fitness function score as the final target strategy, and performing the pairing step sequence of the strategy to complete the Bluetooth connection operation.
2. The Bluetooth connection method of claim 1, wherein, The connection strategy comprises: Selecting a preferred connection device group of the source device and the earphone device, the selection being based on the historical connection stability and the current environment state of the devices; Selecting a communication frequency band that minimizes interference with known interference sources; Adjusting the Bluetooth transmission power based on real-time monitoring of the signal strength; Performing encryption authentication based on device feature fingerprints and protocol handshaking, and selecting an identity verification method in combination with historical pairing information; Adjusting the execution timing of the pairing steps according to the device idle time window and the connection queue length; Restarting the steps and optimizing the parameters when the pairing fails, and switching to a new strategy if the failure occurs multiple times.
3. The Bluetooth connection method of claim 1, wherein, The calculation of the relative position of the device coordinates, the signal strength range and the influence factor of the known interference source between each pair of steps comprises: Calculating the relative position of the device coordinates between steps through a three-dimensional coordinate difference algorithm: where x i , y i , z i are the device coordinates of step i; x j , y j , z j are the device coordinates of step j; Calculating the signal strength range through a radio frequency propagation model: where P t is the transmit power, G r is the receive gain, d is the device separation, and λ is the wavelength. Calculating the interference source influence factor through an interference superposition model: wherein I i,j denotes the interference source influence factor between pairing step i and pairing step j, A k denotes the intensity of the kth interference source, τ is the distance attenuation coefficient, r k is the distance between the interference source and the device, and n is the total number of interference sources.
4. The Bluetooth connection method of claim 1, wherein, The method for performing data consistency verification comprises: Based on the communication timestamp, signal strength fluctuation value and data packet type parameters of the current Bluetooth pairing step, constructing a three-dimensional verification matrix, wherein the three dimensions of the three-dimensional verification matrix are mapped to the timestamp interval, the signal strength gradient interval and the data packet type coding interval, respectively; Extracting the protocol data units transmitted in the step, generating a hash value sequence of the corresponding data packet header field, and comparing it bit by bit with the standard hash template stored in the preset Bluetooth protocol specification library, and recording the hash consistency rate; Real-time capturing the actual frequency point distribution of the Bluetooth frequency hopping sequence, calculating the frequency point matching standard deviation of the actual frequency point distribution and the theoretical frequency hopping sequence within a preset time window, the theoretical frequency hopping sequence being dynamically generated according to the Bluetooth MAC address and the clock offset. When the hash consistency rate is lower than a first preset threshold and the frequency point matching standard deviation exceeds a second preset threshold, a dynamic adjustment mechanism is triggered, the order of operations not completed in the current step is rearranged, the sub-operation with the highest protocol data unit check pass rate is preferentially executed, and the communication frequency band with the lowest frequency point matching degree is marked as a disabled interval.
5. The Bluetooth connection method of claim 1, wherein, The method for calculating the comprehensive weight value of each step according to the signal strength, pairing success rate and interference risk value comprises: For each Bluetooth pairing step, the mean signal strength in the historical connection record, the current real-time signal strength sample value and the preset signal strength attenuation coefficient are extracted, and a normalized signal strength index is calculated, with the formula being: Where S real is the real-time signal strength, S hist is the historical average, a is the decay coefficient, and s is the ambient noise compensation value. The ratio of the number of pairing successes to the total number of attempts of the step within a preset time period is obtained as the pairing success rate, and the interference risk value is calculated based on the interference source type, interference intensity and duration, wherein: R isk =∑(I type ×I intensity ×T duration ) where I type is the type of interference source weight, I intensity is the intensity coefficient, T duration is the duration of the interference; Set the signal strength, the weight coefficient W of the pairing success rate and the interference risk value s , W p , W r , the integrated weight value W is calculated according to the formula total : W total = (S norm × W s ) + (P rate × W p ) - (R isk × W r ) The comprehensive weight values of all steps under the same connection strategy are normalized so that the total sum of the comprehensive weight values is 1, and a weight distribution vector is generated.
6. The Bluetooth connection method of claim 1, wherein, The priority of the effective steps is sorted based on the comprehensive weight values, and a preliminary optimized pairing step sequence is generated, comprising the following steps: All steps in the same connection strategy are arranged in descending order according to the normalized comprehensive weight values, and steps with a weight value higher than a preset effective threshold are selected as the effective step set; The effective step set is traversed, and a directed acyclic graph is constructed based on the device operation dependency relationship between steps, wherein the nodes represent the steps and the edges represent the step execution order constraints; An initial sequence is generated according to the topological sorting result of the directed acyclic graph, and Bluetooth protocol switching conflicts in the initial sequence are detected, and if there is a conflict, a protocol adaptation buffer step is inserted; Based on the weight distribution vector of the steps, the steps with a continuous weight difference value exceeding a preset fluctuation threshold in the sequence are locally rearranged, and the high weight step set is preferentially concentrated in the time interval with the highest mean signal strength. The rearranged sequence is matched with the longest common subsequence with the historical optimal sequence in the Bluetooth connection database, a dynamic priority improvement mark is applied to the non-matching segment, and a preliminary optimized pairing step sequence is generated.
7. The Bluetooth connection method of claim 1, wherein, The preliminary optimized sequence is divided into multiple sub-sequences for cross-validation, and a corrected pairing step sequence is generated, comprising the following steps: The preliminary optimized sequence is divided into at least three continuous sub-sequences according to the protocol switching points and device operation types, each sub-sequence contains 3-5 steps and covers a complete protocol interaction period; Adjacent sub-sequences are cross-validated, the step groups of the head and tail sub-sequences are exchanged, test data packets are injected, the protocol response delay and packet loss rate of the exchanged sub-sequences are monitored, and a cross-matching degree score is calculated; The interference factor bias value of each step under the same type of interference source is calculated by extracting the interference scene record matching the current device identifier from the historical connection database, and the current interference factor weight is adjusted according to the formula; wherein, W r represents the initial weight coefficient of the interference factor, D hist is the historical deviation mean, D current is the current measured deviation, T action is the interference duration ratio, and ∈ is the smoothing coefficient. Based on the adjusted interference factor weight, the sub-sequences with a matching degree score lower than the threshold in the cross-validation are reorganized, and the position of the high interference risk step is preferentially replaced by using a greedy algorithm while maintaining the topological dependency. The recombined sub-sequence is spliced according to the original division point, a plurality of rounds of conflict detection iterations are performed, after each iteration, a step causing a protocol conflict is deleted and a standby step in the historical optimal sequence is supplemented, and a corrected pairing step sequence is generated.
8. The Bluetooth connection method of claim 1, wherein, The steps of constructing a normalized fitness function and scoring each connection strategy include the following steps: Collecting the average of signal strength μ of each connection strategy in multiple rounds of testing s , the success rate of pairing P rate , and the fluctuation variance of interference factor Extracting the extreme values of the corresponding indicators [μ max , μ min ], [P max , P min ] from the historical optimal connection records The range normalization processing is performed on each index, and the formula is: wherein S' represents the normalized signal strength indicator, μ max and μ min respectively represent the maximum and minimum values of the signal strength in the historical optimal connection record; P' represents the normalized pairing success rate indicator, and R' represents the normalized interference stability indicator; Setting signal strength weight W s ', pairing success rate weight W p ', interference stability weight W r ', fitness function value F is calculated according to the formula F = (S' x W s ') + (P' x W p ') + (R' x W r ') The fitness function values of all test rounds under the same connection strategy are taken as weighted average values, the weight is the spectral similarity coefficient of the test environment of each round and the current real-time environment, a final strategy score is generated and is arranged in descending order.
9. A Bluetooth connection system, characterized in that The method comprises the following units: The acquisition unit is configured to acquire Bluetooth connection information of the earphone, wherein the Bluetooth connection information comprises an earphone device identifier and a source device identifier. The database unit is configured to extract a plurality of connection strategies corresponding to the earphone device identifier and the source device identifier from a preset Bluetooth connection database, wherein each connection strategy comprises a plurality of Bluetooth pairing steps. The calculation unit is configured to calculate, for each Bluetooth pairing step in each connection strategy, a relative position of device coordinates between each pair of steps, a signal strength range, and an influence factor of a known interference source. The data consistency verification unit is configured to perform data consistency verification on each Bluetooth pairing step, wherein the data consistency verification comprises constructing a three-dimensional verification matrix, comparing protocol data units, monitoring Bluetooth frequency hopping sequence matching degrees, and dynamically adjusting an operation order according to a verification result. The weight calculation unit is configured to calculate a comprehensive weight value of each step according to a signal strength, a pairing success rate, and an interference risk value, to prioritize effective steps based on the comprehensive weight value, and to generate a preliminary optimized pairing step sequence. The verification unit is configured to divide the preliminary optimized pairing step sequence into a plurality of sub-sequences for cross verification, to adjust an interference factor weight and to rearrange a step order in combination with historical connection data, and to generate a corrected pairing step sequence through a plurality of verification iteration optimizations. The scoring unit is configured to collect a signal strength average, a pairing success rate, and an interference factor fluctuation variance in a plurality of test rounds, to construct a normalized fitness function, and to score each connection strategy. The strategy selection unit is configured to select a connection strategy with the highest fitness function score as a final target strategy, and to perform a pairing step sequence of the connection strategy to complete a Bluetooth connection operation.
10. The Bluetooth connection system of claim 9, wherein, The database unit is configured to store Bluetooth connection information between different devices and connection strategies corresponding thereto; the data consistency verification unit is configured to verify Bluetooth pairing steps through real-time communication with devices to ensure correctness and consistency of device information in a pairing process; the scoring unit is configured to comprehensively evaluate performances of each connection strategy according to a signal strength, a pairing success rate, and an interference factor fluctuation variance, and to sort the connection strategies according to evaluation results; and the verification unit is configured to gradually improve a Bluetooth connection success rate and stability through iteration optimization of a plurality of cross verification results.
Citation Information
Patent Citations
Connection method and system of Bluetooth earphone
CN117715156A
Method and system for automatic coupling of bluetooth devices
US11638313B1