Bluetooth connection method and system

By extracting and optimizing Bluetooth connection strategies, calculating device coordinates and signal strength, performing data consistency verification and dynamically adjusting operation sequence, the traditional Bluetooth connection method solves the problems of signal instability, pairing failure and low connection efficiency in complex environments, and achieves more efficient and reliable Bluetooth connection.

CN120201398AActive Publication Date: 2025-06-24深圳市慕客科技有限公司

Patent Information

Application Number
CN202510298239.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-13
Publication Date
2025-06-24
Estimated Expiration
2045-03-13

AI Technical Summary

Technical Problem

Traditional Bluetooth connection methods have problems such as instability in signal, failure in pairing and low connection efficiency in complex environments.

Method used

By obtaining the Bluetooth connection information of the headset, multiple connection strategies are extracted, the relative position of the device coordinates, the signal strength range and the influencing factors of the interference source, the data consistency verification is performed, the operation sequence is dynamically adjusted, the pairing step sequence is optimized, and the optimal connection strategy is generated through multiple rounds of cross-verification and iterative optimization.

Benefits of technology

It significantly improves the stability and success rate of Bluetooth connection, avoids the problems of weak signal, unstable connection and failed pairing, and improves the efficiency and reliability of the connection process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120201398A_ABST
    Figure CN120201398A_ABST
Patent Text Reader

Abstract

The invention relates to a Bluetooth connection method and system, and the method comprises the steps: obtaining Bluetooth identifiers of an earphone and a source device, and extracting a multi-connection strategy from a database; and calculating equipment positions, signal intensities and interference factors among all strategy steps, executing a three-dimensional verification matrix, comparing protocol units, and monitoring a frequency hopping sequence to realize dynamic sequence adjustment. Combining the signal intensity, the success rate and the interference risk to calculate a comprehensive weight, generating an optimized sequence, then dividing multiple subsequences for cross validation, and utilizing historical data to adjust the interference weight and reconstruct a step sequence. Collecting intensity mean values and success rate variances of multiple rounds of tests to construct a normalized fitness function, and selecting an optimal scheme after scoring each strategy. Through a multi-dimensional parameter fusion and iteration verification mechanism, traditional single-path limitation is broken through, and finally, Bluetooth connection is completed by adopting a highest score strategy, so that the problem of equipment interconnection in a complex electromagnetic environment is effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Bluetooth technology, and specifically relates to a Bluetooth connection method and system. Background Art

[0002] With the wide application of Bluetooth technology, especially in wireless earphones, smart homes, and other intelligent devices, Bluetooth connection has become a common wireless communication method. However, despite the wide application of Bluetooth connection in short-range wireless communication, its stability and efficiency are still important technical challenges.

[0003] Traditional Bluetooth pairing methods usually rely on fixed steps and processes. In different devices and environments, factors such as signal interference and device movement may be encountered, resulting in poor connection quality, pairing failure, or slow connection speed. To address these issues, some existing technologies have proposed optimization strategies based on device information or environmental characteristics, but there are still deficiencies in lacking flexibility and adaptability. Especially in complex environments or scenarios where multiple devices are connected simultaneously, the efficiency and stability of Bluetooth connection often cannot meet the needs of users.

[0004] In addition, the verification steps in the existing Bluetooth connection methods during the pairing process are relatively simplified. Usually, only the basic signal strength or whether the pairing is successful is checked, lacking in-depth analysis of data consistency between devices and environmental interference sources. Therefore, these methods cannot perform effective self-adjustment and optimization when facing complex or variable connection conditions. Summary of the Invention

[0005] The present invention provides a Bluetooth connection method and system, aiming 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 object, the first aspect of the present invention provides a Bluetooth connection method, including the following steps:

[0007] Obtain the Bluetooth connection information of the earphone, where the Bluetooth connection information includes the earphone device identifier and the source device identifier;

[0008] Based on the earphone device identifier and the source device identifier, extract corresponding multiple connection strategies from a preset Bluetooth connection database, and each connection strategy includes multiple Bluetooth pairing steps;

[0009] For the Bluetooth pairing steps in each connection strategy, calculate the relative position of device coordinates, signal strength range, and influence factor of known interference sources between each pair of steps;

[0010] 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 matching degree of Bluetooth hopping sequences, and dynamically adjusting the operation order according to the verification results;

[0011] Calculate the comprehensive weight value of each step according to the signal strength, pairing success rate, and interference risk value, and perform priority sorting on the valid steps based on the comprehensive weight value to generate a preliminarily optimized pairing step sequence;

[0012] Divide the preliminarily optimized sequence into multiple subsequences for cross-verification, adjust the interference factor weight in combination with historical connection data, and rearrange the step order. Through multiple rounds of verification and iteration optimization, generate a corrected pairing step sequence;

[0013] Collect the average signal strength, pairing success rate, and variance of interference factor fluctuations in multiple rounds of tests, construct a normalized fitness function, and score each connection strategy;

[0014] Select the connection strategy with the highest fitness function score as the final target strategy, and execute the pairing step sequence of this strategy to complete the Bluetooth connection operation.

[0015] Further, the connection strategies include:

[0016] Select the preferred connection device group of the source device and the headphone device, and the selection is based on the historical connection stability of the device and the current environmental state;

[0017] Select a communication frequency band with minimal interference from known interference sources;

[0018] Adjust the Bluetooth transmission power based on the real-time monitored signal strength;

[0019] Perform encryption authentication based on device characteristic fingerprints and protocol handshakes, and select an authentication method in combination with historical pairing information;

[0020] Adjust the execution timing of the pairing steps according to the device idle time window and the connection queue length;

[0021] Restart the steps and optimize the parameters when pairing fails. If it fails multiple times, switch to a new strategy.

[0022] Further, calculate the relative position of device coordinates, signal strength range, and influence factors of known interference sources between each pair of steps, including:

[0023] Calculate the relative position of device coordinates between steps through a three-dimensional coordinate difference algorithm:

[0024]

[0025] where, x i , yi , z i is the device coordinate of step i; x j , y j , z j are the device coordinates of step j;

[0026] Calculate the signal strength range through the radio frequency propagation model:

[0027]

[0028] where P t is the transmission power, G r is the receiving gain, d is the device spacing, and λ is the wavelength;

[0029] Calculate the interference source influence factor through the interference superposition model:

[0030]

[0031] where I i,j represents the interference influence factor between pairing step i and pairing step j, A k represents the intensity of the k-th 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.

[0032] Furthermore, the method for performing data consistency verification includes:

[0033] Based on the communication timestamp, signal strength fluctuation value, and packet type parameter of the current Bluetooth pairing step, construct a three-dimensional verification matrix, where the three dimensions of the three-dimensional verification matrix are respectively mapped to the timestamp interval, signal strength gradient interval, and packet type coding interval;

[0034] Extract the protocol data unit transmitted in the step, generate a hash value sequence corresponding to the data packet header field, and perform a bit-by-bit comparison with the standard hash template stored in the preset Bluetooth protocol specification library, and record the hash consistency rate;

[0035] Real-time capture the actual frequency point distribution of the Bluetooth frequency hopping sequence, calculate the frequency point matching standard deviation between it and the theoretical frequency hopping sequence within a preset time window, and the theoretical frequency hopping sequence is dynamically generated according to 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, trigger the dynamic adjustment mechanism, rearrange the operation order of the unfinished operations within the current step, preferentially execute the sub-operation with the highest protocol data unit verification passing rate, and mark the communication frequency band with the lowest frequency point matching degree as the disabled interval.

[0037] Further, the method for calculating the comprehensive weight value of each step according to the signal strength, pairing success rate, and interference risk value includes:

[0038] For each Bluetooth pairing step, extract the average signal strength, current real-time signal strength sampling value, and preset signal strength attenuation coefficient from its historical connection record, and calculate the normalized signal strength index. The formula is:

[0039]

[0040] where S real is the real-time signal strength, S hist is the historical average, α is the attenuation coefficient, and σ is the environmental noise compensation value;

[0041] Obtain the ratio of the number of successful pairings to the total number of attempts for the step within a preset time period as the pairing success rate, and calculate the interference risk value based on the interference source type, interference intensity, and duration. Among them:

[0042] R isk = Σ(I type × I intensity × T duration )

[0043] where I type is the interference source type weight, I intensity is the intensity coefficient, and T duration is the interference duration;

[0044] Set the weight coefficients W s 、W p 、W r of the signal strength, pairing success rate, and interference risk value, and calculate the comprehensive weight value W total according to the formula:

[0045] W total = (S norm × W s ) + (P rate × W p ) - (R isk × W r )

[0046] Normalize the comprehensive weight values of all steps under the same connection strategy so that the sum of the comprehensive weight values is 1, and generate a weight distribution vector.

[0047] Further, the steps for prioritizing the effective steps based on the comprehensive weight value and generating a preliminarily optimized pairing step sequence include the following steps:

[0048] Arrange all steps in the same connection strategy in descending order according to the normalized comprehensive weight value, and filter out the steps with weight values higher than the preset effective threshold as the set of effective steps;

[0049] Traverse the set of effective steps, and construct a directed acyclic graph based on the device operation dependencies between steps, where nodes represent steps and edges represent step execution order constraints;

[0050] Generate an initial sequence according to the topological sorting result of the directed acyclic graph, and detect the Bluetooth protocol switching conflicts between adjacent steps in the initial sequence. If there are conflicts, insert protocol adaptation buffer steps;

[0051] Based on the weight distribution vector of steps, perform local rearrangement on the step segments in the sequence where the continuous weight difference exceeds the preset fluctuation threshold, and give priority to concentrating high-weight steps in the time interval with the highest average signal strength;

[0052] Match the rearranged sequence with the historical optimal sequence in the Bluetooth connection database by the longest common subsequence, apply dynamic priority promotion marks to the non-matching segments, and generate a preliminarily optimized paired step sequence.

[0053] Further, dividing the preliminarily optimized sequence into multiple subsequences for cross-validation and generating a corrected paired step sequence includes the following steps:

[0054] Based on the protocol switching points and device operation types as the segmentation basis, divide the preliminarily optimized sequence into at least three consecutive subsequences, each subsequence contains 3-5 steps and covers a complete protocol interaction cycle;

[0055] Perform cross-validation on adjacent subsequences, exchange the step groups of the first and last subsequences and inject test data packets, monitor the protocol response delay and packet loss rate of the subsequences after the exchange, and calculate the cross-matching degree score;

[0056] Extract the interference scenario records matching the current device identifier from the historical connection database, count the actual interference factor deviation values of each step under the same type of interference source, and adjust the current interference factor weight according to the formula;

[0057]

[0058] Among them, 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 proportion of interference duration, and ∈ is the smoothing coefficient;

[0059] Based on the adjusted interference factor weights, reorganize the subsequences with matching scores lower than the threshold in cross-validation, and use the greedy algorithm to preferentially replace the positions of steps with high interference risk while maintaining topological dependencies;

[0060] Reassemble the reorganized subsequences at 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 optimal sequence to generate a corrected paired step sequence.

[0061] Furthermore, constructing a normalized fitness function and scoring each connection strategy includes the following steps:

[0062] Collect the mean signal strength μ of each connection strategy in multiple rounds of tests s , pairing success rate P rate and the variance of interference factor fluctuations Extract the extreme values of the corresponding metrics from the historical optimal connection records [μ max , μ min ,

[0063] [P max , P min ,

[0064] Perform range normalization on each metric, and the formula is:

[0065]

[0066] where S′ represents the normalized signal strength metric, μ max and μ min are the maximum and minimum signal strengths in the historical optimal connection records respectively; P′ represents the normalized pairing success rate metric, and R′ represents the normalized interference stability metric;

[0067] Set the signal strength weight W s ′, pairing success rate weight W p ′, interference stability weight W r ′, and calculate the fitness function value F according to the formula:

[0068] F = (S′ × W s ′) + (P′ × W p ′) + (R′ × W r ′)

[0069] Take the weighted average of the fitness function values for all test rounds under the same connection strategy, with the weight being the spectral similarity coefficient between the test environment of each round and the current real-time environment, generate the final strategy score, and sort it in descending order.

[0070] To achieve the above object, the second aspect of the present invention provides a Bluetooth connection system, including the following modules:

[0071] An acquisition unit, configured to acquire Bluetooth connection information of the earphone, where the Bluetooth connection information includes an earphone device identifier and a source device identifier;

[0072] A database unit, configured to extract corresponding multiple connection strategies from a preset Bluetooth connection database based on the earphone device identifier and the source device identifier, and each connection strategy includes multiple Bluetooth pairing steps;

[0073] A calculation unit, configured to calculate the relative position of device coordinates, the signal strength range, and the influence factor of known interference sources between each pair of steps for the Bluetooth pairing steps in each connection strategy;

[0074] A data consistency verification unit, configured to perform data consistency verification on each Bluetooth pairing step, where the data consistency verification includes constructing a three-dimensional verification matrix, comparing protocol data units, monitoring the matching degree of Bluetooth hopping sequences, and dynamically adjusting the operation order according to the verification results;

[0075] A weight calculation unit, configured to calculate the comprehensive weight value of each step according to the signal strength, pairing success rate, and interference risk value, perform priority sorting on the effective steps based on the comprehensive weight value, and generate a preliminarily optimized pairing step sequence;

[0076] A verification unit, configured to divide the preliminarily optimized sequence into multiple subsequences for cross-verification, adjust the interference factor weight and rearrange the step order in combination with historical connection data, and generate a corrected pairing step sequence through multiple rounds of verification iteration optimization;

[0077] A scoring unit, configured to collect the average signal strength, pairing success rate, and interference factor fluctuation variance in multiple rounds of tests, construct a normalized fitness function, and score each connection strategy;

[0078] A strategy selection unit, configured 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] Further, the database unit is configured to store Bluetooth connection information between different devices and their corresponding connection strategies; the data consistency verification unit is configured to verify the Bluetooth pairing steps through real-time communication with the device to ensure the correctness and consistency of device information during the pairing process; the scoring unit is configured to comprehensively evaluate the performance of each connection strategy according to the signal strength, pairing success rate, and interference factor fluctuation variance, and perform sorting according to the evaluation results; the verification unit is configured to gradually improve the success rate and stability of Bluetooth connection through iterative optimization of the results of multiple rounds of cross-verification.

[0080] Advantages of the present invention:

[0081] Compared with the prior art, a Bluetooth connection method and system provided by the present invention can flexibly adjust the pairing steps of Bluetooth connection according to the specific identification of the device, environmental factors, and the influence of interference sources by introducing a multi-strategy extraction and dynamic optimization mechanism. 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 preferentially executed, significantly improving the stability and success rate of the connection. At the same time, the present invention ensures data consistency during the pairing process through three-dimensional verification matrix and hopping sequence matching degree monitoring, dynamically adjusts the operation sequence, and avoids failures caused by fixed processes. Multiple rounds of cross-verification and iterative optimization further eliminate the negative impact of interference sources on the connection. Finally, the best strategy is selected through fitness function scoring, ensuring the efficiency and reliability of the connection process. Therefore, the present invention can significantly improve the performance of Bluetooth connection in complex environments, overcoming problems such as weak signal, unstable connection, and pairing failure existing in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0082] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments.

[0083] Figure 1 is a flowchart of a Bluetooth connection method disclosed in an embodiment of the present invention.

[0084] Figure 2 is an organizational framework diagram of a connection strategy disclosed in an embodiment of the present invention.

[0085] Figure 3 is a flowchart of a method for performing data consistency verification disclosed in an embodiment of the present invention.

[0086] Figure 4 is a flowchart of a method for performing priority sorting and generating a preliminary optimized pairing step sequence disclosed in an embodiment of the present invention.

[0087] Figure 5 is a framework diagram of a Bluetooth connection system disclosed in an embodiment of the present invention.

[0088] Figure 6 is a comparison diagram of connection delay and packet loss rate in a simulated environment during an experiment disclosed in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[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 of this application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts belong to the scope of protection of this application. The "and / or" in each embodiment of this specification means at least one of the former and the latter.

[0090] As Figure 1 shown, the present invention provides a Bluetooth connection method, which can be executed by a terminal device. In other words, this 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 earphone, where the Bluetooth connection information includes the earphone device identifier and the source device identifier;

[0092] During the pairing process between Bluetooth devices, there is usually a situation where the device identifier is unclear or cannot be accurately recognized, which may lead to delays or failures in the connection process. Especially in a multi-device environment, the accurate acquisition of the device identifier is crucial for subsequent pairing and connection operations; this step is the initialization stage of Bluetooth connection, and the identifier information of the earphone and the source device (such as a mobile phone or a computer) needs to be collected, and the device identifier is stored in the form of key-value pairs.

[0093] Earphone device identifier: including Bluetooth MAC address, firmware version number, device type (such as TWS earphone), etc., which is read from the earphone chip through the HCI_Read_BD_ADDR command of the Bluetooth protocol stack.

[0094] Source device identifier: including the Bluetooth address of the source device, operating system type (such as Android / iOS), Bluetooth protocol version (such as Bluetooth 5.3), etc., which is obtained through the system API (such as BluetoothAdapter.getAddress() in Android).

[0095] Step S200: Based on the earphone device identifier and the source device identifier, extract corresponding multiple connection strategies from a preset Bluetooth connection database, and each connection strategy includes multiple Bluetooth pairing steps;

[0096] In practical applications, different Bluetooth devices face different environmental conditions during the connection process, such as signal strength, distance between devices, interference sources, and other factors. Traditional Bluetooth pairing methods usually rely on fixed pairing steps, ignoring device characteristics and environmental changes, which results in low stability and efficiency of the connection process in some complex environments. In addition, the historical connection stability between devices is also an important factor affecting the connection quality. The lack of a flexible connection strategy leads to the inability to effectively adjust the connection process according to changes in devices and the environment.

[0097] In this step, by extracting multiple connection strategies from a preset Bluetooth connection database and combining the headphone device identifier and the source device identifier, it is possible to flexibly select the optimal pairing strategy based on the historical connection situation of the actual device and the current environmental state. In this way, the connection process can be adaptively adjusted according to different environmental conditions, improving the success rate and stability of the connection. In a complex wireless environment, the present invention can significantly reduce the problems of connection failures and inefficient connections, optimize the pairing process between Bluetooth devices, and enhance the user experience.

[0098] Step S300: For each Bluetooth pairing step in each connection strategy, calculate the relative position of the device coordinates, the signal strength range, and the influence factor of known interference sources between each pair of steps;

[0099] In the prior art, most Bluetooth pairing methods only rely on signal strength and basic pairing algorithms, ignoring the change in the relative position between devices and the influence of interference sources on signal transmission; in step S300 of the present invention, for each Bluetooth pairing step in each connection strategy, calculate the relative position of the device coordinates, the signal strength range, and the influence factor of known interference sources between each pair of steps. By introducing the relative position of the devices and environmental interference factors, it is possible to more accurately evaluate the communication quality between devices in each pairing process and make dynamic adjustments based on these factors. For example, the relative position between devices affects signal attenuation, and the presence of interference sources introduces noise.

[0100] Step S400: Perform data consistency verification on each Bluetooth pairing step. The data consistency verification includes constructing a three-dimensional verification matrix, comparing protocol data units, monitoring the matching degree of Bluetooth hopping sequences, 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 comprehensive influence of factors such as the relative position of the devices, signal strength, and interference sources. These factors are analyzed in multiple dimensions through the matrix form to ensure data consistency during the pairing process.

[0102] The comparison protocol data unit checks whether the information during the protocol handshake between devices is consistent, ensuring that the data exchange between devices complies with the Bluetooth protocol specifications and avoiding pairing failures or connection problems caused by inconsistent protocols.

[0103] Monitoring the Bluetooth frequency hopping sequence matching degree involves the issue of Bluetooth frequency hopping synchronization between devices. Bluetooth devices will frequently change frequencies during communication. Ensuring the matching degree of the frequency hopping sequence can reduce the influence of interference sources and maintain stable signal transmission. Therefore, through these three verifications, the communication quality and data consistency during the Bluetooth pairing process can be comprehensively ensured, avoiding connection failures caused by protocol mismatches or environmental interference.

[0104] Step S500: Calculate the comprehensive weight value for each step based on the signal strength, pairing success rate, and interference risk value, and prioritize the effective steps based on the comprehensive weight value to generate a preliminarily optimized pairing step sequence.

[0105] The comprehensive weight value is a quantitative evaluation of the importance and effectiveness of each Bluetooth pairing step. It is calculated based on multiple factors, including signal strength, pairing success rate, interference risk, etc. These factors will affect the stability and success rate of the pairing steps. Therefore, by assigning certain weight values to each factor, the system can comprehensively evaluate the priority of each step. For example, steps with stronger signal strength will be given higher weights, while steps with higher interference risks will be given lower weights. Ultimately, the comprehensive weight value helps the system determine which steps are more critical and which steps need to be executed first, thereby optimizing the pairing process and improving the overall pairing efficiency and success rate.

[0106] Step S600: Divide the preliminarily optimized sequence into multiple subsequences for cross-verification, adjust the interference factor weights in combination with historical connection data, and rearrange the step order to generate a corrected pairing step sequence through multiple rounds of verification and iteration optimization.

[0107] Divide the optimized pairing step sequence into multiple small segments (subsequences), and independently verify each subsequence. Through cross-verification, the execution effects of different subsequences can be evaluated, and the performance of each subsequence in the actual pairing process can be analyzed. This can discover potential optimization problems or interference between steps, ensuring the reliability and stability of the pairing process under different conditions. The results of cross-verification help identify which subsequences or steps perform best under specific conditions, further optimizing the entire pairing process.

[0108] Adjusting the weights of interference factors and rearranging the step order means dynamically adjusting the weights of interference factors (such as environmental interference, device distance, signal attenuation, etc.) in each step according to the results of cross-validation. By analyzing the fluctuations of interference factors in the test results and their impacts on the pairing effect, it is possible to more accurately evaluate which steps are more vulnerable to interference. After adjusting the weights of interference factors, the system will rearrange the order of pairing steps and give priority to executing those steps with less interference and higher efficiency.

[0109] Step S700: Collect the mean signal strength, pairing success rate, and variance of interference factor fluctuations in multiple rounds of tests, construct a normalized fitness function, and score each connection strategy.

[0110] The normalized fitness function is used to uniformly score multiple connection strategies. By standardizing multiple factors, such as the mean signal strength, pairing success rate, variance of interference factor fluctuations, etc., this function ensures that the dimensions of each evaluation index are unified, making the comparison between different strategies fairer and more consistent. The normalization process converts parameters of different magnitudes into relative values, eliminating the differences of each parameter itself, so that the final fitness score can reflect the overall advantages and disadvantages of each connection strategy. Scoring means scoring each strategy according to the normalized fitness function. A strategy with a higher score indicates that the strategy can provide a more stable and efficient Bluetooth connection in the current environment. Through this scoring mechanism, the performance of each connection strategy can be quantified, and finally the optimal connection strategy can be selected.

[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 this strategy to complete the Bluetooth connection operation.

[0112] In this embodiment, as described in step S200 above, where the connection strategy (see Figure 2 ) includes:

[0113] Step S201: Select the preferred connection device group of the source device and the headphone device, and the selection is based on the historical connection stability of the device and the current environmental state.

[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 encryption authentication based on device feature fingerprints and protocol handshakes, and select an authentication method in combination with historical pairing information.

[0117] Step S205: Adjust the execution timing of pairing steps according to the device idle time window and the connection queue length.

[0118] Step S206: Restart the steps and optimize the parameters when the pairing fails. If the failure occurs multiple times, switch to a new strategy.

[0119] In this embodiment, as described in step S300 above, calculate the relative position of device coordinates, signal strength range, and influence factor of known interference sources between each pair of steps, including:

[0120] Calculate the relative position of device coordinates between steps through a three-dimensional coordinate difference algorithm:

[0121]

[0122] 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;

[0123] Calculate the signal strength range through a radio frequency propagation model:

[0124]

[0125] where P t is the transmission power, G r is the receiving gain, d is the device spacing, and λ is the wavelength;

[0126] Calculate the influence factor of interference sources through an interference superposition model:

[0127]

[0128] where I i,j represents the interference influence factor between pairing step i and pairing step j, A k represents 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.

[0129] In this embodiment, as described in step S400 above, the method for performing data consistency verification (see Figure 3 ) includes:

[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, where the three dimensions of the three-dimensional verification matrix are respectively mapped to the timestamp interval, signal strength gradient interval, and data packet type coding interval;

[0131] Step S402: Extract the protocol data units transmitted in the step, generate a hash value sequence for the corresponding data packet header fields, and perform a bit-by-bit comparison with the standard hash templates stored in the preset Bluetooth protocol specification library, and record the hash consistency rate;

[0132] Step S403: Capture the actual frequency point distribution of the Bluetooth frequency hopping sequence in real time, and calculate the frequency point matching standard deviation between it and 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, trigger the dynamic adjustment mechanism, rearrange the operation order of the unfinished operations in the current step, preferentially execute the sub-operations with the highest protocol data unit verification passing rate, and mark the communication frequency band with the lowest frequency point matching degree as the disabled interval.

[0134] It can be understood that the three dimensions of the three-dimensional verification matrix respectively correspond to the important factors that may affect data consistency during the Bluetooth pairing process, namely communication time, signal strength, and data packet type. The first dimension is the timestamp interval, which is used to record the time when each pairing step occurs and helps analyze the temporal fluctuations during the pairing process; the second dimension is the signal strength gradient interval, which represents the change in signal strength during the pairing process and is used to analyze the trend of signal attenuation or enhancement; the third dimension is the data packet type encoding interval, which is used to distinguish different types of data packets to ensure that different data transmission processes follow the expected protocols. By mapping these three dimensions into 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 value sequence of the data packet header fields is an encryption process of the content of the transmitted data packet header. By generating the hash value sequence, it can ensure that the information is not tampered with or lost during the data transmission process. Each data packet generates a unique hash value during the Bluetooth pairing process, and this hash value contains the identity and content characteristics of the data packet. The process of performing a bit-by-bit comparison with the standard hash templates stored in the preset Bluetooth protocol specification library is used to ensure that the data transmitted by the device during the pairing process conforms to the Bluetooth protocol specification. If the hash value of the data packet header does not match the standard template, it indicates that there are deviations or errors in the data during the transmission process. Therefore, a bit-by-bit comparison is performed to ensure that the data transmission in each step of the pairing is completely consistent and meets the protocol requirements.

[0136] The standard deviation of frequency point matching is a statistical value that measures the deviation between the actual frequency points and the theoretical frequency points during the frequency hopping process of Bluetooth devices. In Bluetooth communication, devices transmit signals according to a specific frequency hopping pattern. The theoretical hopping sequence is dynamically generated based on the Bluetooth MAC address and the device clock offset to ensure that devices can avoid interfering with each other. Through the calculation of the standard deviation of frequency point matching, the matching degree between the actual frequency points and the theoretical frequency points can be obtained. If the standard deviation is too large, it indicates that the hopping sequence of the device fails to synchronize accurately according to the theoretical sequence, which may lead to frequency conflicts or interference, thus affecting the connection stability.

[0137] Based on the communication timestamp, signal strength fluctuation value, and 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 the three-dimensional matrix:

[0139] Timestamp interval: According to the timestamps of each pairing step during the Bluetooth pairing process, set a suitable time window (e.g., at the second or millisecond level), and divide the timestamps during the pairing process into multiple time periods.

[0140] Signal strength gradient interval: According to the change of signal strength during the pairing process, set the minimum and maximum values of the signal strength, and divide them into multiple gradient intervals (e.g., low, medium, high).

[0141] Packet type coding interval: According to different packet types in the Bluetooth protocol (such as synchronization, data, acknowledgment packets, etc.), divide their coding values into multiple categories or intervals.

[0142] During the pairing process, collect relevant communication data in real time. Whenever a pairing step is executed, record the timestamp, signal strength, and packet type of that step. Map each recorded timestamp, signal strength, and packet type to the above-set interval range. For example, if the timestamp is 10ms, the signal strength is -50dBm, and the packet type is "acknowledgment packet", then map them to the corresponding time interval, signal gradient, and packet type coding interval respectively.

[0143] According to the timestamp, signal strength, and packet type of each pairing step, map them to the corresponding positions in the three-dimensional matrix. For example, if the timestamp belongs to the interval [0 - 100ms], the signal strength belongs to the interval [-60dBm, -50dBm], and the packet type belongs to the "data packet" category, then fill a value (such as 1 for valid data and 0 for invalid data) at the corresponding position in the matrix. Record the corresponding signal strength, timestamp, and packet type in each matrix element, and gradually fill the entire three-dimensional matrix.

[0144] Through a three-dimensional verification matrix, the matching degree and consistency among different time periods, different signal strengths, and different data packet types can be verified. If the verification value in a certain matrix area shows an abnormality (such as abnormal signal strength change or data packet type mismatch), analysis is required to find possible interference sources or errors, and then the pairing steps are adjusted.

[0145] In this embodiment, as described in the above step S500, the method for calculating the comprehensive weight value of each step according to the signal strength, pairing success rate, and interference risk value includes:

[0146] For each Bluetooth pairing step, extract the average signal strength, the current real-time signal strength sampling value, and the preset signal strength attenuation coefficient from its historical connection record, and calculate the normalized signal strength index. The formula is:

[0147]

[0148] where S real is the real-time signal strength, S hist is the historical average, α is the attenuation coefficient, and σ is the environmental noise compensation value;

[0149] Obtain the ratio of the number of successful pairings to the total number of attempts of the step within a preset time period as the pairing success rate, and calculate the interference risk value based on the interference source type, interference intensity, and duration. Among them:

[0150] R isk =∑(I type ×I intensity ×T duration )

[0151] where I type is the interference source type weight, I intensity is the intensity coefficient, and T duration is the interference duration;

[0152] Set the weight coefficients W s 、W p 、W r , and calculate the comprehensive weight value W total according to the formula:

[0153] W total =(S norm ×W s )+(P rate ×W p )-(R isk ×W r )

[0154] Normalize the comprehensive weight values of all steps under the same connection strategy so that the sum of the comprehensive weight values is 1, and generate a weight distribution vector.

[0155] In this embodiment, as described in the above step S500, prioritize the effective steps based on the comprehensive weight values and generate a preliminarily optimized paired step sequence (see Figure 4 ) including the following steps:

[0156] Step S501: Arrange all steps in the same connection strategy in descending order according to the normalized comprehensive weight values, and screen out the steps with weight values higher than the preset effective threshold as the effective step set;

[0157] Step S502: Traverse the effective step set, and construct a directed acyclic graph based on the device operation dependencies between steps, where nodes represent steps and edges represent step execution order constraints;

[0158] Step S503: Generate an initial sequence according to the topological sorting result of the directed acyclic graph, and detect the Bluetooth protocol switching conflicts between adjacent steps in the initial sequence. If there are conflicts, insert protocol adaptation buffer steps;

[0159] Step S504: Based on the weight distribution vector of the steps, perform local rearrangement on the step segments with continuous weight differences exceeding the preset fluctuation threshold in the sequence, and preferentially concentrate the high-weight steps in the time interval with the highest average signal strength;

[0160] Step S505: Perform the longest common subsequence matching between the rearranged sequence and the historical optimal sequence in the Bluetooth connection database, apply dynamic priority promotion marks to the non-matching segments, and generate a preliminarily optimized paired step sequence.

[0161] It can be understood that a directed acyclic graph (DAG) is used to represent the dependency relationships and execution orders between Bluetooth pairing steps. Each pairing step is regarded as a node in the graph, and the dependency relationships between steps are represented by directed edges, where the directed edges indicate that one step must be executed before another step. Since the execution of some steps in the Bluetooth pairing process depends on the results of previous steps, these dependency relationships form a directed graph. In addition, to avoid circular dependencies in the execution order (i.e., an unclear execution order cannot be formed), the graph is required to be acyclic. By constructing a directed acyclic graph, the system can clearly show the sequence of pairing steps, ensure that the steps are executed in the correct order, and avoid pairing failures or low efficiency caused by step conflicts or improper orders.

[0162] In this embodiment, as described in the above step S600, dividing the preliminarily optimized sequence into multiple subsequences for cross-validation and generating a corrected paired step sequence includes the following steps:

[0163] Step S601: Based on the protocol switching point and device operation type as the segmentation basis, divide the preliminary optimization sequence into at least three consecutive subsequences. Each subsequence contains 3 - 5 steps and covers a complete protocol interaction cycle;

[0164] Step S602: Perform cross - validation on adjacent subsequences. Exchange the step groups of the head and tail subsequences and inject test data packets. Monitor the protocol response delay and packet loss rate of the subsequences after the exchange, and calculate the cross - matching degree score;

[0165] Step S603: Extract the interference scenario records that match the current device identifier from the historical connection database. Statistically calculate the actual interference factor deviation values of each step under the same type of interference source, and adjust the current interference factor weight according to the formula;

[0166]

[0167] Among them, 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 proportion of the interference duration, and ∈ is the smoothing coefficient;

[0168] Step S604: Based on the adjusted interference factor weight, perform step recombination on the subsequences with matching degree scores lower than the threshold in the cross - validation. Use the greedy algorithm to preferentially replace the positions of high - interference - risk steps while maintaining the topological dependence;

[0169] Step S605: Re - splice the re - combined subsequences according to the original segmentation points, perform multiple rounds of conflict detection iterations. After each iteration, delete the steps that cause protocol conflicts and supplement the spare steps in the historical optimal sequence to generate the corrected paired step sequence.

[0170] In step S604, according to the adjusted interference factor weight, the greedy algorithm, while ensuring the topological dependence relationship between steps, preferentially moves the high - interference - risk steps to less sensitive positions. Specifically, the algorithm will evaluate the interference risk of each step and select those steps with higher interference factors, and try to replace their positions with steps that have less impact on the system, so as to reduce 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 mean signal strength μ s of each connection strategy in multiple rounds of tests, the pairing success rate P rate and the variance of the interference factor fluctuation Extract the extreme values of the corresponding metrics from the historical optimal connection records [μ max , μ min ,

[0173] [P max , P min ,

[0174] Perform range normalization on each metric, and the formula is:

[0175]

[0176] Among them, S′ represents the signal strength metric after normalization, μ max and μ min are respectively the maximum and minimum signal strengths in the historical optimal connection records; P′ represents the paired success rate metric after normalization, and R′ represents the interference stability metric after normalization;

[0177] Set the signal strength weight W s ′, the paired success rate weight W p ′, the interference stability weight W r ′, and calculate the fitness function value F according to the formula:

[0178] F = (S′ × W s ′) + (P′ × W p ′) + (R′ × W r ′)

[0179] Take the weighted average of the fitness function values of all test rounds under the same connection strategy, with the weight being the spectral similarity coefficient between the test environment of each round and the current real-time environment, generate the final strategy score and sort it in descending order.

[0180] In one embodiment, as Figure 5 shown, a Bluetooth connection system is provided, including:

[0181] An acquisition unit 100, configured to acquire the Bluetooth connection information of the earphone, and the Bluetooth connection information includes the earphone device identifier and the source device identifier;

[0182] A database unit 200, configured to extract corresponding multiple connection strategies from a preset Bluetooth connection database based on the earphone device identifier and the source device identifier, and each connection strategy includes multiple Bluetooth pairing steps;

[0183] A calculation unit 300, configured to calculate 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 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 matching degree of Bluetooth hopping sequences, 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 according to the signal strength, pairing success rate, and interference risk value, prioritize the effective steps based on the comprehensive weight value, and generate a preliminarily optimized pairing step sequence.

[0186] The verification unit 600 is used to divide the preliminarily optimized sequence into multiple subsequences for cross-verification, adjust the interference factor weight in combination with historical connection data, and rearrange the step order, and generate a corrected pairing step sequence through multiple rounds of verification iteration optimization.

[0187] The scoring unit 700 is used to collect the average signal strength, pairing success rate, and interference factor fluctuation variance in multiple rounds of tests, 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 this strategy to complete the Bluetooth connection operation.

[0189] To verify the superiority of the Bluetooth connection method proposed by the present invention over the prior art, the experiment was carried out in a simulated environment. First, two devices supporting the Bluetooth 5.0 protocol were selected as the experimental objects, namely the source device and the headphone device. The source device selected was the Huawei P40 (mobile phone model, running Android 10 operating system, supporting Bluetooth 5.0), and the headphone device selected was the Sony WH-1000XM4 (Bluetooth headset, supporting Bluetooth 5.0). The experiment was tested separately in a normal environment, a weak signal environment, and a high interference environment.

[0190] Normal environment: The test was carried out in an ordinary indoor environment without any interference sources, simulating a common home or office environment.

[0191] Weak signal environment: By increasing the distance between the devices, a weak Bluetooth signal environment was simulated.

[0192] High interference environment: By introducing multiple Wi-Fi signals, microwave ovens and other devices, a high interference wireless environment was simulated, increasing the possible interference sources during the Bluetooth connection process.

[0193] In each environment, the source device and the headphone device were used for Bluetooth pairing. For the control group (prior art), the traditional Bluetooth pairing method was directly used, while the experimental group adopted the Bluetooth connection method proposed by the present invention.

[0194] Record data such as the success rate of each Bluetooth pairing, connection latency, signal strength fluctuation, and packet loss rate. In each test environment, conduct 30 pairing tests, collect and record the results.

[0195] During the experiment, all experimental data were monitored through the device's Bluetooth debugging tool to ensure data accuracy.

[0196] Through the above experimental steps, it is possible to compare the performance of different technical methods in different environments and verify the superiority of the method of the present invention.

[0197] The following is some data obtained through experiments. The experiments were conducted multiple times in normal and interference environments respectively. The pairing process of each experimental group was measured 30 times. The results are shown in the following table:

[0198] Table 1 30 Tests in Normal and Interference Environments

[0199]

[0200] The experimental data show that the method of the present invention has a higher pairing success rate compared to the prior art. In the simulated interference environment, the pairing success rate of the prior art drops to 85%, while the method of the present invention, through dynamic adjustment of the pairing steps and interference factor optimization, increases the pairing success rate to 98%. This gap indicates that the method of the present invention can more effectively cope with signal attenuation and interference problems in complex environments, thereby increasing the probability of successful pairing.

[0201] Looking at the data of the connection latency, the method of the present invention significantly reduces the time to complete the pairing. In the interference environment, the connection latency of the prior art is 3.5 seconds, while the method of the present invention, through optimizing the step sequence and real-time adjustment of the connection strategy, reduces the connection latency to 2.1 seconds, with an improvement of 40%. This result shows that the method of the present invention can complete the Bluetooth pairing process more efficiently, especially in complex wireless environments, reducing the delay caused by unnecessary steps and waiting times.

[0202] In the test of signal strength, the method of the present invention demonstrates stronger signal strength. The prior art performs poorly in environments with weak signal strength, while the method of the present invention, through dynamic adjustment of the Bluetooth transmission power and interference factor optimization, can maintain a relatively high signal strength, thereby improving the connection stability. The experimental data show that the signal strength of the method of the present invention has increased by 10 dBm, which has a significant effect on improving the connection stability and data transmission speed.

[0203] The experimental results of the packet loss rate also show that the method of the present invention can better cope with environmental interference during data transmission and reduce the packet loss phenomenon. 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 the Bluetooth frequency hopping sequence, the optimization of the interference factor, and the improvement of the signal strength, thus significantly reducing the packet loss phenomenon in data transmission.

[0204] Figure 6 It is a comparison chart of the connection delay and packet loss rate in the simulated environment during the experiment. The left chart shows the comparison of the connection delay in the normal environment, weak signal environment, and high interference environment. The experimental group is significantly lower than the control group, indicating that the method of the present invention can effectively reduce the connection delay. The right chart shows the comparison of the packet loss rate in different environments. The packet loss rate of the experimental group is much lower than that of the control group, proving that the method of the present invention has significant advantages in reducing packet loss.

[0205] Through the analysis of the experimental data and simulation diagrams, it can be concluded that the Bluetooth connection method proposed by the present invention shows significant advantages in key performance indicators such as pairing success rate, connection delay, signal strength, and packet loss rate compared with the prior art. Especially in a complex interference environment, the method of the present invention can effectively reduce pairing failures and connection delays, and improve the stability and efficiency of Bluetooth connections. Therefore, the method of the present invention has high practical value in practical applications and can significantly improve the connection performance between Bluetooth devices.

[0206] In the above embodiments of the present invention, the descriptions of each embodiment have their own emphases. For parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0207] In the several embodiments provided by the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the units or modules can be in an electrical or other form.

[0208] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0209] When the integrated unit is implemented in the form of 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. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs.

[0210] The foregoing are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.

Claims

1. A Bluetooth connection method, characterized in that: The steps include: Obtaining Bluetooth connection information of the headset, wherein the Bluetooth connection information includes a headset device identifier and a source device identifier; Based on the headset device identifier and the source device identifier, extracting corresponding multiple connection strategies from a preset Bluetooth connection database, each connection strategy including multiple Bluetooth pairing steps; For each Bluetooth pairing step in each connection strategy, calculate the relative position of device coordinates, signal strength range, and influence factors of known interference sources between each pair of steps; Perform data consistency verification for each Bluetooth pairing step, the data consistency verification includes building a three-dimensional verification matrix, comparing protocol data units, monitoring the matching degree of Bluetooth frequency hopping sequences, and dynamically adjusting the operation sequence according to the verification results; Calculate the comprehensive weight value of each step according to 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; The preliminary optimized sequence is divided into multiple subsequences for cross-validation, the interference factor weights are adjusted and the step order is rearranged in combination with historical connection data, and a revised pairing step sequence is generated through multiple rounds of validation and iterative optimization; The signal strength mean, pairing success rate and interference factor fluctuation variance in multiple rounds of tests were collected to construct a normalized fitness function and score each connection strategy; The connection strategy with the highest fitness function score is selected as the final target strategy, and the pairing step sequence of the strategy is executed to complete the Bluetooth connection operation.

2. The Bluetooth connection method according to claim 1, wherein: The connection strategy includes: Selecting a priority connection device group between the source device and the headphone device, wherein the selection is based on the historical connection stability of the device and the current environment status; Select communication frequency bands that minimize interference with known interference sources; Adjust Bluetooth transmission power based on real-time monitored signal strength; Perform cryptographic authentication based on device fingerprint and protocol handshake, and select the authentication method based on historical pairing information; Adjust the timing of pairing steps based on device idle time windows and connection queue lengths; When pairing fails, restart the step and optimize the parameters. If it fails multiple times, switch to a new strategy.

3. The Bluetooth connection method according to claim 1, wherein: Calculate the relative position of device coordinates, signal strength range, and influence factors of known interference sources between each pair of steps, including: The relative position of the device coordinates between steps is calculated using the three-dimensional coordinate difference algorithm: Among them, x i ,y i 、z i is the device coordinate of step i; x j ,y j 、z j is the device coordinate of step j; Calculate the signal strength range using the RF propagation model: Among them, P t is the transmission power, G r is the receiving gain, d is the device spacing, and λ is the wavelength; Calculate the interference source impact factor through the interference superposition model: Among them, I i,j represents the interference factor between pairing step i and pairing step j, A k represents the strength 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 according to claim 1, wherein: Methods for performing data consistency verification include: Based on the communication timestamp, signal strength fluctuation value and data packet type parameter 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; Extract the protocol data unit transmitted in the step, generate a hash value sequence corresponding to the data packet header field, compare it bit by bit with the standard hash template stored in the preset Bluetooth protocol specification library, and record the hash consistency rate; Capture the actual frequency distribution of the Bluetooth frequency hopping sequence in real time, and calculate 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 according to the Bluetooth MAC address and clock offset; When the hash consistency rate is lower than the first preset threshold and the frequency matching standard deviation exceeds the second preset threshold, the dynamic adjustment mechanism is triggered to rearrange the order of unfinished operations in the current step, prioritize the sub-operations with the highest protocol data unit verification pass rate, and mark the communication frequency band with the lowest frequency matching degree as a disabled interval.

5. The Bluetooth connection method according to claim 1, wherein: The method of calculating the comprehensive weight value of each step according to the signal strength, pairing success rate and interference risk value includes: For each Bluetooth pairing step, extract the signal strength average value in its historical connection record, the current real-time signal strength sampling value and the preset signal strength attenuation coefficient, and calculate the normalized signal strength index. The formula is: Among them, S real is the real-time signal strength, S hist is the historical mean, α is the attenuation coefficient, and σ is the environmental noise compensation value; The ratio of the number of successful pairing attempts in the step within a preset time period to the total number of attempts is obtained as the pairing success rate, and the interference risk value is calculated based on the interference source type, interference intensity and duration, where: R isk =Σ(I type ×I intensity ×T duration ) Among them, I type is the interference source type weight, I intensity is the strength coefficient, T duration is the duration of the disturbance; Set the weight coefficient W of 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 : 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 sum of the comprehensive weight values ​​is 1, and a weight distribution vector is generated.

6. The Bluetooth connection method according to claim 1, wherein: Prioritizing effective steps based on comprehensive weight values ​​and generating a preliminary optimized pairing step sequence includes the following steps: All steps in the same connection strategy are arranged in descending order according to the normalized comprehensive weight values, and the steps with weight values ​​higher than the preset effective threshold are selected as the effective step set; Traverse the valid step set and build a directed acyclic graph based on the device operation dependency between steps, where nodes represent steps and edges represent step execution order constraints; Generate an initial sequence according to the topological sorting result of the directed acyclic graph, and detect Bluetooth protocol switching conflicts of adjacent steps in the initial sequence. If there is a conflict, insert a protocol adaptation buffer step; Based on the weight distribution vector of the steps, the step segments whose continuous weight differences exceed the preset fluctuation threshold in the sequence are locally rearranged, and high-weight steps are preferentially concentrated in the time interval with the highest mean signal strength; The rearranged sequence is matched with the historical optimal sequence in the Bluetooth connection database for the longest common subsequence, and a dynamic priority enhancement mark is applied to the non-matching segment to generate a preliminary optimized pairing step sequence.

7. The Bluetooth connection method according to claim 1, wherein: Dividing the preliminary optimized sequence into multiple subsequences for cross-validation and generating a revised paired step sequence includes the following steps: Based on the protocol switching point and device operation type, the preliminary optimization sequence is divided into at least three consecutive subsequences, each of which contains 3-5 steps and covers the complete protocol interaction cycle; 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 delay and packet loss rate of the swapped subsequences, and calculate the cross-matching score; Extract interference scenario records matching the current device ID from the historical connection database, count the actual interference factor deviation values ​​of each step under the same interference source, and adjust the current interference factor weight according to the formula; Among them, 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, ∈ is the smoothing coefficient; Based on the adjusted interference factor weights, the steps of the subsequences with matching scores lower than the threshold in the cross-validation are reorganized, and a greedy algorithm is used to preferentially replace the positions of the steps with high interference risks while maintaining topological dependence. The reorganized subsequences are reassembled according to the original segmentation 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 spare steps in the historical optimal sequence are supplemented to generate a revised pairing step sequence.

8. The Bluetooth connection method according to claim 1, wherein: Constructing a normalized fitness function and scoring each connection strategy includes the following steps: Collect the mean signal strength μ of each connection strategy in multiple rounds of testing s , Pairing success rate P rate and the volatility variance of the interference factor Extract the extreme value of the corresponding indicator [μ max ,μ min ]、[P max ,P min ]、 Each indicator is normalized to its range, and the formula is: Among them, S′ represents the normalized signal strength index, μ max and μ min are the maximum and minimum signal strength values ​​in the historical optimal connection records, respectively; P′ represents the normalized pairing success rate index, and R′ represents the normalized interference stability index; Set signal strength weight W s ′, weight of pairing success rate W p ′, disturbance stability weight W r ′, calculate the fitness function value F according to the formula: F=(S′×W s ′)+(P′×W p ′)+(R′×W r ′) Take the weighted average of the fitness function values ​​of all test rounds under the same connection strategy, where the weight is the spectrum similarity coefficient between the test environment of each round and the current real-time environment, generate the final strategy score and arrange them in descending order.

9. A Bluetooth connection system, characterized in that: The following units are included: An acquiring unit, configured to acquire Bluetooth connection information of the headset, wherein the Bluetooth connection information includes a headset device identifier and a source device identifier; A database unit, configured to extract corresponding multiple connection strategies from a preset Bluetooth connection database based on the headset device identifier and the source device identifier, each connection strategy comprising multiple Bluetooth pairing steps; A calculation unit, for calculating the relative position of device coordinates, signal strength range and influence factors of known interference sources between each pair of steps of the Bluetooth pairing step in each connection strategy; A data consistency verification unit, used to perform data consistency verification on each Bluetooth pairing step, wherein the data consistency verification includes constructing a three-dimensional verification matrix, comparing protocol data units, monitoring the matching degree of Bluetooth frequency hopping sequences, and dynamically adjusting the operation sequence according to the verification results; A weight calculation unit, used to calculate the comprehensive weight value of each step according to 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; A verification unit, which is used to divide the preliminary optimization sequence into multiple subsequences for cross-validation, adjust the interference factor weights and rearrange the step sequence in combination with historical connection data, and generate a revised pairing step sequence through multiple rounds of verification and iterative optimization; The scoring unit is used to collect the mean signal strength, pairing success rate and interference factor fluctuation variance in multiple rounds of tests, construct a normalized fitness function and score each connection strategy; 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.

10. The Bluetooth connection system according to claim 9, characterized in that: The database unit is used to store Bluetooth connection information between different devices and its corresponding connection strategies; the data consistency verification unit is used to verify the Bluetooth pairing steps through real-time communication with the device 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 sort them according to the evaluation results; the verification unit is used to gradually improve the success rate and stability of Bluetooth connection by iteratively optimizing multiple rounds of cross-validation results.

Citation Information

Patent Citations

  • Connection method and system of Bluetooth earphone

    CN117715156A

  • Bluetooth earphone pairing system capable of automatically reducing noise, identifying and pairing

    CN118139211A

  • Bluetooth transmission speed test method and system

    CN118573610A

  • Bluetooth earphone automatic pairing method and device for multi-terminal switching

    CN119402935A

  • Method and system for automatic coupling of bluetooth devices

    US11638313B1

Cited By

  • Wireless communication management method and system based on synchronization of Bluetooth and WIFI

    CN120499836A

  • Wireless communication management method and system based on Bluetooth and WIFI synchronization

    CN120499836B

  • Method for optimizing secure communication of Bluetooth chip equipment

    CN121078415A

  • An optimization method for secure communication of a Bluetooth chip device

    CN121078415B

  • Data transmission method and device based on equipment reconnection mechanism

    CN121262643A